feat(home-manager): create timer unit
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
shimun 2023-07-10 08:44:11 +02:00
parent 1183ba0d73
commit 9d405a6324
Signed by: shimun
GPG Key ID: E0420647856EA39E
2 changed files with 20 additions and 3 deletions

View File

@ -11,8 +11,8 @@ in
Unit.Description = "ssh-cert-dist service for ${path}";
Service = {
Environment = "RUST_LOG=debug";
ExecStart = toString (pkgs.writeShellApplication {
name = "ssh-cert-dist-${options.name}";
ExecStart = "${pkgs.writeShellApplication {
name = "sshcd";
runtimeInputs = [ cfg.package ];
text = ''
${optionalString options.fetch ''
@ -22,11 +22,23 @@ in
sshcd upload --api-endpoint '${cfg.endpoint}' ${path}/*
''}
'';
});
}}/bin/sshcd";
};
};
})
cfg.directories);
config.systemd.user.timers = mkIf cfg.enable (mapAttrs'
(path: options: {
inherit (options) name; value = {
Unit.Description = "ssh-cert-dist service for ${path}";
Timer = {
OnCalendar = options.interval;
Unit = "${options.name}.service";
};
Install.WantedBy = [ "timers.target" ];
};
})
cfg.directories);
config.home.sessionVariables = mkIf (cfg.enable && cfg.endpoint != null) {
SSH_CD_API = cfg.endpoint;
};

View File

@ -13,6 +13,11 @@
type = types.bool;
default = false;
};
interval = mkOption {
type = types.str;
default = "daily";
description = "https://www.freedesktop.org/software/systemd/man/systemd.time.html";
};
};
};
endpointOption = mkOption {