From 61b00afc45534ef77647497a43f9b9f5ecb79888 Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Sun, 3 Aug 2025 14:16:48 +0200 Subject: [PATCH 1/2] icestorm: 2020.12.04 -> 0-unstable-2025-06-03 The patches are no longer needed due to added upstream support for specifying the Python interpreter and for non-standard $PREFIX installation. --- pkgs/by-name/ic/icestorm/package.nix | 31 +++++++++++++--------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/pkgs/by-name/ic/icestorm/package.nix b/pkgs/by-name/ic/icestorm/package.nix index 2e443636247e..82b1a999edd3 100644 --- a/pkgs/by-name/ic/icestorm/package.nix +++ b/pkgs/by-name/ic/icestorm/package.nix @@ -20,7 +20,7 @@ stdenv.mkDerivation rec { pname = "icestorm"; - version = "2020.12.04"; + version = "0-unstable-2025-06-03"; passthru = rec { pythonPkg = if (false && usePyPy) then pypy3 else python3; @@ -30,8 +30,8 @@ stdenv.mkDerivation rec { src = fetchFromGitHub { owner = "YosysHQ"; repo = "icestorm"; - rev = "7afc64b480212c9ac2ce7cb1622731a69a7d212c"; - sha256 = "0vxhqs2fampglg3xlfwb35229iv96kvlwp1gyxrdrmlpznhkqdrk"; + rev = "f31c39cc2eadd0ab7f29f34becba1348ae9f8721"; + hash = "sha256-SLSxqgVsYMUxv8YjY1iRLnVFiIAhk/GKmZr4Ido0A3o="; }; nativeBuildInputs = [ pkg-config ]; @@ -39,27 +39,24 @@ stdenv.mkDerivation rec { passthru.pythonPkg libftdi1 ]; - makeFlags = [ "PREFIX=$(out)" ]; + makeFlags = [ + "PREFIX=$(out)" + "PYTHON3=${passthru.pythonInterp}" + ]; enableParallelBuilding = true; - # 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 + # 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 "${passthru.pythonInterp}" - done - - for x in $(find . -type f -iname '*.py'); do + for x in $(find . -type f -iname '*.py' -executable); do substituteInPlace "$x" \ - --replace '/usr/bin/env python3' '${passthru.pythonInterp}' + --replace-fail '/usr/bin/env python3' '${passthru.pythonInterp}' done + + # We use GNU sed on Darwin, while icebox/Makefile assumed BSD sed (which + # requires a (potentially empty) argument for the -i flag). + substituteInPlace icebox/Makefile --replace-fail "sed -i '''" "sed -i" ''; meta = { From bffa59d5bc778bf9850d21259a521550fc7bfda5 Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Mon, 4 Aug 2025 09:35:30 +0200 Subject: [PATCH 2/2] icestorm: add examples as integration tests --- pkgs/by-name/ic/icestorm/package.nix | 16 ++++++++++----- pkgs/by-name/ic/icestorm/tests.nix | 29 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 pkgs/by-name/ic/icestorm/tests.nix diff --git a/pkgs/by-name/ic/icestorm/package.nix b/pkgs/by-name/ic/icestorm/package.nix index 82b1a999edd3..f0ebd58a71aa 100644 --- a/pkgs/by-name/ic/icestorm/package.nix +++ b/pkgs/by-name/ic/icestorm/package.nix @@ -1,6 +1,7 @@ { lib, stdenv, + callPackage, fetchFromGitHub, pkg-config, libftdi1, @@ -18,13 +19,18 @@ usePyPy ? stdenv.hostPlatform.system == "x86_64-linux", }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "icestorm"; version = "0-unstable-2025-06-03"; passthru = rec { pythonPkg = if (false && usePyPy) then pypy3 else python3; pythonInterp = pythonPkg.interpreter; + + tests.examples = callPackage ./tests.nix { + inherit (finalAttrs) pname src; + icestorm = finalAttrs.finalPackage; + }; }; src = fetchFromGitHub { @@ -36,12 +42,12 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ pkg-config ]; buildInputs = [ - passthru.pythonPkg + finalAttrs.passthru.pythonPkg libftdi1 ]; makeFlags = [ "PREFIX=$(out)" - "PYTHON3=${passthru.pythonInterp}" + "PYTHON3=${finalAttrs.passthru.pythonInterp}" ]; enableParallelBuilding = true; @@ -51,7 +57,7 @@ stdenv.mkDerivation rec { patchPhase = '' for x in $(find . -type f -iname '*.py' -executable); do substituteInPlace "$x" \ - --replace-fail '/usr/bin/env python3' '${passthru.pythonInterp}' + --replace-fail '/usr/bin/env python3' '${finalAttrs.passthru.pythonInterp}' done # We use GNU sed on Darwin, while icebox/Makefile assumed BSD sed (which @@ -75,4 +81,4 @@ stdenv.mkDerivation rec { ]; platforms = lib.platforms.all; }; -} +}) diff --git a/pkgs/by-name/ic/icestorm/tests.nix b/pkgs/by-name/ic/icestorm/tests.nix new file mode 100644 index 000000000000..c7e89a87171e --- /dev/null +++ b/pkgs/by-name/ic/icestorm/tests.nix @@ -0,0 +1,29 @@ +# Run the examples from $src/examples/ as simple integration tests. They require +# yosys and nextpnr (which itself depends on this package), so they cannot be +# ran during the check phase. +{ + runCommand, + icestorm, + nextpnr, + yosys, + + pname, + src, +}: + +runCommand "${pname}-test-examples" + { + nativeBuildInputs = [ + icestorm + nextpnr + yosys + ]; + } + '' + cp -r ${src}/examples . + chmod -R +w examples + for example in examples/*; do + make -C $example + done + touch $out + ''