-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libresoc: centralize existing packages, fix bitrot, and enable all te…
…st suites (#168) Signed-off-by: Jack Leightcap <jack@leightcap.com> Co-authored-by: Las Safin <me@las.rs> Co-authored-by: Albert Chae <albertchae@users.noreply.github.com>
- Loading branch information
1 parent
6e622a0
commit 3af73ed
Showing
23 changed files
with
866 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
lib, | ||
python39Packages, | ||
fetchPypi, | ||
mpfr, | ||
}: | ||
python39Packages.buildPythonPackage rec { | ||
pname = "bigfloat"; | ||
version = "0.4.0"; | ||
|
||
src = fetchPypi { | ||
inherit pname version; | ||
hash = "sha256-WLlr3ocqylmJ0T2C66Os8qoblOIhF91yoWulkRsMDLg="; | ||
}; | ||
|
||
propagatedBuildInputs = [mpfr] ++ (with python39Packages; [six]); | ||
|
||
meta = { | ||
description = "Arbitrary-precision correctly-rounded floating-point arithmetic, via MPFR."; | ||
homepage = "http://github.com/mdickinson/bigfloat"; | ||
license = lib.licenses.lgpl3; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
lib, | ||
python39Packages, | ||
fetchFromLibresoc, | ||
bigfloat, | ||
sfpy, | ||
symbiyosys, | ||
nmutil, | ||
nmigen, | ||
pytest-output-to-files, | ||
}: | ||
python39Packages.buildPythonPackage rec { | ||
pname = "ieee754fpu"; | ||
version = "unstable-2024-03-31"; | ||
|
||
src = fetchFromLibresoc { | ||
inherit pname; | ||
hash = "sha256-Ghbvg2Y4YlmxVEa3EtcvEVai4hC4VU4q+XIQh4pQ7+c="; | ||
rev = "829dfbc53ba38ec17bc544cb0b862e73cee223db"; # HEAD @ version date | ||
}; | ||
|
||
prePatch = '' | ||
touch ./src/ieee754/part{,_ass,_cat,_repl}/__init__.py | ||
''; | ||
|
||
propagatedBuildInputs = [nmutil]; | ||
|
||
nativeCheckInputs = | ||
[pytest-output-to-files nmigen symbiyosys sfpy bigfloat] | ||
++ (with python39Packages; [pytestCheckHook pytest-xdist]); | ||
|
||
disabledTests = [ | ||
"test_fadd_f16_rna_formal" | ||
"test_fadd_f16_rne_formal" | ||
"test_fadd_f16_rtn_formal" | ||
"test_fadd_f16_rton_formal" | ||
"test_fadd_f16_rtop_formal" | ||
"test_fadd_f16_rtp_formal" | ||
"test_fadd_f16_rtz_formal" | ||
"test_fmadd_f8_rna_formal" | ||
"test_fmadd_f8_rne_formal" | ||
"test_fmadd_f8_rtn_formal" | ||
"test_fmadd_f8_rton_formal" | ||
"test_fmadd_f8_rtop_formal" | ||
"test_fmadd_f8_rtp_formal" | ||
"test_fmadd_f8_rtz_formal" | ||
"test_fmsub_f8_rna_formal" | ||
"test_fmsub_f8_rne_formal" | ||
"test_fmsub_f8_rtn_formal" | ||
"test_fmsub_f8_rton_formal" | ||
"test_fmsub_f8_rtop_formal" | ||
"test_fmsub_f8_rtp_formal" | ||
"test_fmsub_f8_rtz_formal" | ||
"test_fnmadd_f8_rna_formal" | ||
"test_fnmadd_f8_rne_formal" | ||
"test_fnmadd_f8_rtn_formal" | ||
"test_fnmadd_f8_rton_formal" | ||
"test_fnmadd_f8_rtop_formal" | ||
"test_fnmadd_f8_rtp_formal" | ||
"test_fnmadd_f8_rtz_formal" | ||
"test_fnmsub_f8_rna_formal" | ||
"test_fnmsub_f8_rne_formal" | ||
"test_fnmsub_f8_rtn_formal" | ||
"test_fnmsub_f8_rton_formal" | ||
"test_fnmsub_f8_rtop_formal" | ||
"test_fnmsub_f8_rtp_formal" | ||
"test_fnmsub_f8_rtz_formal" | ||
"test_fsub_f16_rna_formal" | ||
"test_fsub_f16_rne_formal" | ||
"test_fsub_f16_rtn_formal" | ||
"test_fsub_f16_rton_formal" | ||
"test_fsub_f16_rtop_formal" | ||
"test_fsub_f16_rtp_formal" | ||
"test_fsub_f16_rtz_formal" | ||
]; | ||
|
||
pythonImportsCheck = ["ieee754.part"]; | ||
|
||
meta = { | ||
description = "A nmigen (HDL) IEEE754 Floating-Point library"; | ||
homepage = "https://git.libre-soc.org/?p=ieee754fpu.git;a=summary"; | ||
license = lib.licenses.gpl3Plus; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{fetchgit}: { | ||
# given recent poor availability of upstream https://git.libre-soc.org/, | ||
# define a dedicated fetcher for current mirror source | ||
# (currently github.com/Libre-SOC-mirrors, cc @jleightcap @albertchae) | ||
fetchFromLibresoc = { | ||
pname, | ||
hash, | ||
rev, | ||
fetchSubmodules ? true, | ||
}: | ||
fetchgit { | ||
url = "https://github.com/Libre-SOC-mirrors/${pname}.git"; | ||
inherit rev hash fetchSubmodules; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
lib, | ||
fetchFromLibresoc, | ||
python39, | ||
python39Packages, | ||
nmigen-soc, | ||
nmigen, | ||
}: | ||
python39Packages.buildPythonPackage rec { | ||
pname = "c4m-jtag"; | ||
version = "unstable-2024-03-31"; | ||
realVersion = "0.3.dev243+g${lib.substring 0 7 src.rev}"; | ||
|
||
src = fetchFromLibresoc { | ||
inherit pname; | ||
rev = "f5322d804e8228a2a5715c77185c60148ff96da8"; # HEAD @ version date | ||
hash = "sha256-0yF/yqcknCq1fre5pnKux4V7guu2oDa6duPO9mU46n8=3"; | ||
}; | ||
|
||
prePatch = '' | ||
export SETUPTOOLS_SCM_PRETEND_VERSION="${realVersion}" | ||
''; | ||
|
||
nativeBuildInputs = with python39Packages; [setuptools-scm]; | ||
propagatedBuildInputs = [nmigen-soc]; | ||
|
||
nativeCheckInputs = with python39Packages; [nose]; | ||
checkPhase = "nosetests"; | ||
|
||
pythonImportsCheck = ["c4m.nmigen.jtag.tap"]; | ||
|
||
meta = { | ||
description = "Chip4Makers nmigen JTAG implementation"; | ||
homepage = "https://git.libre-soc.org/?p=c4m-jtag.git;a=summary"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
lib, | ||
python39Packages, | ||
fetchFromGitHub, | ||
}: | ||
python39Packages.pyelftools.overrideAttrs (_: rec { | ||
name = "pyelftools"; | ||
version = "unstable-2024-03-31"; | ||
|
||
# upstream Libre-SOC uses a mirror, | ||
# and while this would be best handled as github.com/Libre-SOC-mirrors copy, | ||
# an included GitHub workflow interferes with the automated mirror. | ||
# instead, | ||
src = fetchFromGitHub { | ||
owner = "eliben"; | ||
repo = name; | ||
rev = "8b97f5da6838791fd5c6b47b1623fb414daed2f0"; | ||
hash = "sha256-E+grMrl0NJMl+yUzRyzTVIb/MjMOUOgq6YynGJhnMZg="; | ||
}; | ||
|
||
meta = { | ||
description = "Library for analyzing ELF files and DWARF debugging information"; | ||
homepage = "https://git.libre-soc.org/?p=pyelftools.git;a=summary"; | ||
license = lib.licenses.unlicense; | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
lib, | ||
python39Packages, | ||
fetchPypi, | ||
}: | ||
python39Packages.buildPythonPackage rec { | ||
pname = "mdis"; | ||
version = "0.5.1"; | ||
|
||
src = fetchPypi { | ||
inherit pname version; | ||
sha256 = "sha256-gvXtP8NO5XPDAs0XMbGknG79FscN/7lxqmF1kg3nhxg="; | ||
}; | ||
|
||
meta = { | ||
description = "Python dispatching library"; | ||
homepage = "https://git.libre-soc.org/?p=mdis.git"; | ||
license = lib.licenses.bsd3; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
lib, | ||
python39Packages, | ||
fetchFromGitLab, | ||
nmigen, | ||
}: | ||
python39Packages.buildPythonPackage rec { | ||
pname = "nmigen-soc"; | ||
version = "unstable-2024-03-31"; | ||
# python setup.py --version | ||
realVersion = "0.1.dev243+g${lib.substring 0 7 src.rev}"; | ||
|
||
# NOTE(jleightcap): libresoc's nmigen-soc fork has been renamed to https://github.com/amaranth-lang/amaranth-soc. | ||
# suffers from the same rename issue as the previous commit with renaming issue as nmigen/amaranth | ||
# NOTE(jleightcap): while libre-soc project does have local forks of nmigen* projects, | ||
# HEADs of repos are incompatible. | ||
# dev-env-setup implies that these forks are unused in build process, so using upstream. | ||
src = fetchFromGitLab { | ||
owner = "nmigen"; | ||
repo = "nmigen-soc"; | ||
hash = "sha256-RI481chXiD9kP/6vNLzYGOfcbwHH0Cvhk+CgloCY9JU="; | ||
rev = "fd2aaa336283cff2e46f489bf3897780cd217b8b"; # HEAD @ version date | ||
}; | ||
|
||
nativeBuildInputs = with python39Packages; [setuptools-scm]; | ||
propagatedBuildInputs = with python39Packages; [nmigen setuptools]; | ||
|
||
preBuild = '' | ||
export SETUPTOOLS_SCM_PRETEND_VERSION="${realVersion}" | ||
''; | ||
|
||
nativeCheckInputs = with python39Packages; [pytestCheckHook]; | ||
|
||
meta = { | ||
description = "Python toolbox for building complex digital hardware"; | ||
license = lib.licenses.bsd3; | ||
homepage = "https://git.libre-soc.org/?p=nmigen.git;a=summary"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
lib, | ||
fetchFromGitLab, | ||
git, | ||
python39Packages, | ||
symbiyosys, | ||
yices, | ||
yosys, | ||
}: | ||
python39Packages.buildPythonPackage rec { | ||
pname = "nmigen"; | ||
version = "unstable-2024-03-31"; | ||
realVersion = "0.3.dev243+g${lib.substring 0 7 src.rev}"; | ||
|
||
# libresoc's nmigen fork has been renamed to https://github.com/amaranth-lang/amaranth | ||
# amaranth is packaged in nixpkgs but we can't just override a few of the attributes the way we did for pyelftools, | ||
# because the names are different, so much of this is copied from the amaranth build recipe | ||
src = fetchFromGitLab { | ||
owner = "nmigen"; | ||
repo = "nmigen"; | ||
hash = "sha256-tpcA+FFHhm4gF37Z+rB/uZopSRtAtNxU8j5IXnSGeCg="; | ||
rev = "29dec30f628356828aa2aa2b91ce205a570d664e"; # HEAD @ version date | ||
}; | ||
|
||
preBuild = '' | ||
export SETUPTOOLS_SCM_PRETEND_VERSION="${realVersion}" | ||
''; | ||
|
||
nativeBuildInputs = [git] ++ (with python39Packages; [setuptools-scm]); | ||
|
||
propagatedBuildInputs = | ||
[yosys] | ||
++ (with python39Packages; [ | ||
jinja2 | ||
pyvcd | ||
]); | ||
|
||
nativeCheckInputs = | ||
[ | ||
symbiyosys | ||
yices | ||
yosys | ||
] | ||
++ (with python39Packages; [pytestCheckHook]); | ||
|
||
# TODO: upstream nixpkgs Amaranth package uses a patch for Python >3.8 compatibility in setuptools: | ||
# https://github.com/amaranth-lang/amaranth/commit/64771a065a280fa683c1e6692383bec4f59f20fa.patch | ||
# without this upgraded version, the C/C++ compiler used in tests via setuptools.distutils.ccompiler breaks. | ||
# Given the pre-fork nmigen release being used in Libre-SOC, this patch isn't directly portable to this package, | ||
# so disabling the test suite for now. | ||
doCheck = false; | ||
|
||
meta = { | ||
description = "Python toolbox for building complex digital hardware"; | ||
homepage = "https://git.libre-soc.org/?p=nmigen.git;a=summary"; | ||
license = lib.licenses.mit; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
lib, | ||
fetchFromLibresoc, | ||
python39Packages, | ||
symbiyosys, | ||
yices, | ||
nmigen, | ||
pytest-output-to-files, | ||
}: | ||
python39Packages.buildPythonPackage rec { | ||
pname = "libresoc-nmutil"; # Libre-SOC's bespoke fork | ||
version = "unstable-2024-03-31"; | ||
|
||
src = fetchFromLibresoc { | ||
pname = "nmutil"; | ||
rev = "4bf2f20bddc057df1597d14e0b990c0b9bdeb10e"; # HEAD @ version date | ||
hash = "sha256-8jXQGO4IeB6WjGtjuHO8UBh9n3ei7LukmRoXSbNJ1vM="; | ||
}; | ||
|
||
propagatedNativeBuildInputs = | ||
[ | ||
symbiyosys | ||
yices | ||
] | ||
++ (with python39Packages; [ | ||
pyvcd | ||
]); | ||
|
||
nativeCheckInputs = | ||
[ | ||
nmigen | ||
symbiyosys | ||
yices | ||
] | ||
++ (with python39Packages; [ | ||
pytestCheckHook | ||
pytest-xdist | ||
pytest-output-to-files | ||
]); | ||
|
||
pythonImportsCheck = ["nmutil"]; | ||
|
||
meta = { | ||
description = "A nmigen utility library"; | ||
homepage = "https://git.libre-soc.org/?p=nmutil.git;a=summary"; | ||
license = lib.licenses.lgpl3Plus; | ||
}; | ||
} |
Oops, something went wrong.