summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-30 21:05:06 +0000
committertv <tv@krebsco.de>2026-12-01 00:22:40 +0000
commit9e69de1edd908efb748e3a51afd157974c5afea0 (patch)
tree3d0e5229501d6537f60c8b63fc3bda985a84473a
parentd2e3f6081739ff793cdda996550751e922ab4497 (diff)
enstate: name each slot's source
enstate.channels.<channel>.slots.<slot>.source, in enstate's source syntax, run on the deploying host; enstate.sourceLists gathers them per channel, complete if every slot of the channel names a source, for the deploying host to evaluate. Shared configs set sources with lib.mkDefault, for hosts to override.
-rw-r--r--modules/enstate.nix37
1 files changed, 35 insertions, 2 deletions
diff --git a/modules/enstate.nix b/modules/enstate.nix
index 79063d7f..55e0d50c 100644
--- a/modules/enstate.nix
+++ b/modules/enstate.nix
@@ -1,4 +1,37 @@
-{ inputs, pkgs, ... }: {
+{ config, inputs, lib, pkgs, ... }: {
imports = [ (inputs.enstate + "/nix/module.nix") ];
- enstate.package = pkgs.enstate;
+
+ options.enstate = {
+ # Where a deploy gets each slot's entry from, in enstate's source
+ # syntax, run on the deploying host.
+ 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: { 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;
}