blob: c6f238f422e5e2458a4d3e53281e1d362a6f5542 (
plain)
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
|
{ config, inputs, lib, pkgs, ... }: {
imports = [ (inputs.enstate + "/nix/module.nix") ];
options.enstate = {
# Where a deploy gets each slot's entry from, in enstate's source
# syntax, run on the deploying host; or { location = NAME; VAR = …; },
# a source the deploying host declares, with its variables.
channels = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
options.slots = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
options.source = lib.mkOption {
type = lib.types.nullOr lib.types.raw;
default = null;
};
});
};
});
};
# Per channel, a source list for enstate --pack, from the slots that
# name a source: complete if every slot of the channel does. For the
# deploying host to evaluate; not part of the system.
sourceLists = lib.mkOption {
readOnly = true;
default = lib.mapAttrs (channel: channelCfg: let
sourced = lib.filterAttrs (_: slot: slot.source != null) channelCfg.slots;
in {
inherit channel;
complete = lib.attrNames sourced == lib.attrNames channelCfg.slots;
items = lib.mapAttrs (_: slot:
if slot.source ? location then slot.source
else { inherit (slot) source; }
) sourced;
}) (lib.filterAttrs (_: channelCfg:
lib.any (slot: slot.source != null) (lib.attrValues channelCfg.slots)
) config.enstate.channels);
};
};
config.enstate.package = pkgs.enstate;
}
|