diff --git a/pkgs/development/tools/icestorm/default.nix b/pkgs/development/tools/icestorm/default.nix index 68e217f9aabb..64bec03eb4a0 100644 --- a/pkgs/development/tools/icestorm/default.nix +++ b/pkgs/development/tools/icestorm/default.nix @@ -1,4 +1,13 @@ -{ stdenv, fetchFromGitHub, python3, libftdi, pkgconfig }: +{ stdenv, fetchFromGitHub +, pkgconfig, libftdi +, python3, pypy3 +}: + +let + pypyCompatible = stdenv.isx86_64; /* pypy3 seems broken on i686 */ + pythonPkg = if pypyCompatible then pypy3 else python3; + pythonInterp = if pypyCompatible then "pypy3" else "python3"; +in stdenv.mkDerivation rec { name = "icestorm-${version}"; @@ -12,14 +21,26 @@ stdenv.mkDerivation rec { }; nativeBuildInputs = [ pkgconfig ]; - buildInputs = [ python3 libftdi ]; + buildInputs = [ pythonPkg libftdi ]; makeFlags = [ "PREFIX=$(out)" ]; # fix icebox_vlog chipdb path. icestorm issue: # https://github.com/cliffordwolf/icestorm/issues/125 + # + # also, fix up the path to the chosen Python interpreter. for pypy-compatible + # platforms, it offers significant performance improvements. patchPhase = '' substituteInPlace ./icebox/icebox_vlog.py \ --replace /usr/local/share "$out/share" + + for x in icefuzz/Makefile icebox/Makefile icetime/Makefile; do + substituteInPlace "$x" --replace python3 "${pythonInterp}" + done + + for x in $(find . -type f -iname '*.py'); do + substituteInPlace "$x" \ + --replace '/usr/bin/env python3' '${pythonPkg}/bin/${pythonInterp}' + done ''; meta = { @@ -30,9 +51,9 @@ stdenv.mkDerivation rec { FPGAs and providing simple tools for analyzing and creating bitstream files. ''; - homepage = http://www.clifford.at/icestorm/; - license = stdenv.lib.licenses.isc; + homepage = http://www.clifford.at/icestorm/; + license = stdenv.lib.licenses.isc; maintainers = with stdenv.lib.maintainers; [ shell thoughtpolice ]; - platforms = stdenv.lib.platforms.linux; + platforms = stdenv.lib.platforms.linux; }; }