Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Last active January 20, 2020 04:45
Show Gist options
  • Save CMCDragonkai/0908706df9c9dbc45575a2345fab93f1 to your computer and use it in GitHub Desktop.
Save CMCDragonkai/0908706df9c9dbc45575a2345fab93f1 to your computer and use it in GitHub Desktop.
Garbage collect `./result*` symlinks using Nix #nix
#!/usr/bin/env bash
# if no argument is passed in, we use the current directory
dir="${1:-.}"
while IFS= read -r -d '' file; do
store_path="$(readlink "$file")"
rm --verbose "$file"
nix-store --delete "$store_path"
done < <(find "$dir" -maxdepth 1 -type l -lname '/nix/store/*' -print0)
@CMCDragonkai
Copy link
Author

This should be turned into an application that can be installed it seems quite useful to alot of people.

Also this should be renamed nix-build-gc.

@CMCDragonkai
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment