-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Description
Describe the bug
As a low-level approach to update Language-level derivations without affecting the value of its drvPath and outPath lib.extendDerivation has no idea about existing overriders (attributes that perform overriding) added by stdenv.mkDerivation or other build helpers. This causes surprising behaviors of per-output overriders and the effect of lib.extendDerivation lost after updating for derivations updated by lib.extendDerivation.
This has cause passthru value loss after overriding on several packages including the Linux kernel packages (#111504) and the python module packages made by buildPythonPackage or buildPythonApplication. The assertion added by lib.extendDerivation is also prone to loss after overriding.
Steps To Reproduce
Background:
nix-repl> pkgs.cowsay
«derivation /nix/store/snay6nazh182gnk10xkk8c0839p71m9k-cowsay-3.7.0.drv»
nix-repl> pkgs.cowsay.outputs
[ "out" "man" ]
Reproducer of the wrong behavior of <pkg>.<outputName>.overrideAttrs when <outputName> is not out after updated by lib.extendDerivation.
nix-repl> (pkgs.cowsay.man.overrideAttrs { }).outputName
"man"
nix-repl> (pkgs.cowsay.man.override { }).outputName
"man"
nix-repl> ((lib.extendDerivation true { } pkgs.cowsay).man.overrideAttrs { }).outputName
"out"
nix-repl> ((lib.extendDerivation true { } pkgs.cowsay).man.override { }).outputName
"out"
Reproducer of the loss of passthru values after overriding:
nix-repl> hello-with-ans = lib.extendDerivation true { ans = 42; } pkgs.hello
nix-repl> hello-with-ans.ans
42
nix-repl> (hello-with-ans.overrideAttrs { }).ans
error: attribute 'ans' missing
nix-repl> (hello-with-ans.override { }).ans
error: attribute 'ans' missing
Reproducer of the loss of assertions added by lib.extendDerivation after overriding:
nix-repl> hello-five = lib.extendDerivation (builtins.trace "2 + 2 != 5" false) { } pkgs.hello
nix-repl> hello-five
trace: 2 + 2 != 5
error: assertion 'condition' failed
«derivation
nix-repl> hello-five.overrideAttrs { }
«derivation /nix/store/hyljyc0pml0l1gxqmrxby45q8gwidxgd-hello-2.12.1.drv»
nix-repl> hello-five.override { }
«derivation /nix/store/hyljyc0pml0l1gxqmrxby45q8gwidxgd-hello-2.12.1.drv»
Expected behavior
nix-repl> ((lib.extendDerivation true { } pkgs.cowsay).man.overrideAttrs { }).outputName
"man"
nix-repl> ((lib.extendDerivation true { } pkgs.cowsay).man.override { }).outputName
"man"
nix-repl> (hello-with-ans.overrideAttrs { }).ans
42
nix-repl> (hello-with-ans.override { }).ans
42
nix-repl> hello-five.overrideAttrs { }
trace: 2 + 2 != 5
error: assertion 'condition' failed
«derivation
nix-repl> hello-five.override { }
trace: 2 + 2 != 5
error: assertion 'condition' failed
«derivation
Potential solutions/workarounds
- Fix this issue directly inside
lib.extendDerivation: This would be tough, and would make the implementation much more complex and slower than the original one. - Use the
passthruattribute provided bystdenv.mkDerivationwhenever applicable. One of the major application oflib.extendDerivationis to implementstdenv.mkDerivation, and the latter already provide a friendlier and more overridable interface (i.e. thepassthruattribute) to pass attributes down to each outputs withoutdrvAttrs. It should be suitable for most use cases when the assertion is not needed. - Implement a
lib.extendDerivationalternative that takes care of the overriders properly and re-apply the changes to future overriding results. lib.extendDerivation': init to fix overriding issues caused by lib.extendDerivation #269785 is one such attempt.
Screenshots
Additional context
Notify maintainers
Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.
[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
output hereAdd a 👍 reaction to issues you find important.