Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nix-eda #136

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
magic-vlsi,
netgen,
volare,
octave,
xschem,
ngspice,

Expand Down Expand Up @@ -69,7 +68,6 @@
klayout-gdsfactory
magic-vlsi
netgen
octave
ngspice
xschem
];
Expand Down
19 changes: 10 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

153 changes: 99 additions & 54 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -37,66 +39,109 @@
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-python-packages = with pkgs.python3.pkgs; [
jupyter
pandas
];
}) {};
# 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;
}) {};
}
);
};
}
3 changes: 1 addition & 2 deletions nix/colab-env.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
10 changes: 4 additions & 6 deletions nix/create-shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# limitations under the License.
{
extra-packages ? [],
extra-python-packages ? []
extra-python-packages ? [],
include-cace ? true
}: ({
lib,
cace,
git,
zsh,
delta,
Expand All @@ -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}";
Expand Down
Loading