Skip to content

Instantly share code, notes, and snippets.

@barrbrain
Last active July 11, 2024 07:03
Show Gist options
  • Select an option

  • Save barrbrain/838440d10c2acbdf6f87b0f6d563d37c to your computer and use it in GitHub Desktop.

Select an option

Save barrbrain/838440d10c2acbdf6f87b0f6d563d37c to your computer and use it in GitHub Desktop.
Pin NixOS build deps
set -e
ROOTS=${1:-/root/dev-roots}
mkdir -p "$ROOTS"
rm "$ROOTS/"*
nix --extra-experimental-features nix-command derivation show -r /run/current-system |
jq -r 'map(select(.outputs.out.path)) | map(.outputs.out.path) | unique .[]' |
grep -xFf <(nix-store --gc --print-dead) |
xargs ln -vst "$ROOTS"
ln -vst /nix/var/nix/gcroots/auto "$ROOTS/"*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment