blob: 1cb4ea9d03ba1c0f33b9bcd8e38f28514b44978d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.direnv;
in
{
programs.direnv.nix-direnv.enable = true;
systemd.user = lib.mkIf cfg.enable (
pkgs.personal.lib.homeManager.serviceWithTimer "direnv-clean-update" {
Unit = {
Description = "Remove old virtual environments and update the current ones";
After = [ "network-online.target" ];
};
Service = {
Type = "oneshot";
ExecSearchPath = "${pkgs.coreutils}/bin:${pkgs.findutils}/bin:${pkgs.direnv}/bin:/bin/sh";
WorkingDirectory = "${config.home.homeDirectory}";
ExecStart = ''
find -type d -name .direnv \
-execdir nix flake update || true \; \
-execdir /bin/sh -c "rm -f .direnv/{nix,flake}-profile*" \; \
-execdir direnv exec . true \;
'';
};
Timer = {
Persistent = true;
OnCalendar = "daily";
};
Install = {
WantedBy = [ "default.target " ];
};
}
);
}
|