1{ lib
2, buildPythonPackage
3, pythonOlder
4, fetchFromGitHub
5, pyvcd
6, bitarray
7, jinja2
8
9# nmigen.{test,build} call out to these
10, yosys
11, symbiyosys
12, nextpnr ? null
13, icestorm ? null
14, trellis ? null
15
16# for tests
17, yices
18}:
19
20buildPythonPackage rec {
21 pname = "nmigen";
22 version = "unstable-2019-08-31";
23 realVersion = lib.substring 0 7 src.rev;
24
25 src = fetchFromGitHub {
26 owner = "m-labs";
27 repo = "nmigen";
28 rev = "2e206220462c67aa6ae97f7515a2191440fd61b3";
29 sha256 = "0y3w6vd493jqm9b8ppgwzs02v1al8w1n5gylljlsw70ci7fyk4qa";
30 };
31
32 disabled = pythonOlder "3.6";
33
34 propagatedBuildInputs = [ pyvcd bitarray jinja2 ];
35
36 checkInputs = [ yosys yices ];
37
38 postPatch = let
39 tool = pkg: name:
40 if pkg == null then {} else { ${name} = "${pkg}/bin/${name}"; };
41
42 # Only FOSS toolchain supported out of the box, sorry!
43 toolchainOverrides =
44 tool yosys "yosys" //
45 tool symbiyosys "sby" //
46 tool nextpnr "nextpnr-ice40" //
47 tool nextpnr "nextpnr-ecp5" //
48 tool icestorm "icepack" //
49 tool trellis "ecppack";
50 in ''
51 substituteInPlace setup.py \
52 --replace 'versioneer.get_version()' '"${realVersion}"'
53
54 substituteInPlace nmigen/_toolchain.py \
55 --replace 'overrides = {}' \
56 'overrides = ${builtins.toJSON toolchainOverrides}'
57 '';
58
59 meta = with lib; {
60 description = "A refreshed Python toolbox for building complex digital hardware";
61 homepage = https://github.com/m-labs/nmigen;
62 license = licenses.bsd0;
63 maintainers = with maintainers; [ emily ];
64 };
65}