lol
1{ lib, stdenv, fetchFromGitHub, cmake
2, boost, python3, eigen, python3Packages
3, icestorm, trellis
4, llvmPackages
5
6, enableGui ? false
7, wrapQtAppsHook ? null
8, qtbase ? null
9, OpenGL ? null
10}:
11
12let
13 boostPython = boost.override { python = python3; enablePython = true; };
14in
15stdenv.mkDerivation rec {
16 pname = "nextpnr";
17 version = "0.4";
18
19 srcs = [
20 (fetchFromGitHub {
21 owner = "YosysHQ";
22 repo = "nextpnr";
23 rev = "${pname}-${version}";
24 hash = "sha256-gnNUFSV+/SzCuP43KyUUgVNdAzjOM7lOLNJT72L8lTY=";
25 name = "nextpnr";
26 })
27 (fetchFromGitHub {
28 owner = "YosysHQ";
29 repo = "nextpnr-tests";
30 rev = "00c55a9eb9ea2e062b51fe0d64741412b185d95d";
31 sha256 = "sha256-83suMftMtnaRFq3T2/I7Uahb11WZlXhwYt6Q/rqi2Yo=";
32 name = "nextpnr-tests";
33 })
34 ];
35
36 sourceRoot = "nextpnr";
37
38 nativeBuildInputs
39 = [ cmake ]
40 ++ (lib.optional enableGui wrapQtAppsHook);
41 buildInputs
42 = [ boostPython python3 eigen python3Packages.apycula ]
43 ++ (lib.optional enableGui qtbase)
44 ++ (lib.optional stdenv.cc.isClang llvmPackages.openmp);
45
46 cmakeFlags =
47 [ "-DCURRENT_GIT_VERSION=${lib.substring 0 7 (lib.elemAt srcs 0).rev}"
48 "-DARCH=generic;ice40;ecp5;gowin"
49 "-DBUILD_TESTS=ON"
50 "-DICESTORM_INSTALL_PREFIX=${icestorm}"
51 "-DTRELLIS_INSTALL_PREFIX=${trellis}"
52 "-DTRELLIS_LIBDIR=${trellis}/lib/trellis"
53 "-DGOWIN_BBA_EXECUTABLE=${python3Packages.apycula}/bin/gowin_bba"
54 "-DUSE_OPENMP=ON"
55 # warning: high RAM usage
56 "-DSERIALIZE_CHIPDBS=OFF"
57 ]
58 ++ (lib.optional enableGui "-DBUILD_GUI=ON")
59 ++ (lib.optional (enableGui && stdenv.isDarwin)
60 "-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks");
61
62 patchPhase = with builtins; ''
63 # use PyPy for icestorm if enabled
64 substituteInPlace ./ice40/CMakeLists.txt \
65 --replace ''\'''${PYTHON_EXECUTABLE}' '${icestorm.pythonInterp}'
66 '';
67
68 preBuild = ''
69 ln -s ../nextpnr-tests tests
70 '';
71
72 doCheck = true;
73
74 postFixup = lib.optionalString enableGui ''
75 wrapQtApp $out/bin/nextpnr-generic
76 wrapQtApp $out/bin/nextpnr-ice40
77 wrapQtApp $out/bin/nextpnr-ecp5
78 wrapQtApp $out/bin/nextpnr-gowin
79 '';
80
81 meta = with lib; {
82 description = "Place and route tool for FPGAs";
83 homepage = "https://github.com/yosyshq/nextpnr";
84 license = licenses.isc;
85 platforms = platforms.all;
86 maintainers = with maintainers; [ thoughtpolice emily ];
87 };
88}