From a9dee76c4b6cd7bfefa7a6055804aab8b870220b Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 18:54:03 +0000 Subject: continuum: add credentials credentials maps names to secret files. They reach the instance by LoadCredential, so settings refer to them as ${env:CREDENTIALS_DIRECTORY}/, and the instance restarts when one changes. --- modules/continuum.nix | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'modules/continuum.nix') diff --git a/modules/continuum.nix b/modules/continuum.nix index a6b6d8c..4a30b0e 100644 --- a/modules/continuum.nix +++ b/modules/continuum.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: let +{ config, lib, mylib, pkgs, ... }: let cfg = config.hrm.continuum; format = pkgs.formats.toml {}; @@ -28,6 +28,16 @@ in { directory /var/lib/continuum-. ''; type = lib.types.attrsOf (lib.types.submodule { + options.credentials = lib.mkOption { + default = {}; + description = '' + Secret files by name, like an htpasswd file or a key. The instance + alone can read each as ''${env:CREDENTIALS_DIRECTORY}/, which + is how settings refer to them. It restarts when one changes. + ''; + example = { htpasswd = "/var/src/secrets/continuum.htpasswd"; }; + type = lib.types.attrsOf mylib.types.absolute-pathname; + }; options.settings = lib.mkOption { default = {}; description = '' @@ -49,6 +59,12 @@ in { }); }; + config.hrm.systemd.services = lib.mapAttrs' (name: instance: + lib.nameValuePair "continuum-${name}" { + restartIfCredentialsChange = true; + } + ) (lib.filterAttrs (_: instance: instance.credentials != {}) cfg.instances); + config.systemd.services = lib.mapAttrs' (name: instance: lib.nameValuePair "continuum-${name}" { description = "continuum ${name}"; @@ -67,6 +83,8 @@ in { DynamicUser = true; StateDirectory = "continuum-${name}"; StateDirectoryMode = "0700"; + LoadCredential = + lib.mapAttrsToList (name: path: "${name}:${path}") instance.credentials; # It only needs the network and its state directory. ProtectSystem = "strict"; -- cgit v1.3.1