Skip to content

Instantly share code, notes, and snippets.

@LnL7
Created September 12, 2018 20:24
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 LnL7/59d26191a5f313a2ffdb4475b03df164 to your computer and use it in GitHub Desktop.
Save LnL7/59d26191a5f313a2ffdb4475b03df164 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
if ! test -e /tmp/nix-nixpkgs-cache; then
nix-env -f '<nixpkgs>' -qaP --no-name --out-path \* > /tmp/nix-nixpkgs-cache
fi
exprs="with import <nixpkgs> {}; (pkgs.runCommandCC or pkgs.runCommand) \"instantiate\" { buildInputs = [ $* ]; } \"\""
exprsDrv=$(nix-instantiate -E "$exprs" 2> /dev/null)
for drv in $(nix-store -qR "$exprsDrv"); do
out="$(nix-store -q --binding out "$drv" 2> /dev/null)"
if test -n "$out"; then
grep "$out" /tmp/nix-nixpkgs-cache | awk '{print $1}'
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment