Created
September 30, 2018 17:05
-
-
Save markuskowa/20700860c09af1ca4cc828f8dc2e36b3 to your computer and use it in GitHub Desktop.
Nix expression for finding derivations with missing licenses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with builtins; | |
let | |
pkgs = import ./nixpkgs { overlays = []; }; | |
# clean evals | |
cc1 = pkgs.lib.mapAttrs (n: v: (builtins.tryEval v).value ) pkgs; | |
# Only top level derivations | |
cc2 = pkgs.lib.filterAttrs (n: v: pkgs.lib.isDerivation v) cc1; | |
# Filter for meta tags | |
cc3 = pkgs.lib.filterAttrs (n: v: v ? "meta") cc2; | |
noLic = with pkgs.lib; concatStringsSep "\n" | |
( | |
mapAttrsToList (name: v: "${v.meta.position}") ( | |
filterAttrs (n: v: (! hasAttr "license" v.meta) && (hasAttr "position" v.meta) ) cc3 | |
) | |
); | |
in pkgs.runCommand "missing-licenses" | |
{} | |
'' | |
mkdir $out | |
cat << EOF > $out/unsorted | |
${noLic} | |
EOF | |
cat $out/unsorted | sort | uniq > $out/unique | |
'' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment