Skip to content

Commit

Permalink
feat: generate shell for each package but make default the combined s…
Browse files Browse the repository at this point in the history
…hell
  • Loading branch information
yusdacra committed Dec 21, 2022
1 parent 0176f85 commit faa2b46
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 18 deletions.
28 changes: 21 additions & 7 deletions src/subsystems/rust/builders/build-rust-package/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,32 @@
(name: version: {"${version}" = buildPackage name version;})
args.packages;

mkShellForDrvs = drvs:
pkgs.callPackage ../devshell.nix {
name = "devshell";
inherit drvs;
};

pkgShells =
l.mapAttrs
(
name: version: let
pkg = allPackages.${name}.${version};
in
mkShellForDrvs [pkg]
)
args.packages;

allPackagesList =
l.mapAttrsToList
(name: version: allPackages.${name}.${version})
args.packages;
shell = pkgs.callPackage ../devshell.nix {
name = "devshell";
drvs = allPackagesList;
};
in {
packages = allPackages;
devShells = {
default = shell;
};
devShells =
pkgShells
// {
default = mkShellForDrvs allPackagesList;
};
};
}
28 changes: 21 additions & 7 deletions src/subsystems/rust/builders/crane/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,22 @@
(name: version: {"${version}" = buildPackage name version;})
args.packages;

mkShellForDrvs = drvs:
pkgs.callPackage ../devshell.nix {
name = "devshell";
inherit drvs;
};

pkgShells =
l.mapAttrs
(
name: version: let
pkg = allPackages.${name}.${version};
in
mkShellForDrvs [pkg.passthru.dependencies pkg]
)
args.packages;

allPackagesList = l.flatten (
l.mapAttrsToList
(
Expand All @@ -145,14 +161,12 @@
)
args.packages
);
shell = pkgs.callPackage ../devshell.nix {
name = "devshell";
drvs = allPackagesList;
};
in {
packages = allPackages;
devShells = {
default = shell;
};
devShells =
pkgShells
// {
default = mkShellForDrvs allPackagesList;
};
};
}
7 changes: 3 additions & 4 deletions src/subsystems/rust/builders/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,18 @@
all
// env
// {
packages = (all.packages or []) ++ (env.packages or []);
buildInputs = (all.buildInputs or []) ++ (env.buildInputs or []);
nativeBuildInputs = (all.nativeBuildInputs or []) ++ (env.nativeBuildInputs or []);
propagatedBuildInputs = (all.propagatedBuildInputs or []) ++ (env.propagatedBuildInputs or []);
propagatedNativeBuildInputs = (all.propagatedNativeBuildInputs or []) ++ (env.propagatedNativeBuildInputs or []);
}
)
{}
envs;
_shellEnv = combineEnvs (l.map getEnvs drvs);
shellEnv =
(combineEnvs (l.map getEnvs drvs))
_shellEnv
// {
inherit name;
passthru.env = _shellEnv;
};
in
(mkShell.override {stdenv = (l.head drvs).stdenv;}) shellEnv

0 comments on commit faa2b46

Please sign in to comment.