From 27cc126d4aa7f8ae0125b0c4e712d5e57a9e57b6 Mon Sep 17 00:00:00 2001 From: lelgenio Date: Tue, 8 Aug 2023 17:55:13 -0300 Subject: [PATCH] storage: automatically cleanup old files --- system/configuration.nix | 1 + user/home.nix | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/system/configuration.nix b/system/configuration.nix index ceab9e3..77a1eae 100644 --- a/system/configuration.nix +++ b/system/configuration.nix @@ -44,6 +44,7 @@ services.flatpak.enable = true; virtualisation.docker.enable = true; virtualisation.docker.autoPrune.enable = true; + virtualisation.docker.autoPrune.flags = [ "--all --volumes" ]; programs.firejail.enable = true; security.rtkit.enable = true; diff --git a/user/home.nix b/user/home.nix index 896243f..377b728 100644 --- a/user/home.nix +++ b/user/home.nix @@ -181,6 +181,26 @@ exec nicotine ''; + systemd.user.services.rm-target = { + Unit = { + Description = "Remove directories named 'target'"; + }; + Service = { + Type = "oneshot"; + ExecStart = pkgs.writeShellScript "rm-target" '' + sudo ${pkgs.fd}/bin/fd -td -u '^\.?target$' "$HOME" -x rm -vrf -- + ''; + }; + }; + systemd.user.timers.rm-target = { + Unit = { Description = "Remove directories named 'target'"; }; + Timer = { + OnCalendar = "weekly"; + Unit = "rm-target.service"; + }; + Install = { WantedBy = [ "timers.target" ]; }; + }; + # This value determines the Home Manager release that your # configuration is compatible with. This helps avoid breakage # when a new Home Manager release introduces backwards