nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, buildPythonPackage
3, pythonOlder
4, fetchFromGitHub
5, setuptools
6, setuptools-scm
7, pyvcd
8, jinja2
9, importlib-resources
10, importlib-metadata
11, git
12
13# for tests
14, pytestCheckHook
15, symbiyosys
16, yices
17, yosys
18}:
19
20buildPythonPackage rec {
21 pname = "amaranth";
22 version = "0.3";
23 # python setup.py --version
24 realVersion = "0.3";
25 disabled = pythonOlder "3.6";
26
27 src = fetchFromGitHub {
28 owner = "amaranth-lang";
29 repo = "amaranth";
30 rev = "39a83f4d995d16364cc9b99da646ff8db6394166";
31 sha256 = "P9AG3t30eGeeCN5+t7mjhRoOWIGZVzWQji9eYXphjA0=";
32 };
33
34 SETUPTOOLS_SCM_PRETEND_VERSION="${realVersion}";
35
36 nativeBuildInputs = [
37 git
38 setuptools-scm
39 ];
40
41 propagatedBuildInputs = [
42 jinja2
43 pyvcd
44 setuptools
45 ] ++
46 lib.optional (pythonOlder "3.9") importlib-resources ++
47 lib.optional (pythonOlder "3.8") importlib-metadata;
48
49 checkInputs = [
50 pytestCheckHook
51 symbiyosys
52 yices
53 yosys
54 ];
55
56 postPatch = ''
57 substituteInPlace setup.py \
58 --replace "Jinja2~=2.11" "Jinja2>=2.11" \
59 --replace "pyvcd~=0.2.2" "pyvcd"
60
61 # jinja2.contextfunction was removed in jinja2 v3.1
62 substituteInPlace amaranth/build/plat.py \
63 --replace "@jinja2.contextfunction" "@jinja2.pass_context"
64 '';
65
66 pythonImportsCheck = [ "amaranth" ];
67
68 meta = with lib; {
69 description = "A modern hardware definition language and toolchain based on Python";
70 homepage = "https://amaranth-lang.org/docs/amaranth";
71 license = licenses.bsd2;
72 maintainers = with maintainers; [ emily thoughtpolice ];
73 };
74}