diff options
| -rw-r--r-- | nix/module.nix | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/nix/module.nix b/nix/module.nix index f7a51a9..a4b0ea7 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -75,6 +75,18 @@ let default = true; description = "Whether the slot is its own view, `CHANNEL.SLOT`."; }; + source = mkOption { + type = types.nullOr types.raw; + default = null; + description = '' + Where a deployment gets the slot's entry, on the deploying host: a source + in enstate's syntax (`cmd:…`, `{ command = [ … ]; }`, …), or + `{ location = NAME; VAR = …; }`, a location with its variables. Not part + of the system: the deploying host reads it from `sourceLists`. Commands + and paths only, never a secret itself. + ''; + example = lib.literalExpression ''{ location = "secrets"; key = "retiolum.ed25519_key.priv"; }''; + }; path = mkOption { type = types.nullOr types.str; readOnly = true; @@ -269,6 +281,51 @@ in description = "Views made by renderers."; }; + locations = mkOption { + type = types.attrsOf types.raw; + default = { }; + description = '' + Locations for every source list (`sourceLists`): sources declared once, + which slots' `source` use by name, with variables. A deployment may add its + own (a location that names the deploying host's tools, say). A source list + is packed on the deploying host, so `$(env:…)` there are its: write the + host's own name in by Nix (`config.networking.hostName`), or as a variable. + ''; + example = lib.literalExpression '' + { secrets.source.command = [ "secrets" config.networking.hostName "show" "$(var:key)" ]; } + ''; + }; + + sourceLists = mkOption { + type = types.attrsOf types.raw; + readOnly = true; + description = '' + A source list for `enstate --pack` per channel, from the slots that have a + `source`, complete if every slot of the channel has one, with `locations`. + For the deploying host to evaluate (and to write as JSON, e.g. with + `pkgs.writers.writeJSON`): not part of the system. + ''; + default = lib.mapAttrs ( + channel: channelCfg: + let + sourced = lib.filterAttrs (_: slotCfg: slotCfg.source != null) channelCfg.slots; + in + { + inherit channel; + complete = lib.attrNames sourced == lib.attrNames channelCfg.slots; + items = lib.mapAttrs ( + _: slotCfg: + if lib.isAttrs slotCfg.source && slotCfg.source ? location then + slotCfg.source + else + { inherit (slotCfg) source; } + ) sourced; + } + // lib.optionalAttrs (cfg.locations != { }) { inherit (cfg) locations; } + ) (lib.filterAttrs (_: channelCfg: lib.any (slotCfg: slotCfg.source != null) (lib.attrValues channelCfg.slots)) cfg.channels); + defaultText = lib.literalExpression "a source list per channel with sources"; + }; + incomingDir = mkOption { type = types.str; readOnly = true; |
