Compare commits

..
Author SHA1 Message Date
John Ericson da9ade20e3 Add warning for non-JSON-object exportReferencesGraph 2025-12-09 13:02:46 -05:00
322 changed files with 3481 additions and 6979 deletions

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ jobs:
# required to find all branches # required to find all branches
fetch-depth: 0 fetch-depth: 0
- name: Create backport PRs - name: Create backport PRs
uses: korthout/backport-action@c656f5d5851037b2b38fb5db2691a03fa229e3b2 # v4.0.1 uses: korthout/backport-action@d07416681cab29bf2661702f925f020aaa962997 # v3.4.1
id: backport id: backport
with: with:
# Config README: https://github.com/korthout/backport-action#backport-action # Config README: https://github.com/korthout/backport-action#backport-action
+84 -18
View File
@@ -125,13 +125,13 @@ jobs:
cat coverage-reports/index.txt >> $GITHUB_STEP_SUMMARY cat coverage-reports/index.txt >> $GITHUB_STEP_SUMMARY
if: ${{ matrix.instrumented }} if: ${{ matrix.instrumented }}
- name: Upload coverage reports - name: Upload coverage reports
uses: actions/upload-artifact@v6 uses: actions/upload-artifact@v5
with: with:
name: coverage-reports name: coverage-reports
path: coverage-reports/ path: coverage-reports/
if: ${{ matrix.instrumented }} if: ${{ matrix.instrumented }}
- name: Upload installer tarball - name: Upload installer tarball
uses: actions/upload-artifact@v6 uses: actions/upload-artifact@v5
with: with:
name: installer-${{matrix.os}} name: installer-${{matrix.os}}
path: out/* path: out/*
@@ -164,7 +164,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- name: Download installer tarball - name: Download installer tarball
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 uses: actions/download-artifact@v6
with: with:
name: installer-${{matrix.os}} name: installer-${{matrix.os}}
path: out path: out
@@ -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@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0 - 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) }}
@@ -197,6 +197,80 @@ jobs:
- run: exec bash -c "nix-channel --add https://releases.nixos.org/nixos/unstable/nixos-23.05pre466020.60c1d71f2ba nixpkgs" - run: exec bash -c "nix-channel --add https://releases.nixos.org/nixos/unstable/nixos-23.05pre466020.60c1d71f2ba nixpkgs"
- run: exec bash -c "nix-channel --update && nix-env -iA nixpkgs.hello && hello" - run: exec bash -c "nix-channel --update && nix-env -iA nixpkgs.hello && hello"
# Steps to test CI automation in your own fork.
# 1. Sign-up for https://hub.docker.com/
# 2. Store your dockerhub username as DOCKERHUB_USERNAME in "Repository secrets" of your fork repository settings (https://github.com/$githubuser/nix/settings/secrets/actions)
# 3. Create an access token in https://hub.docker.com/settings/security and store it as DOCKERHUB_TOKEN in "Repository secrets" of your fork
check_secrets:
permissions:
contents: none
name: Check presence of secrets
runs-on: ubuntu-24.04
outputs:
docker: ${{ steps.secret.outputs.docker }}
steps:
- name: Check for DockerHub secrets
id: secret
env:
_DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }}
run: |
echo "docker=${{ env._DOCKER_SECRETS != '' }}" >> $GITHUB_OUTPUT
docker_push_image:
needs: [tests, check_secrets]
permissions:
contents: read
packages: write
if: >-
needs.check_secrets.outputs.docker == 'true' &&
github.event_name == 'push' &&
github.ref_name == 'master'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: ./.github/actions/install-nix-action
with:
dogfood: false
extra_nix_config: |
experimental-features = flakes nix-command
- run: echo NIX_VERSION="$(nix eval .\#nix.version | tr -d \")" >> $GITHUB_ENV
- run: nix build .#dockerImage -L
- run: docker load -i ./result/image.tar.gz
- run: docker tag nix:$NIX_VERSION ${{ secrets.DOCKERHUB_USERNAME }}/nix:$NIX_VERSION
- run: docker tag nix:$NIX_VERSION ${{ secrets.DOCKERHUB_USERNAME }}/nix:master
# We'll deploy the newly built image to both Docker Hub and Github Container Registry.
#
# Push to Docker Hub first
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/nix:$NIX_VERSION
- run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/nix:master
# Push to GitHub Container Registry as well
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/nix
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
docker tag nix:$NIX_VERSION $IMAGE_ID:$NIX_VERSION
docker tag nix:$NIX_VERSION $IMAGE_ID:latest
docker push $IMAGE_ID:$NIX_VERSION
docker push $IMAGE_ID:latest
# deprecated 2024-02-24
docker tag nix:$NIX_VERSION $IMAGE_ID:master
docker push $IMAGE_ID:master
flake_regressions: flake_regressions:
needs: tests needs: tests
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
@@ -213,21 +287,13 @@ jobs:
with: with:
repository: NixOS/flake-regressions-data repository: NixOS/flake-regressions-data
path: flake-regressions/tests path: flake-regressions/tests
- name: Download installer tarball - uses: ./.github/actions/install-nix-action
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with: with:
name: installer-linux dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
path: out extra_nix_config:
- name: Looking up the installer tarball URL experimental-features = nix-command flakes
id: installer-tarball-url github_token: ${{ secrets.GITHUB_TOKEN }}
run: | - run: nix build -L --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh
echo "installer-url=file://$GITHUB_WORKSPACE/out" >> "$GITHUB_OUTPUT"
- uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0
with:
install_url: ${{ format('{0}/install', steps.installer-tarball-url.outputs.installer-url) }}
install_options: ${{ format('--tarball-url-prefix {0}', steps.installer-tarball-url.outputs.installer-url) }}
- name: Run flake regressions tests
run: MAX_FLAKES=25 flake-regressions/eval-all.sh
profile_build: profile_build:
needs: tests needs: tests
-69
View File
@@ -1,69 +0,0 @@
name: Upload Release
on:
workflow_dispatch:
inputs:
eval_id:
description: "Hydra evaluation ID"
required: true
type: number
is_latest:
description: "Mark as latest release"
required: false
type: boolean
default: false
permissions:
contents: read
id-token: write
packages: write
jobs:
release:
runs-on: ubuntu-24.04
environment: releases
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: ./.github/actions/install-nix-action
with:
dogfood: false # Use stable version
use_cache: false # Don't want any cache injection shenanigans
extra_nix_config: |
experimental-features = nix-command flakes
- name: Set NIX_PATH from flake input
run: |
NIXPKGS_PATH=$(nix build --inputs-from .# nixpkgs#path --print-out-paths --no-link)
# Shebangs with perl have issues. Pin nixpkgs this way. nix shell should maybe
# get the same uberhack that nix-shell has to support it.
echo "NIX_PATH=nixpkgs=$NIXPKGS_PATH" >> "$GITHUB_ENV"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708 # v5.1.1
with:
role-to-assume: "arn:aws:iam::080433136561:role/nix-release"
role-session-name: nix-release-oidc-${{ github.run_id }}
aws-region: eu-west-1
- name: Login to Docker Hub
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release
run: |
./maintainers/upload-release.pl \
${{ inputs.eval_id }} \
--skip-git
env:
IS_LATEST: ${{ inputs.is_latest && '1' || '' }}
- name: Push to GHCR
run: |
DOCKER_OWNER="ghcr.io/$(echo '${{ github.repository_owner }}' | tr '[A-Z]' '[a-z]')/nix"
./maintainers/upload-release.pl \
${{ inputs.eval_id }} \
--skip-git \
--skip-s3 \
--docker-owner "$DOCKER_OWNER"
env:
IS_LATEST: ${{ inputs.is_latest && '1' || '' }}
+1 -1
View File
@@ -1 +1 @@
2.34.0 2.33.0
+3 -6
View File
@@ -26,6 +26,7 @@ bash = find_program('bash', native : true)
# HTML manual dependencies (conditional) # HTML manual dependencies (conditional)
if get_option('html-manual') if get_option('html-manual')
mdbook = find_program('mdbook', native : true) mdbook = find_program('mdbook', native : true)
rsync = find_program('rsync', required : true, native : true)
endif endif
pymod = import('python') pymod = import('python')
@@ -125,12 +126,7 @@ if get_option('html-manual')
@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
# Copy source to build directory, excluding the build directory itself @4@ -r -L --exclude='*.drv' --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
# (which is present when built as an individual component).
# Use tar with --dereference to copy symlink targets (e.g., JSON examples from tests).
(cd @CURRENT_SOURCE_DIR@ && find . -mindepth 1 -maxdepth 1 ! -name build | tar -c --dereference -T - -f -) | (cd @2@ && tar -xf -)
chmod -R u+w @2@
find @2@ -name '*.drv' -delete
(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
@@ -142,6 +138,7 @@ if get_option('html-manual')
mdbook.full_path(), mdbook.full_path(),
meson.current_build_dir(), meson.current_build_dir(),
meson.project_version(), meson.project_version(),
rsync.full_path(),
), ),
], ],
input : [ input : [
+2 -2
View File
@@ -10,6 +10,7 @@
mdbook, mdbook,
jq, jq,
python3, python3,
rsync,
nix-cli, nix-cli,
changelog-d, changelog-d,
json-schema-for-humans, json-schema-for-humans,
@@ -53,8 +54,6 @@ mkMesonDerivation (finalAttrs: {
../../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 ../../src/libstore-tests/data/dummy-store
# For derivation examples referenced by symlinks in doc/manual/source/protocols/json/schema/
../../tests/functional/derivation
# Too many different types of files to filter for now # Too many different types of files to filter for now
../../doc/manual ../../doc/manual
./. ./.
@@ -91,6 +90,7 @@ mkMesonDerivation (finalAttrs: {
] ]
++ lib.optionals buildHtmlManual [ ++ lib.optionals buildHtmlManual [
mdbook mdbook
rsync
json-schema-for-humans json-schema-for-humans
] ]
++ lib.optionals (!officialRelease && buildHtmlManual) [ ++ lib.optionals (!officialRelease && buildHtmlManual) [
+9
View File
@@ -0,0 +1,9 @@
---
synopsis: Channel URLs migrated to channels.nixos.org subdomain
prs: [14518]
issues: [14517]
---
Channel URLs have been updated from `https://nixos.org/channels/` to `https://channels.nixos.org/` throughout Nix.
The subdomain provides better reliability with IPv6 support and improved CDN distribution. The old domain apex (`nixos.org/channels/`) currently redirects to the new location but may be deprecated in the future.
+88
View File
@@ -0,0 +1,88 @@
---
synopsis: "JSON format changes for store path info and derivations"
prs: []
issues: []
---
JSON formats for store path info and derivations have been updated with new versions and structured fields.
## Store Path Info JSON
`nix path-info --json` now requires a `--json-format` flag to specify the output format version.
Using `--json` without `--json-format` is deprecated and will become an error in a future release.
For now, it defaults to version 1 with a warning, for a smoother migration.
### Version 1 (`--json-format 1`)
This is the legacy format, preserved for backwards compatibility:
- String-based hash values (e.g., `"narHash": "sha256:FePFYIlM..."`)
- String-based content addresses (e.g., `"ca": "fixed:r:sha256:1abc..."`)
- Full store paths for map keys and references (e.g., `"/nix/store/abc...-foo"`)
- Now includes `"storeDir"` field at the top level
### Version 2 (`--json-format 2`)
The new structured format follows the [JSON guidelines](@docroot@/development/json-guideline.md) with the following changes:
- **Nested structure with top-level metadata**:
The output is now wrapped in an object with `version`, `storeDir`, and `info` fields:
```json
{
"version": 2,
"storeDir": "/nix/store",
"info": { ... }
}
```
The map from store bath base names to store object info is nested under the `info` field.
- **Store path base names instead of full paths**:
Map keys and references use store path base names (e.g., `"abc...-foo"`) instead of full absolute store paths.
Combined with `storeDir`, the full path can be reconstructed.
- **Structured `ca` field**:
Content address is now a structured JSON object instead of a string:
- Old: `"ca": "fixed:r:sha256:1abc..."`
- New: `"ca": {"method": "nar", "hash": "sha256-ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0="}`
- Still `null` values for input-addressed store objects
The `hash` field uses the [SRI](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) format like other hashes.
Nix currently only produces, and doesn't consume this format.
Additionally the following field is added to both formats.
(The `version` tracks breaking changes, and adding fields to outputted JSON is not a breaking change.)
- **`version` field**:
All store path info JSON now includes `"version": <1|2>`.
- **`storeDir` field**:
Top-level `"storeDir"` field contains the store directory path (e.g., `"/nix/store"`).
## Derivation JSON (Version 4)
The derivation JSON format has been updated from version 3 to version 4:
- **Restructured inputs**:
Inputs are now nested under an `inputs` object:
- Old: `"inputSrcs": [...], "inputDrvs": {...}`
- New: `"inputs": {"srcs": [...], "drvs": {...}}`
- **Consistent content addresses**:
Fixed content-addressed outputs now use structured JSON format.
This is the same format as `ca` in store path info (after the new version).
Version 3 and earlier formats are *not* accepted when reading.
**Affected command**: `nix derivation`, namely its `show` and `add` sub-commands.
+12
View File
@@ -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).
+8
View File
@@ -0,0 +1,8 @@
---
synopsis: Interrupting REPL commands works more than once
issues: [13481]
---
Previously, this only worked once per REPL session; further attempts would be ignored.
This issue is now fixed, so REPL commands such as `:b` or `:p` can be canceled consistently.
This is a cherry-pick of the change from the [Lix project](https://gerrit.lix.systems/c/lix/+/1097).
@@ -0,0 +1,40 @@
---
synopsis: "Improved S3 binary cache support via HTTP"
prs: [13752, 13823, 14026, 14120, 14131, 14135, 14144, 14170, 14190, 14198, 14206, 14209, 14222, 14223, 14330, 14333, 14335, 14336, 14337, 14350, 14356, 14357, 14374, 14375, 14376, 14377, 14391, 14393, 14420, 14421]
issues: [13084, 12671, 11748, 12403]
---
S3 binary cache operations now happen via HTTP, leveraging `libcurl`'s native
AWS SigV4 authentication instead of the AWS C++ SDK, providing significant
improvements:
- **Reduced memory usage**: Eliminates memory buffering issues that caused
segfaults with large files
- **Fixed upload reliability**: Resolves AWS SDK chunking errors
(`InvalidChunkSizeError`)
- **Lighter dependencies**: Uses lightweight `aws-crt-cpp` instead of full
`aws-cpp-sdk`, reducing build complexity
The new implementation requires curl >= 7.75.0 and `aws-crt-cpp` for credential
management.
All existing S3 URL formats and parameters remain supported, however the store
settings for configuring multipart uploads have changed:
- **`multipart-upload`** (default: `false`): Enable multipart uploads for large
files. When enabled, files exceeding the multipart threshold will be uploaded
in multiple parts.
- **`multipart-threshold`** (default: `100 MiB`): Minimum file size for using
multipart uploads. Files smaller than this will use regular PUT requests.
Only takes effect when `multipart-upload` is enabled.
- **`multipart-chunk-size`** (default: `5 MiB`): Size of each part in multipart
uploads. Must be at least 5 MiB (AWS S3 requirement). Larger chunk sizes
reduce the number of requests but use more memory.
- **`buffer-size`**: Has been replaced by `multipart-chunk-size` and is now an alias to it.
Note that this change also means Nix now supports S3 binary cache stores even
if built without `aws-crt-cpp`, but only for public buckets which do not
require authentication.
@@ -0,0 +1,14 @@
---
synopsis: "S3 URLs now support object versioning via versionId parameter"
prs: [14274]
issues: [13955]
---
S3 URLs now support a `versionId` query parameter to fetch specific versions
of objects from S3 buckets with versioning enabled. This allows pinning to
exact object versions for reproducibility and protection against unexpected
changes:
```
s3://bucket/key?region=us-east-1&versionId=abc123def456
```
+21
View File
@@ -0,0 +1,21 @@
---
synopsis: "S3 binary cache stores now support storage class configuration"
prs: [14464]
issues: [7015]
---
S3 binary cache stores now support configuring the storage class for uploaded objects via the `storage-class` parameter. This allows users to optimize costs by selecting appropriate storage tiers based on access patterns.
Example usage:
```bash
# Use Glacier storage for long-term archival
nix copy --to 's3://my-bucket?storage-class=GLACIER' /nix/store/...
# Use Intelligent Tiering for automatic cost optimization
nix copy --to 's3://my-bucket?storage-class=INTELLIGENT_TIERING' /nix/store/...
```
The storage class applies to both regular uploads and multipart uploads. When not specified, objects use the bucket's default storage class.
See the [S3 storage classes documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-class-intro.html) for available storage classes and their characteristics.
-1
View File
@@ -151,7 +151,6 @@
- [Contributing](development/contributing.md) - [Contributing](development/contributing.md)
- [Releases](release-notes/index.md) - [Releases](release-notes/index.md)
{{#include ./SUMMARY-rl-next.md}} {{#include ./SUMMARY-rl-next.md}}
- [Release 2.33 (2025-12-09)](release-notes/rl-2.33.md)
- [Release 2.32 (2025-10-06)](release-notes/rl-2.32.md) - [Release 2.32 (2025-10-06)](release-notes/rl-2.32.md)
- [Release 2.31 (2025-08-21)](release-notes/rl-2.31.md) - [Release 2.31 (2025-08-21)](release-notes/rl-2.31.md)
- [Release 2.30 (2025-07-07)](release-notes/rl-2.30.md) - [Release 2.30 (2025-07-07)](release-notes/rl-2.30.md)
@@ -27,7 +27,7 @@ site](https://en.wikipedia.org/wiki/Call_site) position and the name of the
function being called (when available). For example: function being called (when available). For example:
``` ```
/nix/store/2q71fdvr4h33g9832hiriwnf20fn630l-source/pkgs/top-level/default.nix:167:5:primop import /nix/store/x9wnkly3k1gkq580m90jjn32q9f05q2v-source/pkgs/top-level/default.nix:167:5:primop import
``` ```
Here `import` primop is called at `/nix/store/2q71fdvr4h33g9832hiriwnf20fn630l-source/pkgs/top-level/default.nix:167:5`. Here `import` primop is called at `/nix/store/x9wnkly3k1gkq580m90jjn32q9f05q2v-source/pkgs/top-level/default.nix:167:5`.
@@ -39,11 +39,11 @@ This makes all subscribed channels available as attributes in the default expres
A symlink that ensures that [`nix-env`] can find the current user's [channels]: A symlink that ensures that [`nix-env`] can find the current user's [channels]:
- `~/.nix-defexpr/channels` - `~/.nix-defexpr/channels`
- `$XDG_STATE_HOME/nix/defexpr/channels` if [`use-xdg-base-directories`] is set to `true`. - `$XDG_STATE_HOME/defexpr/channels` if [`use-xdg-base-directories`] is set to `true`.
This symlink points to: This symlink points to:
- `$XDG_STATE_HOME/nix/profiles/channels` for regular users - `$XDG_STATE_HOME/profiles/channels` for regular users
- `$NIX_STATE_DIR/profiles/per-user/root/channels` for `root` - `$NIX_STATE_DIR/profiles/per-user/root/channels` for `root`
In a multi-user installation, you may also have `~/.nix-defexpr/channels_root`, which links to the channels of the root user. In a multi-user installation, you may also have `~/.nix-defexpr/channels_root`, which links to the channels of the root user.
@@ -114,9 +114,9 @@ Here is an example of how this file might look like after installing `hello` fro
}; };
name = "hello-2.12.1"; name = "hello-2.12.1";
out = { out = {
outPath = "/nix/store/src1vzij2z0slnakrsbpqpk20389z0k6-hello-2.12.1"; outPath = "/nix/store/260q5867crm1xjs4khgqpl6vr9kywql1-hello-2.12.1";
}; };
outPath = "/nix/store/src1vzij2z0slnakrsbpqpk20389z0k6-hello-2.12.1"; outPath = "/nix/store/260q5867crm1xjs4khgqpl6vr9kywql1-hello-2.12.1";
outputs = [ "out" ]; outputs = [ "out" ];
system = "x86_64-linux"; system = "x86_64-linux";
type = "derivation"; type = "derivation";
@@ -37,13 +37,13 @@ dr-xr-xr-x 4 root root 4096 Jan 1 1970 share
/home/eelco/.local/state/nix/profiles/profile-7-link/bin: /home/eelco/.local/state/nix/profiles/profile-7-link/bin:
total 20 total 20
lrwxrwxrwx 5 root root 79 Jan 1 1970 chromium -> /nix/store/cyxny9d1zjb9l9103fr6j6kavp3bqjxf-chromium-86.0.4240.111/bin/chromium lrwxrwxrwx 5 root root 79 Jan 1 1970 chromium -> /nix/store/ijm5k0zqisvkdwjkc77mb9qzb35xfi4m-chromium-86.0.4240.111/bin/chromium
lrwxrwxrwx 7 root root 87 Jan 1 1970 spotify -> /nix/store/w9182874m1bl56smps3m5zjj36jhp3rn-spotify-1.1.26.501.gbe11e53b-15/bin/spotify lrwxrwxrwx 7 root root 87 Jan 1 1970 spotify -> /nix/store/w9182874m1bl56smps3m5zjj36jhp3rn-spotify-1.1.26.501.gbe11e53b-15/bin/spotify
lrwxrwxrwx 3 root root 79 Jan 1 1970 zoom-us -> /nix/store/wbhg2ga8f3h87s9h5k0slxk0m81m4cxl-zoom-us-5.3.469451.0927/bin/zoom-us lrwxrwxrwx 3 root root 79 Jan 1 1970 zoom-us -> /nix/store/wbhg2ga8f3h87s9h5k0slxk0m81m4cxl-zoom-us-5.3.469451.0927/bin/zoom-us
/home/eelco/.local/state/nix/profiles/profile-7-link/share/applications: /home/eelco/.local/state/nix/profiles/profile-7-link/share/applications:
total 12 total 12
lrwxrwxrwx 4 root root 120 Jan 1 1970 chromium-browser.desktop -> /nix/store/sqzyx2l85i6j2a77pnyvglh3bvzwmjjp-chromium-unwrapped-86.0.4240.111/share/applications/chromium-browser.desktop lrwxrwxrwx 4 root root 120 Jan 1 1970 chromium-browser.desktop -> /nix/store/4cf803y4vzfm3gyk3vzhzb2327v0kl8a-chromium-unwrapped-86.0.4240.111/share/applications/chromium-browser.desktop
lrwxrwxrwx 7 root root 110 Jan 1 1970 spotify.desktop -> /nix/store/w9182874m1bl56smps3m5zjj36jhp3rn-spotify-1.1.26.501.gbe11e53b-15/share/applications/spotify.desktop lrwxrwxrwx 7 root root 110 Jan 1 1970 spotify.desktop -> /nix/store/w9182874m1bl56smps3m5zjj36jhp3rn-spotify-1.1.26.501.gbe11e53b-15/share/applications/spotify.desktop
lrwxrwxrwx 3 root root 107 Jan 1 1970 us.zoom.Zoom.desktop -> /nix/store/wbhg2ga8f3h87s9h5k0slxk0m81m4cxl-zoom-us-5.3.469451.0927/share/applications/us.zoom.Zoom.desktop lrwxrwxrwx 3 root root 107 Jan 1 1970 us.zoom.Zoom.desktop -> /nix/store/wbhg2ga8f3h87s9h5k0slxk0m81m4cxl-zoom-us-5.3.469451.0927/share/applications/us.zoom.Zoom.desktop
@@ -72,11 +72,11 @@ When using public key authentication, you can avoid typing the passphrase with `
> $ storePath="$(nix-build '<nixpkgs>' -I nixpkgs=channel:nixpkgs-unstable -A hello --no-out-link)" > $ storePath="$(nix-build '<nixpkgs>' -I nixpkgs=channel:nixpkgs-unstable -A hello --no-out-link)"
> $ nix-copy-closure --to alice@itchy.example.org "$storePath" > $ nix-copy-closure --to alice@itchy.example.org "$storePath"
> copying 5 paths... > copying 5 paths...
> copying path '/nix/store/h6q8sqsqfbd3252f9gixqn3z282wds7m-xgcc-13.2.0-libgcc' to 'ssh://alice@itchy.example.org'... > copying path '/nix/store/nrwkk6ak3rgkrxbqhsscb01jpzmslf2r-xgcc-13.2.0-libgcc' to 'ssh://alice@itchy.example.org'...
> copying path '/nix/store/imnwvn96lw355giswsk36hx105j4wnpj-libunistring-1.1' to 'ssh://alice@itchy.example.org'... > copying path '/nix/store/gm61h1y42pqyl6178g90x8zm22n6pyy5-libunistring-1.1' to 'ssh://alice@itchy.example.org'...
> copying path '/nix/store/85301indj7scg34spnfczkz72jgv8wa9-libidn2-2.3.7' to 'ssh://alice@itchy.example.org'... > copying path '/nix/store/ddfzjdykw67s20c35i7a6624by3iz5jv-libidn2-2.3.7' to 'ssh://alice@itchy.example.org'...
> copying path '/nix/store/ypwfsaljwhzw9iffiysxmxnhjj8v7np0-glibc-2.39-31' to 'ssh://alice@itchy.example.org'... > copying path '/nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31' to 'ssh://alice@itchy.example.org'...
> copying path '/nix/store/0dklv59zppdsqdvgf0qdvjgzcs5wbwxa-hello-2.12.1' to 'ssh://alice@itchy.example.org'... > copying path '/nix/store/g1n2vryg06amvcc1avb2mcq36faly0mh-hello-2.12.1' to 'ssh://alice@itchy.example.org'...
> ``` > ```
> **Example** > **Example**
@@ -204,7 +204,7 @@ To install a specific [store derivation] (typically created by
`nix-instantiate`): `nix-instantiate`):
```console ```console
$ nix-env --install /nix/store/8la6y31fmm6i4wfmby6avly1wf718xnj-gcc-3.4.3.drv $ nix-env --install /nix/store/fibjb1bfbpm5mrsxc4mh2d8n37sxh91i-gcc-3.4.3.drv
``` ```
To install a specific output path: To install a specific output path:
@@ -232,7 +232,7 @@ $ nix-env --file '<nixpkgs>' --install --attr hello --dry-run
(dry run; not doing anything) (dry run; not doing anything)
installing ‘hello-2.10’ installing ‘hello-2.10’
this path will be fetched (0.04 MiB download, 0.19 MiB unpacked): this path will be fetched (0.04 MiB download, 0.19 MiB unpacked):
/nix/store/ikwkxz4wwlp2g1428n7dy729cg1d9hin-hello-2.10 /nix/store/wkhdf9jinag5750mqlax6z2zbwhqb76n-hello-2.10
... ...
``` ```
@@ -76,7 +76,7 @@ $ nix-prefetch-url ftp://ftp.gnu.org/pub/gnu/hello/hello-2.10.tar.gz
```console ```console
$ nix-prefetch-url --print-path mirror://gnu/hello/hello-2.10.tar.gz $ nix-prefetch-url --print-path mirror://gnu/hello/hello-2.10.tar.gz
0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i 0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i
/nix/store/8alrpdaasjd1x6g1fczchmzbpqm936a3-hello-2.10.tar.gz /nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz
``` ```
```console ```console
@@ -34,6 +34,6 @@ This operation has the following options:
```console ```console
$ nix-store --add-fixed sha256 ./hello-2.10.tar.gz $ nix-store --add-fixed sha256 ./hello-2.10.tar.gz
/nix/store/8alrpdaasjd1x6g1fczchmzbpqm936a3-hello-2.10.tar.gz /nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz
``` ```
@@ -27,7 +27,7 @@ paths in the store that refer to it (i.e., depend on it).
# Example # Example
```console ```console
$ nix-store --delete /nix/store/gjak3al7lj61x4gj6rln4f5pc5v0f67n-mesa-6.4 $ nix-store --delete /nix/store/zq0h41l75vlb4z45kzgjjmsjxvcv1qk7-mesa-6.4
0 bytes freed (0.00 MiB) 0 bytes freed (0.00 MiB)
error: cannot delete path `/nix/store/gjak3al7lj61x4gj6rln4f5pc5v0f67n-mesa-6.4' since it is still alive error: cannot delete path `/nix/store/zq0h41l75vlb4z45kzgjjmsjxvcv1qk7-mesa-6.4' since it is still alive
``` ```
@@ -184,9 +184,9 @@ Print the build-time dependencies of `svn`:
```console ```console
$ nix-store --query --requisites $(nix-store --query --deriver $(which svn)) $ nix-store --query --requisites $(nix-store --query --deriver $(which svn))
/nix/store/y6qa66l9h0pw161crnlk6y16rdrcljx4-grep-2.5.1.tar.bz2.drv /nix/store/02iizgn86m42q905rddvg4ja975bk2i4-grep-2.5.1.tar.bz2.drv
/nix/store/z716h753s97jhnzvfank2srqbljswpgm-gcc-wrapper.sh /nix/store/07a2bzxmzwz5hp58nf03pahrv2ygwgs3-gcc-wrapper.sh
/nix/store/f39x0q73rjdyvzm93y9wrkfr6x39lb7f-glibc-2.3.4.drv /nix/store/0ma7c9wsbaxahwwl04gbw3fcd806ski4-glibc-2.3.4.drv
... lots of other paths ... ... lots of other paths ...
``` ```
@@ -199,10 +199,10 @@ Show the build-time dependencies as a tree:
```console ```console
$ nix-store --query --tree $(nix-store --query --deriver $(which svn)) $ nix-store --query --tree $(nix-store --query --deriver $(which svn))
/nix/store/7i5082kfb6yjbqdbiwdhhza0am2xvh6c-subversion-1.1.4.drv /nix/store/7i5082kfb6yjbqdbiwdhhza0am2xvh6c-subversion-1.1.4.drv
+---/nix/store/vxnmkc8l8d2ijjha4xwhkfgx9vvc3q4c-builder.sh +---/nix/store/d8afh10z72n8l1cr5w42366abiblgn54-builder.sh
+---/nix/store/rn9776dy82n5qrgz7xbcl1iw4vfkcrkk-bash-3.0.drv +---/nix/store/fmzxmpjx2lh849ph0l36snfj9zdibw67-bash-3.0.drv
| +---/nix/store/x9j20hz6bln1crzn55qifk0bbsm8v5ac-bash | +---/nix/store/570hmhmx3v57605cqg9yfvvyh0nnb8k8-bash
| +---/nix/store/ajnn1mcm45wjvn0rlc22gvx2cwhjnazx-builder.sh | +---/nix/store/p3srsbd8dx44v2pg6nbnszab5mcwx03v-builder.sh
... ...
``` ```
@@ -76,7 +76,7 @@ This operation is typically used to build [store derivation]s produced by
```console ```console
$ nix-store --realise $(nix-instantiate ./test.nix) $ nix-store --realise $(nix-instantiate ./test.nix)
/nix/store/6gwmy5jcnwdlz6aqqhksz863f1l8xc2w-aterm-2.3.1 /nix/store/31axcgrlbfsxzmfff1gyj1bf62hvkby2-aterm-2.3.1
``` ```
This is essentially what [`nix-build`](@docroot@/command-ref/nix-build.md) does. This is essentially what [`nix-build`](@docroot@/command-ref/nix-build.md) does.
@@ -3,10 +3,6 @@
This section provides some notes on how to start hacking on Nix. This section provides some notes on how to start hacking on Nix.
To get the latest version of Nix from GitHub: To get the latest version of Nix from GitHub:
> **Note**
>
> When checking out the repo on Windows, make sure you have the git setting `core.symlinks` enabled, before cloning, as there are symlinks in the repo.
```console ```console
$ git clone https://github.com/NixOS/nix.git $ git clone https://github.com/NixOS/nix.git
$ cd nix $ cd nix
+8 -1
View File
@@ -6,7 +6,14 @@ Additionally, see [Testing Nix](./testing.md) for further instructions on how to
## Building Nix with Debug Symbols ## Building Nix with Debug Symbols
In the development shell, `mesonBuildType` is set automatically to `debugoptimized`. This builds Nix with debug symbols, which are essential for effective debugging. In the development shell, set the `mesonBuildType` environment variable to `debug` before configuring the build:
```console
[nix-shell]$ export mesonBuildType=debugoptimized
```
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.
It is also possible to build without optimization for faster build: It is also possible to build without optimization for faster build:
+1 -1
View File
@@ -136,7 +136,7 @@
> **Example** > **Example**
> >
> `/nix/store/jf6gn2dzna4nmsfbdxsd7kwhsk6gnnlr-git-2.38.1` > `/nix/store/a040m110amc4h71lds2jmr8qrkj2jhxd-git-2.38.1`
See [Store Path](@docroot@/store/store-path.md) for details. See [Store Path](@docroot@/store/store-path.md) for details.
+1 -1
View File
@@ -8,7 +8,7 @@ stores packages in the _Nix store_, usually the directory
`/nix/store`, where each package has its own unique subdirectory such `/nix/store`, where each package has its own unique subdirectory such
as as
/nix/store/q06x3jll2yfzckz2bzqak089p43ixkkq-firefox-33.1/ /nix/store/b6gvzjyb2pg0kjfwrjmg1vfhh54ad73z-firefox-33.1/
where `b6gvzjyb2pg0…` is a unique identifier for the package that where `b6gvzjyb2pg0…` is a unique identifier for the package that
captures all its dependencies (it’s a cryptographic hash of the captures all its dependencies (it’s a cryptographic hash of the
+2 -2
View File
@@ -34,12 +34,12 @@ String context elements come in different forms:
> [`builtins.storePath`] creates a string with a single constant string context element: > [`builtins.storePath`] creates a string with a single constant string context element:
> >
> ```nix > ```nix
> builtins.getContext (builtins.storePath "/nix/store/ikwkxz4wwlp2g1428n7dy729cg1d9hin-hello-2.10") > builtins.getContext (builtins.storePath "/nix/store/wkhdf9jinag5750mqlax6z2zbwhqb76n-hello-2.10")
> ``` > ```
> evaluates to > evaluates to
> ```nix > ```nix
> { > {
> "/nix/store/ikwkxz4wwlp2g1428n7dy729cg1d9hin-hello-2.10" = { > "/nix/store/wkhdf9jinag5750mqlax6z2zbwhqb76n-hello-2.10" = {
> path = true; > path = true;
> }; > };
> } > }
@@ -181,7 +181,7 @@ A derivation interpolates to the [store path] of its first [output](./derivation
> "${pkgs.hello}" > "${pkgs.hello}"
> ``` > ```
> >
> "/nix/store/qnlr7906z0mrl2syrkdbpicffq02nw07-hello-2.12.1" > "/nix/store/4xpfqf29z4m8vbhrqcz064wfmb46w5r7-hello-2.12.1"
An attribute set interpolates to the return value of the function in the `__toString` applied to the attribute set itself. An attribute set interpolates to the return value of the function in the `__toString` applied to the attribute set itself.
+1 -23
View File
@@ -51,7 +51,6 @@ See [String literals](string-literals.md).
Path literals can also include [string interpolation], besides being [interpolated into other expressions]. Path literals can also include [string interpolation], besides being [interpolated into other expressions].
[string interpolation]: ./string-interpolation.md
[interpolated into other expressions]: ./string-interpolation.md#interpolated-expression [interpolated into other expressions]: ./string-interpolation.md#interpolated-expression
At least one slash (`/`) must appear *before* any interpolated expression for the result to be recognized as a path. At least one slash (`/`) must appear *before* any interpolated expression for the result to be recognized as a path.
@@ -273,7 +272,7 @@ will crash with an `infinite recursion encountered` error message.
A let-expression allows you to define local variables for an expression. A let-expression allows you to define local variables for an expression.
> *let-in* = `let` [ *identifier* = *expr* `;` ]... `in` *expr* > *let-in* = `let` [ *identifier* = *expr* ]... `in` *expr*
Example: Example:
@@ -286,27 +285,6 @@ in x + y
This evaluates to `"foobar"`. This evaluates to `"foobar"`.
There is also another, older, syntax for let expressions that should not be used in new code:
> *let* = `let` `{` *identifier* = *expr* `;` [ *identifier* = *expr* `;`]... `}`
In this form, the attribute set between the `{` `}` is recursive.
One of the attributes must have the special name `body`,
which is the result of the expression.
Example:
```nix
let {
foo = bar;
bar = "baz";
body = foo;
}
```
This evaluates to "baz".
## Inheriting attributes ## Inheriting attributes
When defining an [attribute set](./types.md#type-attrs) or in a [let-expression](#let-expressions) it is often convenient to copy variables from the surrounding lexical scope (e.g., when you want to propagate attributes). When defining an [attribute set](./types.md#type-attrs) or in a [let-expression](#let-expressions) it is often convenient to copy variables from the surrounding lexical scope (e.g., when you want to propagate attributes).
@@ -1,21 +1,27 @@
{{#include build-trace-entry-v2-fixed.md}} {{#include build-trace-entry-v1-fixed.md}}
## Examples ## Examples
### Simple build trace entry ### Simple build trace entry
```json ```json
{{#include schema/build-trace-entry-v2/simple.json}} {{#include schema/build-trace-entry-v1/simple.json}}
```
### Build trace entry with dependencies
```json
{{#include schema/build-trace-entry-v1/with-dependent-realisations.json}}
``` ```
### Build trace entry with signature ### Build trace entry with signature
```json ```json
{{#include schema/build-trace-entry-v2/with-signature.json}} {{#include schema/build-trace-entry-v1/with-signature.json}}
``` ```
<!-- <!--
## Raw Schema ## Raw Schema
[JSON Schema for Build Trace Entry v1](schema/build-trace-entry-v2.json) [JSON Schema for Build Trace Entry v1](schema/build-trace-entry-v1.json)
--> -->
+1 -1
View File
@@ -17,7 +17,7 @@ schemas = [
'derivation-v4', 'derivation-v4',
'derivation-options-v1', 'derivation-options-v1',
'deriving-path-v1', 'deriving-path-v1',
'build-trace-entry-v2', 'build-trace-entry-v1',
'build-result-v1', 'build-result-v1',
'store-v1', 'store-v1',
] ]
@@ -83,7 +83,7 @@ properties:
description: | description: |
A mapping from output names to their build trace entries. A mapping from output names to their build trace entries.
additionalProperties: additionalProperties:
"$ref": "build-trace-entry-v2.yaml" "$ref": "build-trace-entry-v1.yaml"
failure: failure:
type: object type: object
@@ -1,5 +1,5 @@
"$schema": "http://json-schema.org/draft-04/schema" "$schema": "http://json-schema.org/draft-04/schema"
"$id": "https://nix.dev/manual/nix/latest/protocols/json/schema/build-trace-entry-v2.json" "$id": "https://nix.dev/manual/nix/latest/protocols/json/schema/build-trace-entry-v1.json"
title: Build Trace Entry 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.
@@ -11,17 +11,10 @@ description: |
> 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.
Verision history:
- Version 1: Original format
- Version 2: Remove `dependentRealisations`
type: object
required: required:
- id - id
- outPath - outPath
- dependentRealisations
- signatures - signatures
allOf: allOf:
- "$ref": "#/$defs/key" - "$ref": "#/$defs/key"
@@ -29,11 +22,9 @@ allOf:
properties: properties:
id: {} id: {}
outPath: {} outPath: {}
dependentRealisations: {}
signatures: {} signatures: {}
additionalProperties: additionalProperties: false
dependentRealisations:
description: deprecated field
type: object
"$defs": "$defs":
key: key:
@@ -69,6 +60,7 @@ additionalProperties:
type: object type: object
required: required:
- outPath - outPath
- dependentRealisations
- signatures - signatures
properties: properties:
outPath: outPath:
@@ -77,6 +69,19 @@ additionalProperties:
description: | description: |
The path to the store object that resulted from building this derivation for the given output name. 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: patternProperties:
"^sha256:[0-9a-f]{64}![a-zA-Z_][a-zA-Z0-9_-]*$": "^sha256:[0-9a-f]{64}![a-zA-Z_][a-zA-Z0-9_-]*$":
"$ref": "store-path-v1.yaml" "$ref": "store-path-v1.yaml"
@@ -94,8 +94,8 @@ properties:
> >
> ```json > ```json
> "srcs": [ > "srcs": [
> "b8nwz167km1yciqpwzjj24f8jcy8pq1h-separate-debug-info.sh", > "47y241wqdhac3jm5l7nv0x4975mb1975-separate-debug-info.sh",
> "ihzmilr413r8fb3ah30yjnhlb18c1laz-fix-pop-var-context-error.patch" > "56d0w71pjj9bdr363ym3wj1zkwyqq97j-fix-pop-var-context-error.patch"
> ] > ]
> ``` > ```
items: items:
@@ -140,7 +140,7 @@ properties:
description: | description: |
Absolute path of the program used to perform the build. Absolute path of the program used to perform the build.
Typically this is the `bash` shell Typically this is the `bash` shell
(e.g. `/nix/store/p4xlj4imjbnm4v0x5jf4qysvyjjlgq1d-bash-4.4-p23/bin/bash`). (e.g. `/nix/store/r3j288vpmczbl500w6zz89gyfa4nr0b1-bash-4.4-p23/bin/bash`).
args: args:
type: array type: array
@@ -70,7 +70,7 @@ properties:
"^[A-Za-z0-9+/]{43}=$": "^[A-Za-z0-9+/]{43}=$":
type: object type: object
additionalProperties: additionalProperties:
"$ref": "./build-trace-entry-v2.yaml#/$defs/value" "$ref": "./build-trace-entry-v1.yaml#/$defs/value"
additionalProperties: false additionalProperties: false
"$defs": "$defs":
+1 -1
View File
@@ -80,7 +80,7 @@
... ...
the following paths will be downloaded/copied (30.02 MiB): the following paths will be downloaded/copied (30.02 MiB):
/nix/store/4m8pvgy2dcjgppf5b4cj5l6wyshjhalj-samba-3.2.4 /nix/store/4m8pvgy2dcjgppf5b4cj5l6wyshjhalj-samba-3.2.4
/nix/store/spc1m987vlibchdx369qwa391s738s7l-libunwind-0.98.6 /nix/store/7h1kwcj29ip8vk26rhmx6bfjraxp0g4l-libunwind-0.98.6
... ...
- Language features: - Language features:
+1 -1
View File
@@ -63,7 +63,7 @@ Nix 0.8 has the following improvements:
can query all paths that directly or indirectly use a certain Glibc: can query all paths that directly or indirectly use a certain Glibc:
$ nix-store -q --referrers-closure \ $ nix-store -q --referrers-closure \
/nix/store/1a6mdrjz4wn7b9sfmcw5ggbk1mi281mh-glibc-2.3.4 /nix/store/8lz9yc6zgmc0vlqmn2ipcpkjlmbi51vv-glibc-2.3.4
- The concept of fixed-output derivations has been formalised. - The concept of fixed-output derivations has been formalised.
Previously, functions such as `fetchurl` in Nixpkgs used a hack Previously, functions such as `fetchurl` in Nixpkgs used a hack
+2 -2
View File
@@ -66,7 +66,7 @@ This release has the following new features:
nix copy --to ssh://machine nixpkgs.hello nix copy --to ssh://machine nixpkgs.hello
nix copy --to ssh://machine /nix/store/qbhyj3blxpw2i6pb7c6grc9185nbnpvy-hello-2.10 nix copy --to ssh://machine /nix/store/0i2jd68mp5g6h2sa5k9c85rb80sn8hi9-hello-2.10
nix copy --to ssh://machine '(with import <nixpkgs> {}; hello)' nix copy --to ssh://machine '(with import <nixpkgs> {}; hello)'
@@ -187,7 +187,7 @@ This release has the following new features:
former is primarily useful in conjunction with remote stores, former is primarily useful in conjunction with remote stores,
e.g. e.g.
nix ls-store --store https://cache.nixos.org/ -lR /nix/store/qbhyj3blxpw2i6pb7c6grc9185nbnpvy-hello-2.10 nix ls-store --store https://cache.nixos.org/ -lR /nix/store/0i2jd68mp5g6h2sa5k9c85rb80sn8hi9-hello-2.10
lists the contents of path in a binary cache. lists the contents of path in a binary cache.
+1 -1
View File
@@ -25,7 +25,7 @@
* Allow explicitly selecting outputs in a store derivation installable, just like we can do with other sorts of installables. * Allow explicitly selecting outputs in a store derivation installable, just like we can do with other sorts of installables.
For example, For example,
```shell-session ```shell-session
# nix build /nix/store/fpq78s2h8ffh66v2iy0q1838mhff06y8-glibc-2.33-78.drv^dev # nix build /nix/store/gzaflydcr6sb3567hap9q6srzx8ggdgg-glibc-2.33-78.drv^dev
``` ```
now works just as now works just as
```shell-session ```shell-session
+2 -2
View File
@@ -18,13 +18,13 @@
For example, For example,
```shell-session ```shell-session
$ nix path-info /nix/store/fpq78s2h8ffh66v2iy0q1838mhff06y8-glibc-2.33-78.drv $ nix path-info /nix/store/gzaflydcr6sb3567hap9q6srzx8ggdgg-glibc-2.33-78.drv
``` ```
now gives info about the derivation itself, while now gives info about the derivation itself, while
```shell-session ```shell-session
$ nix path-info /nix/store/fpq78s2h8ffh66v2iy0q1838mhff06y8-glibc-2.33-78.drv^* $ nix path-info /nix/store/gzaflydcr6sb3567hap9q6srzx8ggdgg-glibc-2.33-78.drv^*
``` ```
provides information about each of its outputs. provides information about each of its outputs.
+2 -2
View File
@@ -45,7 +45,7 @@
```json5 ```json5
[ [
{ {
"path": "/nix/store/fvqsvk65d38p8qqir371ii0hyqxvjcw6-bash-5.2-p15", "path": "/nix/store/8fv91097mbh5049i9rglc73dx6kjg3qk-bash-5.2-p15",
"valid": true, "valid": true,
// ... // ...
}, },
@@ -60,7 +60,7 @@
```json5 ```json5
{ {
"/nix/store/fvqsvk65d38p8qqir371ii0hyqxvjcw6-bash-5.2-p15": { "/nix/store/8fv91097mbh5049i9rglc73dx6kjg3qk-bash-5.2-p15": {
// ... // ...
}, },
"/nix/store/wffw7l0alvs3iw94cbgi1gmmbmw99sqb-home-manager-path": null, "/nix/store/wffw7l0alvs3iw94cbgi1gmmbmw99sqb-home-manager-path": null,
+1 -1
View File
@@ -182,7 +182,7 @@
«partially applied primop map» «partially applied primop map»
nix-repl> builtins.trace lib.id "my-value" nix-repl> builtins.trace lib.id "my-value"
trace: «lambda id @ /nix/store/kgr5lnaiiv08wb7k324yv1i1npjmrvjc-source/lib/trivial.nix:26:5» trace: «lambda id @ /nix/store/8rrzq23h2zq7sv5l2vhw44kls5w0f654-source/lib/trivial.nix:26:5»
"my-value" "my-value"
``` ```
-281
View File
@@ -1,281 +0,0 @@
# Release 2.33.0 (2025-12-09)
## New features
- New command `nix registry resolve` [#14595](https://github.com/NixOS/nix/pull/14595)
This command looks up a flake registry input name and returns the flakeref it resolves to.
For example, looking up Nixpkgs:
```
$ nix registry resolve nixpkgs
github:NixOS/nixpkgs/nixpkgs-unstable
```
Upstreamed from [Determinate Nix 3.14.0](https://github.com/DeterminateSystems/nix-src/pull/273).
- `nix flake clone` supports all input types [#14581](https://github.com/NixOS/nix/pull/14581)
`nix flake clone` now supports arbitrary input types. In particular, this allows you to clone tarball flakes, such as flakes on FlakeHub.
Upstreamed from [Determinate Nix 3.12.0](https://github.com/DeterminateSystems/nix-src/pull/229).
## Performance improvements
- Git fetcher computes `revCount`s using multiple threads [#14462](https://github.com/NixOS/nix/pull/14462)
When using Git repositories with a long history, calculating the `revCount` attribute can take a long time. Nix now computes `revCount` using multiple threads, making it much faster (e.g. 9.1s to 3.7s for Nixpkgs).
Note that if you don't need `revCount`, you can disable it altogether by setting the flake input attribute `shallow = true`.
Upstreamed from [Determinate Nix 3.12.2](https://github.com/DeterminateSystems/nix-src/pull/245).
- `builtins.stringLength` now runs in constant time [#14442](https://github.com/NixOS/nix/pull/14442)
The internal representation of strings has been replaced with a size-prefixed Pascal style string. Previously Nix stored strings as a NUL-terminated array of bytes, necessitating a linear scan to calculate the length.
- Uploads to `http://` and `https://` binary cache stores now run in constant memory [#14390](https://github.com/NixOS/nix/pull/14390)
Nix used to buffer the whole compressed NAR contents in memory. It now reads it in a streaming fashion.
- Channel URLs migrated to channels.nixos.org subdomain [#14517](https://github.com/NixOS/nix/issues/14517) [#14518](https://github.com/NixOS/nix/pull/14518)
Channel URLs have been updated from `https://nixos.org/channels/` to `https://channels.nixos.org/` throughout Nix. This subdomain provides better reliability with IPv6 support and improved CDN distribution. The old domain apex (`nixos.org/channels/`) currently redirects to the new location but may be deprecated in the future.
- Fix `download buffer is full; consider increasing the 'download-buffer-size' setting` warning [#11728](https://github.com/NixOS/nix/issues/11728) [#14614](https://github.com/NixOS/nix/pull/14614)
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).
- Significantly improve tarball unpacking performance [#14689](https://github.com/NixOS/nix/pull/14689) [#14696](https://github.com/NixOS/nix/pull/14696) [#10683](https://github.com/NixOS/nix/issues/10683) [#11098](https://github.com/NixOS/nix/issues/11098)
Nix uses a content-addressed cache backed by libgit2 for deduplicating files fetched via `fetchTarball` and `github`, `tarball` flake inputs. Its usage has been significantly optimised to reduce the amount of I/O operations that are performed. For a typical nixpkgs source tarball this results in 200 times fewer system calls on Linux. In combination with libcurl pausing this alleviates performance regressions stemming from the tarball cache.
- Already valid derivations are no longer copied to the store [#14219](https://github.com/NixOS/nix/pull/14219)
This results in a modest speedup when using the Nix daemon.
- `nix nar ls` and `nix nar cat` are significantly faster and no longer buffer the whole NAR in memory [#14273](https://github.com/NixOS/nix/pull/14273) [#14732](https://github.com/NixOS/nix/pull/14732)
## S3 improvements
- Improved S3 binary cache support via HTTP [#11748](https://github.com/NixOS/nix/issues/11748) [#12403](https://github.com/NixOS/nix/issues/12403) [#12671](https://github.com/NixOS/nix/issues/12671) [#13084](https://github.com/NixOS/nix/issues/13084) [#13752](https://github.com/NixOS/nix/pull/13752) [#13823](https://github.com/NixOS/nix/pull/13823) [#14026](https://github.com/NixOS/nix/pull/14026) [#14120](https://github.com/NixOS/nix/pull/14120) [#14131](https://github.com/NixOS/nix/pull/14131) [#14135](https://github.com/NixOS/nix/pull/14135) [#14144](https://github.com/NixOS/nix/pull/14144) [#14170](https://github.com/NixOS/nix/pull/14170) [#14190](https://github.com/NixOS/nix/pull/14190) [#14198](https://github.com/NixOS/nix/pull/14198) [#14206](https://github.com/NixOS/nix/pull/14206) [#14209](https://github.com/NixOS/nix/pull/14209) [#14222](https://github.com/NixOS/nix/pull/14222) [#14223](https://github.com/NixOS/nix/pull/14223) [#14330](https://github.com/NixOS/nix/pull/14330) [#14333](https://github.com/NixOS/nix/pull/14333) [#14335](https://github.com/NixOS/nix/pull/14335) [#14336](https://github.com/NixOS/nix/pull/14336) [#14337](https://github.com/NixOS/nix/pull/14337) [#14350](https://github.com/NixOS/nix/pull/14350) [#14356](https://github.com/NixOS/nix/pull/14356) [#14357](https://github.com/NixOS/nix/pull/14357) [#14374](https://github.com/NixOS/nix/pull/14374) [#14375](https://github.com/NixOS/nix/pull/14375) [#14376](https://github.com/NixOS/nix/pull/14376) [#14377](https://github.com/NixOS/nix/pull/14377) [#14391](https://github.com/NixOS/nix/pull/14391) [#14393](https://github.com/NixOS/nix/pull/14393) [#14420](https://github.com/NixOS/nix/pull/14420) [#14421](https://github.com/NixOS/nix/pull/14421)
S3 binary cache operations now happen via HTTP, leveraging `libcurl`'s native AWS SigV4 authentication instead of the AWS C++ SDK, providing significant improvements:
- **Reduced memory usage**: Eliminates memory buffering issues that caused segfaults with large files
- **Fixed upload reliability**: Resolves AWS SDK chunking errors (`InvalidChunkSizeError`)
- **Lighter dependencies**: Uses lightweight `aws-crt-cpp` instead of full `aws-cpp-sdk`, reducing build complexity
The new implementation requires curl >= 7.75.0 and `aws-crt-cpp` for credential management.
All existing S3 URL formats and parameters remain supported, however the store settings for configuring multipart uploads have changed:
- **`multipart-upload`** (default: `false`): Enable multipart uploads for large files. When enabled, files exceeding the multipart threshold will be uploaded in multiple parts.
- **`multipart-threshold`** (default: `100 MiB`): Minimum file size for using multipart uploads. Files smaller than this will use regular PUT requests. Only takes effect when `multipart-upload` is enabled.
- **`multipart-chunk-size`** (default: `5 MiB`): Size of each part in multipart uploads. Must be at least 5 MiB (AWS S3 requirement). Larger chunk sizes reduce the number of requests but use more memory.
- **`buffer-size`**: Has been replaced by `multipart-chunk-size` and is now an alias to it.
Note that this change also means Nix now supports S3 binary cache stores even if built without `aws-crt-cpp`, but only for public buckets which do not require authentication.
- S3 URLs now support object versioning via `versionId` parameter [#13955](https://github.com/NixOS/nix/issues/13955) [#14274](https://github.com/NixOS/nix/pull/14274)
S3 URLs now support a `versionId` query parameter to fetch specific versions
of objects from S3 buckets with versioning enabled. This allows pinning to
exact object versions for reproducibility and protection against unexpected
changes:
```
s3://bucket/key?region=us-east-1&versionId=abc123def456
```
- S3 binary cache stores now support storage class configuration [#7015](https://github.com/NixOS/nix/issues/7015) [#14464](https://github.com/NixOS/nix/pull/14464)
S3 binary cache stores now support configuring the storage class for uploaded objects via the `storage-class` parameter. This allows users to optimize costs by selecting appropriate storage tiers based on access patterns.
Example usage:
```bash
# Use Glacier storage for long-term archival
nix copy --to 's3://my-bucket?storage-class=GLACIER' /nix/store/...
# Use Intelligent Tiering for automatic cost optimization
nix copy --to 's3://my-bucket?storage-class=INTELLIGENT_TIERING' /nix/store/...
```
The storage class applies to both regular uploads and multipart uploads. When not specified, objects use the bucket's default storage class.
See the [S3 storage classes documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-class-intro.html) for available storage classes and their characteristics.
## Store path info JSON format changes
The JSON format emitted by `nix path-info --json` has been updated to a new version with improved structure.
To maintain compatibility, `nix path-info --json` now requires a `--json-format` flag to specify the output format version.
Using `--json` without `--json-format` is deprecated and will become an error in a future release.
For now, it defaults to version 1 with a warning, for a smoother migration.
### Version 1 (`--json-format 1`)
This is the legacy format, preserved for backwards compatibility:
- String-based hash values (e.g., `"narHash": "sha256:FePFYIlM..."`)
- String-based content addresses (e.g., `"ca": "fixed:r:sha256:1abc..."`)
- Full store paths for map keys and references (e.g., `"/nix/store/abc...-foo"`)
- Now includes `"storeDir"` field at the top level
### Version 2 (`--json-format 2`)
The new structured format follows the [JSON guidelines](@docroot@/development/json-guideline.md) with the following changes:
- **Nested structure with top-level metadata**:
The output is now wrapped in an object with `version`, `storeDir`, and `info` fields:
```json
{
"version": 2,
"storeDir": "/nix/store",
"info": { ... }
}
```
The map from store path base names to store object info is nested under the `info` field.
- **Store path base names instead of full paths**:
Map keys and references use store path base names (e.g., `"abc...-foo"`) instead of full absolute store paths.
Combined with `storeDir`, the full path can be reconstructed.
- **Structured `ca` field**:
Content address is now a structured JSON object instead of a string:
- Old: `"ca": "fixed:r:sha256:1abc..."`
- New: `"ca": {"method": "nar", "hash": "sha256-ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0="}`
- Still `null` values for input-addressed store objects
The `hash` field uses the [SRI](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) format like other hashes.
Additionally the following fields are added to both formats:
- **`version` field**:
All store path info JSON now includes `"version": <1|2>`. The `version` tracks breaking changes, and adding fields to outputted JSON is not a breaking change.
- **`storeDir` field**:
Top-level `"storeDir"` field contains the store directory path (e.g., `"/nix/store"`).
## Derivation JSON format changes
The derivation JSON format has been updated from version 3 to version 4:
- **Nested structure with top-level metadata**:
The output of `nix derivation show` is now wrapped in an object with `version` and `derivations` fields:
```json
{
"version": 4,
"derivations": { ... }
}
```
The map from derivation paths to derivation info is nested under the `derivations` field.
This matches the structure used for `nix path-info --json --json-format 2`, and likewise brings this command into compliance with the JSON guidelines.
- **Restructured inputs**:
Inputs are now nested under an `inputs` object:
- Old: `"inputSrcs": [...], "inputDrvs": {...}`
- New: `"inputs": {"srcs": [...], "drvs": {...}}`
- **Consistent content addresses**:
Fixed content-addressed outputs now use structured JSON format.
This is the same format as `ca` in store path info (after the new version).
Version 3 and earlier formats are *not* accepted when reading.
**Affected command**: `nix derivation`, namely its `show` and `add` sub-commands.
## Miscellaneous changes
- Git fetcher: Restore progress indication [#14487](https://github.com/NixOS/nix/pull/14487)
Nix used to feel "stuck" while it was cloning large repositories. Nix now shows Git's native progress indicator while fetching.
Upstreamed from [Determinate Nix 3.13.0](https://github.com/DeterminateSystems/nix-src/pull/250).
- Interrupting REPL commands works more than once [#13481](https://github.com/NixOS/nix/issues/13481)
Previously, this only worked once per REPL session; further attempts would be ignored.
This issue is now fixed, so REPL commands such as `:b` or `:p` can be canceled consistently.
This is a cherry-pick of the change from the [Lix project](https://gerrit.lix.systems/c/lix/+/1097).
- NAR unpacking code has been rewritten to make use of dirfd-based `openat` and `openat2` system calls when available [#14597](https://github.com/NixOS/nix/pull/14597)
- Dynamic size unit rendering [#14423](https://github.com/NixOS/nix/pull/14423) [#14364](https://github.com/NixOS/nix/pull/14364)
Various commands and the progress bar now use dynamically determined size units instead
of always using `MiB`. For example, the progress bar now reports download status like:
```
[1/196/197 copied (773.7 MiB/2.1 GiB), 172.4/421.5 MiB DL]
```
Instead of:
```
[1/196/197 copied (773.7/2147.3 MiB), 172.4/421.5 MiB DL]
```
## Contributors
This release was made possible by the following 33 contributors:
- Adam Dinwoodie [**(@me-and)**](https://github.com/me-and)
- jonhermansen [**(@jonhermansen)**](https://github.com/jonhermansen)
- Arnout Engelen [**(@raboof)**](https://github.com/raboof)
- Jean-François Roche [**(@jfroche)**](https://github.com/jfroche)
- tomberek [**(@tomberek)**](https://github.com/tomberek)
- Eelco Dolstra [**(@edolstra)**](https://github.com/edolstra)
- Marcel [**(@MarcelCoding)**](https://github.com/MarcelCoding)
- David McFarland [**(@corngood)**](https://github.com/corngood)
- Soumyadip Sarkar [**(@neuralsorcerer)**](https://github.com/neuralsorcerer)
- Cole Helbling [**(@cole-h)**](https://github.com/cole-h)
- John Ericson [**(@Ericson2314)**](https://github.com/Ericson2314)
- Tristan Ross [**(@RossComputerGuy)**](https://github.com/RossComputerGuy)
- Alex Auvolat [**(@Alexis211)**](https://github.com/Alexis211)
- edef [**(@edef1c)**](https://github.com/edef1c)
- Sergei Zimmerman [**(@xokdvium)**](https://github.com/xokdvium)
- Vinayak Goyal [**(@vinayakankugoyal)**](https://github.com/vinayakankugoyal)
- Graham Dennis [**(@GrahamDennis)**](https://github.com/GrahamDennis)
- Aspen Smith [**(@glittershark)**](https://github.com/glittershark)
- Jens Petersen [**(@juhp)**](https://github.com/juhp)
- Bernardo Meurer [**(@lovesegfault)**](https://github.com/lovesegfault)
- Peter Bynum [**(@pkpbynum)**](https://github.com/pkpbynum)
- Jörg Thalheim [**(@Mic92)**](https://github.com/Mic92)
- Alex Decious [**(@adeci)**](https://github.com/adeci)
- Matthieu Coudron [**(@teto)**](https://github.com/teto)
- Domen Kožar [**(@domenkozar)**](https://github.com/domenkozar)
- Taeer Bar-Yam [**(@Radvendii)**](https://github.com/Radvendii)
- Seth Flynn [**(@getchoo)**](https://github.com/getchoo)
- Robert Hensing [**(@roberth)**](https://github.com/roberth)
- Vladimir Panteleev [**(@CyberShadow)**](https://github.com/CyberShadow)
- bryango [**(@bryango)**](https://github.com/bryango)
- Henry [**(@cootshk)**](https://github.com/cootshk)
- Martin Joerg [**(@mjoerg)**](https://github.com/mjoerg)
- Farid Zakaria [**(@fzakaria)**](https://github.com/fzakaria)
+3 -3
View File
@@ -2,7 +2,7 @@
> **Example** > **Example**
> >
> `/nix/store/jf6gn2dzna4nmsfbdxsd7kwhsk6gnnlr-git-2.38.1` > `/nix/store/a040m110amc4h71lds2jmr8qrkj2jhxd-git-2.38.1`
> >
> A rendered store path > A rendered store path
@@ -22,7 +22,7 @@ Store paths are pairs of
> **Example** > **Example**
> >
> - Digest: `q06x3jll2yfzckz2bzqak089p43ixkkq` > - Digest: `b6gvzjyb2pg0kjfwrjmg1vfhh54ad73z`
> - Name: `firefox-33.1` > - Name: `firefox-33.1`
To make store objects accessible to operating system processes, stores have to expose store objects through the file system. To make store objects accessible to operating system processes, stores have to expose store objects through the file system.
@@ -38,7 +38,7 @@ A store path is rendered to a file system path as the concatenation of
> **Example** > **Example**
> >
> ``` > ```
> /nix/store/q06x3jll2yfzckz2bzqak089p43ixkkq-firefox-33.1 > /nix/store/b6gvzjyb2pg0kjfwrjmg1vfhh54ad73z-firefox-33.1
> |--------| |------------------------------| |----------| > |--------| |------------------------------| |----------|
> store directory digest name > store directory digest name
> ``` > ```
+1 -1
View File
@@ -8,7 +8,7 @@ Stores are specified using a URL-like syntax. For example, the command
```console ```console
# nix path-info --store https://cache.nixos.org/ --json \ # nix path-info --store https://cache.nixos.org/ --json \
/nix/store/1542dip9i7k4f24y6hqgd04hmvid9hr5-coreutils-9.1 /nix/store/a7gvj343m05j2s32xcnwr35v31ynlypr-coreutils-9.1
``` ```
fetches information about a store path in the HTTP binary cache fetches information about a store path in the HTTP binary cache
Generated
+5 -5
View File
@@ -3,15 +3,15 @@
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1767039857, "lastModified": 1733328505,
"narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
"owner": "NixOS", "owner": "edolstra",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "edolstra",
"repo": "flake-compat", "repo": "flake-compat",
"type": "github" "type": "github"
} }
+5 -1
View File
@@ -6,7 +6,7 @@
inputs.nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2"; inputs.nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2";
inputs.nixpkgs-23-11.url = "github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446"; inputs.nixpkgs-23-11.url = "github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446";
inputs.flake-compat = { inputs.flake-compat = {
url = "github:NixOS/flake-compat"; url = "github:edolstra/flake-compat";
flake = false; flake = false;
}; };
@@ -418,6 +418,10 @@
supportsCross = false; supportsCross = false;
}; };
"nix-kaitai-struct-checks" = {
supportsCross = false;
};
"nix-perl-bindings" = { "nix-perl-bindings" = {
supportsCross = false; supportsCross = false;
}; };
@@ -224,25 +224,5 @@
"42688647+netadr@users.noreply.github.com": "netadr", "42688647+netadr@users.noreply.github.com": "netadr",
"matej.urbas@gmail.com": "urbas", "matej.urbas@gmail.com": "urbas",
"ethanalexevans@gmail.com": "ethanavatar", "ethanalexevans@gmail.com": "ethanavatar",
"greg.marti@gmail.com": "gmarti", "greg.marti@gmail.com": "gmarti"
"arnout@bzzt.net": "raboof",
"vinayakankugoyal@gmail.com": "vinayakankugoyal",
"Radvendii@users.noreply.github.com": "Radvendii",
"jon@jh86.org": "jonhermansen",
"edef@edef.eu": "edef1c",
"pkpbynum@gmail.com": "pkpbynum",
"886074+teto@users.noreply.github.com": "teto",
"alex@adnab.me": "Alexis211",
"root@gws.fyi": "glittershark",
"me@m4rc3l.de": "MarcelCoding",
"taeer.bar-yam@bevuta.com": "Radvendii",
"martin.joerg@gmail.com": "mjoerg",
"git@cy.md": "CyberShadow",
"cootshk@duck.com": "cootshk",
"adam@dinwoodie.org": "me-and",
"domen@cachix.org": "domenkozar",
"alex.decious@gmail.com": "adeci",
"soumya.papanvk18@gmail.com": "neuralsorcerer",
"gdennis@anduril.com": null,
"graham.dennis@gmail.com": "GrahamDennis"
} }
@@ -196,21 +196,5 @@
"gmarti": "Gr\u00e9gory Marti", "gmarti": "Gr\u00e9gory Marti",
"lovesegfault": "Bernardo Meurer", "lovesegfault": "Bernardo Meurer",
"EphraimSiegfried": "Ephraim Siegfried", "EphraimSiegfried": "Ephraim Siegfried",
"hgl": "Glen Huang", "hgl": "Glen Huang"
"mjoerg": "Martin Joerg",
"Alexis211": "Alex Auvolat",
"domenkozar": "Domen Ko\u017ear",
"edef1c": "edef",
"cootshk": "Henry",
"raboof": "Arnout Engelen",
"pkpbynum": "Peter Bynum",
"glittershark": "Aspen Smith",
"MarcelCoding": "Marcel",
"teto": "Matthieu Coudron",
"jonhermansen": null,
"neuralsorcerer": "Soumyadip Sarkar",
"adeci": "Alex Decious",
"vinayakankugoyal": "Vinayak Goyal",
"me-and": "Adam Dinwoodie",
"GrahamDennis": "Graham Dennis"
} }
-32
View File
@@ -1,32 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
set -x
git ls-files -z \
| xargs -0 grep -o '[0123456789abcdfghijklmnpqrsvwxyz]\{32\}' 2> /dev/null \
| rev \
| cut -d: -f1 \
| rev \
| sort \
| uniq \
| while read -r oldhash; do
if ! curl --fail -I "https://cache.nixos.org/$oldhash.narinfo" > /dev/null 2>&1; then
continue
fi
newhash=$(
nix eval --expr "builtins.toFile \"006c6ssvddri1sg34wnw65mzd05pcp3qliylxlhv49binldajba5\" \"$oldhash\"" \
| cut -d- -f1 \
| cut -d/ -f4
)
msg=$(printf "bad: %s -> %s" "$oldhash" "$newhash")
echo "$msg"
git ls-files -z \
| xargs -0 grep -a -l "$oldhash" 2> /dev/null \
| while read -r file; do
[ -L "$file" ] && continue
perl -pi -e "s/$oldhash/$newhash/g" "$file" || true
done || true
git commit -am "$msg"
done
@@ -1,110 +0,0 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGPtMiwBEAC0sFZW2QW/OaDjKm5zGRpDvHXDsMIUtlHfoi5ce8pocC63W05o
FSXbUZjZ1VfYO8lT8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5FWNNndqGArEaeZ8Shzdo/Uyi
b9lOsBIL6xc2ZcnX5f+rTu02LCEtEb0FwCycZLEWYf8hG4k8uttIOZOC+CLk/k8d
kBmPikMwUVTTV0CdT1cemQKdTaoAaK+kurF6FYXwcnjhRlHrisSt/tVMEwTw4LUM
3MYf6qfjjvE4HlDwZal8th7ccoQp/flfJIuRv85xCcKK+PI=
=u5cX
-----END PGP PUBLIC KEY BLOCK-----
-13
View File
@@ -1,13 +0,0 @@
# Maintainer GPG Keys
Release tags are signed by members of the [Nix maintainer team](https://nixos.org/community/teams/nix/) as part of the [release process](../release-process.md). This directory contains the public GPG keys used for signing.
## Keys
- **Eelco Dolstra**
GPG Fingerprint: `B541 D553 0127 0E0B CF15 CA5D 8170 B472 6D71 98DE`
- **Sergei Zimmerman**
GPG Fingerprint: [`158A 6F53 0EA2 02E5 F651 6113 14FA EA63 448E 1DF9`](https://keys.openpgp.org/vks/v1/by-fingerprint/158A6F530EA202E5F651611314FAEA63448E1DF9)
<!-- TODO: Add keys for other Nix team members -->
+11 -9
View File
@@ -5,11 +5,11 @@
The release process is intended to create the following for each The release process is intended to create the following for each
release: release:
* A signed Git tag (public keys in `maintainers/keys/`) * A Git tag
* Binary tarballs in https://releases.nixos.org/?prefix=nix/ * Binary tarballs in https://releases.nixos.org/?prefix=nix/
* Docker images (arm64 and amd64 variants, uploaded to DockerHub and GHCR) * Docker images
* Closures in https://cache.nixos.org * Closures in https://cache.nixos.org
@@ -104,17 +104,21 @@ release:
evaluation ID (e.g. `1780832` in evaluation ID (e.g. `1780832` in
`https://hydra.nixos.org/eval/1780832`). `https://hydra.nixos.org/eval/1780832`).
* Tag the release: * Tag the release and upload the release artifacts to
[`releases.nixos.org`](https://releases.nixos.org/) and [Docker Hub](https://hub.docker.com/):
```console ```console
$ IS_LATEST=1 ./maintainers/upload-release.pl --skip-docker --skip-s3 --project-root $PWD <EVAL-ID> $ IS_LATEST=1 ./maintainers/upload-release.pl <EVAL-ID>
``` ```
Note: `IS_LATEST=1` causes the `latest-release` branch to be Note: `IS_LATEST=1` causes the `latest-release` branch to be
force-updated. This is used by the `nixos.org` website to get the force-updated. This is used by the `nixos.org` website to get the
[latest Nix manual](https://nixos.org/manual/nixpkgs/unstable/). [latest Nix manual](https://nixos.org/manual/nixpkgs/unstable/).
* Trigger the [`upload-release.yml` workflow](https://github.com/NixOS/nix/actions/workflows/upload-release.yml) via `workflow_dispatch` trigger. At the top click `Run workflow` -> select the current release branch from `Use workflow from` -> fill in `Hydra evaluation ID` with `<EVAL-ID>` value from previous steps -> click `Run workflow`. Wait for the run to be approved by `NixOS/nix-team` (or bypass checks if warranted). Wait for the workflow to succeed. TODO: This script requires the right AWS credentials. Document.
TODO: This script currently requires a
`/home/eelco/Dev/nix-pristine`.
TODO: trigger nixos.org netlify: https://docs.netlify.com/configure-builds/build-hooks/ TODO: trigger nixos.org netlify: https://docs.netlify.com/configure-builds/build-hooks/
@@ -177,18 +181,16 @@ release:
* Wait for the desired evaluation of the maintenance jobset to finish * Wait for the desired evaluation of the maintenance jobset to finish
building. building.
* Tag the release * Run
```console ```console
$ IS_LATEST=1 ./maintainers/upload-release.pl --skip-docker --skip-s3 --project-root $PWD <EVAL-ID> $ IS_LATEST=1 ./maintainers/upload-release.pl <EVAL-ID>
``` ```
Omit `IS_LATEST=1` when creating a point release that is not on the Omit `IS_LATEST=1` when creating a point release that is not on the
most recent stable branch. This prevents `nixos.org` to going back most recent stable branch. This prevents `nixos.org` to going back
to an older release. to an older release.
* Trigger the [`upload-release.yml` workflow](https://github.com/NixOS/nix/actions/workflows/upload-release.yml) via `workflow_dispatch` trigger. At the top click `Run workflow` -> select the current release branch from `Use workflow from` -> fill in `Hydra evaluation ID` with `<EVAL-ID>` value from previous steps -> click `Run workflow`. Wait for the run to be approved by `NixOS/nix-team` (or bypass checks if warranted). Wait for the workflow to succeed.
* Bump the version number of the release branch as above (e.g. to * Bump the version number of the release branch as above (e.g. to
`2.12.2`). `2.12.2`).
+82 -128
View File
@@ -1,8 +1,7 @@
#! /usr/bin/env nix-shell #! /usr/bin/env nix-shell
#! nix-shell -i perl -p awscli2 perl perlPackages.LWPUserAgent perlPackages.LWPProtocolHttps perlPackages.FileSlurp perlPackages.NetAmazonS3 perlPackages.GetoptLongDescriptive gnupg1 #! nix-shell -i perl -p perl perlPackages.LWPUserAgent perlPackages.LWPProtocolHttps perlPackages.FileSlurp perlPackages.NetAmazonS3 gnupg1
use strict; use strict;
use Getopt::Long::Descriptive;
use Data::Dumper; use Data::Dumper;
use File::Basename; use File::Basename;
use File::Path; use File::Path;
@@ -14,30 +13,7 @@ use Net::Amazon::S3;
delete $ENV{'shell'}; # shut up a LWP::UserAgent.pm warning delete $ENV{'shell'}; # shut up a LWP::UserAgent.pm warning
my ($opt, $usage) = describe_options( my $evalId = $ARGV[0] or die "Usage: $0 EVAL-ID\n";
'%c %o <eval-id>',
[ 'skip-docker', 'Skip Docker image upload' ],
[ 'skip-git', 'Skip Git tagging' ],
[ 'skip-s3', 'Skip S3 upload' ],
[ 'docker-owner=s', 'Docker image owner', { default => 'nixos/nix' } ],
[ 'project-root=s', 'Pristine git repository path' ],
[ 's3-endpoint=s', 'Custom S3 endpoint' ],
[ 's3-host=s', 'S3 host', { default => 's3-eu-west-1.amazonaws.com' } ],
[],
[ 'help|h', 'Show this help message', { shortcircuit => 1 } ],
[],
[ 'Environment variables:' ],
[ 'AWS_ACCESS_KEY_ID' ],
[ 'AWS_SECRET_ACCESS_KEY' ],
[ 'AWS_SESSION_TOKEN For OIDC' ],
[ 'IS_LATEST Set to "1" to mark as latest release' ],
);
print($usage->text), exit if $opt->help;
my $evalId = $ARGV[0] or do { print STDERR $usage->text; exit 1 };
die "--project-root is required unless --skip-git is specified\n" unless $opt->skip_git || $opt->project_root;
my $releasesBucketName = "nix-releases"; my $releasesBucketName = "nix-releases";
my $channelsBucketName = "nix-channels"; my $channelsBucketName = "nix-channels";
@@ -86,38 +62,25 @@ File::Path::make_path($narCache);
my $binaryCache = "https://cache.nixos.org/?local-nar-cache=$narCache"; my $binaryCache = "https://cache.nixos.org/?local-nar-cache=$narCache";
# S3 setup. # S3 setup.
my $aws_access_key_id = $ENV{'AWS_ACCESS_KEY_ID'}; my $aws_access_key_id = $ENV{'AWS_ACCESS_KEY_ID'} or die "No AWS_ACCESS_KEY_ID given.";
my $aws_secret_access_key = $ENV{'AWS_SECRET_ACCESS_KEY'}; my $aws_secret_access_key = $ENV{'AWS_SECRET_ACCESS_KEY'} or die "No AWS_SECRET_ACCESS_KEY given.";
my $aws_session_token = $ENV{'AWS_SESSION_TOKEN'};
my ($s3, $releasesBucket, $s3_channels, $channelsBucket); my $s3 = Net::Amazon::S3->new(
{ aws_access_key_id => $aws_access_key_id,
aws_secret_access_key => $aws_secret_access_key,
retry => 1,
host => "s3-eu-west-1.amazonaws.com",
});
unless ($opt->skip_s3) { my $releasesBucket = $s3->bucket($releasesBucketName) or die;
$aws_access_key_id or die "No AWS_ACCESS_KEY_ID given.";
$aws_secret_access_key or die "No AWS_SECRET_ACCESS_KEY given.";
$s3 = Net::Amazon::S3->new( my $s3_us = Net::Amazon::S3->new(
{ aws_access_key_id => $aws_access_key_id, { aws_access_key_id => $aws_access_key_id,
aws_secret_access_key => $aws_secret_access_key, aws_secret_access_key => $aws_secret_access_key,
$aws_session_token ? (aws_session_token => $aws_session_token) : (), retry => 1,
retry => 1, });
host => $opt->s3_host,
secure => ($opt->s3_endpoint && $opt->s3_endpoint =~ /^http:/) ? 0 : 1,
});
$releasesBucket = $s3->bucket($releasesBucketName) or die; my $channelsBucket = $s3_us->bucket($channelsBucketName) or die;
$s3_channels = Net::Amazon::S3->new(
{ aws_access_key_id => $aws_access_key_id,
aws_secret_access_key => $aws_secret_access_key,
$aws_session_token ? (aws_session_token => $aws_session_token) : (),
retry => 1,
$opt->s3_endpoint ? (host => $opt->s3_host) : (),
$opt->s3_endpoint ? (secure => ($opt->s3_endpoint =~ /^http:/) ? 0 : 1) : (),
});
$channelsBucket = $s3_channels->bucket($channelsBucketName) or die;
}
sub getStorePath { sub getStorePath {
my ($jobName, $output) = @_; my ($jobName, $output) = @_;
@@ -152,12 +115,11 @@ sub copyManual {
File::Path::remove_tree("$tmpDir/manual.tmp", {safe => 1}); File::Path::remove_tree("$tmpDir/manual.tmp", {safe => 1});
} }
my $awsEndpoint = $opt->s3_endpoint ? "--endpoint-url " . $opt->s3_endpoint : ""; system("aws s3 sync '$tmpDir/manual' s3://$releasesBucketName/$releaseDir/manual") == 0
system("aws $awsEndpoint s3 sync '$tmpDir/manual' s3://$releasesBucketName/$releaseDir/manual") == 0
or die "syncing manual to S3\n"; or die "syncing manual to S3\n";
} }
copyManual unless $opt->skip_s3; copyManual;
sub downloadFile { sub downloadFile {
my ($jobName, $productNr, $dstName) = @_; my ($jobName, $productNr, $dstName) = @_;
@@ -196,12 +158,30 @@ sub downloadFile {
return $sha256_expected; return $sha256_expected;
} }
# Upload docker images. downloadFile("binaryTarball.i686-linux", "1");
downloadFile("binaryTarball.x86_64-linux", "1");
downloadFile("binaryTarball.aarch64-linux", "1");
downloadFile("binaryTarball.x86_64-darwin", "1");
downloadFile("binaryTarball.aarch64-darwin", "1");
eval {
downloadFile("binaryTarballCross.x86_64-linux.armv6l-unknown-linux-gnueabihf", "1");
};
warn "$@" if $@;
eval {
downloadFile("binaryTarballCross.x86_64-linux.armv7l-unknown-linux-gnueabihf", "1");
};
warn "$@" if $@;
eval {
downloadFile("binaryTarballCross.x86_64-linux.riscv64-unknown-linux-gnu", "1");
};
warn "$@" if $@;
downloadFile("installerScript", "1");
# Upload docker images to dockerhub.
my $dockerManifest = ""; my $dockerManifest = "";
my $dockerManifestLatest = ""; my $dockerManifestLatest = "";
my $haveDocker = 0; my $haveDocker = 0;
unless ($opt->skip_docker) {
for my $platforms (["x86_64-linux", "amd64"], ["aarch64-linux", "arm64"]) { for my $platforms (["x86_64-linux", "amd64"], ["aarch64-linux", "arm64"]) {
my $system = $platforms->[0]; my $system = $platforms->[0];
my $dockerPlatform = $platforms->[1]; my $dockerPlatform = $platforms->[1];
@@ -215,8 +195,8 @@ for my $platforms (["x86_64-linux", "amd64"], ["aarch64-linux", "arm64"]) {
print STDERR "loading docker image for $dockerPlatform...\n"; print STDERR "loading docker image for $dockerPlatform...\n";
system("docker load -i $tmpDir/$fn") == 0 or die; system("docker load -i $tmpDir/$fn") == 0 or die;
my $tag = $opt->docker_owner . ":$version-$dockerPlatform"; my $tag = "nixos/nix:$version-$dockerPlatform";
my $latestTag = $opt->docker_owner . ":latest-$dockerPlatform"; my $latestTag = "nixos/nix:latest-$dockerPlatform";
print STDERR "tagging $version docker image for $dockerPlatform...\n"; print STDERR "tagging $version docker image for $dockerPlatform...\n";
system("docker tag nix:$version $tag") == 0 or die; system("docker tag nix:$version $tag") == 0 or die;
@@ -239,94 +219,68 @@ for my $platforms (["x86_64-linux", "amd64"], ["aarch64-linux", "arm64"]) {
} }
if ($haveDocker) { if ($haveDocker) {
my $dockerOwner = $opt->docker_owner;
print STDERR "creating multi-platform docker manifest...\n"; print STDERR "creating multi-platform docker manifest...\n";
system("docker manifest rm $dockerOwner:$version"); system("docker manifest rm nixos/nix:$version");
system("docker manifest create $dockerOwner:$version $dockerManifest") == 0 or die; system("docker manifest create nixos/nix:$version $dockerManifest") == 0 or die;
if ($isLatest) { if ($isLatest) {
print STDERR "creating latest multi-platform docker manifest...\n"; print STDERR "creating latest multi-platform docker manifest...\n";
system("docker manifest rm $dockerOwner:latest"); system("docker manifest rm nixos/nix:latest");
system("docker manifest create $dockerOwner:latest $dockerManifestLatest") == 0 or die; system("docker manifest create nixos/nix:latest $dockerManifestLatest") == 0 or die;
} }
print STDERR "pushing multi-platform docker manifest...\n"; print STDERR "pushing multi-platform docker manifest...\n";
system("docker manifest push $dockerOwner:$version") == 0 or die; system("docker manifest push nixos/nix:$version") == 0 or die;
if ($isLatest) { if ($isLatest) {
print STDERR "pushing latest multi-platform docker manifest...\n"; print STDERR "pushing latest multi-platform docker manifest...\n";
system("docker manifest push $dockerOwner:latest") == 0 or die; system("docker manifest push nixos/nix:latest") == 0 or die;
} }
} }
}
# Upload nix-fallback-paths.nix.
write_file("$tmpDir/fallback-paths.nix",
"{\n" .
" x86_64-linux = \"" . getStorePath("build.nix-everything.x86_64-linux") . "\";\n" .
" i686-linux = \"" . getStorePath("build.nix-everything.i686-linux") . "\";\n" .
" aarch64-linux = \"" . getStorePath("build.nix-everything.aarch64-linux") . "\";\n" .
" riscv64-linux = \"" . getStorePath("buildCross.nix-everything.riscv64-unknown-linux-gnu.x86_64-linux") . "\";\n" .
" x86_64-darwin = \"" . getStorePath("build.nix-everything.x86_64-darwin") . "\";\n" .
" aarch64-darwin = \"" . getStorePath("build.nix-everything.aarch64-darwin") . "\";\n" .
"}\n");
# Upload release files to S3. # Upload release files to S3.
unless ($opt->skip_s3) { for my $fn (glob "$tmpDir/*") {
downloadFile("binaryTarball.i686-linux", "1"); my $name = basename($fn);
downloadFile("binaryTarball.x86_64-linux", "1"); next if $name eq "manual";
downloadFile("binaryTarball.aarch64-linux", "1"); my $dstKey = "$releaseDir/" . $name;
downloadFile("binaryTarball.x86_64-darwin", "1"); unless (defined $releasesBucket->head_key($dstKey)) {
downloadFile("binaryTarball.aarch64-darwin", "1"); print STDERR "uploading $fn to s3://$releasesBucketName/$dstKey...\n";
eval {
downloadFile("binaryTarballCross.x86_64-linux.armv6l-unknown-linux-gnueabihf", "1");
};
warn "$@" if $@;
eval {
downloadFile("binaryTarballCross.x86_64-linux.armv7l-unknown-linux-gnueabihf", "1");
};
warn "$@" if $@;
eval {
downloadFile("binaryTarballCross.x86_64-linux.riscv64-unknown-linux-gnu", "1");
};
warn "$@" if $@;
downloadFile("installerScript", "1");
# Upload nix-fallback-paths.nix. my $configuration = ();
write_file("$tmpDir/fallback-paths.nix", $configuration->{content_type} = "application/octet-stream";
"{\n" .
" x86_64-linux = \"" . getStorePath("build.nix-everything.x86_64-linux") . "\";\n" .
" i686-linux = \"" . getStorePath("build.nix-everything.i686-linux") . "\";\n" .
" aarch64-linux = \"" . getStorePath("build.nix-everything.aarch64-linux") . "\";\n" .
" riscv64-linux = \"" . getStorePath("buildCross.nix-everything.riscv64-unknown-linux-gnu.x86_64-linux") . "\";\n" .
" x86_64-darwin = \"" . getStorePath("build.nix-everything.x86_64-darwin") . "\";\n" .
" aarch64-darwin = \"" . getStorePath("build.nix-everything.aarch64-darwin") . "\";\n" .
"}\n");
for my $fn (glob "$tmpDir/*") { if ($fn =~ /.sha256|install|\.nix$/) {
my $name = basename($fn); $configuration->{content_type} = "text/plain";
next if $name eq "manual";
my $dstKey = "$releaseDir/" . $name;
unless (defined $releasesBucket->head_key($dstKey)) {
print STDERR "uploading $fn to s3://$releasesBucketName/$dstKey...\n";
my $configuration = ();
$configuration->{content_type} = "application/octet-stream";
if ($fn =~ /.sha256|install|\.nix$/) {
$configuration->{content_type} = "text/plain";
}
$releasesBucket->add_key_filename($dstKey, $fn, $configuration)
or die $releasesBucket->err . ": " . $releasesBucket->errstr;
} }
}
# Update the "latest" symlink. $releasesBucket->add_key_filename($dstKey, $fn, $configuration)
$channelsBucket->add_key( or die $releasesBucket->err . ": " . $releasesBucket->errstr;
"nix-latest/install", "", }
{ "x-amz-website-redirect-location" => "https://releases.nixos.org/$releaseDir/install" })
or die $channelsBucket->err . ": " . $channelsBucket->errstr
if $isLatest;
} }
# Update the "latest" symlink.
$channelsBucket->add_key(
"nix-latest/install", "",
{ "x-amz-website-redirect-location" => "https://releases.nixos.org/$releaseDir/install" })
or die $channelsBucket->err . ": " . $channelsBucket->errstr
if $isLatest;
# Tag the release in Git. # Tag the release in Git.
unless ($opt->skip_git) { chdir("/home/eelco/Dev/nix-pristine") or die;
chdir($opt->project_root) or die "Cannot chdir to " . $opt->project_root . ": $!"; system("git remote update origin") == 0 or die;
system("git remote update origin") == 0 or die; system("git tag --force --sign $version $nixRev -m 'Tagging release $version'") == 0 or die;
system("git tag --force --sign $version $nixRev -m 'Tagging release $version'") == 0 or die; system("git push --tags") == 0 or die;
system("git push origin refs/tags/$version") == 0 or die; system("git push --force-with-lease origin $nixRev:refs/heads/latest-release") == 0 or die if $isLatest;
system("git push --force-with-lease origin $nixRev:refs/heads/latest-release") == 0 or die if $isLatest;
}
File::Path::remove_tree($narCache, {safe => 1}); File::Path::remove_tree($narCache, {safe => 1});
File::Path::remove_tree($tmpDir, {safe => 1}); File::Path::remove_tree($tmpDir, {safe => 1});
+3
View File
@@ -63,3 +63,6 @@ subproject('nix-functional-tests')
if get_option('json-schema-checks') if get_option('json-schema-checks')
subproject('json-schema-checks') subproject('json-schema-checks')
endif endif
if get_option('kaitai-struct-checks')
subproject('kaitai-struct-checks')
endif
+7
View File
@@ -28,6 +28,13 @@ option(
description : 'Build benchmarks (requires gbenchmark)', description : 'Build benchmarks (requires gbenchmark)',
) )
option(
'kaitai-struct-checks',
type : 'boolean',
value : true,
description : 'Check the Kaitai Struct specifications (requires Kaitai Struct)',
)
option( option(
'json-schema-checks', 'json-schema-checks',
type : 'boolean', type : 'boolean',
+6 -1
View File
@@ -133,7 +133,7 @@ let
+ +
lib.optionalString lib.optionalString
( (
!(stdenv.hostPlatform.isWindows || stdenv.hostPlatform.isCygwin) !stdenv.hostPlatform.isWindows
# build failure # build failure
&& !stdenv.hostPlatform.isStatic && !stdenv.hostPlatform.isStatic
# LTO breaks exception handling on x86-64-darwin. # LTO breaks exception handling on x86-64-darwin.
@@ -452,6 +452,11 @@ in
*/ */
nix-json-schema-checks = callPackage ../src/json-schema-checks/package.nix { }; nix-json-schema-checks = callPackage ../src/json-schema-checks/package.nix { };
/**
Kaitai struct schema validation checks
*/
nix-kaitai-struct-checks = callPackage ../src/kaitai-struct-checks/package.nix { };
nix-perl-bindings = callPackage ../src/perl/package.nix { }; nix-perl-bindings = callPackage ../src/perl/package.nix { };
/** /**
-1
View File
@@ -40,7 +40,6 @@ scope: {
postInstall = postInstall =
lib.replaceStrings [ "lowdown.so.1" "lowdown.1.dylib" ] [ "lowdown.so.2" "lowdown.2.dylib" ] lib.replaceStrings [ "lowdown.so.1" "lowdown.1.dylib" ] [ "lowdown.so.2" "lowdown.2.dylib" ]
(prevAttrs.postInstall or ""); (prevAttrs.postInstall or "");
patches = [ ];
}); });
# TODO: Remove this when https://github.com/NixOS/nixpkgs/pull/442682 is included in a stable release # TODO: Remove this when https://github.com/NixOS/nixpkgs/pull/442682 is included in a stable release
+40 -57
View File
@@ -142,23 +142,12 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
internalDrvs = byDrvPath ( internalDrvs = byDrvPath (
# Drop the attr names (not present in buildInputs anyway) # Drop the attr names (not present in buildInputs anyway)
lib.attrValues availableComponents lib.attrValues availableComponents
++ lib.concatMap (c: lib.filter (v: !v.meta.broken) (lib.attrValues (c.tests or { }))) ( ++ lib.concatMap (c: lib.attrValues c.tests or { }) (lib.attrValues availableComponents)
lib.attrValues availableComponents
)
); );
isInternal = isInternal =
dep: internalDrvs ? ${builtins.unsafeDiscardStringContext dep.drvPath or "_non-existent_"}; dep: internalDrvs ? ${builtins.unsafeDiscardStringContext dep.drvPath or "_non-existent_"};
activeComponentNames = lib.listToAttrs (
map (c: {
name = c.pname or c.name;
value = null;
}) activeComponents
);
isActiveComponent = name: activeComponentNames ? ${name};
in in
{ {
pname = "shell-for-nix"; pname = "shell-for-nix";
@@ -201,19 +190,27 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
} }
); );
small = finalAttrs.finalPackage.withActiveComponents ( small =
c: (finalAttrs.finalPackage.withActiveComponents (
lib.intersectAttrs (lib.genAttrs [ 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"
"nix-perl-bindings" "nix-functional-tests"
] (_: null)) c "nix-perl-bindings"
); ] (_: null)) c
)).overrideAttrs
(o: {
mesonFlags = o.mesonFlags ++ [
# TODO: infer from activeComponents or vice versa
"-Dkaitai-struct-checks=false"
"-Djson-schema-checks=false"
];
});
}; };
# Remove the version suffix to avoid unnecessary attempts to substitute in nix develop # Remove the version suffix to avoid unnecessary attempts to substitute in nix develop
@@ -261,13 +258,10 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
# We use this shell with the local checkout, not unpackPhase. # We use this shell with the local checkout, not unpackPhase.
src = null; src = null;
# Workaround https://sourceware.org/pipermail/gdb-patches/2025-October/221398.html # Workaround https://sourceware.org/pipermail/gdb-patches/2025-October/221398.html
# Remove when gdb fix is rolled out everywhere. # Remove when gdb fix is rolled out everywhere.
separateDebugInfo = false; separateDebugInfo = false;
mesonBuildType = "debugoptimized";
env = { env = {
# For `make format`, to work without installing pre-commit # For `make format`, to work without installing pre-commit
_NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml" _NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml"
@@ -281,32 +275,21 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
dontUseCmakeConfigure = true; dontUseCmakeConfigure = true;
mesonFlags = [ mesonFlags =
(lib.mesonBool "json-schema-checks" (isActiveComponent "nix-json-schema-checks")) map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents2.nix-util.mesonFlags)
] ++ map (transformFlag "libstore") (ignoreCrossFile pkgs.nixComponents2.nix-store.mesonFlags)
++ map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents2.nix-util.mesonFlags) ++ map (transformFlag "libfetchers") (ignoreCrossFile pkgs.nixComponents2.nix-fetchers.mesonFlags)
++ map (transformFlag "libstore") (ignoreCrossFile pkgs.nixComponents2.nix-store.mesonFlags) ++ lib.optionals havePerl (
++ map (transformFlag "libfetchers") (ignoreCrossFile pkgs.nixComponents2.nix-fetchers.mesonFlags) map (transformFlag "perl") (ignoreCrossFile pkgs.nixComponents2.nix-perl-bindings.mesonFlags)
++ lib.optionals havePerl ( )
map (transformFlag "perl") (ignoreCrossFile pkgs.nixComponents2.nix-perl-bindings.mesonFlags) ++ map (transformFlag "libexpr") (ignoreCrossFile pkgs.nixComponents2.nix-expr.mesonFlags)
) ++ map (transformFlag "libcmd") (ignoreCrossFile pkgs.nixComponents2.nix-cmd.mesonFlags);
++ map (transformFlag "libexpr") (ignoreCrossFile pkgs.nixComponents2.nix-expr.mesonFlags)
++ map (transformFlag "libcmd") (ignoreCrossFile pkgs.nixComponents2.nix-cmd.mesonFlags);
nativeBuildInputs = nativeBuildInputs =
let let
inputs = inputs =
dedupByString (v: "${v}") ( dedupByString (v: "${v}") (
lib.filter (x: !isInternal x) ( lib.filter (x: !isInternal x) (lib.lists.concatMap (c: c.nativeBuildInputs) activeComponents)
lib.lists.concatMap (
# Nix manual has a build-time dependency on nix, but we
# don't want to do a native build just to enter the ross
# dev shell.
#
# TODO: think of a more principled fix for this.
c: lib.filter (f: f.pname or null != "nix") c.nativeBuildInputs
) activeComponents
)
) )
++ lib.optional ( ++ lib.optional (
!buildCanExecuteHost !buildCanExecuteHost
@@ -322,8 +305,8 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
pkgs.buildPackages.nixfmt-rfc-style pkgs.buildPackages.nixfmt-rfc-style
pkgs.buildPackages.shellcheck pkgs.buildPackages.shellcheck
pkgs.buildPackages.include-what-you-use pkgs.buildPackages.include-what-you-use
pkgs.buildPackages.gdb
] ]
++ lib.optional pkgs.hostPlatform.isUnix pkgs.buildPackages.gdb
++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) ( ++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) (
lib.hiPrio pkgs.buildPackages.clang-tools lib.hiPrio pkgs.buildPackages.clang-tools
) )
@@ -339,13 +322,13 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
) )
); );
buildInputs = buildInputs = [
# TODO change Nixpkgs to mark gbenchmark as building on Windows pkgs.gbenchmark
lib.optional pkgs.hostPlatform.isUnix pkgs.gbenchmark ]
++ dedupByString (v: "${v}") ( ++ dedupByString (v: "${v}") (
lib.filter (x: !isInternal x) (lib.lists.concatMap (c: c.buildInputs) activeComponents) lib.filter (x: !isInternal x) (lib.lists.concatMap (c: c.buildInputs) activeComponents)
) )
++ lib.optional havePerl pkgs.perl; ++ lib.optional havePerl pkgs.perl;
propagatedBuildInputs = dedupByString (v: "${v}") ( propagatedBuildInputs = dedupByString (v: "${v}") (
lib.filter (x: !isInternal x) (lib.lists.concatMap (c: c.propagatedBuildInputs) activeComponents) lib.filter (x: !isInternal x) (lib.lists.concatMap (c: c.propagatedBuildInputs) activeComponents)
+1
View File
@@ -72,6 +72,7 @@ let
"nix-manual-manpages-only" "nix-manual-manpages-only"
"nix-internal-api-docs" "nix-internal-api-docs"
"nix-external-api-docs" "nix-external-api-docs"
"nix-kaitai-struct-checks"
] ]
); );
in in
+2 -2
View File
@@ -53,8 +53,8 @@ readonly PROFILE_NIX_FILE_FISH="$NIX_ROOT/var/nix/profiles/default/etc/profile.d
readonly NIX_INSTALLED_NIX="@nix@" readonly NIX_INSTALLED_NIX="@nix@"
readonly NIX_INSTALLED_CACERT="@cacert@" readonly NIX_INSTALLED_CACERT="@cacert@"
#readonly NIX_INSTALLED_NIX="/nix/store/byi37zv50wnfrpp4d81z3spswd5zva37-nix-2.3.6" #readonly NIX_INSTALLED_NIX="/nix/store/j8dbv5w6jl34caywh2ygdy88knx1mdf7-nix-2.3.6"
#readonly NIX_INSTALLED_CACERT="/nix/store/7pi45g541xa8ahwgpbpy7ggsl0xj1jj6-nss-cacert-3.49.2" #readonly NIX_INSTALLED_CACERT="/nix/store/7dxhzymvy330i28ii676fl1pqwcahv2f-nss-cacert-3.49.2"
EXTRACTED_NIX_PATH="$(dirname "$0")" EXTRACTED_NIX_PATH="$(dirname "$0")"
readonly EXTRACTED_NIX_PATH readonly EXTRACTED_NIX_PATH
+1 -3
View File
@@ -62,11 +62,9 @@ schemas = [
}, },
{ {
'stem' : 'build-trace-entry', 'stem' : 'build-trace-entry',
'schema' : schema_dir / 'build-trace-entry-v2.yaml', 'schema' : schema_dir / 'build-trace-entry-v1.yaml',
'files' : [ 'files' : [
'simple.json', 'simple.json',
# The field is no longer supported, but we want to show that we
# ignore it during parsing.
'with-dependent-realisations.json', 'with-dependent-realisations.json',
'with-signature.json', 'with-signature.json',
], ],
+1
View File
@@ -0,0 +1 @@
../../.version
+77
View File
@@ -0,0 +1,77 @@
# Run with:
# meson test --suite kaitai-struct
# Run with: (without shell / configure)
# nix build .#nix-kaitai-struct-checks
project(
'nix-kaitai-struct-checks',
'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++23',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'errorlogs=true', # Please print logs for tests that fail
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
)
kaitai_runtime_dep = dependency('kaitai-struct-cpp-stl-runtime', required : true)
gtest_dep = dependency('gtest')
gtest_main_dep = dependency('gtest_main', required : true)
# Find the Kaitai Struct compiler
ksc = find_program('ksc', required : true)
kaitai_generated_srcs = custom_target(
'kaitai-generated-sources',
input : [ 'nar.ksy' ],
output : [ 'nix_nar.cpp', 'nix_nar.h' ],
command : [
ksc,
'@INPUT@',
'--target', 'cpp_stl',
'--outdir',
meson.current_build_dir(),
],
)
nar_kaitai_lib = library(
'nix-nar-kaitai-lib',
kaitai_generated_srcs,
dependencies : [ kaitai_runtime_dep ],
install : true,
)
nar_kaitai_dep = declare_dependency(
link_with : nar_kaitai_lib,
sources : kaitai_generated_srcs[1],
)
# The nar directory is a committed symlink to the actual nars location
nars_dir = meson.current_source_dir() / 'nars'
# Get all example files
nars = [
'dot.nar',
]
test_deps = [
nar_kaitai_dep,
kaitai_runtime_dep,
gtest_main_dep,
]
this_exe = executable(
meson.project_name(),
'test-parse-nar.cc',
dependencies : test_deps,
)
test(
meson.project_name(),
this_exe,
env : [ 'NIX_NARS_DIR=' + nars_dir ],
protocol : 'gtest',
)
+1
View File
@@ -0,0 +1 @@
../../doc/manual/source/protocols/nix-archive/nar.ksy
+1
View File
@@ -0,0 +1 @@
../libutil-tests/data/nars
+1
View File
@@ -0,0 +1 @@
../../nix-meson-build-support
+70
View File
@@ -0,0 +1,70 @@
# Run with: nix build .#nix-kaitai-struct-checks
# or: `nix develop .#nix-kaitai-struct-checks` to enter a dev shell
{
lib,
mkMesonDerivation,
gtest,
meson,
ninja,
pkg-config,
kaitai-struct-compiler,
fetchzip,
kaitai-struct-cpp-stl-runtime,
# Configuration Options
version,
}:
let
inherit (lib) fileset;
in
mkMesonDerivation (finalAttrs: {
pname = "nix-kaitai-struct-checks";
inherit version;
workDir = ./.;
fileset = lib.fileset.unions [
../../nix-meson-build-support
./nix-meson-build-support
./.version
../../.version
../../doc/manual/source/protocols/nix-archive/nar.ksy
./nars
../../src/libutil-tests/data
./meson.build
./nar.ksy
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];
outputs = [ "out" ];
buildInputs = [
gtest
kaitai-struct-cpp-stl-runtime
];
nativeBuildInputs = [
meson
ninja
pkg-config
# This can go away when we bump up to 25.11
(kaitai-struct-compiler.overrideAttrs (finalAttrs: {
version = "0.11";
src = fetchzip {
url = "https://github.com/kaitai-io/kaitai_struct_compiler/releases/download/${version}/kaitai-struct-compiler-${version}.zip";
sha256 = "sha256-j9TEilijqgIiD0GbJfGKkU1FLio9aTopIi1v8QT1b+A=";
};
}))
];
doCheck = true;
mesonCheckFlags = [ "--print-errorlogs" ];
postInstall = ''
touch $out
'';
meta = {
platforms = lib.platforms.unix;
};
})
@@ -0,0 +1,48 @@
#include <gtest/gtest.h>
#include <filesystem>
#include <fstream>
#include <vector>
#include <string>
#include <kaitai/kaitaistream.h>
#include <fstream>
#include <string>
#include <vector>
#include "nix_nar.h"
static const std::vector<std::string> NarFiles = {
"empty.nar",
"dot.nar",
"dotdot.nar",
"executable-after-contents.nar",
"invalid-tag-instead-of-contents.nar",
"name-after-node.nar",
"nul-character.nar",
"slash.nar",
};
class NarParseTest : public ::testing::TestWithParam<std::string>
{};
TEST_P(NarParseTest, ParseSucceeds)
{
const auto nar_file = GetParam();
const char * nars_dir_env = std::getenv("NIX_NARS_DIR");
if (nars_dir_env == nullptr) {
FAIL() << "NIX_NARS_DIR environment variable not set.";
}
const std::filesystem::path nar_file_path = std::filesystem::path(nars_dir_env) / "dot.nar";
ASSERT_TRUE(std::filesystem::exists(nar_file_path)) << "Missing test file: " << nar_file_path;
std::ifstream ifs(nar_file_path, std::ifstream::binary);
ASSERT_TRUE(ifs.is_open()) << "Failed to open file: " << nar_file;
kaitai::kstream ks(&ifs);
nix_nar_t nar(&ks);
ASSERT_TRUE(nar.root_node() != nullptr) << "Failed to parse NAR file: " << nar_file;
}
INSTANTIATE_TEST_SUITE_P(AllNarFiles, NarParseTest, ::testing::ValuesIn(NarFiles));
+4 -12
View File
@@ -116,11 +116,7 @@ MixFlakeOptions::MixFlakeOptions()
.labels = {"input-path"}, .labels = {"input-path"},
.handler = {[&](std::string s) { .handler = {[&](std::string s) {
warn("'--update-input' is a deprecated alias for 'flake update' and will be removed in a future version."); warn("'--update-input' is a deprecated alias for 'flake update' and will be removed in a future version.");
auto path = flake::NonEmptyInputAttrPath::parse(s); lockFlags.inputUpdates.insert(flake::parseInputAttrPath(s));
if (!path)
throw UsageError(
"--update-input was passed a zero-length input path, which would refer to the flake itself, not an input");
lockFlags.inputUpdates.insert(*path);
}}, }},
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) { .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
completeFlakeInputAttrPath(completions, getEvalState(), getFlakeRefsForCompletion(), prefix); completeFlakeInputAttrPath(completions, getEvalState(), getFlakeRefsForCompletion(), prefix);
@@ -129,18 +125,14 @@ MixFlakeOptions::MixFlakeOptions()
addFlag({ addFlag({
.longName = "override-input", .longName = "override-input",
.description = .description = "Override a specific flake input (e.g. `dwarffs/nixpkgs`). This implies `--no-write-lock-file`.",
"Override a specific flake input (e.g. `dwarffs/nixpkgs`). The input path must not be empty. This implies `--no-write-lock-file`.",
.category = category, .category = category,
.labels = {"input-path", "flake-url"}, .labels = {"input-path", "flake-url"},
.handler = {[&](std::string inputAttrPath, std::string flakeRef) { .handler = {[&](std::string inputAttrPath, std::string flakeRef) {
lockFlags.writeLockFile = false; lockFlags.writeLockFile = false;
auto path = flake::NonEmptyInputAttrPath::parse(inputAttrPath);
if (!path)
throw UsageError(
"--override-input was passed a zero-length input path, which would refer to the flake itself, not an input");
lockFlags.inputOverrides.insert_or_assign( lockFlags.inputOverrides.insert_or_assign(
std::move(*path), parseFlakeRef(fetchSettings, flakeRef, absPath(getCommandBaseDir()).string(), true)); flake::parseInputAttrPath(inputAttrPath),
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) {
-14
View File
@@ -1,14 +0,0 @@
#include <benchmark/benchmark.h>
#include "nix/expr/eval-gc.hh"
#include "nix/store/globals.hh"
int main(int argc, char ** argv)
{
nix::initLibStore(false);
nix::initGC();
::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
return 0;
}
-55
View File
@@ -1,55 +0,0 @@
#include <benchmark/benchmark.h>
#include "nix/expr/eval.hh"
#include "nix/expr/eval-settings.hh"
#include "nix/fetchers/fetch-settings.hh"
#include "nix/store/store-open.hh"
using namespace nix;
static std::string mkDynamicAttrsExpr(size_t attrCount)
{
std::string res;
res.reserve(attrCount * 24);
res += "{ ";
for (size_t i = 0; i < attrCount; ++i) {
res += "${\"a";
res += std::to_string(i);
res += "\"} = ";
res += std::to_string(i);
res += "; ";
}
res += "}";
return res;
}
static void BM_EvalDynamicAttrs(benchmark::State & state)
{
const auto attrCount = static_cast<size_t>(state.range(0));
const auto exprStr = mkDynamicAttrsExpr(attrCount);
for (auto _ : state) {
state.PauseTiming();
auto store = openStore("dummy://");
fetchers::Settings fetchSettings{};
bool readOnlyMode = true;
EvalSettings evalSettings{readOnlyMode};
evalSettings.nixPath = {};
EvalState st({}, store, fetchSettings, evalSettings, nullptr);
Expr * expr = st.parseExprFromString(exprStr, st.rootPath(CanonPath::root));
Value v;
state.ResumeTiming();
st.eval(expr, v);
st.forceValue(v, noPos);
benchmark::DoNotOptimize(v);
}
state.SetItemsProcessed(state.iterations() * attrCount);
}
BENCHMARK(BM_EvalDynamicAttrs)->Arg(100)->Arg(500)->Arg(2'000);
-64
View File
@@ -1,64 +0,0 @@
#include <benchmark/benchmark.h>
#include "nix/expr/get-drvs.hh"
#include "nix/expr/eval-settings.hh"
#include "nix/fetchers/fetch-settings.hh"
#include "nix/store/store-open.hh"
#include "nix/util/fmt.hh"
using namespace nix;
namespace {
struct GetDerivationsEnv
{
ref<Store> store = openStore("dummy://");
fetchers::Settings fetchSettings{};
bool readOnlyMode = true;
EvalSettings evalSettings{readOnlyMode};
EvalState state;
Bindings * autoArgs = nullptr;
Value attrsValue;
explicit GetDerivationsEnv(size_t attrCount)
: evalSettings([&]() {
EvalSettings settings{readOnlyMode};
settings.nixPath = {};
return settings;
}())
, state({}, store, fetchSettings, evalSettings, nullptr)
{
autoArgs = state.buildBindings(0).finish();
auto attrs = state.buildBindings(attrCount);
for (size_t i = 0; i < attrCount; ++i) {
auto name = fmt("pkg%|1$06d|", i);
auto sym = state.symbols.create(name);
auto & v = attrs.alloc(sym);
v.mkInt(i);
}
attrsValue.mkAttrs(attrs.finish());
}
};
} // namespace
static void BM_GetDerivationsAttrScan(benchmark::State & state)
{
const auto attrCount = static_cast<size_t>(state.range(0));
GetDerivationsEnv env(attrCount);
for (auto _ : state) {
PackageInfos drvs;
getDerivations(
env.state, env.attrsValue, /*pathPrefix=*/"", *env.autoArgs, drvs, /*ignoreAssertionFailures=*/true);
benchmark::DoNotOptimize(drvs.size());
}
state.SetItemsProcessed(state.iterations() * attrCount);
}
BENCHMARK(BM_GetDerivationsAttrScan)->Arg(1'000)->Arg(5'000)->Arg(10'000);
-30
View File
@@ -87,33 +87,3 @@ test(
}, },
protocol : 'gtest', protocol : 'gtest',
) )
# Build benchmarks if enabled
if get_option('benchmarks')
gbenchmark = dependency('benchmark', required : true)
benchmark_sources = files(
'bench-main.cc',
'dynamic-attrs-bench.cc',
'get-drvs-bench.cc',
'regex-cache-bench.cc',
)
benchmark_exe = executable(
'nix-expr-benchmarks',
benchmark_sources,
config_priv_h,
dependencies : deps_private_subproject + deps_private + deps_other + [
gbenchmark,
],
include_directories : include_dirs,
link_args : linker_export_flags,
install : true,
cpp_pch : do_pch ? [ 'pch/precompiled-headers.hh' ] : [],
)
benchmark(
'nix-expr-benchmarks',
benchmark_exe,
)
endif
-9
View File
@@ -1,9 +0,0 @@
# vim: filetype=meson
option(
'benchmarks',
type : 'boolean',
value : false,
description : 'Build benchmarks (requires gbenchmark)',
yield : true,
)
+1 -1
View File
@@ -33,7 +33,7 @@ mkMesonExecutable (finalAttrs: {
../../.version ../../.version
./.version ./.version
./meson.build ./meson.build
./meson.options # ./meson.options
(fileset.fileFilter (file: file.hasExt "cc") ./.) (fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.) (fileset.fileFilter (file: file.hasExt "hh") ./.)
]; ];
-45
View File
@@ -1,45 +0,0 @@
#include <benchmark/benchmark.h>
#include "nix/expr/eval.hh"
#include "nix/expr/eval-settings.hh"
#include "nix/fetchers/fetch-settings.hh"
#include "nix/store/store-open.hh"
using namespace nix;
static void BM_EvalManyBuiltinsMatchSameRegex(benchmark::State & state)
{
static constexpr int iterations = 5'000;
static constexpr std::string_view exprStr =
"builtins.foldl' "
"(acc: _: acc + builtins.length (builtins.match \"a\" \"a\")) "
"0 "
"(builtins.genList (x: x) "
"5000)";
for (auto _ : state) {
state.PauseTiming();
auto store = openStore("dummy://");
fetchers::Settings fetchSettings{};
bool readOnlyMode = true;
EvalSettings evalSettings{readOnlyMode};
evalSettings.nixPath = {};
EvalState st({}, store, fetchSettings, evalSettings, nullptr);
Expr * expr = st.parseExprFromString(std::string(exprStr), st.rootPath(CanonPath::root));
Value v;
state.ResumeTiming();
st.eval(expr, v);
st.forceValue(v, noPos);
benchmark::DoNotOptimize(v);
}
state.SetItemsProcessed(state.iterations() * iterations);
}
BENCHMARK(BM_EvalManyBuiltinsMatchSameRegex);
+9 -9
View File
@@ -1,6 +1,5 @@
#include "nix/expr/attr-path.hh" #include "nix/expr/attr-path.hh"
#include "nix/expr/eval-inline.hh" #include "nix/expr/eval-inline.hh"
#include "nix/util/util.hh"
#include "nix/util/strings-inline.hh" #include "nix/util/strings-inline.hh"
namespace nix { namespace nix {
@@ -138,15 +137,16 @@ std::pair<SourcePath, uint32_t> findPackageFilename(EvalState & state, Value & v
auto fail = [fn]() { throw ParseError("cannot parse 'meta.position' attribute '%s'", fn); }; auto fail = [fn]() { throw ParseError("cannot parse 'meta.position' attribute '%s'", fn); };
auto colon = fn.rfind(':'); try {
if (colon == std::string::npos) auto colon = fn.rfind(':');
if (colon == std::string::npos)
fail();
auto lineno = std::stoi(std::string(fn, colon + 1, std::string::npos));
return {SourcePath{path.accessor, CanonPath(fn.substr(0, colon))}, lineno};
} catch (std::invalid_argument & e) {
fail(); fail();
unreachable();
auto lineno = string2Int<uint32_t>(std::string_view(fn).substr(colon + 1)); }
if (!lineno)
fail();
return {SourcePath{path.accessor, CanonPath(fn.substr(0, colon))}, *lineno};
} }
} // namespace nix } // namespace nix
+1 -1
View File
@@ -265,7 +265,7 @@ struct AttrDb
case AttrType::String: { case AttrType::String: {
NixStringContext context; NixStringContext context;
if (!queryAttribute.isNull(3)) if (!queryAttribute.isNull(3))
for (auto & s : tokenizeString<std::vector<std::string>>(queryAttribute.getStr(3), " ")) for (auto & s : tokenizeString<std::vector<std::string>>(queryAttribute.getStr(3), ";"))
context.insert(NixStringContextElem::parse(s)); context.insert(NixStringContextElem::parse(s));
return {{rowId, string_t{queryAttribute.getStr(2), context}}}; return {{rowId, string_t{queryAttribute.getStr(2), context}}};
} }
-1
View File
@@ -111,7 +111,6 @@ template class EvalErrorBuilder<TypeError>;
template class EvalErrorBuilder<UndefinedVarError>; template class EvalErrorBuilder<UndefinedVarError>;
template class EvalErrorBuilder<MissingArgumentError>; template class EvalErrorBuilder<MissingArgumentError>;
template class EvalErrorBuilder<InfiniteRecursionError>; template class EvalErrorBuilder<InfiniteRecursionError>;
template class EvalErrorBuilder<StackOverflowError>;
template class EvalErrorBuilder<InvalidPathError>; template class EvalErrorBuilder<InvalidPathError>;
template class EvalErrorBuilder<IFDError>; template class EvalErrorBuilder<IFDError>;
-11
View File
@@ -741,11 +741,6 @@ public:
inDebugger = true; inDebugger = true;
} }
DebuggerGuard(DebuggerGuard &&) = delete;
DebuggerGuard(const DebuggerGuard &) = delete;
DebuggerGuard & operator=(DebuggerGuard &&) = delete;
DebuggerGuard & operator=(const DebuggerGuard &) = delete;
~DebuggerGuard() ~DebuggerGuard()
{ {
inDebugger = false; inDebugger = false;
@@ -2408,8 +2403,6 @@ BackedStringView EvalState::coerceToString(
bool copyToStore, bool copyToStore,
bool canonicalizePath) bool canonicalizePath)
{ {
auto _level = addCallDepth(pos);
forceValue(v, pos); forceValue(v, pos);
if (v.type() == nString) { if (v.type() == nString) {
@@ -2629,8 +2622,6 @@ SingleDerivedPath EvalState::coerceToSingleDerivedPath(const PosIdx pos, Value &
// `assert a == b; x` are critical for our users' testing UX. // `assert a == b; x` are critical for our users' testing UX.
void EvalState::assertEqValues(Value & v1, Value & v2, const PosIdx pos, std::string_view errorCtx) void EvalState::assertEqValues(Value & v1, Value & v2, const PosIdx pos, std::string_view errorCtx)
{ {
auto _level = addCallDepth(pos);
// This implementation must match eqValues. // This implementation must match eqValues.
forceValue(v1, pos); forceValue(v1, pos);
forceValue(v2, pos); forceValue(v2, pos);
@@ -2837,8 +2828,6 @@ void EvalState::assertEqValues(Value & v1, Value & v2, const PosIdx pos, std::st
// This implementation must match assertEqValues // This implementation must match assertEqValues
bool EvalState::eqValues(Value & v1, Value & v2, const PosIdx pos, std::string_view errorCtx) bool EvalState::eqValues(Value & v1, Value & v2, const PosIdx pos, std::string_view errorCtx)
{ {
auto _level = addCallDepth(pos);
forceValue(v1, pos); forceValue(v1, pos);
forceValue(v2, pos); forceValue(v2, pos);
+2 -25
View File
@@ -213,8 +213,6 @@ StringSet PackageInfo::queryMetaNames()
bool PackageInfo::checkMeta(Value & v) bool PackageInfo::checkMeta(Value & v)
{ {
auto _level = state->addCallDepth(v.determinePos(noPos));
state->forceValue(v, v.determinePos(noPos)); state->forceValue(v, v.determinePos(noPos));
if (v.type() == nList) { if (v.type() == nList) {
for (auto elem : v.listView()) for (auto elem : v.listView())
@@ -369,26 +367,7 @@ static std::string addToPath(const std::string & s1, std::string_view s2)
return s1.empty() ? std::string(s2) : s1 + "." + s2; return s1.empty() ? std::string(s2) : s1 + "." + s2;
} }
static bool isAttrPathComponent(std::string_view symbol) static std::regex attrRegex("[A-Za-z_][A-Za-z0-9-_+]*");
{
if (symbol.empty())
return false;
/* [A-Za-z_] */
unsigned char first = symbol[0];
if (!((first >= 'A' && first <= 'Z') || (first >= 'a' && first <= 'z') || first == '_'))
return false;
/* [A-Za-z0-9-_+]* */
for (unsigned char c : symbol.substr(1)) {
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '-' || c == '_'
|| c == '+')
continue;
return false;
}
return true;
}
static void getDerivations( static void getDerivations(
EvalState & state, EvalState & state,
@@ -399,8 +378,6 @@ static void getDerivations(
Done & done, Done & done,
bool ignoreAssertionFailures) bool ignoreAssertionFailures)
{ {
auto _level = state.addCallDepth(vIn.determinePos(noPos));
Value v; Value v;
state.autoCallFunction(autoArgs, vIn, v); state.autoCallFunction(autoArgs, vIn, v);
@@ -423,7 +400,7 @@ static void getDerivations(
std::string_view symbol{state.symbols[i->name]}; std::string_view symbol{state.symbols[i->name]};
try { try {
debug("evaluating attribute '%1%'", symbol); debug("evaluating attribute '%1%'", symbol);
if (!isAttrPathComponent(symbol)) if (!std::regex_match(symbol.begin(), symbol.end(), attrRegex))
continue; continue;
std::string pathPrefix2 = addToPath(pathPrefix, symbol); std::string pathPrefix2 = addToPath(pathPrefix, symbol);
if (combineChannels) if (combineChannels)
-2
View File
@@ -107,8 +107,6 @@ private:
Bindings & operator=(const Bindings &) = delete; Bindings & operator=(const Bindings &) = delete;
Bindings & operator=(Bindings &&) = delete; Bindings & operator=(Bindings &&) = delete;
~Bindings() = default;
friend class BindingsBuilder; friend class BindingsBuilder;
/** /**
@@ -54,20 +54,6 @@ MakeError(TypeError, EvalError);
MakeError(UndefinedVarError, EvalError); MakeError(UndefinedVarError, EvalError);
MakeError(MissingArgumentError, EvalError); MakeError(MissingArgumentError, EvalError);
MakeError(InfiniteRecursionError, EvalError); MakeError(InfiniteRecursionError, EvalError);
/**
* Resource exhaustion error when evaluation exceeds max-call-depth.
* Inherits from EvalBaseError (not EvalError) because resource exhaustion
* should not be cached.
*/
struct StackOverflowError : public EvalBaseError
{
StackOverflowError(EvalState & state)
: EvalBaseError(state, "stack overflow; max-call-depth exceeded")
{
}
};
MakeError(IFDError, EvalBaseError); MakeError(IFDError, EvalBaseError);
struct InvalidPathError : public EvalError struct InvalidPathError : public EvalError
+1 -1
View File
@@ -139,7 +139,7 @@ inline void EvalState::forceList(Value & v, const PosIdx pos, std::string_view e
inline CallDepth EvalState::addCallDepth(const PosIdx pos) inline CallDepth EvalState::addCallDepth(const PosIdx pos)
{ {
if (callDepth > settings.maxCallDepth) if (callDepth > settings.maxCallDepth)
error<StackOverflowError>().atPos(pos).debugThrow(); error<EvalBaseError>("stack overflow; max-call-depth exceeded").atPos(pos).debugThrow();
return CallDepth(callDepth); return CallDepth(callDepth);
}; };
@@ -5,8 +5,6 @@
namespace nix { namespace nix {
class EvalState;
/** /**
* Print a value in the deprecated format used by `nix-instantiate --eval` and * Print a value in the deprecated format used by `nix-instantiate --eval` and
* `nix-env` (for manifests). * `nix-env` (for manifests).
@@ -17,6 +15,7 @@ class EvalState;
* *
* See: https://github.com/NixOS/nix/issues/9730 * See: https://github.com/NixOS/nix/issues/9730
*/ */
void printAmbiguous(EvalState & state, Value & v, std::ostream & str, std::set<const void *> * seen, size_t depth = 0); void printAmbiguous(
Value & v, const SymbolTable & symbols, std::ostream & str, std::set<const void *> * seen, int depth);
} // namespace nix } // namespace nix
+2 -5
View File
@@ -164,6 +164,8 @@ public:
Value ** elems; Value ** elems;
ListBuilder(EvalMemory & mem, size_t size); ListBuilder(EvalMemory & mem, size_t size);
// NOTE: Can be noexcept because we are just copying integral values and
// raw pointers.
ListBuilder(ListBuilder && x) noexcept ListBuilder(ListBuilder && x) noexcept
: size(x.size) : size(x.size)
, inlineElems{x.inlineElems[0], x.inlineElems[1]} , inlineElems{x.inlineElems[0], x.inlineElems[1]}
@@ -171,11 +173,6 @@ public:
{ {
} }
ListBuilder(const ListBuilder &) = delete;
ListBuilder & operator=(ListBuilder &&) = delete;
ListBuilder & operator=(const ListBuilder &) = delete;
~ListBuilder() = default;
Value *& operator[](size_t n) Value *& operator[](size_t n)
{ {
return elems[n]; return elems[n];
+20 -46
View File
@@ -3002,19 +3002,16 @@ static RegisterPrimOp primop_path({
- recursive\ - recursive\
When `false`, when `path` is added to the store it is with a When `false`, when `path` is added to the store it is with a
[flat hash](@docroot@/store/file-system-object/content-address.md#serial-flat), flat hash, rather than a hash of the NAR serialization of the
rather than a hash of the file. Thus, `path` must refer to a regular file, not a
[NAR serialization](@docroot@/store/file-system-object/content-address.md#serial-nix-archive)
of the file. Thus, `path` must refer to a regular file, not a
directory. This allows similar behavior to `fetchurl`. Defaults directory. This allows similar behavior to `fetchurl`. Defaults
to `true`. to `true`.
- sha256\ - sha256\
When provided, this is the expected When provided, this is the expected hash of the file at the
[content hash](@docroot@/store/file-system-object/content-address.md) path. Evaluation fails if the hash is incorrect, and
of the path. Evaluation fails if the hash is incorrect, providing a hash allows `builtins.path` to be used even when the
and providing a hash allows `builtins.path` to be used even `pure-eval` nix config option is on.
when the `pure-eval` nix config option is on.
)", )",
.fun = prim_path, .fun = prim_path,
}); });
@@ -4064,8 +4061,6 @@ static RegisterPrimOp primop_sort({
1. Transitivity 1. Transitivity
If a is less than b and b is less than c, then it follows that a is less than c.
```nix ```nix
comparator a b && comparator b c -> comparator a c comparator a b && comparator b c -> comparator a c
``` ```
@@ -4078,23 +4073,9 @@ static RegisterPrimOp primop_sort({
1. Transitivity of equivalence 1. Transitivity of equivalence
First, two values a and b are considered equivalent with respect to the comparator if:
```
!comparator a b && !comparator b a
```
In other words, neither is considered "less than" the other.
Transitivity of equivalence means:
If a is equivalent to b, and b is equivalent to c, then a must also be equivalent to c.
```nix ```nix
let let equiv = a: b: (!comparator a b && !comparator b a); in
equiv = x: y: (!comparator x y && !comparator y x); equiv a b && equiv b c -> equiv a c
in
equiv a b && equiv b c -> equiv a c
``` ```
If the *comparator* violates any of these properties, then `builtins.sort` If the *comparator* violates any of these properties, then `builtins.sort`
@@ -4712,28 +4693,21 @@ static RegisterPrimOp primop_convertHash({
struct RegexCache struct RegexCache
{ {
struct Entry boost::concurrent_flat_map<std::string, std::regex, StringViewHash, std::equal_to<>> cache;
std::regex get(std::string_view re)
{ {
ref<const std::regex> regex; std::regex regex;
/* No std::regex constructor overload from std::string_view, but can be constructed
Entry(const char * s, size_t count) from a pointer + size or an iterator range. */
: regex(make_ref<const std::regex>(s, count, std::regex::extended))
{
}
};
boost::concurrent_flat_map<std::string, Entry, StringViewHash, std::equal_to<>> cache;
ref<const std::regex> get(std::string_view re)
{
std::optional<ref<const std::regex>> regex;
cache.try_emplace_and_cvisit( cache.try_emplace_and_cvisit(
re, re,
/*s=*/re.data(), /*s=*/re.data(),
/*count=*/re.size(), /*count=*/re.size(),
[&regex](const auto & kv) { regex = kv.second.regex; }, std::regex::extended,
[&regex](const auto & kv) { regex = kv.second.regex; }); [&regex](const auto & kv) { regex = kv.second; },
return *regex; [&regex](const auto & kv) { regex = kv.second; });
return regex;
} }
}; };
@@ -4755,7 +4729,7 @@ void prim_match(EvalState & state, const PosIdx pos, Value ** args, Value & v)
state.forceString(*args[1], context, pos, "while evaluating the second argument passed to builtins.match"); state.forceString(*args[1], context, pos, "while evaluating the second argument passed to builtins.match");
std::cmatch match; std::cmatch match;
if (!std::regex_match(str.begin(), str.end(), match, *regex)) { if (!std::regex_match(str.begin(), str.end(), match, regex)) {
v.mkNull(); v.mkNull();
return; return;
} }
@@ -4828,7 +4802,7 @@ void prim_split(EvalState & state, const PosIdx pos, Value ** args, Value & v)
const auto str = const auto str =
state.forceString(*args[1], context, pos, "while evaluating the second argument passed to builtins.split"); state.forceString(*args[1], context, pos, "while evaluating the second argument passed to builtins.split");
auto begin = std::cregex_iterator(str.begin(), str.end(), *regex); auto begin = std::cregex_iterator(str.begin(), str.end(), regex);
auto end = std::cregex_iterator(); auto end = std::cregex_iterator();
// Any matches results are surrounded by non-matching results. // Any matches results are surrounded by non-matching results.
+4 -4
View File
@@ -243,7 +243,7 @@ static RegisterPrimOp primop_fetchClosure({
```nix ```nix
builtins.fetchClosure { builtins.fetchClosure {
fromStore = "https://cache.nixos.org"; fromStore = "https://cache.nixos.org";
fromPath = /nix/store/nph9br6y2dmciy6q3dj3fwk2brdlr4gh-git-2.33.1; fromPath = /nix/store/r2jd6ygnmirm2g803mksqqjm4y39yi6i-git-2.33.1;
toPath = /nix/store/ldbhlwhh39wha58rm61bkiiwm6j7211j-git-2.33.1; toPath = /nix/store/ldbhlwhh39wha58rm61bkiiwm6j7211j-git-2.33.1;
} }
``` ```
@@ -258,8 +258,8 @@ static RegisterPrimOp primop_fetchClosure({
use [`nix store make-content-addressed`](@docroot@/command-ref/new-cli/nix3-store-make-content-addressed.md): use [`nix store make-content-addressed`](@docroot@/command-ref/new-cli/nix3-store-make-content-addressed.md):
```console ```console
# nix store make-content-addressed --from https://cache.nixos.org /nix/store/nph9br6y2dmciy6q3dj3fwk2brdlr4gh-git-2.33.1 # nix store make-content-addressed --from https://cache.nixos.org /nix/store/r2jd6ygnmirm2g803mksqqjm4y39yi6i-git-2.33.1
rewrote '/nix/store/nph9br6y2dmciy6q3dj3fwk2brdlr4gh-git-2.33.1' to '/nix/store/ldbhlwhh39wha58rm61bkiiwm6j7211j-git-2.33.1' rewrote '/nix/store/r2jd6ygnmirm2g803mksqqjm4y39yi6i-git-2.33.1' to '/nix/store/ldbhlwhh39wha58rm61bkiiwm6j7211j-git-2.33.1'
``` ```
Alternatively, set `toPath = ""` and find the correct `toPath` in the error message. Alternatively, set `toPath = ""` and find the correct `toPath` in the error message.
@@ -271,7 +271,7 @@ static RegisterPrimOp primop_fetchClosure({
```nix ```nix
builtins.fetchClosure { builtins.fetchClosure {
fromStore = "https://cache.nixos.org"; fromStore = "https://cache.nixos.org";
fromPath = /nix/store/nph9br6y2dmciy6q3dj3fwk2brdlr4gh-git-2.33.1; fromPath = /nix/store/r2jd6ygnmirm2g803mksqqjm4y39yi6i-git-2.33.1;
inputAddressed = true; inputAddressed = true;
} }
``` ```
+10 -8
View File
@@ -2,17 +2,19 @@
#include "nix/expr/print.hh" #include "nix/expr/print.hh"
#include "nix/util/signals.hh" #include "nix/util/signals.hh"
#include "nix/expr/eval.hh" #include "nix/expr/eval.hh"
#include "nix/expr/eval-error.hh"
namespace nix { namespace nix {
// See: https://github.com/NixOS/nix/issues/9730 // See: https://github.com/NixOS/nix/issues/9730
void printAmbiguous(EvalState & state, Value & v, std::ostream & str, std::set<const void *> * seen, size_t depth) void printAmbiguous(
Value & v, const SymbolTable & symbols, std::ostream & str, std::set<const void *> * seen, int depth)
{ {
checkInterrupt(); checkInterrupt();
if (depth > state.settings.maxCallDepth) if (depth <= 0) {
state.error<StackOverflowError>().atPos(v.determinePos(noPos)).debugThrow(); str << "«too deep»";
return;
}
switch (v.type()) { switch (v.type()) {
case nInt: case nInt:
str << v.integer(); str << v.integer();
@@ -34,9 +36,9 @@ void printAmbiguous(EvalState & state, Value & v, std::ostream & str, std::set<c
str << "«repeated»"; str << "«repeated»";
else { else {
str << "{ "; str << "{ ";
for (auto & i : v.attrs()->lexicographicOrder(state.symbols)) { for (auto & i : v.attrs()->lexicographicOrder(symbols)) {
str << state.symbols[i->name] << " = "; str << symbols[i->name] << " = ";
printAmbiguous(state, *i->value, str, seen, depth + 1); printAmbiguous(*i->value, symbols, str, seen, depth - 1);
str << "; "; str << "; ";
} }
str << "}"; str << "}";
@@ -52,7 +54,7 @@ void printAmbiguous(EvalState & state, Value & v, std::ostream & str, std::set<c
str << "[ "; str << "[ ";
for (auto v2 : v.listView()) { for (auto v2 : v.listView()) {
if (v2) if (v2)
printAmbiguous(state, *v2, str, seen, depth + 1); printAmbiguous(*v2, symbols, str, seen, depth - 1);
else else
str << "(nullptr)"; str << "(nullptr)";
str << " "; str << " ";
-15
View File
@@ -537,16 +537,6 @@ private:
output.flush(); output.flush();
checkInterrupt(); checkInterrupt();
// Catch infinite recursion before it overflows the C++ stack.
// Non-cyclic structures can be infinitely deep when values are
// lazily produced (e.g., `let f = n: { inner = f (n + 1); }; in f 0`).
// We check print depth against max-call-depth rather than incrementing
// the callDepth counter, because accessing an attribute is not a call.
// Other places do increment callDepth for simplicity, but that is
// technically incorrect.
if (depth > state.settings.maxCallDepth)
state.error<StackOverflowError>().atPos(v.determinePos(noPos)).debugThrow();
try { try {
if (options.force) { if (options.force) {
state.forceValue(v, v.determinePos(noPos)); state.forceValue(v, v.determinePos(noPos));
@@ -602,11 +592,6 @@ private:
printUnknown(); printUnknown();
break; break;
} }
} catch (StackOverflowError &) {
// Always re-throw because stack overflow is a serious condition
// that expressions should avoid, unlike say `throw`, which can
// be part of legitimate expression patterns.
throw;
} catch (Error & e) { } catch (Error & e) {
if (options.errors == ErrorPrintBehavior::Throw if (options.errors == ErrorPrintBehavior::Throw
|| (options.errors == ErrorPrintBehavior::ThrowTopLevel && depth == 0)) { || (options.errors == ErrorPrintBehavior::ThrowTopLevel && depth == 0)) {
-2
View File
@@ -66,8 +66,6 @@ static void printValueAsXML(
{ {
checkInterrupt(); checkInterrupt();
auto _level = state.addCallDepth(pos);
if (strict) if (strict)
state.forceValue(v, pos); state.forceValue(v, pos);
+2 -3
View File
@@ -48,7 +48,7 @@ public:
ref<GitRepo> openRepo() ref<GitRepo> openRepo()
{ {
return GitRepo::openRepo(tmpDir, {.create = true}); return GitRepo::openRepo(tmpDir, true, false);
} }
std::string getRepoName() const std::string getRepoName() const
@@ -115,10 +115,9 @@ TEST_F(GitUtilsTest, sink_hardlink)
try { try {
sink->createHardlink(CanonPath("foo-1.1/link"), CanonPath("hello")); sink->createHardlink(CanonPath("foo-1.1/link"), CanonPath("hello"));
sink->flush();
FAIL() << "Expected an exception"; FAIL() << "Expected an exception";
} catch (const nix::Error & e) { } catch (const nix::Error & e) {
ASSERT_THAT(e.msg(), testing::HasSubstr("does not exist")); ASSERT_THAT(e.msg(), testing::HasSubstr("cannot find hard link target"));
ASSERT_THAT(e.msg(), testing::HasSubstr("/hello")); ASSERT_THAT(e.msg(), testing::HasSubstr("/hello"));
ASSERT_THAT(e.msg(), testing::HasSubstr("foo-1.1/link")); ASSERT_THAT(e.msg(), testing::HasSubstr("foo-1.1/link"));
} }
+225 -250
View File
@@ -203,19 +203,16 @@ static git_packbuilder_progress PACKBUILDER_PROGRESS_CHECK_INTERRUPT = &packBuil
} // extern "C" } // extern "C"
static void initRepoAtomically(std::filesystem::path & path, GitRepo::Options options) static void initRepoAtomically(std::filesystem::path & path, bool bare)
{ {
if (pathExists(path.string())) if (pathExists(path.string()))
return; return;
if (!options.create)
throw Error("Git repository %s does not exist.", path);
std::filesystem::path tmpDir = createTempDir(path.parent_path()); std::filesystem::path tmpDir = createTempDir(path.parent_path());
AutoDelete delTmpDir(tmpDir, true); AutoDelete delTmpDir(tmpDir, true);
Repository tmpRepo; Repository tmpRepo;
if (git_repository_init(Setter(tmpRepo), tmpDir.string().c_str(), options.bare)) if (git_repository_init(Setter(tmpRepo), tmpDir.string().c_str(), bare))
throw Error("creating Git repository %s: %s", path, git_error_last()->message); throw Error("creating Git repository %s: %s", path, git_error_last()->message);
try { try {
std::filesystem::rename(tmpDir, path); std::filesystem::rename(tmpDir, path);
@@ -237,7 +234,7 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
/** Location of the repository on disk. */ /** Location of the repository on disk. */
std::filesystem::path path; std::filesystem::path path;
Options options; bool bare;
/** /**
* libgit2 repository. Note that new objects are not written to disk, * libgit2 repository. Note that new objects are not written to disk,
@@ -258,18 +255,18 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
*/ */
git_odb_backend * packBackend = nullptr; git_odb_backend * packBackend = nullptr;
GitRepoImpl(std::filesystem::path _path, Options _options) GitRepoImpl(std::filesystem::path _path, bool create, bool bare, bool packfilesOnly = false)
: path(std::move(_path)) : path(std::move(_path))
, options(_options) , bare(bare)
{ {
initLibGit2(); initLibGit2();
initRepoAtomically(path, options); initRepoAtomically(path, bare);
if (git_repository_open(Setter(repo), path.string().c_str())) if (git_repository_open(Setter(repo), path.string().c_str()))
throw Error("opening Git repository %s: %s", path, git_error_last()->message); throw Error("opening Git repository %s: %s", path, git_error_last()->message);
ObjectDb odb; ObjectDb odb;
if (options.packfilesOnly) { if (packfilesOnly) {
/* Create a fresh object database because by default the repo also /* Create a fresh object database because by default the repo also
loose object backends. We are not using any of those for the loose object backends. We are not using any of those for the
tarball cache, but libgit2 still does a bunch of unnecessary tarball cache, but libgit2 still does a bunch of unnecessary
@@ -298,7 +295,7 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
if (git_odb_add_backend(odb.get(), mempackBackend, 999)) if (git_odb_add_backend(odb.get(), mempackBackend, 999))
throw Error("adding mempack backend to Git object database: %s", git_error_last()->message); throw Error("adding mempack backend to Git object database: %s", git_error_last()->message);
if (options.packfilesOnly) { if (packfilesOnly) {
if (git_repository_set_odb(repo.get(), odb.get())) if (git_repository_set_odb(repo.get(), odb.get()))
throw Error("setting Git object database: %s", git_error_last()->message); throw Error("setting Git object database: %s", git_error_last()->message);
} }
@@ -369,26 +366,7 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
{ {
// TODO: as an optimization, it would be nice to include `this` in the pool. // TODO: as an optimization, it would be nice to include `this` in the pool.
return Pool<GitRepoImpl>(std::numeric_limits<size_t>::max(), [this]() -> ref<GitRepoImpl> { return Pool<GitRepoImpl>(std::numeric_limits<size_t>::max(), [this]() -> ref<GitRepoImpl> {
auto repo = make_ref<GitRepoImpl>(path, options); return make_ref<GitRepoImpl>(path, false, bare);
/* Monkey-patching the pack backend to only read the pack directory
once. Otherwise it will do a readdir for each added oid when it's
not found and that translates to ~6 syscalls. Since we are never
writing pack files until flushing we can force the odb backend to
read the directory just once. It's very convenient that the vtable is
semi-public interface and is up for grabs.
This is purely an optimization for our use-case with a tarball cache.
libgit2 calls refresh() if the backend provides it when an oid isn't found.
We are only writing objects to a mempack (it has higher priority) and there isn't
a realistic use-case where a previously missing object would appear from thin air
on the disk (unless another process happens to be unpacking a similar tarball to
the cache at the same time, but that's a very unrealistic scenario).
*/
if (auto * backend = repo->packBackend)
backend->refresh = nullptr;
return repo;
}); });
} }
@@ -687,7 +665,6 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
keyDecoded = base64::decode(k.key); keyDecoded = base64::decode(k.key);
} catch (Error & e) { } catch (Error & e) {
e.addTrace({}, "while decoding public key '%s' used for git signature", k.key); e.addTrace({}, "while decoding public key '%s' used for git signature", k.key);
throw;
} }
auto fingerprint = auto fingerprint =
trim(hashString(HashAlgorithm::SHA256, keyDecoded).to_string(nix::HashFormat::Base64, false), "="); trim(hashString(HashAlgorithm::SHA256, keyDecoded).to_string(nix::HashFormat::Base64, false), "=");
@@ -735,9 +712,9 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
} }
}; };
ref<GitRepo> GitRepo::openRepo(const std::filesystem::path & path, GitRepo::Options options) ref<GitRepo> GitRepo::openRepo(const std::filesystem::path & path, bool create, bool bare, bool packfilesOnly)
{ {
return make_ref<GitRepoImpl>(path, options); return make_ref<GitRepoImpl>(path, create, bare, packfilesOnly);
} }
/** /**
@@ -1078,155 +1055,185 @@ struct GitFileSystemObjectSinkImpl : GitFileSystemObjectSink
{ {
ref<GitRepoImpl> repo; ref<GitRepoImpl> repo;
Pool<GitRepoImpl> repoPool; struct PendingDir
{
std::string name;
TreeBuilder builder;
};
unsigned int concurrency = std::min(std::thread::hardware_concurrency(), 10U); std::vector<PendingDir> pendingDirs;
ThreadPool workers{concurrency}; /**
* Temporary buffer used by createRegularFile for storing small file contents.
*/
std::string regularFileContentsBuffer;
/** Total file contents in flight. */ /**
std::atomic<size_t> totalBufSize{0}; * If repo has a non-null packBackend, this has a copy of the refresh function
* from the backend virtual table. This is needed to restore it after we've flushed
* the sink. We modify it to avoid unnecessary I/O on non-existent oids.
*/
decltype(::git_odb_backend::refresh) packfileOdbRefresh = nullptr;
static constexpr std::size_t maxBufSize = 16 * 1024 * 1024; void pushBuilder(std::string name)
{
const git_tree_entry * entry;
Tree prevTree = nullptr;
if (!pendingDirs.empty() && (entry = git_treebuilder_get(pendingDirs.back().builder.get(), name.c_str()))) {
/* Clone a tree that we've already finished. This happens
if a tarball has directory entries that are not
contiguous. */
if (git_tree_entry_type(entry) != GIT_OBJECT_TREE)
throw Error("parent of '%s' is not a directory", name);
if (git_tree_entry_to_object((git_object **) (git_tree **) Setter(prevTree), *repo, entry))
throw Error("looking up parent of '%s': %s", name, git_error_last()->message);
}
git_treebuilder * b;
if (git_treebuilder_new(&b, *repo, prevTree.get()))
throw Error("creating a tree builder: %s", git_error_last()->message);
pendingDirs.push_back({.name = std::move(name), .builder = TreeBuilder(b)});
};
GitFileSystemObjectSinkImpl(ref<GitRepoImpl> repo) GitFileSystemObjectSinkImpl(ref<GitRepoImpl> repo)
: repo(repo) : repo(repo)
, repoPool(repo->getPool())
{ {
/* Monkey-patching the pack backend to only read the pack directory
once. Otherwise it will do a readdir for each added oid when it's
not found and that translates to ~6 syscalls. Since we are never
writing pack files until flushing we can force the odb backend to
read the directory just once. It's very convenient that the vtable is
semi-public interface and is up for grabs.
This is purely an optimization for our use-case with a tarball cache.
libgit2 calls refresh() if the backend provides it when an oid isn't found.
We are only writing objects to a mempack (it has higher priority) and there isn't
a realistic use-case where a previously missing object would appear from thin air
on the disk (unless another process happens to be unpacking a similar tarball to
the cache at the same time, but that's a very unrealistic scenario).
*/
if (auto * backend = repo->packBackend) {
if (backend->refresh(backend)) /* Refresh just once manually. */
throw Error("refreshing packfiles: %s", git_error_last()->message);
/* Save the function pointer to restore it later in flush() and
unset it in the vtable. libgit2 does nothing if it's a nullptr:
https://github.com/libgit2/libgit2/blob/58d9363f02f1fa39e46d49b604f27008e75b72f2/src/libgit2/odb.c#L1922
*/
packfileOdbRefresh = std::exchange(backend->refresh, nullptr);
}
pushBuilder("");
} }
~GitFileSystemObjectSinkImpl() std::pair<git_oid, std::string> popBuilder()
{ {
// Make sure the worker threads are destroyed before any state assert(!pendingDirs.empty());
// they're referring to. auto pending = std::move(pendingDirs.back());
workers.shutdown(); git_oid oid;
} if (git_treebuilder_write(&oid, pending.builder.get()))
throw Error("creating a tree object: %s", git_error_last()->message);
struct Child; pendingDirs.pop_back();
return {oid, pending.name};
/// A directory to be written as a Git tree.
struct Directory
{
std::map<std::string, Child> children;
std::optional<git_oid> oid;
Child & lookup(const CanonPath & path)
{
assert(!path.isRoot());
auto parent = path.parent();
auto cur = this;
for (auto & name : *parent) {
auto i = cur->children.find(std::string(name));
if (i == cur->children.end())
throw Error("path '%s' does not exist", path);
auto dir = std::get_if<Directory>(&i->second.file);
if (!dir)
throw Error("path '%s' has a non-directory parent", path);
cur = dir;
}
auto i = cur->children.find(std::string(*path.baseName()));
if (i == cur->children.end())
throw Error("path '%s' does not exist", path);
return i->second;
}
}; };
size_t nextId = 0; // for Child.id void addToTree(const std::string & name, const git_oid & oid, git_filemode_t mode)
struct Child
{ {
git_filemode_t mode; assert(!pendingDirs.empty());
std::variant<Directory, git_oid> file; auto & pending = pendingDirs.back();
if (git_treebuilder_insert(nullptr, pending.builder.get(), name.c_str(), &oid, mode))
/// Sequential numbering of the file in the tarball. This is throw Error("adding a file to a tree builder: %s", git_error_last()->message);
/// used to make sure we only import the latest version of a
/// path.
size_t id{0};
}; };
struct State void updateBuilders(std::span<const std::string> names)
{ {
Directory root; // Find the common prefix of pendingDirs and names.
}; size_t prefixLen = 0;
for (; prefixLen < names.size() && prefixLen + 1 < pendingDirs.size(); ++prefixLen)
if (names[prefixLen] != pendingDirs[prefixLen + 1].name)
break;
Sync<State> _state; // Finish the builders that are not part of the common prefix.
for (auto n = pendingDirs.size(); n > prefixLen + 1; --n) {
void addNode(State & state, const CanonPath & path, Child && child) auto [oid, name] = popBuilder();
{ addToTree(name, oid, GIT_FILEMODE_TREE);
assert(!path.isRoot());
auto parent = path.parent();
Directory * cur = &state.root;
for (auto & i : *parent) {
auto child = std::get_if<Directory>(
&cur->children.emplace(std::string(i), Child{GIT_FILEMODE_TREE, {Directory()}}).first->second.file);
assert(child);
cur = child;
} }
std::string name(*path.baseName()); // Create builders for the new directories.
for (auto n = prefixLen; n < names.size(); ++n)
pushBuilder(names[n]);
};
if (auto prev = cur->children.find(name); prev == cur->children.end() || prev->second.id < child.id) bool prepareDirs(const std::vector<std::string> & pathComponents, bool isDir)
cur->children.insert_or_assign(name, std::move(child)); {
std::span<const std::string> pathComponents2{pathComponents};
updateBuilders(isDir ? pathComponents2 : pathComponents2.first(pathComponents2.size() - 1));
return true;
} }
void createRegularFile(const CanonPath & path, std::function<void(CreateRegularFileSink &)> func) override void createRegularFile(const CanonPath & path, std::function<void(CreateRegularFileSink &)> func) override
{ {
checkInterrupt(); auto pathComponents = tokenizeString<std::vector<std::string>>(path.rel(), "/");
if (!prepareDirs(pathComponents, false))
/* Multithreaded blob writing. We read the incoming file data into memory and asynchronously write it to a Git return;
blob object. However, to avoid unbounded memory usage, if the amount of data in flight exceeds a threshold,
we switch to writing directly to a Git write stream. */
using WriteStream = std::unique_ptr<::git_writestream, decltype([](::git_writestream * stream) { using WriteStream = std::unique_ptr<::git_writestream, decltype([](::git_writestream * stream) {
if (stream) if (stream)
stream->free(stream); stream->free(stream);
})>; })>;
/* Maximum file size that gets buffered in memory before flushing to a WriteStream,
that's backed by a temporary objects/streamed_git2_* file. We should avoid that
for common cases, since creating (and deleting) a temporary file for each blob
is insanely expensive. */
static constexpr std::size_t maxBufferSize = 1024 * 1024; /* 1 MiB */
struct CRF : CreateRegularFileSink struct CRF : CreateRegularFileSink
{ {
CanonPath path; const CanonPath & path;
GitFileSystemObjectSinkImpl & parent; GitFileSystemObjectSinkImpl & back;
WriteStream stream; WriteStream stream;
std::optional<decltype(parent.repoPool)::Handle> repo; std::string & contents;
std::string contents;
bool executable = false; bool executable = false;
CRF(CanonPath path, GitFileSystemObjectSinkImpl & parent) CRF(const CanonPath & path, GitFileSystemObjectSinkImpl & back, std::string & regularFileContentsBuffer)
: path(std::move(path)) : path(path)
, parent(parent) , back(back)
, stream(nullptr)
, contents(regularFileContentsBuffer)
{ {
contents.clear();
} }
~CRF() void writeToStream(std::string_view data)
{ {
parent.totalBufSize -= contents.size(); /* Lazily create the stream. */
if (!stream) {
::git_writestream * stream2 = nullptr;
if (git_blob_create_from_stream(&stream2, *back.repo, nullptr))
throw Error("creating a blob stream object: %s", git_error_last()->message);
stream = WriteStream{stream2};
assert(stream);
}
if (stream->write(stream.get(), data.data(), data.size()))
throw Error("writing a blob for tarball member '%s': %s", path, git_error_last()->message);
} }
void operator()(std::string_view data) override void operator()(std::string_view data) override
{ {
if (!stream) { /* Already in slow path. Just write to the slow stream. */
contents.append(data); if (stream) {
parent.totalBufSize += data.size(); writeToStream(data);
return;
}
if (parent.totalBufSize > parent.maxBufSize) { contents += data;
repo.emplace(parent.repoPool.get()); if (contents.size() > maxBufferSize) {
writeToStream(contents); /* Will initialize stream. */
if (git_blob_create_from_stream(Setter(stream), **repo, nullptr)) contents.clear();
throw Error("creating a blob stream object: %s", git_error_last()->message);
if (stream->write(stream.get(), contents.data(), contents.size()))
throw Error("writing a blob for tarball member '%s': %s", path, git_error_last()->message);
parent.totalBufSize -= contents.size();
contents.clear();
}
} else {
if (stream->write(stream.get(), data.data(), data.size()))
throw Error("writing a blob for tarball member '%s': %s", path, git_error_last()->message);
} }
} }
@@ -1234,140 +1241,112 @@ struct GitFileSystemObjectSinkImpl : GitFileSystemObjectSink
{ {
executable = true; executable = true;
} }
}; } crf{path, *this, regularFileContentsBuffer};
auto crf = std::make_shared<CRF>(path, *this); func(crf);
func(*crf); git_oid oid;
if (crf.stream) {
auto id = nextId++; /* Call .release(), since git_blob_create_from_stream_commit
if (crf->stream) {
/* Finish the slow path by creating the blob object synchronously.
Call .release(), since git_blob_create_from_stream_commit
acquires ownership and frees the stream. */ acquires ownership and frees the stream. */
git_oid oid; if (git_blob_create_from_stream_commit(&oid, crf.stream.release()))
if (git_blob_create_from_stream_commit(&oid, crf->stream.release()))
throw Error("creating a blob object for '%s': %s", path, git_error_last()->message); throw Error("creating a blob object for '%s': %s", path, git_error_last()->message);
addNode( } else {
*_state.lock(), if (git_blob_create_from_buffer(&oid, *repo, crf.contents.data(), crf.contents.size()))
crf->path, throw Error(
Child{crf->executable ? GIT_FILEMODE_BLOB_EXECUTABLE : GIT_FILEMODE_BLOB, oid, id}); "creating a blob object for '%s' from in-memory buffer: %s", path, git_error_last()->message);
return;
} }
/* Fast path: create the blob object in a separate thread. */ addToTree(*pathComponents.rbegin(), oid, crf.executable ? GIT_FILEMODE_BLOB_EXECUTABLE : GIT_FILEMODE_BLOB);
workers.enqueue([this, crf{std::move(crf)}, id]() {
auto repo(repoPool.get());
git_oid oid;
if (git_blob_create_from_buffer(&oid, *repo, crf->contents.data(), crf->contents.size()))
throw Error(
"creating a blob object for '%s' from in-memory buffer: %s", crf->path, git_error_last()->message);
addNode(
*_state.lock(),
crf->path,
Child{crf->executable ? GIT_FILEMODE_BLOB_EXECUTABLE : GIT_FILEMODE_BLOB, oid, id});
});
} }
void createDirectory(const CanonPath & path) override void createDirectory(const CanonPath & path) override
{ {
if (path.isRoot()) auto pathComponents = tokenizeString<std::vector<std::string>>(path.rel(), "/");
return; (void) prepareDirs(pathComponents, true);
auto state(_state.lock());
addNode(*state, path, {GIT_FILEMODE_TREE, Directory()});
} }
void createSymlink(const CanonPath & path, const std::string & target) override void createSymlink(const CanonPath & path, const std::string & target) override
{ {
workers.enqueue([this, path, target]() { auto pathComponents = tokenizeString<std::vector<std::string>>(path.rel(), "/");
auto repo(repoPool.get()); if (!prepareDirs(pathComponents, false))
return;
git_oid oid; git_oid oid;
if (git_blob_create_from_buffer(&oid, *repo, target.c_str(), target.size())) if (git_blob_create_from_buffer(&oid, *repo, target.c_str(), target.size()))
throw Error( throw Error("creating a blob object for tarball symlink member '%s': %s", path, git_error_last()->message);
"creating a blob object for tarball symlink member '%s': %s", path, git_error_last()->message);
auto state(_state.lock()); addToTree(*pathComponents.rbegin(), oid, GIT_FILEMODE_LINK);
addNode(*state, path, Child{GIT_FILEMODE_LINK, oid});
});
} }
std::map<CanonPath, CanonPath> hardLinks;
void createHardlink(const CanonPath & path, const CanonPath & target) override void createHardlink(const CanonPath & path, const CanonPath & target) override
{ {
hardLinks.insert_or_assign(path, target); std::vector<std::string> pathComponents;
for (auto & c : path)
pathComponents.emplace_back(c);
if (!prepareDirs(pathComponents, false))
return;
// We can't just look up the path from the start of the root, since
// some parent directories may not have finished yet, so we compute
// a relative path that helps us find the right git_tree_builder or object.
auto relTarget = CanonPath(path).parent()->makeRelative(target);
auto dir = pendingDirs.rbegin();
// For each ../ component at the start, go up one directory.
// CanonPath::makeRelative() always puts all .. elements at the start,
// so they're all handled by this loop:
std::string_view relTargetLeft(relTarget);
while (hasPrefix(relTargetLeft, "../")) {
if (dir == pendingDirs.rend())
throw Error("invalid hard link target '%s' for path '%s'", target, path);
++dir;
relTargetLeft = relTargetLeft.substr(3);
}
if (dir == pendingDirs.rend())
throw Error("invalid hard link target '%s' for path '%s'", target, path);
// Look up the remainder of the target, starting at the
// top-most `git_treebuilder`.
std::variant<git_treebuilder *, git_oid> curDir{dir->builder.get()};
Object tree; // needed to keep `entry` alive
const git_tree_entry * entry = nullptr;
for (auto & c : CanonPath(relTargetLeft)) {
if (auto builder = std::get_if<git_treebuilder *>(&curDir)) {
assert(*builder);
if (!(entry = git_treebuilder_get(*builder, std::string(c).c_str())))
throw Error("cannot find hard link target '%s' for path '%s'", target, path);
curDir = *git_tree_entry_id(entry);
} else if (auto oid = std::get_if<git_oid>(&curDir)) {
tree = lookupObject(*repo, *oid, GIT_OBJECT_TREE);
if (!(entry = git_tree_entry_byname((const git_tree *) &*tree, std::string(c).c_str())))
throw Error("cannot find hard link target '%s' for path '%s'", target, path);
curDir = *git_tree_entry_id(entry);
}
}
assert(entry);
addToTree(*pathComponents.rbegin(), *git_tree_entry_id(entry), git_tree_entry_filemode(entry));
} }
Hash flush() override Hash flush() override
{ {
workers.process(); updateBuilders({});
/* Create hard links. */ auto [oid, _name] = popBuilder();
{
auto state(_state.lock()); if (auto * backend = repo->packBackend) {
for (auto & [path, target] : hardLinks) { /* We are done writing blobs, can restore refresh functionality. */
if (target.isRoot()) backend->refresh = packfileOdbRefresh;
continue;
try {
auto child = state->root.lookup(target);
auto oid = std::get_if<git_oid>(&child.file);
if (!oid)
throw Error("cannot create a hard link to a directory");
addNode(*state, path, {child.mode, *oid});
} catch (Error & e) {
e.addTrace(nullptr, "while creating a hard link from '%s' to '%s'", path, target);
throw;
}
}
} }
// Flush all repo objects to disk.
{
auto repos = repoPool.clear();
ThreadPool workers{repos.size()};
for (auto & repo : repos)
workers.enqueue([repo]() { repo->flush(); });
workers.process();
}
// Write the Git trees to disk. Would be nice to have this multithreaded too, but that's hard because a tree
// can't refer to an object that hasn't been written yet. Also it doesn't make a big difference for performance.
auto repo(repoPool.get());
[&](this const auto & visit, Directory & node) -> void {
checkInterrupt();
// Write the child directories.
for (auto & child : node.children)
if (auto dir = std::get_if<Directory>(&child.second.file))
visit(*dir);
// Write this directory.
git_treebuilder * b;
if (git_treebuilder_new(&b, *repo, nullptr))
throw Error("creating a tree builder: %s", git_error_last()->message);
TreeBuilder builder(b);
for (auto & [name, child] : node.children) {
auto oid_p = std::get_if<git_oid>(&child.file);
auto oid = oid_p ? *oid_p : std::get<Directory>(child.file).oid.value();
if (git_treebuilder_insert(nullptr, builder.get(), name.c_str(), &oid, child.mode))
throw Error("adding a file to a tree builder: %s", git_error_last()->message);
}
git_oid oid;
if (git_treebuilder_write(&oid, builder.get()))
throw Error("creating a tree object: %s", git_error_last()->message);
node.oid = oid;
}(_state.lock()->root);
repo->flush(); repo->flush();
return toHash(_state.lock()->root.oid.value()); return toHash(oid);
} }
}; };
@@ -1448,12 +1427,8 @@ namespace fetchers {
ref<GitRepo> Settings::getTarballCache() const ref<GitRepo> Settings::getTarballCache() const
{ {
/* v1: Had either only loose objects or thin packfiles referring to loose objects static auto repoDir = std::filesystem::path(getCacheDir()) / "tarball-cache";
* v2: Must have only packfiles with no loose objects. Should get repacked periodically return GitRepo::openRepo(repoDir, /*create=*/true, /*bare=*/true, /*packfilesOnly=*/true);
* for optimal packfiles.
*/
static auto repoDir = std::filesystem::path(getCacheDir()) / "tarball-cache-v2";
return GitRepo::openRepo(repoDir, {.create = true, .bare = true, .packfilesOnly = true});
} }
} // namespace fetchers } // namespace fetchers
@@ -1467,7 +1442,7 @@ GitRepo::WorkdirInfo GitRepo::getCachedWorkdirInfo(const std::filesystem::path &
if (i != cache->end()) if (i != cache->end())
return i->second; return i->second;
} }
auto workdirInfo = GitRepo::openRepo(path, {})->getWorkdirInfo(); auto workdirInfo = GitRepo::openRepo(path)->getWorkdirInfo();
_cache.lock()->emplace(path, workdirInfo); _cache.lock()->emplace(path, workdirInfo);
return workdirInfo; return workdirInfo;
} }
+13 -8
View File
@@ -637,6 +637,11 @@ struct GitInputScheme : InputScheme
url); url);
} }
// If we don't check here for the path existence, then we can give libgit2 any directory
// and it will initialize them as git directories.
if (!pathExists(path)) {
throw Error("The path '%s' does not exist.", path);
}
repoInfo.location = std::filesystem::absolute(path); repoInfo.location = std::filesystem::absolute(path);
} else { } else {
if (url.scheme == "file") if (url.scheme == "file")
@@ -698,7 +703,7 @@ struct GitInputScheme : InputScheme
if (auto res = cache->lookup(key)) if (auto res = cache->lookup(key))
return getIntAttr(*res, "lastModified"); return getIntAttr(*res, "lastModified");
auto lastModified = GitRepo::openRepo(repoDir, {})->getLastModified(rev); auto lastModified = GitRepo::openRepo(repoDir)->getLastModified(rev);
cache->upsert(key, {{"lastModified", lastModified}}); cache->upsert(key, {{"lastModified", lastModified}});
@@ -721,7 +726,7 @@ struct GitInputScheme : InputScheme
Activity act( Activity act(
*logger, lvlChatty, actUnknown, fmt("getting Git revision count of '%s'", repoInfo.locationToArg())); *logger, lvlChatty, actUnknown, fmt("getting Git revision count of '%s'", repoInfo.locationToArg()));
auto revCount = GitRepo::openRepo(repoDir, {})->getRevCount(rev); auto revCount = GitRepo::openRepo(repoDir)->getRevCount(rev);
cache->upsert(key, Attrs{{"revCount", revCount}}); cache->upsert(key, Attrs{{"revCount", revCount}});
@@ -732,7 +737,7 @@ struct GitInputScheme : InputScheme
{ {
auto head = std::visit( auto head = std::visit(
overloaded{ overloaded{
[&](const std::filesystem::path & path) { return GitRepo::openRepo(path, {})->getWorkdirRef(); }, [&](const std::filesystem::path & path) { return GitRepo::openRepo(path)->getWorkdirRef(); },
[&](const ParsedURL & url) { return readHeadCached(url.to_string(), shallow); }}, [&](const ParsedURL & url) { return readHeadCached(url.to_string(), shallow); }},
repoInfo.location); repoInfo.location);
if (!head) { if (!head) {
@@ -790,7 +795,7 @@ struct GitInputScheme : InputScheme
if (auto repoPath = repoInfo.getPath()) { if (auto repoPath = repoInfo.getPath()) {
repoDir = *repoPath; repoDir = *repoPath;
if (!input.getRev()) if (!input.getRev())
input.attrs.insert_or_assign("rev", GitRepo::openRepo(repoDir, {})->resolveRef(ref).gitRev()); input.attrs.insert_or_assign("rev", GitRepo::openRepo(repoDir)->resolveRef(ref).gitRev());
} else { } else {
auto repoUrl = std::get<ParsedURL>(repoInfo.location); auto repoUrl = std::get<ParsedURL>(repoInfo.location);
std::filesystem::path cacheDir = getCachePath(repoUrl.to_string(), shallow); std::filesystem::path cacheDir = getCachePath(repoUrl.to_string(), shallow);
@@ -800,7 +805,7 @@ struct GitInputScheme : InputScheme
std::filesystem::create_directories(cacheDir.parent_path()); std::filesystem::create_directories(cacheDir.parent_path());
PathLocks cacheDirLock({cacheDir.string()}); PathLocks cacheDirLock({cacheDir.string()});
auto repo = GitRepo::openRepo(cacheDir, {.create = true, .bare = true}); auto repo = GitRepo::openRepo(cacheDir, true, true);
// We need to set the origin so resolving submodule URLs works // We need to set the origin so resolving submodule URLs works
repo->setRemote("origin", repoUrl.to_string()); repo->setRemote("origin", repoUrl.to_string());
@@ -871,7 +876,7 @@ struct GitInputScheme : InputScheme
// the remainder // the remainder
} }
auto repo = GitRepo::openRepo(repoDir, {}); auto repo = GitRepo::openRepo(repoDir);
auto isShallow = repo->isShallow(); auto isShallow = repo->isShallow();
@@ -958,7 +963,7 @@ struct GitInputScheme : InputScheme
for (auto & submodule : repoInfo.workdirInfo.submodules) for (auto & submodule : repoInfo.workdirInfo.submodules)
repoInfo.workdirInfo.files.insert(submodule.path); repoInfo.workdirInfo.files.insert(submodule.path);
auto repo = GitRepo::openRepo(repoPath, {}); auto repo = GitRepo::openRepo(repoPath, false, false);
auto exportIgnore = getExportIgnoreAttr(input); auto exportIgnore = getExportIgnoreAttr(input);
@@ -998,7 +1003,7 @@ struct GitInputScheme : InputScheme
} }
if (!repoInfo.workdirInfo.isDirty) { if (!repoInfo.workdirInfo.isDirty) {
auto repo = GitRepo::openRepo(repoPath, {}); auto repo = GitRepo::openRepo(repoPath);
if (auto ref = repo->getWorkdirRef()) if (auto ref = repo->getWorkdirRef())
input.attrs.insert_or_assign("ref", *ref); input.attrs.insert_or_assign("ref", *ref);
Loaded 100 of 322 files, more files were not shown because too many files have changed in this diff. Show more