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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
from testlib.fixtures.nix import Nix
from testlib.fixtures.file_helper import with_files
from testlib.utils import get_global_asset
import json
from textwrap import dedent
@with_files(
{
"multiple-outputs.nix": get_global_asset("multiple-outputs.nix"),
"config.nix": get_global_asset("config.nix"),
}
)
def test_regression_6572_independent(nix: Nix):
"""
https://github.com/NixOS/nix/issues/6572
"""
nix.settings.add_xp_feature("nix-command")
independent_text = (
nix.nix(["build", "-f", "multiple-outputs.nix", "--json", "independent", "--no-link"])
.run()
.ok()
)
independent_json = json.loads(independent_text.stdout_plain)
# Make sure that 'nix build' can build a derivation that depends on both outputs of another derivation.
res = (
nix.nix(
[
"build",
"-f",
"multiple-outputs.nix",
"use-independent",
"--no-link",
"--print-out-paths",
]
)
.run()
.ok()
)
path = res.stdout_plain
res = nix.nix_store(["--delete", path]).run().ok()
assert "1 store paths deleted" in res.stderr_plain
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
res = nix.nix_store(["--delete", independent_json[0]["outputs"]["first"]]).run().ok()
assert "1 store paths deleted" in res.stderr_plain
res = (
nix.nix(
[
"build",
"-f",
"multiple-outputs.nix",
"use-independent",
"--no-link",
"--print-out-paths",
]
)
.run()
.ok()
)
assert nix.physical_store_path_for(res.stdout_plain).read_text() == dedent("""\
first
second
""")
res = nix.nix_store(["--delete", path]).run().ok()
assert "1 store paths deleted" in res.stderr_plain
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
res = nix.nix_store(["--delete", independent_json[0]["outputs"]["second"]]).run().ok()
assert "1 store paths deleted" in res.stderr_plain
res = (
nix.nix(
[
"build",
"-f",
"multiple-outputs.nix",
"use-independent",
"--no-link",
"--print-out-paths",
]
)
.run()
.ok()
)
assert nix.physical_store_path_for(res.stdout_plain).read_text() == dedent("""\
first
second
""")
@with_files(
{
"multiple-outputs.nix": get_global_asset("multiple-outputs.nix"),
"config.nix": get_global_asset("config.nix"),
}
)
def test_regression_6572_dependent(nix: Nix):
"""
https://github.com/NixOS/nix/issues/6572
"""
nix.settings.add_xp_feature("nix-command")
res = nix.nix(["build", "-f", "multiple-outputs.nix", "--json", "a", "--no-link"]).run().ok()
second_path = json.loads(res.stdout_plain)[0]["outputs"]["second"]
path = (
nix.nix(["build", "-f", "multiple-outputs.nix", "use-a", "--no-link", "--print-out-paths"])
.run()
.ok()
.stdout_plain
)
res = nix.nix_store(["--delete", path]).run().ok()
assert "1 store paths deleted" in res.stderr_plain
res = nix.nix_store(["--delete", second_path]).run().ok()
assert "1 store paths deleted" in res.stderr_plain
res = (
nix.nix(["build", "-f", "multiple-outputs.nix", "use-a", "--no-link", "--print-out-paths"])
.run()
.ok()
)
assert nix.physical_store_path_for(res.stdout_plain).read_text() == dedent("""\
first
second
""")
|