handled by the nix-index enable module
This commit is contained in:
parent
1ac1dc5707
commit
3beae7844f
2 changed files with 59 additions and 1 deletions
|
@ -45,7 +45,6 @@ with config;
|
||||||
dbus
|
dbus
|
||||||
direnv
|
direnv
|
||||||
git
|
git
|
||||||
nix-index
|
|
||||||
python3
|
python3
|
||||||
fzf
|
fzf
|
||||||
ripgrep
|
ripgrep
|
||||||
|
|
59
nixos/modules/nixos/services/nix-index-daily/default.nix
Normal file
59
nixos/modules/nixos/services/nix-index-daily/default.nix
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.services.nix-index-daily;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.nix-index-daily = {
|
||||||
|
enable = lib.mkEnableOption "Automatic daily nix-index database updates";
|
||||||
|
|
||||||
|
user = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "User account under which to run nix-index";
|
||||||
|
example = "alice";
|
||||||
|
};
|
||||||
|
|
||||||
|
startTime = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "daily";
|
||||||
|
description = "When to start the service. See systemd.time(7)";
|
||||||
|
example = "03:00";
|
||||||
|
};
|
||||||
|
|
||||||
|
randomizedDelaySec = lib.mkOption {
|
||||||
|
type = lib.types.int;
|
||||||
|
default = 3600;
|
||||||
|
description = "Random delay in seconds after startTime";
|
||||||
|
example = 1800;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
users.users.${cfg.user}.packages = [ pkgs.nix-index ];
|
||||||
|
|
||||||
|
systemd.user.services.nix-index-update = {
|
||||||
|
description = "Update nix-index database";
|
||||||
|
script = "${pkgs.nix-index}/bin/nix-index";
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.user.timers.nix-index-update = {
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = cfg.startTime;
|
||||||
|
Persistent = true;
|
||||||
|
RandomizedDelaySec = cfg.randomizedDelaySec;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Ensure the services are enabled
|
||||||
|
systemd.user.services.nix-index-update.enable = true;
|
||||||
|
systemd.user.timers.nix-index-update.enable = true;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue