From fa41b08588e4b2f5cc70881f16eff55d85a3a530 Mon Sep 17 00:00:00 2001 From: Filippo Berto Date: Thu, 28 Sep 2023 13:10:27 +0200 Subject: [PATCH] nix-index: setup systemd service with timer --- modules/hm/nix-index.nix | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/modules/hm/nix-index.nix b/modules/hm/nix-index.nix index cbf1b23..a433398 100644 --- a/modules/hm/nix-index.nix +++ b/modules/hm/nix-index.nix @@ -1,4 +1,4 @@ -{ +{ config, lib, ... }: { programs.nix-index = { enable = true; # package = pkgs.unstable_pkgs.nix-index; @@ -6,26 +6,26 @@ enableZshIntegration = true; }; - # systemd.user = { - # services."nix-index" = { - # Unit = { - # Description = "Update the nix-locate database"; - # After = [ "network.target" ]; - # }; - # Service = { - # Type = "oneshot"; - # ExecStart = "${config.programs.nix-index.package}/bin/nix-index"; - # }; - # }; + systemd.user = lib.attrsets.optionalAttrs config.programs.nix-index.enable { + services."nix-index" = { + Unit = { + Description = "Update the nix-locate database"; + After = [ "network.target" ]; + }; + Service = { + Type = "oneshot"; + ExecStart = "${config.programs.nix-index.package}/bin/nix-index"; + }; + }; - # timers."nix-index" = { - # Unit.Description = "Daily update the nix-locate database"; - # Timer = { - # OnCalendar = "daily"; - # Persistent = true; - # Unit = "nix-index.service"; - # }; - # Install.WantedBy = [ "timers.target" ]; - # }; - # }; + timers."nix-index" = { + Unit.Description = "Daily update the nix-locate database"; + Timer = { + OnCalendar = "daily"; + Persistent = true; + Unit = "nix-index.service"; + }; + Install.WantedBy = [ "timers.target" ]; + }; + }; }