diff --git a/home/home.nix b/home/home.nix index d454e1c..bfca7ae 100644 --- a/home/home.nix +++ b/home/home.nix @@ -11,7 +11,7 @@ in { ./programs/atuin.nix ./programs/comma.nix - ./programs/direnv.nix + ./programs/direnv ./programs/gdb.nix ./programs/gh.nix ./programs/git diff --git a/home/programs/direnv/auto-prune.nix b/home/programs/direnv/auto-prune.nix new file mode 100644 index 0000000..4472789 --- /dev/null +++ b/home/programs/direnv/auto-prune.nix @@ -0,0 +1,38 @@ +{ config, pkgs, lib, ... }: +let + cfg = config.programs.direnv; +in +{ + config = { + systemd.user.services.prune-allowed-direnv-dirs = { + Unit = { + Description = "Prune unused allowed directories for direnv"; + Documentation = [ "man:direnv(1)" ]; + }; + + Service = { + Type = "oneshot"; + CPUSchedulingPolicy = "idle"; + IOSchedulingClass = "idle"; + ExecStart = "${lib.getExe cfg.package} prune"; + }; + }; + + systemd.user.timers.prune-allowed-direnv-dirs = { + Unit = { + Description = "Prune unused allowed directories for direnv"; + Documentation = [ "man:direnv(1)" ]; + }; + + Timer = { + Unit = "prune-allowed-direnv-dirs.service"; + OnCalendar = "daily"; + Persistent = true; + }; + + Install = { + WantedBy = [ "timers.target" ]; + }; + }; + }; +} diff --git a/home/programs/direnv.nix b/home/programs/direnv/default.nix similarity index 74% rename from home/programs/direnv.nix rename to home/programs/direnv/default.nix index 0f7a873..322598d 100644 --- a/home/programs/direnv.nix +++ b/home/programs/direnv/default.nix @@ -1,5 +1,9 @@ { ... }: { + imports = [ + ./auto-prune.nix + ]; + programs.direnv = { enable = true; enableZshIntegration = true;