Last active
May 11, 2023 18:55
-
-
Save infinisil/4f2bd165c2603fc28ab536f39ac2fd27 to your computer and use it in GitHub Desktop.
The number of attributes in Nixpkgs that are affected by RFC 140
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
{ | |
system ? builtins.currentSystem, | |
nixpkgs ? fetchTarball { | |
url = "https://github.com/NixOS/nixpkgs/tarball/6948ef4deff7a72ebe5242244bd3730e8542b925"; | |
sha256 = "1fw8vlbcxr3kw96rrjlw94zhbjs3a32dcnvav19cvniwlbhf2jsh"; | |
}, | |
}: | |
let | |
pkgs = import nixpkgs { | |
inherit system; | |
config = { | |
allowAliases = false; | |
}; | |
overlays = [(self: super: { | |
callPackage = file: args: | |
let | |
result = super.callPackage file args; | |
in | |
if self.lib.isAttrs result then | |
result // { | |
_isCallPackage = true; | |
} | |
else | |
# Currently only an irrelevant mathematica non-top-level call | |
# builtins.trace "Got a non-attr callPackage for ${toString file}" | |
result; | |
})]; | |
}; | |
inherit (pkgs) lib; | |
processed = map (value: | |
let | |
result = value._isCallPackage or false && lib.isDerivation value; | |
try = builtins.tryEval result; | |
in | |
if try.success then | |
try.value | |
else | |
null | |
) (lib.attrValues pkgs); | |
evaluate = lib.filter (value: value != null) processed; | |
evaluateLength = lib.length evaluate; | |
matching = lib.filter (value: value) evaluate; | |
matchingLength = lib.length matching; | |
percentMatching = 100.0 / evaluateLength * matchingLength; | |
result = builtins.trace '' | |
Out of ${toString evaluateLength} total non-alias attributes that can be evaluated, ${toString percentMatching}% (${toString matchingLength}) are derivations using `callPackage` | |
'' null; | |
in { | |
inherit result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Evaluate with
Result: