Created
March 30, 2021 20:16
-
-
Save guibou/9f9fd2088c150f91945c9e869bf04e7a to your computer and use it in GitHub Desktop.
Find licenses in a bunch of nix sets.
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
| licensesIn = acc: p: { | |
| res = if builtins.isAttrs p && builtins.hasAttr "meta" p then | |
| pkgs.lib.unique (acc.res ++ [{ | |
| package = p.pname or p.name or "N/A"; | |
| version = p.version or "N/A"; | |
| url = p.meta.homepage or "N/A"; | |
| licenses = (if builtins.isList (p.meta.license or "oops") then | |
| map (l: l.spdxId) p.meta.license | |
| else | |
| [ p.meta.license.spdxId or "N/A" ]); | |
| }]) | |
| else | |
| builtins.trace p acc.res; | |
| subs = pkgs.lib.unique (acc.subs ++ ((p.buildInputs or [ ]) | |
| ++ (p.nativeBuildInputs or [ ]) ++ (p.propagatedBuildInputs or [ ]))); | |
| }; | |
| grouniou = { res, subs }: | |
| if pkgs.lib.traceSeq ([ (builtins.length subs) (builtins.length res) ]) | |
| (builtins.length subs) == 0 then | |
| res | |
| else | |
| grouniou (builtins.foldl' licensesIn { | |
| res = res; | |
| subs = [ ]; | |
| } subs); | |
| licenses = grouniou { | |
| res = [ ]; | |
| subs = roots; | |
| }; | |
| li = pkgs.writeTextFile "crevette" (builtins.toJSON licenses); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment