Skip to content

Commit

Permalink
Move the various devShells to a devShells attribute
Browse files Browse the repository at this point in the history
This attribute doesn’t have a special meaning for now, but we could make
Nix check it and expand `nix develop .#clangStdenv` to `nix develop
.#devShells.${builtins.currentSystem}.clangStdenv`
  • Loading branch information
thufschmitt committed Nov 26, 2021
1 parent 014fa96 commit d9fa9cf
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,32 @@

forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
forAllSystemsAndStdenvs = f: forAllSystems (system:
let stdenvsPackages =
nixpkgs.lib.listToAttrs
nixpkgs.lib.listToAttrs
(map
(n:
nixpkgs.lib.nameValuePair "${n}Packages" (
f system n
)) stdenvs
);
in
stdenvsPackages // stdenvsPackages.stdenvPackages
)
);

forAllStdenvs = stdenvs: f: nixpkgs.lib.genAttrs stdenvs (stdenv: f stdenv);

# Memoize nixpkgs for different platforms for efficiency.
nixpkgsFor = forAllSystemsAndStdenvs (system: stdenv:
import nixpkgs {
inherit system;
overlays = [
(overlayFor (p: p.${stdenv}))
];
}
);
nixpkgsFor =
let stdenvsPackages = forAllSystemsAndStdenvs
(system: stdenv:
import nixpkgs {
inherit system;
overlays = [
(overlayFor (p: p.${stdenv}))
];
}
);
in
# Add the `stdenvPackages` at toplevel, both because these are the ones
# we want most of the time and for backwards compatibility
forAllSystems (system: stdenvsPackages.${system} // stdenvsPackages.${system}.stdenvPackages);

commonDeps = pkgs: with pkgs; rec {
# Use "busybox-sandbox-shell" if present,
Expand Down Expand Up @@ -639,7 +642,9 @@

defaultPackage = forAllSystems (system: self.packages.${system}.nix);

devShell = forAllSystemsAndStdenvs (system: stdenv:
devShell = forAllSystems (system: self.devShells.${system}.stdenvPackages);

devShells = forAllSystemsAndStdenvs (system: stdenv:
with nixpkgsFor.${system};
with commonDeps pkgs;

Expand Down

0 comments on commit d9fa9cf

Please sign in to comment.