Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Find python packages that are likely to fail when used through "nix-shell -p"
with builtins;
# 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 == "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)
rec {
inherit tryDefault validPythonPackage hasPropagatedPython isPython;
validPythonPackages = pkgs: (filter validPythonPackage
(attrValues pkgs));
withoutPropagatedPython = pkgs:
(pkg: tryDefault (pkg?name && !(hasPropagatedPython pkg)) false)
(validPythonPackages pkgs);
# run `nix-repl THISFILE.nix`
# :l <nixpkgs>
# (pkg: (withoutPropagatedPython python2Packages)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment