-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Problem: We want broken/unfree/etc. packages (and their dependents) to refuse to evaluate and build without specific user request and to have an unpolluted hydra eval errors tab. Exception throwing does anything more structured than "yes this evaluates"/"no this doesn't" violates the purely functional nature of nix: The order of evaluate affects the result that a function catching an exception will see.
Proposed solution: Add a "poisoned derivation" type, which infects any derivations that depend on it in a non-eval-order dependent way and which can be introspected for arbitrary metadata but which by default simply causes an exception to be thrown.
Example: Package foo is marked broken, package bar depends on foo. nix-build -A bar throws "foo is marked broken, add allowBroken to try anyway" as soon as foo is evaluated, whereas:
let
maybe-poisoned = builtins.diagnosePoison pkgs.bar;
in if maybe-poisoned.poisoned && lib.only-broken-or-unfree maybe-poisoned.poisons
then { /* some set which doesn't reference bar */}
else { /* some set which does reference bar (via maybe-posoned.value), which either evaluates fine or throws if bar is poisoned for some reason besides being broken or unfree */ }`will evaluate to the first set, unless bar is also poisoned for some other reason we don't want to ignore. The specifics of the poisons attribute I haven't yet worked out, but can be made evaluation-order independent.
Alternative: Instead of the diagnosePoison builtin, we can just have different eval modes, where nix-build says "throw on poison" and hydra says "don't throw on poison" and poisoned drvs can be queried directly for poison status.
@edolstra I will implement this if it is an acceptable solution.
See also #1000 and NixOS/nixpkgs#7830