2024-01-21 19:29:36 +03:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
dirsToClean = [
|
|
|
|
"Downloads"
|
|
|
|
];
|
|
|
|
olderThanDays = "14";
|
|
|
|
in {
|
2022-12-10 22:34:39 +03:00
|
|
|
home-manager.users.${config.mainuser} = {
|
2021-06-16 05:30:04 +03:00
|
|
|
xdg.enable = true;
|
|
|
|
xdg.userDirs.enable = true;
|
|
|
|
};
|
|
|
|
|
2023-04-15 03:21:02 +03:00
|
|
|
environment.sessionVariables = { DE = "generic"; };
|
|
|
|
|
|
|
|
systemd.user.services.cleanup-home-dirs = let
|
|
|
|
home-conf = config.home-manager.users.${config.mainuser};
|
2024-01-21 19:29:36 +03:00
|
|
|
directories = map (x: home-conf.home.homeDirectory + "/" + x) dirsToClean;
|
2023-04-15 03:21:02 +03:00
|
|
|
in {
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
script = ''
|
|
|
|
${builtins.concatStringsSep "\n" (map (x:
|
|
|
|
"find ${
|
|
|
|
lib.escapeShellArg x
|
2024-01-21 19:29:36 +03:00
|
|
|
} -mtime +${olderThanDays} -exec rm -rv {} + -depth;")
|
|
|
|
directories)}
|
2023-04-15 03:21:02 +03:00
|
|
|
'';
|
|
|
|
wantedBy = [ "default.target" ];
|
2021-06-16 05:30:04 +03:00
|
|
|
};
|
2022-12-14 23:46:25 +03:00
|
|
|
|
2023-04-15 03:21:02 +03:00
|
|
|
persist.state.homeDirectories =
|
2023-04-25 17:45:38 +03:00
|
|
|
[ "Books" "Documents" "Downloads" "Music" "Pictures" "Videos" ];
|
2023-04-15 03:21:02 +03:00
|
|
|
}
|