From 0fc48fd45f756534648d989f5a2c4f3060464218 Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 24 Dec 2023 04:20:53 -0500 Subject: pkgs: auto-import directories *and* files --- pkgs/nixgc.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pkgs/nixgc.nix (limited to 'pkgs/nixgc.nix') diff --git a/pkgs/nixgc.nix b/pkgs/nixgc.nix new file mode 100644 index 0000000..9e25bd7 --- /dev/null +++ b/pkgs/nixgc.nix @@ -0,0 +1,25 @@ +# this is a shell script that uses the new nix cli to emulate +# nix-collect-garbage +{ + lib, + writeShellApplication, + nix, + fd, +}: +writeShellApplication { + name = "nixgc"; + + runtimeInputs = [nix fd]; + + text = '' + fd . /nix/var/nix/profiles /home/*/.local/state/nix/profiles -d 3 -t symlink -E '*-link' | while read -r profile; do + nix profile wipe-history --profile "$profile" "$@" + done + ''; + + meta = with lib; { + description = "nix-collect-garbage, but with nix profile"; + maintainers = [maintainers.getchoo]; + platforms = platforms.linux; + }; +} -- cgit v1.2.3