Skip to content

Instantly share code, notes, and snippets.

@Mic92
Last active August 7, 2023 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mic92/fee7b25d1d7f7451d6e34f6c3db14f28 to your computer and use it in GitHub Desktop.
Save Mic92/fee7b25d1d7f7451d6e34f6c3db14f28 to your computer and use it in GitHub Desktop.
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p sqlite -p bash
SQL=$(cat <<EOF
select * from DerivationOutputs do
inner join ValidPaths vp on vp.id = do.drv
inner join Refs r1 on r1.referrer = vp.id
inner join ValidPaths vp2 on r1.reference = vp2.id
where do.path GLOB '/nix/store/$1-*'
EOF
)
sqlite3 -readonly /nix/var/nix/db/db.sqlite "$SQL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment