Created
August 12, 2016 00:15
-
-
Save olejorgenb/7c2c4328060cf5be0b55bfb5b4b08f2f to your computer and use it in GitHub Desktop.
Find python packages that are likely to fail when used through "nix-shell -p"
This file contains 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 | |
# evaluate expr, returning default on error | |
tryDefault = expr: default: | |
let res = (tryEval expr); | |
in if res.success then res.value else default; | |
isPython = pkg: pkg?name && (parseDrvName pkg.name).name == "python"; | |
hasPropagatedPython = pkg: | |
(pkg?propagatedNativeBuildInputs && | |
(length (filter isPython pkg.propagatedNativeBuildInputs)) > 0) | |
; | |
# Skip broken packages and packages that doesn't support the given python version | |
validPythonPackage = pkg: tryDefault (pkg?disabled -> !pkg.disabled) | |
false | |
; | |
in | |
rec { | |
inherit tryDefault validPythonPackage hasPropagatedPython isPython; | |
validPythonPackages = pkgs: (filter validPythonPackage | |
(attrValues pkgs)); | |
withoutPropagatedPython = pkgs: | |
filter | |
(pkg: tryDefault (pkg?name && !(hasPropagatedPython pkg)) false) | |
(validPythonPackages pkgs); | |
} | |
# run `nix-repl THISFILE.nix` | |
# :l <nixpkgs> | |
# builtins.map (pkg: pkg.name) (withoutPropagatedPython python2Packages) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment