From 42c94d06fdb683ab9bd72a9cd624868386d0f0cd Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 3 Jul 2023 21:34:50 +0300 Subject: stdenv: fix overriding with attrset when finalAttrs isn't used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` nix-repl> (pkgs.htop.overrideAttrs { pname = "hello-overriden"; }).pname error: … while evaluating a branch condition at /nix/store/phn5cahwacv9wjgalygw62x8l4xbl6x3-source/lib/customisation.nix:86:7: 85| in 86| if builtins.isAttrs result then | ^ 87| result // { … while calling the 'isAttrs' builtin at /nix/store/phn5cahwacv9wjgalygw62x8l4xbl6x3-source/lib/customisation.nix:86:10: 85| in 86| if builtins.isAttrs result then | ^ 87| result // { (stack trace truncated; use '--show-trace' to show the full trace) error: attempt to call something which is not a function but a set at /nix/store/phn5cahwacv9wjgalygw62x8l4xbl6x3-source/pkgs/stdenv/generic/make-derivation.nix:58:21: 57| f = self: super: 58| let x = f0 super; | ^ 59| in ``` --- pkgs/stdenv/generic/make-derivation.nix | 2 +- pkgs/test/overriding.nix | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 8af162da7f2d..745426915987 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -62,7 +62,7 @@ let f0 self super else x; in - makeDerivationExtensible (self: attrs // f self attrs)) + makeDerivationExtensible (self: attrs // (if builtins.isFunction f0 || f0?__functor then f self attrs else f0))) attrs; mkDerivationSimple = overrideAttrs: diff --git a/pkgs/test/overriding.nix b/pkgs/test/overriding.nix index 7838f637f313..f2519088f138 100644 --- a/pkgs/test/overriding.nix +++ b/pkgs/test/overriding.nix @@ -26,6 +26,11 @@ let expr = (pkgs.hello.overrideAttrs { pname = "hello-overriden"; }).pname == "hello-overriden"; expected = true; }) + ({ + name = "overriding-using-only-attrset-no-final-attrs"; + expr = ((stdenvNoCC.mkDerivation { pname = "hello-no-final-attrs"; }).overrideAttrs { pname = "hello-no-final-attrs-overridden"; }).pname == "hello-no-final-attrs-overridden"; + expected = true; + }) ]; addEntangled = origOverrideAttrs: f: -- cgit 1.4.1