add initial nixos modules
All checks were successful
buildbot/nix-eval Build done.
buildbot/nix-build gitea:ops/nix-cache-login#checks.x86_64-linux.devShell Build done.
buildbot/nix-build gitea:ops/nix-cache-login#checks.x86_64-linux.tests Build done.
buildbot/nix-build Build done.
buildbot/nix-effects Build done.
All checks were successful
buildbot/nix-eval Build done.
buildbot/nix-build gitea:ops/nix-cache-login#checks.x86_64-linux.devShell Build done.
buildbot/nix-build gitea:ops/nix-cache-login#checks.x86_64-linux.tests Build done.
buildbot/nix-build Build done.
buildbot/nix-effects Build done.
This commit is contained in:
parent
164a8e9aa9
commit
07bd576628
3 changed files with 123 additions and 0 deletions
42
nixos-module.nix
Normal file
42
nixos-module.nix
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.services.nix-cache-login;
|
||||
in
|
||||
{
|
||||
options.services.nix-cache-login = {
|
||||
enable = lib.mkEnableOption "nix-cache-login automatic token refresh";
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
description = "The nix-cache-login package to use.";
|
||||
};
|
||||
refreshInterval = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "15min";
|
||||
description = ''
|
||||
Interval between token refresh attempts, as a systemd time span.
|
||||
If no valid session exists, the service logs an error and the timer
|
||||
retries on the next interval. Run nix-cache-login to log in.
|
||||
'';
|
||||
example = "1h";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.user.services.nix-cache-login = {
|
||||
description = "Nix cache login - refresh access token";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${cfg.package}/bin/nix-cache-login refresh";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.timers.nix-cache-login = {
|
||||
description = "Nix cache login - periodic token refresh";
|
||||
timerConfig = {
|
||||
OnBootSec = "2min";
|
||||
OnUnitActiveSec = cfg.refreshInterval;
|
||||
};
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue