summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/repo-sync.nix
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2021-12-25 20:08:03 +0100
committerlassulus <lassulus@lassul.us>2021-12-25 20:08:03 +0100
commit9f194012bd6e5524f547a9c361ee411baaee5048 (patch)
treea4cd821b08167d2db91b8ee7eca93805f41c776b /krebs/3modules/repo-sync.nix
parentf31f9f37907c031091f208d30bd5f2e5011eebb0 (diff)
parenta1a0f11af481d94fea38f0f6f71e3340587503ac (diff)
Merge remote-tracking branch 'ni/master'
Diffstat (limited to 'krebs/3modules/repo-sync.nix')
-rw-r--r--krebs/3modules/repo-sync.nix29
1 files changed, 13 insertions, 16 deletions
diff --git a/krebs/3modules/repo-sync.nix b/krebs/3modules/repo-sync.nix
index 0312c62fd..c4cfb9a49 100644
--- a/krebs/3modules/repo-sync.nix
+++ b/krebs/3modules/repo-sync.nix
@@ -122,13 +122,9 @@ let
};
privateKeyFile = mkOption {
- type = types.secret-file;
- default = {
- name = "repo-sync-key";
- path = "${cfg.stateDir}/ssh.priv";
- owner = cfg.user;
- source-path = toString <secrets> + "/repo-sync.ssh.key";
- };
+ type = types.absolute-pathname;
+ default = toString <secrets> + "/repo-sync.ssh.key";
+ defaultText = "‹secrets/repo-sync.ssh.key›";
};
unitConfig = mkOption {
@@ -144,14 +140,16 @@ let
};
imp = {
- krebs.secret.files.repo-sync-key = cfg.privateKeyFile;
users.users.${cfg.user.name} = {
inherit (cfg.user) home name uid;
createHome = true;
+ group = cfg.user.name;
description = "repo-sync user";
isSystemUser = true;
};
+ users.groups.${cfg.user.name} = {};
+
systemd.timers = mapAttrs' (name: repo:
nameValuePair "repo-sync-${name}" {
description = "repo-sync timer";
@@ -160,6 +158,10 @@ let
}
) cfg.repos;
+ krebs.systemd.services = mapAttrs' (name: _:
+ nameValuePair "repo-sync-${name}" {}
+ ) cfg.repos;
+
systemd.services = mapAttrs' (name: repo:
let
repo-sync-config = pkgs.writeJSON "repo-sync-config-${name}.json"
@@ -168,16 +170,10 @@ let
});
in nameValuePair "repo-sync-${name}" {
description = "repo-sync";
- after = [
- config.krebs.secret.files.repo-sync-key.service
- "network.target"
- ];
- partOf = [
- config.krebs.secret.files.repo-sync-key.service
- ];
+ after = [ "network.target" ];
environment = {
- GIT_SSH_COMMAND = "${pkgs.openssh}/bin/ssh -i ${cfg.privateKeyFile.path}";
+ GIT_SSH_COMMAND = "${pkgs.openssh}/bin/ssh -i $CREDENTIALS_DIRECTORY/ssh_key";
REPONAME = "${name}.git";
};
@@ -185,6 +181,7 @@ let
serviceConfig = {
Type = "simple";
PermissionsStartOnly = true;
+ LoadCredential = "ssh_key:${cfg.privateKeyFile}";
ExecStart = "${pkgs.repo-sync}/bin/repo-sync ${repo-sync-config}";
WorkingDirectory = cfg.stateDir;
User = "repo-sync";