1 { lib, pkgs, stdenvNoCC }:
6 p = pkgs.python3Packages.xpybutil.overridePythonAttrs (_: { dontWrapPythonPrograms = true; });
9 overridePythonAttrs = {
10 expr = !lib.hasInfix "wrapPythonPrograms" p.postFixup;
13 repeatedOverrides-pname = {
14 expr = repeatedOverrides.pname == "a-better-hello-with-blackjack";
17 repeatedOverrides-entangled-pname = {
18 expr = repeatedOverrides.entangled.pname == "a-better-figlet-with-blackjack";
21 overriding-using-only-attrset = {
22 expr = (pkgs.hello.overrideAttrs { pname = "hello-overriden"; }).pname == "hello-overriden";
25 overriding-using-only-attrset-no-final-attrs = {
26 name = "overriding-using-only-attrset-no-final-attrs";
27 expr = ((stdenvNoCC.mkDerivation { pname = "hello-no-final-attrs"; }).overrideAttrs { pname = "hello-no-final-attrs-overridden"; }).pname == "hello-no-final-attrs-overridden";
30 buildGoModule-overrideAttrs = {
34 attrPathPretty = lib.concatStringsSep "." attrPath;
35 valueNative = lib.getAttrFromPath attrPath pet_0_4_0;
36 valueOverridden = lib.getAttrFromPath attrPath pet_0_4_0-overridden;
39 (valueNative == valueOverridden)
40 "pet_0_4_0.${attrPathPretty} (${valueNative}) does not equal pet_0_4_0-overridden.${attrPathPretty} (${valueOverridden})"
48 [ "goModules" "drvPath" ]
49 [ "goModules" "name" ]
50 [ "goModules" "outputHash" ]
54 buildGoModule-goModules-overrideAttrs = {
55 expr = pet-foo.goModules.FOO == "foo";
58 buildGoModule-goModules-overrideAttrs-vendored = {
59 expr = lib.isString pet-vendored.drvPath;
64 addEntangled = origOverrideAttrs: f:
66 lib.composeExtensions f (self: super: {
67 passthru = super.passthru // {
68 entangled = super.passthru.entangled.overrideAttrs f;
69 overrideAttrs = addEntangled self.overrideAttrs;
74 entangle = pkg1: pkg2: pkg1.overrideAttrs (self: super: {
75 passthru = super.passthru // {
77 overrideAttrs = addEntangled self.overrideAttrs;
81 example = entangle pkgs.hello pkgs.figlet;
83 overrides1 = example.overrideAttrs (_: super: { pname = "a-better-${super.pname}"; });
85 repeatedOverrides = overrides1.overrideAttrs (_: super: { pname = "${super.pname}-with-blackjack"; });
87 pet_0_3_4 = pkgs.buildGoModule rec {
91 src = pkgs.fetchFromGitHub {
95 hash = "sha256-Gjw1dRrgM8D3G7v6WIM2+50r4HmTXvx0Xxme2fH9TlQ=";
98 vendorHash = "sha256-ciBIR+a1oaYH+H1PcC8cD8ncfJczk1IiJ8iYNM+R6aA=";
101 description = "Simple command-line snippet manager, written in Go";
102 homepage = "https://github.com/knqyf263/pet";
103 license = lib.licenses.mit;
104 maintainers = with lib.maintainers; [ kalbasit ];
108 pet_0_4_0 = pkgs.buildGoModule rec {
112 src = pkgs.fetchFromGitHub {
116 hash = "sha256-gVTpzmXekQxGMucDKskGi+e+34nJwwsXwvQTjRO6Gdg=";
119 vendorHash = "sha256-dUvp7FEW09V0xMuhewPGw3TuAic/sD7xyXEYviZ2Ivs=";
122 description = "Simple command-line snippet manager, written in Go";
123 homepage = "https://github.com/knqyf263/pet";
124 license = lib.licenses.mit;
125 maintainers = with lib.maintainers; [ kalbasit ];
129 pet_0_4_0-overridden = pet_0_3_4.overrideAttrs (finalAttrs: previousAttrs: {
132 src = pkgs.fetchFromGitHub {
133 inherit (previousAttrs.src) owner repo;
134 rev = "v${finalAttrs.version}";
135 hash = "sha256-gVTpzmXekQxGMucDKskGi+e+34nJwwsXwvQTjRO6Gdg=";
138 vendorHash = "sha256-dUvp7FEW09V0xMuhewPGw3TuAic/sD7xyXEYviZ2Ivs=";
141 pet-foo = pet_0_3_4.overrideAttrs (
142 finalAttrs: previousAttrs: {
143 passthru = previousAttrs.passthru // {
144 overrideModAttrs = lib.composeExtensions previousAttrs.passthru.overrideModAttrs (
145 finalModAttrs: previousModAttrs: {
153 pet-vendored = pet-foo.overrideAttrs { vendorHash = null; };
156 stdenvNoCC.mkDerivation {
157 name = "test-overriding";
158 passthru = { inherit tests; };
161 '' + lib.concatStringsSep "\n" (lib.attrValues (lib.mapAttrs (name: t: "([[ ${lib.boolToString t.expr} == ${lib.boolToString t.expected} ]] && echo '${name} success') || (echo '${name} fail' && exit 1)") tests));