-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
55 lines (50 loc) · 1.67 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
# https://github.com/nix4cyber/nix4cyber
description = "nix4cyber";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
outputs = { self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
utils = import ./utils.nix { inherit pkgs; };
# Automatically detect directories containing shell.nix files
isDirectory = path: builtins.pathExists (path + "/shell.nix");
# Get a list of all entries in the repo root
allEntries = builtins.attrNames (builtins.readDir ./.);
# Filter to only include directories that have a shell.nix file
dirs = builtins.filter (dir:
builtins.pathExists (./. + "/${dir}/shell.nix")
&& builtins.isAttrs (builtins.readDir (./. + "/${dir}"))) allEntries;
loadShell = name: {
inherit name;
value = import ./${name}/shell.nix {
inherit pkgs;
inherit utils;
};
};
shells = builtins.listToAttrs (map loadShell dirs);
allBuildInputs = builtins.concatLists (map (name:
(import ./${name}/shell.nix {
inherit pkgs;
inherit utils;
}).nativeBuildInputs or [ ]) dirs);
combineShellHooks = builtins.concatStringsSep "\n" (map (name:
let
shell = import ./${name}/shell.nix {
inherit pkgs;
inherit utils;
};
in shell.shellHook or "") dirs);
in {
lib = { inherit utils; };
devShells.${system} = shells // {
all = pkgs.mkShell {
nativeBuildInputs = allBuildInputs;
shellHook = combineShellHooks;
};
};
};
}