Compare commits
146
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6935d6c18 | ||
|
|
6cc44e4fdf | ||
|
|
952be9fc96 | ||
|
|
4031343e44 | ||
|
|
0c0a41a81a | ||
|
|
97abcda9cc | ||
|
|
423e732b22 | ||
|
|
05990fb2ec | ||
|
|
6a4a1e9f72 | ||
|
|
1c10ce6047 | ||
|
|
6f33f64ce5 | ||
|
|
801cb16131 | ||
|
|
e91b7d1732 | ||
|
|
ab58d2720c | ||
|
|
c72f3dc27e | ||
|
|
d1470f76c7 | ||
|
|
84079e10cf | ||
|
|
88c9c6d89d | ||
|
|
4f4da90513 | ||
|
|
3e9104c9ca | ||
|
|
3a9be9fd2f | ||
|
|
0275b64b81 | ||
|
|
622a5cd1bf | ||
|
|
b0c016ae7d | ||
|
|
f78e88c973 | ||
|
|
d8d75cff9f | ||
|
|
f198e9a0b3 | ||
|
|
439af1dca1 | ||
|
|
77990e7cca | ||
|
|
3bac0d7aa2 | ||
|
|
36419a6ccb | ||
|
|
3ba51bf61b | ||
|
|
209f413e80 | ||
|
|
b8d32388bc | ||
|
|
eb53e61e08 | ||
|
|
60f09928d1 | ||
|
|
43a183120a | ||
|
|
0c786f3a3c | ||
|
|
504c5e7cf9 | ||
|
|
5d066386b5 | ||
|
|
c7b61f3d13 | ||
|
|
d689b764f3 | ||
|
|
487c6b6c46 | ||
|
|
28fac9fe4d | ||
|
|
2594e417b5 | ||
|
|
76ed967f79 | ||
|
|
327e8babf7 | ||
|
|
d5d4bafc2a | ||
|
|
bd11043c67 | ||
|
|
dbfe6318b3 | ||
|
|
484f40fc64 | ||
|
|
43fc6c314d | ||
|
|
2bbec7d573 | ||
|
|
385d7e77bd | ||
|
|
67f6a24171 | ||
|
|
8cdeab8f2e | ||
|
|
ed176cb42e | ||
|
|
3ff8d0ece4 | ||
|
|
c9fe290b30 | ||
|
|
48c800f7ef | ||
|
|
79dcc094b0 | ||
|
|
be28ad92fd | ||
|
|
a2d6a69d45 | ||
|
|
4307420c44 | ||
|
|
ec0b270c6c | ||
|
|
3f8474a62f | ||
|
|
c7e1c612eb | ||
|
|
a812b6c6e6 | ||
|
|
59a566db13 | ||
|
|
eb654acdd1 | ||
|
|
7cd3252946 | ||
|
|
9b9446e860 | ||
|
|
6c4d2a7d11 | ||
|
|
152e7e48c1 | ||
|
|
ea4854fda1 | ||
|
|
d3ff01cb2e | ||
|
|
a835d6ad2a | ||
|
|
ec3c93f17f | ||
|
|
6d0f4fa666 | ||
|
|
b2ead92791 | ||
|
|
50407ab63e | ||
|
|
7357a654de | ||
|
|
c4906741a1 | ||
|
|
ac36d74b66 | ||
|
|
d17bfe3866 | ||
|
|
437b9b9879 | ||
|
|
5caebab63a | ||
|
|
620a6947ab | ||
|
|
294acfd807 | ||
|
|
19d83d2605 | ||
|
|
70b9fbd76c | ||
|
|
40b25153b8 | ||
|
|
09755e696a | ||
|
|
fa380e0991 | ||
|
|
f7de5b326a | ||
|
|
533cced249 | ||
|
|
8b167ea89b | ||
|
|
76bd600302 | ||
|
|
b975f719b1 | ||
|
|
063cdb5508 | ||
|
|
72dbd43882 | ||
|
|
fb989bd93f | ||
|
|
b309826a48 | ||
|
|
bed0570629 | ||
|
|
ef6dbe76dc | ||
|
|
dfac44cdfb | ||
|
|
36f4e290d0 | ||
|
|
bd0b338e15 | ||
|
|
b3dfe37aea | ||
|
|
87d3c3ba1a | ||
|
|
1e42e55fb4 | ||
|
|
e704b8eeed | ||
|
|
6d65f8eea2 | ||
|
|
f4989b118b | ||
|
|
2de742155a | ||
|
|
09d6847490 | ||
|
|
53af1119fb | ||
|
|
68d2292f3a | ||
|
|
16f0279d4f | ||
|
|
8165419a0c | ||
|
|
7721fa6df4 | ||
|
|
cb5d97a607 | ||
|
|
436bc1f39e | ||
|
|
ae4ed24257 | ||
|
|
fcf3bdcac8 | ||
|
|
4b97f1130a | ||
|
|
614e143a20 | ||
|
|
77982c55b2 | ||
|
|
acacdf87b4 | ||
|
|
d5b6e1a0fc | ||
|
|
3511a919b4 | ||
|
|
f6aa8c0486 | ||
|
|
cd5cac0c40 | ||
|
|
958866b9a6 | ||
|
|
d07c24f4c8 | ||
|
|
95da93c05b | ||
|
|
f8141a2c26 | ||
|
|
bdeaf976bd | ||
|
|
cdba2534cf | ||
|
|
8642c0a9a2 | ||
|
|
70e56a41ce | ||
|
|
a235b454cc | ||
|
|
261f674a25 | ||
|
|
08e218eb0b | ||
|
|
2349c3dbde | ||
|
|
f6aeca0522 |
No files matched your search
@@ -20,7 +20,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
app-id: ${{ vars.CI_APP_ID }}
|
app-id: ${{ vars.CI_APP_ID }}
|
||||||
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
# required to find all branches
|
# required to find all branches
|
||||||
|
|||||||
+10
-10
@@ -24,7 +24,7 @@ jobs:
|
|||||||
eval:
|
eval:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: ./.github/actions/install-nix-action
|
- uses: ./.github/actions/install-nix-action
|
||||||
@@ -40,7 +40,7 @@ jobs:
|
|||||||
name: pre-commit checks
|
name: pre-commit checks
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: ./.github/actions/install-nix-action
|
- uses: ./.github/actions/install-nix-action
|
||||||
with:
|
with:
|
||||||
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
|
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
|
||||||
@@ -87,7 +87,7 @@ jobs:
|
|||||||
runs-on: ${{ matrix.runs-on }}
|
runs-on: ${{ matrix.runs-on }}
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: ./.github/actions/install-nix-action
|
- uses: ./.github/actions/install-nix-action
|
||||||
@@ -162,7 +162,7 @@ jobs:
|
|||||||
name: installer test ${{ matrix.scenario }}
|
name: installer test ${{ matrix.scenario }}
|
||||||
runs-on: ${{ matrix.runs-on }}
|
runs-on: ${{ matrix.runs-on }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- name: Download installer tarball
|
- name: Download installer tarball
|
||||||
uses: actions/download-artifact@v6
|
uses: actions/download-artifact@v6
|
||||||
with:
|
with:
|
||||||
@@ -174,7 +174,7 @@ jobs:
|
|||||||
echo "installer-url=file://$GITHUB_WORKSPACE/out" >> "$GITHUB_OUTPUT"
|
echo "installer-url=file://$GITHUB_WORKSPACE/out" >> "$GITHUB_OUTPUT"
|
||||||
TARBALL_PATH="$(find "$GITHUB_WORKSPACE/out" -name 'nix*.tar.xz' -print | head -n 1)"
|
TARBALL_PATH="$(find "$GITHUB_WORKSPACE/out" -name 'nix*.tar.xz' -print | head -n 1)"
|
||||||
echo "tarball-path=file://$TARBALL_PATH" >> "$GITHUB_OUTPUT"
|
echo "tarball-path=file://$TARBALL_PATH" >> "$GITHUB_OUTPUT"
|
||||||
- uses: cachix/install-nix-action@7ec16f2c061ab07b235a7245e06ed46fe9a1cab6 # v31.8.3
|
- uses: cachix/install-nix-action@0b0e072294b088b73964f1d72dfdac0951439dbd # v31.8.4
|
||||||
if: ${{ !matrix.experimental-installer }}
|
if: ${{ !matrix.experimental-installer }}
|
||||||
with:
|
with:
|
||||||
install_url: ${{ format('{0}/install', steps.installer-tarball-url.outputs.installer-url) }}
|
install_url: ${{ format('{0}/install', steps.installer-tarball-url.outputs.installer-url) }}
|
||||||
@@ -227,7 +227,7 @@ jobs:
|
|||||||
github.ref_name == 'master'
|
github.ref_name == 'master'
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: ./.github/actions/install-nix-action
|
- uses: ./.github/actions/install-nix-action
|
||||||
@@ -276,14 +276,14 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout nix
|
- name: Checkout nix
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
- name: Checkout flake-regressions
|
- name: Checkout flake-regressions
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
repository: NixOS/flake-regressions
|
repository: NixOS/flake-regressions
|
||||||
path: flake-regressions
|
path: flake-regressions
|
||||||
- name: Checkout flake-regressions-data
|
- name: Checkout flake-regressions-data
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
repository: NixOS/flake-regressions-data
|
repository: NixOS/flake-regressions-data
|
||||||
path: flake-regressions/tests
|
path: flake-regressions/tests
|
||||||
@@ -303,7 +303,7 @@ jobs:
|
|||||||
github.event_name == 'push' &&
|
github.event_name == 'push' &&
|
||||||
github.ref_name == 'master'
|
github.ref_name == 'master'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: ./.github/actions/install-nix-action
|
- uses: ./.github/actions/install-nix-action
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ manual = custom_target(
|
|||||||
@0@ @INPUT0@ @CURRENT_SOURCE_DIR@ > @DEPFILE@
|
@0@ @INPUT0@ @CURRENT_SOURCE_DIR@ > @DEPFILE@
|
||||||
@0@ @INPUT1@ summary @2@ < @CURRENT_SOURCE_DIR@/source/SUMMARY.md.in > @2@/source/SUMMARY.md
|
@0@ @INPUT1@ summary @2@ < @CURRENT_SOURCE_DIR@/source/SUMMARY.md.in > @2@/source/SUMMARY.md
|
||||||
sed -e 's|@version@|@3@|g' < @INPUT2@ > @2@/book.toml
|
sed -e 's|@version@|@3@|g' < @INPUT2@ > @2@/book.toml
|
||||||
@4@ -r -L --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
|
@4@ -r -L --exclude='*.drv' --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
|
||||||
(cd @2@; RUST_LOG=warn @1@ build -d @2@ 3>&2 2>&1 1>&3) | { grep -Fv "because fragment resolution isn't implemented" || :; } 3>&2 2>&1 1>&3
|
(cd @2@; RUST_LOG=warn @1@ build -d @2@ 3>&2 2>&1 1>&3) | { grep -Fv "because fragment resolution isn't implemented" || :; } 3>&2 2>&1 1>&3
|
||||||
rm -rf @2@/manual
|
rm -rf @2@/manual
|
||||||
mv @2@/html @2@/manual
|
mv @2@/html @2@/manual
|
||||||
|
|||||||
@@ -37,14 +37,17 @@ mkMesonDerivation (finalAttrs: {
|
|||||||
(fileset.unions [
|
(fileset.unions [
|
||||||
../../.version
|
../../.version
|
||||||
# For example JSON
|
# For example JSON
|
||||||
|
../../src/libutil-tests/data/memory-source-accessor
|
||||||
../../src/libutil-tests/data/hash
|
../../src/libutil-tests/data/hash
|
||||||
../../src/libstore-tests/data/content-address
|
../../src/libstore-tests/data/content-address
|
||||||
../../src/libstore-tests/data/store-path
|
../../src/libstore-tests/data/store-path
|
||||||
../../src/libstore-tests/data/realisation
|
../../src/libstore-tests/data/realisation
|
||||||
|
../../src/libstore-tests/data/derivation
|
||||||
../../src/libstore-tests/data/derived-path
|
../../src/libstore-tests/data/derived-path
|
||||||
../../src/libstore-tests/data/path-info
|
../../src/libstore-tests/data/path-info
|
||||||
../../src/libstore-tests/data/nar-info
|
../../src/libstore-tests/data/nar-info
|
||||||
../../src/libstore-tests/data/build-result
|
../../src/libstore-tests/data/build-result
|
||||||
|
../../src/libstore-tests/data/dummy-store
|
||||||
# Too many different types of files to filter for now
|
# Too many different types of files to filter for now
|
||||||
../../doc/manual
|
../../doc/manual
|
||||||
./.
|
./.
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
synopsis: Fix "download buffer is full; consider increasing the 'download-buffer-size' setting" warning
|
||||||
|
prs: [14614]
|
||||||
|
issues: [11728]
|
||||||
|
---
|
||||||
|
|
||||||
|
The underlying issue that led to [#11728](https://github.com/NixOS/nix/issues/11728) has been resolved by utilizing
|
||||||
|
[libcurl write pausing functionality](https://curl.se/libcurl/c/curl_easy_pause.html) to control backpressure when unpacking to slow destinations like the git-backed tarball cache. The default value of `download-buffer-size` is now 1 MiB and it's no longer recommended to increase it, since the root cause has been fixed.
|
||||||
|
|
||||||
|
This is expected to improve download performance on fast connections, since previously a single slow download consumer would stall the thread and prevent any other transfers from progressing.
|
||||||
|
|
||||||
|
Many thanks go out to the [Lix project](https://lix.systems/) for the [implementation](https://git.lix.systems/lix-project/lix/commit/4ae6fb5a8f0d456b8d2ba2aaca3712b4e49057fc) that served as inspiration for this change and for triaging libcurl [issues with pausing](https://github.com/curl/curl/issues/19334).
|
||||||
@@ -121,14 +121,17 @@
|
|||||||
- [Architecture and Design](architecture/architecture.md)
|
- [Architecture and Design](architecture/architecture.md)
|
||||||
- [Formats and Protocols](protocols/index.md)
|
- [Formats and Protocols](protocols/index.md)
|
||||||
- [JSON Formats](protocols/json/index.md)
|
- [JSON Formats](protocols/json/index.md)
|
||||||
|
- [File System Object](protocols/json/file-system-object.md)
|
||||||
- [Hash](protocols/json/hash.md)
|
- [Hash](protocols/json/hash.md)
|
||||||
- [Content Address](protocols/json/content-address.md)
|
- [Content Address](protocols/json/content-address.md)
|
||||||
- [Store Path](protocols/json/store-path.md)
|
- [Store Path](protocols/json/store-path.md)
|
||||||
- [Store Object Info](protocols/json/store-object-info.md)
|
- [Store Object Info](protocols/json/store-object-info.md)
|
||||||
- [Derivation](protocols/json/derivation.md)
|
- [Derivation](protocols/json/derivation/index.md)
|
||||||
|
- [Derivation Options](protocols/json/derivation/options.md)
|
||||||
- [Deriving Path](protocols/json/deriving-path.md)
|
- [Deriving Path](protocols/json/deriving-path.md)
|
||||||
- [Build Trace Entry](protocols/json/build-trace-entry.md)
|
- [Build Trace Entry](protocols/json/build-trace-entry.md)
|
||||||
- [Build Result](protocols/json/build-result.md)
|
- [Build Result](protocols/json/build-result.md)
|
||||||
|
- [Store](protocols/json/store.md)
|
||||||
- [Serving Tarball Flakes](protocols/tarball-fetcher.md)
|
- [Serving Tarball Flakes](protocols/tarball-fetcher.md)
|
||||||
- [Store Path Specification](protocols/store-path.md)
|
- [Store Path Specification](protocols/store-path.md)
|
||||||
- [Nix Archive (NAR) Format](protocols/nix-archive/index.md)
|
- [Nix Archive (NAR) Format](protocols/nix-archive/index.md)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ to a temporary location. The tarball must include a single top-level
|
|||||||
directory containing at least a file named `default.nix`.
|
directory containing at least a file named `default.nix`.
|
||||||
|
|
||||||
`nix-build` is essentially a wrapper around
|
`nix-build` is essentially a wrapper around
|
||||||
[`nix-instantiate`](nix-instantiate.md) (to translate a high-level Nix
|
[`nix-instantiate`](./nix-instantiate.md) (to translate a high-level Nix
|
||||||
expression to a low-level [store derivation]) and [`nix-store
|
expression to a low-level [store derivation]) and [`nix-store
|
||||||
--realise`](@docroot@/command-ref/nix-store/realise.md) (to build the store
|
--realise`](@docroot@/command-ref/nix-store/realise.md) (to build the store
|
||||||
derivation).
|
derivation).
|
||||||
@@ -52,8 +52,8 @@ derivation).
|
|||||||
# Options
|
# Options
|
||||||
|
|
||||||
All options not listed here are passed to
|
All options not listed here are passed to
|
||||||
[`nix-store --realise`](nix-store/realise.md),
|
[`nix-store --realise`](./nix-store/realise.md),
|
||||||
except for `--arg` and `--attr` / `-A` which are passed to [`nix-instantiate`](nix-instantiate.md).
|
except for `--arg` and `--attr` / `-A` which are passed to [`nix-instantiate`](./nix-instantiate.md).
|
||||||
|
|
||||||
- <span id="opt-no-out-link">[`--no-out-link`](#opt-no-out-link)<span>
|
- <span id="opt-no-out-link">[`--no-out-link`](#opt-no-out-link)<span>
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ standard input.
|
|||||||
|
|
||||||
- `--add-root` *path*
|
- `--add-root` *path*
|
||||||
|
|
||||||
See the [corresponding option](nix-store.md) in `nix-store`.
|
See the [corresponding option](./nix-store.md) in `nix-store`.
|
||||||
|
|
||||||
- `--parse`
|
- `--parse`
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ In the development shell, set the `mesonBuildType` environment variable to `debu
|
|||||||
Then, proceed to build Nix as described in [Building Nix](./building.md).
|
Then, proceed to build Nix as described in [Building Nix](./building.md).
|
||||||
This will build Nix with debug symbols, which are essential for effective debugging.
|
This will build Nix with debug symbols, which are essential for effective debugging.
|
||||||
|
|
||||||
It is also possible to build without debugging for faster build:
|
It is also possible to build without optimization for faster build:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
[nix-shell]$ NIX_HARDENING_ENABLE=$(printLines $NIX_HARDENING_ENABLE | grep -v fortify)
|
[nix-shell]$ NIX_HARDENING_ENABLE=$(printLines $NIX_HARDENING_ENABLE | grep -v fortify)
|
||||||
|
|||||||
@@ -137,6 +137,12 @@ $ _NIX_TEST_ACCEPT=1 meson test nix-store-tests -v
|
|||||||
will regenerate the "golden master" expected result for the `libnixstore` characterisation tests.
|
will regenerate the "golden master" expected result for the `libnixstore` characterisation tests.
|
||||||
The characterisation tests will mark themselves "skipped" since they regenerated the expected result instead of actually testing anything.
|
The characterisation tests will mark themselves "skipped" since they regenerated the expected result instead of actually testing anything.
|
||||||
|
|
||||||
|
### JSON Schema testing
|
||||||
|
|
||||||
|
In `doc/manual/source/protocols/json/` we have a number of manual pages generated from [JSON Schema](https://json-schema.org/).
|
||||||
|
That JSON schema is tested against the JSON file test data used in [characterisation tests](#characterisation-testing-unit ) for JSON (de)serialization, in `src/json-schema-checks`.
|
||||||
|
Between the JSON (de)serialization testing, and this testing of the same data against the schema, we make sure that the manual, the implementation, and a machine-readable schema are are all in sync.
|
||||||
|
|
||||||
### Unit test support libraries
|
### Unit test support libraries
|
||||||
|
|
||||||
There are headers and code which are not just used to test the library in question, but also downstream libraries.
|
There are headers and code which are not just used to test the library in question, but also downstream libraries.
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{{#include derivation-v4-fixed.md}}
|
|
||||||
|
|
||||||
<!-- need to convert YAML to JSON first
|
|
||||||
## Raw Schema
|
|
||||||
|
|
||||||
[JSON Schema for Derivation v3](schema/derivation-v4.json)
|
|
||||||
-->
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{{#include ../derivation-v4-fixed.md}}
|
||||||
|
|
||||||
|
<!-- need to convert YAML to JSON first
|
||||||
|
## Raw Schema
|
||||||
|
|
||||||
|
[JSON Schema for Derivation v4](schema/derivation-v4.json)
|
||||||
|
-->
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
{{#include ../derivation-options-v1-fixed.md}}
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Input-addressed derivations
|
||||||
|
|
||||||
|
#### Default options
|
||||||
|
|
||||||
|
```json
|
||||||
|
{{#include ../schema/derivation-options-v1/ia/defaults.json}}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### All options set
|
||||||
|
|
||||||
|
```json
|
||||||
|
{{#include ../schema/derivation-options-v1/ia/all_set.json}}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Default options (structured attributes)
|
||||||
|
|
||||||
|
```json
|
||||||
|
{{#include ../schema/derivation-options-v1/ia/structuredAttrs_defaults.json}}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### All options set (structured attributes)
|
||||||
|
|
||||||
|
```json
|
||||||
|
{{#include ../schema/derivation-options-v1/ia/structuredAttrs_all_set.json}}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Content-addressed derivations
|
||||||
|
|
||||||
|
#### All options set
|
||||||
|
|
||||||
|
```json
|
||||||
|
{{#include ../schema/derivation-options-v1/ca/all_set.json}}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### All options set (structured attributes)
|
||||||
|
|
||||||
|
```json
|
||||||
|
{{#include ../schema/derivation-options-v1/ca/structuredAttrs_all_set.json}}
|
||||||
|
```
|
||||||
|
|
||||||
|
<!-- need to convert YAML to JSON first
|
||||||
|
## Raw Schema
|
||||||
|
|
||||||
|
[JSON Schema for Derivation Options v1](schema/derivation-options-v1.json)
|
||||||
|
-->
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{{#include file-system-object-v1-fixed.md}}
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Simple
|
||||||
|
|
||||||
|
```json
|
||||||
|
{{#include schema/file-system-object-v1/simple.json}}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Complex
|
||||||
|
|
||||||
|
```json
|
||||||
|
{{#include schema/file-system-object-v1/complex.json}}
|
||||||
|
```
|
||||||
|
|
||||||
|
<!-- need to convert YAML to JSON first
|
||||||
|
## Raw Schema
|
||||||
|
|
||||||
|
[JSON Schema for File System Object v1](schema/file-system-object-v1.json)
|
||||||
|
-->
|
||||||
@@ -11,7 +11,8 @@ s/\\`/`/g
|
|||||||
#
|
#
|
||||||
# As we have more such relative links, more replacements of this nature
|
# As we have more such relative links, more replacements of this nature
|
||||||
# should appear below.
|
# should appear below.
|
||||||
s^\(./hash-v1.yaml\)\?#/$defs/algorithm^[JSON format for `Hash`](./hash.html#algorithm)^g
|
s^#/\$defs/\(regular\|symlink\|directory\)^In this schema^g
|
||||||
s^\(./hash-v1.yaml\)^[JSON format for `Hash`](./hash.html)^g
|
s^\(./hash-v1.yaml\)\?#/$defs/algorithm^[JSON format for `Hash`](@docroot@/protocols/json/hash.html#algorithm)^g
|
||||||
s^\(./content-address-v1.yaml\)\?#/$defs/method^[JSON format for `ContentAddress`](./content-address.html#method)^g
|
s^\(./hash-v1.yaml\)^[JSON format for `Hash`](@docroot@/protocols/json/hash.html)^g
|
||||||
s^\(./content-address-v1.yaml\)^[JSON format for `ContentAddress`](./content-address.html)^g
|
s^\(./content-address-v1.yaml\)\?#/$defs/method^[JSON format for `ContentAddress`](@docroot@/protocols/json/content-address.html#method)^g
|
||||||
|
s^\(./content-address-v1.yaml\)^[JSON format for `ContentAddress`](@docroot@/protocols/json/content-address.html)^g
|
||||||
@@ -9,14 +9,17 @@ json_schema_for_humans = find_program('generate-schema-doc', required : false)
|
|||||||
json_schema_config = files('json-schema-for-humans-config.yaml')
|
json_schema_config = files('json-schema-for-humans-config.yaml')
|
||||||
|
|
||||||
schemas = [
|
schemas = [
|
||||||
|
'file-system-object-v1',
|
||||||
'hash-v1',
|
'hash-v1',
|
||||||
'content-address-v1',
|
'content-address-v1',
|
||||||
'store-path-v1',
|
'store-path-v1',
|
||||||
'store-object-info-v2',
|
'store-object-info-v2',
|
||||||
'derivation-v4',
|
'derivation-v4',
|
||||||
|
'derivation-options-v1',
|
||||||
'deriving-path-v1',
|
'deriving-path-v1',
|
||||||
'build-trace-entry-v1',
|
'build-trace-entry-v1',
|
||||||
'build-result-v1',
|
'build-result-v1',
|
||||||
|
'store-v1',
|
||||||
]
|
]
|
||||||
|
|
||||||
schema_files = files()
|
schema_files = files()
|
||||||
|
|||||||
@@ -4,71 +4,97 @@ title: Build Trace Entry
|
|||||||
description: |
|
description: |
|
||||||
A record of a successful build outcome for a specific derivation output.
|
A record of a successful build outcome for a specific derivation output.
|
||||||
|
|
||||||
This schema describes the JSON representation of a [build trace entry](@docroot@/store/build-trace.md) entry.
|
This schema describes the JSON representation of a [build trace entry](@docroot@/store/build-trace.md).
|
||||||
|
|
||||||
> **Warning**
|
> **Warning**
|
||||||
>
|
>
|
||||||
> This JSON format is currently
|
> This JSON format is currently
|
||||||
> [**experimental**](@docroot@/development/experimental-features.md#xp-feature-ca-derivations)
|
> [**experimental**](@docroot@/development/experimental-features.md#xp-feature-ca-derivations)
|
||||||
> and subject to change.
|
> and subject to change.
|
||||||
|
|
||||||
type: object
|
|
||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
- outPath
|
- outPath
|
||||||
- dependentRealisations
|
- dependentRealisations
|
||||||
- signatures
|
- signatures
|
||||||
|
allOf:
|
||||||
|
- "$ref": "#/$defs/key"
|
||||||
|
- "$ref": "#/$defs/value"
|
||||||
properties:
|
properties:
|
||||||
id:
|
id: {}
|
||||||
type: string
|
outPath: {}
|
||||||
title: Derivation Output ID
|
dependentRealisations: {}
|
||||||
pattern: "^sha256:[0-9a-f]{64}![a-zA-Z_][a-zA-Z0-9_-]*$"
|
signatures: {}
|
||||||
description: |
|
|
||||||
Unique identifier for the derivation output that was built.
|
|
||||||
|
|
||||||
Format: `{hash-quotient-drv}!{output-name}`
|
|
||||||
|
|
||||||
- **hash-quotient-drv**: SHA-256 [hash of the quotient derivation](@docroot@/store/derivation/outputs/input-address.md#hash-quotient-drv).
|
|
||||||
Begins with `sha256:`.
|
|
||||||
|
|
||||||
- **output-name**: Name of the specific output (e.g., "out", "dev", "doc")
|
|
||||||
|
|
||||||
Example: `"sha256:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad!foo"`
|
|
||||||
|
|
||||||
outPath:
|
|
||||||
"$ref": "store-path-v1.yaml"
|
|
||||||
title: Output Store Path
|
|
||||||
description: |
|
|
||||||
The path to the store object that resulted from building this derivation for the given output name.
|
|
||||||
|
|
||||||
dependentRealisations:
|
|
||||||
type: object
|
|
||||||
title: Underlying Base Build Trace
|
|
||||||
description: |
|
|
||||||
This is for [*derived*](@docroot@/store/build-trace.md#derived) build trace entries to ensure coherence.
|
|
||||||
|
|
||||||
Keys are derivation output IDs (same format as the main `id` field).
|
|
||||||
Values are the store paths that those dependencies resolved to.
|
|
||||||
|
|
||||||
As described in the linked section on derived build trace traces, derived build trace entries must be kept in addition and not instead of the underlying base build entries.
|
|
||||||
This is the set of base build trace entries that this derived build trace is derived from.
|
|
||||||
(The set is also a map since this miniature base build trace must be coherent, mapping each key to a single value.)
|
|
||||||
|
|
||||||
patternProperties:
|
|
||||||
"^sha256:[0-9a-f]{64}![a-zA-Z_][a-zA-Z0-9_-]*$":
|
|
||||||
$ref: "store-path-v1.yaml"
|
|
||||||
title: Dependent Store Path
|
|
||||||
description: Store path that this dependency resolved to during the build
|
|
||||||
additionalProperties: false
|
|
||||||
|
|
||||||
signatures:
|
|
||||||
type: array
|
|
||||||
title: Build Signatures
|
|
||||||
description: |
|
|
||||||
A set of cryptographic signatures attesting to the authenticity of this build trace entry.
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
title: Signature
|
|
||||||
description: A single cryptographic signature
|
|
||||||
|
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
|
|
||||||
|
"$defs":
|
||||||
|
key:
|
||||||
|
title: Build Trace Key
|
||||||
|
description: |
|
||||||
|
A [build trace entry](@docroot@/store/build-trace.md) is a key-value pair.
|
||||||
|
This is the "key" part, refering to a derivation and output.
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
title: Derivation Output ID
|
||||||
|
pattern: "^sha256:[0-9a-f]{64}![a-zA-Z_][a-zA-Z0-9_-]*$"
|
||||||
|
description: |
|
||||||
|
Unique identifier for the derivation output that was built.
|
||||||
|
|
||||||
|
Format: `{hash-quotient-drv}!{output-name}`
|
||||||
|
|
||||||
|
- **hash-quotient-drv**: SHA-256 [hash of the quotient derivation](@docroot@/store/derivation/outputs/input-address.md#hash-quotient-drv).
|
||||||
|
Begins with `sha256:`.
|
||||||
|
|
||||||
|
- **output-name**: Name of the specific output (e.g., "out", "dev", "doc")
|
||||||
|
|
||||||
|
Example: `"sha256:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad!foo"`
|
||||||
|
|
||||||
|
value:
|
||||||
|
title: Build Trace Value
|
||||||
|
description: |
|
||||||
|
A [build trace entry](@docroot@/store/build-trace.md) is a key-value pair.
|
||||||
|
This is the "value" part, describing an output.
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- outPath
|
||||||
|
- dependentRealisations
|
||||||
|
- signatures
|
||||||
|
properties:
|
||||||
|
outPath:
|
||||||
|
"$ref": "store-path-v1.yaml"
|
||||||
|
title: Output Store Path
|
||||||
|
description: |
|
||||||
|
The path to the store object that resulted from building this derivation for the given output name.
|
||||||
|
|
||||||
|
dependentRealisations:
|
||||||
|
type: object
|
||||||
|
title: Underlying Base Build Trace
|
||||||
|
description: |
|
||||||
|
This is for [*derived*](@docroot@/store/build-trace.md#derived) build trace entries to ensure coherence.
|
||||||
|
|
||||||
|
Keys are derivation output IDs (same format as the main `id` field).
|
||||||
|
Values are the store paths that those dependencies resolved to.
|
||||||
|
|
||||||
|
As described in the linked section on derived build trace traces, derived build trace entries must be kept in addition and not instead of the underlying base build entries.
|
||||||
|
This is the set of base build trace entries that this derived build trace is derived from.
|
||||||
|
(The set is also a map since this miniature base build trace must be coherent, mapping each key to a single value.)
|
||||||
|
|
||||||
|
patternProperties:
|
||||||
|
"^sha256:[0-9a-f]{64}![a-zA-Z_][a-zA-Z0-9_-]*$":
|
||||||
|
"$ref": "store-path-v1.yaml"
|
||||||
|
title: Dependent Store Path
|
||||||
|
description: Store path that this dependency resolved to during the build
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
signatures:
|
||||||
|
type: array
|
||||||
|
title: Build Signatures
|
||||||
|
description: |
|
||||||
|
A set of cryptographic signatures attesting to the authenticity of this build trace entry.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
title: Signature
|
||||||
|
description: A single cryptographic signature
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../../../../src/libstore-tests/data/derivation
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
"$schema": "http://json-schema.org/draft-04/schema"
|
||||||
|
"$id": "https://nix.dev/manual/nix/latest/protocols/json/schema/derivation-options-v1.json"
|
||||||
|
title: Derivation Options
|
||||||
|
description: |
|
||||||
|
JSON representation of Nix's `DerivationOptions` type.
|
||||||
|
|
||||||
|
This schema describes various build-time options and constraints that can be specified for a derivation.
|
||||||
|
|
||||||
|
> **Warning**
|
||||||
|
>
|
||||||
|
> This JSON format is currently
|
||||||
|
> [**experimental**](@docroot@/development/experimental-features.md#xp-feature-nix-command)
|
||||||
|
> and subject to change.
|
||||||
|
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- outputChecks
|
||||||
|
- unsafeDiscardReferences
|
||||||
|
- passAsFile
|
||||||
|
- exportReferencesGraph
|
||||||
|
- additionalSandboxProfile
|
||||||
|
- noChroot
|
||||||
|
- impureHostDeps
|
||||||
|
- impureEnvVars
|
||||||
|
- allowLocalNetworking
|
||||||
|
- requiredSystemFeatures
|
||||||
|
- preferLocalBuild
|
||||||
|
- allowSubstitutes
|
||||||
|
properties:
|
||||||
|
outputChecks:
|
||||||
|
type: object
|
||||||
|
title: Output Check
|
||||||
|
description: |
|
||||||
|
Constraints on what the derivation's outputs can and cannot reference.
|
||||||
|
Can either apply to all outputs or be specified per output.
|
||||||
|
oneOf:
|
||||||
|
- title: Output Checks For All Outputs
|
||||||
|
description: |
|
||||||
|
Output checks that apply to all outputs of the derivation.
|
||||||
|
required:
|
||||||
|
- forAllOutputs
|
||||||
|
properties:
|
||||||
|
forAllOutputs:
|
||||||
|
"$ref": "#/$defs/outputCheckSpec"
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
- title: Output Checks Per Output
|
||||||
|
description: |
|
||||||
|
Output checks specified individually for each output.
|
||||||
|
required:
|
||||||
|
- perOutput
|
||||||
|
properties:
|
||||||
|
perOutput:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
"$ref": "#/$defs/outputCheckSpec"
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
unsafeDiscardReferences:
|
||||||
|
type: object
|
||||||
|
title: Unsafe Discard References
|
||||||
|
description: |
|
||||||
|
A map specifying which references should be unsafely discarded from each output.
|
||||||
|
This is generally not recommended and requires special permissions.
|
||||||
|
additionalProperties:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
|
||||||
|
passAsFile:
|
||||||
|
type: array
|
||||||
|
title: Pass As File
|
||||||
|
description: |
|
||||||
|
List of environment variable names whose values should be passed as files rather than directly.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
|
||||||
|
exportReferencesGraph:
|
||||||
|
type: object
|
||||||
|
title: Export References Graph
|
||||||
|
description: |
|
||||||
|
Specify paths whose references graph should be exported to files.
|
||||||
|
additionalProperties:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
"$ref": "deriving-path-v1.yaml"
|
||||||
|
|
||||||
|
additionalSandboxProfile:
|
||||||
|
type: string
|
||||||
|
title: Additional Sandbox Profile
|
||||||
|
description: |
|
||||||
|
Additional sandbox profile directives (macOS specific).
|
||||||
|
|
||||||
|
noChroot:
|
||||||
|
type: boolean
|
||||||
|
title: No Chroot
|
||||||
|
description: |
|
||||||
|
Whether to disable the build sandbox, if allowed.
|
||||||
|
|
||||||
|
impureHostDeps:
|
||||||
|
type: array
|
||||||
|
title: Impure Host Dependencies
|
||||||
|
description: |
|
||||||
|
List of host paths that the build can access.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
|
||||||
|
impureEnvVars:
|
||||||
|
type: array
|
||||||
|
title: Impure Environment Variables
|
||||||
|
description: |
|
||||||
|
List of environment variable names that should be passed through to the build from the calling environment.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
|
||||||
|
allowLocalNetworking:
|
||||||
|
type: boolean
|
||||||
|
title: Allow Local Networking
|
||||||
|
description: |
|
||||||
|
Whether the build should have access to local network (macOS specific).
|
||||||
|
|
||||||
|
requiredSystemFeatures:
|
||||||
|
type: array
|
||||||
|
title: Required System Features
|
||||||
|
description: |
|
||||||
|
List of system features required to build this derivation (e.g., "kvm", "nixos-test").
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
|
||||||
|
preferLocalBuild:
|
||||||
|
type: boolean
|
||||||
|
title: Prefer Local Build
|
||||||
|
description: |
|
||||||
|
Whether this derivation should preferably be built locally rather than its outputs substituted.
|
||||||
|
|
||||||
|
allowSubstitutes:
|
||||||
|
type: boolean
|
||||||
|
title: Allow Substitutes
|
||||||
|
description: |
|
||||||
|
Whether substituting from other stores should be allowed for this derivation's outputs.
|
||||||
|
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
$defs:
|
||||||
|
|
||||||
|
outputCheckSpec:
|
||||||
|
type: object
|
||||||
|
title: Output Check Specification
|
||||||
|
description: |
|
||||||
|
Constraints on what a specific output can reference.
|
||||||
|
required:
|
||||||
|
- ignoreSelfRefs
|
||||||
|
- maxSize
|
||||||
|
- maxClosureSize
|
||||||
|
- allowedReferences
|
||||||
|
- allowedRequisites
|
||||||
|
- disallowedReferences
|
||||||
|
- disallowedRequisites
|
||||||
|
properties:
|
||||||
|
ignoreSelfRefs:
|
||||||
|
type: boolean
|
||||||
|
title: Ignore Self References
|
||||||
|
description: |
|
||||||
|
Whether references from this output to itself should be ignored when checking references.
|
||||||
|
|
||||||
|
maxSize:
|
||||||
|
type: ["integer", "null"]
|
||||||
|
title: Maximum Size
|
||||||
|
description: |
|
||||||
|
Maximum allowed size of this output in bytes, or null for no limit.
|
||||||
|
minimum: 0
|
||||||
|
|
||||||
|
maxClosureSize:
|
||||||
|
type: ["integer", "null"]
|
||||||
|
title: Maximum Closure Size
|
||||||
|
description: |
|
||||||
|
Maximum allowed size of this output's closure in bytes, or null for no limit.
|
||||||
|
minimum: 0
|
||||||
|
|
||||||
|
allowedReferences:
|
||||||
|
oneOf:
|
||||||
|
- type: array
|
||||||
|
items:
|
||||||
|
"$ref": "#/$defs/drvRef"
|
||||||
|
- type: "null"
|
||||||
|
title: Allowed References
|
||||||
|
description: |
|
||||||
|
If set, the output can only reference paths in this list.
|
||||||
|
If null, no restrictions apply.
|
||||||
|
|
||||||
|
allowedRequisites:
|
||||||
|
oneOf:
|
||||||
|
- type: array
|
||||||
|
items:
|
||||||
|
"$ref": "#/$defs/drvRef"
|
||||||
|
- type: "null"
|
||||||
|
title: Allowed Requisites
|
||||||
|
description: |
|
||||||
|
If set, the output's closure can only contain paths in this list.
|
||||||
|
If null, no restrictions apply.
|
||||||
|
|
||||||
|
disallowedReferences:
|
||||||
|
type: array
|
||||||
|
title: Disallowed References
|
||||||
|
description: |
|
||||||
|
The output must not reference any paths in this list.
|
||||||
|
items:
|
||||||
|
"$ref": "#/$defs/drvRef"
|
||||||
|
|
||||||
|
disallowedRequisites:
|
||||||
|
type: array
|
||||||
|
title: Disallowed Requisites
|
||||||
|
description: |
|
||||||
|
The output's closure must not contain any paths in this list.
|
||||||
|
items:
|
||||||
|
"$ref": "#/$defs/drvRef"
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
drvRef:
|
||||||
|
# TODO fix bug in checker, should be `oneOf`
|
||||||
|
anyOf:
|
||||||
|
- type: object
|
||||||
|
title: Current derivation Output Reference
|
||||||
|
description: |
|
||||||
|
A reference to a specific output of the current derivation.
|
||||||
|
required:
|
||||||
|
- drvPath
|
||||||
|
- output
|
||||||
|
properties:
|
||||||
|
drvPath:
|
||||||
|
type: string
|
||||||
|
const: "self"
|
||||||
|
title: This derivation
|
||||||
|
description: |
|
||||||
|
Won't be confused for a deriving path
|
||||||
|
output:
|
||||||
|
type: string
|
||||||
|
title: Output Name
|
||||||
|
description: |
|
||||||
|
The name of the output being referenced.
|
||||||
|
additionalProperties: false
|
||||||
|
- "$ref": "deriving-path-v1.yaml"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../../../../src/libutil-tests/data/memory-source-accessor
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
"$schema": http://json-schema.org/draft-04/schema#
|
||||||
|
"$id": https://nix.dev/manual/nix/latest/protocols/json/schema/file-system-object-v1.json
|
||||||
|
title: File System Object
|
||||||
|
description: |
|
||||||
|
This schema describes the JSON representation of Nix's [File System Object](@docroot@/store/file-system-object.md).
|
||||||
|
|
||||||
|
The schema is recursive because file system objects contain other file system objects.
|
||||||
|
type: object
|
||||||
|
required: ["type"]
|
||||||
|
properties:
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
enum: ["regular", "symlink", "directory"]
|
||||||
|
|
||||||
|
# Enforce conditional structure based on `type`
|
||||||
|
anyOf:
|
||||||
|
- $ref: "#/$defs/regular"
|
||||||
|
required: ["type", "contents"]
|
||||||
|
|
||||||
|
- $ref: "#/$defs/directory"
|
||||||
|
required: ["type", "entries"]
|
||||||
|
|
||||||
|
- $ref: "#/$defs/symlink"
|
||||||
|
required: ["type", "target"]
|
||||||
|
|
||||||
|
"$defs":
|
||||||
|
regular:
|
||||||
|
title: Regular File
|
||||||
|
description: |
|
||||||
|
See [Regular File](@docroot@/store/file-system-object.md#regular) in the manual for details.
|
||||||
|
required: ["contents"]
|
||||||
|
properties:
|
||||||
|
type:
|
||||||
|
const: "regular"
|
||||||
|
contents:
|
||||||
|
type: string
|
||||||
|
description: File contents
|
||||||
|
executable:
|
||||||
|
type: boolean
|
||||||
|
description: Whether the file is executable.
|
||||||
|
default: false
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
directory:
|
||||||
|
title: Directory
|
||||||
|
description: |
|
||||||
|
See [Directory](@docroot@/store/file-system-object.md#directory) in the manual for details.
|
||||||
|
required: ["entries"]
|
||||||
|
properties:
|
||||||
|
type:
|
||||||
|
const: "directory"
|
||||||
|
entries:
|
||||||
|
type: object
|
||||||
|
description: |
|
||||||
|
Map of names to nested file system objects (for type=directory)
|
||||||
|
additionalProperties:
|
||||||
|
$ref: "#"
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
symlink:
|
||||||
|
title: Symbolic Link
|
||||||
|
description: |
|
||||||
|
See [Symbolic Link](@docroot@/store/file-system-object.md#symlink) in the manual for details.
|
||||||
|
required: ["target"]
|
||||||
|
properties:
|
||||||
|
type:
|
||||||
|
const: "symlink"
|
||||||
|
target:
|
||||||
|
type: string
|
||||||
|
description: Target path of the symlink.
|
||||||
|
additionalProperties: false
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../../../../../src/libstore-tests/data/dummy-store
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
"$schema": "http://json-schema.org/draft-04/schema"
|
||||||
|
"$id": "https://nix.dev/manual/nix/latest/protocols/json/schema/store-v1.json"
|
||||||
|
title: Store
|
||||||
|
description: |
|
||||||
|
Experimental JSON representation of a Nix [Store](@docroot@/store/index.md).
|
||||||
|
|
||||||
|
This schema describes the JSON serialization of a Nix store.
|
||||||
|
We use it for (de)serializing in-memory "dummy stores" used for testing, but in principle the data represented in this schema could live in any type of store.
|
||||||
|
|
||||||
|
> **Warning**
|
||||||
|
>
|
||||||
|
> This JSON format is currently
|
||||||
|
> [**experimental**](@docroot@/development/experimental-features.md#xp-feature-nix-command)
|
||||||
|
> and subject to change.
|
||||||
|
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- config
|
||||||
|
- contents
|
||||||
|
- derivations
|
||||||
|
- buildTrace
|
||||||
|
properties:
|
||||||
|
config:
|
||||||
|
"$ref": "#/$defs/storeConfig"
|
||||||
|
|
||||||
|
contents:
|
||||||
|
type: object
|
||||||
|
title: Store Objects
|
||||||
|
description: |
|
||||||
|
Map of [store path](@docroot@/store/store-path.md) base names to [store objects](@docroot@/store/store-object.md).
|
||||||
|
patternProperties:
|
||||||
|
"^[0123456789abcdfghijklmnpqrsvwxyz]{32}-.+$":
|
||||||
|
type: object
|
||||||
|
title: Store Object
|
||||||
|
required:
|
||||||
|
- info
|
||||||
|
- contents
|
||||||
|
properties:
|
||||||
|
info:
|
||||||
|
"$ref": "./store-object-info-v2.yaml#/$defs/impure"
|
||||||
|
title: Store Object Info
|
||||||
|
description: |
|
||||||
|
Metadata about the [store object](@docroot@/store/store-object.md) including hash, size, references, etc.
|
||||||
|
contents:
|
||||||
|
"$ref": "./file-system-object-v1.yaml"
|
||||||
|
title: File System Object Contents
|
||||||
|
description: |
|
||||||
|
The actual [file system object](@docroot@/store/file-system-object.md) contents of this store path.
|
||||||
|
additionalProperties: false
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
derivations:
|
||||||
|
type: object
|
||||||
|
title: Derivations
|
||||||
|
description: |
|
||||||
|
Map of [store path](@docroot@/store/store-path.md) base names (always ending in `.drv`) to [derivations](@docroot@/store/derivation/index.md).
|
||||||
|
patternProperties:
|
||||||
|
"^[0123456789abcdfghijklmnpqrsvwxyz]{32}-.+\\.drv$":
|
||||||
|
"$ref": "./derivation-v4.yaml"
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
buildTrace:
|
||||||
|
type: object
|
||||||
|
title: Build Trace
|
||||||
|
description: |
|
||||||
|
Map of output hashes (base64 SHA256) to maps of output names to realisations.
|
||||||
|
Records which outputs have been built and their realisations.
|
||||||
|
See [Build Trace](@docroot@/store/build-trace.md) for more details.
|
||||||
|
patternProperties:
|
||||||
|
"^[A-Za-z0-9+/]{43}=$":
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
"$ref": "./build-trace-entry-v1.yaml#/$defs/value"
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
"$defs":
|
||||||
|
storeConfig:
|
||||||
|
title: Store Configuration
|
||||||
|
description: |
|
||||||
|
Configuration for the store, including the store directory path.
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- store
|
||||||
|
properties:
|
||||||
|
store:
|
||||||
|
type: string
|
||||||
|
title: Store Directory
|
||||||
|
description: |
|
||||||
|
The store directory path (e.g., `/nix/store`).
|
||||||
|
additionalProperties: false
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{{#include store-v1-fixed.md}}
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Empty store
|
||||||
|
|
||||||
|
```json
|
||||||
|
{{#include schema/store-v1/empty.json}}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Store with one file
|
||||||
|
|
||||||
|
```json
|
||||||
|
{{#include schema/store-v1/one-flat-file.json}}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Store with one derivation
|
||||||
|
|
||||||
|
```json
|
||||||
|
{{#include schema/store-v1/one-derivation.json}}
|
||||||
|
```
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
We ultimately want to rectify this issue with all JSON formats to the extent allowed by our stability promises. To start with, we are changing the JSON format for derivations because the `nix derivation` commands are — in addition to being formally unstable — less widely used than other unstable commands.
|
We ultimately want to rectify this issue with all JSON formats to the extent allowed by our stability promises. To start with, we are changing the JSON format for derivations because the `nix derivation` commands are — in addition to being formally unstable — less widely used than other unstable commands.
|
||||||
|
|
||||||
See the documentation on the [JSON format for derivations](@docroot@/protocols/json/derivation.md) for further details.
|
See the documentation on the [JSON format for derivations](@docroot@/protocols/json/derivation/index.md) for further details.
|
||||||
|
|
||||||
- C API: `nix_get_attr_name_byidx`, `nix_get_attr_byidx` take a `nix_value *` instead of `const nix_value *` [#13987](https://github.com/NixOS/nix/pull/13987)
|
- C API: `nix_get_attr_name_byidx`, `nix_get_attr_byidx` take a `nix_value *` instead of `const nix_value *` [#13987](https://github.com/NixOS/nix/pull/13987)
|
||||||
|
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ There are two formats, documented separately:
|
|||||||
|
|
||||||
- The legacy ["ATerm" format](@docroot@/protocols/derivation-aterm.md)
|
- The legacy ["ATerm" format](@docroot@/protocols/derivation-aterm.md)
|
||||||
|
|
||||||
- The experimental, currently under development and changing [JSON format](@docroot@/protocols/json/derivation.md)
|
- The experimental, currently under development and changing [JSON format](@docroot@/protocols/json/derivation/index.md)
|
||||||
|
|
||||||
Every derivation has a canonical choice of encoding used to serialize it to a store object.
|
Every derivation has a canonical choice of encoding used to serialize it to a store object.
|
||||||
This ensures that there is a canonical [store path] used to refer to the derivation, as described in [Referencing derivations](#derivation-path).
|
This ensures that there is a canonical [store path] used to refer to the derivation, as described in [Referencing derivations](#derivation-path).
|
||||||
|
|||||||
@@ -3,19 +3,23 @@
|
|||||||
Nix uses a simplified model of the file system, which consists of file system objects.
|
Nix uses a simplified model of the file system, which consists of file system objects.
|
||||||
Every file system object is one of the following:
|
Every file system object is one of the following:
|
||||||
|
|
||||||
- File
|
- [**Regular File**]{#regular}
|
||||||
|
|
||||||
- A possibly empty sequence of bytes for contents
|
- A possibly empty sequence of bytes for contents
|
||||||
- A single boolean representing the [executable](https://en.m.wikipedia.org/wiki/File-system_permissions#Permissions) permission
|
- A single boolean representing the [executable](https://en.m.wikipedia.org/wiki/File-system_permissions#Permissions) permission
|
||||||
|
|
||||||
- Directory
|
- [**Directory**]{#directory}
|
||||||
|
|
||||||
Mapping of names to child file system objects
|
Mapping of names to child file system objects
|
||||||
|
|
||||||
- [Symbolic link](https://en.m.wikipedia.org/wiki/Symbolic_link)
|
- [**Symbolic link**]{#symlink}
|
||||||
|
|
||||||
An arbitrary string.
|
An arbitrary string, known as the *target* of the symlink.
|
||||||
Nix does not assign any semantics to symbolic links.
|
|
||||||
|
In general, Nix does not assign any semantics to symbolic links.
|
||||||
|
Certain operations however, may make additional assumptions and attempt to use the target to find another file system object.
|
||||||
|
|
||||||
|
> See [the Wikpedia article on symbolic links](https://en.m.wikipedia.org/wiki/Symbolic_link) for background information if you are unfamiliar with this Unix concept.
|
||||||
|
|
||||||
File system objects and their children form a tree.
|
File system objects and their children form a tree.
|
||||||
A bare file or symlink can be a root file system object.
|
A bare file or symlink can be a root file system object.
|
||||||
|
|||||||
@@ -79,6 +79,8 @@
|
|||||||
# Not supported by nixfmt
|
# Not supported by nixfmt
|
||||||
''^tests/functional/lang/eval-okay-deprecate-cursed-or\.nix$''
|
''^tests/functional/lang/eval-okay-deprecate-cursed-or\.nix$''
|
||||||
''^tests/functional/lang/eval-okay-attrs5\.nix$''
|
''^tests/functional/lang/eval-okay-attrs5\.nix$''
|
||||||
|
''^tests/functional/lang/eval-fail-dynamic-attrs-inherit\.nix$''
|
||||||
|
''^tests/functional/lang/eval-fail-dynamic-attrs-inherit-2\.nix$''
|
||||||
|
|
||||||
# More syntax tests
|
# More syntax tests
|
||||||
# These tests, or parts of them, should have been parse-* test cases.
|
# These tests, or parts of them, should have been parse-* test cases.
|
||||||
|
|||||||
+22
-16
@@ -130,15 +130,19 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
|
|||||||
havePerl = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform.isUnix;
|
havePerl = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform.isUnix;
|
||||||
ignoreCrossFile = flags: builtins.filter (flag: !(lib.strings.hasInfix "cross-file" flag)) flags;
|
ignoreCrossFile = flags: builtins.filter (flag: !(lib.strings.hasInfix "cross-file" flag)) flags;
|
||||||
|
|
||||||
|
availableComponents = lib.filterAttrs (
|
||||||
|
k: v: lib.meta.availableOn pkgs.hostPlatform v
|
||||||
|
) allComponents;
|
||||||
|
|
||||||
activeComponents = buildInputsClosureCond isInternal (
|
activeComponents = buildInputsClosureCond isInternal (
|
||||||
lib.attrValues (finalAttrs.passthru.config.getComponents allComponents)
|
lib.attrValues (finalAttrs.passthru.config.getComponents availableComponents)
|
||||||
);
|
);
|
||||||
|
|
||||||
allComponents = lib.filterAttrs (k: v: lib.isDerivation v) pkgs.nixComponents2;
|
allComponents = lib.filterAttrs (k: v: lib.isDerivation v) pkgs.nixComponents2;
|
||||||
internalDrvs = byDrvPath (
|
internalDrvs = byDrvPath (
|
||||||
# Drop the attr names (not present in buildInputs anyway)
|
# Drop the attr names (not present in buildInputs anyway)
|
||||||
lib.attrValues allComponents
|
lib.attrValues availableComponents
|
||||||
++ lib.concatMap (c: lib.attrValues c.tests or { }) (lib.attrValues allComponents)
|
++ lib.concatMap (c: lib.attrValues c.tests or { }) (lib.attrValues availableComponents)
|
||||||
);
|
);
|
||||||
|
|
||||||
isInternal =
|
isInternal =
|
||||||
@@ -187,19 +191,19 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
|
|||||||
);
|
);
|
||||||
|
|
||||||
small =
|
small =
|
||||||
(finalAttrs.finalPackage.withActiveComponents (c: {
|
(finalAttrs.finalPackage.withActiveComponents (
|
||||||
inherit (c)
|
c:
|
||||||
nix-cli
|
lib.intersectAttrs (lib.genAttrs [
|
||||||
nix-util-tests
|
"nix-cli"
|
||||||
nix-store-tests
|
"nix-util-tests"
|
||||||
nix-expr-tests
|
"nix-store-tests"
|
||||||
nix-fetchers-tests
|
"nix-expr-tests"
|
||||||
nix-flake-tests
|
"nix-fetchers-tests"
|
||||||
nix-functional-tests
|
"nix-flake-tests"
|
||||||
# Currently required
|
"nix-functional-tests"
|
||||||
nix-perl-bindings
|
"nix-perl-bindings"
|
||||||
;
|
] (_: null)) c
|
||||||
})).overrideAttrs
|
)).overrideAttrs
|
||||||
(o: {
|
(o: {
|
||||||
mesonFlags = o.mesonFlags ++ [
|
mesonFlags = o.mesonFlags ++ [
|
||||||
# TODO: infer from activeComponents or vice versa
|
# TODO: infer from activeComponents or vice versa
|
||||||
@@ -269,6 +273,8 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
|
|||||||
CXX_LD = "mold";
|
CXX_LD = "mold";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dontUseCmakeConfigure = true;
|
||||||
|
|
||||||
mesonFlags =
|
mesonFlags =
|
||||||
map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents2.nix-util.mesonFlags)
|
map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents2.nix-util.mesonFlags)
|
||||||
++ map (transformFlag "libstore") (ignoreCrossFile pkgs.nixComponents2.nix-store.mesonFlags)
|
++ map (transformFlag "libstore") (ignoreCrossFile pkgs.nixComponents2.nix-store.mesonFlags)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
../libstore-tests/data/derivation
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
../../src/libutil-tests/data/memory-source-accessor
|
||||||
@@ -20,6 +20,14 @@ schema_dir = meson.current_source_dir() / 'schema'
|
|||||||
|
|
||||||
# Get all example files
|
# Get all example files
|
||||||
schemas = [
|
schemas = [
|
||||||
|
{
|
||||||
|
'stem' : 'file-system-object',
|
||||||
|
'schema' : schema_dir / 'file-system-object-v1.yaml',
|
||||||
|
'files' : [
|
||||||
|
'simple.json',
|
||||||
|
'complex.json',
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'stem' : 'hash',
|
'stem' : 'hash',
|
||||||
'schema' : schema_dir / 'hash-v1.yaml',
|
'schema' : schema_dir / 'hash-v1.yaml',
|
||||||
@@ -63,6 +71,18 @@ schemas = [
|
|||||||
'with-signature.json',
|
'with-signature.json',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'stem' : 'derivation-options',
|
||||||
|
'schema' : schema_dir / 'derivation-options-v1.yaml',
|
||||||
|
'files' : [
|
||||||
|
'ia' / 'defaults.json',
|
||||||
|
'ia' / 'all_set.json',
|
||||||
|
'ia' / 'structuredAttrs_defaults.json',
|
||||||
|
'ia' / 'structuredAttrs_all_set.json',
|
||||||
|
'ca' / 'all_set.json',
|
||||||
|
'ca' / 'structuredAttrs_all_set.json',
|
||||||
|
],
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
# Derivation and Derivation output
|
# Derivation and Derivation output
|
||||||
@@ -192,6 +212,19 @@ schemas += [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Dummy store
|
||||||
|
schemas += [
|
||||||
|
{
|
||||||
|
'stem' : 'store',
|
||||||
|
'schema' : schema_dir / 'store-v1.yaml',
|
||||||
|
'files' : [
|
||||||
|
'empty.json',
|
||||||
|
'one-flat-file.json',
|
||||||
|
'one-derivation.json',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
# Validate each example against the schema
|
# Validate each example against the schema
|
||||||
foreach schema : schemas
|
foreach schema : schemas
|
||||||
stem = schema['stem']
|
stem = schema['stem']
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ mkMesonDerivation (finalAttrs: {
|
|||||||
fileset = lib.fileset.unions [
|
fileset = lib.fileset.unions [
|
||||||
../../.version
|
../../.version
|
||||||
../../doc/manual/source/protocols/json/schema
|
../../doc/manual/source/protocols/json/schema
|
||||||
|
../../src/libutil-tests/data/memory-source-accessor
|
||||||
../../src/libutil-tests/data/hash
|
../../src/libutil-tests/data/hash
|
||||||
../../src/libstore-tests/data/content-address
|
../../src/libstore-tests/data/content-address
|
||||||
../../src/libstore-tests/data/store-path
|
../../src/libstore-tests/data/store-path
|
||||||
@@ -29,6 +30,7 @@ mkMesonDerivation (finalAttrs: {
|
|||||||
../../src/libstore-tests/data/path-info
|
../../src/libstore-tests/data/path-info
|
||||||
../../src/libstore-tests/data/nar-info
|
../../src/libstore-tests/data/nar-info
|
||||||
../../src/libstore-tests/data/build-result
|
../../src/libstore-tests/data/build-result
|
||||||
|
../../src/libstore-tests/data/dummy-store
|
||||||
./.
|
./.
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
../../src/libstore-tests/data/dummy-store
|
||||||
@@ -65,6 +65,6 @@ mkMesonDerivation (finalAttrs: {
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
platforms = lib.platforms.all;
|
platforms = lib.platforms.unix;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
@@ -297,7 +297,7 @@ void MixProfile::updateProfile(const BuiltPaths & buildables)
|
|||||||
|
|
||||||
MixDefaultProfile::MixDefaultProfile()
|
MixDefaultProfile::MixDefaultProfile()
|
||||||
{
|
{
|
||||||
profile = getDefaultProfile();
|
profile = getDefaultProfile().string();
|
||||||
}
|
}
|
||||||
|
|
||||||
MixEnvironment::MixEnvironment()
|
MixEnvironment::MixEnvironment()
|
||||||
@@ -391,7 +391,7 @@ void createOutLinks(const std::filesystem::path & outLink, const BuiltPaths & bu
|
|||||||
auto symlink = outLink;
|
auto symlink = outLink;
|
||||||
if (i)
|
if (i)
|
||||||
symlink += fmt("-%d", i);
|
symlink += fmt("-%d", i);
|
||||||
store.addPermRoot(bo.path, absPath(symlink.string()));
|
store.addPermRoot(bo.path, absPath(symlink).string());
|
||||||
},
|
},
|
||||||
[&](const BuiltPath::Built & bfd) {
|
[&](const BuiltPath::Built & bfd) {
|
||||||
for (auto & output : bfd.outputs) {
|
for (auto & output : bfd.outputs) {
|
||||||
@@ -400,7 +400,7 @@ void createOutLinks(const std::filesystem::path & outLink, const BuiltPaths & bu
|
|||||||
symlink += fmt("-%d", i);
|
symlink += fmt("-%d", i);
|
||||||
if (output.first != "out")
|
if (output.first != "out")
|
||||||
symlink += fmt("-%s", output.first);
|
symlink += fmt("-%s", output.first);
|
||||||
store.addPermRoot(output.second, absPath(symlink.string()));
|
store.addPermRoot(output.second, absPath(symlink).string());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ EvalSettings evalSettings{
|
|||||||
auto flakeRef = parseFlakeRef(fetchSettings, std::string{rest}, {}, true, false);
|
auto flakeRef = parseFlakeRef(fetchSettings, std::string{rest}, {}, true, false);
|
||||||
debug("fetching flake search path element '%s''", rest);
|
debug("fetching flake search path element '%s''", rest);
|
||||||
auto [accessor, lockedRef] =
|
auto [accessor, lockedRef] =
|
||||||
flakeRef.resolve(fetchSettings, state.store).lazyFetch(fetchSettings, state.store);
|
flakeRef.resolve(fetchSettings, *state.store).lazyFetch(fetchSettings, *state.store);
|
||||||
auto storePath = nix::fetchToStore(
|
auto storePath = nix::fetchToStore(
|
||||||
state.fetchSettings,
|
state.fetchSettings,
|
||||||
*state.store,
|
*state.store,
|
||||||
@@ -132,7 +132,7 @@ MixEvalArgs::MixEvalArgs()
|
|||||||
fetchers::Attrs extraAttrs;
|
fetchers::Attrs extraAttrs;
|
||||||
if (to.subdir != "")
|
if (to.subdir != "")
|
||||||
extraAttrs["dir"] = to.subdir;
|
extraAttrs["dir"] = to.subdir;
|
||||||
fetchers::overrideRegistry(fetchSettings, from.input, to.input, extraAttrs);
|
fetchers::overrideRegistry(from.input, to.input, extraAttrs);
|
||||||
}},
|
}},
|
||||||
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
|
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
|
||||||
completeFlakeRef(completions, openStore(), prefix);
|
completeFlakeRef(completions, openStore(), prefix);
|
||||||
@@ -165,22 +165,22 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state)
|
|||||||
state.parseExprFromString(
|
state.parseExprFromString(
|
||||||
arg.expr,
|
arg.expr,
|
||||||
compatibilitySettings.nixShellShebangArgumentsRelativeToScript
|
compatibilitySettings.nixShellShebangArgumentsRelativeToScript
|
||||||
? state.rootPath(absPath(getCommandBaseDir()))
|
? state.rootPath(absPath(getCommandBaseDir()).string())
|
||||||
: state.rootPath(".")));
|
: state.rootPath(".")));
|
||||||
},
|
},
|
||||||
[&](const AutoArgString & arg) { v->mkString(arg.s); },
|
[&](const AutoArgString & arg) { v->mkString(arg.s, state.mem); },
|
||||||
[&](const AutoArgFile & arg) { v->mkString(readFile(arg.path.string())); },
|
[&](const AutoArgFile & arg) { v->mkString(readFile(arg.path.string()), state.mem); },
|
||||||
[&](const AutoArgStdin & arg) { v->mkString(readFile(STDIN_FILENO)); }},
|
[&](const AutoArgStdin & arg) { v->mkString(readFile(STDIN_FILENO), state.mem); }},
|
||||||
arg);
|
arg);
|
||||||
res.insert(state.symbols.create(name), v);
|
res.insert(state.symbols.create(name), v);
|
||||||
}
|
}
|
||||||
return res.finish();
|
return res.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * baseDir)
|
SourcePath lookupFileArg(EvalState & state, std::string_view s, const std::filesystem::path * baseDir)
|
||||||
{
|
{
|
||||||
if (EvalSettings::isPseudoUrl(s)) {
|
if (EvalSettings::isPseudoUrl(s)) {
|
||||||
auto accessor = fetchers::downloadTarball(state.store, state.fetchSettings, EvalSettings::resolvePseudoUrl(s));
|
auto accessor = fetchers::downloadTarball(*state.store, state.fetchSettings, EvalSettings::resolvePseudoUrl(s));
|
||||||
auto storePath = fetchToStore(state.fetchSettings, *state.store, SourcePath(accessor), FetchMode::Copy);
|
auto storePath = fetchToStore(state.fetchSettings, *state.store, SourcePath(accessor), FetchMode::Copy);
|
||||||
return state.storePath(storePath);
|
return state.storePath(storePath);
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,8 @@ SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * bas
|
|||||||
else if (hasPrefix(s, "flake:")) {
|
else if (hasPrefix(s, "flake:")) {
|
||||||
experimentalFeatureSettings.require(Xp::Flakes);
|
experimentalFeatureSettings.require(Xp::Flakes);
|
||||||
auto flakeRef = parseFlakeRef(fetchSettings, std::string(s.substr(6)), {}, true, false);
|
auto flakeRef = parseFlakeRef(fetchSettings, std::string(s.substr(6)), {}, true, false);
|
||||||
auto [accessor, lockedRef] = flakeRef.resolve(fetchSettings, state.store).lazyFetch(fetchSettings, state.store);
|
auto [accessor, lockedRef] =
|
||||||
|
flakeRef.resolve(fetchSettings, *state.store).lazyFetch(fetchSettings, *state.store);
|
||||||
auto storePath = nix::fetchToStore(
|
auto storePath = nix::fetchToStore(
|
||||||
state.fetchSettings, *state.store, SourcePath(accessor), FetchMode::Copy, lockedRef.input.getName());
|
state.fetchSettings, *state.store, SourcePath(accessor), FetchMode::Copy, lockedRef.input.getName());
|
||||||
state.allowPath(storePath);
|
state.allowPath(storePath);
|
||||||
@@ -196,12 +197,13 @@ SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * bas
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') {
|
else if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') {
|
||||||
Path p(s.substr(1, s.size() - 2));
|
// Should perhaps be a `CanonPath`?
|
||||||
|
std::string p(s.substr(1, s.size() - 2));
|
||||||
return state.findFile(p);
|
return state.findFile(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
return state.rootPath(baseDir ? absPath(s, *baseDir) : absPath(s));
|
return state.rootPath(absPath(std::filesystem::path{s}, baseDir).string());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
@@ -134,7 +134,7 @@ struct MixFlakeOptions : virtual Args, EvalCommand
|
|||||||
|
|
||||||
struct SourceExprCommand : virtual Args, MixFlakeOptions
|
struct SourceExprCommand : virtual Args, MixFlakeOptions
|
||||||
{
|
{
|
||||||
std::optional<Path> file;
|
std::optional<std::filesystem::path> file;
|
||||||
std::optional<std::string> expr;
|
std::optional<std::string> expr;
|
||||||
|
|
||||||
SourceExprCommand();
|
SourceExprCommand();
|
||||||
@@ -310,7 +310,7 @@ static RegisterCommand registerCommand2(std::vector<std::string> && name)
|
|||||||
|
|
||||||
struct MixProfile : virtual StoreCommand
|
struct MixProfile : virtual StoreCommand
|
||||||
{
|
{
|
||||||
std::optional<Path> profile;
|
std::optional<std::filesystem::path> profile;
|
||||||
|
|
||||||
MixProfile();
|
MixProfile();
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,6 @@ private:
|
|||||||
/**
|
/**
|
||||||
* @param baseDir Optional [base directory](https://nix.dev/manual/nix/development/glossary#gloss-base-directory)
|
* @param baseDir Optional [base directory](https://nix.dev/manual/nix/development/glossary#gloss-base-directory)
|
||||||
*/
|
*/
|
||||||
SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * baseDir = nullptr);
|
SourcePath lookupFileArg(EvalState & state, std::string_view s, const std::filesystem::path * baseDir = nullptr);
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
@@ -17,7 +17,7 @@ class AttrCursor;
|
|||||||
struct App
|
struct App
|
||||||
{
|
{
|
||||||
std::vector<DerivedPath> context;
|
std::vector<DerivedPath> context;
|
||||||
Path program;
|
std::filesystem::path program;
|
||||||
// FIXME: add args, sandbox settings, metadata, ...
|
// FIXME: add args, sandbox settings, metadata, ...
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,16 @@ struct AbstractNixRepl
|
|||||||
|
|
||||||
typedef std::vector<std::pair<Value *, std::string>> AnnotatedValues;
|
typedef std::vector<std::pair<Value *, std::string>> AnnotatedValues;
|
||||||
|
|
||||||
using RunNix = void(Path program, const Strings & args, const std::optional<std::string> & input);
|
/**
|
||||||
|
* Run a nix executable
|
||||||
|
*
|
||||||
|
* @todo this is a layer violation
|
||||||
|
*
|
||||||
|
* @param programName Name of the command, e.g. `nix` or `nix-env`.
|
||||||
|
* @param args aguments to the command.
|
||||||
|
*/
|
||||||
|
using RunNix =
|
||||||
|
void(const std::string & programName, const Strings & args, const std::optional<std::string> & input);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param runNix Function to run the nix CLI to support various
|
* @param runNix Function to run the nix CLI to support various
|
||||||
|
|||||||
+11
-10
@@ -132,7 +132,7 @@ MixFlakeOptions::MixFlakeOptions()
|
|||||||
lockFlags.writeLockFile = false;
|
lockFlags.writeLockFile = false;
|
||||||
lockFlags.inputOverrides.insert_or_assign(
|
lockFlags.inputOverrides.insert_or_assign(
|
||||||
flake::parseInputAttrPath(inputAttrPath),
|
flake::parseInputAttrPath(inputAttrPath),
|
||||||
parseFlakeRef(fetchSettings, flakeRef, absPath(getCommandBaseDir()), true));
|
parseFlakeRef(fetchSettings, flakeRef, absPath(getCommandBaseDir()).string(), true));
|
||||||
}},
|
}},
|
||||||
.completer = {[&](AddCompletions & completions, size_t n, std::string_view prefix) {
|
.completer = {[&](AddCompletions & completions, size_t n, std::string_view prefix) {
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
@@ -173,7 +173,7 @@ MixFlakeOptions::MixFlakeOptions()
|
|||||||
auto flake = flake::lockFlake(
|
auto flake = flake::lockFlake(
|
||||||
flakeSettings,
|
flakeSettings,
|
||||||
*evalState,
|
*evalState,
|
||||||
parseFlakeRef(fetchSettings, flakeRef, absPath(getCommandBaseDir())),
|
parseFlakeRef(fetchSettings, flakeRef, absPath(getCommandBaseDir()).string()),
|
||||||
{.writeLockFile = false});
|
{.writeLockFile = false});
|
||||||
for (auto & [inputName, input] : flake.lockFile.root->inputs) {
|
for (auto & [inputName, input] : flake.lockFile.root->inputs) {
|
||||||
auto input2 = flake.lockFile.findInput({inputName}); // resolve 'follows' nodes
|
auto input2 = flake.lockFile.findInput({inputName}); // resolve 'follows' nodes
|
||||||
@@ -185,7 +185,6 @@ MixFlakeOptions::MixFlakeOptions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
overrideRegistry(
|
overrideRegistry(
|
||||||
fetchSettings,
|
|
||||||
fetchers::Input::fromAttrs(fetchSettings, {{"type", "indirect"}, {"id", inputName}}),
|
fetchers::Input::fromAttrs(fetchSettings, {{"type", "indirect"}, {"id", inputName}}),
|
||||||
input3->lockedRef.input,
|
input3->lockedRef.input,
|
||||||
extraAttrs);
|
extraAttrs);
|
||||||
@@ -264,7 +263,7 @@ void SourceExprCommand::completeInstallable(AddCompletions & completions, std::s
|
|||||||
|
|
||||||
evalSettings.pureEval = false;
|
evalSettings.pureEval = false;
|
||||||
auto state = getEvalState();
|
auto state = getEvalState();
|
||||||
auto e = state->parseExprFromFile(resolveExprPath(lookupFileArg(*state, *file)));
|
auto e = state->parseExprFromFile(resolveExprPath(lookupFileArg(*state, file->string())));
|
||||||
|
|
||||||
Value root;
|
Value root;
|
||||||
state->eval(e, root);
|
state->eval(e, root);
|
||||||
@@ -410,7 +409,7 @@ void completeFlakeRef(AddCompletions & completions, ref<Store> store, std::strin
|
|||||||
Args::completeDir(completions, 0, prefix);
|
Args::completeDir(completions, 0, prefix);
|
||||||
|
|
||||||
/* Look for registry entries that match the prefix. */
|
/* Look for registry entries that match the prefix. */
|
||||||
for (auto & registry : fetchers::getRegistries(fetchSettings, store)) {
|
for (auto & registry : fetchers::getRegistries(fetchSettings, *store)) {
|
||||||
for (auto & entry : registry->entries) {
|
for (auto & entry : registry->entries) {
|
||||||
auto from = entry.from.to_string();
|
auto from = entry.from.to_string();
|
||||||
if (!hasPrefix(prefix, "flake:") && hasPrefix(from, "flake:")) {
|
if (!hasPrefix(prefix, "flake:") && hasPrefix(from, "flake:")) {
|
||||||
@@ -466,10 +465,10 @@ Installables SourceExprCommand::parseInstallables(ref<Store> store, std::vector<
|
|||||||
state->eval(e, *vFile);
|
state->eval(e, *vFile);
|
||||||
} else if (file) {
|
} else if (file) {
|
||||||
auto dir = absPath(getCommandBaseDir());
|
auto dir = absPath(getCommandBaseDir());
|
||||||
state->evalFile(lookupFileArg(*state, *file, &dir), *vFile);
|
state->evalFile(lookupFileArg(*state, file->string(), &dir), *vFile);
|
||||||
} else {
|
} else {
|
||||||
Path dir = absPath(getCommandBaseDir());
|
auto dir = absPath(getCommandBaseDir());
|
||||||
auto e = state->parseExprFromString(*expr, state->rootPath(dir));
|
auto e = state->parseExprFromString(*expr, state->rootPath(dir.string()));
|
||||||
state->eval(e, *vFile);
|
state->eval(e, *vFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -802,7 +801,8 @@ std::vector<FlakeRef> RawInstallablesCommand::getFlakeRefsForCompletion()
|
|||||||
std::vector<FlakeRef> res;
|
std::vector<FlakeRef> res;
|
||||||
res.reserve(rawInstallables.size());
|
res.reserve(rawInstallables.size());
|
||||||
for (const auto & i : rawInstallables)
|
for (const auto & i : rawInstallables)
|
||||||
res.push_back(parseFlakeRefWithFragment(fetchSettings, expandTilde(i), absPath(getCommandBaseDir())).first);
|
res.push_back(
|
||||||
|
parseFlakeRefWithFragment(fetchSettings, expandTilde(i), absPath(getCommandBaseDir()).string()).first);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -821,7 +821,8 @@ void RawInstallablesCommand::run(ref<Store> store)
|
|||||||
|
|
||||||
std::vector<FlakeRef> InstallableCommand::getFlakeRefsForCompletion()
|
std::vector<FlakeRef> InstallableCommand::getFlakeRefsForCompletion()
|
||||||
{
|
{
|
||||||
return {parseFlakeRefWithFragment(fetchSettings, expandTilde(_installable), absPath(getCommandBaseDir())).first};
|
return {parseFlakeRefWithFragment(fetchSettings, expandTilde(_installable), absPath(getCommandBaseDir()).string())
|
||||||
|
.first};
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallablesCommand::run(ref<Store> store, std::vector<std::string> && rawInstallables)
|
void InstallablesCommand::run(ref<Store> store, std::vector<std::string> && rawInstallables)
|
||||||
|
|||||||
+11
-10
@@ -58,8 +58,7 @@ struct NixRepl : AbstractNixRepl, detail::ReplCompleterMixin, gc
|
|||||||
{
|
{
|
||||||
size_t debugTraceIndex;
|
size_t debugTraceIndex;
|
||||||
|
|
||||||
// Arguments passed to :load, saved so they can be reloaded with :reload
|
std::list<std::filesystem::path> loadedFiles;
|
||||||
Strings loadedFiles;
|
|
||||||
// Arguments passed to :load-flake, saved so they can be reloaded with :reload
|
// Arguments passed to :load-flake, saved so they can be reloaded with :reload
|
||||||
Strings loadedFlakes;
|
Strings loadedFlakes;
|
||||||
std::function<AnnotatedValues()> getValues;
|
std::function<AnnotatedValues()> getValues;
|
||||||
@@ -73,7 +72,7 @@ struct NixRepl : AbstractNixRepl, detail::ReplCompleterMixin, gc
|
|||||||
|
|
||||||
RunNix * runNixPtr;
|
RunNix * runNixPtr;
|
||||||
|
|
||||||
void runNix(Path program, const Strings & args, const std::optional<std::string> & input = {});
|
void runNix(const std::string & program, const Strings & args, const std::optional<std::string> & input = {});
|
||||||
|
|
||||||
std::unique_ptr<ReplInteracter> interacter;
|
std::unique_ptr<ReplInteracter> interacter;
|
||||||
|
|
||||||
@@ -92,7 +91,7 @@ struct NixRepl : AbstractNixRepl, detail::ReplCompleterMixin, gc
|
|||||||
StorePath getDerivationPath(Value & v);
|
StorePath getDerivationPath(Value & v);
|
||||||
ProcessLineResult processLine(std::string line);
|
ProcessLineResult processLine(std::string line);
|
||||||
|
|
||||||
void loadFile(const Path & path);
|
void loadFile(const std::filesystem::path & path);
|
||||||
void loadFlake(const std::string & flakeRef);
|
void loadFlake(const std::string & flakeRef);
|
||||||
void loadFiles();
|
void loadFiles();
|
||||||
void loadFlakes();
|
void loadFlakes();
|
||||||
@@ -539,7 +538,9 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
|||||||
Value v;
|
Value v;
|
||||||
evalString(arg, v);
|
evalString(arg, v);
|
||||||
StorePath drvPath = getDerivationPath(v);
|
StorePath drvPath = getDerivationPath(v);
|
||||||
Path drvPathRaw = state->store->printStorePath(drvPath);
|
// N.B. This need not be a local / native file path. For
|
||||||
|
// example, we might be using an SSH store to a different OS.
|
||||||
|
std::string drvPathRaw = state->store->printStorePath(drvPath);
|
||||||
|
|
||||||
if (command == ":b" || command == ":bl") {
|
if (command == ":b" || command == ":bl") {
|
||||||
state->store->buildPaths({
|
state->store->buildPaths({
|
||||||
@@ -712,12 +713,12 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
|||||||
return ProcessLineResult::PromptAgain;
|
return ProcessLineResult::PromptAgain;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NixRepl::loadFile(const Path & path)
|
void NixRepl::loadFile(const std::filesystem::path & path)
|
||||||
{
|
{
|
||||||
loadedFiles.remove(path);
|
loadedFiles.remove(path);
|
||||||
loadedFiles.push_back(path);
|
loadedFiles.push_back(path);
|
||||||
Value v, v2;
|
Value v, v2;
|
||||||
state->evalFile(lookupFileArg(*state, path), v);
|
state->evalFile(lookupFileArg(*state, path.string()), v);
|
||||||
state->autoCallFunction(*autoArgs, v, v2);
|
state->autoCallFunction(*autoArgs, v, v2);
|
||||||
addAttrsToScope(v2);
|
addAttrsToScope(v2);
|
||||||
}
|
}
|
||||||
@@ -739,7 +740,7 @@ void NixRepl::loadFlake(const std::string & flakeRefS)
|
|||||||
|
|
||||||
auto flakeRef = parseFlakeRef(fetchSettings, flakeRefS, cwd.string(), true);
|
auto flakeRef = parseFlakeRef(fetchSettings, flakeRefS, cwd.string(), true);
|
||||||
if (evalSettings.pureEval && !flakeRef.input.isLocked(fetchSettings))
|
if (evalSettings.pureEval && !flakeRef.input.isLocked(fetchSettings))
|
||||||
throw Error("cannot use ':load-flake' on locked flake reference '%s' (use --impure to override)", flakeRefS);
|
throw Error("cannot use ':load-flake' on unlocked flake reference '%s' (use --impure to override)", flakeRefS);
|
||||||
|
|
||||||
Value v;
|
Value v;
|
||||||
|
|
||||||
@@ -790,7 +791,7 @@ void NixRepl::reloadFilesAndFlakes()
|
|||||||
|
|
||||||
void NixRepl::loadFiles()
|
void NixRepl::loadFiles()
|
||||||
{
|
{
|
||||||
Strings old = loadedFiles;
|
decltype(loadedFiles) old = loadedFiles;
|
||||||
loadedFiles.clear();
|
loadedFiles.clear();
|
||||||
|
|
||||||
for (auto & i : old) {
|
for (auto & i : old) {
|
||||||
@@ -888,7 +889,7 @@ void NixRepl::evalString(std::string s, Value & v)
|
|||||||
state->forceValue(v, v.determinePos(noPos));
|
state->forceValue(v, v.determinePos(noPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NixRepl::runNix(Path program, const Strings & args, const std::optional<std::string> & input)
|
void NixRepl::runNix(const std::string & program, const Strings & args, const std::optional<std::string> & input)
|
||||||
{
|
{
|
||||||
if (runNixPtr)
|
if (runNixPtr)
|
||||||
(*runNixPtr)(program, args, input);
|
(*runNixPtr)(program, args, input);
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ nix_err nix_expr_eval_from_string(
|
|||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
try {
|
try {
|
||||||
nix::Expr * parsedExpr = state->state.parseExprFromString(expr, state->state.rootPath(nix::CanonPath(path)));
|
nix::Expr * parsedExpr = state->state.parseExprFromString(expr, state->state.rootPath(nix::CanonPath(path)));
|
||||||
state->state.eval(parsedExpr, value->value);
|
state->state.eval(parsedExpr, *value->value);
|
||||||
state->state.forceValue(value->value, nix::noPos);
|
state->state.forceValue(*value->value, nix::noPos);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS
|
NIXC_CATCH_ERRS
|
||||||
}
|
}
|
||||||
@@ -80,8 +80,8 @@ nix_err nix_value_call(nix_c_context * context, EvalState * state, Value * fn, n
|
|||||||
if (context)
|
if (context)
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
try {
|
try {
|
||||||
state->state.callFunction(fn->value, arg->value, value->value, nix::noPos);
|
state->state.callFunction(*fn->value, *arg->value, *value->value, nix::noPos);
|
||||||
state->state.forceValue(value->value, nix::noPos);
|
state->state.forceValue(*value->value, nix::noPos);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS
|
NIXC_CATCH_ERRS
|
||||||
}
|
}
|
||||||
@@ -91,9 +91,15 @@ nix_err nix_value_call_multi(
|
|||||||
{
|
{
|
||||||
if (context)
|
if (context)
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
|
|
||||||
|
std::vector<nix::Value *> internal_args;
|
||||||
|
internal_args.reserve(nargs);
|
||||||
|
for (size_t i = 0; i < nargs; i++)
|
||||||
|
internal_args.push_back(args[i]->value);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
state->state.callFunction(fn->value, {(nix::Value **) args, nargs}, value->value, nix::noPos);
|
state->state.callFunction(*fn->value, {internal_args.data(), nargs}, *value->value, nix::noPos);
|
||||||
state->state.forceValue(value->value, nix::noPos);
|
state->state.forceValue(*value->value, nix::noPos);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS
|
NIXC_CATCH_ERRS
|
||||||
}
|
}
|
||||||
@@ -103,7 +109,7 @@ nix_err nix_value_force(nix_c_context * context, EvalState * state, nix_value *
|
|||||||
if (context)
|
if (context)
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
try {
|
try {
|
||||||
state->state.forceValue(value->value, nix::noPos);
|
state->state.forceValue(*value->value, nix::noPos);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS
|
NIXC_CATCH_ERRS
|
||||||
}
|
}
|
||||||
@@ -113,7 +119,7 @@ nix_err nix_value_force_deep(nix_c_context * context, EvalState * state, nix_val
|
|||||||
if (context)
|
if (context)
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
try {
|
try {
|
||||||
state->state.forceValueDeep(value->value);
|
state->state.forceValueDeep(*value->value);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS
|
NIXC_CATCH_ERRS
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,13 @@ struct ListBuilder
|
|||||||
|
|
||||||
struct nix_value
|
struct nix_value
|
||||||
{
|
{
|
||||||
nix::Value value;
|
nix::Value * value;
|
||||||
|
/**
|
||||||
|
* As we move to a managed heap, we need EvalMemory in more places. Ideally, we would take in EvalState or
|
||||||
|
* EvalMemory as an argument when we need it, but we don't want to make changes to the stable C api, so we stuff it
|
||||||
|
* into the nix_value that will get passed in to the relevant functions.
|
||||||
|
*/
|
||||||
|
nix::EvalMemory * mem;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nix_string_return
|
struct nix_string_return
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ static const nix::Value & check_value_not_null(const nix_value * value)
|
|||||||
if (!value) {
|
if (!value) {
|
||||||
throw std::runtime_error("nix_value is null");
|
throw std::runtime_error("nix_value is null");
|
||||||
}
|
}
|
||||||
return *((const nix::Value *) value);
|
return *value->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static nix::Value & check_value_not_null(nix_value * value)
|
static nix::Value & check_value_not_null(nix_value * value)
|
||||||
@@ -28,7 +28,7 @@ static nix::Value & check_value_not_null(nix_value * value)
|
|||||||
if (!value) {
|
if (!value) {
|
||||||
throw std::runtime_error("nix_value is null");
|
throw std::runtime_error("nix_value is null");
|
||||||
}
|
}
|
||||||
return value->value;
|
return *value->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const nix::Value & check_value_in(const nix_value * value)
|
static const nix::Value & check_value_in(const nix_value * value)
|
||||||
@@ -58,9 +58,14 @@ static nix::Value & check_value_out(nix_value * value)
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline nix_value * as_nix_value_ptr(nix::Value * v)
|
static inline nix_value * new_nix_value(nix::Value * v, nix::EvalMemory & mem)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<nix_value *>(v);
|
nix_value * ret = new (mem.allocBytes(sizeof(nix_value))) nix_value{
|
||||||
|
.value = v,
|
||||||
|
.mem = &mem,
|
||||||
|
};
|
||||||
|
nix_gc_incref(nullptr, ret);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,7 +74,13 @@ static inline nix_value * as_nix_value_ptr(nix::Value * v)
|
|||||||
* Deals with errors and converts arguments from C++ into C types.
|
* Deals with errors and converts arguments from C++ into C types.
|
||||||
*/
|
*/
|
||||||
static void nix_c_primop_wrapper(
|
static void nix_c_primop_wrapper(
|
||||||
PrimOpFun f, void * userdata, nix::EvalState & state, const nix::PosIdx pos, nix::Value ** args, nix::Value & v)
|
PrimOpFun f,
|
||||||
|
void * userdata,
|
||||||
|
int arity,
|
||||||
|
nix::EvalState & state,
|
||||||
|
const nix::PosIdx pos,
|
||||||
|
nix::Value ** args,
|
||||||
|
nix::Value & v)
|
||||||
{
|
{
|
||||||
nix_c_context ctx;
|
nix_c_context ctx;
|
||||||
|
|
||||||
@@ -85,8 +96,15 @@ static void nix_c_primop_wrapper(
|
|||||||
// ok because we don't see a need for this yet (e.g. inspecting thunks,
|
// ok because we don't see a need for this yet (e.g. inspecting thunks,
|
||||||
// or maybe something to make blackholes work better; we don't know).
|
// or maybe something to make blackholes work better; we don't know).
|
||||||
nix::Value vTmp;
|
nix::Value vTmp;
|
||||||
|
nix_value * vTmpPtr = new_nix_value(&vTmp, state.mem);
|
||||||
|
|
||||||
f(userdata, &ctx, (EvalState *) &state, (nix_value **) args, (nix_value *) &vTmp);
|
std::vector<nix_value *> external_args;
|
||||||
|
external_args.reserve(arity);
|
||||||
|
for (int i = 0; i < arity; i++) {
|
||||||
|
nix_value * external_arg = new_nix_value(args[i], state.mem);
|
||||||
|
external_args.push_back(external_arg);
|
||||||
|
}
|
||||||
|
f(userdata, &ctx, (EvalState *) &state, external_args.data(), vTmpPtr);
|
||||||
|
|
||||||
if (ctx.last_err_code != NIX_OK) {
|
if (ctx.last_err_code != NIX_OK) {
|
||||||
/* TODO: Throw different errors depending on the error code */
|
/* TODO: Throw different errors depending on the error code */
|
||||||
@@ -135,7 +153,7 @@ PrimOp * nix_alloc_primop(
|
|||||||
.args = {},
|
.args = {},
|
||||||
.arity = (size_t) arity,
|
.arity = (size_t) arity,
|
||||||
.doc = doc,
|
.doc = doc,
|
||||||
.fun = std::bind(nix_c_primop_wrapper, fun, user_data, _1, _2, _3, _4)};
|
.fun = std::bind(nix_c_primop_wrapper, fun, user_data, arity, _1, _2, _3, _4)};
|
||||||
if (args)
|
if (args)
|
||||||
for (size_t i = 0; args[i]; i++)
|
for (size_t i = 0; args[i]; i++)
|
||||||
p->args.emplace_back(*args);
|
p->args.emplace_back(*args);
|
||||||
@@ -160,8 +178,7 @@ nix_value * nix_alloc_value(nix_c_context * context, EvalState * state)
|
|||||||
if (context)
|
if (context)
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
try {
|
try {
|
||||||
nix_value * res = as_nix_value_ptr(state->state.allocValue());
|
nix_value * res = new_nix_value(state->state.allocValue(), state->state.mem);
|
||||||
nix_gc_incref(nullptr, res);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS_NULL
|
NIXC_CATCH_ERRS_NULL
|
||||||
@@ -331,10 +348,10 @@ nix_value * nix_get_list_byidx(nix_c_context * context, const nix_value * value,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto * p = v.listView()[ix];
|
auto * p = v.listView()[ix];
|
||||||
nix_gc_incref(nullptr, p);
|
if (p == nullptr)
|
||||||
if (p != nullptr)
|
return nullptr;
|
||||||
state->state.forceValue(*p, nix::noPos);
|
state->state.forceValue(*p, nix::noPos);
|
||||||
return as_nix_value_ptr(p);
|
return new_nix_value(p, state->state.mem);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS_NULL
|
NIXC_CATCH_ERRS_NULL
|
||||||
}
|
}
|
||||||
@@ -352,9 +369,8 @@ nix_get_list_byidx_lazy(nix_c_context * context, const nix_value * value, EvalSt
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto * p = v.listView()[ix];
|
auto * p = v.listView()[ix];
|
||||||
nix_gc_incref(nullptr, p);
|
|
||||||
// Note: intentionally NOT calling forceValue() to keep the element lazy
|
// Note: intentionally NOT calling forceValue() to keep the element lazy
|
||||||
return as_nix_value_ptr(p);
|
return new_nix_value(p, state->state.mem);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS_NULL
|
NIXC_CATCH_ERRS_NULL
|
||||||
}
|
}
|
||||||
@@ -369,9 +385,8 @@ nix_value * nix_get_attr_byname(nix_c_context * context, const nix_value * value
|
|||||||
nix::Symbol s = state->state.symbols.create(name);
|
nix::Symbol s = state->state.symbols.create(name);
|
||||||
auto attr = v.attrs()->get(s);
|
auto attr = v.attrs()->get(s);
|
||||||
if (attr) {
|
if (attr) {
|
||||||
nix_gc_incref(nullptr, attr->value);
|
|
||||||
state->state.forceValue(*attr->value, nix::noPos);
|
state->state.forceValue(*attr->value, nix::noPos);
|
||||||
return as_nix_value_ptr(attr->value);
|
return new_nix_value(attr->value, state->state.mem);
|
||||||
}
|
}
|
||||||
nix_set_err_msg(context, NIX_ERR_KEY, "missing attribute");
|
nix_set_err_msg(context, NIX_ERR_KEY, "missing attribute");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -390,9 +405,8 @@ nix_get_attr_byname_lazy(nix_c_context * context, const nix_value * value, EvalS
|
|||||||
nix::Symbol s = state->state.symbols.create(name);
|
nix::Symbol s = state->state.symbols.create(name);
|
||||||
auto attr = v.attrs()->get(s);
|
auto attr = v.attrs()->get(s);
|
||||||
if (attr) {
|
if (attr) {
|
||||||
nix_gc_incref(nullptr, attr->value);
|
|
||||||
// Note: intentionally NOT calling forceValue() to keep the attribute lazy
|
// Note: intentionally NOT calling forceValue() to keep the attribute lazy
|
||||||
return as_nix_value_ptr(attr->value);
|
return new_nix_value(attr->value, state->state.mem);
|
||||||
}
|
}
|
||||||
nix_set_err_msg(context, NIX_ERR_KEY, "missing attribute");
|
nix_set_err_msg(context, NIX_ERR_KEY, "missing attribute");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -440,9 +454,8 @@ nix_get_attr_byidx(nix_c_context * context, nix_value * value, EvalState * state
|
|||||||
}
|
}
|
||||||
const nix::Attr & a = (*v.attrs())[i];
|
const nix::Attr & a = (*v.attrs())[i];
|
||||||
*name = state->state.symbols[a.name].c_str();
|
*name = state->state.symbols[a.name].c_str();
|
||||||
nix_gc_incref(nullptr, a.value);
|
|
||||||
state->state.forceValue(*a.value, nix::noPos);
|
state->state.forceValue(*a.value, nix::noPos);
|
||||||
return as_nix_value_ptr(a.value);
|
return new_nix_value(a.value, state->state.mem);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS_NULL
|
NIXC_CATCH_ERRS_NULL
|
||||||
}
|
}
|
||||||
@@ -461,9 +474,8 @@ nix_value * nix_get_attr_byidx_lazy(
|
|||||||
}
|
}
|
||||||
const nix::Attr & a = (*v.attrs())[i];
|
const nix::Attr & a = (*v.attrs())[i];
|
||||||
*name = state->state.symbols[a.name].c_str();
|
*name = state->state.symbols[a.name].c_str();
|
||||||
nix_gc_incref(nullptr, a.value);
|
|
||||||
// Note: intentionally NOT calling forceValue() to keep the attribute lazy
|
// Note: intentionally NOT calling forceValue() to keep the attribute lazy
|
||||||
return as_nix_value_ptr(a.value);
|
return new_nix_value(a.value, state->state.mem);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS_NULL
|
NIXC_CATCH_ERRS_NULL
|
||||||
}
|
}
|
||||||
@@ -503,7 +515,7 @@ nix_err nix_init_string(nix_c_context * context, nix_value * value, const char *
|
|||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
try {
|
try {
|
||||||
auto & v = check_value_out(value);
|
auto & v = check_value_out(value);
|
||||||
v.mkString(std::string_view(str));
|
v.mkString(std::string_view(str), *value->mem);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS
|
NIXC_CATCH_ERRS
|
||||||
}
|
}
|
||||||
@@ -514,7 +526,7 @@ nix_err nix_init_path_string(nix_c_context * context, EvalState * s, nix_value *
|
|||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
try {
|
try {
|
||||||
auto & v = check_value_out(value);
|
auto & v = check_value_out(value);
|
||||||
v.mkPath(s->state.rootPath(nix::CanonPath(str)));
|
v.mkPath(s->state.rootPath(nix::CanonPath(str)), s->state.mem);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS
|
NIXC_CATCH_ERRS
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ TEST_F(JSONValueTest, StringQuotes)
|
|||||||
TEST_F(JSONValueTest, DISABLED_Path)
|
TEST_F(JSONValueTest, DISABLED_Path)
|
||||||
{
|
{
|
||||||
Value v;
|
Value v;
|
||||||
v.mkPath(state.rootPath(CanonPath("/test")));
|
v.mkPath(state.rootPath(CanonPath("/test")), state.mem);
|
||||||
ASSERT_EQ(getJSONValue(v), "\"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x\"");
|
ASSERT_EQ(getJSONValue(v), "\"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x\"");
|
||||||
}
|
}
|
||||||
} /* namespace nix */
|
} /* namespace nix */
|
||||||
@@ -268,7 +268,7 @@ struct StringPrintingTests : LibExprTest
|
|||||||
void test(std::string_view literal, std::string_view expected, unsigned int maxLength, A... args)
|
void test(std::string_view literal, std::string_view expected, unsigned int maxLength, A... args)
|
||||||
{
|
{
|
||||||
Value v;
|
Value v;
|
||||||
v.mkString(literal);
|
v.mkString(literal, state.mem);
|
||||||
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
printValue(state, out, v, PrintOptions{.maxStringLength = maxLength});
|
printValue(state, out, v, PrintOptions{.maxStringLength = maxLength});
|
||||||
@@ -353,7 +353,7 @@ TEST_F(ValuePrintingTests, ansiColorsStringElided)
|
|||||||
TEST_F(ValuePrintingTests, ansiColorsPath)
|
TEST_F(ValuePrintingTests, ansiColorsPath)
|
||||||
{
|
{
|
||||||
Value v;
|
Value v;
|
||||||
v.mkPath(state.rootPath(CanonPath("puppy")));
|
v.mkPath(state.rootPath(CanonPath("puppy")), state.mem);
|
||||||
|
|
||||||
test(v, ANSI_GREEN "/puppy" ANSI_NORMAL, PrintOptions{.ansiColors = true});
|
test(v, ANSI_GREEN "/puppy" ANSI_NORMAL, PrintOptions{.ansiColors = true});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,18 +60,18 @@ EvalSettings::EvalSettings(bool & readOnlyMode, EvalSettings::LookupPathHooks lo
|
|||||||
Strings EvalSettings::getDefaultNixPath()
|
Strings EvalSettings::getDefaultNixPath()
|
||||||
{
|
{
|
||||||
Strings res;
|
Strings res;
|
||||||
auto add = [&](const Path & p, const std::string & s = std::string()) {
|
auto add = [&](const std::filesystem::path & p, const std::string & s = std::string()) {
|
||||||
if (std::filesystem::exists(p)) {
|
if (std::filesystem::exists(p)) {
|
||||||
if (s.empty()) {
|
if (s.empty()) {
|
||||||
res.push_back(p);
|
res.push_back(p.string());
|
||||||
} else {
|
} else {
|
||||||
res.push_back(s + "=" + p);
|
res.push_back(s + "=" + p.string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
add(getNixDefExpr() + "/channels");
|
add(std::filesystem::path{getNixDefExpr()} / "channels");
|
||||||
add(rootChannelsDir() + "/nixpkgs", "nixpkgs");
|
add(rootChannelsDir() / "nixpkgs", "nixpkgs");
|
||||||
add(rootChannelsDir());
|
add(rootChannelsDir());
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -108,4 +108,4 @@ Path getNixDefExpr()
|
|||||||
return settings.useXDGBaseDirectories ? getStateDir() + "/defexpr" : getHome() + "/.nix-defexpr";
|
return settings.useXDGBaseDirectories ? getStateDir() + "/defexpr" : getHome() + "/.nix-defexpr";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
+39
-30
@@ -81,20 +81,20 @@ static const char * makeImmutableString(std::string_view s)
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringData & StringData::alloc(size_t size)
|
StringData & StringData::alloc(EvalMemory & mem, size_t size)
|
||||||
{
|
{
|
||||||
void * t = GC_MALLOC_ATOMIC(sizeof(StringData) + size + 1);
|
void * t = mem.allocBytes(sizeof(StringData) + size + 1);
|
||||||
if (!t)
|
if (!t)
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
auto res = new (t) StringData(size);
|
auto res = new (t) StringData(size);
|
||||||
return *res;
|
return *res;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StringData & StringData::make(std::string_view s)
|
const StringData & StringData::make(EvalMemory & mem, std::string_view s)
|
||||||
{
|
{
|
||||||
if (s.empty())
|
if (s.empty())
|
||||||
return ""_sds;
|
return ""_sds;
|
||||||
auto & res = alloc(s.size());
|
auto & res = alloc(mem, s.size());
|
||||||
std::memcpy(&res.data_, s.data(), s.size());
|
std::memcpy(&res.data_, s.data(), s.size());
|
||||||
res.data_[s.size()] = '\0';
|
res.data_[s.size()] = '\0';
|
||||||
return res;
|
return res;
|
||||||
@@ -205,7 +205,7 @@ bool Value::isTrivial() const
|
|||||||
{
|
{
|
||||||
return !isa<tApp, tPrimOpApp>()
|
return !isa<tApp, tPrimOpApp>()
|
||||||
&& (!isa<tThunk>()
|
&& (!isa<tThunk>()
|
||||||
|| (dynamic_cast<ExprAttrs *>(thunk().expr) && ((ExprAttrs *) thunk().expr)->dynamicAttrs.empty())
|
|| (dynamic_cast<ExprAttrs *>(thunk().expr) && ((ExprAttrs *) thunk().expr)->dynamicAttrs->empty())
|
||||||
|| dynamic_cast<ExprLambda *>(thunk().expr) || dynamic_cast<ExprList *>(thunk().expr));
|
|| dynamic_cast<ExprLambda *>(thunk().expr) || dynamic_cast<ExprList *>(thunk().expr));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -849,9 +849,9 @@ DebugTraceStacker::DebugTraceStacker(EvalState & evalState, DebugTrace t)
|
|||||||
evalState.runDebugRepl(nullptr, trace.env, trace.expr);
|
evalState.runDebugRepl(nullptr, trace.env, trace.expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Value::mkString(std::string_view s)
|
void Value::mkString(std::string_view s, EvalMemory & mem)
|
||||||
{
|
{
|
||||||
mkStringNoCopy(StringData::make(s));
|
mkStringNoCopy(StringData::make(mem, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::StringWithContext::Context *
|
Value::StringWithContext::Context *
|
||||||
@@ -862,13 +862,13 @@ Value::StringWithContext::Context::fromBuilder(const NixStringContext & context,
|
|||||||
|
|
||||||
auto ctx = new (mem.allocBytes(sizeof(Context) + context.size() * sizeof(value_type))) Context(context.size());
|
auto ctx = new (mem.allocBytes(sizeof(Context) + context.size() * sizeof(value_type))) Context(context.size());
|
||||||
std::ranges::transform(
|
std::ranges::transform(
|
||||||
context, ctx->elems, [](const NixStringContextElem & elt) { return &StringData::make(elt.to_string()); });
|
context, ctx->elems, [&](const NixStringContextElem & elt) { return &StringData::make(mem, elt.to_string()); });
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Value::mkString(std::string_view s, const NixStringContext & context, EvalMemory & mem)
|
void Value::mkString(std::string_view s, const NixStringContext & context, EvalMemory & mem)
|
||||||
{
|
{
|
||||||
mkStringNoCopy(StringData::make(s), Value::StringWithContext::Context::fromBuilder(context, mem));
|
mkStringNoCopy(StringData::make(mem, s), Value::StringWithContext::Context::fromBuilder(context, mem));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Value::mkStringMove(const StringData & s, const NixStringContext & context, EvalMemory & mem)
|
void Value::mkStringMove(const StringData & s, const NixStringContext & context, EvalMemory & mem)
|
||||||
@@ -876,9 +876,9 @@ void Value::mkStringMove(const StringData & s, const NixStringContext & context,
|
|||||||
mkStringNoCopy(s, Value::StringWithContext::Context::fromBuilder(context, mem));
|
mkStringNoCopy(s, Value::StringWithContext::Context::fromBuilder(context, mem));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Value::mkPath(const SourcePath & path)
|
void Value::mkPath(const SourcePath & path, EvalMemory & mem)
|
||||||
{
|
{
|
||||||
mkPath(&*path.accessor, StringData::make(path.path.abs()));
|
mkPath(&*path.accessor, StringData::make(mem, path.path.abs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Value * EvalState::lookupVar(Env * env, const ExprVar & var, bool noEval)
|
inline Value * EvalState::lookupVar(Env * env, const ExprVar & var, bool noEval)
|
||||||
@@ -943,7 +943,7 @@ void EvalState::mkPos(Value & v, PosIdx p)
|
|||||||
auto origin = positions.originOf(p);
|
auto origin = positions.originOf(p);
|
||||||
if (auto path = std::get_if<SourcePath>(&origin)) {
|
if (auto path = std::get_if<SourcePath>(&origin)) {
|
||||||
auto attrs = buildBindings(3);
|
auto attrs = buildBindings(3);
|
||||||
attrs.alloc(s.file).mkString(path->path.abs());
|
attrs.alloc(s.file).mkString(path->path.abs(), mem);
|
||||||
makePositionThunks(*this, p, attrs.alloc(s.line), attrs.alloc(s.column));
|
makePositionThunks(*this, p, attrs.alloc(s.line), attrs.alloc(s.column));
|
||||||
v.mkAttrs(attrs);
|
v.mkAttrs(attrs);
|
||||||
} else
|
} else
|
||||||
@@ -1226,26 +1226,26 @@ Env * ExprAttrs::buildInheritFromEnv(EvalState & state, Env & up)
|
|||||||
|
|
||||||
void ExprAttrs::eval(EvalState & state, Env & env, Value & v)
|
void ExprAttrs::eval(EvalState & state, Env & env, Value & v)
|
||||||
{
|
{
|
||||||
auto bindings = state.buildBindings(attrs.size() + dynamicAttrs.size());
|
auto bindings = state.buildBindings(attrs->size() + dynamicAttrs->size());
|
||||||
auto dynamicEnv = &env;
|
auto dynamicEnv = &env;
|
||||||
bool sort = false;
|
bool sort = false;
|
||||||
|
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
/* Create a new environment that contains the attributes in
|
/* Create a new environment that contains the attributes in
|
||||||
this `rec'. */
|
this `rec'. */
|
||||||
Env & env2(state.mem.allocEnv(attrs.size()));
|
Env & env2(state.mem.allocEnv(attrs->size()));
|
||||||
env2.up = &env;
|
env2.up = &env;
|
||||||
dynamicEnv = &env2;
|
dynamicEnv = &env2;
|
||||||
Env * inheritEnv = inheritFromExprs ? buildInheritFromEnv(state, env2) : nullptr;
|
Env * inheritEnv = inheritFromExprs ? buildInheritFromEnv(state, env2) : nullptr;
|
||||||
|
|
||||||
AttrDefs::iterator overrides = attrs.find(state.s.overrides);
|
AttrDefs::iterator overrides = attrs->find(state.s.overrides);
|
||||||
bool hasOverrides = overrides != attrs.end();
|
bool hasOverrides = overrides != attrs->end();
|
||||||
|
|
||||||
/* The recursive attributes are evaluated in the new
|
/* The recursive attributes are evaluated in the new
|
||||||
environment, while the inherited attributes are evaluated
|
environment, while the inherited attributes are evaluated
|
||||||
in the original environment. */
|
in the original environment. */
|
||||||
Displacement displ = 0;
|
Displacement displ = 0;
|
||||||
for (auto & i : attrs) {
|
for (auto & i : *attrs) {
|
||||||
Value * vAttr;
|
Value * vAttr;
|
||||||
if (hasOverrides && i.second.kind != AttrDef::Kind::Inherited) {
|
if (hasOverrides && i.second.kind != AttrDef::Kind::Inherited) {
|
||||||
vAttr = state.allocValue();
|
vAttr = state.allocValue();
|
||||||
@@ -1272,8 +1272,8 @@ void ExprAttrs::eval(EvalState & state, Env & env, Value & v)
|
|||||||
"while evaluating the `__overrides` attribute");
|
"while evaluating the `__overrides` attribute");
|
||||||
bindings.grow(state.buildBindings(bindings.capacity() + vOverrides->attrs()->size()));
|
bindings.grow(state.buildBindings(bindings.capacity() + vOverrides->attrs()->size()));
|
||||||
for (auto & i : *vOverrides->attrs()) {
|
for (auto & i : *vOverrides->attrs()) {
|
||||||
AttrDefs::iterator j = attrs.find(i.name);
|
AttrDefs::iterator j = attrs->find(i.name);
|
||||||
if (j != attrs.end()) {
|
if (j != attrs->end()) {
|
||||||
(*bindings.bindings)[j->second.displ] = i;
|
(*bindings.bindings)[j->second.displ] = i;
|
||||||
env2.values[j->second.displ] = i.value;
|
env2.values[j->second.displ] = i.value;
|
||||||
} else
|
} else
|
||||||
@@ -1285,13 +1285,13 @@ void ExprAttrs::eval(EvalState & state, Env & env, Value & v)
|
|||||||
|
|
||||||
else {
|
else {
|
||||||
Env * inheritEnv = inheritFromExprs ? buildInheritFromEnv(state, env) : nullptr;
|
Env * inheritEnv = inheritFromExprs ? buildInheritFromEnv(state, env) : nullptr;
|
||||||
for (auto & i : attrs)
|
for (auto & i : *attrs)
|
||||||
bindings.insert(
|
bindings.insert(
|
||||||
i.first, i.second.e->maybeThunk(state, *i.second.chooseByKind(&env, &env, inheritEnv)), i.second.pos);
|
i.first, i.second.e->maybeThunk(state, *i.second.chooseByKind(&env, &env, inheritEnv)), i.second.pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dynamic attrs apply *after* rec and __overrides. */
|
/* Dynamic attrs apply *after* rec and __overrides. */
|
||||||
for (auto & i : dynamicAttrs) {
|
for (auto & i : *dynamicAttrs) {
|
||||||
Value nameVal;
|
Value nameVal;
|
||||||
i.nameExpr->eval(state, *dynamicEnv, nameVal);
|
i.nameExpr->eval(state, *dynamicEnv, nameVal);
|
||||||
state.forceValue(nameVal, i.pos);
|
state.forceValue(nameVal, i.pos);
|
||||||
@@ -1325,7 +1325,7 @@ void ExprLet::eval(EvalState & state, Env & env, Value & v)
|
|||||||
{
|
{
|
||||||
/* Create a new environment that contains the attributes in this
|
/* Create a new environment that contains the attributes in this
|
||||||
`let'. */
|
`let'. */
|
||||||
Env & env2(state.mem.allocEnv(attrs->attrs.size()));
|
Env & env2(state.mem.allocEnv(attrs->attrs->size()));
|
||||||
env2.up = &env;
|
env2.up = &env;
|
||||||
|
|
||||||
Env * inheritEnv = attrs->inheritFromExprs ? attrs->buildInheritFromEnv(state, env2) : nullptr;
|
Env * inheritEnv = attrs->inheritFromExprs ? attrs->buildInheritFromEnv(state, env2) : nullptr;
|
||||||
@@ -1334,7 +1334,7 @@ void ExprLet::eval(EvalState & state, Env & env, Value & v)
|
|||||||
while the inherited attributes are evaluated in the original
|
while the inherited attributes are evaluated in the original
|
||||||
environment. */
|
environment. */
|
||||||
Displacement displ = 0;
|
Displacement displ = 0;
|
||||||
for (auto & i : attrs->attrs) {
|
for (auto & i : *attrs->attrs) {
|
||||||
env2.values[displ++] = i.second.e->maybeThunk(state, *i.second.chooseByKind(&env2, &env, inheritEnv));
|
env2.values[displ++] = i.second.e->maybeThunk(state, *i.second.chooseByKind(&env2, &env, inheritEnv));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1751,9 +1751,9 @@ void ExprCall::eval(EvalState & state, Env & env, Value & v)
|
|||||||
// 4: about 60
|
// 4: about 60
|
||||||
// 5: under 10
|
// 5: under 10
|
||||||
// This excluded attrset lambdas (`{...}:`). Contributions of mixed lambdas appears insignificant at ~150 total.
|
// This excluded attrset lambdas (`{...}:`). Contributions of mixed lambdas appears insignificant at ~150 total.
|
||||||
SmallValueVector<4> vArgs(args.size());
|
SmallValueVector<4> vArgs(args->size());
|
||||||
for (size_t i = 0; i < args.size(); ++i)
|
for (size_t i = 0; i < args->size(); ++i)
|
||||||
vArgs[i] = args[i]->maybeThunk(state, env);
|
vArgs[i] = (*args)[i]->maybeThunk(state, env);
|
||||||
|
|
||||||
state.callFunction(vFun, vArgs, v, pos);
|
state.callFunction(vFun, vArgs, v, pos);
|
||||||
}
|
}
|
||||||
@@ -2139,9 +2139,9 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
|
|||||||
for (const auto & part : strings) {
|
for (const auto & part : strings) {
|
||||||
resultStr += *part;
|
resultStr += *part;
|
||||||
}
|
}
|
||||||
v.mkPath(state.rootPath(CanonPath(resultStr)));
|
v.mkPath(state.rootPath(CanonPath(resultStr)), state.mem);
|
||||||
} else {
|
} else {
|
||||||
auto & resultStr = StringData::alloc(sSize);
|
auto & resultStr = StringData::alloc(state.mem, sSize);
|
||||||
auto * tmp = resultStr.data();
|
auto * tmp = resultStr.data();
|
||||||
for (const auto & part : strings) {
|
for (const auto & part : strings) {
|
||||||
std::memcpy(tmp, part->data(), part->size());
|
std::memcpy(tmp, part->data(), part->size());
|
||||||
@@ -2188,6 +2188,8 @@ void EvalState::forceValueDeep(Value & v)
|
|||||||
std::set<const Value *> seen;
|
std::set<const Value *> seen;
|
||||||
|
|
||||||
[&, &state(*this)](this const auto & recurse, Value & v) {
|
[&, &state(*this)](this const auto & recurse, Value & v) {
|
||||||
|
auto _level = state.addCallDepth(v.determinePos(noPos));
|
||||||
|
|
||||||
if (!seen.insert(&v).second)
|
if (!seen.insert(&v).second)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -2214,8 +2216,15 @@ void EvalState::forceValueDeep(Value & v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (v.isList()) {
|
else if (v.isList()) {
|
||||||
|
size_t index = 0;
|
||||||
for (auto v2 : v.listView())
|
for (auto v2 : v.listView())
|
||||||
recurse(*v2);
|
try {
|
||||||
|
recurse(*v2);
|
||||||
|
index++;
|
||||||
|
} catch (Error & e) {
|
||||||
|
state.addErrorTrace(e, "while evaluating list element at index %1%", index);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}(v);
|
}(v);
|
||||||
}
|
}
|
||||||
@@ -3190,7 +3199,7 @@ std::optional<SourcePath> EvalState::resolveLookupPathPath(const LookupPath::Pat
|
|||||||
|
|
||||||
if (EvalSettings::isPseudoUrl(value)) {
|
if (EvalSettings::isPseudoUrl(value)) {
|
||||||
try {
|
try {
|
||||||
auto accessor = fetchers::downloadTarball(store, fetchSettings, EvalSettings::resolvePseudoUrl(value));
|
auto accessor = fetchers::downloadTarball(*store, fetchSettings, EvalSettings::resolvePseudoUrl(value));
|
||||||
auto storePath = fetchToStore(fetchSettings, *store, SourcePath(accessor), FetchMode::Copy);
|
auto storePath = fetchToStore(fetchSettings, *store, SourcePath(accessor), FetchMode::Copy);
|
||||||
return finish(this->storePath(storePath));
|
return finish(this->storePath(storePath));
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
|
|||||||
@@ -395,9 +395,13 @@ struct ExprAttrs : Expr
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<Symbol, AttrDef> AttrDefs;
|
typedef std::pmr::map<Symbol, AttrDef> AttrDefs;
|
||||||
AttrDefs attrs;
|
/**
|
||||||
std::unique_ptr<std::vector<Expr *>> inheritFromExprs;
|
* attrs will never be null. we use std::optional so that we can call emplace() to re-initialize the value with a
|
||||||
|
* new pmr::map using a different allocator (move assignment will copy into the old allocator)
|
||||||
|
*/
|
||||||
|
std::optional<AttrDefs> attrs;
|
||||||
|
std::unique_ptr<std::pmr::vector<Expr *>> inheritFromExprs;
|
||||||
|
|
||||||
struct DynamicAttrDef
|
struct DynamicAttrDef
|
||||||
{
|
{
|
||||||
@@ -409,13 +413,20 @@ struct ExprAttrs : Expr
|
|||||||
, pos(pos) {};
|
, pos(pos) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<DynamicAttrDef> DynamicAttrDefs;
|
typedef std::pmr::vector<DynamicAttrDef> DynamicAttrDefs;
|
||||||
DynamicAttrDefs dynamicAttrs;
|
/**
|
||||||
|
* dynamicAttrs will never be null. See comment on AttrDefs above.
|
||||||
|
*/
|
||||||
|
std::optional<DynamicAttrDefs> dynamicAttrs;
|
||||||
ExprAttrs(const PosIdx & pos)
|
ExprAttrs(const PosIdx & pos)
|
||||||
: recursive(false)
|
: recursive(false)
|
||||||
, pos(pos) {};
|
, pos(pos)
|
||||||
|
, attrs(AttrDefs{})
|
||||||
|
, dynamicAttrs(DynamicAttrDefs{}) {};
|
||||||
ExprAttrs()
|
ExprAttrs()
|
||||||
: recursive(false) {};
|
: recursive(false)
|
||||||
|
, attrs(AttrDefs{})
|
||||||
|
, dynamicAttrs(DynamicAttrDefs{}) {};
|
||||||
|
|
||||||
PosIdx getPos() const override
|
PosIdx getPos() const override
|
||||||
{
|
{
|
||||||
@@ -427,6 +438,7 @@ struct ExprAttrs : Expr
|
|||||||
std::shared_ptr<const StaticEnv> bindInheritSources(EvalState & es, const std::shared_ptr<const StaticEnv> & env);
|
std::shared_ptr<const StaticEnv> bindInheritSources(EvalState & es, const std::shared_ptr<const StaticEnv> & env);
|
||||||
Env * buildInheritFromEnv(EvalState & state, Env & up);
|
Env * buildInheritFromEnv(EvalState & state, Env & up);
|
||||||
void showBindings(const SymbolTable & symbols, std::ostream & str) const;
|
void showBindings(const SymbolTable & symbols, std::ostream & str) const;
|
||||||
|
void moveDataToAllocator(std::pmr::polymorphic_allocator<char> & alloc);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ExprList : Expr
|
struct ExprList : Expr
|
||||||
@@ -581,11 +593,14 @@ public:
|
|||||||
struct ExprCall : Expr
|
struct ExprCall : Expr
|
||||||
{
|
{
|
||||||
Expr * fun;
|
Expr * fun;
|
||||||
std::vector<Expr *> args;
|
/**
|
||||||
|
* args will never be null. See comment on ExprAttrs::AttrDefs below.
|
||||||
|
*/
|
||||||
|
std::optional<std::pmr::vector<Expr *>> args;
|
||||||
PosIdx pos;
|
PosIdx pos;
|
||||||
std::optional<PosIdx> cursedOrEndPos; // used during parsing to warn about https://github.com/NixOS/nix/issues/11118
|
std::optional<PosIdx> cursedOrEndPos; // used during parsing to warn about https://github.com/NixOS/nix/issues/11118
|
||||||
|
|
||||||
ExprCall(const PosIdx & pos, Expr * fun, std::vector<Expr *> && args)
|
ExprCall(const PosIdx & pos, Expr * fun, std::pmr::vector<Expr *> && args)
|
||||||
: fun(fun)
|
: fun(fun)
|
||||||
, args(args)
|
, args(args)
|
||||||
, pos(pos)
|
, pos(pos)
|
||||||
@@ -593,7 +608,7 @@ struct ExprCall : Expr
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprCall(const PosIdx & pos, Expr * fun, std::vector<Expr *> && args, PosIdx && cursedOrEndPos)
|
ExprCall(const PosIdx & pos, Expr * fun, std::pmr::vector<Expr *> && args, PosIdx && cursedOrEndPos)
|
||||||
: fun(fun)
|
: fun(fun)
|
||||||
, args(args)
|
, args(args)
|
||||||
, pos(pos)
|
, pos(pos)
|
||||||
@@ -608,6 +623,7 @@ struct ExprCall : Expr
|
|||||||
|
|
||||||
virtual void resetCursedOr() override;
|
virtual void resetCursedOr() override;
|
||||||
virtual void warnIfCursedOr(const SymbolTable & symbols, const PosTable & positions) override;
|
virtual void warnIfCursedOr(const SymbolTable & symbols, const PosTable & positions) override;
|
||||||
|
void moveDataToAllocator(std::pmr::polymorphic_allocator<char> & alloc);
|
||||||
COMMON_METHODS
|
COMMON_METHODS
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -825,7 +841,7 @@ public:
|
|||||||
// we define some calls to add explicitly so that the argument can be passed in as initializer lists
|
// we define some calls to add explicitly so that the argument can be passed in as initializer lists
|
||||||
template<class C>
|
template<class C>
|
||||||
[[gnu::always_inline]]
|
[[gnu::always_inline]]
|
||||||
C * add(const PosIdx & pos, Expr * fun, std::vector<Expr *> && args)
|
C * add(const PosIdx & pos, Expr * fun, std::pmr::vector<Expr *> && args)
|
||||||
requires(std::same_as<C, ExprCall>)
|
requires(std::same_as<C, ExprCall>)
|
||||||
{
|
{
|
||||||
return alloc.new_object<C>(pos, fun, std::move(args));
|
return alloc.new_object<C>(pos, fun, std::move(args));
|
||||||
@@ -833,7 +849,7 @@ public:
|
|||||||
|
|
||||||
template<class C>
|
template<class C>
|
||||||
[[gnu::always_inline]]
|
[[gnu::always_inline]]
|
||||||
C * add(const PosIdx & pos, Expr * fun, std::vector<Expr *> && args, PosIdx && cursedOrEndPos)
|
C * add(const PosIdx & pos, Expr * fun, std::pmr::vector<Expr *> && args, PosIdx && cursedOrEndPos)
|
||||||
requires(std::same_as<C, ExprCall>)
|
requires(std::same_as<C, ExprCall>)
|
||||||
{
|
{
|
||||||
return alloc.new_object<C>(pos, fun, std::move(args), std::move(cursedOrEndPos));
|
return alloc.new_object<C>(pos, fun, std::move(args), std::move(cursedOrEndPos));
|
||||||
|
|||||||
@@ -47,6 +47,79 @@ struct ParserLocation
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This represents a string-like parse that possibly has yet to be constructed.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
* "foo"
|
||||||
|
* ${"foo" + "bar"}
|
||||||
|
* "foo.bar"
|
||||||
|
* "foo-${a}"
|
||||||
|
*
|
||||||
|
* Using this type allows us to avoid construction altogether in cases where what we actually need is the string
|
||||||
|
* contents. For example in foo."bar.baz", there is no need to construct an AST node for "bar.baz", but we don't know
|
||||||
|
* that until we bubble the value up during parsing and see that it's a node in an AttrPath.
|
||||||
|
*/
|
||||||
|
class ToBeStringyExpr
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
using Raw = std::variant<std::monostate, std::string_view, Expr *>;
|
||||||
|
Raw raw;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ToBeStringyExpr() = default;
|
||||||
|
|
||||||
|
ToBeStringyExpr(std::string_view v)
|
||||||
|
: raw(v)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ToBeStringyExpr(Expr * expr)
|
||||||
|
: raw(expr)
|
||||||
|
{
|
||||||
|
assert(expr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visits the expression and invokes an overloaded functor object \ref f.
|
||||||
|
* If the underlying Expr has a dynamic type of ExprString the overload taking std::string_view
|
||||||
|
* is invoked.
|
||||||
|
*
|
||||||
|
* Used to consistently handle simple StringExpr ${"string"} as non-dynamic attributes.
|
||||||
|
* @see https://github.com/NixOS/nix/issues/14642
|
||||||
|
*/
|
||||||
|
template<class F>
|
||||||
|
void visit(F && f)
|
||||||
|
{
|
||||||
|
std::visit(
|
||||||
|
overloaded{
|
||||||
|
[&](std::string_view str) { f(str); },
|
||||||
|
[&](Expr * expr) {
|
||||||
|
ExprString * str = dynamic_cast<ExprString *>(expr);
|
||||||
|
if (str)
|
||||||
|
f(str->v.string_view());
|
||||||
|
else
|
||||||
|
f(expr);
|
||||||
|
},
|
||||||
|
[](std::monostate) { unreachable(); }},
|
||||||
|
raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get or create an Expr from either an existing Expr or from a string.
|
||||||
|
* Delays the allocation or an AST node in case the parser only cares about string contents.
|
||||||
|
*/
|
||||||
|
Expr * toExpr(Exprs & exprs)
|
||||||
|
{
|
||||||
|
return std::visit(
|
||||||
|
overloaded{
|
||||||
|
[&](std::string_view str) -> Expr * { return exprs.add<ExprString>(exprs.alloc, str); },
|
||||||
|
[&](Expr * expr) { return expr; },
|
||||||
|
[](std::monostate) -> Expr * { unreachable(); }},
|
||||||
|
raw);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct LexerState
|
struct LexerState
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -126,8 +199,8 @@ inline void ParserState::addAttr(
|
|||||||
for (i = attrPath.begin(); i + 1 < attrPath.end(); i++) {
|
for (i = attrPath.begin(); i + 1 < attrPath.end(); i++) {
|
||||||
ExprAttrs * nested;
|
ExprAttrs * nested;
|
||||||
if (i->symbol) {
|
if (i->symbol) {
|
||||||
ExprAttrs::AttrDefs::iterator j = attrs->attrs.find(i->symbol);
|
ExprAttrs::AttrDefs::iterator j = attrs->attrs->find(i->symbol);
|
||||||
if (j != attrs->attrs.end()) {
|
if (j != attrs->attrs->end()) {
|
||||||
nested = dynamic_cast<ExprAttrs *>(j->second.e);
|
nested = dynamic_cast<ExprAttrs *>(j->second.e);
|
||||||
if (!nested) {
|
if (!nested) {
|
||||||
attrPath.erase(i + 1, attrPath.end());
|
attrPath.erase(i + 1, attrPath.end());
|
||||||
@@ -135,11 +208,11 @@ inline void ParserState::addAttr(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nested = exprs.add<ExprAttrs>();
|
nested = exprs.add<ExprAttrs>();
|
||||||
attrs->attrs[i->symbol] = ExprAttrs::AttrDef(nested, pos);
|
(*attrs->attrs)[i->symbol] = ExprAttrs::AttrDef(nested, pos);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nested = exprs.add<ExprAttrs>();
|
nested = exprs.add<ExprAttrs>();
|
||||||
attrs->dynamicAttrs.push_back(ExprAttrs::DynamicAttrDef(i->expr, nested, pos));
|
attrs->dynamicAttrs->push_back(ExprAttrs::DynamicAttrDef(i->expr, nested, pos));
|
||||||
}
|
}
|
||||||
attrs = nested;
|
attrs = nested;
|
||||||
}
|
}
|
||||||
@@ -148,7 +221,7 @@ inline void ParserState::addAttr(
|
|||||||
if (i->symbol) {
|
if (i->symbol) {
|
||||||
addAttr(attrs, attrPath, i->symbol, ExprAttrs::AttrDef(e, pos));
|
addAttr(attrs, attrPath, i->symbol, ExprAttrs::AttrDef(e, pos));
|
||||||
} else {
|
} else {
|
||||||
attrs->dynamicAttrs.push_back(ExprAttrs::DynamicAttrDef(i->expr, e, pos));
|
attrs->dynamicAttrs->push_back(ExprAttrs::DynamicAttrDef(i->expr, e, pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = lexerState.positionToDocComment.find(pos);
|
auto it = lexerState.positionToDocComment.find(pos);
|
||||||
@@ -165,8 +238,8 @@ inline void ParserState::addAttr(
|
|||||||
inline void
|
inline void
|
||||||
ParserState::addAttr(ExprAttrs * attrs, AttrPath & attrPath, const Symbol & symbol, ExprAttrs::AttrDef && def)
|
ParserState::addAttr(ExprAttrs * attrs, AttrPath & attrPath, const Symbol & symbol, ExprAttrs::AttrDef && def)
|
||||||
{
|
{
|
||||||
ExprAttrs::AttrDefs::iterator j = attrs->attrs.find(symbol);
|
ExprAttrs::AttrDefs::iterator j = attrs->attrs->find(symbol);
|
||||||
if (j != attrs->attrs.end()) {
|
if (j != attrs->attrs->end()) {
|
||||||
// This attr path is already defined. However, if both
|
// This attr path is already defined. However, if both
|
||||||
// e and the expr pointed by the attr path are two attribute sets,
|
// e and the expr pointed by the attr path are two attribute sets,
|
||||||
// we want to merge them.
|
// we want to merge them.
|
||||||
@@ -181,8 +254,8 @@ ParserState::addAttr(ExprAttrs * attrs, AttrPath & attrPath, const Symbol & symb
|
|||||||
// See https://github.com/NixOS/nix/issues/9020.
|
// See https://github.com/NixOS/nix/issues/9020.
|
||||||
if (jAttrs && ae) {
|
if (jAttrs && ae) {
|
||||||
if (ae->inheritFromExprs && !jAttrs->inheritFromExprs)
|
if (ae->inheritFromExprs && !jAttrs->inheritFromExprs)
|
||||||
jAttrs->inheritFromExprs = std::make_unique<std::vector<Expr *>>();
|
jAttrs->inheritFromExprs = std::make_unique<std::pmr::vector<Expr *>>();
|
||||||
for (auto & ad : ae->attrs) {
|
for (auto & ad : *ae->attrs) {
|
||||||
if (ad.second.kind == ExprAttrs::AttrDef::Kind::InheritedFrom) {
|
if (ad.second.kind == ExprAttrs::AttrDef::Kind::InheritedFrom) {
|
||||||
auto & sel = dynamic_cast<ExprSelect &>(*ad.second.e);
|
auto & sel = dynamic_cast<ExprSelect &>(*ad.second.e);
|
||||||
auto & from = dynamic_cast<ExprInheritFrom &>(*sel.e);
|
auto & from = dynamic_cast<ExprInheritFrom &>(*sel.e);
|
||||||
@@ -192,12 +265,12 @@ ParserState::addAttr(ExprAttrs * attrs, AttrPath & attrPath, const Symbol & symb
|
|||||||
addAttr(jAttrs, attrPath, ad.first, std::move(ad.second));
|
addAttr(jAttrs, attrPath, ad.first, std::move(ad.second));
|
||||||
attrPath.pop_back();
|
attrPath.pop_back();
|
||||||
}
|
}
|
||||||
ae->attrs.clear();
|
ae->attrs->clear();
|
||||||
jAttrs->dynamicAttrs.insert(
|
jAttrs->dynamicAttrs->insert(
|
||||||
jAttrs->dynamicAttrs.end(),
|
jAttrs->dynamicAttrs->end(),
|
||||||
std::make_move_iterator(ae->dynamicAttrs.begin()),
|
std::make_move_iterator(ae->dynamicAttrs->begin()),
|
||||||
std::make_move_iterator(ae->dynamicAttrs.end()));
|
std::make_move_iterator(ae->dynamicAttrs->end()));
|
||||||
ae->dynamicAttrs.clear();
|
ae->dynamicAttrs->clear();
|
||||||
if (ae->inheritFromExprs) {
|
if (ae->inheritFromExprs) {
|
||||||
jAttrs->inheritFromExprs->insert(
|
jAttrs->inheritFromExprs->insert(
|
||||||
jAttrs->inheritFromExprs->end(),
|
jAttrs->inheritFromExprs->end(),
|
||||||
@@ -210,7 +283,7 @@ ParserState::addAttr(ExprAttrs * attrs, AttrPath & attrPath, const Symbol & symb
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// This attr path is not defined. Let's create it.
|
// This attr path is not defined. Let's create it.
|
||||||
attrs->attrs.emplace(symbol, def);
|
attrs->attrs->emplace(symbol, def);
|
||||||
def.e->setName(symbol);
|
def.e->setName(symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,13 +232,13 @@ public:
|
|||||||
* Allocate StringData on the (possibly) GC-managed heap and copy
|
* Allocate StringData on the (possibly) GC-managed heap and copy
|
||||||
* the contents of s to it.
|
* the contents of s to it.
|
||||||
*/
|
*/
|
||||||
static const StringData & make(std::string_view s);
|
static const StringData & make(EvalMemory & mem, std::string_view s);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate StringData on the (possibly) GC-managed heap.
|
* Allocate StringData on the (possibly) GC-managed heap.
|
||||||
* @param size Length of the string (without the NUL terminator).
|
* @param size Length of the string (without the NUL terminator).
|
||||||
*/
|
*/
|
||||||
static StringData & alloc(size_t size);
|
static StringData & alloc(EvalMemory & mem, size_t size);
|
||||||
|
|
||||||
size_t size() const
|
size_t size() const
|
||||||
{
|
{
|
||||||
@@ -1147,13 +1147,13 @@ public:
|
|||||||
setStorage(StringWithContext{.str = &s, .context = context});
|
setStorage(StringWithContext{.str = &s, .context = context});
|
||||||
}
|
}
|
||||||
|
|
||||||
void mkString(std::string_view s);
|
void mkString(std::string_view s, EvalMemory & mem);
|
||||||
|
|
||||||
void mkString(std::string_view s, const NixStringContext & context, EvalMemory & mem);
|
void mkString(std::string_view s, const NixStringContext & context, EvalMemory & mem);
|
||||||
|
|
||||||
void mkStringMove(const StringData & s, const NixStringContext & context, EvalMemory & mem);
|
void mkStringMove(const StringData & s, const NixStringContext & context, EvalMemory & mem);
|
||||||
|
|
||||||
void mkPath(const SourcePath & path);
|
void mkPath(const SourcePath & path, EvalMemory & mem);
|
||||||
|
|
||||||
inline void mkPath(SourceAccessor * accessor, const StringData & path) noexcept
|
inline void mkPath(SourceAccessor * accessor, const StringData & path) noexcept
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ public:
|
|||||||
bool string(string_t & val) override
|
bool string(string_t & val) override
|
||||||
{
|
{
|
||||||
forceNoNullByte(val);
|
forceNoNullByte(val);
|
||||||
rs->value(state).mkString(val);
|
rs->value(state).mkString(val, state.mem);
|
||||||
rs->add();
|
rs->add();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-14
@@ -74,9 +74,9 @@ void ExprOpHasAttr::show(const SymbolTable & symbols, std::ostream & str) const
|
|||||||
|
|
||||||
void ExprAttrs::showBindings(const SymbolTable & symbols, std::ostream & str) const
|
void ExprAttrs::showBindings(const SymbolTable & symbols, std::ostream & str) const
|
||||||
{
|
{
|
||||||
typedef const decltype(attrs)::value_type * Attr;
|
typedef const AttrDefs::value_type * Attr;
|
||||||
std::vector<Attr> sorted;
|
std::vector<Attr> sorted;
|
||||||
for (auto & i : attrs)
|
for (auto & i : *attrs)
|
||||||
sorted.push_back(&i);
|
sorted.push_back(&i);
|
||||||
std::sort(sorted.begin(), sorted.end(), [&](Attr a, Attr b) {
|
std::sort(sorted.begin(), sorted.end(), [&](Attr a, Attr b) {
|
||||||
std::string_view sa = symbols[a->first], sb = symbols[b->first];
|
std::string_view sa = symbols[a->first], sb = symbols[b->first];
|
||||||
@@ -122,7 +122,7 @@ void ExprAttrs::showBindings(const SymbolTable & symbols, std::ostream & str) co
|
|||||||
str << "; ";
|
str << "; ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto & i : dynamicAttrs) {
|
for (auto & i : *dynamicAttrs) {
|
||||||
str << "\"${";
|
str << "\"${";
|
||||||
i.nameExpr->show(symbols, str);
|
i.nameExpr->show(symbols, str);
|
||||||
str << "}\" = ";
|
str << "}\" = ";
|
||||||
@@ -191,7 +191,7 @@ void ExprCall::show(const SymbolTable & symbols, std::ostream & str) const
|
|||||||
{
|
{
|
||||||
str << '(';
|
str << '(';
|
||||||
fun->show(symbols, str);
|
fun->show(symbols, str);
|
||||||
for (auto e : args) {
|
for (auto e : *args) {
|
||||||
str << ' ';
|
str << ' ';
|
||||||
e->show(symbols, str);
|
e->show(symbols, str);
|
||||||
}
|
}
|
||||||
@@ -399,17 +399,29 @@ ExprAttrs::bindInheritSources(EvalState & es, const std::shared_ptr<const Static
|
|||||||
return inner;
|
return inner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExprAttrs::moveDataToAllocator(std::pmr::polymorphic_allocator<char> & alloc)
|
||||||
|
{
|
||||||
|
AttrDefs newAttrs{std::move(*attrs), alloc};
|
||||||
|
attrs.emplace(std::move(newAttrs), alloc);
|
||||||
|
DynamicAttrDefs newDynamicAttrs{std::move(*dynamicAttrs), alloc};
|
||||||
|
dynamicAttrs.emplace(std::move(newDynamicAttrs), alloc);
|
||||||
|
if (inheritFromExprs)
|
||||||
|
inheritFromExprs = std::make_unique<std::pmr::vector<Expr *>>(std::move(*inheritFromExprs), alloc);
|
||||||
|
}
|
||||||
|
|
||||||
void ExprAttrs::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env)
|
void ExprAttrs::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env)
|
||||||
{
|
{
|
||||||
|
moveDataToAllocator(es.mem.exprs.alloc);
|
||||||
|
|
||||||
if (es.debugRepl)
|
if (es.debugRepl)
|
||||||
es.exprEnvs.insert(std::make_pair(this, env));
|
es.exprEnvs.insert(std::make_pair(this, env));
|
||||||
|
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
auto newEnv = [&]() -> std::shared_ptr<const StaticEnv> {
|
auto newEnv = [&]() -> std::shared_ptr<const StaticEnv> {
|
||||||
auto newEnv = std::make_shared<StaticEnv>(nullptr, env, attrs.size());
|
auto newEnv = std::make_shared<StaticEnv>(nullptr, env, attrs->size());
|
||||||
|
|
||||||
Displacement displ = 0;
|
Displacement displ = 0;
|
||||||
for (auto & i : attrs)
|
for (auto & i : *attrs)
|
||||||
newEnv->vars.emplace_back(i.first, i.second.displ = displ++);
|
newEnv->vars.emplace_back(i.first, i.second.displ = displ++);
|
||||||
return newEnv;
|
return newEnv;
|
||||||
}();
|
}();
|
||||||
@@ -417,20 +429,20 @@ void ExprAttrs::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv>
|
|||||||
// No need to sort newEnv since attrs is in sorted order.
|
// No need to sort newEnv since attrs is in sorted order.
|
||||||
|
|
||||||
auto inheritFromEnv = bindInheritSources(es, newEnv);
|
auto inheritFromEnv = bindInheritSources(es, newEnv);
|
||||||
for (auto & i : attrs)
|
for (auto & i : *attrs)
|
||||||
i.second.e->bindVars(es, i.second.chooseByKind(newEnv, env, inheritFromEnv));
|
i.second.e->bindVars(es, i.second.chooseByKind(newEnv, env, inheritFromEnv));
|
||||||
|
|
||||||
for (auto & i : dynamicAttrs) {
|
for (auto & i : *dynamicAttrs) {
|
||||||
i.nameExpr->bindVars(es, newEnv);
|
i.nameExpr->bindVars(es, newEnv);
|
||||||
i.valueExpr->bindVars(es, newEnv);
|
i.valueExpr->bindVars(es, newEnv);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto inheritFromEnv = bindInheritSources(es, env);
|
auto inheritFromEnv = bindInheritSources(es, env);
|
||||||
|
|
||||||
for (auto & i : attrs)
|
for (auto & i : *attrs)
|
||||||
i.second.e->bindVars(es, i.second.chooseByKind(env, env, inheritFromEnv));
|
i.second.e->bindVars(es, i.second.chooseByKind(env, env, inheritFromEnv));
|
||||||
|
|
||||||
for (auto & i : dynamicAttrs) {
|
for (auto & i : *dynamicAttrs) {
|
||||||
i.nameExpr->bindVars(es, env);
|
i.nameExpr->bindVars(es, env);
|
||||||
i.valueExpr->bindVars(es, env);
|
i.valueExpr->bindVars(es, env);
|
||||||
}
|
}
|
||||||
@@ -473,23 +485,31 @@ void ExprLambda::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv>
|
|||||||
body->bindVars(es, newEnv);
|
body->bindVars(es, newEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExprCall::moveDataToAllocator(std::pmr::polymorphic_allocator<char> & alloc)
|
||||||
|
{
|
||||||
|
std::pmr::vector<Expr *> newArgs{std::move(*args), alloc};
|
||||||
|
args.emplace(std::move(newArgs), alloc);
|
||||||
|
}
|
||||||
|
|
||||||
void ExprCall::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env)
|
void ExprCall::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env)
|
||||||
{
|
{
|
||||||
|
moveDataToAllocator(es.mem.exprs.alloc);
|
||||||
if (es.debugRepl)
|
if (es.debugRepl)
|
||||||
es.exprEnvs.insert(std::make_pair(this, env));
|
es.exprEnvs.insert(std::make_pair(this, env));
|
||||||
|
|
||||||
fun->bindVars(es, env);
|
fun->bindVars(es, env);
|
||||||
for (auto e : args)
|
for (auto e : *args)
|
||||||
e->bindVars(es, env);
|
e->bindVars(es, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExprLet::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env)
|
void ExprLet::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env)
|
||||||
{
|
{
|
||||||
|
attrs->moveDataToAllocator(es.mem.exprs.alloc);
|
||||||
auto newEnv = [&]() -> std::shared_ptr<const StaticEnv> {
|
auto newEnv = [&]() -> std::shared_ptr<const StaticEnv> {
|
||||||
auto newEnv = std::make_shared<StaticEnv>(nullptr, env, attrs->attrs.size());
|
auto newEnv = std::make_shared<StaticEnv>(nullptr, env, attrs->attrs->size());
|
||||||
|
|
||||||
Displacement displ = 0;
|
Displacement displ = 0;
|
||||||
for (auto & i : attrs->attrs)
|
for (auto & i : *attrs->attrs)
|
||||||
newEnv->vars.emplace_back(i.first, i.second.displ = displ++);
|
newEnv->vars.emplace_back(i.first, i.second.displ = displ++);
|
||||||
return newEnv;
|
return newEnv;
|
||||||
}();
|
}();
|
||||||
@@ -497,7 +517,7 @@ void ExprLet::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> &
|
|||||||
// No need to sort newEnv since attrs->attrs is in sorted order.
|
// No need to sort newEnv since attrs->attrs is in sorted order.
|
||||||
|
|
||||||
auto inheritFromEnv = attrs->bindInheritSources(es, newEnv);
|
auto inheritFromEnv = attrs->bindInheritSources(es, newEnv);
|
||||||
for (auto & i : attrs->attrs)
|
for (auto & i : *attrs->attrs)
|
||||||
i.second.e->bindVars(es, i.second.chooseByKind(newEnv, env, inheritFromEnv));
|
i.second.e->bindVars(es, i.second.chooseByKind(newEnv, env, inheritFromEnv));
|
||||||
|
|
||||||
if (es.debugRepl)
|
if (es.debugRepl)
|
||||||
|
|||||||
+29
-34
@@ -115,7 +115,7 @@ static void setDocPosition(const LexerState & lexerState, ExprLambda * lambda, P
|
|||||||
|
|
||||||
static Expr * makeCall(Exprs & exprs, PosIdx pos, Expr * fn, Expr * arg) {
|
static Expr * makeCall(Exprs & exprs, PosIdx pos, Expr * fn, Expr * arg) {
|
||||||
if (auto e2 = dynamic_cast<ExprCall *>(fn)) {
|
if (auto e2 = dynamic_cast<ExprCall *>(fn)) {
|
||||||
e2->args.push_back(arg);
|
e2->args->push_back(arg);
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
return exprs.add<ExprCall>(pos, fn, {arg});
|
return exprs.add<ExprCall>(pos, fn, {arg});
|
||||||
@@ -129,7 +129,7 @@ static Expr * makeCall(Exprs & exprs, PosIdx pos, Expr * fn, Expr * arg) {
|
|||||||
%type <Expr *> start expr expr_function expr_if expr_op
|
%type <Expr *> start expr expr_function expr_if expr_op
|
||||||
%type <Expr *> expr_select expr_simple expr_app
|
%type <Expr *> expr_select expr_simple expr_app
|
||||||
%type <Expr *> expr_pipe_from expr_pipe_into
|
%type <Expr *> expr_pipe_from expr_pipe_into
|
||||||
%type <std::vector<Expr *>> list
|
%type <std::pmr::vector<Expr *>> list
|
||||||
%type <ExprAttrs *> binds binds1
|
%type <ExprAttrs *> binds binds1
|
||||||
%type <FormalsBuilder> formals formal_set
|
%type <FormalsBuilder> formals formal_set
|
||||||
%type <Formal> formal
|
%type <Formal> formal
|
||||||
@@ -138,7 +138,7 @@ static Expr * makeCall(Exprs & exprs, PosIdx pos, Expr * fn, Expr * arg) {
|
|||||||
%type <std::vector<std::pair<PosIdx, Expr *>>> string_parts_interpolated
|
%type <std::vector<std::pair<PosIdx, Expr *>>> string_parts_interpolated
|
||||||
%type <std::vector<std::pair<PosIdx, std::variant<Expr *, StringToken>>>> ind_string_parts
|
%type <std::vector<std::pair<PosIdx, std::variant<Expr *, StringToken>>>> ind_string_parts
|
||||||
%type <Expr *> path_start
|
%type <Expr *> path_start
|
||||||
%type <std::variant<Expr *, std::string_view>> string_parts string_attr
|
%type <ToBeStringyExpr> string_parts string_attr
|
||||||
%type <StringToken> attr
|
%type <StringToken> attr
|
||||||
%token <StringToken> ID
|
%token <StringToken> ID
|
||||||
%token <StringToken> STR IND_STR
|
%token <StringToken> STR IND_STR
|
||||||
@@ -211,7 +211,7 @@ expr_function
|
|||||||
| WITH expr ';' expr_function
|
| WITH expr ';' expr_function
|
||||||
{ $$ = state->exprs.add<ExprWith>(CUR_POS, $2, $4); }
|
{ $$ = state->exprs.add<ExprWith>(CUR_POS, $2, $4); }
|
||||||
| LET binds IN_KW expr_function
|
| LET binds IN_KW expr_function
|
||||||
{ if (!$2->dynamicAttrs.empty())
|
{ if (!$2->dynamicAttrs->empty())
|
||||||
throw ParseError({
|
throw ParseError({
|
||||||
.msg = HintFmt("dynamic attributes not allowed in let"),
|
.msg = HintFmt("dynamic attributes not allowed in let"),
|
||||||
.pos = state->positions[CUR_POS]
|
.pos = state->positions[CUR_POS]
|
||||||
@@ -297,12 +297,7 @@ expr_simple
|
|||||||
}
|
}
|
||||||
| INT_LIT { $$ = state->exprs.add<ExprInt>($1); }
|
| INT_LIT { $$ = state->exprs.add<ExprInt>($1); }
|
||||||
| FLOAT_LIT { $$ = state->exprs.add<ExprFloat>($1); }
|
| FLOAT_LIT { $$ = state->exprs.add<ExprFloat>($1); }
|
||||||
| '"' string_parts '"' {
|
| '"' string_parts '"' { $$ = $2.toExpr(state->exprs); }
|
||||||
std::visit(overloaded{
|
|
||||||
[&](std::string_view str) { $$ = state->exprs.add<ExprString>(state->exprs.alloc, str); },
|
|
||||||
[&](Expr * expr) { $$ = expr; }},
|
|
||||||
$2);
|
|
||||||
}
|
|
||||||
| IND_STRING_OPEN ind_string_parts IND_STRING_CLOSE {
|
| IND_STRING_OPEN ind_string_parts IND_STRING_CLOSE {
|
||||||
$$ = state->stripIndentation(CUR_POS, $2);
|
$$ = state->stripIndentation(CUR_POS, $2);
|
||||||
}
|
}
|
||||||
@@ -342,9 +337,9 @@ expr_simple
|
|||||||
;
|
;
|
||||||
|
|
||||||
string_parts
|
string_parts
|
||||||
: STR { $$ = $1; }
|
: STR { $$ = {$1}; }
|
||||||
| string_parts_interpolated { $$ = state->exprs.add<ExprConcatStrings>(state->exprs.alloc, CUR_POS, true, $1); }
|
| string_parts_interpolated { $$ = {state->exprs.add<ExprConcatStrings>(state->exprs.alloc, CUR_POS, true, $1)}; }
|
||||||
| { $$ = std::string_view(); }
|
| { $$ = {std::string_view()}; }
|
||||||
;
|
;
|
||||||
|
|
||||||
string_parts_interpolated
|
string_parts_interpolated
|
||||||
@@ -413,9 +408,9 @@ binds1
|
|||||||
| binds[accum] INHERIT attrs ';'
|
| binds[accum] INHERIT attrs ';'
|
||||||
{ $$ = $accum;
|
{ $$ = $accum;
|
||||||
for (auto & [i, iPos] : $attrs) {
|
for (auto & [i, iPos] : $attrs) {
|
||||||
if ($accum->attrs.find(i.symbol) != $accum->attrs.end())
|
if ($accum->attrs->find(i.symbol) != $accum->attrs->end())
|
||||||
state->dupAttr(i.symbol, iPos, $accum->attrs[i.symbol].pos);
|
state->dupAttr(i.symbol, iPos, (*$accum->attrs)[i.symbol].pos);
|
||||||
$accum->attrs.emplace(
|
$accum->attrs->emplace(
|
||||||
i.symbol,
|
i.symbol,
|
||||||
ExprAttrs::AttrDef(state->exprs.add<ExprVar>(iPos, i.symbol), iPos, ExprAttrs::AttrDef::Kind::Inherited));
|
ExprAttrs::AttrDef(state->exprs.add<ExprVar>(iPos, i.symbol), iPos, ExprAttrs::AttrDef::Kind::Inherited));
|
||||||
}
|
}
|
||||||
@@ -423,13 +418,13 @@ binds1
|
|||||||
| binds[accum] INHERIT '(' expr ')' attrs ';'
|
| binds[accum] INHERIT '(' expr ')' attrs ';'
|
||||||
{ $$ = $accum;
|
{ $$ = $accum;
|
||||||
if (!$accum->inheritFromExprs)
|
if (!$accum->inheritFromExprs)
|
||||||
$accum->inheritFromExprs = std::make_unique<std::vector<Expr *>>();
|
$accum->inheritFromExprs = std::make_unique<std::pmr::vector<Expr *>>();
|
||||||
$accum->inheritFromExprs->push_back($expr);
|
$accum->inheritFromExprs->push_back($expr);
|
||||||
auto from = state->exprs.add<ExprInheritFrom>(state->at(@expr), $accum->inheritFromExprs->size() - 1);
|
auto from = state->exprs.add<ExprInheritFrom>(state->at(@expr), $accum->inheritFromExprs->size() - 1);
|
||||||
for (auto & [i, iPos] : $attrs) {
|
for (auto & [i, iPos] : $attrs) {
|
||||||
if ($accum->attrs.find(i.symbol) != $accum->attrs.end())
|
if ($accum->attrs->find(i.symbol) != $accum->attrs->end())
|
||||||
state->dupAttr(i.symbol, iPos, $accum->attrs[i.symbol].pos);
|
state->dupAttr(i.symbol, iPos, (*$accum->attrs)[i.symbol].pos);
|
||||||
$accum->attrs.emplace(
|
$accum->attrs->emplace(
|
||||||
i.symbol,
|
i.symbol,
|
||||||
ExprAttrs::AttrDef(
|
ExprAttrs::AttrDef(
|
||||||
state->exprs.add<ExprSelect>(state->exprs.alloc, iPos, from, i.symbol),
|
state->exprs.add<ExprSelect>(state->exprs.alloc, iPos, from, i.symbol),
|
||||||
@@ -447,15 +442,15 @@ attrs
|
|||||||
: attrs attr { $$ = std::move($1); $$.emplace_back(state->symbols.create($2), state->at(@2)); }
|
: attrs attr { $$ = std::move($1); $$.emplace_back(state->symbols.create($2), state->at(@2)); }
|
||||||
| attrs string_attr
|
| attrs string_attr
|
||||||
{ $$ = std::move($1);
|
{ $$ = std::move($1);
|
||||||
std::visit(overloaded {
|
$2.visit(overloaded{
|
||||||
[&](std::string_view str) { $$.emplace_back(state->symbols.create(str), state->at(@2)); },
|
[&](std::string_view str) { $$.emplace_back(state->symbols.create(str), state->at(@2)); },
|
||||||
[&](Expr * expr) {
|
[&](Expr * expr) {
|
||||||
throw ParseError({
|
throw ParseError({
|
||||||
.msg = HintFmt("dynamic attributes not allowed in inherit"),
|
.msg = HintFmt("dynamic attributes not allowed in inherit"),
|
||||||
.pos = state->positions[state->at(@2)]
|
.pos = state->positions[state->at(@2)]
|
||||||
});
|
});
|
||||||
}
|
}}
|
||||||
}, $2);
|
);
|
||||||
}
|
}
|
||||||
| { }
|
| { }
|
||||||
;
|
;
|
||||||
@@ -464,17 +459,17 @@ attrpath
|
|||||||
: attrpath '.' attr { $$ = std::move($1); $$.emplace_back(state->symbols.create($3)); }
|
: attrpath '.' attr { $$ = std::move($1); $$.emplace_back(state->symbols.create($3)); }
|
||||||
| attrpath '.' string_attr
|
| attrpath '.' string_attr
|
||||||
{ $$ = std::move($1);
|
{ $$ = std::move($1);
|
||||||
std::visit(overloaded {
|
$3.visit(overloaded{
|
||||||
[&](std::string_view str) { $$.emplace_back(state->symbols.create(str)); },
|
[&](std::string_view str) { $$.emplace_back(state->symbols.create(str)); },
|
||||||
[&](Expr * expr) { $$.emplace_back(expr); }
|
[&](Expr * expr) { $$.emplace_back(expr); }}
|
||||||
}, std::move($3));
|
);
|
||||||
}
|
}
|
||||||
| attr { $$.emplace_back(state->symbols.create($1)); }
|
| attr { $$.emplace_back(state->symbols.create($1)); }
|
||||||
| string_attr
|
| string_attr
|
||||||
{ std::visit(overloaded {
|
{ $1.visit(overloaded{
|
||||||
[&](std::string_view str) { $$.emplace_back(state->symbols.create(str)); },
|
[&](std::string_view str) { $$.emplace_back(state->symbols.create(str)); },
|
||||||
[&](Expr * expr) { $$.emplace_back(expr); }
|
[&](Expr * expr) { $$.emplace_back(expr); }}
|
||||||
}, std::move($1));
|
);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -485,7 +480,7 @@ attr
|
|||||||
|
|
||||||
string_attr
|
string_attr
|
||||||
: '"' string_parts '"' { $$ = std::move($2); }
|
: '"' string_parts '"' { $$ = std::move($2); }
|
||||||
| DOLLAR_CURLY expr '}' { $$ = $2; }
|
| DOLLAR_CURLY expr '}' { $$ = {$2}; }
|
||||||
;
|
;
|
||||||
|
|
||||||
list
|
list
|
||||||
|
|||||||
+25
-44
@@ -53,7 +53,7 @@ RegisterPrimOp::PrimOps & RegisterPrimOp::primOps()
|
|||||||
static inline Value * mkString(EvalState & state, const std::csub_match & match)
|
static inline Value * mkString(EvalState & state, const std::csub_match & match)
|
||||||
{
|
{
|
||||||
Value * v = state.allocValue();
|
Value * v = state.allocValue();
|
||||||
v->mkString({match.first, match.second});
|
v->mkString({match.first, match.second}, state.mem);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,12 +230,12 @@ void derivationToValue(
|
|||||||
NixStringContextElem::DrvDeep{.drvPath = storePath},
|
NixStringContextElem::DrvDeep{.drvPath = storePath},
|
||||||
},
|
},
|
||||||
state.mem);
|
state.mem);
|
||||||
attrs.alloc(state.s.name).mkString(drv.env["name"]);
|
attrs.alloc(state.s.name).mkString(drv.env["name"], state.mem);
|
||||||
|
|
||||||
auto list = state.buildList(drv.outputs.size());
|
auto list = state.buildList(drv.outputs.size());
|
||||||
for (const auto & [i, o] : enumerate(drv.outputs)) {
|
for (const auto & [i, o] : enumerate(drv.outputs)) {
|
||||||
mkOutputString(state, attrs, storePath, o);
|
mkOutputString(state, attrs, storePath, o);
|
||||||
(list[i] = state.allocValue())->mkString(o.first);
|
(list[i] = state.allocValue())->mkString(o.first, state.mem);
|
||||||
}
|
}
|
||||||
attrs.alloc(state.s.outputs).mkList(list);
|
attrs.alloc(state.s.outputs).mkList(list);
|
||||||
|
|
||||||
@@ -519,7 +519,7 @@ static void prim_typeOf(EvalState & state, const PosIdx pos, Value ** args, Valu
|
|||||||
v.mkStringNoCopy("lambda"_sds);
|
v.mkStringNoCopy("lambda"_sds);
|
||||||
break;
|
break;
|
||||||
case nExternal:
|
case nExternal:
|
||||||
v.mkString(args[0]->external()->typeOf());
|
v.mkString(args[0]->external()->typeOf(), state.mem);
|
||||||
break;
|
break;
|
||||||
case nFloat:
|
case nFloat:
|
||||||
v.mkStringNoCopy("float"_sds);
|
v.mkStringNoCopy("float"_sds);
|
||||||
@@ -1176,7 +1176,7 @@ static void prim_getEnv(EvalState & state, const PosIdx pos, Value ** args, Valu
|
|||||||
{
|
{
|
||||||
std::string name(
|
std::string name(
|
||||||
state.forceStringNoCtx(*args[0], pos, "while evaluating the first argument passed to builtins.getEnv"));
|
state.forceStringNoCtx(*args[0], pos, "while evaluating the first argument passed to builtins.getEnv"));
|
||||||
v.mkString(state.settings.restrictEval || state.settings.pureEval ? "" : getEnv(name).value_or(""));
|
v.mkString(state.settings.restrictEval || state.settings.pureEval ? "" : getEnv(name).value_or(""), state.mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp primop_getEnv({
|
static RegisterPrimOp primop_getEnv({
|
||||||
@@ -1774,28 +1774,7 @@ static void derivationStrictInternal(EvalState & state, std::string_view drvName
|
|||||||
drv.outputs.insert_or_assign(i, DerivationOutput::Deferred{});
|
drv.outputs.insert_or_assign(i, DerivationOutput::Deferred{});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hashModulo = hashDerivationModulo(*state.store, Derivation(drv), true);
|
drv.fillInOutputPaths(*state.store);
|
||||||
switch (hashModulo.kind) {
|
|
||||||
case DrvHash::Kind::Regular:
|
|
||||||
for (auto & i : outputs) {
|
|
||||||
auto h = get(hashModulo.hashes, i);
|
|
||||||
if (!h)
|
|
||||||
state.error<AssertionError>("derivation produced no hash for output '%s'", i).atPos(v).debugThrow();
|
|
||||||
auto outPath = state.store->makeOutputPath(i, *h, drvName);
|
|
||||||
drv.env[i] = state.store->printStorePath(outPath);
|
|
||||||
drv.outputs.insert_or_assign(
|
|
||||||
i,
|
|
||||||
DerivationOutput::InputAddressed{
|
|
||||||
.path = std::move(outPath),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
;
|
|
||||||
case DrvHash::Kind::Deferred:
|
|
||||||
for (auto & i : outputs) {
|
|
||||||
drv.outputs.insert_or_assign(i, DerivationOutput::Deferred{});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the resulting term into the Nix store directory. */
|
/* Write the resulting term into the Nix store directory. */
|
||||||
@@ -1842,8 +1821,10 @@ static RegisterPrimOp primop_derivationStrict(
|
|||||||
‘out’. */
|
‘out’. */
|
||||||
static void prim_placeholder(EvalState & state, const PosIdx pos, Value ** args, Value & v)
|
static void prim_placeholder(EvalState & state, const PosIdx pos, Value ** args, Value & v)
|
||||||
{
|
{
|
||||||
v.mkString(hashPlaceholder(
|
v.mkString(
|
||||||
state.forceStringNoCtx(*args[0], pos, "while evaluating the first argument passed to builtins.placeholder")));
|
hashPlaceholder(state.forceStringNoCtx(
|
||||||
|
*args[0], pos, "while evaluating the first argument passed to builtins.placeholder")),
|
||||||
|
state.mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp primop_placeholder({
|
static RegisterPrimOp primop_placeholder({
|
||||||
@@ -2027,7 +2008,7 @@ static void prim_dirOf(EvalState & state, const PosIdx pos, Value ** args, Value
|
|||||||
state.forceValue(*args[0], pos);
|
state.forceValue(*args[0], pos);
|
||||||
if (args[0]->type() == nPath) {
|
if (args[0]->type() == nPath) {
|
||||||
auto path = args[0]->path();
|
auto path = args[0]->path();
|
||||||
v.mkPath(path.path.isRoot() ? path : path.parent());
|
v.mkPath(path.path.isRoot() ? path : path.parent(), state.mem);
|
||||||
} else {
|
} else {
|
||||||
NixStringContext context;
|
NixStringContext context;
|
||||||
auto path = state.coerceToString(
|
auto path = state.coerceToString(
|
||||||
@@ -2144,7 +2125,7 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value ** args, Va
|
|||||||
auto path =
|
auto path =
|
||||||
state.forceStringNoCtx(*args[1], pos, "while evaluating the second argument passed to builtins.findFile");
|
state.forceStringNoCtx(*args[1], pos, "while evaluating the second argument passed to builtins.findFile");
|
||||||
|
|
||||||
v.mkPath(state.findFile(lookupPath, path, pos));
|
v.mkPath(state.findFile(lookupPath, path, pos), state.mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp primop_findFile(
|
static RegisterPrimOp primop_findFile(
|
||||||
@@ -2293,7 +2274,7 @@ static void prim_hashFile(EvalState & state, const PosIdx pos, Value ** args, Va
|
|||||||
|
|
||||||
auto path = realisePath(state, pos, *args[1]);
|
auto path = realisePath(state, pos, *args[1]);
|
||||||
|
|
||||||
v.mkString(hashString(*ha, path.readFile()).to_string(HashFormat::Base16, false));
|
v.mkString(hashString(*ha, path.readFile()).to_string(HashFormat::Base16, false), state.mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp primop_hashFile({
|
static RegisterPrimOp primop_hashFile({
|
||||||
@@ -2382,7 +2363,7 @@ static void prim_readDir(EvalState & state, const PosIdx pos, Value ** args, Val
|
|||||||
// detailed node info quickly in this case we produce a thunk to
|
// detailed node info quickly in this case we produce a thunk to
|
||||||
// query the file type lazily.
|
// query the file type lazily.
|
||||||
auto epath = state.allocValue();
|
auto epath = state.allocValue();
|
||||||
epath->mkPath(path / name);
|
epath->mkPath(path / name, state.mem);
|
||||||
if (!readFileType)
|
if (!readFileType)
|
||||||
readFileType = &state.getBuiltin("readFileType");
|
readFileType = &state.getBuiltin("readFileType");
|
||||||
attr.mkApp(readFileType, epath);
|
attr.mkApp(readFileType, epath);
|
||||||
@@ -2763,7 +2744,7 @@ bool EvalState::callPathFilter(Value * filterFun, const SourcePath & path, PosId
|
|||||||
/* Call the filter function. The first argument is the path, the
|
/* Call the filter function. The first argument is the path, the
|
||||||
second is a string indicating the type of the file. */
|
second is a string indicating the type of the file. */
|
||||||
Value arg1;
|
Value arg1;
|
||||||
arg1.mkString(path.path.abs());
|
arg1.mkString(path.path.abs(), mem);
|
||||||
|
|
||||||
// assert that type is not "unknown"
|
// assert that type is not "unknown"
|
||||||
Value * args[]{&arg1, const_cast<Value *>(&fileTypeToString(*this, st.type))};
|
Value * args[]{&arg1, const_cast<Value *>(&fileTypeToString(*this, st.type))};
|
||||||
@@ -4541,7 +4522,7 @@ static void prim_hashString(EvalState & state, const PosIdx pos, Value ** args,
|
|||||||
auto s =
|
auto s =
|
||||||
state.forceString(*args[1], context, pos, "while evaluating the second argument passed to builtins.hashString");
|
state.forceString(*args[1], context, pos, "while evaluating the second argument passed to builtins.hashString");
|
||||||
|
|
||||||
v.mkString(hashString(*ha, s).to_string(HashFormat::Base16, false));
|
v.mkString(hashString(*ha, s).to_string(HashFormat::Base16, false), state.mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp primop_hashString({
|
static RegisterPrimOp primop_hashString({
|
||||||
@@ -4574,7 +4555,7 @@ static void prim_convertHash(EvalState & state, const PosIdx pos, Value ** args,
|
|||||||
HashFormat hf = parseHashFormat(
|
HashFormat hf = parseHashFormat(
|
||||||
state.forceStringNoCtx(*iteratorToHashFormat->value, pos, "while evaluating the attribute 'toHashFormat'"));
|
state.forceStringNoCtx(*iteratorToHashFormat->value, pos, "while evaluating the attribute 'toHashFormat'"));
|
||||||
|
|
||||||
v.mkString(Hash::parseAny(hash, ha).to_string(hf, hf == HashFormat::SRI));
|
v.mkString(Hash::parseAny(hash, ha).to_string(hf, hf == HashFormat::SRI), state.mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp primop_convertHash({
|
static RegisterPrimOp primop_convertHash({
|
||||||
@@ -4992,8 +4973,8 @@ static void prim_parseDrvName(EvalState & state, const PosIdx pos, Value ** args
|
|||||||
state.forceStringNoCtx(*args[0], pos, "while evaluating the first argument passed to builtins.parseDrvName");
|
state.forceStringNoCtx(*args[0], pos, "while evaluating the first argument passed to builtins.parseDrvName");
|
||||||
DrvName parsed(name);
|
DrvName parsed(name);
|
||||||
auto attrs = state.buildBindings(2);
|
auto attrs = state.buildBindings(2);
|
||||||
attrs.alloc(state.s.name).mkString(parsed.name);
|
attrs.alloc(state.s.name).mkString(parsed.name, state.mem);
|
||||||
attrs.alloc("version").mkString(parsed.version);
|
attrs.alloc("version").mkString(parsed.version, state.mem);
|
||||||
v.mkAttrs(attrs);
|
v.mkAttrs(attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5048,7 +5029,7 @@ static void prim_splitVersion(EvalState & state, const PosIdx pos, Value ** args
|
|||||||
}
|
}
|
||||||
auto list = state.buildList(components.size());
|
auto list = state.buildList(components.size());
|
||||||
for (const auto & [n, component] : enumerate(components))
|
for (const auto & [n, component] : enumerate(components))
|
||||||
(list[n] = state.allocValue())->mkString(std::move(component));
|
(list[n] = state.allocValue())->mkString(std::move(component), state.mem);
|
||||||
v.mkList(list);
|
v.mkList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5192,7 +5173,7 @@ void EvalState::createBaseEnv(const EvalSettings & evalSettings)
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!settings.pureEval)
|
if (!settings.pureEval)
|
||||||
v.mkString(settings.getCurrentSystem());
|
v.mkString(settings.getCurrentSystem(), mem);
|
||||||
addConstant(
|
addConstant(
|
||||||
"__currentSystem",
|
"__currentSystem",
|
||||||
v,
|
v,
|
||||||
@@ -5224,7 +5205,7 @@ void EvalState::createBaseEnv(const EvalSettings & evalSettings)
|
|||||||
.impureOnly = true,
|
.impureOnly = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
v.mkString(nixVersion);
|
v.mkString(nixVersion, mem);
|
||||||
addConstant(
|
addConstant(
|
||||||
"__nixVersion",
|
"__nixVersion",
|
||||||
v,
|
v,
|
||||||
@@ -5249,7 +5230,7 @@ void EvalState::createBaseEnv(const EvalSettings & evalSettings)
|
|||||||
)",
|
)",
|
||||||
});
|
});
|
||||||
|
|
||||||
v.mkString(store->storeDir);
|
v.mkString(store->storeDir, mem);
|
||||||
addConstant(
|
addConstant(
|
||||||
"__storeDir",
|
"__storeDir",
|
||||||
v,
|
v,
|
||||||
@@ -5314,8 +5295,8 @@ void EvalState::createBaseEnv(const EvalSettings & evalSettings)
|
|||||||
auto list = buildList(lookupPath.elements.size());
|
auto list = buildList(lookupPath.elements.size());
|
||||||
for (const auto & [n, i] : enumerate(lookupPath.elements)) {
|
for (const auto & [n, i] : enumerate(lookupPath.elements)) {
|
||||||
auto attrs = buildBindings(2);
|
auto attrs = buildBindings(2);
|
||||||
attrs.alloc("path").mkString(i.path.s);
|
attrs.alloc("path").mkString(i.path.s, mem);
|
||||||
attrs.alloc("prefix").mkString(i.prefix.s);
|
attrs.alloc("prefix").mkString(i.prefix.s, mem);
|
||||||
(list[n] = allocValue())->mkAttrs(attrs);
|
(list[n] = allocValue())->mkAttrs(attrs);
|
||||||
}
|
}
|
||||||
v.mkList(list);
|
v.mkList(list);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ static void prim_unsafeDiscardStringContext(EvalState & state, const PosIdx pos,
|
|||||||
NixStringContext context;
|
NixStringContext context;
|
||||||
auto s = state.coerceToString(
|
auto s = state.coerceToString(
|
||||||
pos, *args[0], context, "while evaluating the argument passed to builtins.unsafeDiscardStringContext");
|
pos, *args[0], context, "while evaluating the argument passed to builtins.unsafeDiscardStringContext");
|
||||||
v.mkString(*s);
|
v.mkString(*s, state.mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp primop_unsafeDiscardStringContext({
|
static RegisterPrimOp primop_unsafeDiscardStringContext({
|
||||||
@@ -218,7 +218,7 @@ static void prim_getContext(EvalState & state, const PosIdx pos, Value ** args,
|
|||||||
if (!info.second.outputs.empty()) {
|
if (!info.second.outputs.empty()) {
|
||||||
auto list = state.buildList(info.second.outputs.size());
|
auto list = state.buildList(info.second.outputs.size());
|
||||||
for (const auto & [i, output] : enumerate(info.second.outputs))
|
for (const auto & [i, output] : enumerate(info.second.outputs))
|
||||||
(list[i] = state.allocValue())->mkString(output);
|
(list[i] = state.allocValue())->mkString(output, state.mem);
|
||||||
infoAttrs.alloc(state.s.outputs).mkList(list);
|
infoAttrs.alloc(state.s.outputs).mkList(list);
|
||||||
}
|
}
|
||||||
attrs.alloc(state.store->printStorePath(info.first)).mkAttrs(infoAttrs);
|
attrs.alloc(state.store->printStorePath(info.first)).mkAttrs(infoAttrs);
|
||||||
|
|||||||
@@ -81,17 +81,17 @@ static void prim_fetchMercurial(EvalState & state, const PosIdx pos, Value ** ar
|
|||||||
attrs.insert_or_assign("rev", rev->gitRev());
|
attrs.insert_or_assign("rev", rev->gitRev());
|
||||||
auto input = fetchers::Input::fromAttrs(state.fetchSettings, std::move(attrs));
|
auto input = fetchers::Input::fromAttrs(state.fetchSettings, std::move(attrs));
|
||||||
|
|
||||||
auto [storePath, input2] = input.fetchToStore(state.fetchSettings, state.store);
|
auto [storePath, input2] = input.fetchToStore(state.fetchSettings, *state.store);
|
||||||
|
|
||||||
auto attrs2 = state.buildBindings(8);
|
auto attrs2 = state.buildBindings(8);
|
||||||
state.mkStorePathString(storePath, attrs2.alloc(state.s.outPath));
|
state.mkStorePathString(storePath, attrs2.alloc(state.s.outPath));
|
||||||
if (input2.getRef())
|
if (input2.getRef())
|
||||||
attrs2.alloc("branch").mkString(*input2.getRef());
|
attrs2.alloc("branch").mkString(*input2.getRef(), state.mem);
|
||||||
// Backward compatibility: set 'rev' to
|
// Backward compatibility: set 'rev' to
|
||||||
// 0000000000000000000000000000000000000000 for a dirty tree.
|
// 0000000000000000000000000000000000000000 for a dirty tree.
|
||||||
auto rev2 = input2.getRev().value_or(Hash(HashAlgorithm::SHA1));
|
auto rev2 = input2.getRev().value_or(Hash(HashAlgorithm::SHA1));
|
||||||
attrs2.alloc("rev").mkString(rev2.gitRev());
|
attrs2.alloc("rev").mkString(rev2.gitRev(), state.mem);
|
||||||
attrs2.alloc("shortRev").mkString(rev2.gitRev().substr(0, 12));
|
attrs2.alloc("shortRev").mkString(rev2.gitRev().substr(0, 12), state.mem);
|
||||||
if (auto revCount = input2.getRevCount())
|
if (auto revCount = input2.getRevCount())
|
||||||
attrs2.alloc("revCount").mkInt(*revCount);
|
attrs2.alloc("revCount").mkInt(*revCount);
|
||||||
v.mkAttrs(attrs2);
|
v.mkAttrs(attrs2);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ void emitTreeAttrs(
|
|||||||
// FIXME: support arbitrary input attributes.
|
// FIXME: support arbitrary input attributes.
|
||||||
|
|
||||||
if (auto narHash = input.getNarHash())
|
if (auto narHash = input.getNarHash())
|
||||||
attrs.alloc("narHash").mkString(narHash->to_string(HashFormat::SRI, true));
|
attrs.alloc("narHash").mkString(narHash->to_string(HashFormat::SRI, true), state.mem);
|
||||||
|
|
||||||
if (input.getType() == "git")
|
if (input.getType() == "git")
|
||||||
attrs.alloc("submodules").mkBool(fetchers::maybeGetBoolAttr(input.attrs, "submodules").value_or(false));
|
attrs.alloc("submodules").mkBool(fetchers::maybeGetBoolAttr(input.attrs, "submodules").value_or(false));
|
||||||
@@ -43,13 +43,13 @@ void emitTreeAttrs(
|
|||||||
if (!forceDirty) {
|
if (!forceDirty) {
|
||||||
|
|
||||||
if (auto rev = input.getRev()) {
|
if (auto rev = input.getRev()) {
|
||||||
attrs.alloc("rev").mkString(rev->gitRev());
|
attrs.alloc("rev").mkString(rev->gitRev(), state.mem);
|
||||||
attrs.alloc("shortRev").mkString(rev->gitShortRev());
|
attrs.alloc("shortRev").mkString(rev->gitShortRev(), state.mem);
|
||||||
} else if (emptyRevFallback) {
|
} else if (emptyRevFallback) {
|
||||||
// Backwards compat for `builtins.fetchGit`: dirty repos return an empty sha1 as rev
|
// Backwards compat for `builtins.fetchGit`: dirty repos return an empty sha1 as rev
|
||||||
auto emptyHash = Hash(HashAlgorithm::SHA1);
|
auto emptyHash = Hash(HashAlgorithm::SHA1);
|
||||||
attrs.alloc("rev").mkString(emptyHash.gitRev());
|
attrs.alloc("rev").mkString(emptyHash.gitRev(), state.mem);
|
||||||
attrs.alloc("shortRev").mkString(emptyHash.gitShortRev());
|
attrs.alloc("shortRev").mkString(emptyHash.gitShortRev(), state.mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto revCount = input.getRevCount())
|
if (auto revCount = input.getRevCount())
|
||||||
@@ -59,13 +59,14 @@ void emitTreeAttrs(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (auto dirtyRev = fetchers::maybeGetStrAttr(input.attrs, "dirtyRev")) {
|
if (auto dirtyRev = fetchers::maybeGetStrAttr(input.attrs, "dirtyRev")) {
|
||||||
attrs.alloc("dirtyRev").mkString(*dirtyRev);
|
attrs.alloc("dirtyRev").mkString(*dirtyRev, state.mem);
|
||||||
attrs.alloc("dirtyShortRev").mkString(*fetchers::maybeGetStrAttr(input.attrs, "dirtyShortRev"));
|
attrs.alloc("dirtyShortRev").mkString(*fetchers::maybeGetStrAttr(input.attrs, "dirtyShortRev"), state.mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto lastModified = input.getLastModified()) {
|
if (auto lastModified = input.getLastModified()) {
|
||||||
attrs.alloc("lastModified").mkInt(*lastModified);
|
attrs.alloc("lastModified").mkInt(*lastModified);
|
||||||
attrs.alloc("lastModifiedDate").mkString(fmt("%s", std::put_time(std::gmtime(&*lastModified), "%Y%m%d%H%M%S")));
|
attrs.alloc("lastModifiedDate")
|
||||||
|
.mkString(fmt("%s", std::put_time(std::gmtime(&*lastModified), "%Y%m%d%H%M%S")), state.mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
v.mkAttrs(attrs);
|
v.mkAttrs(attrs);
|
||||||
@@ -194,7 +195,7 @@ static void fetchTree(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!state.settings.pureEval && !input.isDirect() && experimentalFeatureSettings.isEnabled(Xp::Flakes))
|
if (!state.settings.pureEval && !input.isDirect() && experimentalFeatureSettings.isEnabled(Xp::Flakes))
|
||||||
input = lookupInRegistries(state.fetchSettings, state.store, input, fetchers::UseRegistries::Limited).first;
|
input = lookupInRegistries(state.fetchSettings, *state.store, input, fetchers::UseRegistries::Limited).first;
|
||||||
|
|
||||||
if (state.settings.pureEval && !input.isLocked(state.fetchSettings)) {
|
if (state.settings.pureEval && !input.isLocked(state.fetchSettings)) {
|
||||||
if (input.getNarHash())
|
if (input.getNarHash())
|
||||||
@@ -220,7 +221,7 @@ static void fetchTree(
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto cachedInput =
|
auto cachedInput =
|
||||||
state.inputCache->getAccessor(state.fetchSettings, state.store, input, fetchers::UseRegistries::No);
|
state.inputCache->getAccessor(state.fetchSettings, *state.store, input, fetchers::UseRegistries::No);
|
||||||
|
|
||||||
auto storePath = state.mountInput(cachedInput.lockedInput, input, cachedInput.accessor);
|
auto storePath = state.mountInput(cachedInput.lockedInput, input, cachedInput.accessor);
|
||||||
|
|
||||||
@@ -480,10 +481,10 @@ static void fetch(
|
|||||||
auto storePath = unpack ? fetchToStore(
|
auto storePath = unpack ? fetchToStore(
|
||||||
state.fetchSettings,
|
state.fetchSettings,
|
||||||
*state.store,
|
*state.store,
|
||||||
fetchers::downloadTarball(state.store, state.fetchSettings, *url),
|
fetchers::downloadTarball(*state.store, state.fetchSettings, *url),
|
||||||
FetchMode::Copy,
|
FetchMode::Copy,
|
||||||
name)
|
name)
|
||||||
: fetchers::downloadFile(state.store, state.fetchSettings, *url, name).storePath;
|
: fetchers::downloadFile(*state.store, state.fetchSettings, *url, name).storePath;
|
||||||
|
|
||||||
if (expectedHash) {
|
if (expectedHash) {
|
||||||
auto hash = unpack ? state.store->queryPathInfo(storePath)->narHash
|
auto hash = unpack ? state.store->queryPathInfo(storePath)->narHash
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value ** args, Va
|
|||||||
case toml::value_t::string: {
|
case toml::value_t::string: {
|
||||||
auto s = toml::get<std::string_view>(t);
|
auto s = toml::get<std::string_view>(t);
|
||||||
forceNoNullByte(s);
|
forceNoNullByte(s);
|
||||||
v.mkString(s);
|
v.mkString(s, state.mem);
|
||||||
} break;
|
} break;
|
||||||
case toml::value_t::local_datetime:
|
case toml::value_t::local_datetime:
|
||||||
case toml::value_t::offset_datetime:
|
case toml::value_t::offset_datetime:
|
||||||
@@ -142,7 +142,7 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value ** args, Va
|
|||||||
s << t;
|
s << t;
|
||||||
auto str = s.view();
|
auto str = s.view();
|
||||||
forceNoNullByte(str);
|
forceNoNullByte(str);
|
||||||
attrs.alloc("value").mkString(str);
|
attrs.alloc("value").mkString(str, state.mem);
|
||||||
v.mkAttrs(attrs);
|
v.mkAttrs(attrs);
|
||||||
} else {
|
} else {
|
||||||
throw std::runtime_error("Dates and times are not supported");
|
throw std::runtime_error("Dates and times are not supported");
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ json printValueAsJSON(
|
|||||||
{
|
{
|
||||||
checkInterrupt();
|
checkInterrupt();
|
||||||
|
|
||||||
|
auto _level = state.addCallDepth(pos);
|
||||||
|
|
||||||
if (strict)
|
if (strict)
|
||||||
state.forceValue(v, pos);
|
state.forceValue(v, pos);
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ TEST_F(GitUtilsTest, sink_basic)
|
|||||||
// sink->createHardlink("foo-1.1/links/foo-2", CanonPath("foo-1.1/hello"));
|
// sink->createHardlink("foo-1.1/links/foo-2", CanonPath("foo-1.1/hello"));
|
||||||
|
|
||||||
auto result = repo->dereferenceSingletonDirectory(sink->flush());
|
auto result = repo->dereferenceSingletonDirectory(sink->flush());
|
||||||
auto accessor = repo->getAccessor(result, false, getRepoName());
|
auto accessor = repo->getAccessor(result, {}, getRepoName());
|
||||||
auto entries = accessor->readDirectory(CanonPath::root);
|
auto entries = accessor->readDirectory(CanonPath::root);
|
||||||
ASSERT_EQ(entries.size(), 5u);
|
ASSERT_EQ(entries.size(), 5u);
|
||||||
ASSERT_EQ(accessor->readFile(CanonPath("hello")), "hello world");
|
ASSERT_EQ(accessor->readFile(CanonPath("hello")), "hello world");
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ TEST_F(GitTest, submodulePeriodSupport)
|
|||||||
{"ref", "main"},
|
{"ref", "main"},
|
||||||
});
|
});
|
||||||
|
|
||||||
auto [accessor, i] = input.getAccessor(settings, store);
|
auto [accessor, i] = input.getAccessor(settings, *store);
|
||||||
|
|
||||||
ASSERT_EQ(accessor->readFile(CanonPath("deps/sub/lib.txt")), "hello from submodule\n");
|
ASSERT_EQ(accessor->readFile(CanonPath("deps/sub/lib.txt")), "hello from submodule\n");
|
||||||
}
|
}
|
||||||
+26
-15
@@ -6,6 +6,7 @@
|
|||||||
#include "nix/fetchers/fetch-settings.hh"
|
#include "nix/fetchers/fetch-settings.hh"
|
||||||
#include "nix/fetchers/fetch-to-store.hh"
|
#include "nix/fetchers/fetch-to-store.hh"
|
||||||
#include "nix/util/url.hh"
|
#include "nix/util/url.hh"
|
||||||
|
#include "nix/util/archive.hh"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
@@ -110,7 +111,7 @@ Input Input::fromAttrs(const Settings & settings, Attrs && attrs)
|
|||||||
return std::move(*res);
|
return std::move(*res);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> Input::getFingerprint(ref<Store> store) const
|
std::optional<std::string> Input::getFingerprint(Store & store) const
|
||||||
{
|
{
|
||||||
if (!scheme)
|
if (!scheme)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
@@ -189,7 +190,7 @@ bool Input::contains(const Input & other) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: remove
|
// FIXME: remove
|
||||||
std::pair<StorePath, Input> Input::fetchToStore(const Settings & settings, ref<Store> store) const
|
std::pair<StorePath, Input> Input::fetchToStore(const Settings & settings, Store & store) const
|
||||||
{
|
{
|
||||||
if (!scheme)
|
if (!scheme)
|
||||||
throw Error("cannot fetch unsupported input '%s'", attrsToJSON(toAttrs()));
|
throw Error("cannot fetch unsupported input '%s'", attrsToJSON(toAttrs()));
|
||||||
@@ -199,9 +200,9 @@ std::pair<StorePath, Input> Input::fetchToStore(const Settings & settings, ref<S
|
|||||||
auto [accessor, result] = getAccessorUnchecked(settings, store);
|
auto [accessor, result] = getAccessorUnchecked(settings, store);
|
||||||
|
|
||||||
auto storePath =
|
auto storePath =
|
||||||
nix::fetchToStore(settings, *store, SourcePath(accessor), FetchMode::Copy, result.getName());
|
nix::fetchToStore(settings, store, SourcePath(accessor), FetchMode::Copy, result.getName());
|
||||||
|
|
||||||
auto narHash = store->queryPathInfo(storePath)->narHash;
|
auto narHash = store.queryPathInfo(storePath)->narHash;
|
||||||
result.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
|
result.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
|
||||||
|
|
||||||
result.attrs.insert_or_assign("__final", Explicit<bool>(true));
|
result.attrs.insert_or_assign("__final", Explicit<bool>(true));
|
||||||
@@ -288,7 +289,7 @@ void Input::checkLocks(Input specified, Input & result)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input> Input::getAccessor(const Settings & settings, ref<Store> store) const
|
std::pair<ref<SourceAccessor>, Input> Input::getAccessor(const Settings & settings, Store & store) const
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto [accessor, result] = getAccessorUnchecked(settings, store);
|
auto [accessor, result] = getAccessorUnchecked(settings, store);
|
||||||
@@ -304,7 +305,7 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessor(const Settings & settin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(const Settings & settings, ref<Store> store) const
|
std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(const Settings & settings, Store & store) const
|
||||||
{
|
{
|
||||||
// FIXME: cache the accessor
|
// FIXME: cache the accessor
|
||||||
|
|
||||||
@@ -324,13 +325,13 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(const Settings
|
|||||||
*/
|
*/
|
||||||
if (isFinal() && getNarHash()) {
|
if (isFinal() && getNarHash()) {
|
||||||
try {
|
try {
|
||||||
auto storePath = computeStorePath(*store);
|
auto storePath = computeStorePath(store);
|
||||||
|
|
||||||
store->ensurePath(storePath);
|
store.ensurePath(storePath);
|
||||||
|
|
||||||
debug("using substituted/cached input '%s' in '%s'", to_string(), store->printStorePath(storePath));
|
debug("using substituted/cached input '%s' in '%s'", to_string(), store.printStorePath(storePath));
|
||||||
|
|
||||||
auto accessor = store->requireStoreObjectAccessor(storePath);
|
auto accessor = store.requireStoreObjectAccessor(storePath);
|
||||||
|
|
||||||
accessor->fingerprint = getFingerprint(store);
|
accessor->fingerprint = getFingerprint(store);
|
||||||
|
|
||||||
@@ -340,7 +341,7 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(const Settings
|
|||||||
if (accessor->fingerprint) {
|
if (accessor->fingerprint) {
|
||||||
ContentAddressMethod method = ContentAddressMethod::Raw::NixArchive;
|
ContentAddressMethod method = ContentAddressMethod::Raw::NixArchive;
|
||||||
auto cacheKey = makeFetchToStoreCacheKey(getName(), *accessor->fingerprint, method, "/");
|
auto cacheKey = makeFetchToStoreCacheKey(getName(), *accessor->fingerprint, method, "/");
|
||||||
settings.getCache()->upsert(cacheKey, *store, {}, storePath);
|
settings.getCache()->upsert(cacheKey, store, {}, storePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
accessor->setPathDisplay("«" + to_string() + "»");
|
accessor->setPathDisplay("«" + to_string() + "»");
|
||||||
@@ -368,10 +369,10 @@ Input Input::applyOverrides(std::optional<std::string> ref, std::optional<Hash>
|
|||||||
return scheme->applyOverrides(*this, ref, rev);
|
return scheme->applyOverrides(*this, ref, rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::clone(const Settings & settings, const Path & destDir) const
|
void Input::clone(const Settings & settings, Store & store, const std::filesystem::path & destDir) const
|
||||||
{
|
{
|
||||||
assert(scheme);
|
assert(scheme);
|
||||||
scheme->clone(settings, *this, destDir);
|
scheme->clone(settings, store, *this, destDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::filesystem::path> Input::getSourcePath() const
|
std::optional<std::filesystem::path> Input::getSourcePath() const
|
||||||
@@ -484,9 +485,19 @@ void InputScheme::putFile(
|
|||||||
throw Error("input '%s' does not support modifying file '%s'", input.to_string(), path);
|
throw Error("input '%s' does not support modifying file '%s'", input.to_string(), path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputScheme::clone(const Settings & settings, const Input & input, const Path & destDir) const
|
void InputScheme::clone(
|
||||||
|
const Settings & settings, Store & store, const Input & input, const std::filesystem::path & destDir) const
|
||||||
{
|
{
|
||||||
throw Error("do not know how to clone input '%s'", input.to_string());
|
if (std::filesystem::exists(destDir))
|
||||||
|
throw Error("cannot clone into existing path %s", destDir);
|
||||||
|
|
||||||
|
auto [accessor, input2] = getAccessor(settings, store, input);
|
||||||
|
|
||||||
|
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying '%s' to %s...", input2.to_string(), destDir));
|
||||||
|
|
||||||
|
RestoreSink sink(/*startFsync=*/false);
|
||||||
|
sink.dstPath = destDir;
|
||||||
|
copyRecursive(*accessor, CanonPath::root, sink, CanonPath::root);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<ExperimentalFeature> InputScheme::experimentalFeature() const
|
std::optional<ExperimentalFeature> InputScheme::experimentalFeature() const
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ std::vector<nlohmann::json> Fetch::fetchUrls(const std::vector<Pointer> & pointe
|
|||||||
auto url = api.endpoint + "/objects/batch";
|
auto url = api.endpoint + "/objects/batch";
|
||||||
const auto & authHeader = api.authHeader;
|
const auto & authHeader = api.authHeader;
|
||||||
FileTransferRequest request(parseURL(url));
|
FileTransferRequest request(parseURL(url));
|
||||||
request.method = HttpMethod::POST;
|
request.method = HttpMethod::Post;
|
||||||
Headers headers;
|
Headers headers;
|
||||||
if (authHeader.has_value())
|
if (authHeader.has_value())
|
||||||
headers.push_back({"Authorization", *authHeader});
|
headers.push_back({"Authorization", *authHeader});
|
||||||
|
|||||||
@@ -541,14 +541,15 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A 'GitSourceAccessor' with no regard for export-ignore or any other transformations.
|
* A 'GitSourceAccessor' with no regard for export-ignore.
|
||||||
*/
|
*/
|
||||||
ref<GitSourceAccessor> getRawAccessor(const Hash & rev, bool smudgeLfs = false);
|
ref<GitSourceAccessor> getRawAccessor(const Hash & rev, const GitAccessorOptions & options);
|
||||||
|
|
||||||
ref<SourceAccessor>
|
ref<SourceAccessor>
|
||||||
getAccessor(const Hash & rev, bool exportIgnore, std::string displayPrefix, bool smudgeLfs = false) override;
|
getAccessor(const Hash & rev, const GitAccessorOptions & options, std::string displayPrefix) override;
|
||||||
|
|
||||||
ref<SourceAccessor> getAccessor(const WorkdirInfo & wd, bool exportIgnore, MakeNotAllowedError e) override;
|
ref<SourceAccessor>
|
||||||
|
getAccessor(const WorkdirInfo & wd, const GitAccessorOptions & options, MakeNotAllowedError e) override;
|
||||||
|
|
||||||
ref<GitFileSystemObjectSink> getFileSystemObjectSink() override;
|
ref<GitFileSystemObjectSink> getFileSystemObjectSink() override;
|
||||||
|
|
||||||
@@ -668,7 +669,7 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
|
|||||||
|
|
||||||
Hash treeHashToNarHash(const fetchers::Settings & settings, const Hash & treeHash) override
|
Hash treeHashToNarHash(const fetchers::Settings & settings, const Hash & treeHash) override
|
||||||
{
|
{
|
||||||
auto accessor = getAccessor(treeHash, false, "");
|
auto accessor = getAccessor(treeHash, {}, "");
|
||||||
|
|
||||||
fetchers::Cache::Key cacheKey{"treeHashToNarHash", {{"treeHash", treeHash.gitRev()}}};
|
fetchers::Cache::Key cacheKey{"treeHashToNarHash", {{"treeHash", treeHash.gitRev()}}};
|
||||||
|
|
||||||
@@ -716,15 +717,17 @@ struct GitSourceAccessor : SourceAccessor
|
|||||||
ref<GitRepoImpl> repo;
|
ref<GitRepoImpl> repo;
|
||||||
Object root;
|
Object root;
|
||||||
std::optional<lfs::Fetch> lfsFetch = std::nullopt;
|
std::optional<lfs::Fetch> lfsFetch = std::nullopt;
|
||||||
|
GitAccessorOptions options;
|
||||||
};
|
};
|
||||||
|
|
||||||
Sync<State> state_;
|
Sync<State> state_;
|
||||||
|
|
||||||
GitSourceAccessor(ref<GitRepoImpl> repo_, const Hash & rev, bool smudgeLfs)
|
GitSourceAccessor(ref<GitRepoImpl> repo_, const Hash & rev, const GitAccessorOptions & options)
|
||||||
: state_{State{
|
: state_{State{
|
||||||
.repo = repo_,
|
.repo = repo_,
|
||||||
.root = peelToTreeOrBlob(lookupObject(*repo_, hashToOID(rev)).get()),
|
.root = peelToTreeOrBlob(lookupObject(*repo_, hashToOID(rev)).get()),
|
||||||
.lfsFetch = smudgeLfs ? std::make_optional(lfs::Fetch(*repo_, hashToOID(rev))) : std::nullopt,
|
.lfsFetch = options.smudgeLfs ? std::make_optional(lfs::Fetch(*repo_, hashToOID(rev))) : std::nullopt,
|
||||||
|
.options = options,
|
||||||
}}
|
}}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1254,26 +1257,26 @@ struct GitFileSystemObjectSinkImpl : GitFileSystemObjectSink
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ref<GitSourceAccessor> GitRepoImpl::getRawAccessor(const Hash & rev, bool smudgeLfs)
|
ref<GitSourceAccessor> GitRepoImpl::getRawAccessor(const Hash & rev, const GitAccessorOptions & options)
|
||||||
{
|
{
|
||||||
auto self = ref<GitRepoImpl>(shared_from_this());
|
auto self = ref<GitRepoImpl>(shared_from_this());
|
||||||
return make_ref<GitSourceAccessor>(self, rev, smudgeLfs);
|
return make_ref<GitSourceAccessor>(self, rev, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<SourceAccessor>
|
ref<SourceAccessor>
|
||||||
GitRepoImpl::getAccessor(const Hash & rev, bool exportIgnore, std::string displayPrefix, bool smudgeLfs)
|
GitRepoImpl::getAccessor(const Hash & rev, const GitAccessorOptions & options, std::string displayPrefix)
|
||||||
{
|
{
|
||||||
auto self = ref<GitRepoImpl>(shared_from_this());
|
auto self = ref<GitRepoImpl>(shared_from_this());
|
||||||
ref<GitSourceAccessor> rawGitAccessor = getRawAccessor(rev, smudgeLfs);
|
ref<GitSourceAccessor> rawGitAccessor = getRawAccessor(rev, options);
|
||||||
rawGitAccessor->setPathDisplay(std::move(displayPrefix));
|
rawGitAccessor->setPathDisplay(std::move(displayPrefix));
|
||||||
if (exportIgnore)
|
if (options.exportIgnore)
|
||||||
return make_ref<GitExportIgnoreSourceAccessor>(self, rawGitAccessor, rev);
|
return make_ref<GitExportIgnoreSourceAccessor>(self, rawGitAccessor, rev);
|
||||||
else
|
else
|
||||||
return rawGitAccessor;
|
return rawGitAccessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<SourceAccessor>
|
ref<SourceAccessor> GitRepoImpl::getAccessor(
|
||||||
GitRepoImpl::getAccessor(const WorkdirInfo & wd, bool exportIgnore, MakeNotAllowedError makeNotAllowedError)
|
const WorkdirInfo & wd, const GitAccessorOptions & options, MakeNotAllowedError makeNotAllowedError)
|
||||||
{
|
{
|
||||||
auto self = ref<GitRepoImpl>(shared_from_this());
|
auto self = ref<GitRepoImpl>(shared_from_this());
|
||||||
ref<SourceAccessor> fileAccessor = AllowListSourceAccessor::create(
|
ref<SourceAccessor> fileAccessor = AllowListSourceAccessor::create(
|
||||||
@@ -1283,10 +1286,9 @@ GitRepoImpl::getAccessor(const WorkdirInfo & wd, bool exportIgnore, MakeNotAllow
|
|||||||
boost::unordered_flat_set<CanonPath>{CanonPath::root},
|
boost::unordered_flat_set<CanonPath>{CanonPath::root},
|
||||||
std::move(makeNotAllowedError))
|
std::move(makeNotAllowedError))
|
||||||
.cast<SourceAccessor>();
|
.cast<SourceAccessor>();
|
||||||
if (exportIgnore)
|
if (options.exportIgnore)
|
||||||
return make_ref<GitExportIgnoreSourceAccessor>(self, fileAccessor, std::nullopt);
|
fileAccessor = make_ref<GitExportIgnoreSourceAccessor>(self, fileAccessor, std::nullopt);
|
||||||
else
|
return fileAccessor;
|
||||||
return fileAccessor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<GitFileSystemObjectSink> GitRepoImpl::getFileSystemObjectSink()
|
ref<GitFileSystemObjectSink> GitRepoImpl::getFileSystemObjectSink()
|
||||||
@@ -1299,7 +1301,7 @@ std::vector<std::tuple<GitRepoImpl::Submodule, Hash>> GitRepoImpl::getSubmodules
|
|||||||
/* Read the .gitmodules files from this revision. */
|
/* Read the .gitmodules files from this revision. */
|
||||||
CanonPath modulesFile(".gitmodules");
|
CanonPath modulesFile(".gitmodules");
|
||||||
|
|
||||||
auto accessor = getAccessor(rev, exportIgnore, "");
|
auto accessor = getAccessor(rev, {.exportIgnore = exportIgnore}, "");
|
||||||
if (!accessor->pathExists(modulesFile))
|
if (!accessor->pathExists(modulesFile))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
@@ -1316,7 +1318,7 @@ std::vector<std::tuple<GitRepoImpl::Submodule, Hash>> GitRepoImpl::getSubmodules
|
|||||||
|
|
||||||
std::vector<std::tuple<Submodule, Hash>> result;
|
std::vector<std::tuple<Submodule, Hash>> result;
|
||||||
|
|
||||||
auto rawAccessor = getRawAccessor(rev);
|
auto rawAccessor = getRawAccessor(rev, {});
|
||||||
|
|
||||||
for (auto & submodule : parseSubmodules(pathTemp)) {
|
for (auto & submodule : parseSubmodules(pathTemp)) {
|
||||||
/* Filter out .gitmodules entries that don't exist or are not
|
/* Filter out .gitmodules entries that don't exist or are not
|
||||||
@@ -1332,10 +1334,8 @@ namespace fetchers {
|
|||||||
|
|
||||||
ref<GitRepo> Settings::getTarballCache() const
|
ref<GitRepo> Settings::getTarballCache() const
|
||||||
{
|
{
|
||||||
auto tarballCache(_tarballCache.lock());
|
static auto repoDir = std::filesystem::path(getCacheDir()) / "tarball-cache";
|
||||||
if (!*tarballCache)
|
return GitRepo::openRepo(repoDir, true, true);
|
||||||
*tarballCache = GitRepo::openRepo(std::filesystem::path(getCacheDir()) / "tarball-cache", true, true);
|
|
||||||
return ref<GitRepo>(*tarballCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace fetchers
|
} // namespace fetchers
|
||||||
|
|||||||
@@ -433,7 +433,8 @@ struct GitInputScheme : InputScheme
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clone(const Settings & settings, const Input & input, const Path & destDir) const override
|
void clone(const Settings & settings, Store & store, const Input & input, const std::filesystem::path & destDir)
|
||||||
|
const override
|
||||||
{
|
{
|
||||||
auto repoInfo = getRepoInfo(input);
|
auto repoInfo = getRepoInfo(input);
|
||||||
|
|
||||||
@@ -778,7 +779,7 @@ struct GitInputScheme : InputScheme
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input>
|
std::pair<ref<SourceAccessor>, Input>
|
||||||
getAccessorFromCommit(const Settings & settings, ref<Store> store, RepoInfo & repoInfo, Input && input) const
|
getAccessorFromCommit(const Settings & settings, Store & store, RepoInfo & repoInfo, Input && input) const
|
||||||
{
|
{
|
||||||
assert(!repoInfo.workdirInfo.isDirty);
|
assert(!repoInfo.workdirInfo.isDirty);
|
||||||
|
|
||||||
@@ -899,7 +900,8 @@ struct GitInputScheme : InputScheme
|
|||||||
|
|
||||||
bool exportIgnore = getExportIgnoreAttr(input);
|
bool exportIgnore = getExportIgnoreAttr(input);
|
||||||
bool smudgeLfs = getLfsAttr(input);
|
bool smudgeLfs = getLfsAttr(input);
|
||||||
auto accessor = repo->getAccessor(rev, exportIgnore, "«" + input.to_string() + "»", smudgeLfs);
|
auto accessor = repo->getAccessor(
|
||||||
|
rev, {.exportIgnore = exportIgnore, .smudgeLfs = smudgeLfs}, "«" + input.to_string() + "»");
|
||||||
|
|
||||||
/* If the repo has submodules, fetch them and return a mounted
|
/* If the repo has submodules, fetch them and return a mounted
|
||||||
input accessor consisting of the accessor for the top-level
|
input accessor consisting of the accessor for the top-level
|
||||||
@@ -952,7 +954,7 @@ struct GitInputScheme : InputScheme
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input>
|
std::pair<ref<SourceAccessor>, Input>
|
||||||
getAccessorFromWorkdir(const Settings & settings, ref<Store> store, RepoInfo & repoInfo, Input && input) const
|
getAccessorFromWorkdir(const Settings & settings, Store & store, RepoInfo & repoInfo, Input && input) const
|
||||||
{
|
{
|
||||||
auto repoPath = repoInfo.getPath().value();
|
auto repoPath = repoInfo.getPath().value();
|
||||||
|
|
||||||
@@ -966,7 +968,7 @@ struct GitInputScheme : InputScheme
|
|||||||
auto exportIgnore = getExportIgnoreAttr(input);
|
auto exportIgnore = getExportIgnoreAttr(input);
|
||||||
|
|
||||||
ref<SourceAccessor> accessor =
|
ref<SourceAccessor> accessor =
|
||||||
repo->getAccessor(repoInfo.workdirInfo, exportIgnore, makeNotAllowedError(repoPath));
|
repo->getAccessor(repoInfo.workdirInfo, {.exportIgnore = exportIgnore}, makeNotAllowedError(repoPath));
|
||||||
|
|
||||||
/* If the repo has submodules, return a mounted input accessor
|
/* If the repo has submodules, return a mounted input accessor
|
||||||
consisting of the accessor for the top-level repo and the
|
consisting of the accessor for the top-level repo and the
|
||||||
@@ -1036,7 +1038,7 @@ struct GitInputScheme : InputScheme
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input>
|
std::pair<ref<SourceAccessor>, Input>
|
||||||
getAccessor(const Settings & settings, ref<Store> store, const Input & _input) const override
|
getAccessor(const Settings & settings, Store & store, const Input & _input) const override
|
||||||
{
|
{
|
||||||
Input input(_input);
|
Input input(_input);
|
||||||
|
|
||||||
@@ -1058,7 +1060,7 @@ struct GitInputScheme : InputScheme
|
|||||||
return {accessor, std::move(final)};
|
return {accessor, std::move(final)};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> getFingerprint(ref<Store> store, const Input & input) const override
|
std::optional<std::string> getFingerprint(Store & store, const Input & input) const override
|
||||||
{
|
{
|
||||||
auto makeFingerprint = [&](const Hash & rev) {
|
auto makeFingerprint = [&](const Hash & rev) {
|
||||||
return rev.gitRev() + (getSubmodulesAttr(input) ? ";s" : "") + (getExportIgnoreAttr(input) ? ";e" : "")
|
return rev.gitRev() + (getSubmodulesAttr(input) ? ";s" : "") + (getExportIgnoreAttr(input) ? ";e" : "")
|
||||||
|
|||||||
+21
-18
@@ -258,7 +258,7 @@ struct GitArchiveInputScheme : InputScheme
|
|||||||
std::optional<Hash> treeHash;
|
std::optional<Hash> treeHash;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual RefInfo getRevFromRef(const Settings & settings, nix::ref<Store> store, const Input & input) const = 0;
|
virtual RefInfo getRevFromRef(const Settings & settings, nix::Store & store, const Input & input) const = 0;
|
||||||
|
|
||||||
virtual DownloadUrl getDownloadUrl(const Settings & settings, const Input & input) const = 0;
|
virtual DownloadUrl getDownloadUrl(const Settings & settings, const Input & input) const = 0;
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ struct GitArchiveInputScheme : InputScheme
|
|||||||
time_t lastModified;
|
time_t lastModified;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::pair<Input, TarballInfo> downloadArchive(const Settings & settings, ref<Store> store, Input input) const
|
std::pair<Input, TarballInfo> downloadArchive(const Settings & settings, Store & store, Input input) const
|
||||||
{
|
{
|
||||||
if (!maybeGetStrAttr(input.attrs, "ref"))
|
if (!maybeGetStrAttr(input.attrs, "ref"))
|
||||||
input.attrs.insert_or_assign("ref", "HEAD");
|
input.attrs.insert_or_assign("ref", "HEAD");
|
||||||
@@ -341,7 +341,7 @@ struct GitArchiveInputScheme : InputScheme
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input>
|
std::pair<ref<SourceAccessor>, Input>
|
||||||
getAccessor(const Settings & settings, ref<Store> store, const Input & _input) const override
|
getAccessor(const Settings & settings, Store & store, const Input & _input) const override
|
||||||
{
|
{
|
||||||
auto [input, tarballInfo] = downloadArchive(settings, store, _input);
|
auto [input, tarballInfo] = downloadArchive(settings, store, _input);
|
||||||
|
|
||||||
@@ -351,7 +351,7 @@ struct GitArchiveInputScheme : InputScheme
|
|||||||
input.attrs.insert_or_assign("lastModified", uint64_t(tarballInfo.lastModified));
|
input.attrs.insert_or_assign("lastModified", uint64_t(tarballInfo.lastModified));
|
||||||
|
|
||||||
auto accessor =
|
auto accessor =
|
||||||
settings.getTarballCache()->getAccessor(tarballInfo.treeHash, false, "«" + input.to_string() + "»");
|
settings.getTarballCache()->getAccessor(tarballInfo.treeHash, {}, "«" + input.to_string() + "»");
|
||||||
|
|
||||||
return {accessor, input};
|
return {accessor, input};
|
||||||
}
|
}
|
||||||
@@ -370,7 +370,7 @@ struct GitArchiveInputScheme : InputScheme
|
|||||||
return Xp::Flakes;
|
return Xp::Flakes;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> getFingerprint(ref<Store> store, const Input & input) const override
|
std::optional<std::string> getFingerprint(Store & store, const Input & input) const override
|
||||||
{
|
{
|
||||||
if (auto rev = input.getRev())
|
if (auto rev = input.getRev())
|
||||||
return rev->gitRev();
|
return rev->gitRev();
|
||||||
@@ -418,7 +418,7 @@ struct GitHubInputScheme : GitArchiveInputScheme
|
|||||||
return getStrAttr(input.attrs, "repo");
|
return getStrAttr(input.attrs, "repo");
|
||||||
}
|
}
|
||||||
|
|
||||||
RefInfo getRevFromRef(const Settings & settings, nix::ref<Store> store, const Input & input) const override
|
RefInfo getRevFromRef(const Settings & settings, nix::Store & store, const Input & input) const override
|
||||||
{
|
{
|
||||||
auto host = getHost(input);
|
auto host = getHost(input);
|
||||||
auto url = fmt(
|
auto url = fmt(
|
||||||
@@ -432,7 +432,7 @@ struct GitHubInputScheme : GitArchiveInputScheme
|
|||||||
|
|
||||||
auto downloadResult = downloadFile(store, settings, url, "source", headers);
|
auto downloadResult = downloadFile(store, settings, url, "source", headers);
|
||||||
auto json = nlohmann::json::parse(
|
auto json = nlohmann::json::parse(
|
||||||
store->requireStoreObjectAccessor(downloadResult.storePath)->readFile(CanonPath::root));
|
store.requireStoreObjectAccessor(downloadResult.storePath)->readFile(CanonPath::root));
|
||||||
|
|
||||||
return RefInfo{
|
return RefInfo{
|
||||||
.rev = Hash::parseAny(std::string{json["sha"]}, HashAlgorithm::SHA1),
|
.rev = Hash::parseAny(std::string{json["sha"]}, HashAlgorithm::SHA1),
|
||||||
@@ -457,12 +457,13 @@ struct GitHubInputScheme : GitArchiveInputScheme
|
|||||||
return DownloadUrl{parseURL(url), headers};
|
return DownloadUrl{parseURL(url), headers};
|
||||||
}
|
}
|
||||||
|
|
||||||
void clone(const Settings & settings, const Input & input, const Path & destDir) const override
|
void clone(const Settings & settings, Store & store, const Input & input, const std::filesystem::path & destDir)
|
||||||
|
const override
|
||||||
{
|
{
|
||||||
auto host = getHost(input);
|
auto host = getHost(input);
|
||||||
Input::fromURL(settings, fmt("git+https://%s/%s/%s.git", host, getOwner(input), getRepo(input)))
|
Input::fromURL(settings, fmt("git+https://%s/%s/%s.git", host, getOwner(input), getRepo(input)))
|
||||||
.applyOverrides(input.getRef(), input.getRev())
|
.applyOverrides(input.getRef(), input.getRev())
|
||||||
.clone(settings, destDir);
|
.clone(settings, store, destDir);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -498,7 +499,7 @@ struct GitLabInputScheme : GitArchiveInputScheme
|
|||||||
return std::make_pair(token.substr(0, fldsplit), token.substr(fldsplit + 1));
|
return std::make_pair(token.substr(0, fldsplit), token.substr(fldsplit + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefInfo getRevFromRef(const Settings & settings, nix::ref<Store> store, const Input & input) const override
|
RefInfo getRevFromRef(const Settings & settings, nix::Store & store, const Input & input) const override
|
||||||
{
|
{
|
||||||
auto host = maybeGetStrAttr(input.attrs, "host").value_or("gitlab.com");
|
auto host = maybeGetStrAttr(input.attrs, "host").value_or("gitlab.com");
|
||||||
// See rate limiting note below
|
// See rate limiting note below
|
||||||
@@ -513,7 +514,7 @@ struct GitLabInputScheme : GitArchiveInputScheme
|
|||||||
|
|
||||||
auto downloadResult = downloadFile(store, settings, url, "source", headers);
|
auto downloadResult = downloadFile(store, settings, url, "source", headers);
|
||||||
auto json = nlohmann::json::parse(
|
auto json = nlohmann::json::parse(
|
||||||
store->requireStoreObjectAccessor(downloadResult.storePath)->readFile(CanonPath::root));
|
store.requireStoreObjectAccessor(downloadResult.storePath)->readFile(CanonPath::root));
|
||||||
|
|
||||||
if (json.is_array() && json.size() >= 1 && json[0]["id"] != nullptr) {
|
if (json.is_array() && json.size() >= 1 && json[0]["id"] != nullptr) {
|
||||||
return RefInfo{.rev = Hash::parseAny(std::string(json[0]["id"]), HashAlgorithm::SHA1)};
|
return RefInfo{.rev = Hash::parseAny(std::string(json[0]["id"]), HashAlgorithm::SHA1)};
|
||||||
@@ -544,7 +545,8 @@ struct GitLabInputScheme : GitArchiveInputScheme
|
|||||||
return DownloadUrl{parseURL(url), headers};
|
return DownloadUrl{parseURL(url), headers};
|
||||||
}
|
}
|
||||||
|
|
||||||
void clone(const Settings & settings, const Input & input, const Path & destDir) const override
|
void clone(const Settings & settings, Store & store, const Input & input, const std::filesystem::path & destDir)
|
||||||
|
const override
|
||||||
{
|
{
|
||||||
auto host = maybeGetStrAttr(input.attrs, "host").value_or("gitlab.com");
|
auto host = maybeGetStrAttr(input.attrs, "host").value_or("gitlab.com");
|
||||||
// FIXME: get username somewhere
|
// FIXME: get username somewhere
|
||||||
@@ -552,7 +554,7 @@ struct GitLabInputScheme : GitArchiveInputScheme
|
|||||||
settings,
|
settings,
|
||||||
fmt("git+https://%s/%s/%s.git", host, getStrAttr(input.attrs, "owner"), getStrAttr(input.attrs, "repo")))
|
fmt("git+https://%s/%s/%s.git", host, getStrAttr(input.attrs, "owner"), getStrAttr(input.attrs, "repo")))
|
||||||
.applyOverrides(input.getRef(), input.getRev())
|
.applyOverrides(input.getRef(), input.getRev())
|
||||||
.clone(settings, destDir);
|
.clone(settings, store, destDir);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -579,7 +581,7 @@ struct SourceHutInputScheme : GitArchiveInputScheme
|
|||||||
// Once it is implemented, however, should work as expected.
|
// Once it is implemented, however, should work as expected.
|
||||||
}
|
}
|
||||||
|
|
||||||
RefInfo getRevFromRef(const Settings & settings, nix::ref<Store> store, const Input & input) const override
|
RefInfo getRevFromRef(const Settings & settings, nix::Store & store, const Input & input) const override
|
||||||
{
|
{
|
||||||
// TODO: In the future, when the sourcehut graphql API is implemented for mercurial
|
// TODO: In the future, when the sourcehut graphql API is implemented for mercurial
|
||||||
// and with anonymous access, this method should use it instead.
|
// and with anonymous access, this method should use it instead.
|
||||||
@@ -595,7 +597,7 @@ struct SourceHutInputScheme : GitArchiveInputScheme
|
|||||||
std::string refUri;
|
std::string refUri;
|
||||||
if (ref == "HEAD") {
|
if (ref == "HEAD") {
|
||||||
auto downloadFileResult = downloadFile(store, settings, fmt("%s/HEAD", base_url), "source", headers);
|
auto downloadFileResult = downloadFile(store, settings, fmt("%s/HEAD", base_url), "source", headers);
|
||||||
auto contents = store->requireStoreObjectAccessor(downloadFileResult.storePath)->readFile(CanonPath::root);
|
auto contents = store.requireStoreObjectAccessor(downloadFileResult.storePath)->readFile(CanonPath::root);
|
||||||
|
|
||||||
auto remoteLine = git::parseLsRemoteLine(getLine(contents).first);
|
auto remoteLine = git::parseLsRemoteLine(getLine(contents).first);
|
||||||
if (!remoteLine) {
|
if (!remoteLine) {
|
||||||
@@ -608,7 +610,7 @@ struct SourceHutInputScheme : GitArchiveInputScheme
|
|||||||
std::regex refRegex(refUri);
|
std::regex refRegex(refUri);
|
||||||
|
|
||||||
auto downloadFileResult = downloadFile(store, settings, fmt("%s/info/refs", base_url), "source", headers);
|
auto downloadFileResult = downloadFile(store, settings, fmt("%s/info/refs", base_url), "source", headers);
|
||||||
auto contents = store->requireStoreObjectAccessor(downloadFileResult.storePath)->readFile(CanonPath::root);
|
auto contents = store.requireStoreObjectAccessor(downloadFileResult.storePath)->readFile(CanonPath::root);
|
||||||
std::istringstream is(contents);
|
std::istringstream is(contents);
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
@@ -639,14 +641,15 @@ struct SourceHutInputScheme : GitArchiveInputScheme
|
|||||||
return DownloadUrl{parseURL(url), headers};
|
return DownloadUrl{parseURL(url), headers};
|
||||||
}
|
}
|
||||||
|
|
||||||
void clone(const Settings & settings, const Input & input, const Path & destDir) const override
|
void clone(const Settings & settings, Store & store, const Input & input, const std::filesystem::path & destDir)
|
||||||
|
const override
|
||||||
{
|
{
|
||||||
auto host = maybeGetStrAttr(input.attrs, "host").value_or("git.sr.ht");
|
auto host = maybeGetStrAttr(input.attrs, "host").value_or("git.sr.ht");
|
||||||
Input::fromURL(
|
Input::fromURL(
|
||||||
settings,
|
settings,
|
||||||
fmt("git+https://%s/%s/%s", host, getStrAttr(input.attrs, "owner"), getStrAttr(input.attrs, "repo")))
|
fmt("git+https://%s/%s/%s", host, getStrAttr(input.attrs, "owner"), getStrAttr(input.attrs, "repo")))
|
||||||
.applyOverrides(input.getRef(), input.getRev())
|
.applyOverrides(input.getRef(), input.getRev())
|
||||||
.clone(settings, destDir);
|
.clone(settings, store, destDir);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -135,8 +135,6 @@ struct Settings : public Config
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
mutable Sync<std::shared_ptr<Cache>> _cache;
|
mutable Sync<std::shared_ptr<Cache>> _cache;
|
||||||
|
|
||||||
mutable Sync<std::shared_ptr<GitRepo>> _tarballCache;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace nix::fetchers
|
} // namespace nix::fetchers
|
||||||
@@ -113,7 +113,7 @@ public:
|
|||||||
* Fetch the entire input into the Nix store, returning the
|
* Fetch the entire input into the Nix store, returning the
|
||||||
* location in the Nix store and the locked input.
|
* location in the Nix store and the locked input.
|
||||||
*/
|
*/
|
||||||
std::pair<StorePath, Input> fetchToStore(const Settings & settings, ref<Store> store) const;
|
std::pair<StorePath, Input> fetchToStore(const Settings & settings, Store & store) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the locking attributes in `result` against
|
* Check the locking attributes in `result` against
|
||||||
@@ -133,17 +133,17 @@ public:
|
|||||||
* input without copying it to the store. Also return a possibly
|
* input without copying it to the store. Also return a possibly
|
||||||
* unlocked input.
|
* unlocked input.
|
||||||
*/
|
*/
|
||||||
std::pair<ref<SourceAccessor>, Input> getAccessor(const Settings & settings, ref<Store> store) const;
|
std::pair<ref<SourceAccessor>, Input> getAccessor(const Settings & settings, Store & store) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input> getAccessorUnchecked(const Settings & settings, ref<Store> store) const;
|
std::pair<ref<SourceAccessor>, Input> getAccessorUnchecked(const Settings & settings, Store & store) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Input applyOverrides(std::optional<std::string> ref, std::optional<Hash> rev) const;
|
Input applyOverrides(std::optional<std::string> ref, std::optional<Hash> rev) const;
|
||||||
|
|
||||||
void clone(const Settings & settings, const Path & destDir) const;
|
void clone(const Settings & settings, Store & store, const std::filesystem::path & destDir) const;
|
||||||
|
|
||||||
std::optional<std::filesystem::path> getSourcePath() const;
|
std::optional<std::filesystem::path> getSourcePath() const;
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ public:
|
|||||||
*
|
*
|
||||||
* This is not a stable identifier between Nix versions, but not guaranteed to change either.
|
* This is not a stable identifier between Nix versions, but not guaranteed to change either.
|
||||||
*/
|
*/
|
||||||
std::optional<std::string> getFingerprint(ref<Store> store) const;
|
std::optional<std::string> getFingerprint(Store & store) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -229,7 +229,8 @@ struct InputScheme
|
|||||||
|
|
||||||
virtual Input applyOverrides(const Input & input, std::optional<std::string> ref, std::optional<Hash> rev) const;
|
virtual Input applyOverrides(const Input & input, std::optional<std::string> ref, std::optional<Hash> rev) const;
|
||||||
|
|
||||||
virtual void clone(const Settings & settings, const Input & input, const Path & destDir) const;
|
virtual void
|
||||||
|
clone(const Settings & settings, Store & store, const Input & input, const std::filesystem::path & destDir) const;
|
||||||
|
|
||||||
virtual std::optional<std::filesystem::path> getSourcePath(const Input & input) const;
|
virtual std::optional<std::filesystem::path> getSourcePath(const Input & input) const;
|
||||||
|
|
||||||
@@ -240,7 +241,7 @@ struct InputScheme
|
|||||||
std::optional<std::string> commitMsg) const;
|
std::optional<std::string> commitMsg) const;
|
||||||
|
|
||||||
virtual std::pair<ref<SourceAccessor>, Input>
|
virtual std::pair<ref<SourceAccessor>, Input>
|
||||||
getAccessor(const Settings & settings, ref<Store> store, const Input & input) const = 0;
|
getAccessor(const Settings & settings, Store & store, const Input & input) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this `InputScheme` part of an experimental feature?
|
* Is this `InputScheme` part of an experimental feature?
|
||||||
@@ -252,7 +253,7 @@ struct InputScheme
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::optional<std::string> getFingerprint(ref<Store> store, const Input & input) const
|
virtual std::optional<std::string> getFingerprint(Store & store, const Input & input) const
|
||||||
{
|
{
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,12 @@ struct GitFileSystemObjectSink : ExtendedFileSystemObjectSink
|
|||||||
virtual Hash flush() = 0;
|
virtual Hash flush() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GitAccessorOptions
|
||||||
|
{
|
||||||
|
bool exportIgnore = false;
|
||||||
|
bool smudgeLfs = false;
|
||||||
|
};
|
||||||
|
|
||||||
struct GitRepo
|
struct GitRepo
|
||||||
{
|
{
|
||||||
virtual ~GitRepo() {}
|
virtual ~GitRepo() {}
|
||||||
@@ -89,10 +95,10 @@ struct GitRepo
|
|||||||
virtual bool hasObject(const Hash & oid) = 0;
|
virtual bool hasObject(const Hash & oid) = 0;
|
||||||
|
|
||||||
virtual ref<SourceAccessor>
|
virtual ref<SourceAccessor>
|
||||||
getAccessor(const Hash & rev, bool exportIgnore, std::string displayPrefix, bool smudgeLfs = false) = 0;
|
getAccessor(const Hash & rev, const GitAccessorOptions & options, std::string displayPrefix) = 0;
|
||||||
|
|
||||||
virtual ref<SourceAccessor>
|
virtual ref<SourceAccessor> getAccessor(
|
||||||
getAccessor(const WorkdirInfo & wd, bool exportIgnore, MakeNotAllowedError makeNotAllowedError) = 0;
|
const WorkdirInfo & wd, const GitAccessorOptions & options, MakeNotAllowedError makeNotAllowedError) = 0;
|
||||||
|
|
||||||
virtual ref<GitFileSystemObjectSink> getFileSystemObjectSink() = 0;
|
virtual ref<GitFileSystemObjectSink> getFileSystemObjectSink() = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ struct InputCache
|
|||||||
};
|
};
|
||||||
|
|
||||||
CachedResult
|
CachedResult
|
||||||
getAccessor(const Settings & settings, ref<Store> store, const Input & originalInput, UseRegistries useRegistries);
|
getAccessor(const Settings & settings, Store & store, const Input & originalInput, UseRegistries useRegistries);
|
||||||
|
|
||||||
struct CachedInput
|
struct CachedInput
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ namespace nix::fetchers {
|
|||||||
|
|
||||||
struct Registry
|
struct Registry
|
||||||
{
|
{
|
||||||
const Settings & settings;
|
|
||||||
|
|
||||||
enum RegistryType {
|
enum RegistryType {
|
||||||
Flag = 0,
|
Flag = 0,
|
||||||
User = 1,
|
User = 1,
|
||||||
@@ -34,9 +32,8 @@ struct Registry
|
|||||||
|
|
||||||
std::vector<Entry> entries;
|
std::vector<Entry> entries;
|
||||||
|
|
||||||
Registry(const Settings & settings, RegistryType type)
|
Registry(RegistryType type)
|
||||||
: settings{settings}
|
: type{type}
|
||||||
, type{type}
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,9 +54,9 @@ std::shared_ptr<Registry> getCustomRegistry(const Settings & settings, const Pat
|
|||||||
|
|
||||||
Path getUserRegistryPath();
|
Path getUserRegistryPath();
|
||||||
|
|
||||||
Registries getRegistries(const Settings & settings, ref<Store> store);
|
Registries getRegistries(const Settings & settings, Store & store);
|
||||||
|
|
||||||
void overrideRegistry(const Settings & settings, const Input & from, const Input & to, const Attrs & extraAttrs);
|
void overrideRegistry(const Input & from, const Input & to, const Attrs & extraAttrs);
|
||||||
|
|
||||||
enum class UseRegistries : int {
|
enum class UseRegistries : int {
|
||||||
No,
|
No,
|
||||||
@@ -72,6 +69,6 @@ enum class UseRegistries : int {
|
|||||||
* use the registries for which the filter function returns true.
|
* use the registries for which the filter function returns true.
|
||||||
*/
|
*/
|
||||||
std::pair<Input, Attrs>
|
std::pair<Input, Attrs>
|
||||||
lookupInRegistries(const Settings & settings, ref<Store> store, const Input & input, UseRegistries useRegistries);
|
lookupInRegistries(const Settings & settings, Store & store, const Input & input, UseRegistries useRegistries);
|
||||||
|
|
||||||
} // namespace nix::fetchers
|
} // namespace nix::fetchers
|
||||||
@@ -25,7 +25,7 @@ struct DownloadFileResult
|
|||||||
};
|
};
|
||||||
|
|
||||||
DownloadFileResult downloadFile(
|
DownloadFileResult downloadFile(
|
||||||
ref<Store> store,
|
Store & store,
|
||||||
const Settings & settings,
|
const Settings & settings,
|
||||||
const std::string & url,
|
const std::string & url,
|
||||||
const std::string & name,
|
const std::string & name,
|
||||||
@@ -43,6 +43,6 @@ struct DownloadTarballResult
|
|||||||
* Download and import a tarball into the Git cache. The result is the
|
* Download and import a tarball into the Git cache. The result is the
|
||||||
* Git tree hash of the root directory.
|
* Git tree hash of the root directory.
|
||||||
*/
|
*/
|
||||||
ref<SourceAccessor> downloadTarball(ref<Store> store, const Settings & settings, const std::string & url);
|
ref<SourceAccessor> downloadTarball(Store & store, const Settings & settings, const std::string & url);
|
||||||
|
|
||||||
} // namespace nix::fetchers
|
} // namespace nix::fetchers
|
||||||
@@ -126,7 +126,7 @@ struct IndirectInputScheme : InputScheme
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input>
|
std::pair<ref<SourceAccessor>, Input>
|
||||||
getAccessor(const Settings & settings, ref<Store> store, const Input & input) const override
|
getAccessor(const Settings & settings, Store & store, const Input & input) const override
|
||||||
{
|
{
|
||||||
throw Error("indirect input '%s' cannot be fetched directly", input.to_string());
|
throw Error("indirect input '%s' cannot be fetched directly", input.to_string());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
namespace nix::fetchers {
|
namespace nix::fetchers {
|
||||||
|
|
||||||
InputCache::CachedResult InputCache::getAccessor(
|
InputCache::CachedResult InputCache::getAccessor(
|
||||||
const Settings & settings, ref<Store> store, const Input & originalInput, UseRegistries useRegistries)
|
const Settings & settings, Store & store, const Input & originalInput, UseRegistries useRegistries)
|
||||||
{
|
{
|
||||||
auto fetched = lookup(originalInput);
|
auto fetched = lookup(originalInput);
|
||||||
Input resolvedInput = originalInput;
|
Input resolvedInput = originalInput;
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ struct MercurialInputScheme : InputScheme
|
|||||||
return {isLocal, isLocal ? renderUrlPathEnsureLegal(url.path) : url.to_string()};
|
return {isLocal, isLocal ? renderUrlPathEnsureLegal(url.path) : url.to_string()};
|
||||||
}
|
}
|
||||||
|
|
||||||
StorePath fetchToStore(const Settings & settings, ref<Store> store, Input & input) const
|
StorePath fetchToStore(const Settings & settings, Store & store, Input & input) const
|
||||||
{
|
{
|
||||||
auto origRev = input.getRev();
|
auto origRev = input.getRev();
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ struct MercurialInputScheme : InputScheme
|
|||||||
return files.count(file);
|
return files.count(file);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto storePath = store->addToStore(
|
auto storePath = store.addToStore(
|
||||||
input.getName(),
|
input.getName(),
|
||||||
{getFSSourceAccessor(), CanonPath(actualPath)},
|
{getFSSourceAccessor(), CanonPath(actualPath)},
|
||||||
ContentAddressMethod::Raw::NixArchive,
|
ContentAddressMethod::Raw::NixArchive,
|
||||||
@@ -251,7 +251,7 @@ struct MercurialInputScheme : InputScheme
|
|||||||
"Hash '%s' is not supported by Mercurial. Only sha1 is supported.",
|
"Hash '%s' is not supported by Mercurial. Only sha1 is supported.",
|
||||||
rev.to_string(HashFormat::Base16, true));
|
rev.to_string(HashFormat::Base16, true));
|
||||||
|
|
||||||
return Cache::Key{"hgRev", {{"store", store->storeDir}, {"name", name}, {"rev", input.getRev()->gitRev()}}};
|
return Cache::Key{"hgRev", {{"store", store.storeDir}, {"name", name}, {"rev", input.getRev()->gitRev()}}};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto makeResult = [&](const Attrs & infoAttrs, const StorePath & storePath) -> StorePath {
|
auto makeResult = [&](const Attrs & infoAttrs, const StorePath & storePath) -> StorePath {
|
||||||
@@ -271,7 +271,7 @@ struct MercurialInputScheme : InputScheme
|
|||||||
|
|
||||||
/* If we have a rev, check if we have a cached store path. */
|
/* If we have a rev, check if we have a cached store path. */
|
||||||
if (auto rev = input.getRev()) {
|
if (auto rev = input.getRev()) {
|
||||||
if (auto res = settings.getCache()->lookupStorePath(revInfoKey(*rev), *store))
|
if (auto res = settings.getCache()->lookupStorePath(revInfoKey(*rev), store))
|
||||||
return makeResult(res->value, res->storePath);
|
return makeResult(res->value, res->storePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ struct MercurialInputScheme : InputScheme
|
|||||||
|
|
||||||
/* Now that we have the rev, check the cache again for a
|
/* Now that we have the rev, check the cache again for a
|
||||||
cached store path. */
|
cached store path. */
|
||||||
if (auto res = settings.getCache()->lookupStorePath(revInfoKey(rev), *store))
|
if (auto res = settings.getCache()->lookupStorePath(revInfoKey(rev), store))
|
||||||
return makeResult(res->value, res->storePath);
|
return makeResult(res->value, res->storePath);
|
||||||
|
|
||||||
Path tmpDir = createTempDir();
|
Path tmpDir = createTempDir();
|
||||||
@@ -335,7 +335,7 @@ struct MercurialInputScheme : InputScheme
|
|||||||
|
|
||||||
deletePath(tmpDir + "/.hg_archival.txt");
|
deletePath(tmpDir + "/.hg_archival.txt");
|
||||||
|
|
||||||
auto storePath = store->addToStore(name, {getFSSourceAccessor(), CanonPath(tmpDir)});
|
auto storePath = store.addToStore(name, {getFSSourceAccessor(), CanonPath(tmpDir)});
|
||||||
|
|
||||||
Attrs infoAttrs({
|
Attrs infoAttrs({
|
||||||
{"revCount", (uint64_t) revCount},
|
{"revCount", (uint64_t) revCount},
|
||||||
@@ -344,18 +344,18 @@ struct MercurialInputScheme : InputScheme
|
|||||||
if (!origRev)
|
if (!origRev)
|
||||||
settings.getCache()->upsert(refToRevKey, {{"rev", rev.gitRev()}});
|
settings.getCache()->upsert(refToRevKey, {{"rev", rev.gitRev()}});
|
||||||
|
|
||||||
settings.getCache()->upsert(revInfoKey(rev), *store, infoAttrs, storePath);
|
settings.getCache()->upsert(revInfoKey(rev), store, infoAttrs, storePath);
|
||||||
|
|
||||||
return makeResult(infoAttrs, std::move(storePath));
|
return makeResult(infoAttrs, std::move(storePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input>
|
std::pair<ref<SourceAccessor>, Input>
|
||||||
getAccessor(const Settings & settings, ref<Store> store, const Input & _input) const override
|
getAccessor(const Settings & settings, Store & store, const Input & _input) const override
|
||||||
{
|
{
|
||||||
Input input(_input);
|
Input input(_input);
|
||||||
|
|
||||||
auto storePath = fetchToStore(settings, store, input);
|
auto storePath = fetchToStore(settings, store, input);
|
||||||
auto accessor = store->requireStoreObjectAccessor(storePath);
|
auto accessor = store.requireStoreObjectAccessor(storePath);
|
||||||
|
|
||||||
accessor->setPathDisplay("«" + input.to_string() + "»");
|
accessor->setPathDisplay("«" + input.to_string() + "»");
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ struct MercurialInputScheme : InputScheme
|
|||||||
return (bool) input.getRev();
|
return (bool) input.getRev();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> getFingerprint(ref<Store> store, const Input & input) const override
|
std::optional<std::string> getFingerprint(Store & store, const Input & input) const override
|
||||||
{
|
{
|
||||||
if (auto rev = input.getRev())
|
if (auto rev = input.getRev())
|
||||||
return rev->gitRev();
|
return rev->gitRev();
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ struct PathInputScheme : InputScheme
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input>
|
std::pair<ref<SourceAccessor>, Input>
|
||||||
getAccessor(const Settings & settings, ref<Store> store, const Input & _input) const override
|
getAccessor(const Settings & settings, Store & store, const Input & _input) const override
|
||||||
{
|
{
|
||||||
Input input(_input);
|
Input input(_input);
|
||||||
auto path = getStrAttr(input.attrs, "path");
|
auto path = getStrAttr(input.attrs, "path");
|
||||||
@@ -147,31 +147,31 @@ struct PathInputScheme : InputScheme
|
|||||||
auto absPath = getAbsPath(input);
|
auto absPath = getAbsPath(input);
|
||||||
|
|
||||||
// FIXME: check whether access to 'path' is allowed.
|
// FIXME: check whether access to 'path' is allowed.
|
||||||
auto storePath = store->maybeParseStorePath(absPath.string());
|
auto storePath = store.maybeParseStorePath(absPath.string());
|
||||||
|
|
||||||
if (storePath)
|
if (storePath)
|
||||||
store->addTempRoot(*storePath);
|
store.addTempRoot(*storePath);
|
||||||
|
|
||||||
time_t mtime = 0;
|
time_t mtime = 0;
|
||||||
if (!storePath || storePath->name() != "source" || !store->isValidPath(*storePath)) {
|
if (!storePath || storePath->name() != "source" || !store.isValidPath(*storePath)) {
|
||||||
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying %s to the store", absPath));
|
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying %s to the store", absPath));
|
||||||
// FIXME: try to substitute storePath.
|
// FIXME: try to substitute storePath.
|
||||||
auto src = sinkToSource(
|
auto src = sinkToSource(
|
||||||
[&](Sink & sink) { mtime = dumpPathAndGetMtime(absPath.string(), sink, defaultPathFilter); });
|
[&](Sink & sink) { mtime = dumpPathAndGetMtime(absPath.string(), sink, defaultPathFilter); });
|
||||||
storePath = store->addToStoreFromDump(*src, "source");
|
storePath = store.addToStoreFromDump(*src, "source");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto accessor = store->requireStoreObjectAccessor(*storePath);
|
auto accessor = store.requireStoreObjectAccessor(*storePath);
|
||||||
|
|
||||||
// To prevent `fetchToStore()` copying the path again to Nix
|
// To prevent `fetchToStore()` copying the path again to Nix
|
||||||
// store, pre-create an entry in the fetcher cache.
|
// store, pre-create an entry in the fetcher cache.
|
||||||
auto info = store->queryPathInfo(*storePath);
|
auto info = store.queryPathInfo(*storePath);
|
||||||
accessor->fingerprint =
|
accessor->fingerprint =
|
||||||
fmt("path:%s", store->queryPathInfo(*storePath)->narHash.to_string(HashFormat::SRI, true));
|
fmt("path:%s", store.queryPathInfo(*storePath)->narHash.to_string(HashFormat::SRI, true));
|
||||||
settings.getCache()->upsert(
|
settings.getCache()->upsert(
|
||||||
makeFetchToStoreCacheKey(
|
makeFetchToStoreCacheKey(
|
||||||
input.getName(), *accessor->fingerprint, ContentAddressMethod::Raw::NixArchive, "/"),
|
input.getName(), *accessor->fingerprint, ContentAddressMethod::Raw::NixArchive, "/"),
|
||||||
*store,
|
store,
|
||||||
{},
|
{},
|
||||||
*storePath);
|
*storePath);
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -14,10 +14,10 @@ std::shared_ptr<Registry> Registry::read(const Settings & settings, const Source
|
|||||||
{
|
{
|
||||||
debug("reading registry '%s'", path);
|
debug("reading registry '%s'", path);
|
||||||
|
|
||||||
auto registry = std::make_shared<Registry>(settings, type);
|
auto registry = std::make_shared<Registry>(type);
|
||||||
|
|
||||||
if (!path.pathExists())
|
if (!path.pathExists())
|
||||||
return std::make_shared<Registry>(settings, type);
|
return std::make_shared<Registry>(type);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@@ -125,23 +125,23 @@ std::shared_ptr<Registry> getCustomRegistry(const Settings & settings, const Pat
|
|||||||
return customRegistry;
|
return customRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Registry> getFlagRegistry(const Settings & settings)
|
std::shared_ptr<Registry> getFlagRegistry()
|
||||||
{
|
{
|
||||||
static auto flagRegistry = std::make_shared<Registry>(settings, Registry::Flag);
|
static auto flagRegistry = std::make_shared<Registry>(Registry::Flag);
|
||||||
return flagRegistry;
|
return flagRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void overrideRegistry(const Settings & settings, const Input & from, const Input & to, const Attrs & extraAttrs)
|
void overrideRegistry(const Input & from, const Input & to, const Attrs & extraAttrs)
|
||||||
{
|
{
|
||||||
getFlagRegistry(settings)->add(from, to, extraAttrs);
|
getFlagRegistry()->add(from, to, extraAttrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::shared_ptr<Registry> getGlobalRegistry(const Settings & settings, ref<Store> store)
|
static std::shared_ptr<Registry> getGlobalRegistry(const Settings & settings, Store & store)
|
||||||
{
|
{
|
||||||
static auto reg = [&]() {
|
static auto reg = [&]() {
|
||||||
auto path = settings.flakeRegistry.get();
|
auto path = settings.flakeRegistry.get();
|
||||||
if (path == "") {
|
if (path == "") {
|
||||||
return std::make_shared<Registry>(settings, Registry::Global); // empty registry
|
return std::make_shared<Registry>(Registry::Global); // empty registry
|
||||||
}
|
}
|
||||||
|
|
||||||
return Registry::read(
|
return Registry::read(
|
||||||
@@ -149,9 +149,9 @@ static std::shared_ptr<Registry> getGlobalRegistry(const Settings & settings, re
|
|||||||
[&] -> SourcePath {
|
[&] -> SourcePath {
|
||||||
if (!isAbsolute(path)) {
|
if (!isAbsolute(path)) {
|
||||||
auto storePath = downloadFile(store, settings, path, "flake-registry.json").storePath;
|
auto storePath = downloadFile(store, settings, path, "flake-registry.json").storePath;
|
||||||
if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>())
|
if (auto store2 = dynamic_cast<LocalFSStore *>(&store))
|
||||||
store2->addPermRoot(storePath, getCacheDir() + "/flake-registry.json");
|
store2->addPermRoot(storePath, getCacheDir() + "/flake-registry.json");
|
||||||
return {store->requireStoreObjectAccessor(storePath)};
|
return {store.requireStoreObjectAccessor(storePath)};
|
||||||
} else {
|
} else {
|
||||||
return SourcePath{getFSSourceAccessor(), CanonPath{path}}.resolveSymlinks();
|
return SourcePath{getFSSourceAccessor(), CanonPath{path}}.resolveSymlinks();
|
||||||
}
|
}
|
||||||
@@ -162,10 +162,10 @@ static std::shared_ptr<Registry> getGlobalRegistry(const Settings & settings, re
|
|||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
Registries getRegistries(const Settings & settings, ref<Store> store)
|
Registries getRegistries(const Settings & settings, Store & store)
|
||||||
{
|
{
|
||||||
Registries registries;
|
Registries registries;
|
||||||
registries.push_back(getFlagRegistry(settings));
|
registries.push_back(getFlagRegistry());
|
||||||
registries.push_back(getUserRegistry(settings));
|
registries.push_back(getUserRegistry(settings));
|
||||||
registries.push_back(getSystemRegistry(settings));
|
registries.push_back(getSystemRegistry(settings));
|
||||||
registries.push_back(getGlobalRegistry(settings, store));
|
registries.push_back(getGlobalRegistry(settings, store));
|
||||||
@@ -173,7 +173,7 @@ Registries getRegistries(const Settings & settings, ref<Store> store)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<Input, Attrs>
|
std::pair<Input, Attrs>
|
||||||
lookupInRegistries(const Settings & settings, ref<Store> store, const Input & _input, UseRegistries useRegistries)
|
lookupInRegistries(const Settings & settings, Store & store, const Input & _input, UseRegistries useRegistries)
|
||||||
{
|
{
|
||||||
Attrs extraAttrs;
|
Attrs extraAttrs;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|||||||
+12
-12
@@ -13,7 +13,7 @@
|
|||||||
namespace nix::fetchers {
|
namespace nix::fetchers {
|
||||||
|
|
||||||
DownloadFileResult downloadFile(
|
DownloadFileResult downloadFile(
|
||||||
ref<Store> store,
|
Store & store,
|
||||||
const Settings & settings,
|
const Settings & settings,
|
||||||
const std::string & url,
|
const std::string & url,
|
||||||
const std::string & name,
|
const std::string & name,
|
||||||
@@ -28,7 +28,7 @@ DownloadFileResult downloadFile(
|
|||||||
{"name", name},
|
{"name", name},
|
||||||
}}};
|
}}};
|
||||||
|
|
||||||
auto cached = settings.getCache()->lookupStorePath(key, *store);
|
auto cached = settings.getCache()->lookupStorePath(key, store);
|
||||||
|
|
||||||
auto useCached = [&]() -> DownloadFileResult {
|
auto useCached = [&]() -> DownloadFileResult {
|
||||||
return {
|
return {
|
||||||
@@ -74,7 +74,7 @@ DownloadFileResult downloadFile(
|
|||||||
dumpString(res.data, sink);
|
dumpString(res.data, sink);
|
||||||
auto hash = hashString(HashAlgorithm::SHA256, res.data);
|
auto hash = hashString(HashAlgorithm::SHA256, res.data);
|
||||||
auto info = ValidPathInfo::makeFromCA(
|
auto info = ValidPathInfo::makeFromCA(
|
||||||
*store,
|
store,
|
||||||
name,
|
name,
|
||||||
FixedOutputInfo{
|
FixedOutputInfo{
|
||||||
.method = FileIngestionMethod::Flat,
|
.method = FileIngestionMethod::Flat,
|
||||||
@@ -84,7 +84,7 @@ DownloadFileResult downloadFile(
|
|||||||
hashString(HashAlgorithm::SHA256, sink.s));
|
hashString(HashAlgorithm::SHA256, sink.s));
|
||||||
info.narSize = sink.s.size();
|
info.narSize = sink.s.size();
|
||||||
auto source = StringSource{sink.s};
|
auto source = StringSource{sink.s};
|
||||||
store->addToStore(info, source, NoRepair, NoCheckSigs);
|
store.addToStore(info, source, NoRepair, NoCheckSigs);
|
||||||
storePath = std::move(info.path);
|
storePath = std::move(info.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ DownloadFileResult downloadFile(
|
|||||||
key.second.insert_or_assign("url", url);
|
key.second.insert_or_assign("url", url);
|
||||||
assert(!res.urls.empty());
|
assert(!res.urls.empty());
|
||||||
infoAttrs.insert_or_assign("url", *res.urls.rbegin());
|
infoAttrs.insert_or_assign("url", *res.urls.rbegin());
|
||||||
settings.getCache()->upsert(key, *store, infoAttrs, *storePath);
|
settings.getCache()->upsert(key, store, infoAttrs, *storePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -136,7 +136,7 @@ static DownloadTarballResult downloadTarball_(
|
|||||||
.treeHash = treeHash,
|
.treeHash = treeHash,
|
||||||
.lastModified = (time_t) getIntAttr(infoAttrs, "lastModified"),
|
.lastModified = (time_t) getIntAttr(infoAttrs, "lastModified"),
|
||||||
.immutableUrl = maybeGetStrAttr(infoAttrs, "immutableUrl"),
|
.immutableUrl = maybeGetStrAttr(infoAttrs, "immutableUrl"),
|
||||||
.accessor = settings.getTarballCache()->getAccessor(treeHash, false, displayPrefix),
|
.accessor = settings.getTarballCache()->getAccessor(treeHash, {}, displayPrefix),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ static DownloadTarballResult downloadTarball_(
|
|||||||
return attrsToResult(infoAttrs);
|
return attrsToResult(infoAttrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<SourceAccessor> downloadTarball(ref<Store> store, const Settings & settings, const std::string & url)
|
ref<SourceAccessor> downloadTarball(Store & store, const Settings & settings, const std::string & url)
|
||||||
{
|
{
|
||||||
/* Go through Input::getAccessor() to ensure that the resulting
|
/* Go through Input::getAccessor() to ensure that the resulting
|
||||||
accessor has a fingerprint. */
|
accessor has a fingerprint. */
|
||||||
@@ -414,7 +414,7 @@ struct FileInputScheme : CurlInputScheme
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input>
|
std::pair<ref<SourceAccessor>, Input>
|
||||||
getAccessor(const Settings & settings, ref<Store> store, const Input & _input) const override
|
getAccessor(const Settings & settings, Store & store, const Input & _input) const override
|
||||||
{
|
{
|
||||||
auto input(_input);
|
auto input(_input);
|
||||||
|
|
||||||
@@ -424,10 +424,10 @@ struct FileInputScheme : CurlInputScheme
|
|||||||
tarballs. */
|
tarballs. */
|
||||||
auto file = downloadFile(store, settings, getStrAttr(input.attrs, "url"), input.getName());
|
auto file = downloadFile(store, settings, getStrAttr(input.attrs, "url"), input.getName());
|
||||||
|
|
||||||
auto narHash = store->queryPathInfo(file.storePath)->narHash;
|
auto narHash = store.queryPathInfo(file.storePath)->narHash;
|
||||||
input.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
|
input.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
|
||||||
|
|
||||||
auto accessor = ref{store->getFSAccessor(file.storePath)};
|
auto accessor = ref{store.getFSAccessor(file.storePath)};
|
||||||
|
|
||||||
accessor->setPathDisplay("«" + input.to_string() + "»");
|
accessor->setPathDisplay("«" + input.to_string() + "»");
|
||||||
|
|
||||||
@@ -480,7 +480,7 @@ struct TarballInputScheme : CurlInputScheme
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input>
|
std::pair<ref<SourceAccessor>, Input>
|
||||||
getAccessor(const Settings & settings, ref<Store> store, const Input & _input) const override
|
getAccessor(const Settings & settings, Store & store, const Input & _input) const override
|
||||||
{
|
{
|
||||||
auto input(_input);
|
auto input(_input);
|
||||||
|
|
||||||
@@ -505,7 +505,7 @@ struct TarballInputScheme : CurlInputScheme
|
|||||||
return {result.accessor, input};
|
return {result.accessor, input};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> getFingerprint(ref<Store> store, const Input & input) const override
|
std::optional<std::string> getFingerprint(Store & store, const Input & input) const override
|
||||||
{
|
{
|
||||||
if (auto narHash = input.getNarHash())
|
if (auto narHash = input.getNarHash())
|
||||||
return narHash->to_string(HashFormat::SRI, true);
|
return narHash->to_string(HashFormat::SRI, true);
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ nix_value * nix_locked_flake_get_output_attrs(
|
|||||||
nix_clear_err(context);
|
nix_clear_err(context);
|
||||||
try {
|
try {
|
||||||
auto v = nix_alloc_value(context, evalState);
|
auto v = nix_alloc_value(context, evalState);
|
||||||
nix::flake::callFlake(evalState->state, *lockedFlake->lockedFlake, v->value);
|
nix::flake::callFlake(evalState->state, *lockedFlake->lockedFlake, *v->value);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS_NULL
|
NIXC_CATCH_ERRS_NULL
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ static void prim_parseFlakeRef(EvalState & state, const PosIdx pos, Value ** arg
|
|||||||
auto & vv = binds.alloc(s);
|
auto & vv = binds.alloc(s);
|
||||||
std::visit(
|
std::visit(
|
||||||
overloaded{
|
overloaded{
|
||||||
[&vv](const std::string & value) { vv.mkString(value); },
|
[&vv, &state](const std::string & value) { vv.mkString(value, state.mem); },
|
||||||
[&vv](const uint64_t & value) { vv.mkInt(value); },
|
[&vv](const uint64_t & value) { vv.mkInt(value); },
|
||||||
[&vv](const Explicit<bool> & value) { vv.mkBool(value.t); }},
|
[&vv](const Explicit<bool> & value) { vv.mkBool(value.t); }},
|
||||||
value);
|
value);
|
||||||
@@ -156,7 +156,7 @@ static void prim_flakeRefToString(EvalState & state, const PosIdx pos, Value **
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto flakeRef = FlakeRef::fromAttrs(state.fetchSettings, attrs);
|
auto flakeRef = FlakeRef::fromAttrs(state.fetchSettings, attrs);
|
||||||
v.mkString(flakeRef.to_string());
|
v.mkString(flakeRef.to_string(), state.mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
nix::PrimOp flakeRefToString({
|
nix::PrimOp flakeRefToString({
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ static Flake getFlake(
|
|||||||
{
|
{
|
||||||
// Fetch a lazy tree first.
|
// Fetch a lazy tree first.
|
||||||
auto cachedInput =
|
auto cachedInput =
|
||||||
state.inputCache->getAccessor(state.fetchSettings, state.store, originalRef.input, useRegistries);
|
state.inputCache->getAccessor(state.fetchSettings, *state.store, originalRef.input, useRegistries);
|
||||||
|
|
||||||
auto subdir = fetchers::maybeGetStrAttr(cachedInput.extraAttrs, "dir").value_or(originalRef.subdir);
|
auto subdir = fetchers::maybeGetStrAttr(cachedInput.extraAttrs, "dir").value_or(originalRef.subdir);
|
||||||
auto resolvedRef = FlakeRef(std::move(cachedInput.resolvedInput), subdir);
|
auto resolvedRef = FlakeRef(std::move(cachedInput.resolvedInput), subdir);
|
||||||
@@ -390,7 +390,7 @@ static Flake getFlake(
|
|||||||
// FIXME: need to remove attrs that are invalidated by the changed input attrs, such as 'narHash'.
|
// FIXME: need to remove attrs that are invalidated by the changed input attrs, such as 'narHash'.
|
||||||
newLockedRef.input.attrs.erase("narHash");
|
newLockedRef.input.attrs.erase("narHash");
|
||||||
auto cachedInput2 = state.inputCache->getAccessor(
|
auto cachedInput2 = state.inputCache->getAccessor(
|
||||||
state.fetchSettings, state.store, newLockedRef.input, fetchers::UseRegistries::No);
|
state.fetchSettings, *state.store, newLockedRef.input, fetchers::UseRegistries::No);
|
||||||
cachedInput.accessor = cachedInput2.accessor;
|
cachedInput.accessor = cachedInput2.accessor;
|
||||||
lockedRef = FlakeRef(std::move(cachedInput2.lockedInput), newLockedRef.subdir);
|
lockedRef = FlakeRef(std::move(cachedInput2.lockedInput), newLockedRef.subdir);
|
||||||
}
|
}
|
||||||
@@ -756,7 +756,7 @@ lockFlake(const Settings & settings, EvalState & state, const FlakeRef & topRef,
|
|||||||
return {*resolvedPath, *input.ref};
|
return {*resolvedPath, *input.ref};
|
||||||
} else {
|
} else {
|
||||||
auto cachedInput = state.inputCache->getAccessor(
|
auto cachedInput = state.inputCache->getAccessor(
|
||||||
state.fetchSettings, state.store, input.ref->input, useRegistriesInputs);
|
state.fetchSettings, *state.store, input.ref->input, useRegistriesInputs);
|
||||||
|
|
||||||
auto lockedRef = FlakeRef(std::move(cachedInput.lockedInput), input.ref->subdir);
|
auto lockedRef = FlakeRef(std::move(cachedInput.lockedInput), input.ref->subdir);
|
||||||
|
|
||||||
@@ -956,7 +956,7 @@ void callFlake(EvalState & state, const LockedFlake & lockedFlake, Value & vRes)
|
|||||||
auto key = keyMap.find(node);
|
auto key = keyMap.find(node);
|
||||||
assert(key != keyMap.end());
|
assert(key != keyMap.end());
|
||||||
|
|
||||||
override.alloc(state.symbols.create("dir")).mkString(CanonPath(subdir).rel());
|
override.alloc(state.symbols.create("dir")).mkString(CanonPath(subdir).rel(), state.mem);
|
||||||
|
|
||||||
overrides.alloc(state.symbols.create(key->second)).mkAttrs(override);
|
overrides.alloc(state.symbols.create(key->second)).mkAttrs(override);
|
||||||
}
|
}
|
||||||
@@ -966,7 +966,7 @@ void callFlake(EvalState & state, const LockedFlake & lockedFlake, Value & vRes)
|
|||||||
Value * vCallFlake = requireInternalFile(state, CanonPath("call-flake.nix"));
|
Value * vCallFlake = requireInternalFile(state, CanonPath("call-flake.nix"));
|
||||||
|
|
||||||
auto vLocks = state.allocValue();
|
auto vLocks = state.allocValue();
|
||||||
vLocks->mkString(lockFileStr);
|
vLocks->mkString(lockFileStr, state.mem);
|
||||||
|
|
||||||
auto vFetchFinalTree = get(state.internalPrimOps, "fetchFinalTree");
|
auto vFetchFinalTree = get(state.internalPrimOps, "fetchFinalTree");
|
||||||
assert(vFetchFinalTree);
|
assert(vFetchFinalTree);
|
||||||
@@ -975,7 +975,7 @@ void callFlake(EvalState & state, const LockedFlake & lockedFlake, Value & vRes)
|
|||||||
state.callFunction(*vCallFlake, args, vRes, noPos);
|
state.callFunction(*vCallFlake, args, vRes, noPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Fingerprint> LockedFlake::getFingerprint(ref<Store> store, const fetchers::Settings & fetchSettings) const
|
std::optional<Fingerprint> LockedFlake::getFingerprint(Store & store, const fetchers::Settings & fetchSettings) const
|
||||||
{
|
{
|
||||||
if (lockFile.isUnlocked(fetchSettings))
|
if (lockFile.isUnlocked(fetchSettings))
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
@@ -1005,7 +1005,7 @@ Flake::~Flake() {}
|
|||||||
ref<eval_cache::EvalCache> openEvalCache(EvalState & state, ref<const LockedFlake> lockedFlake)
|
ref<eval_cache::EvalCache> openEvalCache(EvalState & state, ref<const LockedFlake> lockedFlake)
|
||||||
{
|
{
|
||||||
auto fingerprint = state.settings.useEvalCache && state.settings.pureEval
|
auto fingerprint = state.settings.useEvalCache && state.settings.pureEval
|
||||||
? lockedFlake->getFingerprint(state.store, state.fetchSettings)
|
? lockedFlake->getFingerprint(*state.store, state.fetchSettings)
|
||||||
: std::nullopt;
|
: std::nullopt;
|
||||||
auto rootLoader = [&state, lockedFlake]() {
|
auto rootLoader = [&state, lockedFlake]() {
|
||||||
/* For testing whether the evaluation cache is
|
/* For testing whether the evaluation cache is
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ std::ostream & operator<<(std::ostream & str, const FlakeRef & flakeRef)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlakeRef FlakeRef::resolve(
|
FlakeRef
|
||||||
const fetchers::Settings & fetchSettings, ref<Store> store, fetchers::UseRegistries useRegistries) const
|
FlakeRef::resolve(const fetchers::Settings & fetchSettings, Store & store, fetchers::UseRegistries useRegistries) const
|
||||||
{
|
{
|
||||||
auto [input2, extraAttrs] = lookupInRegistries(fetchSettings, store, input, useRegistries);
|
auto [input2, extraAttrs] = lookupInRegistries(fetchSettings, store, input, useRegistries);
|
||||||
return FlakeRef(std::move(input2), fetchers::maybeGetStrAttr(extraAttrs, "dir").value_or(subdir));
|
return FlakeRef(std::move(input2), fetchers::maybeGetStrAttr(extraAttrs, "dir").value_or(subdir));
|
||||||
@@ -289,7 +289,7 @@ FlakeRef FlakeRef::fromAttrs(const fetchers::Settings & fetchSettings, const fet
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, FlakeRef>
|
std::pair<ref<SourceAccessor>, FlakeRef>
|
||||||
FlakeRef::lazyFetch(const fetchers::Settings & fetchSettings, ref<Store> store) const
|
FlakeRef::lazyFetch(const fetchers::Settings & fetchSettings, Store & store) const
|
||||||
{
|
{
|
||||||
auto [accessor, lockedInput] = input.getAccessor(fetchSettings, store);
|
auto [accessor, lockedInput] = input.getAccessor(fetchSettings, store);
|
||||||
return {accessor, FlakeRef(std::move(lockedInput), subdir)};
|
return {accessor, FlakeRef(std::move(lockedInput), subdir)};
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ struct LockedFlake
|
|||||||
*/
|
*/
|
||||||
std::map<ref<Node>, SourcePath> nodePaths;
|
std::map<ref<Node>, SourcePath> nodePaths;
|
||||||
|
|
||||||
std::optional<Fingerprint> getFingerprint(ref<Store> store, const fetchers::Settings & fetchSettings) const;
|
std::optional<Fingerprint> getFingerprint(Store & store, const fetchers::Settings & fetchSettings) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LockFlags
|
struct LockFlags
|
||||||
|
|||||||
@@ -73,13 +73,12 @@ struct FlakeRef
|
|||||||
|
|
||||||
FlakeRef resolve(
|
FlakeRef resolve(
|
||||||
const fetchers::Settings & fetchSettings,
|
const fetchers::Settings & fetchSettings,
|
||||||
ref<Store> store,
|
Store & store,
|
||||||
fetchers::UseRegistries useRegistries = fetchers::UseRegistries::All) const;
|
fetchers::UseRegistries useRegistries = fetchers::UseRegistries::All) const;
|
||||||
|
|
||||||
static FlakeRef fromAttrs(const fetchers::Settings & fetchSettings, const fetchers::Attrs & attrs);
|
static FlakeRef fromAttrs(const fetchers::Settings & fetchSettings, const fetchers::Attrs & attrs);
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, FlakeRef>
|
std::pair<ref<SourceAccessor>, FlakeRef> lazyFetch(const fetchers::Settings & fetchSettings, Store & store) const;
|
||||||
lazyFetch(const fetchers::Settings & fetchSettings, ref<Store> store) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Canonicalize a flakeref for the purpose of comparing "old" and
|
* Canonicalize a flakeref for the purpose of comparing "old" and
|
||||||
|
|||||||
@@ -470,7 +470,8 @@ public:
|
|||||||
std::string res;
|
std::string res;
|
||||||
|
|
||||||
auto renderActivity =
|
auto renderActivity =
|
||||||
[&](ActivityType type, const std::string & itemFmt, const std::string & numberFmt = "%d", double unit = 1) {
|
[&] [[nodiscard]] (
|
||||||
|
ActivityType type, const std::string & itemFmt, const std::string & numberFmt = "%d", double unit = 1) {
|
||||||
auto & act = state.activitiesByType[type];
|
auto & act = state.activitiesByType[type];
|
||||||
uint64_t done = act.done, expected = act.done, running = 0, failed = act.failed;
|
uint64_t done = act.done, expected = act.done, running = 0, failed = act.failed;
|
||||||
for (auto & j : act.its) {
|
for (auto & j : act.its) {
|
||||||
@@ -514,7 +515,7 @@ public:
|
|||||||
return s;
|
return s;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto renderSizeActivity = [&](ActivityType type, const std::string & itemFmt = "%s") {
|
auto renderSizeActivity = [&] [[nodiscard]] (ActivityType type, const std::string & itemFmt = "%s") {
|
||||||
auto & act = state.activitiesByType[type];
|
auto & act = state.activitiesByType[type];
|
||||||
uint64_t done = act.done, expected = act.done, running = 0, failed = act.failed;
|
uint64_t done = act.done, expected = act.done, running = 0, failed = act.failed;
|
||||||
for (auto & j : act.its) {
|
for (auto & j : act.its) {
|
||||||
@@ -573,14 +574,17 @@ public:
|
|||||||
return s;
|
return s;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto maybeAppendToResult = [&](std::string_view s) {
|
||||||
|
if (s.empty())
|
||||||
|
return;
|
||||||
|
if (!res.empty())
|
||||||
|
res += ", ";
|
||||||
|
res += s;
|
||||||
|
};
|
||||||
|
|
||||||
auto showActivity =
|
auto showActivity =
|
||||||
[&](ActivityType type, const std::string & itemFmt, const std::string & numberFmt = "%d", double unit = 1) {
|
[&](ActivityType type, const std::string & itemFmt, const std::string & numberFmt = "%d", double unit = 1) {
|
||||||
auto s = renderActivity(type, itemFmt, numberFmt, unit);
|
maybeAppendToResult(renderActivity(type, itemFmt, numberFmt, unit));
|
||||||
if (s.empty())
|
|
||||||
return;
|
|
||||||
if (!res.empty())
|
|
||||||
res += ", ";
|
|
||||||
res += s;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
showActivity(actBuilds, "%s built");
|
showActivity(actBuilds, "%s built");
|
||||||
@@ -602,7 +606,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSizeActivity(actFileTransfer, "%s DL");
|
maybeAppendToResult(renderSizeActivity(actFileTransfer, "%s DL"));
|
||||||
|
|
||||||
{
|
{
|
||||||
auto s = renderActivity(actOptimiseStore, "%s paths optimised");
|
auto s = renderActivity(actOptimiseStore, "%s paths optimised");
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ include_dirs = [ include_directories('.') ]
|
|||||||
|
|
||||||
headers = files(
|
headers = files(
|
||||||
'nix_api_store.h',
|
'nix_api_store.h',
|
||||||
|
'nix_api_store/derivation.h',
|
||||||
|
'nix_api_store/store_path.h',
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO don't install this once tests don't use it and/or move the header into `libstore`, non-`c`
|
# TODO don't install this once tests don't use it and/or move the header into `libstore`, non-`c`
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
#include <cstring>
|
||||||
|
#include <span>
|
||||||
|
|
||||||
#include "nix_api_store.h"
|
#include "nix_api_store.h"
|
||||||
#include "nix_api_store_internal.h"
|
#include "nix_api_store_internal.h"
|
||||||
#include "nix_api_util.h"
|
#include "nix_api_util.h"
|
||||||
@@ -8,6 +11,7 @@
|
|||||||
#include "nix/store/store-open.hh"
|
#include "nix/store/store-open.hh"
|
||||||
#include "nix/store/build-result.hh"
|
#include "nix/store/build-result.hh"
|
||||||
#include "nix/store/local-fs-store.hh"
|
#include "nix/store/local-fs-store.hh"
|
||||||
|
#include "nix/util/base-nix-32.hh"
|
||||||
|
|
||||||
#include "nix/store/globals.hh"
|
#include "nix/store/globals.hh"
|
||||||
|
|
||||||
@@ -215,7 +219,65 @@ void nix_derivation_free(nix_derivation * drv)
|
|||||||
|
|
||||||
StorePath * nix_store_path_clone(const StorePath * p)
|
StorePath * nix_store_path_clone(const StorePath * p)
|
||||||
{
|
{
|
||||||
return new StorePath{p->path};
|
try {
|
||||||
|
return new StorePath{p->path};
|
||||||
|
} catch (...) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // extern "C"
|
||||||
|
|
||||||
|
template<size_t S>
|
||||||
|
static auto to_cpp_array(const uint8_t (&r)[S])
|
||||||
|
{
|
||||||
|
return reinterpret_cast<const std::array<std::byte, S> &>(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
nix_err
|
||||||
|
nix_store_path_hash(nix_c_context * context, const StorePath * store_path, nix_store_path_hash_part * hash_part_out)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
auto hashPart = store_path->path.hashPart();
|
||||||
|
// Decode from Nix32 (base32) encoding to raw bytes
|
||||||
|
auto decoded = nix::BaseNix32::decode(hashPart);
|
||||||
|
|
||||||
|
assert(decoded.size() == sizeof(hash_part_out->bytes));
|
||||||
|
std::memcpy(hash_part_out->bytes, decoded.data(), sizeof(hash_part_out->bytes));
|
||||||
|
return NIX_OK;
|
||||||
|
}
|
||||||
|
NIXC_CATCH_ERRS
|
||||||
|
}
|
||||||
|
|
||||||
|
StorePath * nix_store_create_from_parts(
|
||||||
|
nix_c_context * context, const nix_store_path_hash_part * hash, const char * name, size_t name_len)
|
||||||
|
{
|
||||||
|
if (context)
|
||||||
|
context->last_err_code = NIX_OK;
|
||||||
|
try {
|
||||||
|
// Encode the 20 raw bytes to Nix32 (base32) format
|
||||||
|
auto hashStr = nix::BaseNix32::encode(std::span<const std::byte>{to_cpp_array(hash->bytes)});
|
||||||
|
|
||||||
|
// Construct the store path basename: <hash>-<name>
|
||||||
|
std::string baseName;
|
||||||
|
baseName += hashStr;
|
||||||
|
baseName += "-";
|
||||||
|
baseName += std::string_view{name, name_len};
|
||||||
|
|
||||||
|
return new StorePath{nix::StorePath(std::move(baseName))};
|
||||||
|
}
|
||||||
|
NIXC_CATCH_ERRS_NULL
|
||||||
|
}
|
||||||
|
|
||||||
|
nix_derivation * nix_derivation_clone(const nix_derivation * d)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return new nix_derivation{d->drv};
|
||||||
|
} catch (...) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nix_derivation * nix_derivation_from_json(nix_c_context * context, Store * store, const char * json)
|
nix_derivation * nix_derivation_from_json(nix_c_context * context, Store * store, const char * json)
|
||||||
@@ -223,17 +285,25 @@ nix_derivation * nix_derivation_from_json(nix_c_context * context, Store * store
|
|||||||
if (context)
|
if (context)
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
try {
|
try {
|
||||||
auto drv = static_cast<nix::Derivation>(nlohmann::json::parse(json));
|
return new nix_derivation{nix::Derivation::parseJsonAndValidate(*store->ptr, nlohmann::json::parse(json))};
|
||||||
|
|
||||||
auto drvPath = nix::writeDerivation(*store->ptr, drv, nix::NoRepair, /* read only */ true);
|
|
||||||
|
|
||||||
drv.checkInvariants(*store->ptr, drvPath);
|
|
||||||
|
|
||||||
return new nix_derivation{drv};
|
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS_NULL
|
NIXC_CATCH_ERRS_NULL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nix_err nix_derivation_to_json(
|
||||||
|
nix_c_context * context, const nix_derivation * drv, nix_get_string_callback callback, void * userdata)
|
||||||
|
{
|
||||||
|
if (context)
|
||||||
|
context->last_err_code = NIX_OK;
|
||||||
|
try {
|
||||||
|
auto result = static_cast<nlohmann::json>(drv->drv).dump();
|
||||||
|
if (callback) {
|
||||||
|
callback(result.data(), result.size(), userdata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NIXC_CATCH_ERRS
|
||||||
|
}
|
||||||
|
|
||||||
StorePath * nix_add_derivation(nix_c_context * context, Store * store, nix_derivation * derivation)
|
StorePath * nix_add_derivation(nix_c_context * context, Store * store, nix_derivation * derivation)
|
||||||
{
|
{
|
||||||
if (context)
|
if (context)
|
||||||
@@ -258,4 +328,14 @@ nix_err nix_store_copy_closure(nix_c_context * context, Store * srcStore, Store
|
|||||||
NIXC_CATCH_ERRS
|
NIXC_CATCH_ERRS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nix_derivation * nix_store_drv_from_store_path(nix_c_context * context, Store * store, const StorePath * path)
|
||||||
|
{
|
||||||
|
if (context)
|
||||||
|
context->last_err_code = NIX_OK;
|
||||||
|
try {
|
||||||
|
return new nix_derivation{store->ptr->derivationFromPath(path->path)};
|
||||||
|
}
|
||||||
|
NIXC_CATCH_ERRS_NULL
|
||||||
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nix_api_util.h"
|
#include "nix_api_util.h"
|
||||||
|
#include "nix_api_store/store_path.h"
|
||||||
|
#include "nix_api_store/derivation.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -21,10 +23,6 @@ extern "C" {
|
|||||||
|
|
||||||
/** @brief Reference to a Nix store */
|
/** @brief Reference to a Nix store */
|
||||||
typedef struct Store Store;
|
typedef struct Store Store;
|
||||||
/** @brief Nix store path */
|
|
||||||
typedef struct StorePath StorePath;
|
|
||||||
/** @brief Nix Derivation */
|
|
||||||
typedef struct nix_derivation nix_derivation;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the Nix store library
|
* @brief Initializes the Nix store library
|
||||||
@@ -108,7 +106,7 @@ nix_err
|
|||||||
nix_store_get_storedir(nix_c_context * context, Store * store, nix_get_string_callback callback, void * user_data);
|
nix_store_get_storedir(nix_c_context * context, Store * store, nix_get_string_callback callback, void * user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parse a Nix store path into a StorePath
|
* @brief Parse a Nix store path that includes the store dir into a StorePath
|
||||||
*
|
*
|
||||||
* @note Don't forget to free this path using nix_store_path_free()!
|
* @note Don't forget to free this path using nix_store_path_free()!
|
||||||
* @param[out] context Optional, stores error information
|
* @param[out] context Optional, stores error information
|
||||||
@@ -118,30 +116,6 @@ nix_store_get_storedir(nix_c_context * context, Store * store, nix_get_string_ca
|
|||||||
*/
|
*/
|
||||||
StorePath * nix_store_parse_path(nix_c_context * context, Store * store, const char * path);
|
StorePath * nix_store_parse_path(nix_c_context * context, Store * store, const char * path);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the path name (e.g. "name" in /nix/store/...-name)
|
|
||||||
*
|
|
||||||
* @param[in] store_path the path to get the name from
|
|
||||||
* @param[in] callback called with the name
|
|
||||||
* @param[in] user_data arbitrary data, passed to the callback when it's called.
|
|
||||||
*/
|
|
||||||
void nix_store_path_name(const StorePath * store_path, nix_get_string_callback callback, void * user_data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Copy a StorePath
|
|
||||||
*
|
|
||||||
* @param[in] p the path to copy
|
|
||||||
* @return a new StorePath
|
|
||||||
*/
|
|
||||||
StorePath * nix_store_path_clone(const StorePath * p);
|
|
||||||
|
|
||||||
/** @brief Deallocate a StorePath
|
|
||||||
*
|
|
||||||
* Does not fail.
|
|
||||||
* @param[in] p the path to free
|
|
||||||
*/
|
|
||||||
void nix_store_path_free(StorePath * p);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if a StorePath is valid (i.e. that corresponding store object and its closure of references exists in
|
* @brief Check if a StorePath is valid (i.e. that corresponding store object and its closure of references exists in
|
||||||
* the store)
|
* the store)
|
||||||
@@ -214,9 +188,16 @@ nix_store_get_version(nix_c_context * context, Store * store, nix_get_string_cal
|
|||||||
/**
|
/**
|
||||||
* @brief Create a `nix_derivation` from a JSON representation of that derivation.
|
* @brief Create a `nix_derivation` from a JSON representation of that derivation.
|
||||||
*
|
*
|
||||||
|
* @note Unlike `nix_derivation_to_json`, this needs a `Store`. This is because
|
||||||
|
* over time we expect the internal representation of derivations in Nix to
|
||||||
|
* differ from accepted derivation formats. The store argument is here to help
|
||||||
|
* any logic needed to convert from JSON to the internal representation, in
|
||||||
|
* excess of just parsing.
|
||||||
|
*
|
||||||
* @param[out] context Optional, stores error information.
|
* @param[out] context Optional, stores error information.
|
||||||
* @param[in] store nix store reference.
|
* @param[in] store nix store reference.
|
||||||
* @param[in] json JSON of the derivation as a string.
|
* @param[in] json JSON of the derivation as a string.
|
||||||
|
* @return A new derivation, or NULL on error. Free with `nix_derivation_free` when done using the `nix_derivation`.
|
||||||
*/
|
*/
|
||||||
nix_derivation * nix_derivation_from_json(nix_c_context * context, Store * store, const char * json);
|
nix_derivation * nix_derivation_from_json(nix_c_context * context, Store * store, const char * json);
|
||||||
|
|
||||||
@@ -229,14 +210,6 @@ nix_derivation * nix_derivation_from_json(nix_c_context * context, Store * store
|
|||||||
*/
|
*/
|
||||||
StorePath * nix_add_derivation(nix_c_context * context, Store * store, nix_derivation * derivation);
|
StorePath * nix_add_derivation(nix_c_context * context, Store * store, nix_derivation * derivation);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Deallocate a `nix_derivation`
|
|
||||||
*
|
|
||||||
* Does not fail.
|
|
||||||
* @param[in] drv the derivation to free
|
|
||||||
*/
|
|
||||||
void nix_derivation_free(nix_derivation * drv);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Copy the closure of `path` from `srcStore` to `dstStore`.
|
* @brief Copy the closure of `path` from `srcStore` to `dstStore`.
|
||||||
*
|
*
|
||||||
@@ -276,6 +249,16 @@ nix_err nix_store_get_fs_closure(
|
|||||||
void * userdata,
|
void * userdata,
|
||||||
void (*callback)(nix_c_context * context, void * userdata, const StorePath * store_path));
|
void (*callback)(nix_c_context * context, void * userdata, const StorePath * store_path));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the derivation associated with the store path
|
||||||
|
*
|
||||||
|
* @param[out] context Optional, stores error information
|
||||||
|
* @param[in] store The nix store
|
||||||
|
* @param[in] path The nix store path
|
||||||
|
* @return A new derivation, or NULL on error. Free with `nix_derivation_free` when done using the `nix_derivation`.
|
||||||
|
*/
|
||||||
|
nix_derivation * nix_store_drv_from_store_path(nix_c_context * context, Store * store, const StorePath * path);
|
||||||
|
|
||||||
// cffi end
|
// cffi end
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
#ifndef NIX_API_STORE_DERIVATION_H
|
||||||
|
#define NIX_API_STORE_DERIVATION_H
|
||||||
|
/**
|
||||||
|
* @defgroup libstore_derivation Derivation
|
||||||
|
* @ingroup libstore
|
||||||
|
* @brief Derivation operations that don't require a Store
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/** @file
|
||||||
|
* @brief Derivation operations
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "nix_api_util.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
// cffi start
|
||||||
|
|
||||||
|
/** @brief Nix Derivation */
|
||||||
|
typedef struct nix_derivation nix_derivation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Copy a `nix_derivation`
|
||||||
|
*
|
||||||
|
* @param[in] d the derivation to copy
|
||||||
|
* @return a new `nix_derivation`
|
||||||
|
*/
|
||||||
|
nix_derivation * nix_derivation_clone(const nix_derivation * d);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deallocate a `nix_derivation`
|
||||||
|
*
|
||||||
|
* Does not fail.
|
||||||
|
* @param[in] drv the derivation to free
|
||||||
|
*/
|
||||||
|
void nix_derivation_free(nix_derivation * drv);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the derivation as a JSON string
|
||||||
|
*
|
||||||
|
* @param[out] context Optional, stores error information
|
||||||
|
* @param[in] drv The derivation
|
||||||
|
* @param[in] callback Called with the JSON string
|
||||||
|
* @param[in] userdata Arbitrary data passed to the callback
|
||||||
|
*/
|
||||||
|
nix_err nix_derivation_to_json(
|
||||||
|
nix_c_context * context, const nix_derivation * drv, nix_get_string_callback callback, void * userdata);
|
||||||
|
|
||||||
|
// cffi end
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
#endif // NIX_API_STORE_DERIVATION_H
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
#ifndef NIX_API_STORE_STORE_PATH_H
|
||||||
|
#define NIX_API_STORE_STORE_PATH_H
|
||||||
|
/**
|
||||||
|
* @defgroup libstore_storepath StorePath
|
||||||
|
* @ingroup libstore
|
||||||
|
* @brief Store path operations that don't require a Store
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/** @file
|
||||||
|
* @brief Store path operations
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "nix_api_util.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
// cffi start
|
||||||
|
|
||||||
|
/** @brief Nix store path */
|
||||||
|
typedef struct StorePath StorePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Copy a StorePath
|
||||||
|
*
|
||||||
|
* @param[in] p the path to copy
|
||||||
|
* @return a new StorePath
|
||||||
|
*/
|
||||||
|
StorePath * nix_store_path_clone(const StorePath * p);
|
||||||
|
|
||||||
|
/** @brief Deallocate a StorePath
|
||||||
|
*
|
||||||
|
* Does not fail.
|
||||||
|
* @param[in] p the path to free
|
||||||
|
*/
|
||||||
|
void nix_store_path_free(StorePath * p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the path name (e.g. "<name>" in /nix/store/<hash>-<name>)
|
||||||
|
*
|
||||||
|
* @param[in] store_path the path to get the name from
|
||||||
|
* @param[in] callback called with the name
|
||||||
|
* @param[in] user_data arbitrary data, passed to the callback when it's called.
|
||||||
|
*/
|
||||||
|
void nix_store_path_name(const StorePath * store_path, nix_get_string_callback callback, void * user_data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A store path hash
|
||||||
|
*
|
||||||
|
* Once decoded from "nix32" encoding, a store path hash is 20 raw bytes.
|
||||||
|
*/
|
||||||
|
typedef struct nix_store_path_hash_part
|
||||||
|
{
|
||||||
|
uint8_t bytes[20];
|
||||||
|
} nix_store_path_hash_part;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the path hash (e.g. "<hash>" in /nix/store/<hash>-<name>)
|
||||||
|
*
|
||||||
|
* The hash is returned as raw bytes, decoded from "nix32" encoding.
|
||||||
|
*
|
||||||
|
* @param[out] context Optional, stores error information
|
||||||
|
* @param[in] store_path the path to get the hash from
|
||||||
|
* @param[out] hash_part_out the decoded hash as 20 raw bytes
|
||||||
|
* @return NIX_OK on success, error code on failure
|
||||||
|
*/
|
||||||
|
nix_err
|
||||||
|
nix_store_path_hash(nix_c_context * context, const StorePath * store_path, nix_store_path_hash_part * hash_part_out);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create a StorePath from its constituent parts (hash and name)
|
||||||
|
*
|
||||||
|
* This function constructs a store path from a hash and name, without needing
|
||||||
|
* a Store reference or the store directory prefix.
|
||||||
|
*
|
||||||
|
* @note Don't forget to free this path using nix_store_path_free()!
|
||||||
|
* @param[out] context Optional, stores error information
|
||||||
|
* @param[in] hash The store path hash (20 raw bytes)
|
||||||
|
* @param[in] name The store path name (the part after the hash)
|
||||||
|
* @param[in] name_len Length of the name string
|
||||||
|
* @return owned store path, NULL on error
|
||||||
|
*/
|
||||||
|
StorePath * nix_store_create_from_parts(
|
||||||
|
nix_c_context * context, const nix_store_path_hash_part * hash, const char name[/*name_len*/], size_t name_len);
|
||||||
|
|
||||||
|
// cffi end
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
#endif // NIX_API_STORE_STORE_PATH_H
|
||||||
@@ -50,7 +50,8 @@ protected:
|
|||||||
#else
|
#else
|
||||||
// resolve any symlinks in i.e. on macOS /tmp -> /private/tmp
|
// resolve any symlinks in i.e. on macOS /tmp -> /private/tmp
|
||||||
// because this is not allowed for a nix store.
|
// because this is not allowed for a nix store.
|
||||||
auto tmpl = nix::absPath(std::filesystem::path(nix::defaultTempDir()) / "tests_nix-store.XXXXXX", true);
|
auto tmpl =
|
||||||
|
nix::absPath(std::filesystem::path(nix::defaultTempDir()) / "tests_nix-store.XXXXXX", std::nullopt, true);
|
||||||
nixDir = mkdtemp((char *) tmpl.c_str());
|
nixDir = mkdtemp((char *) tmpl.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,13 @@
|
|||||||
"allowSubstitutes": false,
|
"allowSubstitutes": false,
|
||||||
"exportReferencesGraph": {
|
"exportReferencesGraph": {
|
||||||
"refs1": [
|
"refs1": [
|
||||||
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
|
{
|
||||||
|
"drvPath": "j56sf12rxpcv5swr14vsjn5cwm6bj03h-foo.drv",
|
||||||
|
"output": "out"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"refs2": [
|
"refs2": [
|
||||||
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv"
|
"qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"impureEnvVars": [
|
"impureEnvVars": [
|
||||||
@@ -20,18 +23,36 @@
|
|||||||
"outputChecks": {
|
"outputChecks": {
|
||||||
"forAllOutputs": {
|
"forAllOutputs": {
|
||||||
"allowedReferences": [
|
"allowedReferences": [
|
||||||
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
|
{
|
||||||
|
"drvPath": "j56sf12rxpcv5swr14vsjn5cwm6bj03h-foo.drv",
|
||||||
|
"output": "out"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"allowedRequisites": [
|
"allowedRequisites": [
|
||||||
"/0nr45p69vn6izw9446wsh9bng9nndhvn19kpsm4n96a5mycw0s4z",
|
{
|
||||||
"bin"
|
"drvPath": "self",
|
||||||
|
"output": "bin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"drvPath": "j56sf12rxpcv5swr14vsjn5cwm6bj03h-foo.drv",
|
||||||
|
"output": "dev"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"disallowedReferences": [
|
"disallowedReferences": [
|
||||||
"/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g",
|
{
|
||||||
"dev"
|
"drvPath": "self",
|
||||||
|
"output": "dev"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"drvPath": "qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv",
|
||||||
|
"output": "out"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"disallowedRequisites": [
|
"disallowedRequisites": [
|
||||||
"/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8"
|
{
|
||||||
|
"drvPath": "qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv",
|
||||||
|
"output": "dev"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"ignoreSelfRefs": true,
|
"ignoreSelfRefs": true,
|
||||||
"maxClosureSize": null,
|
"maxClosureSize": null,
|
||||||
|
|||||||
@@ -4,10 +4,13 @@
|
|||||||
"allowSubstitutes": false,
|
"allowSubstitutes": false,
|
||||||
"exportReferencesGraph": {
|
"exportReferencesGraph": {
|
||||||
"refs1": [
|
"refs1": [
|
||||||
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
|
{
|
||||||
|
"drvPath": "j56sf12rxpcv5swr14vsjn5cwm6bj03h-foo.drv",
|
||||||
|
"output": "out"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"refs2": [
|
"refs2": [
|
||||||
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv"
|
"qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"impureEnvVars": [
|
"impureEnvVars": [
|
||||||
@@ -23,11 +26,20 @@
|
|||||||
"allowedReferences": null,
|
"allowedReferences": null,
|
||||||
"allowedRequisites": null,
|
"allowedRequisites": null,
|
||||||
"disallowedReferences": [
|
"disallowedReferences": [
|
||||||
"/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g",
|
{
|
||||||
"dev"
|
"drvPath": "self",
|
||||||
|
"output": "dev"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"drvPath": "qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv",
|
||||||
|
"output": "out"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"disallowedRequisites": [
|
"disallowedRequisites": [
|
||||||
"/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8"
|
{
|
||||||
|
"drvPath": "qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv",
|
||||||
|
"output": "dev"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"ignoreSelfRefs": false,
|
"ignoreSelfRefs": false,
|
||||||
"maxClosureSize": null,
|
"maxClosureSize": null,
|
||||||
@@ -44,11 +56,20 @@
|
|||||||
},
|
},
|
||||||
"out": {
|
"out": {
|
||||||
"allowedReferences": [
|
"allowedReferences": [
|
||||||
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
|
{
|
||||||
|
"drvPath": "j56sf12rxpcv5swr14vsjn5cwm6bj03h-foo.drv",
|
||||||
|
"output": "out"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"allowedRequisites": [
|
"allowedRequisites": [
|
||||||
"/0nr45p69vn6izw9446wsh9bng9nndhvn19kpsm4n96a5mycw0s4z",
|
{
|
||||||
"bin"
|
"drvPath": "self",
|
||||||
|
"output": "bin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"drvPath": "j56sf12rxpcv5swr14vsjn5cwm6bj03h-foo.drv",
|
||||||
|
"output": "dev"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"disallowedReferences": [],
|
"disallowedReferences": [],
|
||||||
"disallowedRequisites": [],
|
"disallowedRequisites": [],
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
"allowSubstitutes": false,
|
"allowSubstitutes": false,
|
||||||
"exportReferencesGraph": {
|
"exportReferencesGraph": {
|
||||||
"refs1": [
|
"refs1": [
|
||||||
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
|
"p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
|
||||||
],
|
],
|
||||||
"refs2": [
|
"refs2": [
|
||||||
"/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv"
|
"vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"impureEnvVars": [
|
"impureEnvVars": [
|
||||||
@@ -20,18 +20,24 @@
|
|||||||
"outputChecks": {
|
"outputChecks": {
|
||||||
"forAllOutputs": {
|
"forAllOutputs": {
|
||||||
"allowedReferences": [
|
"allowedReferences": [
|
||||||
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
|
"p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
|
||||||
],
|
],
|
||||||
"allowedRequisites": [
|
"allowedRequisites": [
|
||||||
"/nix/store/z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev",
|
{
|
||||||
"bin"
|
"drvPath": "self",
|
||||||
|
"output": "bin"
|
||||||
|
},
|
||||||
|
"z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev"
|
||||||
],
|
],
|
||||||
"disallowedReferences": [
|
"disallowedReferences": [
|
||||||
"/nix/store/r5cff30838majxk5mp3ip2diffi8vpaj-bar",
|
{
|
||||||
"dev"
|
"drvPath": "self",
|
||||||
|
"output": "dev"
|
||||||
|
},
|
||||||
|
"r5cff30838majxk5mp3ip2diffi8vpaj-bar"
|
||||||
],
|
],
|
||||||
"disallowedRequisites": [
|
"disallowedRequisites": [
|
||||||
"/nix/store/9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev"
|
"9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev"
|
||||||
],
|
],
|
||||||
"ignoreSelfRefs": true,
|
"ignoreSelfRefs": true,
|
||||||
"maxClosureSize": null,
|
"maxClosureSize": null,
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
"allowSubstitutes": false,
|
"allowSubstitutes": false,
|
||||||
"exportReferencesGraph": {
|
"exportReferencesGraph": {
|
||||||
"refs1": [
|
"refs1": [
|
||||||
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
|
"p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
|
||||||
],
|
],
|
||||||
"refs2": [
|
"refs2": [
|
||||||
"/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv"
|
"vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"impureEnvVars": [
|
"impureEnvVars": [
|
||||||
@@ -23,11 +23,14 @@
|
|||||||
"allowedReferences": null,
|
"allowedReferences": null,
|
||||||
"allowedRequisites": null,
|
"allowedRequisites": null,
|
||||||
"disallowedReferences": [
|
"disallowedReferences": [
|
||||||
"/nix/store/r5cff30838majxk5mp3ip2diffi8vpaj-bar",
|
{
|
||||||
"dev"
|
"drvPath": "self",
|
||||||
|
"output": "dev"
|
||||||
|
},
|
||||||
|
"r5cff30838majxk5mp3ip2diffi8vpaj-bar"
|
||||||
],
|
],
|
||||||
"disallowedRequisites": [
|
"disallowedRequisites": [
|
||||||
"/nix/store/9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev"
|
"9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev"
|
||||||
],
|
],
|
||||||
"ignoreSelfRefs": false,
|
"ignoreSelfRefs": false,
|
||||||
"maxClosureSize": null,
|
"maxClosureSize": null,
|
||||||
@@ -44,11 +47,14 @@
|
|||||||
},
|
},
|
||||||
"out": {
|
"out": {
|
||||||
"allowedReferences": [
|
"allowedReferences": [
|
||||||
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
|
"p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
|
||||||
],
|
],
|
||||||
"allowedRequisites": [
|
"allowedRequisites": [
|
||||||
"/nix/store/z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev",
|
{
|
||||||
"bin"
|
"drvPath": "self",
|
||||||
|
"output": "bin"
|
||||||
|
},
|
||||||
|
"z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev"
|
||||||
],
|
],
|
||||||
"disallowedReferences": [],
|
"disallowedReferences": [],
|
||||||
"disallowedRequisites": [],
|
"disallowedRequisites": [],
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"args": [],
|
||||||
|
"builder": "/bin/sh",
|
||||||
|
"env": {
|
||||||
|
"__doc": "InputAddressed throws when should be deferred",
|
||||||
|
"out": ""
|
||||||
|
},
|
||||||
|
"inputs": {
|
||||||
|
"drvs": {
|
||||||
|
"lg4c4b8r9hlczwprl6kgnzfd9mc1xmkk-dependency.drv": {
|
||||||
|
"dynamicOutputs": {},
|
||||||
|
"outputs": [
|
||||||
|
"out"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"srcs": []
|
||||||
|
},
|
||||||
|
"name": "depends-on-drv",
|
||||||
|
"outputs": {
|
||||||
|
"out": {
|
||||||
|
"path": "c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-wrong-name"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"system": "x86_64-linux",
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"args": [],
|
||||||
|
"builder": "/bin/sh",
|
||||||
|
"env": {
|
||||||
|
"__doc": "Wrong env var value throws error",
|
||||||
|
"out": "/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-wrong-name"
|
||||||
|
},
|
||||||
|
"inputs": {
|
||||||
|
"drvs": {},
|
||||||
|
"srcs": []
|
||||||
|
},
|
||||||
|
"name": "bad-env-var",
|
||||||
|
"outputs": {
|
||||||
|
"out": {}
|
||||||
|
},
|
||||||
|
"system": "x86_64-linux",
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
Loaded 100 of 254 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user