From db3a787f4dadf653005a9dfdd639fb0e0b6c05b3 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Thu, 11 Dec 2025 03:16:53 +0800 Subject: [PATCH 1/3] tests.overriding: rename local variable python-package-stub -> package-stub --- pkgs/test/overriding.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/test/overriding.nix b/pkgs/test/overriding.nix index a41400d0d6c1d..57f2604923584 100644 --- a/pkgs/test/overriding.nix +++ b/pkgs/test/overriding.nix @@ -390,7 +390,7 @@ let tests-python = let - python-package-stub = pkgs.python3Packages.callPackage ( + package-stub = pkgs.python3Packages.callPackage ( { buildPythonPackage, emptyDirectory, @@ -418,17 +418,17 @@ let in { overridePythonAttrs = { - expr = (applyOverridePythonAttrs python-package-stub).overridePythonAttrsFlag; + expr = (applyOverridePythonAttrs package-stub).overridePythonAttrsFlag; expected = 1; }; overridePythonAttrs-nested = { expr = - (applyOverridePythonAttrs (applyOverridePythonAttrs python-package-stub)).overridePythonAttrsFlag; + (applyOverridePythonAttrs (applyOverridePythonAttrs package-stub)).overridePythonAttrsFlag; expected = 2; }; overrideAttrs-overridePythonAttrs-test-overrideAttrs = { expr = { - inherit (applyOverridePythonAttrs (overrideAttrsFooBar python-package-stub)) + inherit (applyOverridePythonAttrs (overrideAttrsFooBar package-stub)) FOO BAR ; @@ -440,15 +440,15 @@ let }; overrideAttrs-overridePythonAttrs-test-overridePythonAttrs = { expr = - (applyOverridePythonAttrs (overrideAttrsFooBar python-package-stub)) ? overridePythonAttrsFlag; + (applyOverridePythonAttrs (overrideAttrsFooBar package-stub)) ? overridePythonAttrsFlag; expected = true; }; overrideAttrs-overridePythonAttrs-test-commutation = { - expr = overrideAttrsFooBar (applyOverridePythonAttrs python-package-stub); - expected = applyOverridePythonAttrs (overrideAttrsFooBar python-package-stub); + expr = overrideAttrsFooBar (applyOverridePythonAttrs package-stub); + expected = applyOverridePythonAttrs (overrideAttrsFooBar package-stub); }; chain-of-overrides = rec { - expr = lib.pipe python-package-stub [ + expr = lib.pipe package-stub [ (p: p.overrideAttrs { inherit (expected) a; }) (p: p.overridePythonAttrs { inherit (expected) b; }) (p: p.overrideAttrs { inherit (expected) c; }) From dacf4930a9000d4b00853125104db1006184edd1 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Sat, 25 Oct 2025 13:07:32 +0800 Subject: [PATCH 2/3] tests.overriding: test buildPythonPackage.override Co-authored-by: Matt Sturgeon --- pkgs/test/overriding.nix | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pkgs/test/overriding.nix b/pkgs/test/overriding.nix index 57f2604923584..de08808db3858 100644 --- a/pkgs/test/overriding.nix +++ b/pkgs/test/overriding.nix @@ -402,6 +402,23 @@ let src = emptyDirectory; } ) { }; + + package-stub-gcc = package-stub.override (previousArgs: { + buildPythonPackage = previousArgs.buildPythonPackage.override { + stdenv = pkgs.gccStdenv; + }; + }); + package-stub-clang = package-stub-gcc.override (previousArgs: { + buildPythonPackage = previousArgs.buildPythonPackage.override { + stdenv = pkgs.clangStdenv; + }; + }); + package-stub-libcxx = package-stub-clang.override (previousArgs: { + buildPythonPackage = previousArgs.buildPythonPackage.override { + stdenv = pkgs.libcxxStdenv; + }; + }); + applyOverridePythonAttrs = p: p.overridePythonAttrs (previousAttrs: { @@ -417,6 +434,19 @@ let ); in { + buildPythonPackage-override-gccStdenv = { + expr = package-stub-gcc.stdenv; + expected = pkgs.gccStdenv; + }; + buildPythonPackage-override-clangStdenv = { + expr = package-stub-clang.stdenv; + expected = pkgs.clangStdenv; + }; + buildPythonPackage-override-libcxxStdenv = { + expr = package-stub-libcxx.stdenv; + expected = pkgs.libcxxStdenv; + }; + overridePythonAttrs = { expr = (applyOverridePythonAttrs package-stub).overridePythonAttrsFlag; expected = 1; From 06711e45a0316e0f33b4f903067b26e706773daf Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Thu, 11 Dec 2025 03:39:27 +0800 Subject: [PATCH 3/3] tests.overriding: add overridePythonAttrs-stdenv-deprecated Co-authored-by: Matt Sturgeon --- pkgs/test/overriding.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkgs/test/overriding.nix b/pkgs/test/overriding.nix index de08808db3858..21baca35e927b 100644 --- a/pkgs/test/overriding.nix +++ b/pkgs/test/overriding.nix @@ -446,14 +446,20 @@ let expr = package-stub-libcxx.stdenv; expected = pkgs.libcxxStdenv; }; + overridePythonAttrs-stdenv-deprecated = { + expr = + (package-stub.overridePythonAttrs (_: { + stdenv = pkgs.clangStdenv; + })).stdenv; + expected = pkgs.clangStdenv; + }; overridePythonAttrs = { expr = (applyOverridePythonAttrs package-stub).overridePythonAttrsFlag; expected = 1; }; overridePythonAttrs-nested = { - expr = - (applyOverridePythonAttrs (applyOverridePythonAttrs package-stub)).overridePythonAttrsFlag; + expr = (applyOverridePythonAttrs (applyOverridePythonAttrs package-stub)).overridePythonAttrsFlag; expected = 2; }; overrideAttrs-overridePythonAttrs-test-overrideAttrs = { @@ -469,8 +475,7 @@ let }; }; overrideAttrs-overridePythonAttrs-test-overridePythonAttrs = { - expr = - (applyOverridePythonAttrs (overrideAttrsFooBar package-stub)) ? overridePythonAttrsFlag; + expr = (applyOverridePythonAttrs (overrideAttrsFooBar package-stub)) ? overridePythonAttrsFlag; expected = true; }; overrideAttrs-overridePythonAttrs-test-commutation = {