summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-19 18:54:03 +0000
committertv <tv@krebsco.de>2026-11-19 18:54:03 +0000
commita9dee76c4b6cd7bfefa7a6055804aab8b870220b (patch)
treec188962874f31debb437bab9ac6049679168a9ab /modules
parentdad4070a4e6c23cdef31c7d552e55edc338af81a (diff)
continuum: add credentials
credentials maps names to secret files. They reach the instance by LoadCredential, so settings refer to them as ${env:CREDENTIALS_DIRECTORY}/<name>, and the instance restarts when one changes.
Diffstat (limited to 'modules')
-rw-r--r--modules/continuum.nix20
1 files changed, 19 insertions, 1 deletions
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-<name>.
'';
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}/<name>, 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";