From 5eb008b52869c40286afa096879b706e76090f2d Mon Sep 17 00:00:00 2001 From: Mohamed Gaber Date: Sun, 20 Oct 2024 16:20:04 +0300 Subject: [PATCH] Update Nix Dependencies --- default.nix | 194 ++++++++++++++++++++++++----------------------- flake.lock | 158 +++----------------------------------- flake.nix | 93 ++++++++++++++++------- nix/atalanta.nix | 6 +- nix/podem.nix | 10 +-- requirements.txt | 2 +- 6 files changed, 181 insertions(+), 282 deletions(-) diff --git a/default.nix b/default.nix index c3d21f2..a7d2a54 100644 --- a/default.nix +++ b/default.nix @@ -9,105 +9,107 @@ yosys, verilog, quaigh, - nl2bench, ncurses, makeBinaryWrapper, -}: -let +}: let generated = swiftpm2nix.helpers ./nix; - pyenv = (python3.withPackages(ps: with ps; [pyverilog])); + pyenv = python3.withPackages (ps: with ps; [nl2bench pyverilog]); stdenv = swiftPackages.stdenv; in -stdenv.mkDerivation (finalAttrs: { - name = "fault"; - - src = nix-gitignore.gitignoreSourcePure ./.gitignore ./.; - - swiftpmFlags = [ - "--verbose" - ]; - # ++ lib.lists.optional swiftPackages.stdenv.isDarwin [ - # "-Xcc" - # "-mmacosx-version-min=11" - # "-Xcc" - # "-target" - # "-Xcc" - # "x86_64-apple-macosx11" - # "-Xswiftc" - # "-target" - # "-Xswiftc" - # "x86_64-apple-macosx11" - # ]; - nativeBuildInputs = [ swift swiftpm makeBinaryWrapper ]; - - buildInputs = with swiftPackages; [ - Foundation - XCTest - ] ++ lib.lists.optional (!stdenv.isDarwin) [Dispatch]; - - propagatedBuildInputs = [ - pyenv - yosys - verilog - quaigh - nl2bench - ]; - - nativeCheckInputs = with python3.pkgs; [ - pytest - ]; - - configurePhase = generated.configure; - - # This doesn't work on Linux otherwise and I don't know why. - preBuild = if stdenv.isDarwin then "" else '' - export LD_LIBRARY_PATH=${swiftPackages.Dispatch}/lib:$LD_LIBRARY_PATH - ''; - - doCheck = true; - - faultEnv = '' - export PYTHONPATH=${pyenv}/${pyenv.sitePackages} - export PATH=${verilog}/bin:$PATH - export PATH=${yosys}/bin:$PATH - export PYTHON_LIBRARY=${pyenv}/lib/lib${pyenv.libPrefix}${swiftPackages.stdenv.hostPlatform.extensions.sharedLibrary} - export FAULT_IVL_BASE=${verilog}/lib/ivl - ''; - - checkPhase = '' - runHook preCheck - ${finalAttrs.faultEnv} - PYTEST_FAULT_BIN="$(swiftpmBinPath)/fault" pytest - runHook postCheck - ''; + stdenv.mkDerivation (finalAttrs: { + name = "fault"; - installPhase = '' - runHook preInstall - binPath="$(swiftpmBinPath)" - mkdir -p $out/bin - cp $binPath/fault $out/bin/fault - ln -s ${nl2bench}/bin/nl2bench $out/bin/nl2bench - runHook postInstall - ''; - - fixupPhase = '' - runHook preFixup - wrapProgram $out/bin/fault\ - --prefix PYTHONPATH : ${pyenv}/${pyenv.sitePackages}\ - --prefix PATH : ${verilog}/bin\ - --prefix PATH : ${quaigh}/bin\ - --prefix PATH : ${yosys}/bin\ - --set PYTHON_LIBRARY ${pyenv}/lib/lib${pyenv.libPrefix}${swiftPackages.stdenv.hostPlatform.extensions.sharedLibrary}\ - --set FAULT_IVL_BASE ${verilog}/lib/ivl - runHook postFixup - ''; - - meta = with lib; { - description = "Open-source EDA's missing DFT toolchain"; - homepage = "https://github.com/AUCOHL/Fault"; - license = licenses.asl20; - platforms = platforms.linux ++ platforms.darwin; - }; - - shellHook = finalAttrs.faultEnv + finalAttrs.preBuild; -}) + src = nix-gitignore.gitignoreSourcePure ./.gitignore ./.; + + swiftpmFlags = [ + "--verbose" + ]; + # ++ lib.lists.optional swiftPackages.stdenv.isDarwin [ + # "-Xcc" + # "-mmacosx-version-min=11" + # "-Xcc" + # "-target" + # "-Xcc" + # "x86_64-apple-macosx11" + # "-Xswiftc" + # "-target" + # "-Xswiftc" + # "x86_64-apple-macosx11" + # ]; + nativeBuildInputs = [swift swiftpm makeBinaryWrapper]; + + buildInputs = with swiftPackages; + [ + Foundation + XCTest + ] + ++ lib.lists.optional (!stdenv.isDarwin) [Dispatch]; + + propagatedBuildInputs = [ + pyenv + yosys + verilog + quaigh + ]; + + nativeCheckInputs = with python3.pkgs; [ + pytest + ]; + + configurePhase = generated.configure; + + # This doesn't work on Linux otherwise and I don't know why. + preBuild = + if stdenv.isDarwin + then "" + else '' + export LD_LIBRARY_PATH=${swiftPackages.Dispatch}/lib:$LD_LIBRARY_PATH + ''; + + doCheck = true; + + faultEnv = '' + export PYTHONPATH=${pyenv}/${pyenv.sitePackages} + export PATH=${verilog}/bin:$PATH + export PATH=${yosys}/bin:$PATH + export PYTHON_LIBRARY=${pyenv}/lib/lib${pyenv.libPrefix}${swiftPackages.stdenv.hostPlatform.extensions.sharedLibrary} + export FAULT_IVL_BASE=${verilog}/lib/ivl + ''; + + checkPhase = '' + runHook preCheck + ${finalAttrs.faultEnv} + PYTEST_FAULT_BIN="$(swiftpmBinPath)/fault" pytest + runHook postCheck + ''; + + installPhase = '' + runHook preInstall + binPath="$(swiftpmBinPath)" + mkdir -p $out/bin + cp $binPath/fault $out/bin/fault + ln -s ${python3.pkgs.nl2bench}/bin/nl2bench $out/bin/nl2bench + runHook postInstall + ''; + + fixupPhase = '' + runHook preFixup + wrapProgram $out/bin/fault\ + --prefix PYTHONPATH : ${pyenv}/${pyenv.sitePackages}\ + --prefix PATH : ${verilog}/bin\ + --prefix PATH : ${quaigh}/bin\ + --prefix PATH : ${yosys}/bin\ + --set PYTHON_LIBRARY ${pyenv}/lib/lib${pyenv.libPrefix}${swiftPackages.stdenv.hostPlatform.extensions.sharedLibrary}\ + --set FAULT_IVL_BASE ${verilog}/lib/ivl + runHook postFixup + ''; + + meta = with lib; { + description = "Open-source EDA's missing DFT toolchain"; + homepage = "https://github.com/AUCOHL/Fault"; + license = licenses.asl20; + platforms = platforms.linux ++ platforms.darwin; + }; + + shellHook = finalAttrs.faultEnv + finalAttrs.preBuild; + }) diff --git a/flake.lock b/flake.lock index 21a46a4..9d57cda 100644 --- a/flake.lock +++ b/flake.lock @@ -5,7 +5,6 @@ "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": [ - "nl2bench", "quaigh", "nixpkgs" ], @@ -26,31 +25,6 @@ "type": "github" } }, - "cargo2nix_2": { - "inputs": { - "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_2", - "nixpkgs": [ - "quaigh", - "nixpkgs" - ], - "rust-overlay": "rust-overlay_2" - }, - "locked": { - "lastModified": 1705129117, - "narHash": "sha256-LgdDHibvimzYhxBK3kxCk2gAL7k4Hyigl5KI0X9cijA=", - "owner": "cargo2nix", - "repo": "cargo2nix", - "rev": "ae19a9e1f8f0880c088ea155ab66cee1fa001f59", - "type": "github" - }, - "original": { - "owner": "cargo2nix", - "ref": "release-0.11.0", - "repo": "cargo2nix", - "type": "github" - } - }, "flake-compat": { "flake": false, "locked": { @@ -67,22 +41,6 @@ "type": "github" } }, - "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-utils": { "inputs": { "systems": "systems" @@ -101,24 +59,6 @@ "type": "github" } }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "libparse": { "inputs": { "nixpkgs": [ @@ -146,11 +86,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1727685714, - "narHash": "sha256-WI7eCVT8fp4k6Iizky0UeFr/3vPnOat1P1gr+tLufRk=", + "lastModified": 1728905391, + "narHash": "sha256-iox9yGNG4MwSKhQuwegLcDW6wVGzfdBPrh8SrhSLA8c=", "owner": "efabless", "repo": "nix-eda", - "rev": "3fc4884a62cd3b62230ee90b9687f5aaebe98543", + "rev": "0814aa6c1c7d556aa08212cc875063cff62cb9b0", "type": "github" }, "original": { @@ -175,41 +115,26 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1717144377, - "narHash": "sha256-F/TKWETwB5RaR8owkPPi+SPJh83AQsm6KrQAlJ8v/uA=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "805a384895c696f802a9bf5bf4720f37385df547", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-24.05", - "repo": "nixpkgs", - "type": "github" - } - }, "nl2bench": { "inputs": { "libparse": "libparse", "nix-eda": [ "nix-eda" ], - "quaigh": "quaigh" + "quaigh": [ + "quaigh" + ] }, "locked": { - "lastModified": 1727695229, - "narHash": "sha256-WZUPoPKAilBWRfnRifMzwEXJePFuc2imN2XUNkGklRI=", + "lastModified": 1729429745, + "narHash": "sha256-dQgCxAcoEv1NTqSRpNGEE4NhNufc76Cyc3HDInqL2+0=", "owner": "donn", "repo": "nl2bench", - "rev": "179d8dfdf7c0843a54fbadaeed007586525e1d77", + "rev": "23d4e0954d56ec15a12bb27064501e93566ee8e7", "type": "github" }, "original": { "owner": "donn", - "ref": "pyosys", "repo": "nl2bench", "type": "github" } @@ -217,25 +142,6 @@ "quaigh": { "inputs": { "cargo2nix": "cargo2nix", - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1722162293, - "narHash": "sha256-WILtL6WKXs5pB5Jujx9HIT2w1jiVTZymXC7DTuqLPEM=", - "owner": "coloquinte", - "repo": "quaigh", - "rev": "2fec998178d4e48c5379dd0a2025f8688797f99a", - "type": "github" - }, - "original": { - "owner": "coloquinte", - "repo": "quaigh", - "type": "github" - } - }, - "quaigh_2": { - "inputs": { - "cargo2nix": "cargo2nix_2", "nixpkgs": [ "nix-eda", "nixpkgs" @@ -259,39 +165,10 @@ "inputs": { "nix-eda": "nix-eda", "nl2bench": "nl2bench", - "quaigh": "quaigh_2" + "quaigh": "quaigh" } }, "rust-overlay": { - "inputs": { - "flake-utils": [ - "nl2bench", - "quaigh", - "cargo2nix", - "flake-utils" - ], - "nixpkgs": [ - "nl2bench", - "quaigh", - "cargo2nix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1705112162, - "narHash": "sha256-IAM0+Uijh/fwlfoeDrOwau9MxcZW3zeDoUHc6Z3xfqM=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "9e0af26ffe52bf955ad5575888f093e41fba0104", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "rust-overlay_2": { "inputs": { "flake-utils": [ "quaigh", @@ -332,21 +209,6 @@ "repo": "default", "type": "github" } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index ee44167..f71a029 100644 --- a/flake.nix +++ b/flake.nix @@ -1,42 +1,77 @@ { inputs = { nix-eda.url = github:efabless/nix-eda; - nl2bench = { - url = github:donn/nl2bench/pyosys; - inputs.nix-eda.follows = "nix-eda"; - }; quaigh = { url = github:coloquinte/quaigh; inputs.nixpkgs.follows = "nix-eda/nixpkgs"; }; + nl2bench = { + url = github:donn/nl2bench; + inputs.nix-eda.follows = "nix-eda"; + inputs.quaigh.follows = "quaigh"; + }; }; - outputs = {self, nix-eda, quaigh, nl2bench, ...}: { - packages = nix-eda.forAllSystems { current = self; withInputs = [nix-eda quaigh nl2bench]; } (util: with util; rec{ - atalanta = callPackage ./nix/atalanta.nix {}; - podem = callPackage ./nix/podem.nix {}; - fault = callPackage ./default.nix {}; - default = fault; + outputs = { + self, + nix-eda, + quaigh, + nl2bench, + ... + }: let + nixpkgs = nix-eda.inputs.nixpkgs; + lib = nixpkgs.lib; + in { + overlays = { + default = lib.composeManyExtensions [ + (nix-eda.flakesToOverlay [quaigh]) + nl2bench.overlays.default + (pkgs': pkgs: let + callPackage = lib.callPackageWith pkgs'; + in { + atalanta = callPackage ./nix/atalanta.nix {}; + podem = callPackage ./nix/podem.nix {}; + fault = callPackage ./default.nix {}; + }) + ]; + }; + + legacyPackages = nix-eda.forAllSystems ( + system: + import nixpkgs { + inherit system; + overlays = [nix-eda.overlays.default self.overlays.default]; + } + ); + + packages = nix-eda.forAllSystems (system: { + inherit (self.legacyPackages.${system}) atalanta podem fault; + default = self.packages.${system}.fault; }); - - devShells = nix-eda.forAllSystems { withInputs = [nix-eda quaigh nl2bench self]; } (util: with util; rec { - mac-testing = pkgs.stdenvNoCC.mkDerivation (with pkgs; let - pyenv = (python3.withPackages(ps: with ps; [pyverilog pyyaml pytest pkgs.nl2bench])); + + devShells = nix-eda.forAllSystems ( + system: let + pkgs = self.legacyPackages."${system}"; + callPackage = lib.callPackageWith pkgs; in { - # Use the host's Clang and Swift - name = "shell"; - buildInputs = [ - yosys - verilog - pkgs.quaigh - pyenv - gtkwave - ]; - - PYTHON_LIBRARY="${pyenv}/lib/lib${python3.libPrefix}${stdenvNoCC.hostPlatform.extensions.sharedLibrary}"; - PYTHONPATH="${pyenv}/${pyenv.sitePackages}"; - FAULT_IVL_BASE="${verilog}/lib/ivl"; - }); - }); + mac-testing = pkgs.stdenvNoCC.mkDerivation (with pkgs; let + pyenv = python3.withPackages (ps: with ps; [pyverilog pyyaml pytest nl2bench]); + in { + # Use the host's Clang and Swift + name = "shell"; + buildInputs = [ + yosys + verilog + pkgs.quaigh + pyenv + gtkwave + ]; + + PYTHON_LIBRARY = "${pyenv}/lib/lib${python3.libPrefix}${stdenvNoCC.hostPlatform.extensions.sharedLibrary}"; + PYTHONPATH = "${pyenv}/${pyenv.sitePackages}"; + FAULT_IVL_BASE = "${verilog}/lib/ivl"; + }); + } + ); }; } diff --git a/nix/atalanta.nix b/nix/atalanta.nix index 612af38..c4bd39c 100644 --- a/nix/atalanta.nix +++ b/nix/atalanta.nix @@ -6,19 +6,19 @@ gccStdenv.mkDerivation { pname = "atalanta"; version = "2.0+"; - + src = fetchFromGitHub { owner = "hsluoyz"; repo = "atalanta"; rev = "a8e07fe4af80c55b0d4ca77e382731b03ad731dc"; sha256 = "sha256-e/E9qSPc0Pb+kLE8k169dXtAatCy8qUKHi5nNef5VUE="; }; - + installPhase = '' mkdir -p $out/bin cp atalanta $out/bin ''; - + meta = with lib; { description = "A modified ATPG (Automatic Test Pattern Generation) tool and fault simulator, orginally from VirginiaTech University."; homepage = "https://github.com/hsluoyz/Atalanta"; diff --git a/nix/podem.nix b/nix/podem.nix index 745eab9..791be30 100644 --- a/nix/podem.nix +++ b/nix/podem.nix @@ -6,27 +6,27 @@ gccStdenv.mkDerivation { name = "nctu-ee-podem"; version = "0.1.0"; - + src = fetchFromGitHub { owner = "donn"; repo = "VLSI-Testing"; rev = "ff82db776521b294d79d54acc00b7b6eaaa5846d"; sha256 = "sha256-Nj8hQb9XlRjIIrfht8VNEfORmwtb+WWrP6UVlWgo81A="; }; - + postPatch = '' sed -i 's/^LIBS.*/LIBS = /' podem/Makefile ''; - + buildPhase = '' make -C podem ''; - + installPhase = '' mkdir -p $out/bin cp podem/atpg $out/bin/atpg-podem ''; - + meta = with lib; { description = "A C++ implementation of PODEM used in the testing course of the NCTU EE program"; homepage = "https://github.com/cylinbao/VLSI-Testing"; diff --git a/requirements.txt b/requirements.txt index c994428..e73d785 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ pyverilog -nl2bench +nl2bench>=0.5.0