Skip to content

Instantly share code, notes, and snippets.

@risicle
Last active July 11, 2022 21:09
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 risicle/d2a2ccfbeccdaef76f34f37dcd412b20 to your computer and use it in GitHub Desktop.
Save risicle/d2a2ccfbeccdaef76f34f37dcd412b20 to your computer and use it in GitHub Desktop.
#!/bin/bash
ALL_ATTRS_NIX=$(mktemp)
PKGS_PATH="."
#NIX_SYSTEM="x86_64-linux"
cat > "$ALL_ATTRS_NIX" <<EOF
{}@args: let pkgs = (import $(realpath "$PKGS_PATH") args); in with pkgs; builtins.filter (x: x != null) (builtins.map (x: if (builtins.tryEval x.drvPath).success then x else null) [
EOF
nix-env -f "$PKGS_PATH" ${NIX_SYSTEM:+--argstr system "$NIX_SYSTEM"} -qaP --no-name >> "$ALL_ATTRS_NIX"
echo '])' >> "$ALL_ATTRS_NIX"
nix-instantiate "$ALL_ATTRS_NIX" ${NIX_SYSTEM:+--argstr system "$NIX_SYSTEM"} | cut -f1 -d '!' | sort | uniq | while read f ; do grep -El "$1" $f ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment