5 : ${NIXPKGS=/etc/nixos/nixpkgs}
7 tmp
=$
(mktemp
--tmpdir -d nixpkgs-dep-license.XXXXXX
)
15 trap "exitHandler" EXIT
17 # fetch the trace and the drvPath of the attribute.
18 nix-instantiate
$NIXPKGS -A $attr --show-trace > "$tmp/drvPath" 2> "$tmp/trace" ||
{
19 cat 1>&2 - "$tmp/trace" <<EOF
20 An error occurred while evaluating $attr.
25 # generate a sed script based on the trace output.
30 s,.*@:drv:\(.*\):\(.*\):@.*,s!\1!\1: \2!; t;,
31 s!Str(\\\"\([^,]*\)\\\",\[\])!\1!g
35 ' "$tmp/trace" > "$tmp/filter.sed"
37 if test $
(wc -l "$tmp/filter.sed" |
sed 's/ .*//') == 0; then
39 No derivation mentionned in the stack trace. Either your derivation does
40 not use stdenv.mkDerivation or you forgot to use the stdenv adapter named
43 - defaultStdenv = allStdenvs.stdenv;
44 + defaultStdenv = traceDrvLicenses allStdenvs.stdenv;
50 # remove all dependencies which are using stdenv.mkDerivation
53 ' >> "$tmp/filter.sed"
55 nix-store
-q --tree $
(cat "$tmp/drvPath") |
sed -f "$tmp/filter.sed"