blob: f2519088f138a8d398abf33ec8770f7571778f8c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
{ lib, pkgs, stdenvNoCC }:
let
tests =
let
p = pkgs.python3Packages.xpybutil.overridePythonAttrs (_: { dontWrapPythonPrograms = true; });
in
[
({
name = "overridePythonAttrs";
expr = !lib.hasInfix "wrapPythonPrograms" p.postFixup;
expected = true;
})
({
name = "repeatedOverrides-pname";
expr = repeatedOverrides.pname == "a-better-hello-with-blackjack";
expected = true;
})
({
name = "repeatedOverrides-entangled-pname";
expr = repeatedOverrides.entangled.pname == "a-better-figlet-with-blackjack";
expected = true;
})
({
name = "overriding-using-only-attrset";
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:
origOverrideAttrs (
lib.composeExtensions f (self: super: {
passthru = super.passthru // {
entangled = super.passthru.entangled.overrideAttrs f;
overrideAttrs = addEntangled self.overrideAttrs;
};
})
);
entangle = pkg1: pkg2: pkg1.overrideAttrs (self: super: {
passthru = super.passthru // {
entangled = pkg2;
overrideAttrs = addEntangled self.overrideAttrs;
};
});
example = entangle pkgs.hello pkgs.figlet;
overrides1 = example.overrideAttrs (_: super: { pname = "a-better-${super.pname}"; });
repeatedOverrides = overrides1.overrideAttrs (_: super: { pname = "${super.pname}-with-blackjack"; });
in
stdenvNoCC.mkDerivation {
name = "test-overriding";
passthru = { inherit tests; };
buildCommand = ''
touch $out
'' + lib.concatMapStringsSep "\n" (t: "([[ ${lib.boolToString t.expr} == ${lib.boolToString t.expected} ]] && echo '${t.name} success') || (echo '${t.name} fail' && exit 1)") tests;
}
|