summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseth <[email protected]>2023-08-08 09:10:49 -0400
committerseth <[email protected]>2023-08-08 09:10:49 -0400
commitab4a5cb0c6c713d5e3a98f3e21eb8a2bb759653d (patch)
tree2cb928422ed95b9ea389989c5a6ad4d199bc8ff7
parenta0229f519b150e51d8994c98b639c4df45d82d6f (diff)
pkgs: make nixgc an actual package
-rw-r--r--misc/nixgc.nix11
-rw-r--r--pkgs/default.nix1
-rw-r--r--pkgs/nixgc.nix22
3 files changed, 23 insertions, 11 deletions
diff --git a/misc/nixgc.nix b/misc/nixgc.nix
deleted file mode 100644
index 9b2b357..0000000
--- a/misc/nixgc.nix
+++ /dev/null
@@ -1,11 +0,0 @@
-# this is a shell script that uses the new nix cli to emulate
-# nix-collect-garbage
-with (import (builtins.getFlake "nixpkgs") {});
- writeScriptBin "nixgc" ''
- #!${fish}/bin/fish
- set -l profiles (find /nix/var/nix/profiles/ -maxdepth 3 -type l -not -name '*-link')
-
- for profile in $profiles
- sudo nix profile wipe-history --profile $profile
- end
- ''
diff --git a/pkgs/default.nix b/pkgs/default.nix
index dbdc6f5..84e34bb 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -7,6 +7,7 @@ in {
fastfetch = callPackage ./fastfetch.nix {};
huion = callPackage ./huion.nix {};
mommy = callPackage ./mommy.nix {};
+ nixgc = callPackage ./nixgc.nix {};
theseus = callPackage ./theseus.nix {
inherit (pkgs.nodePackages) pnpm;
inherit (pkgs.darwin.apple_sdk.frameworks) CoreServices Security WebKit;
diff --git a/pkgs/nixgc.nix b/pkgs/nixgc.nix
new file mode 100644
index 0000000..d13614a
--- /dev/null
+++ b/pkgs/nixgc.nix
@@ -0,0 +1,22 @@
+# 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.platforms = lib.platforms.linux;
+}