lol

* Add a script to retrieve licenses of the current derivation and of all its dependencies. To make it works, you need to change the default stdenv as documented in the error message.

./maintainers/scripts/dep-licenses.sh <attribute name>

svn path=/nixpkgs/trunk/; revision=18508

+82
+57
maintainers/scripts/dep-licenses.sh
··· 1 + #!/bin/sh 2 + 3 + attr=$1 4 + 5 + : ${NIXPKGS=/etc/nixos/nixpkgs} 6 + 7 + tmp=$(mktemp --tmpdir -d nixpkgs-dep-license.XXXXXX) 8 + 9 + exitHandler() { 10 + exitCode=$? 11 + rm -rf "$tmp" 12 + exit $exitCode 13 + } 14 + 15 + trap "exitHandler" EXIT 16 + 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 occured while evaluating $attr. 21 + EOF 22 + exit 1 23 + } 24 + 25 + # generate a sed script based on the trace output. 26 + sed ' 27 + \,@:.*:@, { 28 + # \1 *.drv file 29 + # \2 License terms 30 + s,.*@:drv:\(.*\):\(.*\):@.*,s!\1!\1: \2!; t;, 31 + s!Str(\\\"\([^,]*\)\\\",\[\])!\1!g 32 + b 33 + } 34 + d 35 + ' "$tmp/trace" > "$tmp/filter.sed" 36 + 37 + if test $(wc -l "$tmp/filter.sed" | sed 's/ .*//') == 0; then 38 + echo 1>&2 " 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 41 + traceDrvLicenses. 42 + 43 + - defaultStdenv = allStdenvs.stdenv; 44 + + defaultStdenv = traceDrvLicenses allStdenvs.stdenv; 45 + " 46 + exit 1 47 + fi 48 + 49 + 50 + # remove all dependencies which are using stdenv.mkDerivation 51 + echo ' 52 + d 53 + ' >> "$tmp/filter.sed" 54 + 55 + nix-store -q --tree $(cat "$tmp/drvPath") | sed -f "$tmp/filter.sed" 56 + 57 + exit 0;
+25
pkgs/stdenv/adapters.nix
··· 202 202 (stdenv.mkDerivation args) 203 203 { meta.maintainers = maintainers; }; 204 204 }; 205 + 206 + 207 + /* Use the trace output to report all processed derivations with their 208 + license name. 209 + 210 + */ 211 + traceDrvLicenses = stdenv: stdenv // 212 + { mkDerivation = args: 213 + let 214 + pkg = stdenv.mkDerivation args; 215 + printDrvPath = val: let 216 + drvPath = builtins.unsafeDiscardStringContext pkg.drvPath; 217 + license = 218 + if pkg ? meta && pkg.meta ? license then 219 + pkg.meta.license 220 + else 221 + null; 222 + in 223 + builtins.trace "@:drv:${toString drvPath}:${builtins.exprToString license}:@" 224 + val; 225 + in pkg // { 226 + outPath = printDrvPath pkg.outPath; 227 + drvPath = printDrvPath pkg.drvPath; 228 + }; 229 + }; 205 230 }