-
Notifications
You must be signed in to change notification settings - Fork 54
/
options.nix
47 lines (38 loc) · 1.29 KB
/
options.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
{ lib, config, inputs, ... }:
let
inherit (lib) mkIf filterAttrs mapAttrs' mkOption types;
mkFalseOption = description: mkOption {
inherit description;
default = false;
example = true;
type = types.bool;
};
flakes = filterAttrs (name: value: value ? outputs) inputs;
nixRegistry = builtins.mapAttrs
(name: v: { flake = v; })
flakes;
cfg = config.nix;
in
{
options.nix = {
generateNixPathFromInputs = mkFalseOption "Generate NIX_PATH from available inputs.";
generateRegistryFromInputs = mkFalseOption "Generate Nix registry from available inputs.";
linkInputs = mkFalseOption "Symlink inputs to /etc/nix/inputs.";
};
config = {
assertions = [
{
assertion = !cfg.generateNixPathFromInputs || cfg.linkInputs;
message = "When using 'nix.generateNixPathFromInputs' please make sure to set 'nix.linkInputs = true'";
}
];
nix.registry =
if cfg.generateRegistryFromInputs
then nixRegistry
else { self.flake = flakes.self; };
environment.etc = mkIf (cfg.linkInputs || cfg.generateNixPathFromInputs) (mapAttrs'
(name: value: { name = "nix/inputs/${name}"; value = { source = value.outPath; }; })
inputs);
nix.nixPath = mkIf cfg.generateNixPathFromInputs [ "/etc/nix/inputs" ];
};
}