Modify flake.nix to make dev shells optional
This commit is contained in:
parent
b395e657fb
commit
ace4288c9d
18
flake.nix
18
flake.nix
|
@ -10,11 +10,19 @@
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
|
||||||
|
# Check if project has a shell.nix
|
||||||
|
hasShell = dir: (builtins.readDir ./${dir}) ? "shell.nix";
|
||||||
|
|
||||||
|
# Get all project directories
|
||||||
currentDir = builtins.readDir ./.;
|
currentDir = builtins.readDir ./.;
|
||||||
dirs = pkgs.lib.filterAttrs (_: v: v == "directory") currentDir;
|
dirs = lib.filterAttrs (_: v: v == "directory") currentDir;
|
||||||
in {
|
in
|
||||||
packages = builtins.mapAttrs (dir: _: pkgs.callPackage ./${dir} {}) dirs;
|
lib.concatMapAttrs (dir: _: {
|
||||||
devShells = builtins.mapAttrs (dir: _: pkgs.callPackage ./${dir}/shell.nix {}) dirs;
|
packages.${dir} = pkgs.callPackage ./${dir} {};
|
||||||
});
|
} // lib.optionalAttrs (hasShell dir) {
|
||||||
|
devShells.${dir} = pkgs.callPackage ./${dir}/shell.nix {};
|
||||||
|
}) dirs
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue