Compare commits
409
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba354cc649 | ||
|
|
8a1c40b927 | ||
|
|
1e5b1d9973 | ||
|
|
cccc26dcb1 | ||
|
|
9eb608cbef | ||
|
|
714662e675 | ||
|
|
052d5cb3fe | ||
|
|
36fa9b90d8 | ||
|
|
a9b6213221 | ||
|
|
fd0835e7d7 | ||
|
|
d07541be29 | ||
|
|
bc67e47298 | ||
|
|
876f676d90 | ||
|
|
9f94a1b9fb | ||
|
|
aa96bf2faf | ||
|
|
aff7facdf6 | ||
|
|
155411397d | ||
|
|
54b7ccc466 | ||
|
|
16f640a9b2 | ||
|
|
15fa95f925 | ||
|
|
4e586149df | ||
|
|
bebef8f0c4 | ||
|
|
933ed27dd9 | ||
|
|
047f2bc1af | ||
|
|
ef36806898 | ||
|
|
363ee6dfcb | ||
|
|
b257ea94e3 | ||
|
|
f186491db9 | ||
|
|
85420b8537 | ||
|
|
5eeeb44f79 | ||
|
|
2b2ea218d9 | ||
|
|
27907e6cac | ||
|
|
f683a555bf | ||
|
|
75679b323b | ||
|
|
b3bbbd2e71 | ||
|
|
e27d804929 | ||
|
|
6dcbac4278 | ||
|
|
6fe0545bf3 | ||
|
|
66ae8f4f44 | ||
|
|
470c521bcc | ||
|
|
fc8c11be48 | ||
|
|
9792d6bbd9 | ||
|
|
6c2a7fdc49 | ||
|
|
b509502bd5 | ||
|
|
d98c0dbe99 | ||
|
|
f81c06accf | ||
|
|
ae7f411a18 | ||
|
|
e83ef7a477 | ||
|
|
89ba6dff66 | ||
|
|
009ff8e5a7 | ||
|
|
cf6da9234c | ||
|
|
32409dd7d7 | ||
|
|
a0b2b75f59 | ||
|
|
99a16c5203 | ||
|
|
22c928f9c0 | ||
|
|
13a0853f04 | ||
|
|
995d4f4aa7 | ||
|
|
2109a5a206 | ||
|
|
9de9410f29 | ||
|
|
674375b021 | ||
|
|
d8be4f618f | ||
|
|
1e31b60043 | ||
|
|
d285b80033 | ||
|
|
307dbe9914 | ||
|
|
7acc229c8f | ||
|
|
b3aa07009d | ||
|
|
c0ed07755a | ||
|
|
4966217b6a | ||
|
|
b1fe93fab7 | ||
|
|
3f3fd2c94b | ||
|
|
7ea536fe84 | ||
|
|
0123640009 | ||
|
|
56d37656ac | ||
|
|
0e1323c041 | ||
|
|
f6df573a91 | ||
|
|
f64b8957c7 | ||
|
|
71567373b6 | ||
|
|
b1b75e1d7a | ||
|
|
837f349a99 | ||
|
|
3094e39dc4 | ||
|
|
51073607ea | ||
|
|
a46ca4f02f | ||
|
|
49f757c24a | ||
|
|
db297d3dda | ||
|
|
9da01e69f9 | ||
|
|
bbfe39ef27 | ||
|
|
7a0e38a1aa | ||
|
|
bf65bc7eb7 | ||
|
|
a0d3003bf2 | ||
|
|
6cd2b4e169 | ||
|
|
fc5b1d2344 | ||
|
|
e3042f10af | ||
|
|
012453d1e6 | ||
|
|
c7f8147282 | ||
|
|
3f3cc6f438 | ||
|
|
26cb166bca | ||
|
|
b3f80283a6 | ||
|
|
9d3595646d | ||
|
|
eb643d034f | ||
|
|
2455bda91b | ||
|
|
b74b0f4e1c | ||
|
|
d45067177e | ||
|
|
fc77a89d53 | ||
|
|
f8b13cce19 | ||
|
|
ea48a318ba | ||
|
|
6d50980c2f | ||
|
|
77d4316353 | ||
|
|
f9a8fdecf5 | ||
|
|
e12369a68e | ||
|
|
e76bbe413e | ||
|
|
73d3159ba0 | ||
|
|
9b47b2b217 | ||
|
|
06acbd37bd | ||
|
|
596389a5f6 | ||
|
|
6789202af0 | ||
|
|
3bcc70b64f | ||
|
|
856f8e0e49 | ||
|
|
c0ad5d36c4 | ||
|
|
d1ba01235f | ||
|
|
8be24f58f2 | ||
|
|
04e9dc27ac | ||
|
|
611fd806cb | ||
|
|
340fa00d52 | ||
|
|
14a829acbb | ||
|
|
2960d7adf5 | ||
|
|
1de951d31d | ||
|
|
3ff19be1f7 | ||
|
|
07204ff6e5 | ||
|
|
da36c34db7 | ||
|
|
1dc7e6c4dc | ||
|
|
7a7fe350d5 | ||
|
|
3294b22a68 | ||
|
|
3fcdccb8ce | ||
|
|
78e2832d7d | ||
|
|
4ac9bc08ea | ||
|
|
93248bd92c | ||
|
|
f261c03686 | ||
|
|
682a28a76b | ||
|
|
e3873aa1a0 | ||
|
|
a56aaf26c2 | ||
|
|
77b4bb74d5 | ||
|
|
cf5e59911b | ||
|
|
ba89da8fa2 | ||
|
|
2b51250534 | ||
|
|
59ced3da96 | ||
|
|
8bd342c660 | ||
|
|
61c6210dbf | ||
|
|
6c3476784b | ||
|
|
4be92e7b82 | ||
|
|
5c4a4aeed7 | ||
|
|
cb972c789a | ||
|
|
4a397cfb80 | ||
|
|
5e19252de9 | ||
|
|
c0912a12bf | ||
|
|
bbc4977fed | ||
|
|
681d7f7e57 | ||
|
|
c4b81184e4 | ||
|
|
1831948c20 | ||
|
|
779687854f | ||
|
|
2ace512a70 | ||
|
|
0f723769b7 | ||
|
|
33e638dc1d | ||
|
|
ff328e1dad | ||
|
|
d81b51d84b | ||
|
|
93d8f62057 | ||
|
|
7eb76186ba | ||
|
|
652a628d1c | ||
|
|
26b33aa1b0 | ||
|
|
67e957b636 | ||
|
|
8c903e0402 | ||
|
|
1a3789e222 | ||
|
|
a0a1d00370 | ||
|
|
60bffbd41b | ||
|
|
1061a0965a | ||
|
|
05e5bd2140 | ||
|
|
02360dd65c | ||
|
|
60b4b220d8 | ||
|
|
0dc9b6b7c7 | ||
|
|
bef91a618a | ||
|
|
70dcd738ef | ||
|
|
7a6570a11c | ||
|
|
f15681df26 | ||
|
|
277c29a64b | ||
|
|
62e2304891 | ||
|
|
cf409fd250 | ||
|
|
fc1de4a610 | ||
|
|
9ed5482545 | ||
|
|
d91310bb32 | ||
|
|
0b61b758fb | ||
|
|
27d71b21fc | ||
|
|
1172e49a3a | ||
|
|
c57e2486df | ||
|
|
cc24766fa6 | ||
|
|
58b657b976 | ||
|
|
4de73df8bf | ||
|
|
55297f865c | ||
|
|
c212035d94 | ||
|
|
cfc4db85a5 | ||
|
|
fadd86011f | ||
|
|
c69e11ac46 | ||
|
|
cfeb9404a8 | ||
|
|
db70061f0b | ||
|
|
2ec1eba7ca | ||
|
|
d3ebbb37e8 | ||
|
|
3f5f2c4734 | ||
|
|
6fe39566d2 | ||
|
|
c204e307ac | ||
|
|
0e1da295e9 | ||
|
|
c6a176be62 | ||
|
|
5a8dedc45c | ||
|
|
38dfb40fdb | ||
|
|
3546e574ca | ||
|
|
97ff7330ef | ||
|
|
f3e1c47f47 | ||
|
|
326548bae5 | ||
|
|
c29b2d1058 | ||
|
|
a4be66828a | ||
|
|
5a35745949 | ||
|
|
8b438fccb4 | ||
|
|
2b4e3fa144 | ||
|
|
3f13cc0f87 | ||
|
|
99041b4d84 | ||
|
|
1cfbd489f5 | ||
|
|
9590167290 | ||
|
|
fd98f30e4e | ||
|
|
f1197f7601 | ||
|
|
c36a9b8e1b | ||
|
|
a2e43cd8e6 | ||
|
|
a08b0c742a | ||
|
|
1e60ebeea0 | ||
|
|
b86a76044e | ||
|
|
e4c571c2f1 | ||
|
|
fb9c9ee35a | ||
|
|
459fb59493 | ||
|
|
ffdce51cd5 | ||
|
|
1df69c3920 | ||
|
|
aa689b96e6 | ||
|
|
a26a15d05c | ||
|
|
0c75581d8b | ||
|
|
7a6ce75aea | ||
|
|
ca165f09c0 | ||
|
|
a8217f2642 | ||
|
|
86de15f4fc | ||
|
|
5c3682d7a1 | ||
|
|
b050db951b | ||
|
|
7e540059a3 | ||
|
|
05082ea1c5 | ||
|
|
fcf5966488 | ||
|
|
6fc9651d57 | ||
|
|
6309bbb426 | ||
|
|
d48101109d | ||
|
|
6a192ec0cd | ||
|
|
39ce478283 | ||
|
|
3c4c0953e0 | ||
|
|
1cffcd91a9 | ||
|
|
9b0f455609 | ||
|
|
4d72e0f73b | ||
|
|
1e7c7244cf | ||
|
|
f4def47c89 | ||
|
|
2b4d461c14 | ||
|
|
32898dc46a | ||
|
|
f3dbaa3f54 | ||
|
|
bbdc3197a9 | ||
|
|
5a4e306cc5 | ||
|
|
07321575ca | ||
|
|
7da2e5ba6a | ||
|
|
3cb38e8ab9 | ||
|
|
f02c57dbfa | ||
|
|
c121daf331 | ||
|
|
1988dc0c73 | ||
|
|
ebcb13842b | ||
|
|
87a34a45ff | ||
|
|
15dfeb9182 | ||
|
|
ff17dd2a9a | ||
|
|
648c095da5 | ||
|
|
49f486d8e0 | ||
|
|
9b3352c3c8 | ||
|
|
1c636284a3 | ||
|
|
cb95791198 | ||
|
|
d028bb4c4a | ||
|
|
8e0bc2c3a8 | ||
|
|
d371aadb2b | ||
|
|
44055dc09d | ||
|
|
8066e4b0c3 | ||
|
|
041394b741 | ||
|
|
bfc05d2e3b | ||
|
|
0ddfbc5939 | ||
|
|
d975d32d67 | ||
|
|
be5a455a1a | ||
|
|
cb66d3eea9 | ||
|
|
a1f05dc669 | ||
|
|
2172c17b5e | ||
|
|
f0b7b37425 | ||
|
|
23c7a45a05 | ||
|
|
83ec81789a | ||
|
|
1bc82d1c86 | ||
|
|
36e5aa6c7d | ||
|
|
c97f779dbb | ||
|
|
3d333e0aff | ||
|
|
12ad06c104 | ||
|
|
91e90aaee0 | ||
|
|
d3de22b2be | ||
|
|
3286728e40 | ||
|
|
2790f5f9ae | ||
|
|
5df1975246 | ||
|
|
0fa3edc921 | ||
|
|
300465c7b8 | ||
|
|
314e9fbeda | ||
|
|
d10f9488fe | ||
|
|
59ef89d886 | ||
|
|
5ba9949b82 | ||
|
|
355a923e81 | ||
|
|
f497711aa8 | ||
|
|
95b0971031 | ||
|
|
9ff8309f47 | ||
|
|
1c022077ea | ||
|
|
7f8d348f3d | ||
|
|
5283589542 | ||
|
|
5026d5af95 | ||
|
|
2cfd031511 | ||
|
|
e4bda20918 | ||
|
|
7f2b7b8bd1 | ||
|
|
d572533774 | ||
|
|
1bff2aeec0 | ||
|
|
fe00dfbd56 | ||
|
|
adbd08399c | ||
|
|
e9af7a0749 | ||
|
|
d0227f8d02 | ||
|
|
50123f2a56 | ||
|
|
bf12aedf2e | ||
|
|
a53b184e63 | ||
|
|
b8eaf1b322 | ||
|
|
ecdcba27c5 | ||
|
|
1055c9fd14 | ||
|
|
af4c587ae3 | ||
|
|
cba1a2155a | ||
|
|
f4fd570ae3 | ||
|
|
dc0bc7f0a3 | ||
|
|
99d0dd3a43 | ||
|
|
06af9cb532 | ||
|
|
a39ed67180 | ||
|
|
db8439c328 | ||
|
|
0e7e1f5b57 | ||
|
|
a87589a035 | ||
|
|
4b521f14ac | ||
|
|
87824bca6b | ||
|
|
145aa2f118 | ||
|
|
75feeecd5d | ||
|
|
e87ba85705 | ||
|
|
1de97bbe2e | ||
|
|
637aa0944d | ||
|
|
e9f1761597 | ||
|
|
0068e225e0 | ||
|
|
78eed85ba3 | ||
|
|
9c5a8e9352 | ||
|
|
cac1168afd | ||
|
|
c9a3101bff | ||
|
|
163f94412a | ||
|
|
affd9bbab7 | ||
|
|
8e8edb5bf8 | ||
|
|
341628a037 | ||
|
|
d1b21e812d | ||
|
|
24fbb456ba | ||
|
|
cacab33f0d | ||
|
|
3387d5a3c4 | ||
|
|
a0facb2aba | ||
|
|
874587516c | ||
|
|
a047dec120 | ||
|
|
fb4d55c227 | ||
|
|
79b019ec4f | ||
|
|
c58202c6f9 | ||
|
|
c82ef825d4 | ||
|
|
9a04f1e732 | ||
|
|
33493b9ead | ||
|
|
47e23811ff | ||
|
|
3b1e23af09 | ||
|
|
3b0b2fd8d6 | ||
|
|
559a2d1bc7 | ||
|
|
82f337de10 | ||
|
|
2c1447b7f2 | ||
|
|
1e1c587073 | ||
|
|
30694b5d8a | ||
|
|
880489051a | ||
|
|
49d8ee5359 | ||
|
|
b129fc8237 | ||
|
|
a5cf291dde | ||
|
|
dcaea8cb1c | ||
|
|
24463dd025 | ||
|
|
9c3dd34cfe | ||
|
|
efbd4c1ebb | ||
|
|
1e00d14c29 | ||
|
|
a58e0584f5 | ||
|
|
8fdb50761d | ||
|
|
89b495520d | ||
|
|
f4f28cdd0e | ||
|
|
7cfc52fd42 | ||
|
|
67aaed7f99 | ||
|
|
0358007da3 | ||
|
|
529cbea343 | ||
|
|
c99edc840c | ||
|
|
77f22db567 | ||
|
|
41085295ab | ||
|
|
d8a7c50495 | ||
|
|
954e9101ba | ||
|
|
92c4789ec7 | ||
|
|
d6139a339b | ||
|
|
2aa6e0f084 | ||
|
|
068cdfafb8 | ||
|
|
23f07fa974 |
No files matched your search
+1
-10
@@ -11,16 +11,7 @@
|
||||
.github/CODEOWNERS @edolstra
|
||||
|
||||
# Documentation of built-in functions
|
||||
src/libexpr/primops.cc @roberth @fricklerhandwerk
|
||||
|
||||
# Documentation of settings
|
||||
src/libexpr/eval-settings.hh @fricklerhandwerk
|
||||
src/libstore/globals.hh @fricklerhandwerk
|
||||
|
||||
# Documentation
|
||||
doc/manual @fricklerhandwerk
|
||||
maintainers/*.md @fricklerhandwerk
|
||||
src/**/*.md @fricklerhandwerk
|
||||
src/libexpr/primops.cc @roberth
|
||||
|
||||
# Libstore layer
|
||||
/src/libstore @ericson2314
|
||||
@@ -13,7 +13,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: cachix/install-nix-action@v30
|
||||
- uses: cachix/install-nix-action@v31
|
||||
- run: nix --experimental-features 'nix-command flakes' flake show --all-systems --json
|
||||
|
||||
tests:
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: cachix/install-nix-action@v30
|
||||
- uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
# The sandbox would otherwise be disabled by default on Darwin
|
||||
extra_nix_config: |
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
- name: Serving installer
|
||||
id: serving_installer
|
||||
run: ./scripts/serve-installer-for-github-actions
|
||||
- uses: cachix/install-nix-action@v30
|
||||
- uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
install_url: 'http://localhost:8126/install'
|
||||
install_options: "--tarball-url-prefix http://localhost:8126/"
|
||||
@@ -131,7 +131,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: cachix/install-nix-action@v30
|
||||
- uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
install_url: https://releases.nixos.org/nix/nix-2.20.3/install
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
|
||||
@@ -128,3 +128,14 @@ pull_request_rules:
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
|
||||
- name: backport patches to 2.28
|
||||
conditions:
|
||||
- label=backport 2.28-maintenance
|
||||
actions:
|
||||
backport:
|
||||
branches:
|
||||
- "2.28-maintenance"
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
@@ -281,7 +281,6 @@ nix3_manpages = [
|
||||
'nix3-store',
|
||||
'nix3-store-optimise',
|
||||
'nix3-store-path-from-hash-part',
|
||||
'nix3-store-ping',
|
||||
'nix3-store-prefetch-file',
|
||||
'nix3-store-repair',
|
||||
'nix3-store-sign',
|
||||
|
||||
@@ -374,6 +374,7 @@ const redirects = {
|
||||
},
|
||||
"glossary.html": {
|
||||
"gloss-local-store": "store/types/local-store.html",
|
||||
"package-attribute-set": "#package",
|
||||
"gloss-chroot-store": "store/types/local-store.html",
|
||||
"gloss-content-addressed-derivation": "#gloss-content-addressing-derivation",
|
||||
},
|
||||
|
||||
@@ -242,16 +242,21 @@ print(t)
|
||||
```
|
||||
|
||||
Similarly, the following is a Perl script that specifies that it
|
||||
requires Perl and the `HTML::TokeParser::Simple` and `LWP` packages:
|
||||
requires Perl and the `HTML::TokeParser::Simple`, `LWP` and
|
||||
`LWP::Protocol::Https` packages:
|
||||
|
||||
```perl
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i perl --packages perl perlPackages.HTMLTokeParserSimple perlPackages.LWP
|
||||
#! nix-shell -i perl
|
||||
#! nix-shell --packages perl
|
||||
#! nix-shell --packages perlPackages.HTMLTokeParserSimple
|
||||
#! nix-shell --packages perlPackages.LWP
|
||||
#! nix-shell --packages perlPackages.LWPProtocolHttps
|
||||
|
||||
use HTML::TokeParser::Simple;
|
||||
|
||||
# Fetch nixos.org and print all hrefs.
|
||||
my $p = HTML::TokeParser::Simple->new(url => 'http://nixos.org/');
|
||||
my $p = HTML::TokeParser::Simple->new(url => 'https://nixos.org/');
|
||||
|
||||
while (my $token = $p->get_tag("a")) {
|
||||
my $href = $token->get_attr("href");
|
||||
@@ -316,7 +321,7 @@ contains:
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
|
||||
runCommand "dummy" { buildInputs = [ python pythonPackages.prettytable ]; } ""
|
||||
runCommand "dummy" { buildInputs = [ python3 python3Packages.prettytable ]; } ""
|
||||
```
|
||||
|
||||
The script's file name is passed as the first argument to the interpreter specified by the `-i` flag.
|
||||
|
||||
@@ -71,9 +71,8 @@
|
||||
|
||||
This can be achieved by:
|
||||
- Fetching a pre-built [store object] from a [substituter]
|
||||
- Running the [`builder`](@docroot@/language/derivations.md#attr-builder) executable as specified in the corresponding [store derivation]
|
||||
- [Building](@docroot@/store/building.md) the corresponding [store derivation]
|
||||
- Delegating to a [remote machine](@docroot@/command-ref/conf-file.md#conf-builders) and retrieving the outputs
|
||||
<!-- TODO: link [running] to build process page, #8888 -->
|
||||
|
||||
See [`nix-store --realise`](@docroot@/command-ref/nix-store/realise.md) for a detailed description of the algorithm.
|
||||
|
||||
@@ -215,7 +214,7 @@
|
||||
|
||||
> **Example**
|
||||
>
|
||||
> Building and deploying software using Nix entails writing Nix expressions as a high-level description of packages and compositions thereof.
|
||||
> Building and deploying software using Nix entails writing Nix expressions to describe [packages][package] and compositions thereof.
|
||||
|
||||
- [reference]{#gloss-reference}
|
||||
|
||||
@@ -330,18 +329,17 @@
|
||||
|
||||
- [package]{#package}
|
||||
|
||||
1. A software package; a collection of files and other data.
|
||||
A software package; files that belong together for a particular purpose, and metadata.
|
||||
|
||||
2. A [package attribute set].
|
||||
Nix represents files as [file system objects][file system object], and how they belong together is encoded as [references][reference] between [store objects][store object] that contain these file system objects.
|
||||
|
||||
- [package attribute set]{#package-attribute-set}
|
||||
The [Nix language] allows denoting packages in terms of [attribute sets](@docroot@/language/types.md#attribute-set) containing:
|
||||
- attributes that refer to the files of a package, typically in the form of [derivation outputs](#output),
|
||||
- attributes with metadata, such as information about how the package is supposed to be used.
|
||||
|
||||
An [attribute set](@docroot@/language/types.md#attribute-set) containing the attribute `type = "derivation";` (derivation for historical reasons), as well as other attributes, such as
|
||||
- attributes that refer to the files of a [package], typically in the form of [derivation outputs](#output),
|
||||
- attributes that declare something about how the package is supposed to be installed or used,
|
||||
- other metadata or arbitrary attributes.
|
||||
The exact shape of these attribute sets is up to convention.
|
||||
|
||||
[package attribute set]: #package-attribute-set
|
||||
[package]: #package
|
||||
|
||||
- [string interpolation]{#gloss-string-interpolation}
|
||||
|
||||
|
||||
@@ -11,7 +11,14 @@ The language is:
|
||||
|
||||
- *domain-specific*
|
||||
|
||||
It comes with [built-in functions](@docroot@/language/builtins.md) to integrate with the Nix store, which manages files and performs the derivations declared in the Nix language.
|
||||
The Nix language is purpose-built for working with text files.
|
||||
Its most characteristic features are:
|
||||
|
||||
- [File system path primitives](@docroot@/language/types.md#type-path), for accessing source files
|
||||
- [Indented strings](@docroot@/language/string-literals.md) and [string interpolation](@docroot@/language/string-interpolation.md), for creating file contents
|
||||
- [Strings with contexts](@docroot@/language/string-context.md), for transparently linking files
|
||||
|
||||
It comes with [built-in functions](@docroot@/language/builtins.md) to integrate with the [Nix store](@docroot@/store/index.md), which manages files and enables [realising](@docroot@/glossary.md#gloss-realise) derivations declared in the Nix language.
|
||||
|
||||
- *declarative*
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ The purpose of string contexts is to collect non-string values attached to strin
|
||||
[string concatenation](./operators.md#string-concatenation),
|
||||
[string interpolation](./string-interpolation.md),
|
||||
and similar operations.
|
||||
The idea is that a user can combine together values to create a build instructions for derivations without manually keeping track of where they come from.
|
||||
Then the Nix language implicitly does that bookkeeping to efficiently obtain the closure of derivation inputs.
|
||||
The idea is that a user can reference other files when creating text files through Nix expressions, without manually keeping track of the exact paths.
|
||||
Nix will ensure that the all referenced files are accessible – that all [store paths](@docroot@/glossary.md#gloss-store-path) are [valid](@docroot@/glossary.md#gloss-validitiy).
|
||||
|
||||
> **Note**
|
||||
>
|
||||
|
||||
Generated
+4
-4
@@ -63,16 +63,16 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1734359947,
|
||||
"narHash": "sha256-1Noao/H+N8nFB4Beoy8fgwrcOQLVm9o4zKW1ODaqK9E=",
|
||||
"lastModified": 1744232761,
|
||||
"narHash": "sha256-gbl9hE39nQRpZaLjhWKmEu5ejtQsgI5TWYrIVVJn30U=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "48d12d5e70ee91fe8481378e540433a7303dbf6a",
|
||||
"rev": "f675531bc7e6657c10a18b565cfebd8aa9e24c14",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "release-24.11",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
description = "The purely functional package manager";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-24.11";
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
inputs.nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2";
|
||||
inputs.nixpkgs-23-11.url = "github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446";
|
||||
@@ -32,7 +32,7 @@
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
|
||||
officialRelease = true;
|
||||
officialRelease = false;
|
||||
|
||||
linux32BitSystems = [ "i686-linux" ];
|
||||
linux64BitSystems = [
|
||||
@@ -143,14 +143,15 @@
|
||||
# without "polluting" the top level "`pkgs`" attrset.
|
||||
# This also has the benefit of providing us with a distinct set of packages
|
||||
# we can iterate over.
|
||||
nixComponents =
|
||||
# The `2` suffix is here because otherwise it interferes with `nixVersions.latest`, which is used in daemon compat tests.
|
||||
nixComponents2 =
|
||||
lib.makeScopeWithSplicing'
|
||||
{
|
||||
inherit (final) splicePackages;
|
||||
inherit (final.nixDependencies) newScope;
|
||||
inherit (final.nixDependencies2) newScope;
|
||||
}
|
||||
{
|
||||
otherSplices = final.generateSplicesForMkScope "nixComponents";
|
||||
otherSplices = final.generateSplicesForMkScope "nixComponents2";
|
||||
f = import ./packaging/components.nix {
|
||||
inherit (final) lib;
|
||||
inherit officialRelease;
|
||||
@@ -161,22 +162,23 @@
|
||||
};
|
||||
|
||||
# The dependencies are in their own scope, so that they don't have to be
|
||||
# in Nixpkgs top level `pkgs` or `nixComponents`.
|
||||
nixDependencies =
|
||||
# in Nixpkgs top level `pkgs` or `nixComponents2`.
|
||||
# The `2` suffix is here because otherwise it interferes with `nixVersions.latest`, which is used in daemon compat tests.
|
||||
nixDependencies2 =
|
||||
lib.makeScopeWithSplicing'
|
||||
{
|
||||
inherit (final) splicePackages;
|
||||
inherit (final) newScope; # layered directly on pkgs, unlike nixComponents above
|
||||
inherit (final) newScope; # layered directly on pkgs, unlike nixComponents2 above
|
||||
}
|
||||
{
|
||||
otherSplices = final.generateSplicesForMkScope "nixDependencies";
|
||||
otherSplices = final.generateSplicesForMkScope "nixDependencies2";
|
||||
f = import ./packaging/dependencies.nix {
|
||||
inherit inputs stdenv;
|
||||
pkgs = final;
|
||||
};
|
||||
};
|
||||
|
||||
nix = final.nixComponents.nix-cli;
|
||||
nix = final.nixComponents2.nix-cli;
|
||||
|
||||
# See https://github.com/NixOS/nixpkgs/pull/214409
|
||||
# Remove when fixed in this flake's nixpkgs
|
||||
@@ -277,7 +279,7 @@
|
||||
# memory leaks with detect_leaks=0.
|
||||
"" = rec {
|
||||
nixpkgs = nixpkgsFor.${system}.native;
|
||||
nixComponents = nixpkgs.nixComponents.overrideScope (
|
||||
nixComponents = nixpkgs.nixComponents2.overrideScope (
|
||||
nixCompFinal: nixCompPrev: {
|
||||
mesonComponentOverrides = _finalAttrs: prevAttrs: {
|
||||
mesonFlags =
|
||||
@@ -305,7 +307,7 @@
|
||||
nixpkgsPrefix:
|
||||
{
|
||||
nixpkgs,
|
||||
nixComponents ? nixpkgs.nixComponents,
|
||||
nixComponents ? nixpkgs.nixComponents2,
|
||||
}:
|
||||
flatMapAttrs nixComponents (
|
||||
pkgName: pkg:
|
||||
@@ -335,9 +337,9 @@
|
||||
binaryTarball = self.hydraJobs.binaryTarball.${system};
|
||||
# TODO probably should be `nix-cli`
|
||||
nix = self.packages.${system}.nix-everything;
|
||||
nix-manual = nixpkgsFor.${system}.native.nixComponents.nix-manual;
|
||||
nix-internal-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-internal-api-docs;
|
||||
nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-external-api-docs;
|
||||
nix-manual = nixpkgsFor.${system}.native.nixComponents2.nix-manual;
|
||||
nix-internal-api-docs = nixpkgsFor.${system}.native.nixComponents2.nix-internal-api-docs;
|
||||
nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents2.nix-external-api-docs;
|
||||
}
|
||||
# We need to flatten recursive attribute sets of derivations to pass `flake check`.
|
||||
//
|
||||
@@ -355,6 +357,7 @@
|
||||
"nix-store-tests" = { };
|
||||
|
||||
"nix-fetchers" = { };
|
||||
"nix-fetchers-c" = { };
|
||||
"nix-fetchers-tests" = { };
|
||||
|
||||
"nix-expr" = { };
|
||||
@@ -363,6 +366,7 @@
|
||||
"nix-expr-tests" = { };
|
||||
|
||||
"nix-flake" = { };
|
||||
"nix-flake-c" = { };
|
||||
"nix-flake-tests" = { };
|
||||
|
||||
"nix-main" = { };
|
||||
@@ -389,9 +393,9 @@
|
||||
}:
|
||||
{
|
||||
# These attributes go right into `packages.<system>`.
|
||||
"${pkgName}" = nixpkgsFor.${system}.native.nixComponents.${pkgName};
|
||||
"${pkgName}-static" = nixpkgsFor.${system}.native.pkgsStatic.nixComponents.${pkgName};
|
||||
"${pkgName}-llvm" = nixpkgsFor.${system}.native.pkgsLLVM.nixComponents.${pkgName};
|
||||
"${pkgName}" = nixpkgsFor.${system}.native.nixComponents2.${pkgName};
|
||||
"${pkgName}-static" = nixpkgsFor.${system}.native.pkgsStatic.nixComponents2.${pkgName};
|
||||
"${pkgName}-llvm" = nixpkgsFor.${system}.native.pkgsLLVM.nixComponents2.${pkgName};
|
||||
}
|
||||
// lib.optionalAttrs supportsCross (
|
||||
flatMapAttrs (lib.genAttrs crossSystems (_: { })) (
|
||||
@@ -399,7 +403,7 @@
|
||||
{ }:
|
||||
{
|
||||
# These attributes go right into `packages.<system>`.
|
||||
"${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.nixComponents.${pkgName};
|
||||
"${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.nixComponents2.${pkgName};
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -409,7 +413,7 @@
|
||||
{
|
||||
# These attributes go right into `packages.<system>`.
|
||||
"${pkgName}-${stdenvName}" =
|
||||
nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.nixComponents.${pkgName};
|
||||
nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.nixComponents2.${pkgName};
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -37,7 +37,7 @@ The team is on Github as [@NixOS/nix-team](https://github.com/orgs/NixOS/teams/n
|
||||
|
||||
The team meets twice a week (times are denoted in the [Europe/Amsterdam](https://en.m.wikipedia.org/wiki/Time_in_the_Netherlands) time zone):
|
||||
|
||||
- Discussion meeting: [Wednesday 21:00-22:00 Europe/Amsterdam](https://www.google.com/calendar/event?eid=ZG5rZzNyajRjajducGV2NGY5aGkzYWIwdnJfMjAyNDA1MDhUMTkwMDAwWiBiOW81MmZvYnFqYWs4b3E4bGZraGczdDBxZ0Bn)
|
||||
- Discussion meeting: Wednesday 21:00-22:00 Europe/Amsterdam see [calendar](https://calendar.google.com/calendar/u/0/embed?src=b9o52fobqjak8oq8lfkhg3t0qg@group.calendar.google.com).
|
||||
|
||||
1. Triage issues and pull requests from the [No Status](#no-status) column (30 min)
|
||||
2. Discuss issues and pull requests from the [To discuss](#to-discuss) column (30 min).
|
||||
@@ -46,7 +46,7 @@ The team meets twice a week (times are denoted in the [Europe/Amsterdam](https:/
|
||||
- mark it as draft if it is blocked on the contributor
|
||||
- escalate it back to the team by moving it to To discuss, and leaving a comment as to why the issue needs to be discussed again.
|
||||
|
||||
- Work meeting: [Mondays 14:00-16:00 Europe/Amsterdam](https://www.google.com/calendar/event?eid=Ym52NDdzYnRic2NzcDcybjZiNDhpNzhpa3NfMjAyNDA1MTNUMTIwMDAwWiBiOW81MmZvYnFqYWs4b3E4bGZraGczdDBxZ0Bn)
|
||||
- Work meeting: Mondays 14:00-16:00 Europe/Amsterdam see [calendar](https://calendar.google.com/calendar/u/0/embed?src=b9o52fobqjak8oq8lfkhg3t0qg@group.calendar.google.com).
|
||||
|
||||
1. Code review on pull requests from [In review](#in-review).
|
||||
2. Other chores and tasks.
|
||||
|
||||
@@ -172,14 +172,14 @@
|
||||
''^src/libfetchers/include/nix/fetchers/tarball\.hh$''
|
||||
''^src/libfetchers/git\.cc$''
|
||||
''^src/libfetchers/mercurial\.cc$''
|
||||
''^src/libflake/flake/config\.cc$''
|
||||
''^src/libflake/flake/flake\.cc$''
|
||||
''^src/libflake/config\.cc$''
|
||||
''^src/libflake/flake\.cc$''
|
||||
''^src/libflake/include/nix/flake/flake\.hh$''
|
||||
''^src/libflake/flake/flakeref\.cc$''
|
||||
''^src/libflake/flakeref\.cc$''
|
||||
''^src/libflake/include/nix/flake/flakeref\.hh$''
|
||||
''^src/libflake/flake/lockfile\.cc$''
|
||||
''^src/libflake/lockfile\.cc$''
|
||||
''^src/libflake/include/nix/flake/lockfile\.hh$''
|
||||
''^src/libflake/flake/url-name\.cc$''
|
||||
''^src/libflake/url-name\.cc$''
|
||||
''^src/libmain/common-args\.cc$''
|
||||
''^src/libmain/include/nix/main/common-args\.hh$''
|
||||
''^src/libmain/loggers\.cc$''
|
||||
@@ -284,8 +284,8 @@
|
||||
''^src/libstore/build/goal\.cc$''
|
||||
''^src/libstore/include/nix/store/build/goal\.hh$''
|
||||
''^src/libstore/unix/build/hook-instance\.cc$''
|
||||
''^src/libstore/unix/build/local-derivation-goal\.cc$''
|
||||
''^src/libstore/unix/include/nix/store/build/local-derivation-goal\.hh$''
|
||||
''^src/libstore/unix/build/derivation-builder\.cc$''
|
||||
''^src/libstore/unix/include/nix/store/build/derivation-builder\.hh$''
|
||||
''^src/libstore/build/substitution-goal\.cc$''
|
||||
''^src/libstore/include/nix/store/build/substitution-goal\.hh$''
|
||||
''^src/libstore/build/worker\.cc$''
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# This script must be run from the root of the Nix repository.
|
||||
#
|
||||
# For include path hygiene, we need to put headers in a separate
|
||||
# directory than sources. But during development, it is nice to paths
|
||||
# that are similar for headers and source files, e.g.
|
||||
# `foo/bar/baz.{cc,hh}`, e.g. for less typing when opening one file, and
|
||||
# then opening the other file.
|
||||
#
|
||||
# This script symlinks the headers next to the source files to
|
||||
# facilitate such a development workflows. It also updates
|
||||
# `.git/info/exclude` so that the symlinks are not accidentally committed
|
||||
# by mistake.
|
||||
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
|
||||
def main() -> None:
|
||||
# Path to the source directory
|
||||
GIT_TOPLEVEL = Path(
|
||||
subprocess.run(
|
||||
["git", "rev-parse", "--show-toplevel"],
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
check=True,
|
||||
).stdout.strip()
|
||||
)
|
||||
|
||||
# Get header files from git
|
||||
result = subprocess.run(
|
||||
["git", "-C", str(GIT_TOPLEVEL), "ls-files", "*/include/nix/**.hh"],
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
check=True,
|
||||
)
|
||||
header_files = result.stdout.strip().split("\n")
|
||||
header_files.sort()
|
||||
|
||||
links = []
|
||||
for file_str in header_files:
|
||||
project_str, header_str = file_str.split("/include/nix/", 1)
|
||||
project = Path(project_str)
|
||||
header = Path(header_str)
|
||||
|
||||
# Reconstruct the full path (relative to SRC_DIR) to the header file.
|
||||
file = project / "include" / "nix" / header
|
||||
|
||||
# The symlink should be created at "project/header", i.e. next to the project's sources.
|
||||
link = project / header
|
||||
|
||||
# Compute a relative path from the symlink's parent directory to the actual header file.
|
||||
relative_source = os.path.relpath(
|
||||
GIT_TOPLEVEL / file, GIT_TOPLEVEL / link.parent
|
||||
)
|
||||
|
||||
# Create the symbolic link.
|
||||
full_link_path = GIT_TOPLEVEL / link
|
||||
full_link_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
if full_link_path.is_symlink():
|
||||
full_link_path.unlink()
|
||||
full_link_path.symlink_to(relative_source)
|
||||
links.append(link)
|
||||
|
||||
# Generate .gitignore file
|
||||
gitignore_path = GIT_TOPLEVEL / ".git" / "info" / "exclude"
|
||||
gitignore_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with gitignore_path.open("w") as gitignore:
|
||||
gitignore.write("# DO NOT EDIT! Autogenerated\n")
|
||||
gitignore.write(
|
||||
"# Symlinks for headers to be next to sources for development\n"
|
||||
)
|
||||
gitignore.write('# Run "maintainers/link-headers" to regenerate\n\n')
|
||||
gitignore.write('# Run "maintainers/link-headers" to regenerate\n\n')
|
||||
|
||||
for link in links:
|
||||
gitignore.write(f"/{link}\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+3
-1
@@ -6,7 +6,8 @@ project('nix-dev-shell', 'cpp',
|
||||
subproject_dir : 'src',
|
||||
default_options : [
|
||||
'localstatedir=/nix/var',
|
||||
]
|
||||
],
|
||||
meson_version : '>= 1.1'
|
||||
)
|
||||
|
||||
# Internal Libraries
|
||||
@@ -33,6 +34,7 @@ endif
|
||||
# External C wrapper libraries
|
||||
subproject('libutil-c')
|
||||
subproject('libstore-c')
|
||||
subproject('libfetchers-c')
|
||||
subproject('libexpr-c')
|
||||
subproject('libflake-c')
|
||||
subproject('libmain-c')
|
||||
|
||||
@@ -12,6 +12,7 @@ add_project_arguments(
|
||||
'-Werror=switch-enum',
|
||||
'-Werror=undef',
|
||||
'-Werror=unused-result',
|
||||
'-Werror=sign-compare',
|
||||
'-Wignored-qualifiers',
|
||||
'-Wimplicit-fallthrough',
|
||||
'-Wno-deprecated-declarations',
|
||||
|
||||
@@ -160,13 +160,6 @@ let
|
||||
];
|
||||
separateDebugInfo = !stdenv.hostPlatform.isStatic;
|
||||
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
||||
env =
|
||||
prevAttrs.env or { }
|
||||
// lib.optionalAttrs (
|
||||
stdenv.isLinux
|
||||
&& !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")
|
||||
&& !(stdenv.hostPlatform.useLLVM or false)
|
||||
) { LDFLAGS = "-fuse-ld=gold"; };
|
||||
};
|
||||
|
||||
mesonLibraryLayer = finalAttrs: prevAttrs: {
|
||||
@@ -340,6 +333,7 @@ in
|
||||
nix-store-tests = callPackage ../src/libstore-tests/package.nix { };
|
||||
|
||||
nix-fetchers = callPackage ../src/libfetchers/package.nix { };
|
||||
nix-fetchers-c = callPackage ../src/libfetchers-c/package.nix { };
|
||||
nix-fetchers-tests = callPackage ../src/libfetchers-tests/package.nix { };
|
||||
|
||||
nix-expr = callPackage ../src/libexpr/package.nix { };
|
||||
|
||||
@@ -38,6 +38,7 @@ scope: {
|
||||
aws-sdk-cpp =
|
||||
(pkgs.aws-sdk-cpp.override {
|
||||
apis = [
|
||||
"identity-management"
|
||||
"s3"
|
||||
"transfer"
|
||||
];
|
||||
|
||||
+38
-32
@@ -5,11 +5,11 @@
|
||||
|
||||
{ pkgs }:
|
||||
|
||||
pkgs.nixComponents.nix-util.overrideAttrs (
|
||||
pkgs.nixComponents2.nix-util.overrideAttrs (
|
||||
attrs:
|
||||
|
||||
let
|
||||
stdenv = pkgs.nixDependencies.stdenv;
|
||||
stdenv = pkgs.nixDependencies2.stdenv;
|
||||
buildCanExecuteHost = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
|
||||
modular = devFlake.getSystem stdenv.buildPlatform.system;
|
||||
transformFlag =
|
||||
@@ -71,34 +71,39 @@ pkgs.nixComponents.nix-util.overrideAttrs (
|
||||
# We use this shell with the local checkout, not unpackPhase.
|
||||
src = null;
|
||||
|
||||
env = {
|
||||
# For `make format`, to work without installing pre-commit
|
||||
_NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml"
|
||||
modular.pre-commit.settings.rawConfig
|
||||
}";
|
||||
};
|
||||
env =
|
||||
{
|
||||
# For `make format`, to work without installing pre-commit
|
||||
_NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml"
|
||||
modular.pre-commit.settings.rawConfig
|
||||
}";
|
||||
}
|
||||
// lib.optionalAttrs stdenv.hostPlatform.isLinux {
|
||||
CC_LD = "mold";
|
||||
CXX_LD = "mold";
|
||||
};
|
||||
|
||||
mesonFlags =
|
||||
map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents.nix-util.mesonFlags)
|
||||
++ map (transformFlag "libstore") (ignoreCrossFile pkgs.nixComponents.nix-store.mesonFlags)
|
||||
++ map (transformFlag "libfetchers") (ignoreCrossFile pkgs.nixComponents.nix-fetchers.mesonFlags)
|
||||
map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents2.nix-util.mesonFlags)
|
||||
++ map (transformFlag "libstore") (ignoreCrossFile pkgs.nixComponents2.nix-store.mesonFlags)
|
||||
++ map (transformFlag "libfetchers") (ignoreCrossFile pkgs.nixComponents2.nix-fetchers.mesonFlags)
|
||||
++ lib.optionals havePerl (
|
||||
map (transformFlag "perl") (ignoreCrossFile pkgs.nixComponents.nix-perl-bindings.mesonFlags)
|
||||
map (transformFlag "perl") (ignoreCrossFile pkgs.nixComponents2.nix-perl-bindings.mesonFlags)
|
||||
)
|
||||
++ map (transformFlag "libexpr") (ignoreCrossFile pkgs.nixComponents.nix-expr.mesonFlags)
|
||||
++ map (transformFlag "libcmd") (ignoreCrossFile pkgs.nixComponents.nix-cmd.mesonFlags);
|
||||
++ map (transformFlag "libexpr") (ignoreCrossFile pkgs.nixComponents2.nix-expr.mesonFlags)
|
||||
++ map (transformFlag "libcmd") (ignoreCrossFile pkgs.nixComponents2.nix-cmd.mesonFlags);
|
||||
|
||||
nativeBuildInputs =
|
||||
attrs.nativeBuildInputs or [ ]
|
||||
++ pkgs.nixComponents.nix-util.nativeBuildInputs
|
||||
++ pkgs.nixComponents.nix-store.nativeBuildInputs
|
||||
++ pkgs.nixComponents.nix-fetchers.nativeBuildInputs
|
||||
++ pkgs.nixComponents.nix-expr.nativeBuildInputs
|
||||
++ lib.optionals havePerl pkgs.nixComponents.nix-perl-bindings.nativeBuildInputs
|
||||
++ lib.optionals buildCanExecuteHost pkgs.nixComponents.nix-manual.externalNativeBuildInputs
|
||||
++ pkgs.nixComponents.nix-internal-api-docs.nativeBuildInputs
|
||||
++ pkgs.nixComponents.nix-external-api-docs.nativeBuildInputs
|
||||
++ pkgs.nixComponents.nix-functional-tests.externalNativeBuildInputs
|
||||
++ pkgs.nixComponents2.nix-util.nativeBuildInputs
|
||||
++ pkgs.nixComponents2.nix-store.nativeBuildInputs
|
||||
++ pkgs.nixComponents2.nix-fetchers.nativeBuildInputs
|
||||
++ pkgs.nixComponents2.nix-expr.nativeBuildInputs
|
||||
++ lib.optionals havePerl pkgs.nixComponents2.nix-perl-bindings.nativeBuildInputs
|
||||
++ lib.optionals buildCanExecuteHost pkgs.nixComponents2.nix-manual.externalNativeBuildInputs
|
||||
++ pkgs.nixComponents2.nix-internal-api-docs.nativeBuildInputs
|
||||
++ pkgs.nixComponents2.nix-external-api-docs.nativeBuildInputs
|
||||
++ pkgs.nixComponents2.nix-functional-tests.externalNativeBuildInputs
|
||||
++ lib.optional (
|
||||
!buildCanExecuteHost
|
||||
# Hack around https://github.com/nixos/nixpkgs/commit/bf7ad8cfbfa102a90463433e2c5027573b462479
|
||||
@@ -119,18 +124,19 @@ pkgs.nixComponents.nix-util.overrideAttrs (
|
||||
++ lib.optional (stdenv.cc.isClang && !stdenv.buildPlatform.isDarwin) pkgs.buildPackages.bear
|
||||
++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) (
|
||||
lib.hiPrio pkgs.buildPackages.clang-tools
|
||||
);
|
||||
)
|
||||
++ lib.optional stdenv.hostPlatform.isLinux pkgs.buildPackages.mold-wrapped;
|
||||
|
||||
buildInputs =
|
||||
attrs.buildInputs or [ ]
|
||||
++ pkgs.nixComponents.nix-util.buildInputs
|
||||
++ pkgs.nixComponents.nix-store.buildInputs
|
||||
++ pkgs.nixComponents.nix-store-tests.externalBuildInputs
|
||||
++ pkgs.nixComponents.nix-fetchers.buildInputs
|
||||
++ pkgs.nixComponents.nix-expr.buildInputs
|
||||
++ pkgs.nixComponents.nix-expr.externalPropagatedBuildInputs
|
||||
++ pkgs.nixComponents.nix-cmd.buildInputs
|
||||
++ lib.optionals havePerl pkgs.nixComponents.nix-perl-bindings.externalBuildInputs
|
||||
++ pkgs.nixComponents2.nix-util.buildInputs
|
||||
++ pkgs.nixComponents2.nix-store.buildInputs
|
||||
++ pkgs.nixComponents2.nix-store-tests.externalBuildInputs
|
||||
++ pkgs.nixComponents2.nix-fetchers.buildInputs
|
||||
++ pkgs.nixComponents2.nix-expr.buildInputs
|
||||
++ pkgs.nixComponents2.nix-expr.externalPropagatedBuildInputs
|
||||
++ pkgs.nixComponents2.nix-cmd.buildInputs
|
||||
++ lib.optionals havePerl pkgs.nixComponents2.nix-perl-bindings.externalBuildInputs
|
||||
++ lib.optional havePerl pkgs.perl;
|
||||
}
|
||||
)
|
||||
@@ -15,6 +15,7 @@
|
||||
nix-store-tests,
|
||||
|
||||
nix-fetchers,
|
||||
nix-fetchers-c,
|
||||
nix-fetchers-tests,
|
||||
|
||||
nix-expr,
|
||||
@@ -54,6 +55,7 @@ let
|
||||
nix-store
|
||||
nix-store-c
|
||||
nix-fetchers
|
||||
nix-fetchers-c
|
||||
nix-expr
|
||||
nix-expr-c
|
||||
nix-flake
|
||||
@@ -230,6 +232,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
"nix-expr"
|
||||
"nix-expr-c"
|
||||
"nix-fetchers"
|
||||
"nix-fetchers-c"
|
||||
"nix-flake"
|
||||
"nix-flake-c"
|
||||
"nix-main"
|
||||
|
||||
+14
-13
@@ -19,14 +19,14 @@ let
|
||||
|
||||
testNixVersions =
|
||||
pkgs: daemon:
|
||||
pkgs.nixComponents.nix-functional-tests.override {
|
||||
pkgs.nixComponents2.nix-functional-tests.override {
|
||||
pname = "nix-daemon-compat-tests";
|
||||
version = "${pkgs.nix.version}-with-daemon-${daemon.version}";
|
||||
|
||||
test-daemon = daemon;
|
||||
};
|
||||
|
||||
# Technically we could just return `pkgs.nixComponents`, but for Hydra it's
|
||||
# Technically we could just return `pkgs.nixComponents2`, but for Hydra it's
|
||||
# convention to transpose it, and to transpose it efficiently, we need to
|
||||
# enumerate them manually, so that we don't evaluate unnecessary package sets.
|
||||
# See listingIsComplete below.
|
||||
@@ -48,6 +48,7 @@ let
|
||||
"nix-store-test-support"
|
||||
"nix-store-tests"
|
||||
"nix-fetchers"
|
||||
"nix-fetchers-c"
|
||||
"nix-fetchers-tests"
|
||||
"nix-expr"
|
||||
"nix-expr-c"
|
||||
@@ -85,7 +86,7 @@ in
|
||||
} (_: null);
|
||||
actualPkgs = lib.concatMapAttrs (
|
||||
k: v: if lib.strings.hasPrefix "nix-" k then { ${k} = null; } else { }
|
||||
) nixpkgsFor.${arbitrarySystem}.native.nixComponents;
|
||||
) nixpkgsFor.${arbitrarySystem}.native.nixComponents2;
|
||||
diff = lib.concatStringsSep "\n" (
|
||||
lib.concatLists (
|
||||
lib.mapAttrsToList (
|
||||
@@ -111,7 +112,7 @@ in
|
||||
|
||||
# Binary package for various platforms.
|
||||
build = forAllPackages (
|
||||
pkgName: forAllSystems (system: nixpkgsFor.${system}.native.nixComponents.${pkgName})
|
||||
pkgName: forAllSystems (system: nixpkgsFor.${system}.native.nixComponents2.${pkgName})
|
||||
);
|
||||
|
||||
shellInputs = removeAttrs (forAllSystems (
|
||||
@@ -121,7 +122,7 @@ in
|
||||
buildStatic = forAllPackages (
|
||||
pkgName:
|
||||
lib.genAttrs linux64BitSystems (
|
||||
system: nixpkgsFor.${system}.native.pkgsStatic.nixComponents.${pkgName}
|
||||
system: nixpkgsFor.${system}.native.pkgsStatic.nixComponents2.${pkgName}
|
||||
)
|
||||
);
|
||||
|
||||
@@ -138,7 +139,7 @@ in
|
||||
forAllCrossSystems (
|
||||
crossSystem:
|
||||
lib.genAttrs [ "x86_64-linux" ] (
|
||||
system: nixpkgsFor.${system}.cross.${crossSystem}.nixComponents.${pkgName}
|
||||
system: nixpkgsFor.${system}.cross.${crossSystem}.nixComponents2.${pkgName}
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -148,7 +149,7 @@ in
|
||||
let
|
||||
components = forAllSystems (
|
||||
system:
|
||||
nixpkgsFor.${system}.native.nixComponents.overrideScope (
|
||||
nixpkgsFor.${system}.native.nixComponents2.overrideScope (
|
||||
self: super: {
|
||||
nix-expr = super.nix-expr.override { enableGC = false; };
|
||||
}
|
||||
@@ -157,7 +158,7 @@ in
|
||||
in
|
||||
forAllPackages (pkgName: forAllSystems (system: components.${system}.${pkgName}));
|
||||
|
||||
buildNoTests = forAllSystems (system: nixpkgsFor.${system}.native.nixComponents.nix-cli);
|
||||
buildNoTests = forAllSystems (system: nixpkgsFor.${system}.native.nixComponents2.nix-cli);
|
||||
|
||||
# Toggles some settings for better coverage. Windows needs these
|
||||
# library combinations, and Debian build Nix with GNU readline too.
|
||||
@@ -165,7 +166,7 @@ in
|
||||
let
|
||||
components = forAllSystems (
|
||||
system:
|
||||
nixpkgsFor.${system}.native.nixComponents.overrideScope (
|
||||
nixpkgsFor.${system}.native.nixComponents2.overrideScope (
|
||||
self: super: {
|
||||
nix-cmd = super.nix-cmd.override {
|
||||
enableMarkdown = false;
|
||||
@@ -178,7 +179,7 @@ in
|
||||
forAllPackages (pkgName: forAllSystems (system: components.${system}.${pkgName}));
|
||||
|
||||
# Perl bindings for various platforms.
|
||||
perlBindings = forAllSystems (system: nixpkgsFor.${system}.native.nixComponents.nix-perl-bindings);
|
||||
perlBindings = forAllSystems (system: nixpkgsFor.${system}.native.nixComponents2.nix-perl-bindings);
|
||||
|
||||
# Binary tarball for various platforms, containing a Nix store
|
||||
# with the closure of 'nix' package, and the second half of
|
||||
@@ -228,13 +229,13 @@ in
|
||||
# };
|
||||
|
||||
# Nix's manual
|
||||
manual = nixpkgsFor.x86_64-linux.native.nixComponents.nix-manual;
|
||||
manual = nixpkgsFor.x86_64-linux.native.nixComponents2.nix-manual;
|
||||
|
||||
# API docs for Nix's unstable internal C++ interfaces.
|
||||
internal-api-docs = nixpkgsFor.x86_64-linux.native.nixComponents.nix-internal-api-docs;
|
||||
internal-api-docs = nixpkgsFor.x86_64-linux.native.nixComponents2.nix-internal-api-docs;
|
||||
|
||||
# API docs for Nix's C bindings.
|
||||
external-api-docs = nixpkgsFor.x86_64-linux.native.nixComponents.nix-external-api-docs;
|
||||
external-api-docs = nixpkgsFor.x86_64-linux.native.nixComponents2.nix-external-api-docs;
|
||||
|
||||
# System tests.
|
||||
tests =
|
||||
|
||||
@@ -62,6 +62,13 @@ else
|
||||
end
|
||||
end
|
||||
|
||||
# Only use MANPATH if it is already set. In general `man` will just simply
|
||||
# pick up `.nix-profile/share/man` because is it close to `.nix-profile/bin`
|
||||
# which is in the $PATH. For more info, run `manpath -d`.
|
||||
if set --query MANPATH
|
||||
set --export --prepend --path MANPATH "$NIX_LINK/share/man"
|
||||
end
|
||||
|
||||
add_path "@localstatedir@/nix/profiles/default/bin"
|
||||
add_path "$NIX_LINK/bin"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Only execute this file once per shell.
|
||||
if test -z "$HOME" || test -z "$USER" || \
|
||||
if test -z "$HOME" || \
|
||||
test -n "$__ETC_PROFILE_NIX_SOURCED"
|
||||
exit
|
||||
end
|
||||
@@ -53,6 +53,13 @@ else if test -e "$NIX_LINK/etc/ssl/certs/ca-bundle.crt" # fall back to cacert in
|
||||
set --export NIX_SSL_CERT_FILE "$NIX_LINK/etc/ssl/certs/ca-bundle.crt"
|
||||
else if test -e "$NIX_LINK/etc/ca-bundle.crt" # old cacert in Nix profile
|
||||
set --export NIX_SSL_CERT_FILE "$NIX_LINK/etc/ca-bundle.crt"
|
||||
else
|
||||
# Fall back to what is in the nix profiles, favouring whatever is defined last.
|
||||
for i in (string split ' ' $NIX_PROFILES)
|
||||
if test -e "$i/etc/ssl/certs/ca-bundle.crt"
|
||||
set --export NIX_SSL_CERT_FILE "$i/etc/ssl/certs/ca-bundle.crt"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Only use MANPATH if it is already set. In general `man` will just simply
|
||||
@@ -62,6 +69,7 @@ if set --query MANPATH
|
||||
set --export --prepend --path MANPATH "$NIX_LINK/share/man"
|
||||
end
|
||||
|
||||
add_path "@localstatedir@/nix/profiles/default/bin"
|
||||
add_path "$NIX_LINK/bin"
|
||||
|
||||
# Cleanup
|
||||
|
||||
@@ -135,7 +135,7 @@ static constexpr const char * promptForType(ReplPromptType promptType)
|
||||
case ReplPromptType::ReplPrompt:
|
||||
return "nix-repl> ";
|
||||
case ReplPromptType::ContinuationPrompt:
|
||||
return " ";
|
||||
return " > "; // 9 spaces + >
|
||||
}
|
||||
assert(false);
|
||||
}
|
||||
|
||||
@@ -37,13 +37,11 @@ include_dirs = [include_directories('.')]
|
||||
|
||||
headers = files(
|
||||
'nix_api_expr.h',
|
||||
'nix_api_expr_internal.h',
|
||||
'nix_api_external.h',
|
||||
'nix_api_value.h',
|
||||
)
|
||||
|
||||
# TODO move this header to libexpr, maybe don't use it in tests?
|
||||
headers += files('nix_api_expr_internal.h')
|
||||
|
||||
subdir('nix-meson-build-support/export-all-symbols')
|
||||
subdir('nix-meson-build-support/windows-version')
|
||||
|
||||
|
||||
@@ -199,7 +199,9 @@ EvalState * nix_state_create(nix_c_context * context, const char ** lookupPath_c
|
||||
!= NIX_OK)
|
||||
return nullptr;
|
||||
|
||||
return nix_eval_state_build(context, builder);
|
||||
auto *state = nix_eval_state_build(context, builder);
|
||||
nix_eval_state_builder_free(builder);
|
||||
return state;
|
||||
}
|
||||
|
||||
void nix_state_free(EvalState * state)
|
||||
|
||||
@@ -286,6 +286,11 @@ nix_err nix_gc_incref(nix_c_context * context, const void * object);
|
||||
/**
|
||||
* @brief Decrement the garbage collector reference counter for the given object
|
||||
*
|
||||
* We also provide typed `nix_*_decref` functions, which are
|
||||
* - safer to use
|
||||
* - easier to integrate when deriving bindings
|
||||
* - allow more flexibility
|
||||
*
|
||||
* @param[out] context Optional, stores error information
|
||||
* @param[in] object The object to stop referencing
|
||||
*/
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace nix {
|
||||
ASSERT_EQ(PrintToString(e.info().msg),
|
||||
PrintToString(HintFmt("puppy")));
|
||||
auto trace = e.info().traces.rbegin();
|
||||
ASSERT_EQ(e.info().traces.size(), 2);
|
||||
ASSERT_EQ(e.info().traces.size(), 2u);
|
||||
ASSERT_EQ(PrintToString(trace->hint),
|
||||
PrintToString(HintFmt("doggy")));
|
||||
trace++;
|
||||
@@ -54,8 +54,8 @@ namespace nix {
|
||||
} catch (Error & e2) {
|
||||
e.addTrace(state.positions[noPos], "beans2");
|
||||
//e2.addTrace(state.positions[noPos], "Something", "");
|
||||
ASSERT_TRUE(e.info().traces.size() == 2);
|
||||
ASSERT_TRUE(e2.info().traces.size() == 0);
|
||||
ASSERT_TRUE(e.info().traces.size() == 2u);
|
||||
ASSERT_TRUE(e2.info().traces.size() == 0u);
|
||||
ASSERT_FALSE(&e.info() == &e2.info());
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ namespace nix {
|
||||
} catch (BaseError & e) { \
|
||||
ASSERT_EQ(PrintToString(e.info().msg), \
|
||||
PrintToString(message)); \
|
||||
ASSERT_EQ(e.info().traces.size(), 1) << "while testing " args << std::endl << e.what(); \
|
||||
ASSERT_EQ(e.info().traces.size(), 1u) << "while testing " args << std::endl << e.what(); \
|
||||
auto trace = e.info().traces.rbegin(); \
|
||||
ASSERT_EQ(PrintToString(trace->hint), \
|
||||
PrintToString(HintFmt("while calling the '%s' builtin", name))); \
|
||||
@@ -90,7 +90,7 @@ namespace nix {
|
||||
} catch (BaseError & e) { \
|
||||
ASSERT_EQ(PrintToString(e.info().msg), \
|
||||
PrintToString(message)); \
|
||||
ASSERT_EQ(e.info().traces.size(), 2) << "while testing " args << std::endl << e.what(); \
|
||||
ASSERT_EQ(e.info().traces.size(), 2u) << "while testing " args << std::endl << e.what(); \
|
||||
auto trace = e.info().traces.rbegin(); \
|
||||
ASSERT_EQ(PrintToString(trace->hint), \
|
||||
PrintToString(context)); \
|
||||
@@ -112,7 +112,7 @@ namespace nix {
|
||||
} catch (BaseError & e) { \
|
||||
ASSERT_EQ(PrintToString(e.info().msg), \
|
||||
PrintToString(message)); \
|
||||
ASSERT_EQ(e.info().traces.size(), 3) << "while testing " args << std::endl << e.what(); \
|
||||
ASSERT_EQ(e.info().traces.size(), 3u) << "while testing " args << std::endl << e.what(); \
|
||||
auto trace = e.info().traces.rbegin(); \
|
||||
ASSERT_EQ(PrintToString(trace->hint), \
|
||||
PrintToString(context1)); \
|
||||
@@ -137,7 +137,7 @@ namespace nix {
|
||||
} catch (BaseError & e) { \
|
||||
ASSERT_EQ(PrintToString(e.info().msg), \
|
||||
PrintToString(message)); \
|
||||
ASSERT_EQ(e.info().traces.size(), 4) << "while testing " args << std::endl << e.what(); \
|
||||
ASSERT_EQ(e.info().traces.size(), 4u) << "while testing " args << std::endl << e.what(); \
|
||||
auto trace = e.info().traces.rbegin(); \
|
||||
ASSERT_EQ(PrintToString(trace->hint), \
|
||||
PrintToString(context1)); \
|
||||
|
||||
@@ -222,7 +222,7 @@ TEST_F(nix_api_expr_test, nix_expr_realise_context)
|
||||
names.push_back(name);
|
||||
}
|
||||
std::sort(names.begin(), names.end());
|
||||
ASSERT_EQ(3, names.size());
|
||||
ASSERT_EQ(3u, names.size());
|
||||
EXPECT_THAT(names[0], testing::StrEq("just-a-file"));
|
||||
EXPECT_THAT(names[1], testing::StrEq("letsbuild"));
|
||||
EXPECT_THAT(names[2], testing::StrEq("not-actually-built-yet.drv"));
|
||||
|
||||
@@ -63,6 +63,9 @@ TEST_F(nix_api_expr_test, nix_expr_eval_external)
|
||||
std::string string_value;
|
||||
nix_get_string(nullptr, valueResult, OBSERVE_STRING(string_value));
|
||||
ASSERT_STREQ("nix-external<MyExternalValueDesc( 42 )>", string_value.c_str());
|
||||
|
||||
nix_state_free(stateResult);
|
||||
nix_state_free(stateFn);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -134,12 +134,12 @@ TEST_F(nix_api_expr_test, nix_build_and_init_list_invalid)
|
||||
{
|
||||
ASSERT_EQ(nullptr, nix_get_list_byidx(ctx, nullptr, state, 0));
|
||||
assert_ctx_err();
|
||||
ASSERT_EQ(0, nix_get_list_size(ctx, nullptr));
|
||||
ASSERT_EQ(0u, nix_get_list_size(ctx, nullptr));
|
||||
assert_ctx_err();
|
||||
|
||||
ASSERT_EQ(nullptr, nix_get_list_byidx(ctx, value, state, 0));
|
||||
assert_ctx_err();
|
||||
ASSERT_EQ(0, nix_get_list_size(ctx, value));
|
||||
ASSERT_EQ(0u, nix_get_list_size(ctx, value));
|
||||
assert_ctx_err();
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ TEST_F(nix_api_expr_test, nix_build_and_init_list)
|
||||
ASSERT_EQ(42, nix_get_int(ctx, nix_get_list_byidx(ctx, value, state, 0)));
|
||||
ASSERT_EQ(43, nix_get_int(ctx, nix_get_list_byidx(ctx, value, state, 1)));
|
||||
ASSERT_EQ(nullptr, nix_get_list_byidx(ctx, value, state, 2));
|
||||
ASSERT_EQ(10, nix_get_list_size(ctx, value));
|
||||
ASSERT_EQ(10u, nix_get_list_size(ctx, value));
|
||||
|
||||
ASSERT_STREQ("a list", nix_get_typename(ctx, value));
|
||||
ASSERT_EQ(NIX_TYPE_LIST, nix_get_type(ctx, value));
|
||||
@@ -180,7 +180,7 @@ TEST_F(nix_api_expr_test, nix_build_and_init_attr_invalid)
|
||||
assert_ctx_err();
|
||||
ASSERT_EQ(nullptr, nix_get_attr_name_byidx(ctx, nullptr, state, 0));
|
||||
assert_ctx_err();
|
||||
ASSERT_EQ(0, nix_get_attrs_size(ctx, nullptr));
|
||||
ASSERT_EQ(0u, nix_get_attrs_size(ctx, nullptr));
|
||||
assert_ctx_err();
|
||||
ASSERT_EQ(false, nix_has_attr_byname(ctx, nullptr, state, "no-value"));
|
||||
assert_ctx_err();
|
||||
@@ -191,7 +191,7 @@ TEST_F(nix_api_expr_test, nix_build_and_init_attr_invalid)
|
||||
assert_ctx_err();
|
||||
ASSERT_EQ(nullptr, nix_get_attr_name_byidx(ctx, value, state, 0));
|
||||
assert_ctx_err();
|
||||
ASSERT_EQ(0, nix_get_attrs_size(ctx, value));
|
||||
ASSERT_EQ(0u, nix_get_attrs_size(ctx, value));
|
||||
assert_ctx_err();
|
||||
ASSERT_EQ(false, nix_has_attr_byname(ctx, value, state, "no-value"));
|
||||
assert_ctx_err();
|
||||
@@ -215,7 +215,7 @@ TEST_F(nix_api_expr_test, nix_build_and_init_attr)
|
||||
nix_make_attrs(ctx, value, builder);
|
||||
nix_bindings_builder_free(builder);
|
||||
|
||||
ASSERT_EQ(2, nix_get_attrs_size(ctx, value));
|
||||
ASSERT_EQ(2u, nix_get_attrs_size(ctx, value));
|
||||
|
||||
nix_value * out_value = nix_get_attr_byname(ctx, value, state, "a");
|
||||
ASSERT_EQ(42, nix_get_int(ctx, out_value));
|
||||
@@ -374,7 +374,7 @@ TEST_F(nix_api_expr_test, nix_value_init_apply_lazy_arg)
|
||||
|
||||
auto n = nix_get_attrs_size(ctx, r);
|
||||
assert_ctx_ok();
|
||||
ASSERT_EQ(1, n);
|
||||
ASSERT_EQ(1u, n);
|
||||
|
||||
// nix_get_attr_byname isn't lazy (it could have been) so it will throw the exception
|
||||
nix_value * foo = nix_get_attr_byname(ctx, r, state, "foo");
|
||||
|
||||
@@ -56,11 +56,31 @@ namespace nix {
|
||||
TEST_F(PrimOpTest, ceil) {
|
||||
auto v = eval("builtins.ceil 1.9");
|
||||
ASSERT_THAT(v, IsIntEq(2));
|
||||
auto intMin = eval("builtins.ceil (-4611686018427387904 - 4611686018427387904)");
|
||||
ASSERT_THAT(intMin, IsIntEq(std::numeric_limits<NixInt::Inner>::min()));
|
||||
ASSERT_THROW(eval("builtins.ceil 1.0e200"), EvalError);
|
||||
ASSERT_THROW(eval("builtins.ceil -1.0e200"), EvalError);
|
||||
ASSERT_THROW(eval("builtins.ceil (1.0e200 * 1.0e200)"), EvalError); // inf
|
||||
ASSERT_THROW(eval("builtins.ceil (-1.0e200 * 1.0e200)"), EvalError); // -inf
|
||||
ASSERT_THROW(eval("builtins.ceil (1.0e200 * 1.0e200 - 1.0e200 * 1.0e200)"), EvalError); // nan
|
||||
// bugs in previous Nix versions
|
||||
ASSERT_THROW(eval("builtins.ceil (4611686018427387904 + 4611686018427387903)"), EvalError);
|
||||
ASSERT_THROW(eval("builtins.ceil (-4611686018427387904 - 4611686018427387903)"), EvalError);
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, floor) {
|
||||
auto v = eval("builtins.floor 1.9");
|
||||
ASSERT_THAT(v, IsIntEq(1));
|
||||
auto intMin = eval("builtins.ceil (-4611686018427387904 - 4611686018427387904)");
|
||||
ASSERT_THAT(intMin, IsIntEq(std::numeric_limits<NixInt::Inner>::min()));
|
||||
ASSERT_THROW(eval("builtins.ceil 1.0e200"), EvalError);
|
||||
ASSERT_THROW(eval("builtins.ceil -1.0e200"), EvalError);
|
||||
ASSERT_THROW(eval("builtins.ceil (1.0e200 * 1.0e200)"), EvalError); // inf
|
||||
ASSERT_THROW(eval("builtins.ceil (-1.0e200 * 1.0e200)"), EvalError); // -inf
|
||||
ASSERT_THROW(eval("builtins.ceil (1.0e200 * 1.0e200 - 1.0e200 * 1.0e200)"), EvalError); // nan
|
||||
// bugs in previous Nix versions
|
||||
ASSERT_THROW(eval("builtins.ceil (4611686018427387904 + 4611686018427387903)"), EvalError);
|
||||
ASSERT_THROW(eval("builtins.ceil (-4611686018427387904 - 4611686018427387903)"), EvalError);
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, tryEvalFailure) {
|
||||
@@ -204,7 +224,7 @@ namespace nix {
|
||||
auto v = eval("builtins.listToAttrs []");
|
||||
ASSERT_THAT(v, IsAttrsOfSize(0));
|
||||
ASSERT_EQ(v.type(), nAttrs);
|
||||
ASSERT_EQ(v.attrs()->size(), 0);
|
||||
ASSERT_EQ(v.attrs()->size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, listToAttrsNotFieldName) {
|
||||
@@ -383,7 +403,7 @@ namespace nix {
|
||||
TEST_F(PrimOpTest, genList) {
|
||||
auto v = eval("builtins.genList (x: x + 1) 3");
|
||||
ASSERT_EQ(v.type(), nList);
|
||||
ASSERT_EQ(v.listSize(), 3);
|
||||
ASSERT_EQ(v.listSize(), 3u);
|
||||
for (const auto [i, elem] : enumerate(v.listItems())) {
|
||||
ASSERT_THAT(*elem, IsThunk());
|
||||
state.forceValue(*elem, noPos);
|
||||
@@ -394,7 +414,7 @@ namespace nix {
|
||||
TEST_F(PrimOpTest, sortLessThan) {
|
||||
auto v = eval("builtins.sort builtins.lessThan [ 483 249 526 147 42 77 ]");
|
||||
ASSERT_EQ(v.type(), nList);
|
||||
ASSERT_EQ(v.listSize(), 6);
|
||||
ASSERT_EQ(v.listSize(), 6u);
|
||||
|
||||
const std::vector<int> numbers = { 42, 77, 147, 249, 483, 526 };
|
||||
for (const auto [n, elem] : enumerate(v.listItems()))
|
||||
@@ -414,7 +434,7 @@ namespace nix {
|
||||
auto wrong = v.attrs()->get(createSymbol("wrong"));
|
||||
ASSERT_NE(wrong, nullptr);
|
||||
ASSERT_EQ(wrong->value->type(), nList);
|
||||
ASSERT_EQ(wrong->value->listSize(), 3);
|
||||
ASSERT_EQ(wrong->value->listSize(), 3u);
|
||||
ASSERT_THAT(*wrong->value, IsListOfSize(3));
|
||||
ASSERT_THAT(*wrong->value->listElems()[0], IsIntEq(1));
|
||||
ASSERT_THAT(*wrong->value->listElems()[1], IsIntEq(9));
|
||||
@@ -424,7 +444,7 @@ namespace nix {
|
||||
TEST_F(PrimOpTest, concatMap) {
|
||||
auto v = eval("builtins.concatMap (x: x ++ [0]) [ [1 2] [3 4] ]");
|
||||
ASSERT_EQ(v.type(), nList);
|
||||
ASSERT_EQ(v.listSize(), 6);
|
||||
ASSERT_EQ(v.listSize(), 6u);
|
||||
|
||||
const std::vector<int> numbers = { 1, 2, 0, 3, 4, 0 };
|
||||
for (const auto [n, elem] : enumerate(v.listItems()))
|
||||
|
||||
@@ -110,5 +110,6 @@ template class EvalErrorBuilder<UndefinedVarError>;
|
||||
template class EvalErrorBuilder<MissingArgumentError>;
|
||||
template class EvalErrorBuilder<InfiniteRecursionError>;
|
||||
template class EvalErrorBuilder<InvalidPathError>;
|
||||
template class EvalErrorBuilder<IFDError>;
|
||||
|
||||
}
|
||||
+27
-5
@@ -19,6 +19,7 @@
|
||||
#include "nix/util/url.hh"
|
||||
#include "nix/fetchers/fetch-to-store.hh"
|
||||
#include "nix/fetchers/tarball.hh"
|
||||
#include "nix/fetchers/input-cache.hh"
|
||||
|
||||
#include "parser-tab.hh"
|
||||
|
||||
@@ -246,6 +247,30 @@ EvalState::EvalState(
|
||||
}
|
||||
, repair(NoRepair)
|
||||
, emptyBindings(0)
|
||||
, storeFS(
|
||||
makeMountedSourceAccessor(
|
||||
{
|
||||
{CanonPath::root, makeEmptySourceAccessor()},
|
||||
/* In the pure eval case, we can simply require
|
||||
valid paths. However, in the *impure* eval
|
||||
case this gets in the way of the union
|
||||
mechanism, because an invalid access in the
|
||||
upper layer will *not* be caught by the union
|
||||
source accessor, but instead abort the entire
|
||||
lookup.
|
||||
|
||||
This happens when the store dir in the
|
||||
ambient file system has a path (e.g. because
|
||||
another Nix store there), but the relocated
|
||||
store does not.
|
||||
|
||||
TODO make the various source accessors doing
|
||||
access control all throw the same type of
|
||||
exception, and make union source accessor
|
||||
catch it, so we don't need to do this hack.
|
||||
*/
|
||||
{CanonPath(store->storeDir), store->getFSAccessor(settings.pureEval)},
|
||||
}))
|
||||
, rootFS(
|
||||
({
|
||||
/* In pure eval mode, we provide a filesystem that only
|
||||
@@ -261,11 +286,6 @@ EvalState::EvalState(
|
||||
|
||||
auto realStoreDir = dirOf(store->toRealPath(StorePath::dummy));
|
||||
if (settings.pureEval || store->storeDir != realStoreDir) {
|
||||
auto storeFS = makeMountedSourceAccessor(
|
||||
{
|
||||
{CanonPath::root, makeEmptySourceAccessor()},
|
||||
{CanonPath(store->storeDir), makeFSSourceAccessor(realStoreDir)}
|
||||
});
|
||||
accessor = settings.pureEval
|
||||
? storeFS
|
||||
: makeUnionSourceAccessor({accessor, storeFS});
|
||||
@@ -291,6 +311,7 @@ EvalState::EvalState(
|
||||
)}
|
||||
, store(store)
|
||||
, buildStore(buildStore ? buildStore : store)
|
||||
, inputCache(fetchers::InputCache::create())
|
||||
, debugRepl(nullptr)
|
||||
, debugStop(false)
|
||||
, trylevel(0)
|
||||
@@ -1133,6 +1154,7 @@ void EvalState::resetFileCache()
|
||||
{
|
||||
fileEvalCache.clear();
|
||||
fileParseCache.clear();
|
||||
inputCache->clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ MakeError(TypeError, EvalError);
|
||||
MakeError(UndefinedVarError, EvalError);
|
||||
MakeError(MissingArgumentError, EvalError);
|
||||
MakeError(InfiniteRecursionError, EvalError);
|
||||
MakeError(IFDError, EvalBaseError);
|
||||
|
||||
struct InvalidPathError : public EvalError
|
||||
{
|
||||
|
||||
@@ -33,7 +33,10 @@ namespace nix {
|
||||
constexpr size_t maxPrimOpArity = 8;
|
||||
|
||||
class Store;
|
||||
namespace fetchers { struct Settings; }
|
||||
namespace fetchers {
|
||||
struct Settings;
|
||||
struct InputCache;
|
||||
}
|
||||
struct EvalSettings;
|
||||
class EvalState;
|
||||
class StorePath;
|
||||
@@ -265,6 +268,11 @@ public:
|
||||
/** `"unknown"` */
|
||||
Value vStringUnknown;
|
||||
|
||||
/**
|
||||
* The accessor corresponding to `store`.
|
||||
*/
|
||||
const ref<SourceAccessor> storeFS;
|
||||
|
||||
/**
|
||||
* The accessor for the root filesystem.
|
||||
*/
|
||||
@@ -295,6 +303,8 @@ public:
|
||||
|
||||
RootValue vImportedDrvToDerivation = nullptr;
|
||||
|
||||
ref<fetchers::InputCache> inputCache;
|
||||
|
||||
/**
|
||||
* Debugger
|
||||
*/
|
||||
|
||||
@@ -179,7 +179,12 @@ static Expr * makeCall(PosIdx pos, Expr * fn, Expr * arg) {
|
||||
|
||||
%%
|
||||
|
||||
start: expr { state->result = $1; };
|
||||
start: expr {
|
||||
state->result = $1;
|
||||
|
||||
// This parser does not use yynerrs; suppress the warning.
|
||||
(void) yynerrs;
|
||||
};
|
||||
|
||||
expr: expr_function;
|
||||
|
||||
|
||||
+63
-13
@@ -91,7 +91,7 @@ StringMap EvalState::realiseContext(const NixStringContext & context, StorePathS
|
||||
if (drvs.empty()) return {};
|
||||
|
||||
if (isIFD && !settings.enableImportFromDerivation)
|
||||
error<EvalBaseError>(
|
||||
error<IFDError>(
|
||||
"cannot build '%1%' during evaluation because the option 'allow-import-from-derivation' is disabled",
|
||||
drvs.begin()->to_string(*store)
|
||||
).debugThrow();
|
||||
@@ -888,18 +888,40 @@ static void prim_ceil(EvalState & state, const PosIdx pos, Value * * args, Value
|
||||
{
|
||||
auto value = state.forceFloat(*args[0], args[0]->determinePos(pos),
|
||||
"while evaluating the first argument passed to builtins.ceil");
|
||||
v.mkInt(ceil(value));
|
||||
auto ceilValue = ceil(value);
|
||||
bool isInt = args[0]->type() == nInt;
|
||||
constexpr NixFloat int_min = std::numeric_limits<NixInt::Inner>::min(); // power of 2, so that no rounding occurs
|
||||
if (ceilValue >= int_min && ceilValue < -int_min) {
|
||||
v.mkInt(ceilValue);
|
||||
} else if (isInt) {
|
||||
// a NixInt, e.g. INT64_MAX, can be rounded to -int_min due to the cast to NixFloat
|
||||
state.error<EvalError>("Due to a bug (see https://github.com/NixOS/nix/issues/12899) the NixInt argument %1% caused undefined behavior in previous Nix versions.\n\tFuture Nix versions might implement the correct behavior.", args[0]->integer().value).atPos(pos).debugThrow();
|
||||
} else {
|
||||
state.error<EvalError>("NixFloat argument %1% is not in the range of NixInt", args[0]->fpoint()).atPos(pos).debugThrow();
|
||||
}
|
||||
// `forceFloat` casts NixInt to NixFloat, but instead NixInt args shall be returned unmodified
|
||||
if (isInt) {
|
||||
auto arg = args[0]->integer();
|
||||
auto res = v.integer();
|
||||
if (arg != res) {
|
||||
state.error<EvalError>("Due to a bug (see https://github.com/NixOS/nix/issues/12899) a loss of precision occured in previous Nix versions because the NixInt argument %1% was rounded to %2%.\n\tFuture Nix versions might implement the correct behavior.", arg, res).atPos(pos).debugThrow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static RegisterPrimOp primop_ceil({
|
||||
.name = "__ceil",
|
||||
.args = {"double"},
|
||||
.args = {"number"},
|
||||
.doc = R"(
|
||||
Converts an IEEE-754 double-precision floating-point number (*double*) to
|
||||
the next higher integer.
|
||||
Rounds and converts *number* to the next higher NixInt value if possible, i.e. `ceil *number* >= *number*` and
|
||||
`ceil *number* - *number* < 1`.
|
||||
|
||||
If the datatype is neither an integer nor a "float", an evaluation error will be
|
||||
thrown.
|
||||
An evaluation error is thrown, if there exists no such NixInt value `ceil *number*`.
|
||||
Due to bugs in previous Nix versions an evaluation error might be thrown, if the datatype of *number* is
|
||||
a NixInt and if `*number* < -9007199254740992` or `*number* > 9007199254740992`.
|
||||
|
||||
If the datatype of *number* is neither a NixInt (signed 64-bit integer) nor a NixFloat
|
||||
(IEEE-754 double-precision floating-point number), an evaluation error will be thrown.
|
||||
)",
|
||||
.fun = prim_ceil,
|
||||
});
|
||||
@@ -907,18 +929,40 @@ static RegisterPrimOp primop_ceil({
|
||||
static void prim_floor(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
||||
{
|
||||
auto value = state.forceFloat(*args[0], args[0]->determinePos(pos), "while evaluating the first argument passed to builtins.floor");
|
||||
v.mkInt(floor(value));
|
||||
auto floorValue = floor(value);
|
||||
bool isInt = args[0]->type() == nInt;
|
||||
constexpr NixFloat int_min = std::numeric_limits<NixInt::Inner>::min(); // power of 2, so that no rounding occurs
|
||||
if (floorValue >= int_min && floorValue < -int_min) {
|
||||
v.mkInt(floorValue);
|
||||
} else if (isInt) {
|
||||
// a NixInt, e.g. INT64_MAX, can be rounded to -int_min due to the cast to NixFloat
|
||||
state.error<EvalError>("Due to a bug (see https://github.com/NixOS/nix/issues/12899) the NixInt argument %1% caused undefined behavior in previous Nix versions.\n\tFuture Nix versions might implement the correct behavior.", args[0]->integer().value).atPos(pos).debugThrow();
|
||||
} else {
|
||||
state.error<EvalError>("NixFloat argument %1% is not in the range of NixInt", args[0]->fpoint()).atPos(pos).debugThrow();
|
||||
}
|
||||
// `forceFloat` casts NixInt to NixFloat, but instead NixInt args shall be returned unmodified
|
||||
if (isInt) {
|
||||
auto arg = args[0]->integer();
|
||||
auto res = v.integer();
|
||||
if (arg != res) {
|
||||
state.error<EvalError>("Due to a bug (see https://github.com/NixOS/nix/issues/12899) a loss of precision occured in previous Nix versions because the NixInt argument %1% was rounded to %2%.\n\tFuture Nix versions might implement the correct behavior.", arg, res).atPos(pos).debugThrow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static RegisterPrimOp primop_floor({
|
||||
.name = "__floor",
|
||||
.args = {"double"},
|
||||
.args = {"number"},
|
||||
.doc = R"(
|
||||
Converts an IEEE-754 double-precision floating-point number (*double*) to
|
||||
the next lower integer.
|
||||
Rounds and converts *number* to the next lower NixInt value if possible, i.e. `floor *number* <= *number*` and
|
||||
`*number* - floor *number* < 1`.
|
||||
|
||||
If the datatype is neither an integer nor a "float", an evaluation error will be
|
||||
thrown.
|
||||
An evaluation error is thrown, if there exists no such NixInt value `floor *number*`.
|
||||
Due to bugs in previous Nix versions an evaluation error might be thrown, if the datatype of *number* is
|
||||
a NixInt and if `*number* < -9007199254740992` or `*number* > 9007199254740992`.
|
||||
|
||||
If the datatype of *number* is neither a NixInt (signed 64-bit integer) nor a NixFloat
|
||||
(IEEE-754 double-precision floating-point number), an evaluation error will be thrown.
|
||||
)",
|
||||
.fun = prim_floor,
|
||||
});
|
||||
@@ -2775,7 +2819,13 @@ static void prim_unsafeGetAttrPos(EvalState & state, const PosIdx pos, Value * *
|
||||
|
||||
static RegisterPrimOp primop_unsafeGetAttrPos(PrimOp {
|
||||
.name = "__unsafeGetAttrPos",
|
||||
.args = {"s", "set"},
|
||||
.arity = 2,
|
||||
.doc = R"(
|
||||
`unsafeGetAttrPos` returns the position of the attribute named *s*
|
||||
from *set*. This is used by Nixpkgs to provide location information
|
||||
in error messages.
|
||||
)",
|
||||
.fun = prim_unsafeGetAttrPos,
|
||||
});
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
namespace nix {
|
||||
using json = nlohmann::json;
|
||||
// TODO: rename. It doesn't print.
|
||||
json printValueAsJSON(EvalState & state, bool strict,
|
||||
Value & v, const PosIdx pos, NixStringContext & context, bool copyToStore)
|
||||
{
|
||||
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../.version
|
||||
@@ -0,0 +1,65 @@
|
||||
project('nix-fetchers-c', 'cpp',
|
||||
version : files('.version'),
|
||||
default_options : [
|
||||
'cpp_std=c++2a',
|
||||
# TODO(Qyriad): increase the warning level
|
||||
'warning_level=1',
|
||||
'errorlogs=true', # Please print logs for tests that fail
|
||||
],
|
||||
meson_version : '>= 1.1',
|
||||
license : 'LGPL-2.1-or-later',
|
||||
)
|
||||
|
||||
cxx = meson.get_compiler('cpp')
|
||||
|
||||
subdir('nix-meson-build-support/deps-lists')
|
||||
|
||||
deps_private_maybe_subproject = [
|
||||
dependency('nix-util'),
|
||||
dependency('nix-store'),
|
||||
dependency('nix-fetchers'),
|
||||
]
|
||||
deps_public_maybe_subproject = [
|
||||
dependency('nix-util-c'),
|
||||
dependency('nix-store-c'),
|
||||
]
|
||||
subdir('nix-meson-build-support/subprojects')
|
||||
|
||||
add_project_arguments(
|
||||
language : 'cpp',
|
||||
)
|
||||
|
||||
subdir('nix-meson-build-support/common')
|
||||
|
||||
sources = files(
|
||||
'nix_api_fetchers.cc',
|
||||
)
|
||||
|
||||
include_dirs = [include_directories('.')]
|
||||
|
||||
headers = files(
|
||||
'nix_api_fetchers.h',
|
||||
'nix_api_fetchers_internal.hh',
|
||||
)
|
||||
|
||||
# TODO move this header to libexpr, maybe don't use it in tests?
|
||||
headers += files('nix_api_fetchers.h')
|
||||
|
||||
subdir('nix-meson-build-support/export-all-symbols')
|
||||
subdir('nix-meson-build-support/windows-version')
|
||||
|
||||
this_library = library(
|
||||
'nixfetchersc',
|
||||
sources,
|
||||
dependencies : deps_public + deps_private + deps_other,
|
||||
include_directories : include_dirs,
|
||||
link_args: linker_export_flags,
|
||||
prelink : true, # For C++ static initializers
|
||||
install : true,
|
||||
)
|
||||
|
||||
install_headers(headers, preserve_path : true)
|
||||
|
||||
libraries_private = []
|
||||
|
||||
subdir('nix-meson-build-support/export')
|
||||
@@ -0,0 +1 @@
|
||||
../../nix-meson-build-support
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "nix_api_fetchers.h"
|
||||
#include "nix_api_fetchers_internal.hh"
|
||||
#include "nix_api_util_internal.h"
|
||||
|
||||
nix_fetchers_settings * nix_fetchers_settings_new(nix_c_context * context)
|
||||
{
|
||||
try {
|
||||
auto fetchersSettings = nix::make_ref<nix::fetchers::Settings>(nix::fetchers::Settings{});
|
||||
return new nix_fetchers_settings{
|
||||
.settings = fetchersSettings,
|
||||
};
|
||||
}
|
||||
NIXC_CATCH_ERRS_NULL
|
||||
}
|
||||
|
||||
void nix_fetchers_settings_free(nix_fetchers_settings * settings)
|
||||
{
|
||||
delete settings;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef NIX_API_FETCHERS_H
|
||||
#define NIX_API_FETCHERS_H
|
||||
/** @defgroup libfetchers libfetchers
|
||||
* @brief Bindings to the Nix fetchers library
|
||||
* @{
|
||||
*/
|
||||
/** @file
|
||||
* @brief Main entry for the libfetchers C bindings
|
||||
*/
|
||||
|
||||
#include "nix_api_util.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
// cffi start
|
||||
|
||||
// Type definitions
|
||||
/**
|
||||
* @brief Shared settings object
|
||||
*/
|
||||
typedef struct nix_fetchers_settings nix_fetchers_settings;
|
||||
|
||||
nix_fetchers_settings * nix_fetchers_settings_new(nix_c_context * context);
|
||||
|
||||
void nix_fetchers_settings_free(nix_fetchers_settings * settings);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // NIX_API_FETCHERS_H
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "nix/fetchers/fetch-settings.hh"
|
||||
#include "nix/util/ref.hh"
|
||||
|
||||
/**
|
||||
* A shared reference to `nix::fetchers::Settings`
|
||||
* @see nix::fetchers::Settings
|
||||
*/
|
||||
struct nix_fetchers_settings
|
||||
{
|
||||
nix::ref<nix::fetchers::Settings> settings;
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
lib,
|
||||
mkMesonLibrary,
|
||||
|
||||
nix-store-c,
|
||||
nix-expr-c,
|
||||
nix-util-c,
|
||||
nix-fetchers,
|
||||
|
||||
# Configuration Options
|
||||
|
||||
version,
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) fileset;
|
||||
in
|
||||
|
||||
mkMesonLibrary (finalAttrs: {
|
||||
pname = "nix-fetchers-c";
|
||||
inherit version;
|
||||
|
||||
workDir = ./.;
|
||||
fileset = fileset.unions [
|
||||
../../nix-meson-build-support
|
||||
./nix-meson-build-support
|
||||
../../.version
|
||||
./.version
|
||||
./meson.build
|
||||
# ./meson.options
|
||||
(fileset.fileFilter (file: file.hasExt "cc") ./.)
|
||||
(fileset.fileFilter (file: file.hasExt "hh") ./.)
|
||||
(fileset.fileFilter (file: file.hasExt "h") ./.)
|
||||
];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
nix-util-c
|
||||
nix-expr-c
|
||||
nix-store-c
|
||||
nix-fetchers
|
||||
];
|
||||
|
||||
mesonFlags = [
|
||||
];
|
||||
|
||||
meta = {
|
||||
platforms = lib.platforms.unix ++ lib.platforms.windows;
|
||||
};
|
||||
|
||||
})
|
||||
@@ -90,11 +90,11 @@ TEST_F(GitUtilsTest, sink_basic)
|
||||
auto result = repo->dereferenceSingletonDirectory(sink->flush());
|
||||
auto accessor = repo->getAccessor(result, false, getRepoName());
|
||||
auto entries = accessor->readDirectory(CanonPath::root);
|
||||
ASSERT_EQ(entries.size(), 5);
|
||||
ASSERT_EQ(entries.size(), 5u);
|
||||
ASSERT_EQ(accessor->readFile(CanonPath("hello")), "hello world");
|
||||
ASSERT_EQ(accessor->readFile(CanonPath("bye")), "thanks for all the fish");
|
||||
ASSERT_EQ(accessor->readLink(CanonPath("bye-link")), "bye");
|
||||
ASSERT_EQ(accessor->readDirectory(CanonPath("empty")).size(), 0);
|
||||
ASSERT_EQ(accessor->readDirectory(CanonPath("empty")).size(), 0u);
|
||||
ASSERT_EQ(accessor->readFile(CanonPath("links/foo")), "hello world");
|
||||
};
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ subdir('nix-meson-build-support/deps-lists')
|
||||
deps_private_maybe_subproject = [
|
||||
dependency('nix-store-test-support'),
|
||||
dependency('nix-fetchers'),
|
||||
dependency('nix-fetchers-c'),
|
||||
]
|
||||
deps_public_maybe_subproject = [
|
||||
]
|
||||
@@ -39,6 +40,7 @@ subdir('nix-meson-build-support/common')
|
||||
sources = files(
|
||||
'access-tokens.cc',
|
||||
'git-utils.cc',
|
||||
'nix_api_fetchers.cc',
|
||||
'public-key.cc',
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "nix_api_fetchers.h"
|
||||
#include "nix/store/tests/nix_api_store.hh"
|
||||
|
||||
namespace nixC {
|
||||
|
||||
TEST_F(nix_api_store_test, nix_api_fetchers_new_free)
|
||||
{
|
||||
nix_fetchers_settings * settings = nix_fetchers_settings_new(ctx);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, settings);
|
||||
|
||||
nix_fetchers_settings_free(settings);
|
||||
}
|
||||
|
||||
} // namespace nixC
|
||||
@@ -5,6 +5,7 @@
|
||||
mkMesonExecutable,
|
||||
|
||||
nix-fetchers,
|
||||
nix-fetchers-c,
|
||||
nix-store-test-support,
|
||||
|
||||
libgit2,
|
||||
@@ -40,6 +41,7 @@ mkMesonExecutable (finalAttrs: {
|
||||
|
||||
buildInputs = [
|
||||
nix-fetchers
|
||||
nix-fetchers-c
|
||||
nix-store-test-support
|
||||
rapidcheck
|
||||
gtest
|
||||
|
||||
@@ -44,10 +44,11 @@ static void downloadToSink(
|
||||
|
||||
static std::string getLfsApiToken(const ParsedURL & url)
|
||||
{
|
||||
auto [status, output] = runProgram(RunOptions{
|
||||
.program = "ssh",
|
||||
.args = {*url.authority, "git-lfs-authenticate", url.path, "download"},
|
||||
});
|
||||
auto [status, output] = runProgram(
|
||||
RunOptions{
|
||||
.program = "ssh",
|
||||
.args = {*url.authority, "git-lfs-authenticate", url.path, "download"},
|
||||
});
|
||||
|
||||
if (output.empty())
|
||||
throw Error(
|
||||
|
||||
@@ -1245,7 +1245,12 @@ std::vector<std::tuple<GitRepoImpl::Submodule, Hash>> GitRepoImpl::getSubmodules
|
||||
auto configS = accessor->readFile(modulesFile);
|
||||
|
||||
auto [fdTemp, pathTemp] = createTempFile("nix-git-submodules");
|
||||
writeFull(fdTemp.get(), configS);
|
||||
try {
|
||||
writeFull(fdTemp.get(), configS);
|
||||
} catch (SysError & e) {
|
||||
e.addTrace({}, "while writing .gitmodules file to temporary file");
|
||||
throw;
|
||||
}
|
||||
|
||||
std::vector<std::tuple<Submodule, Hash>> result;
|
||||
|
||||
|
||||
+14
-14
@@ -38,7 +38,7 @@ const std::string gitInitialBranch = "__nix_dummy_branch";
|
||||
|
||||
bool isCacheFileWithinTtl(time_t now, const struct stat & st)
|
||||
{
|
||||
return st.st_mtime + settings.tarballTtl > now;
|
||||
return st.st_mtime + static_cast<time_t>(settings.tarballTtl) > now;
|
||||
}
|
||||
|
||||
Path getCachePath(std::string_view key, bool shallow)
|
||||
@@ -83,10 +83,9 @@ std::optional<std::string> readHead(const Path & path)
|
||||
}
|
||||
|
||||
// Persist the HEAD ref from the remote repo in the local cached repo.
|
||||
bool storeCachedHead(const std::string & actualUrl, const std::string & headRef)
|
||||
bool storeCachedHead(const std::string & actualUrl, bool shallow, const std::string & headRef)
|
||||
{
|
||||
// set shallow=false as HEAD will never be queried for a shallow repo
|
||||
Path cacheDir = getCachePath(actualUrl, false);
|
||||
Path cacheDir = getCachePath(actualUrl, shallow);
|
||||
try {
|
||||
runProgram("git", true, { "-C", cacheDir, "--git-dir", ".", "symbolic-ref", "--", "HEAD", headRef });
|
||||
} catch (ExecError &e) {
|
||||
@@ -105,12 +104,11 @@ bool storeCachedHead(const std::string & actualUrl, const std::string & headRef)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<std::string> readHeadCached(const std::string & actualUrl)
|
||||
std::optional<std::string> readHeadCached(const std::string & actualUrl, bool shallow)
|
||||
{
|
||||
// Create a cache path to store the branch of the HEAD ref. Append something
|
||||
// in front of the URL to prevent collision with the repository itself.
|
||||
// set shallow=false as HEAD will never be queried for a shallow repo
|
||||
Path cacheDir = getCachePath(actualUrl, false);
|
||||
Path cacheDir = getCachePath(actualUrl, shallow);
|
||||
Path headRefFile = cacheDir + "/HEAD";
|
||||
|
||||
time_t now = time(0);
|
||||
@@ -516,14 +514,14 @@ struct GitInputScheme : InputScheme
|
||||
return revCount;
|
||||
}
|
||||
|
||||
std::string getDefaultRef(const RepoInfo & repoInfo) const
|
||||
std::string getDefaultRef(const RepoInfo & repoInfo, bool shallow) const
|
||||
{
|
||||
auto head = std::visit(
|
||||
overloaded {
|
||||
[&](const std::filesystem::path & path)
|
||||
{ return GitRepo::openRepo(path)->getWorkdirRef(); },
|
||||
[&](const ParsedURL & url)
|
||||
{ return readHeadCached(url.to_string()); }
|
||||
{ return readHeadCached(url.to_string(), shallow); }
|
||||
}, repoInfo.location);
|
||||
if (!head) {
|
||||
warn("could not read HEAD ref from repo at '%s', using 'master'", repoInfo.locationToArg());
|
||||
@@ -572,7 +570,8 @@ struct GitInputScheme : InputScheme
|
||||
auto origRev = input.getRev();
|
||||
|
||||
auto originalRef = input.getRef();
|
||||
auto ref = originalRef ? *originalRef : getDefaultRef(repoInfo);
|
||||
bool shallow = getShallowAttr(input);
|
||||
auto ref = originalRef ? *originalRef : getDefaultRef(repoInfo, shallow);
|
||||
input.attrs.insert_or_assign("ref", ref);
|
||||
|
||||
std::filesystem::path repoDir;
|
||||
@@ -583,7 +582,7 @@ struct GitInputScheme : InputScheme
|
||||
input.attrs.insert_or_assign("rev", GitRepo::openRepo(repoDir)->resolveRef(ref).gitRev());
|
||||
} else {
|
||||
auto repoUrl = std::get<ParsedURL>(repoInfo.location);
|
||||
std::filesystem::path cacheDir = getCachePath(repoUrl.to_string(), getShallowAttr(input));
|
||||
std::filesystem::path cacheDir = getCachePath(repoUrl.to_string(), shallow);
|
||||
repoDir = cacheDir;
|
||||
repoInfo.gitDir = ".";
|
||||
|
||||
@@ -620,6 +619,7 @@ struct GitInputScheme : InputScheme
|
||||
}
|
||||
|
||||
if (doFetch) {
|
||||
bool shallow = getShallowAttr(input);
|
||||
try {
|
||||
auto fetchRef =
|
||||
getAllRefsAttr(input)
|
||||
@@ -632,7 +632,7 @@ struct GitInputScheme : InputScheme
|
||||
? ref
|
||||
: fmt("%1%:%1%", "refs/heads/" + ref);
|
||||
|
||||
repo->fetch(repoUrl.to_string(), fetchRef, getShallowAttr(input));
|
||||
repo->fetch(repoUrl.to_string(), fetchRef, shallow);
|
||||
} catch (Error & e) {
|
||||
if (!std::filesystem::exists(localRefFile)) throw;
|
||||
logError(e.info());
|
||||
@@ -643,9 +643,9 @@ struct GitInputScheme : InputScheme
|
||||
if (!input.getRev())
|
||||
setWriteTime(localRefFile, now, now);
|
||||
} catch (Error & e) {
|
||||
warn("could not update mtime for file '%s': %s", localRefFile, e.info().msg);
|
||||
warn("could not update mtime for file %s: %s", localRefFile, e.info().msg);
|
||||
}
|
||||
if (!originalRef && !storeCachedHead(repoUrl.to_string(), ref))
|
||||
if (!originalRef && !storeCachedHead(repoUrl.to_string(), shallow, ref))
|
||||
warn("could not update cached head '%s' for '%s'", ref, repoInfo.locationToArg());
|
||||
}
|
||||
|
||||
|
||||
@@ -149,6 +149,9 @@ struct GitArchiveInputScheme : InputScheme
|
||||
};
|
||||
if (auto narHash = input.getNarHash())
|
||||
url.query.insert_or_assign("narHash", narHash->to_string(HashFormat::SRI, true));
|
||||
auto host = maybeGetStrAttr(input.attrs, "host");
|
||||
if (host)
|
||||
url.query.insert_or_assign("host", *host);
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "fetchers.hh"
|
||||
|
||||
namespace nix::fetchers {
|
||||
|
||||
struct InputCache
|
||||
{
|
||||
struct CachedResult
|
||||
{
|
||||
ref<SourceAccessor> accessor;
|
||||
Input resolvedInput;
|
||||
Input lockedInput;
|
||||
};
|
||||
|
||||
CachedResult getAccessor(ref<Store> store, const Input & originalInput, bool useRegistries);
|
||||
|
||||
struct CachedInput
|
||||
{
|
||||
Input lockedInput;
|
||||
ref<SourceAccessor> accessor;
|
||||
};
|
||||
|
||||
virtual std::optional<CachedInput> lookup(const Input & originalInput) const = 0;
|
||||
|
||||
virtual void upsert(Input key, CachedInput cachedInput) = 0;
|
||||
|
||||
virtual void clear() = 0;
|
||||
|
||||
static ref<InputCache> create();
|
||||
|
||||
virtual ~InputCache() = default;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ headers = files(
|
||||
'filtering-source-accessor.hh',
|
||||
'git-lfs-fetch.hh',
|
||||
'git-utils.hh',
|
||||
'input-cache.hh',
|
||||
'registry.hh',
|
||||
'store-path-accessor.hh',
|
||||
'tarball.hh',
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
#include "nix/fetchers/input-cache.hh"
|
||||
#include "nix/fetchers/registry.hh"
|
||||
#include "nix/util/sync.hh"
|
||||
#include "nix/util/source-path.hh"
|
||||
|
||||
namespace nix::fetchers {
|
||||
|
||||
InputCache::CachedResult InputCache::getAccessor(ref<Store> store, const Input & originalInput, bool useRegistries)
|
||||
{
|
||||
auto fetched = lookup(originalInput);
|
||||
Input resolvedInput = originalInput;
|
||||
|
||||
if (!fetched) {
|
||||
if (originalInput.isDirect()) {
|
||||
auto [accessor, lockedInput] = originalInput.getAccessor(store);
|
||||
fetched.emplace(CachedInput{.lockedInput = lockedInput, .accessor = accessor});
|
||||
} else {
|
||||
if (useRegistries) {
|
||||
auto [res, extraAttrs] =
|
||||
lookupInRegistries(store, originalInput, [](fetchers::Registry::RegistryType type) {
|
||||
/* Only use the global registry and CLI flags
|
||||
to resolve indirect flakerefs. */
|
||||
return type == fetchers::Registry::Flag || type == fetchers::Registry::Global;
|
||||
});
|
||||
resolvedInput = std::move(res);
|
||||
fetched = lookup(resolvedInput);
|
||||
if (!fetched) {
|
||||
auto [accessor, lockedInput] = resolvedInput.getAccessor(store);
|
||||
fetched.emplace(CachedInput{.lockedInput = lockedInput, .accessor = accessor});
|
||||
}
|
||||
upsert(resolvedInput, *fetched);
|
||||
} else {
|
||||
throw Error(
|
||||
"'%s' is an indirect flake reference, but registry lookups are not allowed",
|
||||
originalInput.to_string());
|
||||
}
|
||||
}
|
||||
upsert(originalInput, *fetched);
|
||||
}
|
||||
|
||||
debug("got tree '%s' from '%s'", fetched->accessor, fetched->lockedInput.to_string());
|
||||
|
||||
return {fetched->accessor, resolvedInput, fetched->lockedInput};
|
||||
}
|
||||
|
||||
struct InputCacheImpl : InputCache
|
||||
{
|
||||
Sync<std::map<Input, CachedInput>> cache_;
|
||||
|
||||
std::optional<CachedInput> lookup(const Input & originalInput) const override
|
||||
{
|
||||
auto cache(cache_.readLock());
|
||||
auto i = cache->find(originalInput);
|
||||
if (i == cache->end())
|
||||
return std::nullopt;
|
||||
debug(
|
||||
"mapping '%s' to previously seen input '%s' -> '%s",
|
||||
originalInput.to_string(),
|
||||
i->first.to_string(),
|
||||
i->second.lockedInput.to_string());
|
||||
return i->second;
|
||||
}
|
||||
|
||||
void upsert(Input key, CachedInput cachedInput) override
|
||||
{
|
||||
cache_.lock()->insert_or_assign(std::move(key), std::move(cachedInput));
|
||||
}
|
||||
|
||||
void clear() override
|
||||
{
|
||||
cache_.lock()->clear();
|
||||
}
|
||||
};
|
||||
|
||||
ref<InputCache> InputCache::create()
|
||||
{
|
||||
return make_ref<InputCacheImpl>();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,6 +44,7 @@ sources = files(
|
||||
'git.cc',
|
||||
'github.cc',
|
||||
'indirect.cc',
|
||||
'input-cache.cc',
|
||||
'mercurial.cc',
|
||||
'path.cc',
|
||||
'registry.cc',
|
||||
|
||||
@@ -5,11 +5,7 @@ namespace nix {
|
||||
|
||||
ref<SourceAccessor> makeStorePathAccessor(ref<Store> store, const StorePath & storePath)
|
||||
{
|
||||
// FIXME: should use `store->getFSAccessor()`
|
||||
auto root = std::filesystem::path{store->toRealPath(storePath)};
|
||||
auto accessor = makeFSSourceAccessor(root);
|
||||
accessor->setPathDisplay(root.string());
|
||||
return accessor;
|
||||
return projectSubdirSourceAccessor(store->getFSAccessor(), storePath.to_string());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,12 +17,14 @@ subdir('nix-meson-build-support/deps-lists')
|
||||
deps_private_maybe_subproject = [
|
||||
dependency('nix-util'),
|
||||
dependency('nix-store'),
|
||||
dependency('nix-fetchers'),
|
||||
dependency('nix-expr'),
|
||||
dependency('nix-flake'),
|
||||
]
|
||||
deps_public_maybe_subproject = [
|
||||
dependency('nix-util-c'),
|
||||
dependency('nix-store-c'),
|
||||
dependency('nix-fetchers-c'),
|
||||
dependency('nix-expr-c'),
|
||||
]
|
||||
subdir('nix-meson-build-support/subprojects')
|
||||
@@ -37,6 +39,7 @@ include_dirs = [include_directories('.')]
|
||||
|
||||
headers = files(
|
||||
'nix_api_flake.h',
|
||||
'nix_api_flake_internal.hh',
|
||||
)
|
||||
|
||||
# TODO move this header to libexpr, maybe don't use it in tests?
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
#include "nix_api_flake.h"
|
||||
#include "nix_api_flake_internal.hh"
|
||||
#include "nix_api_util.h"
|
||||
#include "nix_api_util_internal.h"
|
||||
#include "nix_api_expr_internal.h"
|
||||
#include "nix_api_fetchers_internal.hh"
|
||||
#include "nix_api_fetchers.h"
|
||||
|
||||
#include "nix/flake/flake.hh"
|
||||
|
||||
nix_flake_settings * nix_flake_settings_new(nix_c_context * context)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
auto settings = nix::make_ref<nix::flake::Settings>();
|
||||
return new nix_flake_settings{settings};
|
||||
@@ -22,8 +26,178 @@ void nix_flake_settings_free(nix_flake_settings * settings)
|
||||
nix_err nix_flake_settings_add_to_eval_state_builder(
|
||||
nix_c_context * context, nix_flake_settings * settings, nix_eval_state_builder * builder)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
settings->settings->configureEvalSettings(builder->settings);
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_flake_reference_parse_flags *
|
||||
nix_flake_reference_parse_flags_new(nix_c_context * context, nix_flake_settings * settings)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
return new nix_flake_reference_parse_flags{
|
||||
.baseDirectory = std::nullopt,
|
||||
};
|
||||
}
|
||||
NIXC_CATCH_ERRS_NULL
|
||||
}
|
||||
|
||||
void nix_flake_reference_parse_flags_free(nix_flake_reference_parse_flags * flags)
|
||||
{
|
||||
delete flags;
|
||||
}
|
||||
|
||||
nix_err nix_flake_reference_parse_flags_set_base_directory(
|
||||
nix_c_context * context,
|
||||
nix_flake_reference_parse_flags * flags,
|
||||
const char * baseDirectory,
|
||||
size_t baseDirectoryLen)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->baseDirectory.emplace(nix::Path{std::string(baseDirectory, baseDirectoryLen)});
|
||||
return NIX_OK;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_flake_reference_and_fragment_from_string(
|
||||
nix_c_context * context,
|
||||
nix_fetchers_settings * fetchSettings,
|
||||
nix_flake_settings * flakeSettings,
|
||||
nix_flake_reference_parse_flags * parseFlags,
|
||||
const char * strData,
|
||||
size_t strSize,
|
||||
nix_flake_reference ** flakeReferenceOut,
|
||||
nix_get_string_callback fragmentCallback,
|
||||
void * fragmentCallbackUserData)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
*flakeReferenceOut = nullptr;
|
||||
try {
|
||||
std::string str(strData, 0, strSize);
|
||||
|
||||
auto [flakeRef, fragment] =
|
||||
nix::parseFlakeRefWithFragment(*fetchSettings->settings, str, parseFlags->baseDirectory, true);
|
||||
*flakeReferenceOut = new nix_flake_reference{nix::make_ref<nix::FlakeRef>(flakeRef)};
|
||||
return call_nix_get_string_callback(fragment, fragmentCallback, fragmentCallbackUserData);
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
void nix_flake_reference_free(nix_flake_reference * flakeReference)
|
||||
{
|
||||
delete flakeReference;
|
||||
}
|
||||
|
||||
nix_flake_lock_flags * nix_flake_lock_flags_new(nix_c_context * context, nix_flake_settings * settings)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
auto lockSettings = nix::make_ref<nix::flake::LockFlags>(nix::flake::LockFlags{
|
||||
.recreateLockFile = false,
|
||||
.updateLockFile = true, // == `nix_flake_lock_flags_set_mode_write_as_needed`
|
||||
.writeLockFile = true, // == `nix_flake_lock_flags_set_mode_write_as_needed`
|
||||
.failOnUnlocked = false, // == `nix_flake_lock_flags_set_mode_write_as_needed`
|
||||
.useRegistries = false,
|
||||
.allowUnlocked = false, // == `nix_flake_lock_flags_set_mode_write_as_needed`
|
||||
.commitLockFile = false,
|
||||
|
||||
});
|
||||
return new nix_flake_lock_flags{lockSettings};
|
||||
}
|
||||
NIXC_CATCH_ERRS_NULL
|
||||
}
|
||||
|
||||
void nix_flake_lock_flags_free(nix_flake_lock_flags * flags)
|
||||
{
|
||||
delete flags;
|
||||
}
|
||||
|
||||
nix_err nix_flake_lock_flags_set_mode_virtual(nix_c_context * context, nix_flake_lock_flags * flags)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->lockFlags->updateLockFile = true;
|
||||
flags->lockFlags->writeLockFile = false;
|
||||
flags->lockFlags->failOnUnlocked = false;
|
||||
flags->lockFlags->allowUnlocked = true;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_flake_lock_flags_set_mode_write_as_needed(nix_c_context * context, nix_flake_lock_flags * flags)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->lockFlags->updateLockFile = true;
|
||||
flags->lockFlags->writeLockFile = true;
|
||||
flags->lockFlags->failOnUnlocked = false;
|
||||
flags->lockFlags->allowUnlocked = true;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_flake_lock_flags_set_mode_check(nix_c_context * context, nix_flake_lock_flags * flags)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->lockFlags->updateLockFile = false;
|
||||
flags->lockFlags->writeLockFile = false;
|
||||
flags->lockFlags->failOnUnlocked = true;
|
||||
flags->lockFlags->allowUnlocked = false;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_flake_lock_flags_add_input_override(
|
||||
nix_c_context * context, nix_flake_lock_flags * flags, const char * inputPath, nix_flake_reference * flakeRef)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
auto path = nix::flake::parseInputAttrPath(inputPath);
|
||||
flags->lockFlags->inputOverrides.emplace(path, *flakeRef->flakeRef);
|
||||
if (flags->lockFlags->writeLockFile) {
|
||||
return nix_flake_lock_flags_set_mode_virtual(context, flags);
|
||||
}
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_locked_flake * nix_flake_lock(
|
||||
nix_c_context * context,
|
||||
nix_fetchers_settings * fetchSettings,
|
||||
nix_flake_settings * flakeSettings,
|
||||
EvalState * eval_state,
|
||||
nix_flake_lock_flags * flags,
|
||||
nix_flake_reference * flakeReference)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
eval_state->state.resetFileCache();
|
||||
auto lockedFlake = nix::make_ref<nix::flake::LockedFlake>(nix::flake::lockFlake(
|
||||
*flakeSettings->settings, eval_state->state, *flakeReference->flakeRef, *flags->lockFlags));
|
||||
return new nix_locked_flake{lockedFlake};
|
||||
}
|
||||
NIXC_CATCH_ERRS_NULL
|
||||
}
|
||||
|
||||
void nix_locked_flake_free(nix_locked_flake * lockedFlake)
|
||||
{
|
||||
delete lockedFlake;
|
||||
}
|
||||
|
||||
nix_value * nix_locked_flake_get_output_attrs(
|
||||
nix_c_context * context, nix_flake_settings * settings, EvalState * evalState, nix_locked_flake * lockedFlake)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
auto v = nix_alloc_value(context, evalState);
|
||||
nix::flake::callFlake(evalState->state, *lockedFlake->lockedFlake, v->value);
|
||||
return v;
|
||||
}
|
||||
NIXC_CATCH_ERRS_NULL
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
* @brief Main entry for the libflake C bindings
|
||||
*/
|
||||
|
||||
#include "nix_api_fetchers.h"
|
||||
#include "nix_api_store.h"
|
||||
#include "nix_api_util.h"
|
||||
#include "nix_api_expr.h"
|
||||
@@ -18,8 +19,46 @@ extern "C" {
|
||||
#endif
|
||||
// cffi start
|
||||
|
||||
/**
|
||||
* @brief A settings object for configuring the behavior of the nix-flake-c library.
|
||||
* @see nix_flake_settings_new
|
||||
* @see nix_flake_settings_free
|
||||
*/
|
||||
typedef struct nix_flake_settings nix_flake_settings;
|
||||
|
||||
/**
|
||||
* @brief Context and paramaters for parsing a flake reference
|
||||
* @see nix_flake_reference_parse_flags_free
|
||||
* @see nix_flake_reference_parse_string
|
||||
*/
|
||||
typedef struct nix_flake_reference_parse_flags nix_flake_reference_parse_flags;
|
||||
|
||||
/**
|
||||
* @brief A reference to a flake
|
||||
*
|
||||
* A flake reference specifies how to fetch a flake.
|
||||
*
|
||||
* @see nix_flake_reference_from_string
|
||||
* @see nix_flake_reference_free
|
||||
*/
|
||||
typedef struct nix_flake_reference nix_flake_reference;
|
||||
|
||||
/**
|
||||
* @brief Parameters for locking a flake
|
||||
* @see nix_flake_lock_flags_new
|
||||
* @see nix_flake_lock_flags_free
|
||||
* @see nix_flake_lock
|
||||
*/
|
||||
typedef struct nix_flake_lock_flags nix_flake_lock_flags;
|
||||
|
||||
/**
|
||||
* @brief A flake with a suitable lock (file or otherwise)
|
||||
* @see nix_flake_lock
|
||||
* @see nix_locked_flake_free
|
||||
* @see nix_locked_flake_get_output_attrs
|
||||
*/
|
||||
typedef struct nix_locked_flake nix_locked_flake;
|
||||
|
||||
// Function prototypes
|
||||
/**
|
||||
* Create a nix_flake_settings initialized with default values.
|
||||
@@ -38,6 +77,8 @@ void nix_flake_settings_free(nix_flake_settings * settings);
|
||||
* @brief Initialize a `nix_flake_settings` to contain `builtins.getFlake` and
|
||||
* potentially more.
|
||||
*
|
||||
* @warning This does not put the eval state in pure mode!
|
||||
*
|
||||
* @param[out] context Optional, stores error information
|
||||
* @param[in] settings The settings to use for e.g. `builtins.getFlake`
|
||||
* @param[in] builder The builder to modify
|
||||
@@ -45,6 +86,158 @@ void nix_flake_settings_free(nix_flake_settings * settings);
|
||||
nix_err nix_flake_settings_add_to_eval_state_builder(
|
||||
nix_c_context * context, nix_flake_settings * settings, nix_eval_state_builder * builder);
|
||||
|
||||
/**
|
||||
* @brief A new `nix_flake_reference_parse_flags` with defaults
|
||||
*/
|
||||
nix_flake_reference_parse_flags *
|
||||
nix_flake_reference_parse_flags_new(nix_c_context * context, nix_flake_settings * settings);
|
||||
|
||||
/**
|
||||
* @brief Deallocate and release the resources associated with a `nix_flake_reference_parse_flags`.
|
||||
* Does not fail.
|
||||
* @param[in] flags the `nix_flake_reference_parse_flags *` to free
|
||||
*/
|
||||
void nix_flake_reference_parse_flags_free(nix_flake_reference_parse_flags * flags);
|
||||
|
||||
/**
|
||||
* @brief Provide a base directory for parsing relative flake references
|
||||
* @param[out] context Optional, stores error information
|
||||
* @param[in] flags The flags to modify
|
||||
* @param[in] baseDirectory The base directory to add
|
||||
* @param[in] baseDirectoryLen The length of baseDirectory
|
||||
* @return NIX_OK on success, NIX_ERR on failure
|
||||
*/
|
||||
nix_err nix_flake_reference_parse_flags_set_base_directory(
|
||||
nix_c_context * context,
|
||||
nix_flake_reference_parse_flags * flags,
|
||||
const char * baseDirectory,
|
||||
size_t baseDirectoryLen);
|
||||
|
||||
/**
|
||||
* @brief A new `nix_flake_lock_flags` with defaults
|
||||
* @param[in] settings Flake settings that may affect the defaults
|
||||
*/
|
||||
nix_flake_lock_flags * nix_flake_lock_flags_new(nix_c_context * context, nix_flake_settings * settings);
|
||||
|
||||
/**
|
||||
* @brief Deallocate and release the resources associated with a `nix_flake_lock_flags`.
|
||||
* Does not fail.
|
||||
* @param[in] settings the `nix_flake_lock_flags *` to free
|
||||
*/
|
||||
void nix_flake_lock_flags_free(nix_flake_lock_flags * settings);
|
||||
|
||||
/**
|
||||
* @brief Put the lock flags in a mode that checks whether the lock is up to date.
|
||||
* @param[out] context Optional, stores error information
|
||||
* @param[in] flags The flags to modify
|
||||
* @return NIX_OK on success, NIX_ERR on failure
|
||||
*
|
||||
* This causes `nix_flake_lock` to fail if the lock needs to be updated.
|
||||
*/
|
||||
nix_err nix_flake_lock_flags_set_mode_check(nix_c_context * context, nix_flake_lock_flags * flags);
|
||||
|
||||
/**
|
||||
* @brief Put the lock flags in a mode that updates the lock file in memory, if needed.
|
||||
* @param[out] context Optional, stores error information
|
||||
* @param[in] flags The flags to modify
|
||||
* @param[in] update Whether to allow updates
|
||||
*
|
||||
* This will cause `nix_flake_lock` to update the lock file in memory, if needed.
|
||||
*/
|
||||
nix_err nix_flake_lock_flags_set_mode_virtual(nix_c_context * context, nix_flake_lock_flags * flags);
|
||||
|
||||
/**
|
||||
* @brief Put the lock flags in a mode that updates the lock file on disk, if needed.
|
||||
* @param[out] context Optional, stores error information
|
||||
* @param[in] flags The flags to modify
|
||||
* @param[in] update Whether to allow updates
|
||||
*
|
||||
* This will cause `nix_flake_lock` to update the lock file on disk, if needed.
|
||||
*/
|
||||
nix_err nix_flake_lock_flags_set_mode_write_as_needed(nix_c_context * context, nix_flake_lock_flags * flags);
|
||||
|
||||
/**
|
||||
* @brief Add input overrides to the lock flags
|
||||
* @param[out] context Optional, stores error information
|
||||
* @param[in] flags The flags to modify
|
||||
* @param[in] inputPath The input path to override
|
||||
* @param[in] flakeRef The flake reference to use as the override
|
||||
*
|
||||
* This switches the `flags` to `nix_flake_lock_flags_set_mode_virtual` if not in mode
|
||||
* `nix_flake_lock_flags_set_mode_check`.
|
||||
*/
|
||||
nix_err nix_flake_lock_flags_add_input_override(
|
||||
nix_c_context * context, nix_flake_lock_flags * flags, const char * inputPath, nix_flake_reference * flakeRef);
|
||||
|
||||
/**
|
||||
* @brief Lock a flake, if not already locked.
|
||||
* @param[out] context Optional, stores error information
|
||||
* @param[in] settings The flake (and fetch) settings to use
|
||||
* @param[in] flags The locking flags to use
|
||||
* @param[in] flake The flake to lock
|
||||
*/
|
||||
nix_locked_flake * nix_flake_lock(
|
||||
nix_c_context * context,
|
||||
nix_fetchers_settings * fetchSettings,
|
||||
nix_flake_settings * settings,
|
||||
EvalState * eval_state,
|
||||
nix_flake_lock_flags * flags,
|
||||
nix_flake_reference * flake);
|
||||
|
||||
/**
|
||||
* @brief Deallocate and release the resources associated with a `nix_locked_flake`.
|
||||
* Does not fail.
|
||||
* @param[in] locked_flake the `nix_locked_flake *` to free
|
||||
*/
|
||||
void nix_locked_flake_free(nix_locked_flake * locked_flake);
|
||||
|
||||
/**
|
||||
* @brief Parse a URL-like string into a `nix_flake_reference`.
|
||||
*
|
||||
* @param[out] context **context** – Optional, stores error information
|
||||
* @param[in] fetchSettings **context** – The fetch settings to use
|
||||
* @param[in] flakeSettings **context** – The flake settings to use
|
||||
* @param[in] parseFlags **context** – Specific context and parameters such as base directory
|
||||
*
|
||||
* @param[in] str **input** – The URI-like string to parse
|
||||
* @param[in] strLen **input** – The length of `str`
|
||||
*
|
||||
* @param[out] flakeReferenceOut **result** – The resulting flake reference
|
||||
* @param[in] fragmentCallback **result** – A callback to call with the fragment part of the URL
|
||||
* @param[in] fragmentCallbackUserData **result** – User data to pass to the fragment callback
|
||||
*
|
||||
* @return NIX_OK on success, NIX_ERR on failure
|
||||
*/
|
||||
nix_err nix_flake_reference_and_fragment_from_string(
|
||||
nix_c_context * context,
|
||||
nix_fetchers_settings * fetchSettings,
|
||||
nix_flake_settings * flakeSettings,
|
||||
nix_flake_reference_parse_flags * parseFlags,
|
||||
const char * str,
|
||||
size_t strLen,
|
||||
nix_flake_reference ** flakeReferenceOut,
|
||||
nix_get_string_callback fragmentCallback,
|
||||
void * fragmentCallbackUserData);
|
||||
|
||||
/**
|
||||
* @brief Deallocate and release the resources associated with a `nix_flake_reference`.
|
||||
*
|
||||
* Does not fail.
|
||||
*
|
||||
* @param[in] store the `nix_flake_reference *` to free
|
||||
*/
|
||||
void nix_flake_reference_free(nix_flake_reference * store);
|
||||
|
||||
/**
|
||||
* @brief Get the output attributes of a flake.
|
||||
* @param[out] context Optional, stores error information
|
||||
* @param[in] settings The settings to use
|
||||
* @param[in] locked_flake the flake to get the output attributes from
|
||||
* @return A new nix_value or NULL on failure. Release the `nix_value` with `nix_value_decref`.
|
||||
*/
|
||||
nix_value * nix_locked_flake_get_output_attrs(
|
||||
nix_c_context * context, nix_flake_settings * settings, EvalState * evalState, nix_locked_flake * lockedFlake);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,32 @@
|
||||
#pragma once
|
||||
#include <optional>
|
||||
|
||||
#include "nix/util/ref.hh"
|
||||
#include "nix/flake/flake.hh"
|
||||
#include "nix/flake/flakeref.hh"
|
||||
#include "nix/flake/settings.hh"
|
||||
|
||||
struct nix_flake_settings
|
||||
{
|
||||
nix::ref<nix::flake::Settings> settings;
|
||||
};
|
||||
|
||||
struct nix_flake_reference_parse_flags
|
||||
{
|
||||
std::optional<nix::Path> baseDirectory;
|
||||
};
|
||||
|
||||
struct nix_flake_reference
|
||||
{
|
||||
nix::ref<nix::FlakeRef> flakeRef;
|
||||
};
|
||||
|
||||
struct nix_flake_lock_flags
|
||||
{
|
||||
nix::ref<nix::flake::LockFlags> lockFlags;
|
||||
};
|
||||
|
||||
struct nix_locked_flake
|
||||
{
|
||||
nix::ref<nix::flake::LockedFlake> lockedFlake;
|
||||
};
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
nix-store-c,
|
||||
nix-expr-c,
|
||||
nix-fetchers-c,
|
||||
nix-flake,
|
||||
|
||||
# Configuration Options
|
||||
@@ -35,6 +36,7 @@ mkMesonLibrary (finalAttrs: {
|
||||
propagatedBuildInputs = [
|
||||
nix-expr-c
|
||||
nix-store-c
|
||||
nix-fetchers-c
|
||||
nix-flake
|
||||
];
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "nix/util/file-system.hh"
|
||||
#include "nix_api_store.h"
|
||||
#include "nix_api_store_internal.h"
|
||||
#include "nix_api_util.h"
|
||||
#include "nix_api_util_internal.h"
|
||||
#include "nix_api_expr.h"
|
||||
#include "nix_api_value.h"
|
||||
#include "nix_api_flake.h"
|
||||
@@ -14,7 +13,7 @@
|
||||
|
||||
namespace nixC {
|
||||
|
||||
TEST_F(nix_api_store_test, nix_api_init_global_getFlake_exists)
|
||||
TEST_F(nix_api_store_test, nix_api_init_getFlake_exists)
|
||||
{
|
||||
nix_libstore_init(ctx);
|
||||
assert_ctx_ok();
|
||||
@@ -43,9 +42,342 @@ TEST_F(nix_api_store_test, nix_api_init_global_getFlake_exists)
|
||||
ASSERT_NE(nullptr, value);
|
||||
|
||||
nix_err err = nix_expr_eval_from_string(ctx, state, "builtins.getFlake", ".", value);
|
||||
|
||||
nix_state_free(state);
|
||||
|
||||
assert_ctx_ok();
|
||||
ASSERT_EQ(NIX_OK, err);
|
||||
ASSERT_EQ(NIX_TYPE_FUNCTION, nix_get_type(ctx, value));
|
||||
}
|
||||
|
||||
TEST_F(nix_api_store_test, nix_api_flake_reference_not_absolute_no_basedir_fail)
|
||||
{
|
||||
nix_libstore_init(ctx);
|
||||
assert_ctx_ok();
|
||||
nix_libexpr_init(ctx);
|
||||
assert_ctx_ok();
|
||||
|
||||
auto settings = nix_flake_settings_new(ctx);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, settings);
|
||||
|
||||
auto fetchSettings = nix_fetchers_settings_new(ctx);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, fetchSettings);
|
||||
|
||||
auto parseFlags = nix_flake_reference_parse_flags_new(ctx, settings);
|
||||
|
||||
std::string str(".#legacyPackages.aarch127-unknown...orion");
|
||||
std::string fragment;
|
||||
nix_flake_reference * flakeReference = nullptr;
|
||||
auto r = nix_flake_reference_and_fragment_from_string(
|
||||
ctx, fetchSettings, settings, parseFlags, str.data(), str.size(), &flakeReference, OBSERVE_STRING(fragment));
|
||||
|
||||
ASSERT_NE(NIX_OK, r);
|
||||
ASSERT_EQ(nullptr, flakeReference);
|
||||
|
||||
nix_flake_reference_parse_flags_free(parseFlags);
|
||||
}
|
||||
|
||||
TEST_F(nix_api_store_test, nix_api_load_flake)
|
||||
{
|
||||
auto tmpDir = nix::createTempDir();
|
||||
nix::AutoDelete delTmpDir(tmpDir, true);
|
||||
|
||||
nix::writeFile(tmpDir + "/flake.nix", R"(
|
||||
{
|
||||
outputs = { ... }: {
|
||||
hello = "potato";
|
||||
};
|
||||
}
|
||||
)");
|
||||
|
||||
nix_libstore_init(ctx);
|
||||
assert_ctx_ok();
|
||||
nix_libexpr_init(ctx);
|
||||
assert_ctx_ok();
|
||||
|
||||
auto fetchSettings = nix_fetchers_settings_new(ctx);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, fetchSettings);
|
||||
|
||||
auto settings = nix_flake_settings_new(ctx);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, settings);
|
||||
|
||||
nix_eval_state_builder * builder = nix_eval_state_builder_new(ctx, store);
|
||||
ASSERT_NE(nullptr, builder);
|
||||
assert_ctx_ok();
|
||||
|
||||
auto state = nix_eval_state_build(ctx, builder);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, state);
|
||||
|
||||
nix_eval_state_builder_free(builder);
|
||||
|
||||
auto parseFlags = nix_flake_reference_parse_flags_new(ctx, settings);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, parseFlags);
|
||||
|
||||
auto r0 = nix_flake_reference_parse_flags_set_base_directory(ctx, parseFlags, tmpDir.c_str(), tmpDir.size());
|
||||
assert_ctx_ok();
|
||||
ASSERT_EQ(NIX_OK, r0);
|
||||
|
||||
std::string fragment;
|
||||
const std::string ref = ".#legacyPackages.aarch127-unknown...orion";
|
||||
nix_flake_reference * flakeReference = nullptr;
|
||||
auto r = nix_flake_reference_and_fragment_from_string(
|
||||
ctx, fetchSettings, settings, parseFlags, ref.data(), ref.size(), &flakeReference, OBSERVE_STRING(fragment));
|
||||
assert_ctx_ok();
|
||||
ASSERT_EQ(NIX_OK, r);
|
||||
ASSERT_NE(nullptr, flakeReference);
|
||||
ASSERT_EQ(fragment, "legacyPackages.aarch127-unknown...orion");
|
||||
|
||||
nix_flake_reference_parse_flags_free(parseFlags);
|
||||
|
||||
auto lockFlags = nix_flake_lock_flags_new(ctx, settings);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, lockFlags);
|
||||
|
||||
auto lockedFlake = nix_flake_lock(ctx, fetchSettings, settings, state, lockFlags, flakeReference);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, lockedFlake);
|
||||
|
||||
nix_flake_lock_flags_free(lockFlags);
|
||||
|
||||
auto value = nix_locked_flake_get_output_attrs(ctx, settings, state, lockedFlake);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, value);
|
||||
|
||||
auto helloAttr = nix_get_attr_byname(ctx, value, state, "hello");
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, helloAttr);
|
||||
|
||||
std::string helloStr;
|
||||
nix_get_string(ctx, helloAttr, OBSERVE_STRING(helloStr));
|
||||
assert_ctx_ok();
|
||||
ASSERT_EQ("potato", helloStr);
|
||||
|
||||
nix_value_decref(ctx, value);
|
||||
nix_locked_flake_free(lockedFlake);
|
||||
nix_flake_reference_free(flakeReference);
|
||||
nix_state_free(state);
|
||||
nix_flake_settings_free(settings);
|
||||
}
|
||||
|
||||
TEST_F(nix_api_store_test, nix_api_load_flake_with_flags)
|
||||
{
|
||||
nix_libstore_init(ctx);
|
||||
assert_ctx_ok();
|
||||
nix_libexpr_init(ctx);
|
||||
assert_ctx_ok();
|
||||
|
||||
auto tmpDir = nix::createTempDir();
|
||||
nix::AutoDelete delTmpDir(tmpDir, true);
|
||||
|
||||
nix::createDirs(tmpDir + "/b");
|
||||
nix::writeFile(tmpDir + "/b/flake.nix", R"(
|
||||
{
|
||||
outputs = { ... }: {
|
||||
hello = "BOB";
|
||||
};
|
||||
}
|
||||
)");
|
||||
|
||||
nix::createDirs(tmpDir + "/a");
|
||||
nix::writeFile(tmpDir + "/a/flake.nix", R"(
|
||||
{
|
||||
inputs.b.url = ")" + tmpDir + R"(/b";
|
||||
outputs = { b, ... }: {
|
||||
hello = b.hello;
|
||||
};
|
||||
}
|
||||
)");
|
||||
|
||||
nix::createDirs(tmpDir + "/c");
|
||||
nix::writeFile(tmpDir + "/c/flake.nix", R"(
|
||||
{
|
||||
outputs = { ... }: {
|
||||
hello = "Claire";
|
||||
};
|
||||
}
|
||||
)");
|
||||
|
||||
nix_libstore_init(ctx);
|
||||
assert_ctx_ok();
|
||||
|
||||
auto fetchSettings = nix_fetchers_settings_new(ctx);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, fetchSettings);
|
||||
|
||||
auto settings = nix_flake_settings_new(ctx);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, settings);
|
||||
|
||||
nix_eval_state_builder * builder = nix_eval_state_builder_new(ctx, store);
|
||||
ASSERT_NE(nullptr, builder);
|
||||
assert_ctx_ok();
|
||||
|
||||
auto state = nix_eval_state_build(ctx, builder);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, state);
|
||||
|
||||
nix_eval_state_builder_free(builder);
|
||||
|
||||
auto parseFlags = nix_flake_reference_parse_flags_new(ctx, settings);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, parseFlags);
|
||||
|
||||
auto r0 = nix_flake_reference_parse_flags_set_base_directory(ctx, parseFlags, tmpDir.c_str(), tmpDir.size());
|
||||
assert_ctx_ok();
|
||||
ASSERT_EQ(NIX_OK, r0);
|
||||
|
||||
std::string fragment;
|
||||
const std::string ref = "./a";
|
||||
nix_flake_reference * flakeReference = nullptr;
|
||||
auto r = nix_flake_reference_and_fragment_from_string(
|
||||
ctx, fetchSettings, settings, parseFlags, ref.data(), ref.size(), &flakeReference, OBSERVE_STRING(fragment));
|
||||
assert_ctx_ok();
|
||||
ASSERT_EQ(NIX_OK, r);
|
||||
ASSERT_NE(nullptr, flakeReference);
|
||||
ASSERT_EQ(fragment, "");
|
||||
|
||||
// Step 1: Do not update, fails
|
||||
|
||||
auto lockFlags = nix_flake_lock_flags_new(ctx, settings);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, lockFlags);
|
||||
|
||||
nix_flake_lock_flags_set_mode_check(ctx, lockFlags);
|
||||
assert_ctx_ok();
|
||||
|
||||
// Step 2: Update but do not write, succeeds
|
||||
|
||||
auto lockedFlake = nix_flake_lock(ctx, fetchSettings, settings, state, lockFlags, flakeReference);
|
||||
assert_ctx_err();
|
||||
ASSERT_EQ(nullptr, lockedFlake);
|
||||
|
||||
nix_flake_lock_flags_set_mode_virtual(ctx, lockFlags);
|
||||
assert_ctx_ok();
|
||||
|
||||
lockedFlake = nix_flake_lock(ctx, fetchSettings, settings, state, lockFlags, flakeReference);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, lockedFlake);
|
||||
|
||||
// Get the output attrs
|
||||
auto value = nix_locked_flake_get_output_attrs(ctx, settings, state, lockedFlake);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, value);
|
||||
|
||||
auto helloAttr = nix_get_attr_byname(ctx, value, state, "hello");
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, helloAttr);
|
||||
|
||||
std::string helloStr;
|
||||
nix_get_string(ctx, helloAttr, OBSERVE_STRING(helloStr));
|
||||
assert_ctx_ok();
|
||||
ASSERT_EQ("BOB", helloStr);
|
||||
|
||||
nix_value_decref(ctx, value);
|
||||
nix_locked_flake_free(lockedFlake);
|
||||
|
||||
// Step 3: Lock was not written, so Step 1 would fail again
|
||||
|
||||
nix_flake_lock_flags_set_mode_check(ctx, lockFlags);
|
||||
|
||||
lockedFlake = nix_flake_lock(ctx, fetchSettings, settings, state, lockFlags, flakeReference);
|
||||
assert_ctx_err();
|
||||
ASSERT_EQ(nullptr, lockedFlake);
|
||||
|
||||
// Step 4: Update and write, succeeds
|
||||
|
||||
nix_flake_lock_flags_set_mode_write_as_needed(ctx, lockFlags);
|
||||
assert_ctx_ok();
|
||||
|
||||
lockedFlake = nix_flake_lock(ctx, fetchSettings, settings, state, lockFlags, flakeReference);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, lockedFlake);
|
||||
|
||||
// Get the output attrs
|
||||
value = nix_locked_flake_get_output_attrs(ctx, settings, state, lockedFlake);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, value);
|
||||
|
||||
helloAttr = nix_get_attr_byname(ctx, value, state, "hello");
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, helloAttr);
|
||||
|
||||
helloStr.clear();
|
||||
nix_get_string(ctx, helloAttr, OBSERVE_STRING(helloStr));
|
||||
assert_ctx_ok();
|
||||
ASSERT_EQ("BOB", helloStr);
|
||||
|
||||
nix_value_decref(ctx, value);
|
||||
nix_locked_flake_free(lockedFlake);
|
||||
|
||||
// Step 5: Lock was written, so Step 1 would succeed
|
||||
|
||||
nix_flake_lock_flags_set_mode_check(ctx, lockFlags);
|
||||
assert_ctx_ok();
|
||||
|
||||
lockedFlake = nix_flake_lock(ctx, fetchSettings, settings, state, lockFlags, flakeReference);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, lockedFlake);
|
||||
|
||||
// Get the output attrs
|
||||
value = nix_locked_flake_get_output_attrs(ctx, settings, state, lockedFlake);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, value);
|
||||
|
||||
helloAttr = nix_get_attr_byname(ctx, value, state, "hello");
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, helloAttr);
|
||||
|
||||
helloStr.clear();
|
||||
nix_get_string(ctx, helloAttr, OBSERVE_STRING(helloStr));
|
||||
assert_ctx_ok();
|
||||
ASSERT_EQ("BOB", helloStr);
|
||||
|
||||
nix_value_decref(ctx, value);
|
||||
nix_locked_flake_free(lockedFlake);
|
||||
|
||||
// Step 6: Lock with override, do not write
|
||||
|
||||
nix_flake_lock_flags_set_mode_write_as_needed(ctx, lockFlags);
|
||||
assert_ctx_ok();
|
||||
|
||||
nix_flake_reference * overrideFlakeReference = nullptr;
|
||||
nix_flake_reference_and_fragment_from_string(
|
||||
ctx, fetchSettings, settings, parseFlags, "./c", 3, &overrideFlakeReference, OBSERVE_STRING(fragment));
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, overrideFlakeReference);
|
||||
|
||||
nix_flake_lock_flags_add_input_override(ctx, lockFlags, "b", overrideFlakeReference);
|
||||
assert_ctx_ok();
|
||||
|
||||
lockedFlake = nix_flake_lock(ctx, fetchSettings, settings, state, lockFlags, flakeReference);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, lockedFlake);
|
||||
|
||||
// Get the output attrs
|
||||
value = nix_locked_flake_get_output_attrs(ctx, settings, state, lockedFlake);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, value);
|
||||
|
||||
helloAttr = nix_get_attr_byname(ctx, value, state, "hello");
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, helloAttr);
|
||||
|
||||
helloStr.clear();
|
||||
nix_get_string(ctx, helloAttr, OBSERVE_STRING(helloStr));
|
||||
assert_ctx_ok();
|
||||
ASSERT_EQ("Claire", helloStr);
|
||||
|
||||
nix_flake_reference_parse_flags_free(parseFlags);
|
||||
nix_flake_lock_flags_free(lockFlags);
|
||||
nix_flake_reference_free(flakeReference);
|
||||
nix_state_free(state);
|
||||
nix_flake_settings_free(settings);
|
||||
}
|
||||
|
||||
} // namespace nixC
|
||||
File renamed without changes.
File renamed without changes.
@@ -14,6 +14,7 @@
|
||||
#include "nix/store/local-fs-store.hh"
|
||||
#include "nix/fetchers/fetch-to-store.hh"
|
||||
#include "nix/util/memory-source-accessor.hh"
|
||||
#include "nix/fetchers/input-cache.hh"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
@@ -23,66 +24,6 @@ using namespace flake;
|
||||
|
||||
namespace flake {
|
||||
|
||||
struct FetchedFlake
|
||||
{
|
||||
FlakeRef lockedRef;
|
||||
ref<SourceAccessor> accessor;
|
||||
};
|
||||
|
||||
typedef std::map<FlakeRef, FetchedFlake> FlakeCache;
|
||||
|
||||
static std::optional<FetchedFlake> lookupInFlakeCache(
|
||||
const FlakeCache & flakeCache,
|
||||
const FlakeRef & flakeRef)
|
||||
{
|
||||
auto i = flakeCache.find(flakeRef);
|
||||
if (i == flakeCache.end()) return std::nullopt;
|
||||
debug("mapping '%s' to previously seen input '%s' -> '%s",
|
||||
flakeRef, i->first, i->second.lockedRef);
|
||||
return i->second;
|
||||
}
|
||||
|
||||
static std::tuple<ref<SourceAccessor>, FlakeRef, FlakeRef> fetchOrSubstituteTree(
|
||||
EvalState & state,
|
||||
const FlakeRef & originalRef,
|
||||
bool useRegistries,
|
||||
FlakeCache & flakeCache)
|
||||
{
|
||||
auto fetched = lookupInFlakeCache(flakeCache, originalRef);
|
||||
FlakeRef resolvedRef = originalRef;
|
||||
|
||||
if (!fetched) {
|
||||
if (originalRef.input.isDirect()) {
|
||||
auto [accessor, lockedRef] = originalRef.lazyFetch(state.store);
|
||||
fetched.emplace(FetchedFlake{.lockedRef = lockedRef, .accessor = accessor});
|
||||
} else {
|
||||
if (useRegistries) {
|
||||
resolvedRef = originalRef.resolve(
|
||||
state.store,
|
||||
[](fetchers::Registry::RegistryType type) {
|
||||
/* Only use the global registry and CLI flags
|
||||
to resolve indirect flakerefs. */
|
||||
return type == fetchers::Registry::Flag || type == fetchers::Registry::Global;
|
||||
});
|
||||
fetched = lookupInFlakeCache(flakeCache, originalRef);
|
||||
if (!fetched) {
|
||||
auto [accessor, lockedRef] = resolvedRef.lazyFetch(state.store);
|
||||
fetched.emplace(FetchedFlake{.lockedRef = lockedRef, .accessor = accessor});
|
||||
}
|
||||
flakeCache.insert_or_assign(resolvedRef, *fetched);
|
||||
}
|
||||
else {
|
||||
throw Error("'%s' is an indirect flake reference, but registry lookups are not allowed", originalRef);
|
||||
}
|
||||
}
|
||||
flakeCache.insert_or_assign(originalRef, *fetched);
|
||||
}
|
||||
|
||||
debug("got tree '%s' from '%s'", fetched->accessor, fetched->lockedRef);
|
||||
|
||||
return {fetched->accessor, resolvedRef, fetched->lockedRef};
|
||||
}
|
||||
|
||||
static StorePath copyInputToStore(
|
||||
EvalState & state,
|
||||
fetchers::Input & input,
|
||||
@@ -397,15 +338,16 @@ static Flake getFlake(
|
||||
EvalState & state,
|
||||
const FlakeRef & originalRef,
|
||||
bool useRegistries,
|
||||
FlakeCache & flakeCache,
|
||||
const InputAttrPath & lockRootAttrPath)
|
||||
{
|
||||
// Fetch a lazy tree first.
|
||||
auto [accessor, resolvedRef, lockedRef] = fetchOrSubstituteTree(
|
||||
state, originalRef, useRegistries, flakeCache);
|
||||
auto cachedInput = state.inputCache->getAccessor(state.store, originalRef.input, useRegistries);
|
||||
|
||||
auto resolvedRef = FlakeRef(std::move(cachedInput.resolvedInput), originalRef.subdir);
|
||||
auto lockedRef = FlakeRef(std::move(cachedInput.lockedInput), originalRef.subdir);
|
||||
|
||||
// Parse/eval flake.nix to get at the input.self attributes.
|
||||
auto flake = readFlake(state, originalRef, resolvedRef, lockedRef, {accessor}, lockRootAttrPath);
|
||||
auto flake = readFlake(state, originalRef, resolvedRef, lockedRef, {cachedInput.accessor}, lockRootAttrPath);
|
||||
|
||||
// Re-fetch the tree if necessary.
|
||||
auto newLockedRef = applySelfAttrs(lockedRef, flake);
|
||||
@@ -414,14 +356,13 @@ static Flake getFlake(
|
||||
debug("refetching input '%s' due to self attribute", newLockedRef);
|
||||
// FIXME: need to remove attrs that are invalidated by the changed input attrs, such as 'narHash'.
|
||||
newLockedRef.input.attrs.erase("narHash");
|
||||
auto [accessor2, resolvedRef2, lockedRef2] = fetchOrSubstituteTree(
|
||||
state, newLockedRef, false, flakeCache);
|
||||
accessor = accessor2;
|
||||
lockedRef = lockedRef2;
|
||||
auto cachedInput2 = state.inputCache->getAccessor(state.store, newLockedRef.input, useRegistries);
|
||||
cachedInput.accessor = cachedInput2.accessor;
|
||||
lockedRef = FlakeRef(std::move(cachedInput2.lockedInput), newLockedRef.subdir);
|
||||
}
|
||||
|
||||
// Copy the tree to the store.
|
||||
auto storePath = copyInputToStore(state, lockedRef.input, originalRef.input, accessor);
|
||||
auto storePath = copyInputToStore(state, lockedRef.input, originalRef.input, cachedInput.accessor);
|
||||
|
||||
// Re-parse flake.nix from the store.
|
||||
return readFlake(state, originalRef, resolvedRef, lockedRef, state.storePath(storePath), lockRootAttrPath);
|
||||
@@ -429,8 +370,7 @@ static Flake getFlake(
|
||||
|
||||
Flake getFlake(EvalState & state, const FlakeRef & originalRef, bool useRegistries)
|
||||
{
|
||||
FlakeCache flakeCache;
|
||||
return getFlake(state, originalRef, useRegistries, flakeCache, {});
|
||||
return getFlake(state, originalRef, useRegistries, {});
|
||||
}
|
||||
|
||||
static LockFile readLockFile(
|
||||
@@ -452,11 +392,9 @@ LockedFlake lockFlake(
|
||||
{
|
||||
experimentalFeatureSettings.require(Xp::Flakes);
|
||||
|
||||
FlakeCache flakeCache;
|
||||
|
||||
auto useRegistries = lockFlags.useRegistries.value_or(settings.useRegistries);
|
||||
|
||||
auto flake = getFlake(state, topRef, useRegistries, flakeCache, {});
|
||||
auto flake = getFlake(state, topRef, useRegistries, {});
|
||||
|
||||
if (lockFlags.applyNixConfig) {
|
||||
flake.config.apply(settings);
|
||||
@@ -631,7 +569,7 @@ LockedFlake lockFlake(
|
||||
if (auto resolvedPath = resolveRelativePath()) {
|
||||
return readFlake(state, ref, ref, ref, *resolvedPath, inputAttrPath);
|
||||
} else {
|
||||
return getFlake(state, ref, useRegistries, flakeCache, inputAttrPath);
|
||||
return getFlake(state, ref, useRegistries, inputAttrPath);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -779,11 +717,12 @@ LockedFlake lockFlake(
|
||||
if (auto resolvedPath = resolveRelativePath()) {
|
||||
return {*resolvedPath, *input.ref};
|
||||
} else {
|
||||
auto [accessor, resolvedRef, lockedRef] = fetchOrSubstituteTree(
|
||||
state, *input.ref, useRegistries, flakeCache);
|
||||
auto cachedInput = state.inputCache->getAccessor(state.store, input.ref->input, useRegistries);
|
||||
|
||||
auto lockedRef = FlakeRef(std::move(cachedInput.lockedInput), input.ref->subdir);
|
||||
|
||||
// FIXME: allow input to be lazy.
|
||||
auto storePath = copyInputToStore(state, lockedRef.input, input.ref->input, accessor);
|
||||
auto storePath = copyInputToStore(state, lockedRef.input, input.ref->input, cachedInput.accessor);
|
||||
|
||||
return {state.storePath(storePath), lockedRef};
|
||||
}
|
||||
@@ -864,11 +803,11 @@ LockedFlake lockFlake(
|
||||
auto s = chomp(diff);
|
||||
if (lockFileExists) {
|
||||
if (s.empty())
|
||||
warn("updating lock file '%s'", outputLockFilePath);
|
||||
warn("updating lock file %s", outputLockFilePath);
|
||||
else
|
||||
warn("updating lock file '%s':\n%s", outputLockFilePath, s);
|
||||
warn("updating lock file %s:\n%s", outputLockFilePath, s);
|
||||
} else
|
||||
warn("creating lock file '%s': \n%s", outputLockFilePath, s);
|
||||
warn("creating lock file %s: \n%s", outputLockFilePath, s);
|
||||
|
||||
std::optional<std::string> commitMessage = std::nullopt;
|
||||
|
||||
File renamed without changes.
@@ -63,7 +63,7 @@ struct ConfigFile
|
||||
};
|
||||
|
||||
/**
|
||||
* The contents of a flake.nix file.
|
||||
* A flake in context
|
||||
*/
|
||||
struct Flake
|
||||
{
|
||||
|
||||
File renamed without changes.
@@ -39,13 +39,13 @@ foreach header : [
|
||||
endforeach
|
||||
|
||||
sources = files(
|
||||
'flake/config.cc',
|
||||
'flake/flake.cc',
|
||||
'flake/flakeref.cc',
|
||||
'flake/lockfile.cc',
|
||||
'flake/flake-primops.cc',
|
||||
'flake/settings.cc',
|
||||
'flake/url-name.cc',
|
||||
'config.cc',
|
||||
'flake.cc',
|
||||
'flakeref.cc',
|
||||
'lockfile.cc',
|
||||
'flake-primops.cc',
|
||||
'settings.cc',
|
||||
'url-name.cc',
|
||||
)
|
||||
|
||||
subdir('include/nix/flake')
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,3 +1,5 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "nix/main/common-args.hh"
|
||||
#include "nix/util/args/root.hh"
|
||||
#include "nix/util/config-global.hh"
|
||||
@@ -93,5 +95,18 @@ void MixCommonArgs::initialFlagsProcessed()
|
||||
pluginsInited();
|
||||
}
|
||||
|
||||
|
||||
template <typename T, typename>
|
||||
void MixPrintJSON::printJSON(const T /* nlohmann::json */ & json)
|
||||
{
|
||||
auto suspension = logger->suspend();
|
||||
if (outputPretty) {
|
||||
logger->writeToStdout(json.dump(2));
|
||||
} else {
|
||||
logger->writeToStdout(json.dump());
|
||||
}
|
||||
}
|
||||
|
||||
template void MixPrintJSON::printJSON(const nlohmann::json & json);
|
||||
|
||||
|
||||
} // namespace nix
|
||||
@@ -29,13 +29,69 @@ struct MixDryRun : virtual Args
|
||||
addFlag({
|
||||
.longName = "dry-run",
|
||||
.description = "Show what this command would do without doing it.",
|
||||
//.category = commonArgsCategory,
|
||||
.handler = {&dryRun, true},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
struct MixJSON : virtual Args
|
||||
/**
|
||||
* Commands that can print JSON according to the
|
||||
* `--pretty`/`--no-pretty` flag.
|
||||
*
|
||||
* This is distinct from MixJSON, because for some commands,
|
||||
* JSON outputs is not optional.
|
||||
*/
|
||||
struct MixPrintJSON : virtual Args
|
||||
{
|
||||
bool outputPretty = isatty(STDOUT_FILENO);
|
||||
|
||||
MixPrintJSON()
|
||||
{
|
||||
addFlag({
|
||||
.longName = "pretty",
|
||||
.description =
|
||||
R"(
|
||||
Print multi-line, indented JSON output for readability.
|
||||
|
||||
Default: indent if output is to a terminal.
|
||||
|
||||
This option is only effective when `--json` is also specified.
|
||||
)",
|
||||
.handler = {&outputPretty, true},
|
||||
});
|
||||
addFlag({
|
||||
.longName = "no-pretty",
|
||||
.description =
|
||||
R"(
|
||||
Print compact JSON output on a single line, even when the output is a terminal.
|
||||
Some commands may print multiple JSON objects on separate lines.
|
||||
|
||||
See `--pretty`.
|
||||
)",
|
||||
.handler = {&outputPretty, false},
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Print an `nlohmann::json` to stdout
|
||||
*
|
||||
* - respecting `--pretty` / `--no-pretty`.
|
||||
* - suspending the progress bar
|
||||
*
|
||||
* This is a template to avoid accidental coercions from `string` to `json` in the caller,
|
||||
* to avoid mistakenly passing an already serialized JSON to this function.
|
||||
*
|
||||
* It is not recommended to print a JSON string - see the JSON guidelines
|
||||
* about extensibility, https://nix.dev/manual/nix/development/development/json-guideline.html -
|
||||
* but you _can_ print a sole JSON string by explicitly coercing it to
|
||||
* `nlohmann::json` first.
|
||||
*/
|
||||
template <typename T, typename = std::enable_if_t<std::is_same_v<T, nlohmann::json>>>
|
||||
void printJSON(const T & json);
|
||||
};
|
||||
|
||||
/** Optional JSON support via `--json` flag */
|
||||
struct MixJSON : virtual Args, virtual MixPrintJSON
|
||||
{
|
||||
bool json = false;
|
||||
|
||||
@@ -44,7 +100,6 @@ struct MixJSON : virtual Args
|
||||
addFlag({
|
||||
.longName = "json",
|
||||
.description = "Produce output in JSON format, suitable for consumption by another program.",
|
||||
//.category = commonArgsCategory,
|
||||
.handler = {&json, true},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,8 +14,9 @@ Gen<OutputsSpec> Arbitrary<OutputsSpec>::arbitrary()
|
||||
return gen::just((OutputsSpec) OutputsSpec::All{});
|
||||
case 1:
|
||||
return gen::map(
|
||||
gen::nonEmpty(gen::container<StringSet>(
|
||||
gen::map(gen::arbitrary<StorePathName>(), [](StorePathName n) { return n.name; }))),
|
||||
gen::nonEmpty(
|
||||
gen::container<StringSet>(
|
||||
gen::map(gen::arbitrary<StorePathName>(), [](StorePathName n) { return n.name; }))),
|
||||
[](StringSet names) { return (OutputsSpec) OutputsSpec::Names{names}; });
|
||||
default:
|
||||
assert(false);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
],
|
||||
"builder": "/bin/bash",
|
||||
"env": {
|
||||
"__json": "{\"__darwinAllowLocalNetworking\":true,\"__impureHostDeps\":[\"/usr/bin/ditto\"],\"__noChroot\":true,\"__sandboxProfile\":\"sandcastle\",\"allowSubstitutes\":false,\"builder\":\"/bin/bash\",\"impureEnvVars\":[\"UNICORN\"],\"name\":\"advanced-attributes-structured-attrs\",\"outputChecks\":{\"bin\":{\"disallowedReferences\":[\"/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g\"],\"disallowedRequisites\":[\"/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9\"],\"allowedRequisites\":[\"/0nr45p69vn6izw9446wsh9bng9nndhvn19kpsm4n96a5mycw0s4z\"]}},\"outputHashAlgo\":\"sha256\",\"outputHashMode\":\"recursive\",\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}",
|
||||
"__json": "{\"__darwinAllowLocalNetworking\":true,\"__impureHostDeps\":[\"/usr/bin/ditto\"],\"__noChroot\":true,\"__sandboxProfile\":\"sandcastle\",\"allowSubstitutes\":false,\"builder\":\"/bin/bash\",\"exportReferencesGraph\":{\"refs1\":[\"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9\"],\"refs2\":[\"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv\"]},\"impureEnvVars\":[\"UNICORN\"],\"name\":\"advanced-attributes-structured-attrs\",\"outputChecks\":{\"bin\":{\"disallowedReferences\":[\"/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g\"],\"disallowedRequisites\":[\"/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9\"],\"allowedRequisites\":[\"/0nr45p69vn6izw9446wsh9bng9nndhvn19kpsm4n96a5mycw0s4z\"]}},\"outputHashAlgo\":\"sha256\",\"outputHashMode\":\"recursive\",\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}",
|
||||
"bin": "/04f3da1kmbr67m3gzxikmsl4vjz5zf777sv6m14ahv22r65aac9m",
|
||||
"dev": "/02qcpld1y6xhs5gz9bchpxaw0xdhmsp5dv88lh25r2ss44kh8dxz",
|
||||
"out": "/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9"
|
||||
@@ -26,7 +26,9 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"inputSrcs": [],
|
||||
"inputSrcs": [
|
||||
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv"
|
||||
],
|
||||
"name": "advanced-attributes-structured-attrs",
|
||||
"outputs": {
|
||||
"bin": {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"builder": "/bin/bash",
|
||||
"disallowedReferences": "/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g",
|
||||
"disallowedRequisites": "/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8",
|
||||
"exportReferencesGraph": "refs1 /164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9 refs2 /nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv",
|
||||
"impureEnvVars": "UNICORN",
|
||||
"name": "advanced-attributes",
|
||||
"out": "/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9",
|
||||
@@ -40,7 +41,9 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"inputSrcs": [],
|
||||
"inputSrcs": [
|
||||
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv"
|
||||
],
|
||||
"name": "advanced-attributes",
|
||||
"outputs": {
|
||||
"out": {
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
],
|
||||
"builder": "/bin/bash",
|
||||
"env": {
|
||||
"__json": "{\"__darwinAllowLocalNetworking\":true,\"__impureHostDeps\":[\"/usr/bin/ditto\"],\"__noChroot\":true,\"__sandboxProfile\":\"sandcastle\",\"allowSubstitutes\":false,\"builder\":\"/bin/bash\",\"impureEnvVars\":[\"UNICORN\"],\"name\":\"advanced-attributes-structured-attrs\",\"outputChecks\":{\"bin\":{\"disallowedReferences\":[\"/nix/store/r5cff30838majxk5mp3ip2diffi8vpaj-bar\"],\"disallowedRequisites\":[\"/nix/store/9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo\"],\"allowedRequisites\":[\"/nix/store/z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev\"]}},\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}",
|
||||
"bin": "/nix/store/qjjj3zrlimpjbkk686m052b3ks9iz2sl-advanced-attributes-structured-attrs-bin",
|
||||
"dev": "/nix/store/lpz5grl48v93pdadavyg5is1rqvfdipf-advanced-attributes-structured-attrs-dev",
|
||||
"out": "/nix/store/nzvz1bmh1g89a5dkpqcqan0av7q3hgv3-advanced-attributes-structured-attrs"
|
||||
"__json": "{\"__darwinAllowLocalNetworking\":true,\"__impureHostDeps\":[\"/usr/bin/ditto\"],\"__noChroot\":true,\"__sandboxProfile\":\"sandcastle\",\"allowSubstitutes\":false,\"builder\":\"/bin/bash\",\"exportReferencesGraph\":{\"refs1\":[\"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo\"],\"refs2\":[\"/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv\"]},\"impureEnvVars\":[\"UNICORN\"],\"name\":\"advanced-attributes-structured-attrs\",\"outputChecks\":{\"bin\":{\"disallowedReferences\":[\"/nix/store/r5cff30838majxk5mp3ip2diffi8vpaj-bar\"],\"disallowedRequisites\":[\"/nix/store/9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev\"]},\"dev\":{\"maxClosureSize\":5909,\"maxSize\":789},\"out\":{\"allowedReferences\":[\"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo\"],\"allowedRequisites\":[\"/nix/store/z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev\"]}},\"outputs\":[\"out\",\"bin\",\"dev\"],\"preferLocalBuild\":true,\"requiredSystemFeatures\":[\"rainbow\",\"uid-range\"],\"system\":\"my-system\"}",
|
||||
"bin": "/nix/store/33qms3h55wlaspzba3brlzlrm8m2239g-advanced-attributes-structured-attrs-bin",
|
||||
"dev": "/nix/store/wyfgwsdi8rs851wmy1xfzdxy7y5vrg5l-advanced-attributes-structured-attrs-dev",
|
||||
"out": "/nix/store/7cxy4zx1vqc885r4jl2l64pymqbdmhii-advanced-attributes-structured-attrs"
|
||||
},
|
||||
"inputDrvs": {
|
||||
"/nix/store/afc3vbjbzql750v2lp8gxgaxsajphzih-foo.drv": {
|
||||
@@ -26,17 +26,19 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"inputSrcs": [],
|
||||
"inputSrcs": [
|
||||
"/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv"
|
||||
],
|
||||
"name": "advanced-attributes-structured-attrs",
|
||||
"outputs": {
|
||||
"bin": {
|
||||
"path": "/nix/store/qjjj3zrlimpjbkk686m052b3ks9iz2sl-advanced-attributes-structured-attrs-bin"
|
||||
"path": "/nix/store/33qms3h55wlaspzba3brlzlrm8m2239g-advanced-attributes-structured-attrs-bin"
|
||||
},
|
||||
"dev": {
|
||||
"path": "/nix/store/lpz5grl48v93pdadavyg5is1rqvfdipf-advanced-attributes-structured-attrs-dev"
|
||||
"path": "/nix/store/wyfgwsdi8rs851wmy1xfzdxy7y5vrg5l-advanced-attributes-structured-attrs-dev"
|
||||
},
|
||||
"out": {
|
||||
"path": "/nix/store/nzvz1bmh1g89a5dkpqcqan0av7q3hgv3-advanced-attributes-structured-attrs"
|
||||
"path": "/nix/store/7cxy4zx1vqc885r4jl2l64pymqbdmhii-advanced-attributes-structured-attrs"
|
||||
}
|
||||
},
|
||||
"system": "my-system"
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
"builder": "/bin/bash",
|
||||
"disallowedReferences": "/nix/store/r5cff30838majxk5mp3ip2diffi8vpaj-bar",
|
||||
"disallowedRequisites": "/nix/store/9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev",
|
||||
"exportReferencesGraph": "refs1 /nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo refs2 /nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv",
|
||||
"impureEnvVars": "UNICORN",
|
||||
"name": "advanced-attributes",
|
||||
"out": "/nix/store/swkj0mrq0cq3dfli95v4am0427mi2hxf-advanced-attributes",
|
||||
"out": "/nix/store/wyhpwd748pns4k7svh48wdrc8kvjk0ra-advanced-attributes",
|
||||
"preferLocalBuild": "1",
|
||||
"requiredSystemFeatures": "rainbow uid-range",
|
||||
"system": "my-system"
|
||||
@@ -38,11 +39,13 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"inputSrcs": [],
|
||||
"inputSrcs": [
|
||||
"/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv"
|
||||
],
|
||||
"name": "advanced-attributes",
|
||||
"outputs": {
|
||||
"out": {
|
||||
"path": "/nix/store/swkj0mrq0cq3dfli95v4am0427mi2hxf-advanced-attributes"
|
||||
"path": "/nix/store/wyhpwd748pns4k7svh48wdrc8kvjk0ra-advanced-attributes"
|
||||
}
|
||||
},
|
||||
"system": "my-system"
|
||||
|
||||
@@ -99,6 +99,8 @@ TEST_ATERM_JSON(advancedAttributes_structuredAttrs_defaults, "advanced-attribute
|
||||
|
||||
#undef TEST_ATERM_JSON
|
||||
|
||||
using ExportReferencesMap = decltype(DerivationOptions::exportReferencesGraph);
|
||||
|
||||
TYPED_TEST(DerivationAdvancedAttrsBothTest, advancedAttributes_defaults)
|
||||
{
|
||||
this->readTest("advanced-attributes-defaults.drv", [&](auto encoded) {
|
||||
@@ -106,16 +108,17 @@ TYPED_TEST(DerivationAdvancedAttrsBothTest, advancedAttributes_defaults)
|
||||
|
||||
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||
|
||||
ParsedDerivation parsedDrv(drvPath, got);
|
||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(got.env);
|
||||
DerivationOptions options = DerivationOptions::fromStructuredAttrs(got.env, parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
||||
EXPECT_TRUE(!parsedDrv.hasStructuredAttrs());
|
||||
EXPECT_TRUE(!parsedDrv);
|
||||
|
||||
EXPECT_EQ(options.additionalSandboxProfile, "");
|
||||
EXPECT_EQ(options.noChroot, false);
|
||||
EXPECT_EQ(options.impureHostDeps, StringSet{});
|
||||
EXPECT_EQ(options.impureEnvVars, StringSet{});
|
||||
EXPECT_EQ(options.allowLocalNetworking, false);
|
||||
EXPECT_EQ(options.exportReferencesGraph, ExportReferencesMap{});
|
||||
{
|
||||
auto * checksForAllOutputs_ = std::get_if<0>(&options.outputChecks);
|
||||
ASSERT_TRUE(checksForAllOutputs_ != nullptr);
|
||||
@@ -140,8 +143,8 @@ TEST_F(DerivationAdvancedAttrsTest, advancedAttributes_defaults)
|
||||
|
||||
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||
|
||||
ParsedDerivation parsedDrv(drvPath, got);
|
||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(got.env);
|
||||
DerivationOptions options = DerivationOptions::fromStructuredAttrs(got.env, parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
||||
EXPECT_EQ(options.getRequiredSystemFeatures(got), StringSet{});
|
||||
});
|
||||
@@ -154,8 +157,8 @@ TEST_F(CaDerivationAdvancedAttrsTest, advancedAttributes_defaults)
|
||||
|
||||
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||
|
||||
ParsedDerivation parsedDrv(drvPath, got);
|
||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(got.env);
|
||||
DerivationOptions options = DerivationOptions::fromStructuredAttrs(got.env, parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
||||
EXPECT_EQ(options.getRequiredSystemFeatures(got), StringSet{"ca-derivations"});
|
||||
});
|
||||
@@ -168,10 +171,10 @@ TYPED_TEST(DerivationAdvancedAttrsBothTest, advancedAttributes)
|
||||
|
||||
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||
|
||||
ParsedDerivation parsedDrv(drvPath, got);
|
||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(got.env);
|
||||
DerivationOptions options = DerivationOptions::fromStructuredAttrs(got.env, parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
||||
EXPECT_TRUE(!parsedDrv.hasStructuredAttrs());
|
||||
EXPECT_TRUE(!parsedDrv);
|
||||
|
||||
EXPECT_EQ(options.additionalSandboxProfile, "sandcastle");
|
||||
EXPECT_EQ(options.noChroot, true);
|
||||
@@ -192,8 +195,25 @@ TEST_F(DerivationAdvancedAttrsTest, advancedAttributes)
|
||||
|
||||
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||
|
||||
ParsedDerivation parsedDrv(drvPath, got);
|
||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(got.env);
|
||||
DerivationOptions options = DerivationOptions::fromStructuredAttrs(got.env, parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
||||
EXPECT_EQ(
|
||||
options.exportReferencesGraph,
|
||||
(ExportReferencesMap{
|
||||
{
|
||||
"refs1",
|
||||
{
|
||||
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
"refs2",
|
||||
{
|
||||
"/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv",
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
{
|
||||
auto * checksForAllOutputs_ = std::get_if<0>(&options.outputChecks);
|
||||
@@ -225,8 +245,25 @@ TEST_F(CaDerivationAdvancedAttrsTest, advancedAttributes)
|
||||
|
||||
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||
|
||||
ParsedDerivation parsedDrv(drvPath, got);
|
||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(got.env);
|
||||
DerivationOptions options = DerivationOptions::fromStructuredAttrs(got.env, parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
||||
EXPECT_EQ(
|
||||
options.exportReferencesGraph,
|
||||
(ExportReferencesMap{
|
||||
{
|
||||
"refs1",
|
||||
{
|
||||
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9",
|
||||
},
|
||||
},
|
||||
{
|
||||
"refs2",
|
||||
{
|
||||
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv",
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
{
|
||||
auto * checksForAllOutputs_ = std::get_if<0>(&options.outputChecks);
|
||||
@@ -261,23 +298,24 @@ TYPED_TEST(DerivationAdvancedAttrsBothTest, advancedAttributes_structuredAttrs_d
|
||||
|
||||
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||
|
||||
ParsedDerivation parsedDrv(drvPath, got);
|
||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(got.env);
|
||||
DerivationOptions options = DerivationOptions::fromStructuredAttrs(got.env, parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
||||
EXPECT_TRUE(parsedDrv.hasStructuredAttrs());
|
||||
EXPECT_TRUE(parsedDrv);
|
||||
|
||||
EXPECT_EQ(options.additionalSandboxProfile, "");
|
||||
EXPECT_EQ(options.noChroot, false);
|
||||
EXPECT_EQ(options.impureHostDeps, StringSet{});
|
||||
EXPECT_EQ(options.impureEnvVars, StringSet{});
|
||||
EXPECT_EQ(options.allowLocalNetworking, false);
|
||||
EXPECT_EQ(options.exportReferencesGraph, ExportReferencesMap{});
|
||||
|
||||
{
|
||||
auto * checksPerOutput_ = std::get_if<1>(&options.outputChecks);
|
||||
ASSERT_TRUE(checksPerOutput_ != nullptr);
|
||||
auto & checksPerOutput = *checksPerOutput_;
|
||||
|
||||
EXPECT_EQ(checksPerOutput.size(), 0);
|
||||
EXPECT_EQ(checksPerOutput.size(), 0u);
|
||||
}
|
||||
|
||||
EXPECT_EQ(options.canBuildLocally(*this->store, got), false);
|
||||
@@ -294,8 +332,8 @@ TEST_F(DerivationAdvancedAttrsTest, advancedAttributes_structuredAttrs_defaults)
|
||||
|
||||
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||
|
||||
ParsedDerivation parsedDrv(drvPath, got);
|
||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(got.env);
|
||||
DerivationOptions options = DerivationOptions::fromStructuredAttrs(got.env, parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
||||
EXPECT_EQ(options.getRequiredSystemFeatures(got), StringSet{});
|
||||
});
|
||||
@@ -308,8 +346,8 @@ TEST_F(CaDerivationAdvancedAttrsTest, advancedAttributes_structuredAttrs_default
|
||||
|
||||
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||
|
||||
ParsedDerivation parsedDrv(drvPath, got);
|
||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(got.env);
|
||||
DerivationOptions options = DerivationOptions::fromStructuredAttrs(got.env, parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
||||
EXPECT_EQ(options.getRequiredSystemFeatures(got), StringSet{"ca-derivations"});
|
||||
});
|
||||
@@ -322,10 +360,10 @@ TYPED_TEST(DerivationAdvancedAttrsBothTest, advancedAttributes_structuredAttrs)
|
||||
|
||||
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||
|
||||
ParsedDerivation parsedDrv(drvPath, got);
|
||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(got.env);
|
||||
DerivationOptions options = DerivationOptions::fromStructuredAttrs(got.env, parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
||||
EXPECT_TRUE(parsedDrv.hasStructuredAttrs());
|
||||
EXPECT_TRUE(parsedDrv);
|
||||
|
||||
EXPECT_EQ(options.additionalSandboxProfile, "sandcastle");
|
||||
EXPECT_EQ(options.noChroot, true);
|
||||
@@ -356,8 +394,25 @@ TEST_F(DerivationAdvancedAttrsTest, advancedAttributes_structuredAttrs)
|
||||
|
||||
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||
|
||||
ParsedDerivation parsedDrv(drvPath, got);
|
||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(got.env);
|
||||
DerivationOptions options = DerivationOptions::fromStructuredAttrs(got.env, parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
||||
EXPECT_EQ(
|
||||
options.exportReferencesGraph,
|
||||
(ExportReferencesMap{
|
||||
{
|
||||
"refs1",
|
||||
{
|
||||
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
"refs2",
|
||||
{
|
||||
"/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv",
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
{
|
||||
{
|
||||
@@ -393,8 +448,25 @@ TEST_F(CaDerivationAdvancedAttrsTest, advancedAttributes_structuredAttrs)
|
||||
|
||||
auto drvPath = writeDerivation(*this->store, got, NoRepair, true);
|
||||
|
||||
ParsedDerivation parsedDrv(drvPath, got);
|
||||
DerivationOptions options = DerivationOptions::fromParsedDerivation(parsedDrv);
|
||||
auto parsedDrv = StructuredAttrs::tryParse(got.env);
|
||||
DerivationOptions options = DerivationOptions::fromStructuredAttrs(got.env, parsedDrv ? &*parsedDrv : nullptr);
|
||||
|
||||
EXPECT_EQ(
|
||||
options.exportReferencesGraph,
|
||||
(ExportReferencesMap{
|
||||
{
|
||||
"refs1",
|
||||
{
|
||||
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9",
|
||||
},
|
||||
},
|
||||
{
|
||||
"refs2",
|
||||
{
|
||||
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv",
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
{
|
||||
{
|
||||
|
||||
@@ -93,7 +93,7 @@ TEST_F(PathInfoTest, PathInfo_full_shortRefs) {
|
||||
ValidPathInfo it = makeFullKeyed(*store, true);
|
||||
// it.references = unkeyed.references;
|
||||
auto refs = it.shortRefs();
|
||||
ASSERT_EQ(refs.size(), 2);
|
||||
ASSERT_EQ(refs.size(), 2u);
|
||||
ASSERT_EQ(*refs.begin(), "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar");
|
||||
ASSERT_EQ(*++refs.begin(), "n5wkd9frr45pa74if5gpz9j7mifg27fh-foo");
|
||||
}
|
||||
|
||||
@@ -702,7 +702,7 @@ TEST_F(WorkerProtoTest, handshake_features)
|
||||
clientThread.join();
|
||||
|
||||
EXPECT_EQ(clientResult, daemonResult);
|
||||
EXPECT_EQ(std::get<0>(clientResult), 123);
|
||||
EXPECT_EQ(std::get<0>(clientResult), 123u);
|
||||
EXPECT_EQ(std::get<1>(clientResult), std::set<WorkerProto::Feature>({"bar", "xyzzy"}));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,17 @@ BinaryCacheStore::BinaryCacheStore(const Params & params)
|
||||
, Store(params)
|
||||
{
|
||||
if (secretKeyFile != "")
|
||||
signer = std::make_unique<LocalSigner>(
|
||||
SecretKey { readFile(secretKeyFile) });
|
||||
signers.push_back(std::make_unique<LocalSigner>(
|
||||
SecretKey { readFile(secretKeyFile) }));
|
||||
|
||||
if (secretKeyFiles != "") {
|
||||
std::stringstream ss(secretKeyFiles);
|
||||
Path keyPath;
|
||||
while (std::getline(ss, keyPath, ',')) {
|
||||
signers.push_back(std::make_unique<LocalSigner>(
|
||||
SecretKey { readFile(keyPath) }));
|
||||
}
|
||||
}
|
||||
|
||||
StringSink sink;
|
||||
sink << narVersionMagic1;
|
||||
@@ -270,9 +279,9 @@ ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(
|
||||
stats.narWriteCompressedBytes += fileSize;
|
||||
stats.narWriteCompressionTimeMs += duration;
|
||||
|
||||
/* Atomically write the NAR info file.*/
|
||||
if (signer) narInfo->sign(*this, *signer);
|
||||
narInfo->sign(*this, signers);
|
||||
|
||||
/* Atomically write the NAR info file.*/
|
||||
writeNarInfo(narInfo);
|
||||
|
||||
stats.narInfoWrite++;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -11,7 +11,7 @@ DrvOutputSubstitutionGoal::DrvOutputSubstitutionGoal(
|
||||
Worker & worker,
|
||||
RepairFlag repair,
|
||||
std::optional<ContentAddress> ca)
|
||||
: Goal(worker, DerivedPath::Opaque { StorePath::dummy })
|
||||
: Goal(worker)
|
||||
, id(id)
|
||||
{
|
||||
name = fmt("substitution of '%s'", id.to_string());
|
||||
@@ -87,6 +87,8 @@ Goal::Co DrvOutputSubstitutionGoal::init()
|
||||
|
||||
bool failed = false;
|
||||
|
||||
Goals waitees;
|
||||
|
||||
for (const auto & [depId, depPath] : outputInfo->dependentRealisations) {
|
||||
if (depId != id) {
|
||||
if (auto localOutputInfo = worker.store.queryRealisation(depId);
|
||||
@@ -103,13 +105,13 @@ Goal::Co DrvOutputSubstitutionGoal::init()
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
addWaitee(worker.makeDrvOutputSubstitutionGoal(depId));
|
||||
waitees.insert(worker.makeDrvOutputSubstitutionGoal(depId));
|
||||
}
|
||||
}
|
||||
|
||||
if (failed) continue;
|
||||
|
||||
co_return realisationFetched(outputInfo, sub);
|
||||
co_return realisationFetched(std::move(waitees), outputInfo, sub);
|
||||
}
|
||||
|
||||
/* None left. Terminate this goal and let someone else deal
|
||||
@@ -127,10 +129,10 @@ Goal::Co DrvOutputSubstitutionGoal::init()
|
||||
co_return amDone(substituterFailed ? ecFailed : ecNoSubstituters);
|
||||
}
|
||||
|
||||
Goal::Co DrvOutputSubstitutionGoal::realisationFetched(std::shared_ptr<const Realisation> outputInfo, nix::ref<nix::Store> sub) {
|
||||
addWaitee(worker.makePathSubstitutionGoal(outputInfo->outPath));
|
||||
Goal::Co DrvOutputSubstitutionGoal::realisationFetched(Goals waitees, std::shared_ptr<const Realisation> outputInfo, nix::ref<nix::Store> sub) {
|
||||
waitees.insert(worker.makePathSubstitutionGoal(outputInfo->outPath));
|
||||
|
||||
if (!waitees.empty()) co_await Suspend{};
|
||||
co_await await(std::move(waitees));
|
||||
|
||||
trace("output path substituted");
|
||||
|
||||
|
||||
+52
-30
@@ -132,38 +132,18 @@ void addToWeakGoals(WeakGoals & goals, GoalPtr p)
|
||||
goals.insert(p);
|
||||
}
|
||||
|
||||
|
||||
void Goal::addWaitee(GoalPtr waitee)
|
||||
Co Goal::await(Goals new_waitees)
|
||||
{
|
||||
waitees.insert(waitee);
|
||||
addToWeakGoals(waitee->waiters, shared_from_this());
|
||||
}
|
||||
|
||||
|
||||
void Goal::waiteeDone(GoalPtr waitee, ExitCode result)
|
||||
{
|
||||
assert(waitees.count(waitee));
|
||||
waitees.erase(waitee);
|
||||
|
||||
trace(fmt("waitee '%s' done; %d left", waitee->name, waitees.size()));
|
||||
|
||||
if (result == ecFailed || result == ecNoSubstituters || result == ecIncompleteClosure) ++nrFailed;
|
||||
|
||||
if (result == ecNoSubstituters) ++nrNoSubstituters;
|
||||
|
||||
if (result == ecIncompleteClosure) ++nrIncompleteClosure;
|
||||
|
||||
if (waitees.empty() || (result == ecFailed && !settings.keepGoing)) {
|
||||
|
||||
/* If we failed and keepGoing is not set, we remove all
|
||||
remaining waitees. */
|
||||
for (auto & goal : waitees) {
|
||||
goal->waiters.extract(shared_from_this());
|
||||
assert(waitees.empty());
|
||||
if (!new_waitees.empty()) {
|
||||
waitees = std::move(new_waitees);
|
||||
for (auto waitee : waitees) {
|
||||
addToWeakGoals(waitee->waiters, shared_from_this());
|
||||
}
|
||||
waitees.clear();
|
||||
|
||||
worker.wakeUp(shared_from_this());
|
||||
co_await Suspend{};
|
||||
assert(waitees.empty());
|
||||
}
|
||||
co_return Return{};
|
||||
}
|
||||
|
||||
Goal::Done Goal::amDone(ExitCode result, std::optional<Error> ex)
|
||||
@@ -183,7 +163,32 @@ Goal::Done Goal::amDone(ExitCode result, std::optional<Error> ex)
|
||||
|
||||
for (auto & i : waiters) {
|
||||
GoalPtr goal = i.lock();
|
||||
if (goal) goal->waiteeDone(shared_from_this(), result);
|
||||
if (goal) {
|
||||
auto me = shared_from_this();
|
||||
assert(goal->waitees.count(me));
|
||||
goal->waitees.erase(me);
|
||||
|
||||
goal->trace(fmt("waitee '%s' done; %d left", name, goal->waitees.size()));
|
||||
|
||||
if (result == ecFailed || result == ecNoSubstituters || result == ecIncompleteClosure) ++goal->nrFailed;
|
||||
|
||||
if (result == ecNoSubstituters) ++goal->nrNoSubstituters;
|
||||
|
||||
if (result == ecIncompleteClosure) ++goal->nrIncompleteClosure;
|
||||
|
||||
if (goal->waitees.empty()) {
|
||||
worker.wakeUp(goal);
|
||||
} else if (result == ecFailed && !settings.keepGoing) {
|
||||
/* If we failed and keepGoing is not set, we remove all
|
||||
remaining waitees. */
|
||||
for (auto & g : goal->waitees) {
|
||||
g->waiters.extract(goal);
|
||||
}
|
||||
goal->waitees.clear();
|
||||
|
||||
worker.wakeUp(goal);
|
||||
}
|
||||
}
|
||||
}
|
||||
waiters.clear();
|
||||
worker.removeGoal(shared_from_this());
|
||||
@@ -215,5 +220,22 @@ void Goal::work()
|
||||
assert(top_co || exitCode != ecBusy);
|
||||
}
|
||||
|
||||
Goal::Co Goal::yield() {
|
||||
worker.wakeUp(shared_from_this());
|
||||
co_await Suspend{};
|
||||
co_return Return{};
|
||||
}
|
||||
|
||||
Goal::Co Goal::waitForAWhile() {
|
||||
worker.waitForAWhile(shared_from_this());
|
||||
co_await Suspend{};
|
||||
co_return Return{};
|
||||
}
|
||||
|
||||
Goal::Co Goal::waitForBuildSlot() {
|
||||
worker.waitForBuildSlot(shared_from_this());
|
||||
co_await Suspend{};
|
||||
co_return Return{};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
namespace nix {
|
||||
|
||||
PathSubstitutionGoal::PathSubstitutionGoal(const StorePath & storePath, Worker & worker, RepairFlag repair, std::optional<ContentAddress> ca)
|
||||
: Goal(worker, DerivedPath::Opaque { storePath })
|
||||
: Goal(worker)
|
||||
, storePath(storePath)
|
||||
, repair(repair)
|
||||
, ca(ca)
|
||||
@@ -128,13 +128,15 @@ Goal::Co PathSubstitutionGoal::init()
|
||||
continue;
|
||||
}
|
||||
|
||||
Goals waitees;
|
||||
|
||||
/* To maintain the closure invariant, we first have to realise the
|
||||
paths referenced by this one. */
|
||||
for (auto & i : info->references)
|
||||
if (i != storePath) /* ignore self-references */
|
||||
addWaitee(worker.makePathSubstitutionGoal(i));
|
||||
waitees.insert(worker.makePathSubstitutionGoal(i));
|
||||
|
||||
if (!waitees.empty()) co_await Suspend{};
|
||||
co_await await(std::move(waitees));
|
||||
|
||||
// FIXME: consider returning boolean instead of passing in reference
|
||||
bool out = false; // is mutated by tryToRun
|
||||
@@ -172,11 +174,15 @@ Goal::Co PathSubstitutionGoal::tryToRun(StorePath subPath, nix::ref<Store> sub,
|
||||
}
|
||||
|
||||
for (auto & i : info->references)
|
||||
if (i != storePath) /* ignore self-references */
|
||||
assert(worker.store.isValidPath(i));
|
||||
/* ignore self-references */
|
||||
if (i != storePath) {
|
||||
if (!worker.store.isValidPath(i)) {
|
||||
throw Error("reference '%s' of path '%s' is not a valid path",
|
||||
worker.store.printStorePath(i), worker.store.printStorePath(storePath));
|
||||
}
|
||||
}
|
||||
|
||||
worker.wakeUp(shared_from_this());
|
||||
co_await Suspend{};
|
||||
co_await yield();
|
||||
|
||||
trace("trying to run");
|
||||
|
||||
@@ -184,8 +190,7 @@ Goal::Co PathSubstitutionGoal::tryToRun(StorePath subPath, nix::ref<Store> sub,
|
||||
if maxSubstitutionJobs == 0, we still allow a substituter to run. This
|
||||
prevents infinite waiting. */
|
||||
while (worker.getNrSubstitutions() >= std::max(1U, (unsigned int) settings.maxSubstitutionJobs)) {
|
||||
worker.waitForBuildSlot(shared_from_this());
|
||||
co_await Suspend{};
|
||||
co_await waitForBuildSlot();
|
||||
}
|
||||
|
||||
auto maintainRunningSubstitutions = std::make_unique<MaintainCount<uint64_t>>(worker.runningSubstitutions);
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "nix/store/build/drv-output-substitution-goal.hh"
|
||||
#include "nix/store/build/derivation-goal.hh"
|
||||
#ifndef _WIN32 // TODO Enable building on Windows
|
||||
# include "nix/store/build/local-derivation-goal.hh"
|
||||
# include "nix/store/build/hook-instance.hh"
|
||||
#endif
|
||||
#include "nix/util/signals.hh"
|
||||
@@ -65,13 +64,7 @@ std::shared_ptr<DerivationGoal> Worker::makeDerivationGoal(const StorePath & drv
|
||||
const OutputsSpec & wantedOutputs, BuildMode buildMode)
|
||||
{
|
||||
return makeDerivationGoalCommon(drvPath, wantedOutputs, [&]() -> std::shared_ptr<DerivationGoal> {
|
||||
return
|
||||
#ifndef _WIN32 // TODO Enable building on Windows
|
||||
dynamic_cast<LocalStore *>(&store)
|
||||
? std::make_shared<LocalDerivationGoal>(drvPath, wantedOutputs, *this, buildMode)
|
||||
:
|
||||
#endif
|
||||
std::make_shared</* */DerivationGoal>(drvPath, wantedOutputs, *this, buildMode);
|
||||
return std::make_shared<DerivationGoal>(drvPath, wantedOutputs, *this, buildMode);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,13 +72,7 @@ std::shared_ptr<DerivationGoal> Worker::makeBasicDerivationGoal(const StorePath
|
||||
const BasicDerivation & drv, const OutputsSpec & wantedOutputs, BuildMode buildMode)
|
||||
{
|
||||
return makeDerivationGoalCommon(drvPath, wantedOutputs, [&]() -> std::shared_ptr<DerivationGoal> {
|
||||
return
|
||||
#ifndef _WIN32 // TODO Enable building on Windows
|
||||
dynamic_cast<LocalStore *>(&store)
|
||||
? std::make_shared<LocalDerivationGoal>(drvPath, drv, wantedOutputs, *this, buildMode)
|
||||
:
|
||||
#endif
|
||||
std::make_shared</* */DerivationGoal>(drvPath, drv, wantedOutputs, *this, buildMode);
|
||||
return std::make_shared<DerivationGoal>(drvPath, drv, wantedOutputs, *this, buildMode);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -524,7 +511,7 @@ bool Worker::pathContentsGood(const StorePath & path)
|
||||
res = false;
|
||||
else {
|
||||
auto current = hashPath(
|
||||
{store.getFSAccessor(), CanonPath(store.printStorePath(path))},
|
||||
{store.getFSAccessor(), CanonPath(path.to_string())},
|
||||
FileIngestionMethod::NixArchive, info->narHash.algo).first;
|
||||
Hash nullHash(HashAlgorithm::SHA256);
|
||||
res = info->narHash == nullHash || info->narHash == current;
|
||||
@@ -552,4 +539,9 @@ GoalPtr upcast_goal(std::shared_ptr<DrvOutputSubstitutionGoal> subGoal)
|
||||
return subGoal;
|
||||
}
|
||||
|
||||
GoalPtr upcast_goal(std::shared_ptr<DerivationGoal> subGoal)
|
||||
{
|
||||
return subGoal;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +1,124 @@
|
||||
#include "nix/store/derivation-options.hh"
|
||||
#include "nix/util/json-utils.hh"
|
||||
#include "nix/store/parsed-derivations.hh"
|
||||
#include "nix/store/derivations.hh"
|
||||
#include "nix/store/store-api.hh"
|
||||
#include "nix/util/types.hh"
|
||||
#include "nix/util/util.hh"
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <regex>
|
||||
|
||||
namespace nix {
|
||||
|
||||
static std::optional<std::string>
|
||||
getStringAttr(const StringMap & env, const StructuredAttrs * parsed, const std::string & name)
|
||||
{
|
||||
if (parsed) {
|
||||
auto i = parsed->structuredAttrs.find(name);
|
||||
if (i == parsed->structuredAttrs.end())
|
||||
return {};
|
||||
else {
|
||||
if (!i->is_string())
|
||||
throw Error("attribute '%s' of must be a string", name);
|
||||
return i->get<std::string>();
|
||||
}
|
||||
} else {
|
||||
auto i = env.find(name);
|
||||
if (i == env.end())
|
||||
return {};
|
||||
else
|
||||
return i->second;
|
||||
}
|
||||
}
|
||||
|
||||
static bool getBoolAttr(const StringMap & env, const StructuredAttrs * parsed, const std::string & name, bool def)
|
||||
{
|
||||
if (parsed) {
|
||||
auto i = parsed->structuredAttrs.find(name);
|
||||
if (i == parsed->structuredAttrs.end())
|
||||
return def;
|
||||
else {
|
||||
if (!i->is_boolean())
|
||||
throw Error("attribute '%s' must be a Boolean", name);
|
||||
return i->get<bool>();
|
||||
}
|
||||
} else {
|
||||
auto i = env.find(name);
|
||||
if (i == env.end())
|
||||
return def;
|
||||
else
|
||||
return i->second == "1";
|
||||
}
|
||||
}
|
||||
|
||||
static std::optional<Strings>
|
||||
getStringsAttr(const StringMap & env, const StructuredAttrs * parsed, const std::string & name)
|
||||
{
|
||||
if (parsed) {
|
||||
auto i = parsed->structuredAttrs.find(name);
|
||||
if (i == parsed->structuredAttrs.end())
|
||||
return {};
|
||||
else {
|
||||
if (!i->is_array())
|
||||
throw Error("attribute '%s' must be a list of strings", name);
|
||||
Strings res;
|
||||
for (auto j = i->begin(); j != i->end(); ++j) {
|
||||
if (!j->is_string())
|
||||
throw Error("attribute '%s' must be a list of strings", name);
|
||||
res.push_back(j->get<std::string>());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
auto i = env.find(name);
|
||||
if (i == env.end())
|
||||
return {};
|
||||
else
|
||||
return tokenizeString<Strings>(i->second);
|
||||
}
|
||||
}
|
||||
|
||||
static std::optional<StringSet>
|
||||
getStringSetAttr(const StringMap & env, const StructuredAttrs * parsed, const std::string & name)
|
||||
{
|
||||
auto ss = getStringsAttr(env, parsed, name);
|
||||
return ss ? (std::optional{StringSet{ss->begin(), ss->end()}}) : (std::optional<StringSet>{});
|
||||
}
|
||||
|
||||
using OutputChecks = DerivationOptions::OutputChecks;
|
||||
|
||||
using OutputChecksVariant = std::variant<OutputChecks, std::map<std::string, OutputChecks>>;
|
||||
|
||||
DerivationOptions DerivationOptions::fromParsedDerivation(const ParsedDerivation & parsed, bool shouldWarn)
|
||||
DerivationOptions
|
||||
DerivationOptions::fromStructuredAttrs(const StringMap & env, const StructuredAttrs * parsed, bool shouldWarn)
|
||||
{
|
||||
DerivationOptions defaults = {};
|
||||
|
||||
auto structuredAttrs = parsed.structuredAttrs.get();
|
||||
|
||||
if (shouldWarn && structuredAttrs) {
|
||||
if (get(*structuredAttrs, "allowedReferences")) {
|
||||
if (shouldWarn && parsed) {
|
||||
if (get(parsed->structuredAttrs, "allowedReferences")) {
|
||||
warn(
|
||||
"'structuredAttrs' disables the effect of the top-level attribute 'allowedReferences'; use 'outputChecks' instead");
|
||||
}
|
||||
if (get(*structuredAttrs, "allowedRequisites")) {
|
||||
if (get(parsed->structuredAttrs, "allowedRequisites")) {
|
||||
warn(
|
||||
"'structuredAttrs' disables the effect of the top-level attribute 'allowedRequisites'; use 'outputChecks' instead");
|
||||
}
|
||||
if (get(*structuredAttrs, "disallowedRequisites")) {
|
||||
if (get(parsed->structuredAttrs, "disallowedRequisites")) {
|
||||
warn(
|
||||
"'structuredAttrs' disables the effect of the top-level attribute 'disallowedRequisites'; use 'outputChecks' instead");
|
||||
}
|
||||
if (get(*structuredAttrs, "disallowedReferences")) {
|
||||
if (get(parsed->structuredAttrs, "disallowedReferences")) {
|
||||
warn(
|
||||
"'structuredAttrs' disables the effect of the top-level attribute 'disallowedReferences'; use 'outputChecks' instead");
|
||||
}
|
||||
if (get(*structuredAttrs, "maxSize")) {
|
||||
if (get(parsed->structuredAttrs, "maxSize")) {
|
||||
warn(
|
||||
"'structuredAttrs' disables the effect of the top-level attribute 'maxSize'; use 'outputChecks' instead");
|
||||
}
|
||||
if (get(*structuredAttrs, "maxClosureSize")) {
|
||||
if (get(parsed->structuredAttrs, "maxClosureSize")) {
|
||||
warn(
|
||||
"'structuredAttrs' disables the effect of the top-level attribute 'maxClosureSize'; use 'outputChecks' instead");
|
||||
}
|
||||
@@ -48,9 +126,9 @@ DerivationOptions DerivationOptions::fromParsedDerivation(const ParsedDerivation
|
||||
|
||||
return {
|
||||
.outputChecks = [&]() -> OutputChecksVariant {
|
||||
if (auto structuredAttrs = parsed.structuredAttrs.get()) {
|
||||
if (parsed) {
|
||||
std::map<std::string, OutputChecks> res;
|
||||
if (auto outputChecks = get(*structuredAttrs, "outputChecks")) {
|
||||
if (auto outputChecks = get(parsed->structuredAttrs, "outputChecks")) {
|
||||
for (auto & [outputName, output] : getObject(*outputChecks)) {
|
||||
OutputChecks checks;
|
||||
|
||||
@@ -87,10 +165,10 @@ DerivationOptions DerivationOptions::fromParsedDerivation(const ParsedDerivation
|
||||
return OutputChecks{
|
||||
// legacy non-structured-attributes case
|
||||
.ignoreSelfRefs = true,
|
||||
.allowedReferences = parsed.getStringSetAttr("allowedReferences"),
|
||||
.disallowedReferences = parsed.getStringSetAttr("disallowedReferences").value_or(StringSet{}),
|
||||
.allowedRequisites = parsed.getStringSetAttr("allowedRequisites"),
|
||||
.disallowedRequisites = parsed.getStringSetAttr("disallowedRequisites").value_or(StringSet{}),
|
||||
.allowedReferences = getStringSetAttr(env, parsed, "allowedReferences"),
|
||||
.disallowedReferences = getStringSetAttr(env, parsed, "disallowedReferences").value_or(StringSet{}),
|
||||
.allowedRequisites = getStringSetAttr(env, parsed, "allowedRequisites"),
|
||||
.disallowedRequisites = getStringSetAttr(env, parsed, "disallowedRequisites").value_or(StringSet{}),
|
||||
};
|
||||
}
|
||||
}(),
|
||||
@@ -98,8 +176,8 @@ DerivationOptions DerivationOptions::fromParsedDerivation(const ParsedDerivation
|
||||
[&] {
|
||||
std::map<std::string, bool> res;
|
||||
|
||||
if (auto structuredAttrs = parsed.structuredAttrs.get()) {
|
||||
if (auto udr = get(*structuredAttrs, "unsafeDiscardReferences")) {
|
||||
if (parsed) {
|
||||
if (auto udr = get(parsed->structuredAttrs, "unsafeDiscardReferences")) {
|
||||
for (auto & [outputName, output] : getObject(*udr)) {
|
||||
if (!output.is_boolean())
|
||||
throw Error("attribute 'unsafeDiscardReferences.\"%s\"' must be a Boolean", outputName);
|
||||
@@ -113,8 +191,8 @@ DerivationOptions DerivationOptions::fromParsedDerivation(const ParsedDerivation
|
||||
.passAsFile =
|
||||
[&] {
|
||||
StringSet res;
|
||||
if (auto * passAsFileString = get(parsed.drv.env, "passAsFile")) {
|
||||
if (parsed.hasStructuredAttrs()) {
|
||||
if (auto * passAsFileString = get(env, "passAsFile")) {
|
||||
if (parsed) {
|
||||
if (shouldWarn) {
|
||||
warn(
|
||||
"'structuredAttrs' disables the effect of the top-level attribute 'passAsFile'; because all JSON is always passed via file");
|
||||
@@ -125,16 +203,44 @@ DerivationOptions DerivationOptions::fromParsedDerivation(const ParsedDerivation
|
||||
}
|
||||
return res;
|
||||
}(),
|
||||
.exportReferencesGraph =
|
||||
[&] {
|
||||
std::map<std::string, StringSet> ret;
|
||||
|
||||
if (parsed) {
|
||||
auto e = optionalValueAt(parsed->structuredAttrs, "exportReferencesGraph");
|
||||
if (!e || !e->is_object())
|
||||
return ret;
|
||||
for (auto & [key, storePathsJson] : getObject(*e)) {
|
||||
ret.insert_or_assign(key, storePathsJson);
|
||||
}
|
||||
} else {
|
||||
auto s = getOr(env, "exportReferencesGraph", "");
|
||||
Strings ss = tokenizeString<Strings>(s);
|
||||
if (ss.size() % 2 != 0)
|
||||
throw Error("odd number of tokens in 'exportReferencesGraph': '%1%'", s);
|
||||
for (Strings::iterator i = ss.begin(); i != ss.end();) {
|
||||
auto fileName = std::move(*i++);
|
||||
static std::regex regex("[A-Za-z_][A-Za-z0-9_.-]*");
|
||||
if (!std::regex_match(fileName, regex))
|
||||
throw Error("invalid file name '%s' in 'exportReferencesGraph'", fileName);
|
||||
|
||||
auto & storePathS = *i++;
|
||||
ret.insert_or_assign(std::move(fileName), StringSet{storePathS});
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}(),
|
||||
.additionalSandboxProfile =
|
||||
parsed.getStringAttr("__sandboxProfile").value_or(defaults.additionalSandboxProfile),
|
||||
.noChroot = parsed.getBoolAttr("__noChroot", defaults.noChroot),
|
||||
.impureHostDeps = parsed.getStringSetAttr("__impureHostDeps").value_or(defaults.impureHostDeps),
|
||||
.impureEnvVars = parsed.getStringSetAttr("impureEnvVars").value_or(defaults.impureEnvVars),
|
||||
.allowLocalNetworking = parsed.getBoolAttr("__darwinAllowLocalNetworking", defaults.allowLocalNetworking),
|
||||
getStringAttr(env, parsed, "__sandboxProfile").value_or(defaults.additionalSandboxProfile),
|
||||
.noChroot = getBoolAttr(env, parsed, "__noChroot", defaults.noChroot),
|
||||
.impureHostDeps = getStringSetAttr(env, parsed, "__impureHostDeps").value_or(defaults.impureHostDeps),
|
||||
.impureEnvVars = getStringSetAttr(env, parsed, "impureEnvVars").value_or(defaults.impureEnvVars),
|
||||
.allowLocalNetworking = getBoolAttr(env, parsed, "__darwinAllowLocalNetworking", defaults.allowLocalNetworking),
|
||||
.requiredSystemFeatures =
|
||||
parsed.getStringSetAttr("requiredSystemFeatures").value_or(defaults.requiredSystemFeatures),
|
||||
.preferLocalBuild = parsed.getBoolAttr("preferLocalBuild", defaults.preferLocalBuild),
|
||||
.allowSubstitutes = parsed.getBoolAttr("allowSubstitutes", defaults.allowSubstitutes),
|
||||
getStringSetAttr(env, parsed, "requiredSystemFeatures").value_or(defaults.requiredSystemFeatures),
|
||||
.preferLocalBuild = getBoolAttr(env, parsed, "preferLocalBuild", defaults.preferLocalBuild),
|
||||
.allowSubstitutes = getBoolAttr(env, parsed, "allowSubstitutes", defaults.allowSubstitutes),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+35
-45
@@ -1052,49 +1052,36 @@ static void rewriteDerivation(Store & store, BasicDerivation & drv, const String
|
||||
|
||||
std::optional<BasicDerivation> Derivation::tryResolve(Store & store, Store * evalStore) const
|
||||
{
|
||||
std::map<std::pair<StorePath, std::string>, StorePath> inputDrvOutputs;
|
||||
|
||||
std::function<void(const StorePath &, const DerivedPathMap<StringSet>::ChildNode &)> accum;
|
||||
accum = [&](auto & inputDrv, auto & node) {
|
||||
for (auto & [outputName, outputPath] : store.queryPartialDerivationOutputMap(inputDrv, evalStore)) {
|
||||
if (outputPath) {
|
||||
inputDrvOutputs.insert_or_assign({inputDrv, outputName}, *outputPath);
|
||||
if (auto p = get(node.childMap, outputName))
|
||||
accum(*outputPath, *p);
|
||||
return tryResolve(
|
||||
store,
|
||||
[&](ref<const SingleDerivedPath> drvPath, const std::string & outputName) -> std::optional<StorePath> {
|
||||
try {
|
||||
return resolveDerivedPath(store, SingleDerivedPath::Built{drvPath, outputName}, evalStore);
|
||||
} catch (Error &) {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (auto & [inputDrv, node] : inputDrvs.map)
|
||||
accum(inputDrv, node);
|
||||
|
||||
return tryResolve(store, inputDrvOutputs);
|
||||
});
|
||||
}
|
||||
|
||||
static bool tryResolveInput(
|
||||
Store & store, StorePathSet & inputSrcs, StringMap & inputRewrites,
|
||||
const DownstreamPlaceholder * placeholderOpt,
|
||||
const StorePath & inputDrv, const DerivedPathMap<StringSet>::ChildNode & inputNode,
|
||||
const std::map<std::pair<StorePath, std::string>, StorePath> & inputDrvOutputs)
|
||||
ref<const SingleDerivedPath> drvPath, const DerivedPathMap<StringSet>::ChildNode & inputNode,
|
||||
std::function<std::optional<StorePath>(ref<const SingleDerivedPath> drvPath, const std::string & outputName)> queryResolutionChain)
|
||||
{
|
||||
auto getOutput = [&](const std::string & outputName) {
|
||||
auto * actualPathOpt = get(inputDrvOutputs, { inputDrv, outputName });
|
||||
if (!actualPathOpt)
|
||||
warn("output %s of input %s missing, aborting the resolving",
|
||||
outputName,
|
||||
store.printStorePath(inputDrv)
|
||||
);
|
||||
return actualPathOpt;
|
||||
};
|
||||
|
||||
auto getPlaceholder = [&](const std::string & outputName) {
|
||||
return placeholderOpt
|
||||
? DownstreamPlaceholder::unknownDerivation(*placeholderOpt, outputName)
|
||||
: DownstreamPlaceholder::unknownCaOutput(inputDrv, outputName);
|
||||
: [&]{
|
||||
auto * p = std::get_if<SingleDerivedPath::Opaque>(&drvPath->raw());
|
||||
// otherwise we should have had a placeholder to build-upon already
|
||||
assert(p);
|
||||
return DownstreamPlaceholder::unknownCaOutput(p->path, outputName);
|
||||
}();
|
||||
};
|
||||
|
||||
for (auto & outputName : inputNode.value) {
|
||||
auto actualPathOpt = getOutput(outputName);
|
||||
auto actualPathOpt = queryResolutionChain(drvPath, outputName);
|
||||
if (!actualPathOpt) return false;
|
||||
auto actualPath = *actualPathOpt;
|
||||
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
|
||||
@@ -1106,13 +1093,12 @@ static bool tryResolveInput(
|
||||
}
|
||||
|
||||
for (auto & [outputName, childNode] : inputNode.childMap) {
|
||||
auto actualPathOpt = getOutput(outputName);
|
||||
if (!actualPathOpt) return false;
|
||||
auto actualPath = *actualPathOpt;
|
||||
auto nextPlaceholder = getPlaceholder(outputName);
|
||||
if (!tryResolveInput(store, inputSrcs, inputRewrites,
|
||||
&nextPlaceholder, actualPath, childNode,
|
||||
inputDrvOutputs))
|
||||
&nextPlaceholder,
|
||||
make_ref<const SingleDerivedPath>(SingleDerivedPath::Built{drvPath, outputName}),
|
||||
childNode,
|
||||
queryResolutionChain))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1120,7 +1106,7 @@ static bool tryResolveInput(
|
||||
|
||||
std::optional<BasicDerivation> Derivation::tryResolve(
|
||||
Store & store,
|
||||
const std::map<std::pair<StorePath, std::string>, StorePath> & inputDrvOutputs) const
|
||||
std::function<std::optional<StorePath>(ref<const SingleDerivedPath> drvPath, const std::string & outputName)> queryResolutionChain) const
|
||||
{
|
||||
BasicDerivation resolved { *this };
|
||||
|
||||
@@ -1129,7 +1115,7 @@ std::optional<BasicDerivation> Derivation::tryResolve(
|
||||
|
||||
for (auto & [inputDrv, inputNode] : inputDrvs.map)
|
||||
if (!tryResolveInput(store, resolved.inputSrcs, inputRewrites,
|
||||
nullptr, inputDrv, inputNode, inputDrvOutputs))
|
||||
nullptr, make_ref<const SingleDerivedPath>(SingleDerivedPath::Opaque{inputDrv}), inputNode, queryResolutionChain))
|
||||
return std::nullopt;
|
||||
|
||||
rewriteDerivation(store, resolved, inputRewrites);
|
||||
@@ -1242,13 +1228,13 @@ DerivationOutput DerivationOutput::fromJSON(
|
||||
keys.insert(key);
|
||||
|
||||
auto methodAlgo = [&]() -> std::pair<ContentAddressMethod, HashAlgorithm> {
|
||||
auto & method_ = getString(valueAt(json, "method"));
|
||||
ContentAddressMethod method = ContentAddressMethod::parse(method_);
|
||||
ContentAddressMethod method = ContentAddressMethod::parse(
|
||||
getString(valueAt(json, "method")));
|
||||
if (method == ContentAddressMethod::Raw::Text)
|
||||
xpSettings.require(Xp::DynamicDerivations);
|
||||
|
||||
auto & hashAlgo_ = getString(valueAt(json, "hashAlgo"));
|
||||
auto hashAlgo = parseHashAlgo(hashAlgo_);
|
||||
auto hashAlgo = parseHashAlgo(
|
||||
getString(valueAt(json, "hashAlgo")));
|
||||
return { std::move(method), std::move(hashAlgo) };
|
||||
};
|
||||
|
||||
@@ -1365,7 +1351,8 @@ Derivation Derivation::fromJSON(
|
||||
res.name = getString(valueAt(json, "name"));
|
||||
|
||||
try {
|
||||
for (auto & [outputName, output] : getObject(valueAt(json, "outputs"))) {
|
||||
auto outputs = getObject(valueAt(json, "outputs"));
|
||||
for (auto & [outputName, output] : outputs) {
|
||||
res.outputs.insert_or_assign(
|
||||
outputName,
|
||||
DerivationOutput::fromJSON(store, res.name, outputName, output, xpSettings));
|
||||
@@ -1376,7 +1363,8 @@ Derivation Derivation::fromJSON(
|
||||
}
|
||||
|
||||
try {
|
||||
for (auto & input : getArray(valueAt(json, "inputSrcs")))
|
||||
auto inputSrcs = getArray(valueAt(json, "inputSrcs"));
|
||||
for (auto & input : inputSrcs)
|
||||
res.inputSrcs.insert(store.parseStorePath(static_cast<const std::string &>(input)));
|
||||
} catch (Error & e) {
|
||||
e.addTrace({}, "while reading key 'inputSrcs'");
|
||||
@@ -1389,13 +1377,15 @@ Derivation Derivation::fromJSON(
|
||||
auto & json = getObject(_json);
|
||||
DerivedPathMap<StringSet>::ChildNode node;
|
||||
node.value = getStringSet(valueAt(json, "outputs"));
|
||||
for (auto & [outputId, childNode] : getObject(valueAt(json, "dynamicOutputs"))) {
|
||||
auto drvs = getObject(valueAt(json, "dynamicOutputs"));
|
||||
for (auto & [outputId, childNode] : drvs) {
|
||||
xpSettings.require(Xp::DynamicDerivations);
|
||||
node.childMap[outputId] = doInput(childNode);
|
||||
}
|
||||
return node;
|
||||
};
|
||||
for (auto & [inputDrvPath, inputOutputs] : getObject(valueAt(json, "inputDrvs")))
|
||||
auto drvs = getObject(valueAt(json, "inputDrvs"));
|
||||
for (auto & [inputDrvPath, inputOutputs] : drvs)
|
||||
res.inputDrvs.map[store.parseStorePath(inputDrvPath)] =
|
||||
doInput(inputOutputs);
|
||||
} catch (Error & e) {
|
||||
|
||||
@@ -170,7 +170,7 @@ void drvRequireExperiment(
|
||||
}
|
||||
|
||||
SingleDerivedPath::Built SingleDerivedPath::Built::parse(
|
||||
const StoreDirConfig & store, ref<SingleDerivedPath> drv,
|
||||
const StoreDirConfig & store, ref<const SingleDerivedPath> drv,
|
||||
OutputNameView output,
|
||||
const ExperimentalFeatureSettings & xpSettings)
|
||||
{
|
||||
@@ -182,7 +182,7 @@ SingleDerivedPath::Built SingleDerivedPath::Built::parse(
|
||||
}
|
||||
|
||||
DerivedPath::Built DerivedPath::Built::parse(
|
||||
const StoreDirConfig & store, ref<SingleDerivedPath> drv,
|
||||
const StoreDirConfig & store, ref<const SingleDerivedPath> drv,
|
||||
OutputNameView outputsS,
|
||||
const ExperimentalFeatureSettings & xpSettings)
|
||||
{
|
||||
@@ -201,7 +201,7 @@ static SingleDerivedPath parseWithSingle(
|
||||
return n == s.npos
|
||||
? (SingleDerivedPath) SingleDerivedPath::Opaque::parse(store, s)
|
||||
: (SingleDerivedPath) SingleDerivedPath::Built::parse(store,
|
||||
make_ref<SingleDerivedPath>(parseWithSingle(
|
||||
make_ref<const SingleDerivedPath>(parseWithSingle(
|
||||
store,
|
||||
s.substr(0, n),
|
||||
separator,
|
||||
@@ -234,7 +234,7 @@ static DerivedPath parseWith(
|
||||
return n == s.npos
|
||||
? (DerivedPath) DerivedPath::Opaque::parse(store, s)
|
||||
: (DerivedPath) DerivedPath::Built::parse(store,
|
||||
make_ref<SingleDerivedPath>(parseWithSingle(
|
||||
make_ref<const SingleDerivedPath>(parseWithSingle(
|
||||
store,
|
||||
s.substr(0, n),
|
||||
separator,
|
||||
|
||||
@@ -83,7 +83,9 @@ struct DummyStore : public virtual DummyStoreConfig, public virtual Store
|
||||
{ callback(nullptr); }
|
||||
|
||||
virtual ref<SourceAccessor> getFSAccessor(bool requireValidPath) override
|
||||
{ unsupported("getFSAccessor"); }
|
||||
{
|
||||
return makeEmptySourceAccessor();
|
||||
}
|
||||
};
|
||||
|
||||
static RegisterStoreImplementation<DummyStore, DummyStoreConfig> regDummyStore;
|
||||
|
||||
@@ -33,6 +33,9 @@ using namespace std::string_literals;
|
||||
|
||||
namespace nix {
|
||||
|
||||
const unsigned int RETRY_TIME_MS_DEFAULT = 250;
|
||||
const unsigned int RETRY_TIME_MS_TOO_MANY_REQUESTS = 60000;
|
||||
|
||||
FileTransferSettings fileTransferSettings;
|
||||
|
||||
static GlobalConfig::Register rFileTransferSettings(&fileTransferSettings);
|
||||
@@ -399,6 +402,8 @@ struct curlFileTransfer : public FileTransfer
|
||||
{
|
||||
auto finishTime = std::chrono::steady_clock::now();
|
||||
|
||||
auto retryTimeMs = request.baseRetryTimeMs;
|
||||
|
||||
auto httpStatus = getHTTPStatus();
|
||||
|
||||
debug("finished %s of '%s'; curl status = %d, HTTP status = %d, body = %d bytes, duration = %.2f s",
|
||||
@@ -449,10 +454,12 @@ struct curlFileTransfer : public FileTransfer
|
||||
} else if (httpStatus == 401 || httpStatus == 403 || httpStatus == 407) {
|
||||
// Don't retry on authentication/authorization failures
|
||||
err = Forbidden;
|
||||
} else if (httpStatus >= 400 && httpStatus < 500 && httpStatus != 408 && httpStatus != 429) {
|
||||
} else if (httpStatus == 429) {
|
||||
// 429 means too many requests, so we retry (with a substantially longer delay)
|
||||
retryTimeMs = RETRY_TIME_MS_TOO_MANY_REQUESTS;
|
||||
} else if (httpStatus >= 400 && httpStatus < 500 && httpStatus != 408) {
|
||||
// Most 4xx errors are client errors and are probably not worth retrying:
|
||||
// * 408 means the server timed out waiting for us, so we try again
|
||||
// * 429 means too many requests, so we retry (with a delay)
|
||||
err = Misc;
|
||||
} else if (httpStatus == 501 || httpStatus == 505 || httpStatus == 511) {
|
||||
// Let's treat most 5xx (server) errors as transient, except for a handful:
|
||||
@@ -518,7 +525,7 @@ struct curlFileTransfer : public FileTransfer
|
||||
|| writtenToSink == 0
|
||||
|| (acceptRanges && encoding.empty())))
|
||||
{
|
||||
int ms = request.baseRetryTimeMs * std::pow(2.0f, attempt - 1 + std::uniform_real_distribution<>(0.0, 0.5)(fileTransfer.mt19937));
|
||||
int ms = retryTimeMs * std::pow(2.0f, attempt - 1 + std::uniform_real_distribution<>(0.0, 0.5)(fileTransfer.mt19937));
|
||||
if (writtenToSink)
|
||||
warn("%s; retrying from offset %d in %d ms", exc.what(), writtenToSink, ms);
|
||||
else
|
||||
|
||||
+1
-1
@@ -247,7 +247,7 @@ void LocalStore::findRoots(const Path & path, std::filesystem::file_type type, R
|
||||
else {
|
||||
target = absPath(target, dirOf(path));
|
||||
if (!pathExists(target)) {
|
||||
if (isInDir(path, stateDir + "/" + gcRootsDir + "/auto")) {
|
||||
if (isInDir(path, std::filesystem::path{stateDir.get()} / gcRootsDir / "auto")) {
|
||||
printInfo("removing stale link from '%1%' to '%2%'", path, target);
|
||||
unlink(path.c_str());
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ struct BinaryCacheStoreConfig : virtual StoreConfig
|
||||
const Setting<Path> secretKeyFile{this, "", "secret-key",
|
||||
"Path to the secret key used to sign the binary cache."};
|
||||
|
||||
const Setting<std::string> secretKeyFiles{this, "", "secret-keys",
|
||||
"List of comma-separated paths to the secret keys used to sign the binary cache."};
|
||||
|
||||
const Setting<Path> localNarCache{this, "", "local-nar-cache",
|
||||
"Path to a local cache of NARs fetched from this binary cache, used by commands such as `nix store cat`."};
|
||||
|
||||
@@ -57,7 +60,7 @@ class BinaryCacheStore : public virtual BinaryCacheStoreConfig,
|
||||
{
|
||||
|
||||
private:
|
||||
std::unique_ptr<Signer> signer;
|
||||
std::vector<std::unique_ptr<Signer>> signers;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
/**
|
||||
* @file Misc type defitions for both local building and remote (RPC building)
|
||||
*/
|
||||
|
||||
#include "nix/util/hash.hh"
|
||||
#include "nix/store/path.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
class Store;
|
||||
|
||||
/**
|
||||
* Unless we are repairing, we don't both to test validity and just assume it,
|
||||
* so the choices are `Absent` or `Valid`.
|
||||
*/
|
||||
enum struct PathStatus {
|
||||
Corrupt,
|
||||
Absent,
|
||||
Valid,
|
||||
};
|
||||
|
||||
struct InitialOutputStatus
|
||||
{
|
||||
StorePath path;
|
||||
PathStatus status;
|
||||
/**
|
||||
* Valid in the store, and additionally non-corrupt if we are repairing
|
||||
*/
|
||||
bool isValid() const
|
||||
{
|
||||
return status == PathStatus::Valid;
|
||||
}
|
||||
/**
|
||||
* Merely present, allowed to be corrupt
|
||||
*/
|
||||
bool isPresent() const
|
||||
{
|
||||
return status == PathStatus::Corrupt || status == PathStatus::Valid;
|
||||
}
|
||||
};
|
||||
|
||||
struct InitialOutput
|
||||
{
|
||||
bool wanted;
|
||||
Hash outputHash;
|
||||
std::optional<InitialOutputStatus> known;
|
||||
};
|
||||
|
||||
void runPostBuildHook(Store & store, Logger & logger, const StorePath & drvPath, const StorePathSet & outputPaths);
|
||||
|
||||
}
|
||||
@@ -2,10 +2,9 @@
|
||||
///@file
|
||||
|
||||
#include "nix/store/parsed-derivations.hh"
|
||||
#include "nix/store/derivations.hh"
|
||||
#include "nix/store/derivation-options.hh"
|
||||
#ifndef _WIN32
|
||||
# include "nix/store/user-lock.hh"
|
||||
#endif
|
||||
#include "nix/store/build/derivation-building-misc.hh"
|
||||
#include "nix/store/outputs-spec.hh"
|
||||
#include "nix/store/store-api.hh"
|
||||
#include "nix/store/pathlocks.hh"
|
||||
@@ -17,43 +16,17 @@ using std::map;
|
||||
|
||||
#ifndef _WIN32 // TODO enable build hook on Windows
|
||||
struct HookInstance;
|
||||
struct DerivationBuilder;
|
||||
#endif
|
||||
|
||||
typedef enum {rpAccept, rpDecline, rpPostpone} HookReply;
|
||||
|
||||
/**
|
||||
* Unless we are repairing, we don't both to test validity and just assume it,
|
||||
* so the choices are `Absent` or `Valid`.
|
||||
*/
|
||||
enum struct PathStatus {
|
||||
Corrupt,
|
||||
Absent,
|
||||
Valid,
|
||||
};
|
||||
|
||||
struct InitialOutputStatus {
|
||||
StorePath path;
|
||||
PathStatus status;
|
||||
/**
|
||||
* Valid in the store, and additionally non-corrupt if we are repairing
|
||||
*/
|
||||
bool isValid() const {
|
||||
return status == PathStatus::Valid;
|
||||
}
|
||||
/**
|
||||
* Merely present, allowed to be corrupt
|
||||
*/
|
||||
bool isPresent() const {
|
||||
return status == PathStatus::Corrupt
|
||||
|| status == PathStatus::Valid;
|
||||
}
|
||||
};
|
||||
|
||||
struct InitialOutput {
|
||||
bool wanted;
|
||||
Hash outputHash;
|
||||
std::optional<InitialOutputStatus> known;
|
||||
};
|
||||
/** Used internally */
|
||||
void runPostBuildHook(
|
||||
Store & store,
|
||||
Logger & logger,
|
||||
const StorePath & drvPath,
|
||||
const StorePathSet & outputPaths);
|
||||
|
||||
/**
|
||||
* A goal for building some or all of the outputs of a derivation.
|
||||
@@ -68,23 +41,11 @@ struct DerivationGoal : public Goal
|
||||
/** The path of the derivation. */
|
||||
StorePath drvPath;
|
||||
|
||||
/**
|
||||
* The goal for the corresponding resolved derivation
|
||||
*/
|
||||
std::shared_ptr<DerivationGoal> resolvedDrvGoal;
|
||||
|
||||
/**
|
||||
* The specific outputs that we need to build.
|
||||
*/
|
||||
OutputsSpec wantedOutputs;
|
||||
|
||||
/**
|
||||
* Mapping from input derivations + output names to actual store
|
||||
* paths. This is filled in by waiteeDone() as each dependency
|
||||
* finishes, before `trace("all inputs realised")` is reached.
|
||||
*/
|
||||
std::map<std::pair<StorePath, std::string>, StorePath> inputDrvOutputs;
|
||||
|
||||
/**
|
||||
* See `needRestart`; just for that field.
|
||||
*/
|
||||
@@ -143,7 +104,7 @@ struct DerivationGoal : public Goal
|
||||
*/
|
||||
std::unique_ptr<Derivation> drv;
|
||||
|
||||
std::unique_ptr<ParsedDerivation> parsedDrv;
|
||||
std::unique_ptr<StructuredAttrs> parsedDrv;
|
||||
std::unique_ptr<DerivationOptions> drvOptions;
|
||||
|
||||
/**
|
||||
@@ -189,12 +150,9 @@ struct DerivationGoal : public Goal
|
||||
* The build hook.
|
||||
*/
|
||||
std::unique_ptr<HookInstance> hook;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The sort of derivation we are building.
|
||||
*/
|
||||
std::optional<DerivationType> derivationType;
|
||||
std::unique_ptr<DerivationBuilder> builder;
|
||||
#endif
|
||||
|
||||
BuildMode buildMode;
|
||||
|
||||
@@ -220,7 +178,7 @@ struct DerivationGoal : public Goal
|
||||
DerivationGoal(const StorePath & drvPath, const BasicDerivation & drv,
|
||||
const OutputsSpec & wantedOutputs, Worker & worker,
|
||||
BuildMode buildMode = bmNormal);
|
||||
virtual ~DerivationGoal();
|
||||
~DerivationGoal();
|
||||
|
||||
void timedOut(Error && ex) override;
|
||||
|
||||
@@ -238,55 +196,24 @@ struct DerivationGoal : public Goal
|
||||
Co haveDerivation();
|
||||
Co gaveUpOnSubstitution();
|
||||
Co tryToBuild();
|
||||
virtual Co tryLocalBuild();
|
||||
Co buildDone();
|
||||
|
||||
Co resolvedFinished();
|
||||
Co hookDone();
|
||||
|
||||
/**
|
||||
* Is the build hook willing to perform the build?
|
||||
*/
|
||||
HookReply tryBuildHook();
|
||||
|
||||
virtual int getChildStatus();
|
||||
|
||||
/**
|
||||
* Check that the derivation outputs all exist and register them
|
||||
* as valid.
|
||||
*/
|
||||
virtual SingleDrvOutputs registerOutputs();
|
||||
|
||||
/**
|
||||
* Open a log file and a pipe to it.
|
||||
*/
|
||||
Path openLogFile();
|
||||
|
||||
/**
|
||||
* Sign the newly built realisation if the store allows it
|
||||
*/
|
||||
virtual void signRealisation(Realisation&) {}
|
||||
|
||||
/**
|
||||
* Close the log file.
|
||||
*/
|
||||
void closeLogFile();
|
||||
|
||||
/**
|
||||
* Close the read side of the logger pipe.
|
||||
*/
|
||||
virtual void closeReadPipes();
|
||||
|
||||
/**
|
||||
* Cleanup hooks for buildDone()
|
||||
*/
|
||||
virtual void cleanupHookFinally();
|
||||
virtual void cleanupPreChildKill();
|
||||
virtual void cleanupPostChildKill();
|
||||
virtual bool cleanupDecideWhetherDiskFull();
|
||||
virtual void cleanupPostOutputsRegisteredModeCheck();
|
||||
virtual void cleanupPostOutputsRegisteredModeNonCheck();
|
||||
|
||||
virtual bool isReadDesc(Descriptor fd);
|
||||
bool isReadDesc(Descriptor fd);
|
||||
|
||||
/**
|
||||
* Callback used by the worker to write to the log.
|
||||
@@ -320,7 +247,7 @@ struct DerivationGoal : public Goal
|
||||
/**
|
||||
* Forcibly kill the child process, if any.
|
||||
*/
|
||||
virtual void killChild();
|
||||
void killChild();
|
||||
|
||||
Co repairClosure();
|
||||
|
||||
@@ -331,7 +258,7 @@ struct DerivationGoal : public Goal
|
||||
SingleDrvOutputs builtOutputs = {},
|
||||
std::optional<Error> ex = {});
|
||||
|
||||
void waiteeDone(GoalPtr waitee, ExitCode result) override;
|
||||
void appendLogTailErrorMsg(std::string & msg);
|
||||
|
||||
StorePathSet exportReferences(const StorePathSet & storePaths);
|
||||
|
||||
@@ -340,6 +267,4 @@ struct DerivationGoal : public Goal
|
||||
};
|
||||
};
|
||||
|
||||
MakeError(NotDeterministic, BuildError);
|
||||
|
||||
}
|
||||
Loaded 100 of 201 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user