From 2f59d3d2bff5af9a5624fb0477b733bd9bb9dc71 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 12 Aug 2024 17:36:13 +0200 Subject: [PATCH] home/direnv: add auto prune timer --- home/home.nix | 2 +- home/programs/direnv/auto-prune.nix | 38 +++++++++++++++++++ .../{direnv.nix => direnv/default.nix} | 4 ++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 home/programs/direnv/auto-prune.nix rename home/programs/{direnv.nix => direnv/default.nix} (74%) 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;