aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/development/python-modules/nmigen/default.nix
blob: 02569e0a81bfae24a7abfd31a5290b13a4c65ef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ lib
, buildPythonPackage
, pythonOlder
, fetchFromGitHub
, setuptools
, setuptools_scm
, pyvcd
, bitarray
, jinja2

# nmigen.{test,build} call out to these
, yosys
, symbiyosys
, nextpnr ? null
, icestorm ? null
, trellis ? null

# for tests
, yices
}:

buildPythonPackage rec {
  pname = "nmigen";
  version = "unstable-2019-09-28";
  # python setup.py --version
  realVersion = "0.1.dev689+g${lib.substring 0 7 src.rev}";

  src = fetchFromGitHub {
    owner = "m-labs";
    repo = "nmigen";
    rev = "a02e3750bfeba44bcaad4c5de8d9eb0ef055d9c6";
    sha256 = "0m399c2nm7y54q2f0fbkmi4h35csbc2llckm6k9kqdf5qc6355wd";
  };

  disabled = pythonOlder "3.6";

  nativeBuildInputs = [ setuptools_scm ];

  propagatedBuildInputs = [ setuptools pyvcd bitarray jinja2 ];

  checkInputs = [ yosys yices ];

  postPatch = let
    tool = pkg: name:
      if pkg == null then {} else { ${name} = "${pkg}/bin/${name}"; };

    # Only FOSS toolchain supported out of the box, sorry!
    toolchainOverrides =
      tool yosys "yosys" //
      tool symbiyosys "sby" //
      tool nextpnr "nextpnr-ice40" //
      tool nextpnr "nextpnr-ecp5" //
      tool icestorm "icepack" //
      tool trellis "ecppack";
  in ''
    substituteInPlace nmigen/_toolchain.py \
      --replace 'overrides = {}' \
                'overrides = ${builtins.toJSON toolchainOverrides}'
  '';

  preBuild = ''
    export SETUPTOOLS_SCM_PRETEND_VERSION="${realVersion}"
  '';

  meta = with lib; {
    description = "A refreshed Python toolbox for building complex digital hardware";
    homepage = https://github.com/m-labs/nmigen;
    license = licenses.bsd0;
    maintainers = with maintainers; [ emily ];
  };
}