From 600723e5c538ed1f3f42f3ebd5ccffd8fa92ca0c Mon Sep 17 00:00:00 2001 From: mole99 Date: Thu, 7 Nov 2024 10:41:30 +0100 Subject: [PATCH 1/3] Update nix-eda, use composable overlays --- default.nix | 2 - flake.lock | 19 +++--- flake.nix | 152 ++++++++++++++++++++++++++++--------------- nix/colab-env.nix | 3 +- nix/create-shell.nix | 10 ++- 5 files changed, 113 insertions(+), 73 deletions(-) diff --git a/default.nix b/default.nix index 6785039..d9ff899 100644 --- a/default.nix +++ b/default.nix @@ -23,7 +23,6 @@ magic-vlsi, netgen, volare, - octave, xschem, ngspice, @@ -69,7 +68,6 @@ klayout-gdsfactory magic-vlsi netgen - octave ngspice xschem ]; diff --git a/flake.lock b/flake.lock index ac6bfc1..16c7a92 100644 --- a/flake.lock +++ b/flake.lock @@ -8,11 +8,11 @@ ] }, "locked": { - "lastModified": 1722113426, - "narHash": "sha256-Yo/3loq572A8Su6aY5GP56knpuKYRvM2a1meP9oJZCw=", + "lastModified": 1728330715, + "narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=", "owner": "numtide", "repo": "devshell", - "rev": "67cce7359e4cd3c45296fb4aaf6a19e2a9c757ae", + "rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef", "type": "github" }, "original": { @@ -23,6 +23,7 @@ }, "flake-compat": { "locked": { + "lastModified": 1696426674, "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "revCount": 57, @@ -39,11 +40,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": { @@ -84,11 +85,11 @@ ] }, "locked": { - "lastModified": 1715167549, - "narHash": "sha256-QzMKToqiDQzMjBM2TW1VGMUxSLj70Uk4IdJVjIdkd5c=", + "lastModified": 1724178650, + "narHash": "sha256-p+Li/z3l7ShRSIKUrxVK+7uGhSvqPE7jOW4FA4k3SIw=", "owner": "efabless", "repo": "volare", - "rev": "b72ce150b80f67278d4c6b025183fb3941cab993", + "rev": "0090420799258d29adca54c8951d38bb8b605aeb", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index b3f854d..d42227e 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. { + description = "open-source framework for automatic circuit characterization"; + nixConfig = { extra-substituters = [ "https://openlane.cachix.org" @@ -37,66 +39,108 @@ volare, devshell, ... - }: { + }: let + nixpkgs = nix-eda.inputs.nixpkgs; + lib = nixpkgs.lib; + in { # Common - input-overlays = [ - (import ./nix/overlay.nix) - (devshell.overlays.default) - ]; - + overlays = { + default = lib.composeManyExtensions [ + (import ./nix/overlay.nix) + (nix-eda.flakesToOverlay [volare]) + ( + pkgs': pkgs: let + callPackage = lib.callPackageWith pkgs'; + in { + colab-env = callPackage ./nix/colab-env.nix {}; + } + ) + ( + nix-eda.composePythonOverlay (pkgs': pkgs: pypkgs': pypkgs: let + callPythonPackage = lib.callPackageWith (pkgs' // pkgs'.python3.pkgs); + in { + cace = callPythonPackage ./default.nix {}; + }) + ) + (pkgs': pkgs: let + callPackage = lib.callPackageWith pkgs'; + in + {} + // lib.optionalAttrs pkgs.stdenv.isLinux { + cace-docker = callPackage ./nix/docker.nix { + createDockerImage = nix-eda.createDockerImage; + cace = pkgs'.python3.pkgs.cace; + }; + }) + ]; + }; + # Helper functions createCaceShell = import ./nix/create-shell.nix; - # Outputs - packages = - nix-eda.forAllSystems { - current = self; - withInputs = [nix-eda volare]; - } ( - util: let - self = with util; - { - colab-env = callPackage ./nix/colab-env.nix {}; - cace = callPythonPackage ./default.nix {}; - default = self.cace; - } - // (pkgs.lib.optionalAttrs (pkgs.stdenv.isLinux) {cace-docker = callPackage ./nix/docker.nix {createDockerImage = nix-eda.createDockerImage;};}); - in - self - ); + # Packages + legacyPackages = nix-eda.forAllSystems ( + system: + import nix-eda.inputs.nixpkgs { + inherit system; + overlays = [devshell.overlays.default nix-eda.overlays.default self.overlays.default]; + } + ); - devShells = nix-eda.forAllSystems {withInputs = [self devshell nix-eda volare];} ( - util: - with util; rec { - default = - callPackage (self.createCaceShell { - }) {}; - notebook = callPackage (self.createCaceShell { - extra-packages = with pkgs; [ - jupyter - ]; - }) {}; - dev = callPackage (self.createCaceShell { - extra-packages = with pkgs; [ - ]; - extra-python-packages = with pkgs.python3.pkgs; [ - setuptools - build - twine - black # blue - ]; - }) {}; - docs = callPackage (self.createCaceShell { - extra-packages = with pkgs; [ - ]; - extra-python-packages = with pkgs.python3.pkgs; [ - sphinx - myst-parser - furo - sphinx-autobuild - ]; - }) {}; + packages = nix-eda.forAllSystems ( + system: let + pkgs = (self.legacyPackages."${system}"); + in { + inherit (pkgs) colab-env; + inherit (pkgs.python3.pkgs) cace; + default = pkgs.python3.pkgs.cace; + } + // lib.optionalAttrs pkgs.stdenv.isLinux { + inherit (pkgs) cace-docker; } ); + + # devshells + + devShells = nix-eda.forAllSystems ( + system: let + pkgs = self.legacyPackages."${system}"; + callPackage = lib.callPackageWith pkgs; + in { + # These devShells are rather unorthodox for Nix devShells in that they + # include the package itself. For a proper devShell, try .#dev. + default = + callPackage (self.createCaceShell { + }) {}; + notebook = callPackage (self.createCaceShell { + extra-packages = with pkgs; [ + jupyter + ]; + }) {}; + # Normal devShells + dev = callPackage (self.createCaceShell { + extra-packages = with pkgs; [ + ]; + extra-python-packages = with pkgs.python3.pkgs; [ + setuptools + build + twine + black # blue + ]; + include-cace = false; + }) {}; + docs = callPackage (self.createCaceShell { + extra-packages = with pkgs; [ + ]; + extra-python-packages = with pkgs.python3.pkgs; [ + sphinx + myst-parser + furo + sphinx-autobuild + ]; + include-cace = false; + }) {}; + } + ); }; } diff --git a/nix/colab-env.nix b/nix/colab-env.nix index c42d588..c7e9a71 100644 --- a/nix/colab-env.nix +++ b/nix/colab-env.nix @@ -13,11 +13,10 @@ # limitations under the License. { system, - cace, python3, symlinkJoin, }: symlinkJoin { name = "cace-colab-env"; - paths = cace.includedTools; + paths = python3.pkgs.cace.includedTools; } diff --git a/nix/create-shell.nix b/nix/create-shell.nix index b410363..2db0969 100644 --- a/nix/create-shell.nix +++ b/nix/create-shell.nix @@ -13,10 +13,10 @@ # limitations under the License. { extra-packages ? [], - extra-python-packages ? [] + extra-python-packages ? [], + include-cace ? true }: ({ lib, - cace, git, zsh, delta, @@ -27,12 +27,10 @@ python3, devshell, }: let + cace = python3.pkgs.cace; cace-env = ( python3.withPackages (pp: - with pp; - [ - cace - ] + (if include-cace then [cace] else cace.propagatedBuildInputs) ++ extra-python-packages) ); cace-env-sitepackages = "${cace-env}/${cace-env.sitePackages}"; From 0a619beadcff505563c12a17507589a4fb1e16a5 Mon Sep 17 00:00:00 2001 From: mole99 Date: Thu, 7 Nov 2024 10:43:52 +0100 Subject: [PATCH 2/3] Update nix-eda --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 16c7a92..776caa5 100644 --- a/flake.lock +++ b/flake.lock @@ -40,11 +40,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1728905391, - "narHash": "sha256-iox9yGNG4MwSKhQuwegLcDW6wVGzfdBPrh8SrhSLA8c=", + "lastModified": 1730972444, + "narHash": "sha256-6wbOkA/YSF4bG9ZQHUm7zURm0ScwTGGWxH3oWjhBZZg=", "owner": "efabless", "repo": "nix-eda", - "rev": "0814aa6c1c7d556aa08212cc875063cff62cb9b0", + "rev": "faad81bfd90c90a8b61fc1934cb6413f5ec1cc0d", "type": "github" }, "original": { From eda26deaf3330fe20ef24b34c356eb5b16e3e7cd Mon Sep 17 00:00:00 2001 From: mole99 Date: Wed, 13 Nov 2024 12:38:37 +0100 Subject: [PATCH 3/3] Fix notebook devshell and add pandas --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index d42227e..e22195d 100644 --- a/flake.nix +++ b/flake.nix @@ -113,8 +113,9 @@ callPackage (self.createCaceShell { }) {}; notebook = callPackage (self.createCaceShell { - extra-packages = with pkgs; [ + extra-python-packages = with pkgs.python3.pkgs; [ jupyter + pandas ]; }) {}; # Normal devShells