nixos/cfdyndns: dynamic user and loadcredentials

This commit is contained in:
happysalada 2023-09-11 09:07:25 -04:00 committed by Yt
parent d989b040da
commit 1e335c516b

View file

@ -60,8 +60,8 @@ in
startAt = "*:0/5"; startAt = "*:0/5";
serviceConfig = { serviceConfig = {
Type = "simple"; Type = "simple";
User = config.ids.uids.cfdyndns; LoadCredential = lib.optional (cfg.apiTokenFile != null) "CLOUDFLARE_APITOKEN_FILE:${cfg.apiTokenFile}";
Group = config.ids.gids.cfdyndns; DynamicUser = true;
}; };
environment = { environment = {
CLOUDFLARE_RECORDS="${concatStringsSep "," cfg.records}"; CLOUDFLARE_RECORDS="${concatStringsSep "," cfg.records}";
@ -72,23 +72,10 @@ in
export CLOUDFLARE_EMAIL="${cfg.email}" export CLOUDFLARE_EMAIL="${cfg.email}"
''} ''}
${optionalString (cfg.apiTokenFile != null) '' ${optionalString (cfg.apiTokenFile != null) ''
export CLOUDFLARE_APITOKEN="$(cat ${escapeShellArg cfg.apiTokenFile})" export CLOUDFLARE_APITOKEN=$(${pkgs.systemd}/bin/systemd-creds cat CLOUDFLARE_APITOKEN_FILE)
''} ''}
${pkgs.cfdyndns}/bin/cfdyndns ${pkgs.cfdyndns}/bin/cfdyndns
''; '';
}; };
users.users = {
cfdyndns = {
group = "cfdyndns";
uid = config.ids.uids.cfdyndns;
};
};
users.groups = {
cfdyndns = {
gid = config.ids.gids.cfdyndns;
};
};
}; };
} }