Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Find python packages that are likely to fail when used through "nix-shell -p"
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