Compare commits
173
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43c713155a | ||
|
|
6f49cf9c99 | ||
|
|
74651a4ef0 | ||
|
|
0efca3705b | ||
|
|
3b0c593c03 | ||
|
|
a86c9ee229 | ||
|
|
e5a8eaae25 | ||
|
|
2dfc828f37 | ||
|
|
32d8030fe7 | ||
|
|
7055ed76a1 | ||
|
|
b36b22e837 | ||
|
|
eee30e8a6c | ||
|
|
a8149019b6 | ||
|
|
c3c0c35ae1 | ||
|
|
ef0ea6002a | ||
|
|
184bcfbc7f | ||
|
|
d79461ab84 | ||
|
|
2b5767afd3 | ||
|
|
0a0501527d | ||
|
|
d136ee333f | ||
|
|
9744d19290 | ||
|
|
30cbda8093 | ||
|
|
866747de3e | ||
|
|
e676558fa1 | ||
|
|
4c7676a530 | ||
|
|
0501ae1e49 | ||
|
|
04a86cd3c1 | ||
|
|
903fccf2fd | ||
|
|
19839dbd15 | ||
|
|
4d9efa45e2 | ||
|
|
3f1f531a25 | ||
|
|
50cc70b71e | ||
|
|
3adb146014 | ||
|
|
158efe6cc8 | ||
|
|
c9380d9736 | ||
|
|
a885a36130 | ||
|
|
2851af6784 | ||
|
|
42ddc10d92 | ||
|
|
a5ab03cb16 | ||
|
|
b4871a4a94 | ||
|
|
027bf13e18 | ||
|
|
3e3d2b7d01 | ||
|
|
1a55d733ce | ||
|
|
9328af84d3 | ||
|
|
2aba7ac90d | ||
|
|
adc17bace9 | ||
|
|
d6aebd8847 | ||
|
|
c53ac76f7b | ||
|
|
2454267de0 | ||
|
|
9572fdeb3b | ||
|
|
69d2e6eeef | ||
|
|
2870c177d6 | ||
|
|
b0169fdc5f | ||
|
|
7b08e8d20e | ||
|
|
aabe327111 | ||
|
|
ab4951588b | ||
|
|
b41101c815 | ||
|
|
cb73841205 | ||
|
|
931ca7d11a | ||
|
|
b5efc9ac56 | ||
|
|
012f429104 | ||
|
|
830dfc3b60 | ||
|
|
2968e18d37 | ||
|
|
66a379a6de | ||
|
|
1dcd12b819 | ||
|
|
2298df294b | ||
|
|
b4cd61900b | ||
|
|
2c258dd275 | ||
|
|
75bece800d | ||
|
|
582caa9d8f | ||
|
|
8a3d3b2dce | ||
|
|
56069a968b | ||
|
|
87ee4423ea | ||
|
|
c9ecc99ce5 | ||
|
|
ceb4d561fa | ||
|
|
5d58ab8042 | ||
|
|
27a8b457b8 | ||
|
|
229e97195a | ||
|
|
e3f4cef054 | ||
|
|
223d3222b3 | ||
|
|
a98f742d67 | ||
|
|
e0ceebe2ee | ||
|
|
bb0e9b20aa | ||
|
|
d7ed70841a | ||
|
|
7d1704218f | ||
|
|
44a1e7e88c | ||
|
|
ed7ebdfad3 | ||
|
|
82fa307ca6 | ||
|
|
4d9d307477 | ||
|
|
ee39380c12 | ||
|
|
47ce401222 | ||
|
|
78ac959e4c | ||
|
|
709349b118 | ||
|
|
9106a0b73a | ||
|
|
1b97d7409a | ||
|
|
ab95054e64 | ||
|
|
a5deed32f7 | ||
|
|
94723d5b72 | ||
|
|
ef8dc34bd0 | ||
|
|
bb8b50e4f3 | ||
|
|
0877680b08 | ||
|
|
e37fce3899 | ||
|
|
c1f54da018 | ||
|
|
a1efe99f5b | ||
|
|
359227ad14 | ||
|
|
e0d2cf5a89 | ||
|
|
da770a89e6 | ||
|
|
58c71ed812 | ||
|
|
c972f66475 | ||
|
|
bfc5678471 | ||
|
|
a5684b2c83 | ||
|
|
c17e66af6f | ||
|
|
661caad5bb | ||
|
|
281e3b0247 | ||
|
|
af342d8b2b | ||
|
|
7c2b240ded | ||
|
|
0e35cd6f3e | ||
|
|
a5cfab671b | ||
|
|
bd1ff9f254 | ||
|
|
036cd2a408 | ||
|
|
82bf098fbe | ||
|
|
4b3bbf8511 | ||
|
|
8736cb537d | ||
|
|
d4d0853fee | ||
|
|
aaffbc2209 | ||
|
|
8f6c5d088a | ||
|
|
d0290d342d | ||
|
|
7b050cec80 | ||
|
|
82dcbe0510 | ||
|
|
31e19b0a28 | ||
|
|
7bb2001997 | ||
|
|
5d78f74fe4 | ||
|
|
b3b137ec4a | ||
|
|
833406121c | ||
|
|
01619fbe2d | ||
|
|
075df0b446 | ||
|
|
2f6c758d3d | ||
|
|
4c7e5ce7a8 | ||
|
|
86fbaf3b14 | ||
|
|
5c3aed3e88 | ||
|
|
fcdffffa37 | ||
|
|
aeb627bebf | ||
|
|
a2567f6d7a | ||
|
|
c1e272b47d | ||
|
|
cfba4b3bf4 | ||
|
|
d761dad79c | ||
|
|
d068b82c2f | ||
|
|
8ca4d2ef08 | ||
|
|
acc3cd460d | ||
|
|
c4813b8cbc | ||
|
|
0cd1fce3c3 | ||
|
|
90eb2f759c | ||
|
|
d1e4be6fb4 | ||
|
|
29d98da636 | ||
|
|
91dc6e7fa0 | ||
|
|
b33fd1e4fb | ||
|
|
1c618a9d87 | ||
|
|
ab2abebfc3 | ||
|
|
0f132fc129 | ||
|
|
6fc6db3496 | ||
|
|
ca0bde3578 | ||
|
|
f51b537239 | ||
|
|
2b7e3e9b81 | ||
|
|
fee8454dd0 | ||
|
|
dc238ba102 | ||
|
|
fa7a5ab07a | ||
|
|
27932ae6da | ||
|
|
631d23788e | ||
|
|
4f03bfebd9 | ||
|
|
7f488dc7d3 | ||
|
|
1b2e88effd | ||
|
|
4dcf21a2f6 | ||
|
|
ff24751bdd |
No files matched your search
@@ -1,2 +1,4 @@
|
||||
# bulk initial re-formatting with clang-format
|
||||
e4f62e46088919428a68bd8014201dc8e379fed7 # !autorebase ./maintainers/format.sh --until-stable
|
||||
0e35cd6f3e27760976ead16fb45008ece0185aad # !autorebase ./maintainers/format.sh --until-stable
|
||||
# nixfmt 1.0.0
|
||||
d6aebd884790ae82c21ef2b58a010026ce757eaf # !autorebase ./maintainers/format.sh --until-stable
|
||||
@@ -4,22 +4,36 @@ inputs:
|
||||
dogfood:
|
||||
description: "Whether to use Nix installed from the latest artifact from master branch"
|
||||
required: true # Be explicit about the fact that we are using unreleased artifacts
|
||||
experimental-installer:
|
||||
description: "Whether to use the experimental installer to install Nix"
|
||||
default: false
|
||||
experimental-installer-version:
|
||||
description: "Version of the experimental installer to use. If `latest`, the newest artifact from the default branch is used."
|
||||
# TODO: This should probably be pinned to a release after https://github.com/NixOS/experimental-nix-installer/pull/49 lands in one
|
||||
default: "latest"
|
||||
extra_nix_config:
|
||||
description: "Gets appended to `/etc/nix/nix.conf` if passed."
|
||||
install_url:
|
||||
description: "URL of the Nix installer"
|
||||
required: false
|
||||
default: "https://releases.nixos.org/nix/nix-2.30.1/install"
|
||||
default: "https://releases.nixos.org/nix/nix-2.29.1/install"
|
||||
tarball_url:
|
||||
description: "URL of the Nix tarball to use with the experimental installer"
|
||||
required: false
|
||||
github_token:
|
||||
description: "Github token"
|
||||
required: true
|
||||
use_cache:
|
||||
description: "Whether to setup github actions cache (not implemented currently)"
|
||||
default: false
|
||||
required: false
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Download nix install artifact from master"
|
||||
shell: bash
|
||||
id: download-nix-installer
|
||||
if: ${{ inputs.dogfood }}
|
||||
if: inputs.dogfood == 'true'
|
||||
run: |
|
||||
RUN_ID=$(gh run list --repo "$DOGFOOD_REPO" --workflow ci.yml --branch master --status success --json databaseId --jq ".[0].databaseId")
|
||||
|
||||
@@ -37,14 +51,74 @@ runs:
|
||||
|
||||
gh run download "$RUN_ID" --repo "$DOGFOOD_REPO" -n "$INSTALLER_ARTIFACT" -D "$INSTALLER_DOWNLOAD_DIR"
|
||||
echo "installer-path=file://$INSTALLER_DOWNLOAD_DIR" >> "$GITHUB_OUTPUT"
|
||||
TARBALL_PATH="$(find "$INSTALLER_DOWNLOAD_DIR" -name 'nix*.tar.xz' -print | head -n 1)"
|
||||
echo "tarball-path=file://$TARBALL_PATH" >> "$GITHUB_OUTPUT"
|
||||
|
||||
echo "::notice ::Dogfooding Nix installer from master (https://github.com/$DOGFOOD_REPO/actions/runs/$RUN_ID)"
|
||||
env:
|
||||
GH_TOKEN: ${{ inputs.github_token }}
|
||||
DOGFOOD_REPO: "NixOS/nix"
|
||||
- name: "Gather system info for experimental installer"
|
||||
shell: bash
|
||||
if: ${{ inputs.experimental-installer == 'true' }}
|
||||
run: |
|
||||
echo "::notice Using experimental installer from $EXPERIMENTAL_INSTALLER_REPO (https://github.com/$EXPERIMENTAL_INSTALLER_REPO)"
|
||||
|
||||
if [ "$RUNNER_OS" == "Linux" ]; then
|
||||
EXPERIMENTAL_INSTALLER_SYSTEM="linux"
|
||||
echo "EXPERIMENTAL_INSTALLER_SYSTEM=$EXPERIMENTAL_INSTALLER_SYSTEM" >> "$GITHUB_ENV"
|
||||
elif [ "$RUNNER_OS" == "macOS" ]; then
|
||||
EXPERIMENTAL_INSTALLER_SYSTEM="darwin"
|
||||
echo "EXPERIMENTAL_INSTALLER_SYSTEM=$EXPERIMENTAL_INSTALLER_SYSTEM" >> "$GITHUB_ENV"
|
||||
else
|
||||
echo "::error ::Unsupported RUNNER_OS: $RUNNER_OS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$RUNNER_ARCH" == "X64" ]; then
|
||||
EXPERIMENTAL_INSTALLER_ARCH=x86_64
|
||||
echo "EXPERIMENTAL_INSTALLER_ARCH=$EXPERIMENTAL_INSTALLER_ARCH" >> "$GITHUB_ENV"
|
||||
elif [ "$RUNNER_ARCH" == "ARM64" ]; then
|
||||
EXPERIMENTAL_INSTALLER_ARCH=aarch64
|
||||
echo "EXPERIMENTAL_INSTALLER_ARCH=$EXPERIMENTAL_INSTALLER_ARCH" >> "$GITHUB_ENV"
|
||||
else
|
||||
echo "::error ::Unsupported RUNNER_ARCH: $RUNNER_ARCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "EXPERIMENTAL_INSTALLER_ARTIFACT=nix-installer-$EXPERIMENTAL_INSTALLER_ARCH-$EXPERIMENTAL_INSTALLER_SYSTEM" >> "$GITHUB_ENV"
|
||||
env:
|
||||
EXPERIMENTAL_INSTALLER_REPO: "NixOS/experimental-nix-installer"
|
||||
- name: "Download latest experimental installer"
|
||||
shell: bash
|
||||
id: download-latest-experimental-installer
|
||||
if: ${{ inputs.experimental-installer == 'true' && inputs.experimental-installer-version == 'latest' }}
|
||||
run: |
|
||||
RUN_ID=$(gh run list --repo "$EXPERIMENTAL_INSTALLER_REPO" --workflow ci.yml --branch main --status success --json databaseId --jq ".[0].databaseId")
|
||||
|
||||
EXPERIMENTAL_INSTALLER_DOWNLOAD_DIR="$GITHUB_WORKSPACE/$EXPERIMENTAL_INSTALLER_ARTIFACT"
|
||||
mkdir -p "$EXPERIMENTAL_INSTALLER_DOWNLOAD_DIR"
|
||||
|
||||
gh run download "$RUN_ID" --repo "$EXPERIMENTAL_INSTALLER_REPO" -n "$EXPERIMENTAL_INSTALLER_ARTIFACT" -D "$EXPERIMENTAL_INSTALLER_DOWNLOAD_DIR"
|
||||
# Executable permissions are lost in artifacts
|
||||
find $EXPERIMENTAL_INSTALLER_DOWNLOAD_DIR -type f -exec chmod +x {} +
|
||||
echo "installer-path=$EXPERIMENTAL_INSTALLER_DOWNLOAD_DIR" >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
GH_TOKEN: ${{ inputs.github_token }}
|
||||
EXPERIMENTAL_INSTALLER_REPO: "NixOS/experimental-nix-installer"
|
||||
- uses: cachix/install-nix-action@c134e4c9e34bac6cab09cf239815f9339aaaf84e # v31.5.1
|
||||
if: ${{ inputs.experimental-installer != 'true' }}
|
||||
with:
|
||||
# Ternary operator in GHA: https://www.github.com/actions/runner/issues/409#issuecomment-752775072
|
||||
install_url: ${{ inputs.dogfood && format('{0}/install', steps.download-nix-installer.outputs.installer-path) || inputs.install_url }}
|
||||
install_options: ${{ inputs.dogfood && format('--tarball-url-prefix {0}', steps.download-nix-installer.outputs.installer-path) || '' }}
|
||||
install_url: ${{ inputs.dogfood == 'true' && format('{0}/install', steps.download-nix-installer.outputs.installer-path) || inputs.install_url }}
|
||||
install_options: ${{ inputs.dogfood == 'true' && format('--tarball-url-prefix {0}', steps.download-nix-installer.outputs.installer-path) || '' }}
|
||||
extra_nix_config: ${{ inputs.extra_nix_config }}
|
||||
- uses: DeterminateSystems/nix-installer-action@786fff0690178f1234e4e1fe9b536e94f5433196 # v20
|
||||
if: ${{ inputs.experimental-installer == 'true' }}
|
||||
with:
|
||||
diagnostic-endpoint: ""
|
||||
# TODO: It'd be nice to use `artifacts.nixos.org` for both of these, maybe through an `/experimental-installer/latest` endpoint? or `/commit/<hash>`?
|
||||
local-root: ${{ inputs.experimental-installer-version == 'latest' && steps.download-latest-experimental-installer.outputs.installer-path || '' }}
|
||||
source-url: ${{ inputs.experimental-installer-version != 'latest' && 'https://artifacts.nixos.org/experimental-installer/tag/${{ inputs.experimental-installer-version }}/${{ env.EXPERIMENTAL_INSTALLER_ARTIFACT }}' || '' }}
|
||||
nix-package-url: ${{ inputs.dogfood == 'true' && steps.download-nix-installer.outputs.tarball-path || (inputs.tarball_url || '') }}
|
||||
extra-conf: ${{ inputs.extra_nix_config }}
|
||||
+15
-81
@@ -15,10 +15,11 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- uses: ./.github/actions/install-nix-action
|
||||
with:
|
||||
dogfood: true
|
||||
dogfood: false
|
||||
extra_nix_config:
|
||||
experimental-features = nix-command flakes
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
use_cache: false
|
||||
- run: nix flake show --all-systems --json
|
||||
|
||||
tests:
|
||||
@@ -42,12 +43,11 @@ jobs:
|
||||
- uses: ./.github/actions/install-nix-action
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
dogfood: true
|
||||
dogfood: false
|
||||
# The sandbox would otherwise be disabled by default on Darwin
|
||||
extra_nix_config: |
|
||||
sandbox = true
|
||||
max-jobs = 1
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
# Since ubuntu 22.30, unprivileged usernamespaces are no longer allowed to map to the root user:
|
||||
# https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces
|
||||
- run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
|
||||
@@ -99,84 +99,20 @@ 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 --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 Docker secrets present for installer tests
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
docker: ${{ steps.secret.outputs.docker }}
|
||||
steps:
|
||||
- name: Check for secrets
|
||||
id: secret
|
||||
env:
|
||||
_DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }}
|
||||
run: |
|
||||
echo "::set-output name=docker::${{ env._DOCKER_SECRETS != '' }}"
|
||||
|
||||
docker_push_image:
|
||||
needs: [tests, vm_tests, check_secrets]
|
||||
name: Push docker image to DockerHub and GHCR
|
||||
needs: [tests, vm_tests]
|
||||
if: github.event_name == 'push' && github.ref_name == 'master'
|
||||
uses: ./.github/workflows/docker-push.yml
|
||||
with:
|
||||
ref: ${{ github.sha }}
|
||||
is_master: true
|
||||
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:
|
||||
- name: Check for secrets
|
||||
id: secret
|
||||
env:
|
||||
_DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }}
|
||||
run: |
|
||||
echo "::set-output name=docker::${{ env._DOCKER_SECRETS != '' }}"
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
install_url: https://releases.nixos.org/nix/nix-2.20.3/install
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
- run: echo NIX_VERSION="$(nix --experimental-features 'nix-command flakes' eval .\#nix.version | tr -d \")" >> $GITHUB_ENV
|
||||
- run: nix --experimental-features 'nix-command flakes' 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
|
||||
secrets:
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
vm_tests:
|
||||
runs-on: ubuntu-24.04
|
||||
@@ -184,11 +120,10 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/install-nix-action
|
||||
with:
|
||||
dogfood: true
|
||||
dogfood: false
|
||||
extra_nix_config:
|
||||
experimental-features = nix-command flakes
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
- run: |
|
||||
nix build -L \
|
||||
.#hydraJobs.tests.functional_user \
|
||||
@@ -215,9 +150,8 @@ jobs:
|
||||
path: flake-regressions/tests
|
||||
- uses: ./.github/actions/install-nix-action
|
||||
with:
|
||||
dogfood: true
|
||||
dogfood: false
|
||||
extra_nix_config:
|
||||
experimental-features = nix-command flakes
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
- run: nix build -L --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh
|
||||
@@ -0,0 +1,101 @@
|
||||
name: "Push Docker Image"
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
ref:
|
||||
description: "Git ref to build the docker image from"
|
||||
required: true
|
||||
type: string
|
||||
is_master:
|
||||
description: "Whether run from master branch"
|
||||
required: true
|
||||
type: boolean
|
||||
secrets:
|
||||
DOCKERHUB_USERNAME:
|
||||
required: true
|
||||
DOCKERHUB_TOKEN:
|
||||
required: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
# 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
|
||||
|
||||
push:
|
||||
name: Push docker image to DockerHub and GHCR
|
||||
needs: [check_secrets]
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
if: needs.check_secrets.outputs.docker == 'true'
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ inputs.ref }}
|
||||
- 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
|
||||
# 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@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Push to Docker Hub
|
||||
env:
|
||||
IS_MASTER: ${{ inputs.is_master }}
|
||||
DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_USERNAME }}/nix
|
||||
run: |
|
||||
docker tag nix:$NIX_VERSION $DOCKERHUB_REPO:$NIX_VERSION
|
||||
docker push $DOCKERHUB_REPO:$NIX_VERSION
|
||||
if [ "$IS_MASTER" = "true" ]; then
|
||||
docker tag nix:$NIX_VERSION $DOCKERHUB_REPO:master
|
||||
docker push $DOCKERHUB_REPO:master
|
||||
fi
|
||||
# Push to GitHub Container Registry as well
|
||||
- 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: Push to GHCR
|
||||
env:
|
||||
IS_MASTER: ${{ inputs.is_master }}
|
||||
run: |
|
||||
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/nix
|
||||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
|
||||
|
||||
docker tag nix:$NIX_VERSION $IMAGE_ID:$NIX_VERSION
|
||||
docker push $IMAGE_ID:$NIX_VERSION
|
||||
if [ "$IS_MASTER" = "true" ]; then
|
||||
docker tag nix:$NIX_VERSION $IMAGE_ID:master
|
||||
docker push $IMAGE_ID:master
|
||||
fi
|
||||
@@ -0,0 +1,80 @@
|
||||
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: Disable containerd image store
|
||||
run: |
|
||||
# Docker 28+ defaults to the containerd image store, which
|
||||
# pushes layers uncompressed instead of gzip. OCI clients
|
||||
# that only support gzip (e.g. go-containerregistry) fail
|
||||
# with "gzip: invalid header". Disabling the containerd
|
||||
# snapshotter restores the classic storage driver, which
|
||||
# preserves gzip-compressed layers through the
|
||||
# `docker load` / `docker push` pipeline.
|
||||
echo '{"features":{"containerd-snapshotter":false}}' | sudo tee /etc/docker/daemon.json > /dev/null
|
||||
sudo systemctl restart docker
|
||||
- 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' || '' }}
|
||||
@@ -139,25 +139,3 @@ pull_request_rules:
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
|
||||
- name: backport patches to 2.29
|
||||
conditions:
|
||||
- label=backport 2.29-maintenance
|
||||
actions:
|
||||
backport:
|
||||
branches:
|
||||
- "2.29-maintenance"
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
|
||||
- name: backport patches to 2.30
|
||||
conditions:
|
||||
- label=backport 2.30-maintenance
|
||||
actions:
|
||||
backport:
|
||||
branches:
|
||||
- "2.30-maintenance"
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
+10
-3
@@ -24,8 +24,15 @@ def map_contents_recursively(transformer):
|
||||
def process_command:
|
||||
.[0] as $context |
|
||||
.[1] as $body |
|
||||
$body + {
|
||||
sections: $body.sections | map(map_contents_recursively(if $context.renderer == "html" then transform_anchors_html else transform_anchors_strip end)),
|
||||
};
|
||||
# mdbook 0.5.x uses 'items' instead of 'sections'
|
||||
if $body.items then
|
||||
$body + {
|
||||
items: $body.items | map(map_contents_recursively(if $context.renderer == "html" then transform_anchors_html else transform_anchors_strip end)),
|
||||
}
|
||||
else
|
||||
$body + {
|
||||
sections: $body.sections | map(map_contents_recursively(if $context.renderer == "html" then transform_anchors_html else transform_anchors_strip end)),
|
||||
}
|
||||
end;
|
||||
|
||||
process_command
|
||||
@@ -23,12 +23,3 @@ renderers = ["html"]
|
||||
command = "jq --from-file ./anchors.jq"
|
||||
|
||||
[output.markdown]
|
||||
|
||||
[output.linkcheck]
|
||||
# no Internet during the build (in the sandbox)
|
||||
follow-web-links = false
|
||||
|
||||
# mdbook-linkcheck does not understand [foo]{#bar} style links, resulting in
|
||||
# excessive "Potential incomplete link" warnings. No other kind of warning was
|
||||
# produced at the time of writing.
|
||||
warning-policy = "ignore"
|
||||
@@ -8,7 +8,6 @@ nix = find_program('nix', native : true)
|
||||
|
||||
mdbook = find_program('mdbook', native : true)
|
||||
bash = find_program('bash', native : true)
|
||||
rsync = find_program('rsync', required: true, native: true)
|
||||
|
||||
pymod = import('python')
|
||||
python = pymod.find_installation('python3')
|
||||
@@ -85,7 +84,7 @@ manual = custom_target(
|
||||
@0@ @INPUT0@ @CURRENT_SOURCE_DIR@ > @DEPFILE@
|
||||
@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
|
||||
@4@ -r --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
|
||||
rsync -r --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
|
||||
(cd @2@; RUST_LOG=warn @1@ build -d @2@ 3>&2 2>&1 1>&3) | { grep -Fv "because fragment resolution isn't implemented" || :; } 3>&2 2>&1 1>&3
|
||||
rm -rf @2@/manual
|
||||
mv @2@/html @2@/manual
|
||||
@@ -95,7 +94,6 @@ manual = custom_target(
|
||||
mdbook.full_path(),
|
||||
meson.current_build_dir(),
|
||||
meson.project_version(),
|
||||
rsync.full_path(),
|
||||
),
|
||||
],
|
||||
input : [
|
||||
@@ -248,11 +246,11 @@ nix3_manpages = [
|
||||
'nix3-nar',
|
||||
'nix3-path-info',
|
||||
'nix3-print-dev-env',
|
||||
'nix3-profile',
|
||||
'nix3-profile-add',
|
||||
'nix3-profile-diff-closures',
|
||||
'nix3-profile-history',
|
||||
'nix3-profile-install',
|
||||
'nix3-profile-list',
|
||||
'nix3-profile',
|
||||
'nix3-profile-remove',
|
||||
'nix3-profile-rollback',
|
||||
'nix3-profile-upgrade',
|
||||
|
||||
+16
-19
@@ -6,7 +6,6 @@
|
||||
ninja,
|
||||
lowdown-unsandboxed,
|
||||
mdbook,
|
||||
mdbook-linkcheck,
|
||||
jq,
|
||||
python3,
|
||||
rsync,
|
||||
@@ -46,24 +45,22 @@ mkMesonDerivation (finalAttrs: {
|
||||
];
|
||||
|
||||
# Hack for sake of the dev shell
|
||||
passthru.externalNativeBuildInputs =
|
||||
[
|
||||
meson
|
||||
ninja
|
||||
(lib.getBin lowdown-unsandboxed)
|
||||
mdbook
|
||||
mdbook-linkcheck
|
||||
jq
|
||||
python3
|
||||
rsync
|
||||
changelog-d
|
||||
]
|
||||
++ lib.optionals (!officialRelease) [
|
||||
# When not an official release, we likely have changelog entries that have
|
||||
# yet to be rendered.
|
||||
# When released, these are rendered into a committed file to save a dependency.
|
||||
changelog-d
|
||||
];
|
||||
passthru.externalNativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
(lib.getBin lowdown-unsandboxed)
|
||||
mdbook
|
||||
jq
|
||||
python3
|
||||
rsync
|
||||
changelog-d
|
||||
]
|
||||
++ lib.optionals (!officialRelease) [
|
||||
# When not an official release, we likely have changelog entries that have
|
||||
# yet to be rendered.
|
||||
# When released, these are rendered into a committed file to save a dependency.
|
||||
changelog-d
|
||||
];
|
||||
|
||||
nativeBuildInputs = finalAttrs.passthru.externalNativeBuildInputs ++ [
|
||||
nix-cli
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
---
|
||||
synopsis: "`build-cores = 0` now auto-detects CPU cores"
|
||||
prs: [13402]
|
||||
---
|
||||
|
||||
When `build-cores` is set to `0`, nix now automatically detects the number of available CPU cores and passes this value via `NIX_BUILD_CORES`, instead of passing `0` directly. This matches the behavior when `build-cores` is unset. This prevents the builder from having to detect the number of cores.
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
synopsis: Non-flake inputs now contain a `sourceInfo` attribute
|
||||
issues: 13164
|
||||
prs: 13170
|
||||
---
|
||||
|
||||
Flakes have always a `sourceInfo` attribute which describes the source of the flake.
|
||||
The `sourceInfo.outPath` is often identical to the flake's `outPath`, however it can differ when the flake is located in a subdirectory of its source.
|
||||
|
||||
Non-flake inputs (i.e. inputs with `flake = false`) can also be located at some path _within_ a wider source.
|
||||
This usually happens when defining a relative path input within the same source as the parent flake, e.g. `inputs.foo.url = ./some-file.nix`.
|
||||
Such relative inputs will now inherit their parent's `sourceInfo`.
|
||||
|
||||
This also means it is now possible to use `?dir=subdir` on non-flake inputs.
|
||||
|
||||
This iterates on the work done in 2.26 to improve relative path support ([#10089](https://github.com/NixOS/nix/pull/10089)),
|
||||
and resolves a regression introduced in 2.28 relating to nested relative path inputs ([#13164](https://github.com/NixOS/nix/issues/13164)).
|
||||
@@ -57,7 +57,6 @@
|
||||
- [Tuning Cores and Jobs](advanced-topics/cores-vs-jobs.md)
|
||||
- [Verifying Build Reproducibility](advanced-topics/diff-hook.md)
|
||||
- [Using the `post-build-hook`](advanced-topics/post-build-hook.md)
|
||||
- [Evaluation profiler](advanced-topics/eval-profiler.md)
|
||||
- [Command Reference](command-ref/index.md)
|
||||
- [Common Options](command-ref/opt-common.md)
|
||||
- [Common Environment Variables](command-ref/env-common.md)
|
||||
@@ -137,7 +136,6 @@
|
||||
- [Contributing](development/contributing.md)
|
||||
- [Releases](release-notes/index.md)
|
||||
{{#include ./SUMMARY-rl-next.md}}
|
||||
- [Release 2.30 (2025-07-07)](release-notes/rl-2.30.md)
|
||||
- [Release 2.29 (2025-05-14)](release-notes/rl-2.29.md)
|
||||
- [Release 2.28 (2025-04-02)](release-notes/rl-2.28.md)
|
||||
- [Release 2.27 (2025-03-03)](release-notes/rl-2.27.md)
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
# Using the `eval-profiler`
|
||||
|
||||
Nix evaluator supports [evaluation](@docroot@/language/evaluation.md)
|
||||
[profiling](<https://en.wikipedia.org/wiki/Profiling_(computer_programming)>)
|
||||
compatible with `flamegraph.pl`. The profiler samples the nix
|
||||
function call stack at regular intervals. It can be enabled with the
|
||||
[`eval-profiler`](@docroot@/command-ref/conf-file.md#conf-eval-profiler)
|
||||
setting:
|
||||
|
||||
```console
|
||||
$ nix-instantiate "<nixpkgs>" -A hello --eval-profiler flamegraph
|
||||
```
|
||||
|
||||
Stack sampling frequency and the output file path can be configured with
|
||||
[`eval-profile-file`](@docroot@/command-ref/conf-file.md#conf-eval-profile-file)
|
||||
and [`eval-profiler-frequency`](@docroot@/command-ref/conf-file.md#conf-eval-profiler-frequency).
|
||||
By default the collected profile is saved to `nix.profile` file in the current working directory.
|
||||
|
||||
The collected profile can be directly consumed by `flamegraph.pl`:
|
||||
|
||||
```console
|
||||
$ flamegraph.pl nix.profile > flamegraph.svg
|
||||
```
|
||||
|
||||
The line information in the profile contains the location of the [call
|
||||
site](https://en.wikipedia.org/wiki/Call_site) position and the name of the
|
||||
function being called (when available). For example:
|
||||
|
||||
```
|
||||
/nix/store/x9wnkly3k1gkq580m90jjn32q9f05q2v-source/pkgs/top-level/default.nix:167:5:primop import
|
||||
```
|
||||
|
||||
Here `import` primop is called at `/nix/store/x9wnkly3k1gkq580m90jjn32q9f05q2v-source/pkgs/top-level/default.nix:167:5`.
|
||||
@@ -215,14 +215,18 @@ nix build .#nix-everything-x86_64-w64-mingw32
|
||||
|
||||
For historic reasons and backward-compatibility, some CPU and OS identifiers are translated as follows:
|
||||
|
||||
| `config.guess` | Nix |
|
||||
|----------------------------|---------------------|
|
||||
| `amd64` | `x86_64` |
|
||||
| `i*86` | `i686` |
|
||||
| `arm6` | `arm6l` |
|
||||
| `arm7` | `arm7l` |
|
||||
| `linux-gnu*` | `linux` |
|
||||
| `linux-musl*` | `linux` |
|
||||
| `host_machine.cpu_family()` | `host_machine.endian()` | Nix |
|
||||
|-----------------------------|-------------------------|---------------------|
|
||||
| `x86` | | `i686` |
|
||||
| `arm` | | `host_machine.cpu()`|
|
||||
| `ppc` | `little` | `powerpcle` |
|
||||
| `ppc64` | `little` | `powerpc64le` |
|
||||
| `ppc` | `big` | `powerpc` |
|
||||
| `ppc64` | `big` | `powerpc64` |
|
||||
| `mips` | `little` | `mipsel` |
|
||||
| `mips64` | `little` | `mips64el` |
|
||||
| `mips` | `big` | `mips` |
|
||||
| `mips64` | `big` | `mips64` |
|
||||
|
||||
## Compilation environments
|
||||
|
||||
|
||||
@@ -31,22 +31,9 @@
|
||||
|
||||
The industry term for storage and retrieval systems using [content addressing](#gloss-content-address). A Nix store also has [input addressing](#gloss-input-addressed-store-object), and metadata.
|
||||
|
||||
- [derivation]{#gloss-derivation}
|
||||
|
||||
A derivation can be thought of as a [pure function](https://en.wikipedia.org/wiki/Pure_function) that produces new [store objects][store object] from existing store objects.
|
||||
|
||||
Derivations are implemented as [operating system processes that run in a sandbox](@docroot@/store/building.md#builder-execution).
|
||||
This sandbox by default only allows reading from store objects specified as inputs, and only allows writing to designated [outputs][output] to be [captured as store objects](@docroot@/store/building.md#processing-outputs).
|
||||
|
||||
A derivation is typically specified as a [derivation expression] in the [Nix language], and [instantiated][instantiate] to a [store derivation].
|
||||
There are multiple ways of obtaining store objects from store derivatons, collectively called [realisation][realise].
|
||||
|
||||
[derivation]: #gloss-derivation
|
||||
|
||||
- [store derivation]{#gloss-store-derivation}
|
||||
|
||||
A [derivation] represented as a [store object].
|
||||
|
||||
A single build task.
|
||||
See [Store Derivation](@docroot@/store/derivation/index.md#store-derivation) for details.
|
||||
|
||||
[store derivation]: #gloss-store-derivation
|
||||
@@ -70,7 +57,10 @@
|
||||
|
||||
- [derivation expression]{#gloss-derivation-expression}
|
||||
|
||||
A description of a [store derivation] using the [`derivation` primitive](./language/derivations.md) in the [Nix language].
|
||||
A description of a [store derivation] in the Nix language.
|
||||
The output(s) of a derivation are store objects.
|
||||
Derivations are typically specified in Nix expressions using the [`derivation` primitive](./language/derivations.md).
|
||||
These are translated into store layer *derivations* (implicitly by `nix-env` and `nix-build`, or explicitly by `nix-instantiate`).
|
||||
|
||||
[derivation expression]: #gloss-derivation-expression
|
||||
|
||||
|
||||
@@ -53,13 +53,23 @@ Derivations can declare some infrequently used optional attributes.
|
||||
|
||||
- [`__structuredAttrs`]{#adv-attr-structuredAttrs}\
|
||||
If the special attribute `__structuredAttrs` is set to `true`, the other derivation
|
||||
attributes are serialised into a file in JSON format.
|
||||
attributes are serialised into a file in JSON format. The environment variable
|
||||
`NIX_ATTRS_JSON_FILE` points to the exact location of that file both in a build
|
||||
and a [`nix-shell`](../command-ref/nix-shell.md). This obviates the need for
|
||||
[`passAsFile`](#adv-attr-passAsFile) since JSON files have no size restrictions,
|
||||
unlike process environments.
|
||||
|
||||
This obviates the need for [`passAsFile`](#adv-attr-passAsFile) since JSON files have no size restrictions, unlike process environments.
|
||||
It also makes it possible to tweak derivation settings in a structured way;
|
||||
see [`outputChecks`](#adv-attr-outputChecks) for example.
|
||||
It also makes it possible to tweak derivation settings in a structured way; see
|
||||
[`outputChecks`](#adv-attr-outputChecks) for example.
|
||||
|
||||
See the [corresponding section in the derivation page](@docroot@/store/derivation/index.md#structured-attrs) for further details.
|
||||
As a convenience to Bash builders,
|
||||
Nix writes a script that initialises shell variables
|
||||
corresponding to all attributes that are representable in Bash. The
|
||||
environment variable `NIX_ATTRS_SH_FILE` points to the exact
|
||||
location of the script, both in a build and a
|
||||
[`nix-shell`](../command-ref/nix-shell.md). This includes non-nested
|
||||
(associative) arrays. For example, the attribute `hardening.format = true`
|
||||
ends up as the Bash associative array element `${hardening[format]}`.
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Nix Language
|
||||
|
||||
The Nix language is designed for conveniently creating and composing [derivations](@docroot@/glossary.md#gloss-derivation) – precise descriptions of how contents of existing files are used to derive new files.
|
||||
The Nix language is designed for conveniently creating and composing *derivations* – precise descriptions of how contents of existing files are used to derive new files.
|
||||
|
||||
> **Tip**
|
||||
>
|
||||
|
||||
@@ -225,8 +225,8 @@ passed in first , e.g.,
|
||||
|
||||
```nix
|
||||
let add = { __functor = self: x: x + self.x; };
|
||||
inc = add // { x = 1; }; # inc is { x = 1; __functor = (...) }
|
||||
in inc 1 # equivalent of `add.__functor add 1` i.e. `1 + self.x`
|
||||
inc = add // { x = 1; };
|
||||
in inc 1
|
||||
```
|
||||
|
||||
evaluates to `2`. This can be used to attach metadata to a function
|
||||
|
||||
@@ -12,7 +12,7 @@ $ ln -s /nix/store/d718ef...-foo /nix/var/nix/gcroots/bar
|
||||
That is, after this command, the garbage collector will not remove
|
||||
`/nix/store/d718ef...-foo` or any of its dependencies.
|
||||
|
||||
Subdirectories of `prefix/nix/var/nix/gcroots` are searched
|
||||
recursively. Symlinks to store paths count as roots. Symlinks to
|
||||
non-store paths are ignored, unless the non-store path is itself a
|
||||
symlink to a store path.
|
||||
Subdirectories of `prefix/nix/var/nix/gcroots` are also searched for
|
||||
symlinks. Symlinks to non-store paths are followed and searched for
|
||||
roots, but symlinks to non-store paths *inside* the paths reached in
|
||||
that way are not followed to prevent infinite recursion.
|
||||
@@ -91,7 +91,3 @@ is a JSON object with the following fields:
|
||||
|
||||
* `env`:
|
||||
The environment passed to the `builder`.
|
||||
|
||||
* `structuredAttrs`:
|
||||
[Strucutured Attributes](@docroot@/store/derivation/index.md#structured-attrs), only defined if the derivation contains them.
|
||||
Structured attributes are JSON, and thus embedded as-is.
|
||||
@@ -269,7 +269,7 @@
|
||||
e.g. `--warn-large-path-threshold 100M`.
|
||||
|
||||
|
||||
## Contributors
|
||||
# Contributors
|
||||
|
||||
This release was made possible by the following 43 contributors:
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
`<nix/fetchurl.nix>` is also known as the builtin derivation builder `builtin:fetchurl`. It's not to be confused with the evaluation-time function `builtins.fetchurl`, which was not affected by this issue.
|
||||
|
||||
|
||||
## Contributors
|
||||
# Contributors
|
||||
|
||||
This release was made possible by the following 58 contributors:
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
- Evaluation caching now works for dirty Git workdirs [#11992](https://github.com/NixOS/nix/pull/11992)
|
||||
|
||||
## Contributors
|
||||
# Contributors
|
||||
|
||||
This release was made possible by the following 45 contributors:
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
blake3-34P4p+iZXcbbyB1i4uoF7eWCGcZHjmaRn6Y7QdynLwU=
|
||||
```
|
||||
|
||||
## Contributors
|
||||
# Contributors
|
||||
|
||||
This release was made possible by the following 21 contributors:
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ This completes the infrastructure overhaul for the [RFC 132](https://github.com/
|
||||
Although this change is not as critical, we figured it would be good to do this API change at the same time, also.
|
||||
Also note that we try to keep the C API compatible, but we decided to break this function because it was young and likely not in widespread use yet. This frees up time to make important progress on the rest of the C API.
|
||||
|
||||
## Contributors
|
||||
# Contributors
|
||||
|
||||
This earlier-than-usual release was made possible by the following 16 contributors:
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ This fact is counterbalanced by the fact that most of those changes are bug fixe
|
||||
This in particular prevents parts of GCC 14's diagnostics from being improperly filtered away.
|
||||
|
||||
|
||||
## Contributors
|
||||
# Contributors
|
||||
|
||||
|
||||
This release was made possible by the following 40 contributors:
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
# Release 2.30.0 (2025-07-07)
|
||||
|
||||
## Backward-incompatible changes and deprecations
|
||||
|
||||
- [`build-dir`] no longer defaults to `$TMPDIR`
|
||||
|
||||
The directory in which temporary build directories are created no longer defaults
|
||||
to `TMPDIR` or `/tmp`, to avoid builders making their directories
|
||||
world-accessible. This behavior allowed escaping the build sandbox and can
|
||||
cause build impurities even when not used maliciously. We now default to `builds`
|
||||
in `NIX_STATE_DIR` (which is `/nix/var/nix/builds` in the default configuration).
|
||||
|
||||
- Deprecate manually making structured attrs using the `__json` attribute [#13220](https://github.com/NixOS/nix/pull/13220)
|
||||
|
||||
The proper way to create a derivation using [structured attrs] in the Nix language is by using `__structuredAttrs = true` with [`builtins.derivation`].
|
||||
However, by exploiting how structured attrs are implementated, it has also been possible to create them by setting the `__json` environment variable to a serialized JSON string.
|
||||
This sneaky alternative method is now deprecated, and may be disallowed in future versions of Nix.
|
||||
|
||||
[structured attrs]: @docroot@/language/advanced-attributes.md#adv-attr-structuredAttrs
|
||||
[`builtins.derivation`]: @docroot@/language/builtins.html#builtins-derivation
|
||||
|
||||
- Rename `nix profile install` to [`nix profile add`] [#13224](https://github.com/NixOS/nix/pull/13224)
|
||||
|
||||
The command `nix profile install` has been renamed to [`nix profile add`] (though the former is still available as an alias). This is because the verb "add" is a better antonym for the verb "remove" (i.e. `nix profile remove`). Nix also does not have install hooks or general behavior often associated with "installing".
|
||||
|
||||
## Performance improvements
|
||||
|
||||
This release has a number performance improvements, in particular:
|
||||
|
||||
- Reduce the size of value from 24 to 16 bytes [#13407](https://github.com/NixOS/nix/pull/13407)
|
||||
|
||||
This shaves off a very significant amount of memory used for evaluation (~20% percent reduction in maximum heap size and ~17% in total bytes).
|
||||
|
||||
## Features
|
||||
|
||||
- Add [stack sampling evaluation profiler] [#13220](https://github.com/NixOS/nix/pull/13220)
|
||||
|
||||
The Nix evaluator now supports [stack sampling evaluation profiling](@docroot@/advanced-topics/eval-profiler.md) via the [`--eval-profiler flamegraph`] setting.
|
||||
It outputs collapsed call stack information to the file specified by
|
||||
[`--eval-profile-file`] (`nix.profile` by default) in a format directly consumable
|
||||
by `flamegraph.pl` and compatible tools like [speedscope](https://speedscope.app/).
|
||||
Sampling frequency can be configured via [`--eval-profiler-frequency`] (99 Hz by default).
|
||||
|
||||
Unlike the existing [`--trace-function-calls`], this profiler includes the name of the function
|
||||
being called when it's available.
|
||||
|
||||
- [`nix repl`] prints which variables were loaded [#11406](https://github.com/NixOS/nix/pull/11406)
|
||||
|
||||
Instead of `Added <n> variables` it now prints the first 10 variables that were added to the global scope.
|
||||
|
||||
- `nix flake archive`: Add [`--no-check-sigs`] option [#13277](https://github.com/NixOS/nix/pull/13277)
|
||||
|
||||
This is useful when using [`nix flake archive`] with the destination set to a remote store.
|
||||
|
||||
- Emit warnings for IFDs with [`trace-import-from-derivation`] option [#13279](https://github.com/NixOS/nix/pull/13279)
|
||||
|
||||
While we have the setting [`allow-import-from-derivation`] to deny import-from-derivation (IFD), sometimes users would like to observe IFDs during CI processes to gradually phase out the idiom. The new setting `trace-import-from-derivation`, when set, logs a simple warning to the console.
|
||||
|
||||
- `json-log-path` setting [#13003](https://github.com/NixOS/nix/pull/13003)
|
||||
|
||||
New setting [`json-log-path`] that sends a copy of all Nix log messages (in JSON format) to a file or Unix domain socket.
|
||||
|
||||
- Non-flake inputs now contain a `sourceInfo` attribute [#13164](https://github.com/NixOS/nix/issues/13164) [#13170](https://github.com/NixOS/nix/pull/13170)
|
||||
|
||||
Flakes have always had a `sourceInfo` attribute which describes the source of the flake.
|
||||
The `sourceInfo.outPath` is often identical to the flake's `outPath`. However, it can differ when the flake is located in a subdirectory of its source.
|
||||
|
||||
Non-flake inputs (i.e. inputs with [`flake = false`]) can also be located at some path _within_ a wider source.
|
||||
This usually happens when defining a relative path input within the same source as the parent flake, e.g. `inputs.foo.url = ./some-file.nix`.
|
||||
Such relative inputs will now inherit their parent's `sourceInfo`.
|
||||
|
||||
This also means it is now possible to use `?dir=subdir` on non-flake inputs.
|
||||
|
||||
This iterates on the work done in 2.26 to improve relative path support ([#10089](https://github.com/NixOS/nix/pull/10089)),
|
||||
and resolves a regression introduced in 2.28 relating to nested relative path inputs ([#13164](https://github.com/NixOS/nix/issues/13164)).
|
||||
|
||||
## Miscellaneous changes
|
||||
|
||||
- [`builtins.sort`] uses PeekSort [#12623](https://github.com/NixOS/nix/pull/12623)
|
||||
|
||||
Previously it used libstdc++'s `std::stable_sort()`. However, that implementation is not reliable if the user-supplied comparison function is not a strict weak ordering.
|
||||
|
||||
- Revert incomplete closure mixed download and build feature [#77](https://github.com/NixOS/nix/issues/77) [#12628](https://github.com/NixOS/nix/issues/12628) [#13176](https://github.com/NixOS/nix/pull/13176)
|
||||
|
||||
Since Nix 1.3 ([commit `299141e`] in 2013) Nix has attempted to mix together upstream fresh builds and downstream substitutions when remote substuters contain an "incomplete closure" (have some store objects, but not the store objects they reference).
|
||||
This feature is now removed.
|
||||
|
||||
In the worst case, removing this feature could cause more building downstream, but it should not cause outright failures, since this is not happening for opaque store objects that we don't know how to build if we decide not to substitute.
|
||||
In practice, however, we doubt even more building is very likely to happen.
|
||||
Remote stores that are missing dependencies in arbitrary ways (e.g. corruption) don't seem to be very common.
|
||||
|
||||
On the contrary, when remote stores fail to implement the [closure property](@docroot@/store/store-object.md#closure-property), it is usually an *intentional* choice on the part of the remote store, because it wishes to serve as an "overlay" store over another store, such as `https://cache.nixos.org`.
|
||||
If an "incomplete closure" is encountered in that situation, the right fix is not to do some sort of "franken-building" as this feature implemented, but instead to make sure both substituters are enabled in the settings.
|
||||
|
||||
(In the future, we should make it easier for remote stores to indicate this to clients, to catch settings that won't work in general before a missing dependency is actually encountered.)
|
||||
|
||||
## Contributors
|
||||
|
||||
This release was made possible by the following 32 contributors:
|
||||
|
||||
- Cole Helbling [**(@cole-h)**](https://github.com/cole-h)
|
||||
- Eelco Dolstra [**(@edolstra)**](https://github.com/edolstra)
|
||||
- Egor Konovalov [**(@egorkonovalov)**](https://github.com/egorkonovalov)
|
||||
- Farid Zakaria [**(@fzakaria)**](https://github.com/fzakaria)
|
||||
- Graham Christensen [**(@grahamc)**](https://github.com/grahamc)
|
||||
- gustavderdrache [**(@gustavderdrache)**](https://github.com/gustavderdrache)
|
||||
- Gwenn Le Bihan [**(@gwennlbh)**](https://github.com/gwennlbh)
|
||||
- h0nIg [**(@h0nIg)**](https://github.com/h0nIg)
|
||||
- Jade Masker [**(@donottellmetonottellyou)**](https://github.com/donottellmetonottellyou)
|
||||
- jayeshv [**(@jayeshv)**](https://github.com/jayeshv)
|
||||
- Jeremy Fleischman [**(@jfly)**](https://github.com/jfly)
|
||||
- John Ericson [**(@Ericson2314)**](https://github.com/Ericson2314)
|
||||
- Jonas Chevalier [**(@zimbatm)**](https://github.com/zimbatm)
|
||||
- Jörg Thalheim [**(@Mic92)**](https://github.com/Mic92)
|
||||
- kstrafe [**(@kstrafe)**](https://github.com/kstrafe)
|
||||
- Luc Perkins [**(@lucperkins)**](https://github.com/lucperkins)
|
||||
- Matt Sturgeon [**(@MattSturgeon)**](https://github.com/MattSturgeon)
|
||||
- Nikita Krasnov [**(@synalice)**](https://github.com/synalice)
|
||||
- Peder Bergebakken Sundt [**(@pbsds)**](https://github.com/pbsds)
|
||||
- pennae [**(@pennae)**](https://github.com/pennae)
|
||||
- Philipp Otterbein
|
||||
- Pol Dellaiera [**(@drupol)**](https://github.com/drupol)
|
||||
- PopeRigby [**(@poperigby)**](https://github.com/poperigby)
|
||||
- Raito Bezarius
|
||||
- Robert Hensing [**(@roberth)**](https://github.com/roberth)
|
||||
- Samuli Thomasson [**(@SimSaladin)**](https://github.com/SimSaladin)
|
||||
- Sergei Zimmerman [**(@xokdvium)**](https://github.com/xokdvium)
|
||||
- Seth Flynn [**(@getchoo)**](https://github.com/getchoo)
|
||||
- Stefan Boca [**(@stefanboca)**](https://github.com/stefanboca)
|
||||
- tomberek [**(@tomberek)**](https://github.com/tomberek)
|
||||
- Tristan Ross [**(@RossComputerGuy)**](https://github.com/RossComputerGuy)
|
||||
- Valentin Gagarin [**(@fricklerhandwerk)**](https://github.com/fricklerhandwerk)
|
||||
- Vladimír Čunát [**(@vcunat)**](https://github.com/vcunat)
|
||||
- Wolfgang Walther [**(@wolfgangwalther)**](https://github.com/wolfgangwalther)
|
||||
|
||||
<!-- markdown links -->
|
||||
[stack sampling evaluation profiler]: @docroot@/advanced-topics/eval-profiler.md
|
||||
[`--eval-profiler`]: @docroot@/command-ref/conf-file.md#conf-eval-profiler
|
||||
[`--eval-profiler flamegraph`]: @docroot@/command-ref/conf-file.md#conf-eval-profiler
|
||||
[`--trace-function-calls`]: @docroot@/command-ref/conf-file.md#conf-trace-function-calls
|
||||
[`--eval-profile-file`]: @docroot@/command-ref/conf-file.md#conf-eval-profile-file
|
||||
[`--eval-profiler-frequency`]: @docroot@/command-ref/conf-file.md#conf-eval-profiler-frequency
|
||||
[`build-dir`]: @docroot@/command-ref/conf-file.md#conf-build-dir
|
||||
[`nix profile add`]: @docroot@/command-ref/new-cli/nix3-profile-add.md
|
||||
[`nix repl`]: @docroot@/command-ref/new-cli/nix3-repl.md
|
||||
[`nix flake archive`]: @docroot@/command-ref/new-cli/nix3-flake-archive.md
|
||||
[`json-log-path`]: @docroot@/command-ref/conf-file.md#conf-json-log-path
|
||||
[`trace-import-from-derivation`]: @docroot@/command-ref/conf-file.md#conf-trace-import-from-derivation
|
||||
[`allow-import-from-derivation`]: @docroot@/command-ref/conf-file.md#conf-allow-import-from-derivation
|
||||
[`builtins.sort`]: @docroot@/language/builtins.md#builtins-sort
|
||||
[`flake = false`]: @docroot@/command-ref/new-cli/nix3-flake.md?highlight=false#flake-inputs
|
||||
[`--no-check-sigs`]: @docroot@/command-ref/new-cli/nix3-flake-archive.md#opt-no-check-sigs
|
||||
[commit `299141e`]: https://github.com/NixOS/nix/commit/299141ecbd08bae17013226dbeae71e842b4fdd7
|
||||
@@ -138,17 +138,6 @@ See [Wikipedia](https://en.wikipedia.org/wiki/Argv) for details.
|
||||
|
||||
Environment variables which will be passed to the [builder](#builder) executable.
|
||||
|
||||
#### Structured Attributes {#structured-attrs}
|
||||
|
||||
Nix also has special support for embedding JSON in the derivations.
|
||||
|
||||
The environment variable `NIX_ATTRS_JSON_FILE` points to the exact location of that file both in a build and a [`nix-shell`](@docroot@/command-ref/nix-shell.md).
|
||||
|
||||
As a convenience to Bash builders, Nix writes a script that initialises shell variables corresponding to all attributes that are representable in Bash.
|
||||
The environment variable `NIX_ATTRS_SH_FILE` points to the exact location of the script, both in a build and a [`nix-shell`](@docroot@/command-ref/nix-shell.md).
|
||||
This includes non-nested (associative) arrays.
|
||||
For example, the attribute `hardening.format = true` ends up as the Bash associative array element `${hardening[format]}`.
|
||||
|
||||
### Placeholders
|
||||
|
||||
Placeholders are opaque values used within the [process creation fields] to [store objects] for which we don't yet know [store path]s.
|
||||
|
||||
@@ -41,6 +41,10 @@ def recursive_replace(data: dict[str, t.Any], book_root: Path, search_path: Path
|
||||
return data | dict(
|
||||
sections = [recursive_replace(section, book_root, search_path) for section in sections],
|
||||
)
|
||||
case {'items': items}:
|
||||
return data | dict(
|
||||
items = [recursive_replace(item, book_root, search_path) for item in items],
|
||||
)
|
||||
case {'Chapter': chapter}:
|
||||
path_to_chapter = Path(chapter['path'])
|
||||
chapter_content = chapter['content']
|
||||
|
||||
+103
-139
@@ -1,11 +1,6 @@
|
||||
{
|
||||
# Core dependencies
|
||||
pkgs ? import <nixpkgs> { },
|
||||
lib ? pkgs.lib,
|
||||
dockerTools ? pkgs.dockerTools,
|
||||
runCommand ? pkgs.runCommand,
|
||||
buildPackages ? pkgs.buildPackages,
|
||||
# Image configuration
|
||||
name ? "nix",
|
||||
tag ? "latest",
|
||||
bundleNixpkgs ? true,
|
||||
@@ -19,108 +14,82 @@
|
||||
gid ? 0,
|
||||
uname ? "root",
|
||||
gname ? "root",
|
||||
Labels ? {
|
||||
"org.opencontainers.image.title" = "Nix";
|
||||
"org.opencontainers.image.source" = "https://github.com/NixOS/nix";
|
||||
"org.opencontainers.image.vendor" = "Nix project";
|
||||
"org.opencontainers.image.version" = nix.version;
|
||||
"org.opencontainers.image.description" = "Nix container image";
|
||||
},
|
||||
Cmd ? [ (lib.getExe bashInteractive) ],
|
||||
# Default Packages
|
||||
nix ? pkgs.nix,
|
||||
bashInteractive ? pkgs.bashInteractive,
|
||||
coreutils-full ? pkgs.coreutils-full,
|
||||
gnutar ? pkgs.gnutar,
|
||||
gzip ? pkgs.gzip,
|
||||
gnugrep ? pkgs.gnugrep,
|
||||
which ? pkgs.which,
|
||||
curl ? pkgs.curl,
|
||||
less ? pkgs.less,
|
||||
wget ? pkgs.wget,
|
||||
man ? pkgs.man,
|
||||
cacert ? pkgs.cacert,
|
||||
findutils ? pkgs.findutils,
|
||||
iana-etc ? pkgs.iana-etc,
|
||||
gitMinimal ? pkgs.gitMinimal,
|
||||
openssh ? pkgs.openssh,
|
||||
# Other dependencies
|
||||
shadow ? pkgs.shadow,
|
||||
}:
|
||||
let
|
||||
defaultPkgs = [
|
||||
nix
|
||||
bashInteractive
|
||||
coreutils-full
|
||||
gnutar
|
||||
gzip
|
||||
gnugrep
|
||||
which
|
||||
curl
|
||||
less
|
||||
wget
|
||||
man
|
||||
cacert.out
|
||||
findutils
|
||||
iana-etc
|
||||
gitMinimal
|
||||
openssh
|
||||
] ++ extraPkgs;
|
||||
defaultPkgs =
|
||||
with pkgs;
|
||||
[
|
||||
nix
|
||||
bashInteractive
|
||||
coreutils-full
|
||||
gnutar
|
||||
gzip
|
||||
gnugrep
|
||||
which
|
||||
curl
|
||||
less
|
||||
wget
|
||||
man
|
||||
cacert.out
|
||||
findutils
|
||||
iana-etc
|
||||
git
|
||||
openssh
|
||||
]
|
||||
++ extraPkgs;
|
||||
|
||||
users =
|
||||
{
|
||||
users = {
|
||||
|
||||
root = {
|
||||
uid = 0;
|
||||
shell = lib.getExe bashInteractive;
|
||||
home = "/root";
|
||||
gid = 0;
|
||||
groups = [ "root" ];
|
||||
description = "System administrator";
|
||||
};
|
||||
|
||||
nobody = {
|
||||
uid = 65534;
|
||||
shell = lib.getExe' shadow "nologin";
|
||||
home = "/var/empty";
|
||||
gid = 65534;
|
||||
groups = [ "nobody" ];
|
||||
description = "Unprivileged account (don't use!)";
|
||||
};
|
||||
|
||||
}
|
||||
// lib.optionalAttrs (uid != 0) {
|
||||
"${uname}" = {
|
||||
uid = uid;
|
||||
shell = lib.getExe bashInteractive;
|
||||
home = "/home/${uname}";
|
||||
gid = gid;
|
||||
groups = [ "${gname}" ];
|
||||
description = "Nix user";
|
||||
};
|
||||
}
|
||||
// lib.listToAttrs (
|
||||
map (n: {
|
||||
name = "nixbld${toString n}";
|
||||
value = {
|
||||
uid = 30000 + n;
|
||||
gid = 30000;
|
||||
groups = [ "nixbld" ];
|
||||
description = "Nix build user ${toString n}";
|
||||
};
|
||||
}) (lib.lists.range 1 32)
|
||||
);
|
||||
|
||||
groups =
|
||||
{
|
||||
root.gid = 0;
|
||||
nixbld.gid = 30000;
|
||||
nobody.gid = 65534;
|
||||
}
|
||||
// lib.optionalAttrs (gid != 0) {
|
||||
"${gname}".gid = gid;
|
||||
root = {
|
||||
uid = 0;
|
||||
shell = "${pkgs.bashInteractive}/bin/bash";
|
||||
home = "/root";
|
||||
gid = 0;
|
||||
groups = [ "root" ];
|
||||
description = "System administrator";
|
||||
};
|
||||
|
||||
nobody = {
|
||||
uid = 65534;
|
||||
shell = "${pkgs.shadow}/bin/nologin";
|
||||
home = "/var/empty";
|
||||
gid = 65534;
|
||||
groups = [ "nobody" ];
|
||||
description = "Unprivileged account (don't use!)";
|
||||
};
|
||||
|
||||
}
|
||||
// lib.optionalAttrs (uid != 0) {
|
||||
"${uname}" = {
|
||||
uid = uid;
|
||||
shell = "${pkgs.bashInteractive}/bin/bash";
|
||||
home = "/home/${uname}";
|
||||
gid = gid;
|
||||
groups = [ "${gname}" ];
|
||||
description = "Nix user";
|
||||
};
|
||||
}
|
||||
// lib.listToAttrs (
|
||||
map (n: {
|
||||
name = "nixbld${toString n}";
|
||||
value = {
|
||||
uid = 30000 + n;
|
||||
gid = 30000;
|
||||
groups = [ "nixbld" ];
|
||||
description = "Nix build user ${toString n}";
|
||||
};
|
||||
}) (lib.lists.range 1 32)
|
||||
);
|
||||
|
||||
groups = {
|
||||
root.gid = 0;
|
||||
nixbld.gid = 30000;
|
||||
nobody.gid = 65534;
|
||||
}
|
||||
// lib.optionalAttrs (gid != 0) {
|
||||
"${gname}".gid = gid;
|
||||
};
|
||||
|
||||
userToPasswd = (
|
||||
k:
|
||||
{
|
||||
@@ -176,29 +145,30 @@ let
|
||||
"${k}:x:${toString gid}:${lib.concatStringsSep "," members}";
|
||||
groupContents = (lib.concatStringsSep "\n" (lib.attrValues (lib.mapAttrs groupToGroup groups)));
|
||||
|
||||
toConf =
|
||||
with pkgs.lib.generators;
|
||||
toKeyValue {
|
||||
mkKeyValue = mkKeyValueDefault {
|
||||
mkValueString = v: if lib.isList v then lib.concatStringsSep " " v else mkValueStringDefault { } v;
|
||||
} " = ";
|
||||
};
|
||||
defaultNixConf = {
|
||||
sandbox = "false";
|
||||
build-users-group = "nixbld";
|
||||
trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ];
|
||||
};
|
||||
|
||||
nixConfContents = toConf (
|
||||
{
|
||||
sandbox = false;
|
||||
build-users-group = "nixbld";
|
||||
trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ];
|
||||
}
|
||||
// nixConf
|
||||
);
|
||||
nixConfContents =
|
||||
(lib.concatStringsSep "\n" (
|
||||
lib.mapAttrsToList (
|
||||
n: v:
|
||||
let
|
||||
vStr = if builtins.isList v then lib.concatStringsSep " " v else v;
|
||||
in
|
||||
"${n} = ${vStr}"
|
||||
) (defaultNixConf // nixConf)
|
||||
))
|
||||
+ "\n";
|
||||
|
||||
userHome = if uid == 0 then "/root" else "/home/${uname}";
|
||||
|
||||
baseSystem =
|
||||
let
|
||||
nixpkgs = pkgs.path;
|
||||
channel = runCommand "channel-nixos" { inherit bundleNixpkgs; } ''
|
||||
channel = pkgs.runCommand "channel-nixos" { inherit bundleNixpkgs; } ''
|
||||
mkdir $out
|
||||
if [ "$bundleNixpkgs" ]; then
|
||||
ln -s ${
|
||||
@@ -210,8 +180,11 @@ let
|
||||
echo "[]" > $out/manifest.nix
|
||||
fi
|
||||
'';
|
||||
# doc/manual/source/command-ref/files/manifest.nix.md
|
||||
manifest = buildPackages.runCommand "manifest.nix" { } ''
|
||||
rootEnv = pkgs.buildPackages.buildEnv {
|
||||
name = "root-profile-env";
|
||||
paths = defaultPkgs;
|
||||
};
|
||||
manifest = pkgs.buildPackages.runCommand "manifest.nix" { } ''
|
||||
cat > $out <<EOF
|
||||
[
|
||||
${lib.concatStringsSep "\n" (
|
||||
@@ -240,15 +213,11 @@ let
|
||||
]
|
||||
EOF
|
||||
'';
|
||||
profile = buildPackages.buildEnv {
|
||||
name = "root-profile-env";
|
||||
paths = defaultPkgs;
|
||||
|
||||
postBuild = ''
|
||||
mv $out/manifest $out/manifest.nix
|
||||
'';
|
||||
inherit manifest;
|
||||
};
|
||||
profile = pkgs.buildPackages.runCommand "user-environment" { } ''
|
||||
mkdir $out
|
||||
cp -a ${rootEnv}/* $out/
|
||||
ln -s ${manifest} $out/manifest.nix
|
||||
'';
|
||||
flake-registry-path =
|
||||
if (flake-registry == null) then
|
||||
null
|
||||
@@ -257,7 +226,7 @@ let
|
||||
else
|
||||
flake-registry;
|
||||
in
|
||||
runCommand "base-system"
|
||||
pkgs.runCommand "base-system"
|
||||
{
|
||||
inherit
|
||||
passwdContents
|
||||
@@ -280,7 +249,6 @@ let
|
||||
set -x
|
||||
mkdir -p $out/etc
|
||||
|
||||
# may get replaced by pkgs.dockerTools.caCertificates
|
||||
mkdir -p $out/etc/ssl/certs
|
||||
ln -s /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt $out/etc/ssl/certs
|
||||
|
||||
@@ -308,23 +276,19 @@ let
|
||||
mkdir -p $out${userHome}
|
||||
mkdir -p $out/nix/var/nix/profiles/per-user/${uname}
|
||||
|
||||
# see doc/manual/source/command-ref/files/profiles.md
|
||||
ln -s ${profile} $out/nix/var/nix/profiles/default-1-link
|
||||
ln -s /nix/var/nix/profiles/default-1-link $out/nix/var/nix/profiles/default
|
||||
|
||||
# see doc/manual/source/command-ref/files/channels.md
|
||||
ln -s ${channel} $out/nix/var/nix/profiles/per-user/${uname}/channels-1-link
|
||||
ln -s /nix/var/nix/profiles/per-user/${uname}/channels-1-link $out/nix/var/nix/profiles/per-user/${uname}/channels
|
||||
|
||||
# see doc/manual/source/command-ref/files/default-nix-expression.md
|
||||
mkdir -p $out${userHome}/.nix-defexpr
|
||||
ln -s /nix/var/nix/profiles/per-user/${uname}/channels $out${userHome}/.nix-defexpr/channels
|
||||
echo "${channelURL} ${channelName}" > $out${userHome}/.nix-channels
|
||||
|
||||
# may get replaced by pkgs.dockerTools.binSh & pkgs.dockerTools.usrBinEnv
|
||||
mkdir -p $out/bin $out/usr/bin
|
||||
ln -s ${lib.getExe' coreutils-full "env"} $out/usr/bin/env
|
||||
ln -s ${lib.getExe bashInteractive} $out/bin/sh
|
||||
ln -s ${pkgs.coreutils}/bin/env $out/usr/bin/env
|
||||
ln -s ${pkgs.bashInteractive}/bin/bash $out/bin/sh
|
||||
|
||||
''
|
||||
+ (lib.optionalString (flake-registry-path != null) ''
|
||||
@@ -333,13 +297,13 @@ let
|
||||
globalFlakeRegistryPath="$nixCacheDir/flake-registry.json"
|
||||
ln -s ${flake-registry-path} $out$globalFlakeRegistryPath
|
||||
mkdir -p $out/nix/var/nix/gcroots/auto
|
||||
rootName=$(${lib.getExe' nix "nix"} --extra-experimental-features nix-command hash file --type sha1 --base32 <(echo -n $globalFlakeRegistryPath))
|
||||
rootName=$(${pkgs.nix}/bin/nix --extra-experimental-features nix-command hash file --type sha1 --base32 <(echo -n $globalFlakeRegistryPath))
|
||||
ln -s $globalFlakeRegistryPath $out/nix/var/nix/gcroots/auto/$rootName
|
||||
'')
|
||||
);
|
||||
|
||||
in
|
||||
dockerTools.buildLayeredImageWithNixDb {
|
||||
pkgs.dockerTools.buildLayeredImageWithNixDb {
|
||||
|
||||
inherit
|
||||
name
|
||||
@@ -365,7 +329,7 @@ dockerTools.buildLayeredImageWithNixDb {
|
||||
'';
|
||||
|
||||
config = {
|
||||
inherit Cmd Labels;
|
||||
Cmd = [ (lib.getExe pkgs.bashInteractive) ];
|
||||
User = "${toString uid}:${toString gid}";
|
||||
Env = [
|
||||
"USER=${uname}"
|
||||
|
||||
Generated
+4
-4
@@ -63,16 +63,16 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1747179050,
|
||||
"narHash": "sha256-qhFMmDkeJX9KJwr5H32f1r7Prs7XbQWtO0h3V0a0rFY=",
|
||||
"lastModified": 1756178832,
|
||||
"narHash": "sha256-O2CIn7HjZwEGqBrwu9EU76zlmA5dbmna7jL1XUmAId8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "adaa24fbf46737f3f1b5497bf64bae750f82942e",
|
||||
"rev": "d98ce345cdab58477ca61855540999c86577d19d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"ref": "nixos-25.05-small",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
description = "The purely functional package manager";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05-small";
|
||||
|
||||
inputs.nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2";
|
||||
inputs.nixpkgs-23-11.url = "github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446";
|
||||
@@ -32,7 +32,7 @@
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
|
||||
officialRelease = false;
|
||||
officialRelease = true;
|
||||
|
||||
linux32BitSystems = [ "i686-linux" ];
|
||||
linux64BitSystems = [
|
||||
@@ -179,6 +179,19 @@
|
||||
};
|
||||
|
||||
nix = final.nixComponents2.nix-cli;
|
||||
|
||||
# See https://github.com/NixOS/nixpkgs/pull/214409
|
||||
# Remove when fixed in this flake's nixpkgs
|
||||
pre-commit =
|
||||
if prev.stdenv.hostPlatform.system == "i686-linux" then
|
||||
(prev.pre-commit.override (o: {
|
||||
dotnet-sdk = "";
|
||||
})).overridePythonAttrs
|
||||
(o: {
|
||||
doCheck = false;
|
||||
})
|
||||
else
|
||||
prev.pre-commit;
|
||||
};
|
||||
|
||||
in
|
||||
@@ -220,24 +233,28 @@
|
||||
This shouldn't build anything significant; just check that things
|
||||
(including derivations) are _set up_ correctly.
|
||||
*/
|
||||
packaging-overriding =
|
||||
let
|
||||
pkgs = nixpkgsFor.${system}.native;
|
||||
nix = self.packages.${system}.nix;
|
||||
in
|
||||
assert (nix.appendPatches [ pkgs.emptyFile ]).libs.nix-util.src.patches == [ pkgs.emptyFile ];
|
||||
if pkgs.stdenv.buildPlatform.isDarwin then
|
||||
lib.warn "packaging-overriding check currently disabled because of a permissions issue on macOS" pkgs.emptyFile
|
||||
else
|
||||
# If this fails, something might be wrong with how we've wired the scope,
|
||||
# or something could be broken in Nixpkgs.
|
||||
pkgs.testers.testEqualContents {
|
||||
assertion = "trivial patch does not change source contents";
|
||||
expected = "${./.}";
|
||||
actual =
|
||||
# Same for all components; nix-util is an arbitrary pick
|
||||
(nix.appendPatches [ pkgs.emptyFile ]).libs.nix-util.src;
|
||||
};
|
||||
# Disabled due to a bug in `testEqualContents` (see
|
||||
# https://github.com/NixOS/nix/issues/12690).
|
||||
/*
|
||||
packaging-overriding =
|
||||
let
|
||||
pkgs = nixpkgsFor.${system}.native;
|
||||
nix = self.packages.${system}.nix;
|
||||
in
|
||||
assert (nix.appendPatches [ pkgs.emptyFile ]).libs.nix-util.src.patches == [ pkgs.emptyFile ];
|
||||
if pkgs.stdenv.buildPlatform.isDarwin then
|
||||
lib.warn "packaging-overriding check currently disabled because of a permissions issue on macOS" pkgs.emptyFile
|
||||
else
|
||||
# If this fails, something might be wrong with how we've wired the scope,
|
||||
# or something could be broken in Nixpkgs.
|
||||
pkgs.testers.testEqualContents {
|
||||
assertion = "trivial patch does not change source contents";
|
||||
expected = "${./.}";
|
||||
actual =
|
||||
# Same for all components; nix-util is an arbitrary pick
|
||||
(nix.appendPatches [ pkgs.emptyFile ]).libs.nix-util.src;
|
||||
};
|
||||
*/
|
||||
}
|
||||
// (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
|
||||
dockerImage = self.hydraJobs.dockerImage.${system};
|
||||
@@ -404,7 +421,8 @@
|
||||
dockerImage =
|
||||
let
|
||||
pkgs = nixpkgsFor.${system}.native;
|
||||
image = pkgs.callPackage ./docker.nix {
|
||||
image = import ./docker.nix {
|
||||
inherit pkgs;
|
||||
tag = pkgs.nix.version;
|
||||
};
|
||||
in
|
||||
|
||||
@@ -166,24 +166,5 @@
|
||||
"the-tumultuous-unicorn-of-darkness@gmx.com": "TheTumultuousUnicornOfDarkness",
|
||||
"dev@rodney.id.au": "rvl",
|
||||
"pe@pijul.org": "P-E-Meunier",
|
||||
"yannik@floxdev.com": "ysndr",
|
||||
"73017521+egorkonovalov@users.noreply.github.com": "egorkonovalov",
|
||||
"raito@lix.systems": null,
|
||||
"nikita.nikita.krasnov@gmail.com": "synalice",
|
||||
"lucperkins@gmail.com": "lucperkins",
|
||||
"vladimir.cunat@nic.cz": "vcunat",
|
||||
"walther@technowledgy.de": "wolfgangwalther",
|
||||
"jayesh.mail@gmail.com": "jayeshv",
|
||||
"samuli.thomasson@pm.me": "SimSaladin",
|
||||
"kevin@stravers.net": "kstrafe",
|
||||
"poperigby@mailbox.org": "poperigby",
|
||||
"cole.helbling@determinate.systems": "cole-h",
|
||||
"donottellmetonottellyou@gmail.com": "donottellmetonottellyou",
|
||||
"getchoo@tuta.io": "getchoo",
|
||||
"alex.ford@determinate.systems": "gustavderdrache",
|
||||
"stefan.r.boca@gmail.com": "stefanboca",
|
||||
"gwenn.lebihan7@gmail.com": "gwennlbh",
|
||||
"hey@ewen.works": "gwennlbh",
|
||||
"matt@sturgeon.me.uk": "MattSturgeon",
|
||||
"pbsds@hotmail.com": "pbsds"
|
||||
"yannik@floxdev.com": "ysndr"
|
||||
}
|
||||
@@ -146,21 +146,5 @@
|
||||
"ajlekcahdp4": "Alexander Romanov",
|
||||
"Valodim": "Vincent Breitmoser",
|
||||
"rvl": "Rodney Lorrimar",
|
||||
"whatsthecraic": "Dean De Leo",
|
||||
"gwennlbh": "Gwenn Le Bihan",
|
||||
"donottellmetonottellyou": "Jade Masker",
|
||||
"kstrafe": null,
|
||||
"synalice": "Nikita Krasnov",
|
||||
"poperigby": "PopeRigby",
|
||||
"MattSturgeon": "Matt Sturgeon",
|
||||
"lucperkins": "Luc Perkins",
|
||||
"gustavderdrache": null,
|
||||
"SimSaladin": "Samuli Thomasson",
|
||||
"getchoo": "Seth Flynn",
|
||||
"stefanboca": "Stefan Boca",
|
||||
"wolfgangwalther": "Wolfgang Walther",
|
||||
"pbsds": "Peder Bergebakken Sundt",
|
||||
"egorkonovalov": "Egor Konovalov",
|
||||
"jayeshv": "jayeshv",
|
||||
"vcunat": "Vladim\u00edr \u010cun\u00e1t"
|
||||
"whatsthecraic": "Dean De Leo"
|
||||
}
|
||||
@@ -37,118 +37,6 @@
|
||||
fi
|
||||
''}";
|
||||
};
|
||||
meson-format = {
|
||||
enable = true;
|
||||
files = "(meson.build|meson.options)$";
|
||||
entry = "${pkgs.writeScript "format-meson" ''
|
||||
#!${pkgs.runtimeShell}
|
||||
for file in "$@"; do
|
||||
${lib.getExe pkgs.meson} format -ic ${../meson.format} "$file"
|
||||
done
|
||||
''}";
|
||||
excludes = [
|
||||
# We haven't applied formatting to these files yet
|
||||
''^doc/manual/meson.build$''
|
||||
''^doc/manual/source/command-ref/meson.build$''
|
||||
''^doc/manual/source/development/meson.build$''
|
||||
''^doc/manual/source/language/meson.build$''
|
||||
''^doc/manual/source/meson.build$''
|
||||
''^doc/manual/source/release-notes/meson.build$''
|
||||
''^doc/manual/source/store/meson.build$''
|
||||
''^misc/bash/meson.build$''
|
||||
''^misc/fish/meson.build$''
|
||||
''^misc/launchd/meson.build$''
|
||||
''^misc/meson.build$''
|
||||
''^misc/systemd/meson.build$''
|
||||
''^misc/zsh/meson.build$''
|
||||
''^nix-meson-build-support/$''
|
||||
''^nix-meson-build-support/big-objs/meson.build$''
|
||||
''^nix-meson-build-support/common/meson.build$''
|
||||
''^nix-meson-build-support/deps-lists/meson.build$''
|
||||
''^nix-meson-build-support/export/meson.build$''
|
||||
''^nix-meson-build-support/export-all-symbols/meson.build$''
|
||||
''^nix-meson-build-support/generate-header/meson.build$''
|
||||
''^nix-meson-build-support/libatomic/meson.build$''
|
||||
''^nix-meson-build-support/subprojects/meson.build$''
|
||||
''^scripts/meson.build$''
|
||||
''^src/external-api-docs/meson.build$''
|
||||
''^src/internal-api-docs/meson.build$''
|
||||
''^src/libcmd/include/nix/cmd/meson.build$''
|
||||
''^src/libcmd/meson.build$''
|
||||
''^src/libcmd/nix-meson-build-support$''
|
||||
''^src/libexpr/include/nix/expr/meson.build$''
|
||||
''^src/libexpr/meson.build$''
|
||||
''^src/libexpr/nix-meson-build-support$''
|
||||
''^src/libexpr-c/meson.build$''
|
||||
''^src/libexpr-c/nix-meson-build-support$''
|
||||
''^src/libexpr-test-support/meson.build$''
|
||||
''^src/libexpr-test-support/nix-meson-build-support$''
|
||||
''^src/libexpr-tests/meson.build$''
|
||||
''^src/libexpr-tests/nix-meson-build-support$''
|
||||
''^src/libfetchers/include/nix/fetchers/meson.build$''
|
||||
''^src/libfetchers/meson.build$''
|
||||
''^src/libfetchers/nix-meson-build-support$''
|
||||
''^src/libfetchers-c/meson.build$''
|
||||
''^src/libfetchers-c/nix-meson-build-support$''
|
||||
''^src/libfetchers-tests/meson.build$''
|
||||
''^src/libfetchers-tests/nix-meson-build-support$''
|
||||
''^src/libflake/include/nix/flake/meson.build$''
|
||||
''^src/libflake/meson.build$''
|
||||
''^src/libflake/nix-meson-build-support$''
|
||||
''^src/libflake-c/meson.build$''
|
||||
''^src/libflake-c/nix-meson-build-support$''
|
||||
''^src/libflake-tests/meson.build$''
|
||||
''^src/libflake-tests/nix-meson-build-support$''
|
||||
''^src/libmain/include/nix/main/meson.build$''
|
||||
''^src/libmain/meson.build$''
|
||||
''^src/libmain/nix-meson-build-support$''
|
||||
''^src/libmain-c/meson.build$''
|
||||
''^src/libmain-c/nix-meson-build-support$''
|
||||
''^src/libstore/include/nix/store/meson.build$''
|
||||
''^src/libstore/meson.build$''
|
||||
''^src/libstore/nix-meson-build-support$''
|
||||
''^src/libstore/unix/include/nix/store/meson.build$''
|
||||
''^src/libstore/unix/meson.build$''
|
||||
''^src/libstore/windows/meson.build$''
|
||||
''^src/libstore-c/meson.build$''
|
||||
''^src/libstore-c/nix-meson-build-support$''
|
||||
''^src/libstore-test-support/include/nix/store/tests/meson.build$''
|
||||
''^src/libstore-test-support/meson.build$''
|
||||
''^src/libstore-test-support/nix-meson-build-support$''
|
||||
''^src/libstore-tests/meson.build$''
|
||||
''^src/libstore-tests/nix-meson-build-support$''
|
||||
''^src/libutil/meson.build$''
|
||||
''^src/libutil/nix-meson-build-support$''
|
||||
''^src/libutil/unix/include/nix/util/meson.build$''
|
||||
''^src/libutil/unix/meson.build$''
|
||||
''^src/libutil/windows/meson.build$''
|
||||
''^src/libutil-c/meson.build$''
|
||||
''^src/libutil-c/nix-meson-build-support$''
|
||||
''^src/libutil-test-support/include/nix/util/tests/meson.build$''
|
||||
''^src/libutil-test-support/meson.build$''
|
||||
''^src/libutil-test-support/nix-meson-build-support$''
|
||||
''^src/libutil-tests/meson.build$''
|
||||
''^src/libutil-tests/nix-meson-build-support$''
|
||||
''^src/nix/meson.build$''
|
||||
''^src/nix/nix-meson-build-support$''
|
||||
''^src/perl/lib/Nix/meson.build$''
|
||||
''^src/perl/meson.build$''
|
||||
''^tests/functional/ca/meson.build$''
|
||||
''^tests/functional/common/meson.build$''
|
||||
''^tests/functional/dyn-drv/meson.build$''
|
||||
''^tests/functional/flakes/meson.build$''
|
||||
''^tests/functional/git-hashing/meson.build$''
|
||||
''^tests/functional/local-overlay-store/meson.build$''
|
||||
''^tests/functional/meson.build$''
|
||||
''^src/libcmd/meson.options$''
|
||||
''^src/libexpr/meson.options$''
|
||||
''^src/libstore/meson.options$''
|
||||
''^src/libutil/meson.options$''
|
||||
''^src/libutil-c/meson.options$''
|
||||
''^src/nix/meson.options$''
|
||||
''^src/perl/meson.options$''
|
||||
];
|
||||
};
|
||||
nixfmt-rfc-style = {
|
||||
enable = true;
|
||||
excludes = [
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mQINBGPtMiwBEAC0sFZW2QW/OaDjKm5zGRpDvHXDsMIUtlHfoi5ce8pocC63W05o
|
||||
FSXbUZjZ1VfYO8lT8DFANCzTkiXYaZx0cPRG2pVY4AOQZDNFt5XrAyvw496XCAIM
|
||||
DTYGFLjCqgjPt9RUFEy4MyHPJTEpB0x3rXgT4ILNu9vsj9Q0vttps7SpbZ3Ldq5H
|
||||
o/BBbLW77q/vNjpYzCbBIXF7ycUGpnNv9Go/WuiDnrBMcyxh+8kjjIHB5cxZSnjJ
|
||||
DUv681+m83v+gLZQGX/jexQrrf5JpS0X9qEnhGLrNUDhtyv5ud3Je4EfamkjLVVC
|
||||
RlNLofgflOCsl/tP80i+K7S1QdKhUALxuJ6H0prYUflGBDxDyC8XYuJ62TT0OUpa
|
||||
vJvgwVlCq8/jq+ykYQXlbuBVOzi5wAuI4l3+HqreSQYPSiwe+6N590Zbafdv1fvN
|
||||
WFtZKCTGMqfyaaAnppioH9/+NWkI2AQxaYVasYM/JEYvY9pJgA7alh51jHW4JglP
|
||||
ErypKfBKPKJID0QENqYoa3bDDCihuNWhgQf9dxzPlj2ckd35Zb6w4DfuSmtjaa9D
|
||||
o0jZVY1JbFuxBqP09+saVPrxLHgmPxjcdzPGQQtAqdO2vyJXNEGLFMoVEZPNaLo3
|
||||
QmcIJnT7oSck+4vGfOYtWUHXQynu/Tnwsv2XkA/uyw8HNe+RRMqv/apnzQARAQAB
|
||||
tCdTZXJnZWkgWmltbWVybWFuIDxzZXJnZWlAemltbWVybWFuLmZvbz6JAlEEEwEK
|
||||
ADsCGwEFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AWIQQVim9TDqIC5fZRYRMU+upj
|
||||
RI4d+QUCaUbsaAIZAQAKCRAU+upjRI4d+VdDD/492HRaJ/8V7R7VUzkafmb2Hb28
|
||||
SLf7oiB8Uq9I7SukiDEaIT1fUhquYWQ9KWpPRNR1TX6ApXnIeuJRMGFoDVIRnmnr
|
||||
cKnYYXfqqc81VxIyKvaumB7KWbS7G4Nbor8AH1ouOOOMMS50OTJOWQA4A26inIuG
|
||||
n+7L8MeS5aT+3uNKDoTKsidC47vnaxNMcke1taPfbfo7vn69PsRCM/g9/7TQYU8b
|
||||
6xp+pM9Ao9nJneRk2YCpsGYRrWTpaik0DFKnfpPKJM/yunhtGLF2IYAp3l1mvHPK
|
||||
nnzo92zjpQuZwazEIK+23V1vRT4IjM2BewbJPAzf2/UuxEjjgNQm0tOtH2JhFNeB
|
||||
VM0BVrGxWrrwrsmv6lWghTtBc6zRWyHrj/rpjtVQNmeKYrHWJeXwVz1rqgGPmB2N
|
||||
k0MZD1UjHHhEs1Cntn7yLmxTPztRJCtR+euRu81Uo2NAvrMJ4xsDjaM0LeLTnzjV
|
||||
9AsPjD188dOFyz7VExZum4+XaaEJ41FIPLEqU3U0GAa6stEy0ylSlIN4x9aiXXVW
|
||||
xfzHHchS5jK6QAjuZxN8t01GRactNylINRf7uoTECFZTtXNqfeuk0HQxBH0LuKVE
|
||||
0PxJbcNI4mVWw1KgTJ8PUVC1IXP3sEpqPdJOYiRXgnpcS26fWOBu0aQ4mhxiaJhr
|
||||
/zBfrkLEqp20TdNDZLkCDQRj7TM1ARAAt73xO24curnHTTgXkkVMMRzcMLx3Mb1a
|
||||
2FuddxC5hzTpEpw01L91UBrXVJEg9K2KAwP5CtCLgPCqXr47Tm7krvHxWwBksgY/
|
||||
6aHRsoPQfCFUZHc0aiO+C4NCzR+aEeGKn66Oc1Hq9oUTpDgiBWhsuEPiyA1OSGF0
|
||||
4L0jeTCqfm68kWp4PIK9yuugkdDsoyj6TonuMsb3V5ctHLqop9KH+eHSkUTPo+Lk
|
||||
+bxaeAOJ1UfbohgbRbrYKAfsaghhOMDH3R1w2pvtUJz+sDbuQsiPFTqbxsXDTFws
|
||||
H4N/AQCYnnvOhqEek2sOEZ19bJXt5UrAr10mX4PGmAkWqE1JWBxpOKG3BXSGOTu1
|
||||
3dFhQfPMK+PmvUrs0kcWQr53K/aRUdKKhIfTcMfkqYTGPK5HclHph24WjXj3QFFA
|
||||
SjksQTdm6486ZmLZK4CTbAFOPfTF/aWg8gu9v4ihdq6lqHNNXxv2xBAChcd59H7p
|
||||
D5zy9z8SpwWR9V5JDmlF6HWIIau1c6lSsQq1xHvYM8EuPe03vJvor+2u/cn5zYF1
|
||||
5ZxAuPI2i5vtavg1s8ZGAAogJ9dVcP36LdJfL9quXWvmovkd//qHIepBB+l/zQio
|
||||
ZRDZlIcfV3Xycaqsb5OqHGARHE0097koipMt5y/iXlqG4Ruue6Idb8bW96EKpaWj
|
||||
kKy/iNfQfQMAEQEAAYkEcgQYAQoAJgIbAhYhBBWKb1MOogLl9lFhExT66mNEjh35
|
||||
BQJpRuz3BQkJHCDCAkDBdCAEGQEKAB0WIQRK3hK0WyJ4BicGpcmpsLVXymMjJQUC
|
||||
Y+0zNQAKCRCpsLVXymMjJbdSD/9+f1FOOeGDAJI6Duo5fsWnf4xJJdtQtDbz6d2A
|
||||
SeDapxeJ3zWfKBD0wu5sISEa0uiWsYSmLtsa2SqVAKHlEaMGRR+tkBMPQ+rvgI4c
|
||||
62YjGTgm+IPd+NFIn+ixFU1hpinTh+KhUEoeOwWCvKs9nZfSG9vkienfiG0bBxo2
|
||||
zrvBzXA50x5hbUL+ghKu/AVfN9qZDwh30O4KZTwk4g4cM9SeaQa4YvHYIS3IEhDZ
|
||||
hGybwrrqV9cs92ln4IJw9WCy9QReBNrdeFgC4+3ziUp1QsG3RvqrtuMttwBVC1Z3
|
||||
bj5QjLLOREhhodfvk98t9yVkragObb4rGrLo1mWuF0c4mJGvXwnrqhCMvzv4M+0T
|
||||
Zdrmw6YpGkGOaOPghVuwoTtqSAkl+zFWIJS89jidvkYG3EqKAkgLKog/TQReCq13
|
||||
HWrF8cMck+Rf2K8k26q/RNZaA9ZUKjLExzz8lsWmd2C7rvkGLrlxnzxz0gGyNR3Q
|
||||
KK74vcPhqeABt2GSkHtEXZFFA9IVVzwlRWK3e0S+mVQnZVjNL+cBPn3/hZHMLesB
|
||||
CucyYZv+DxvT+JkYXBkGSw4s3hpABqGym7gdPUIa0q4rbBFG6xP5sLLBG4yru8vV
|
||||
2dyCMmFqRuxpT49uNfyQ6Vj+dobN6qHnP/9NwfzOixXYBHXR6LBqb/M+iCiJaaIn
|
||||
uiRLHwkQFPrqY0SOHfkQpA//W51vj8meuz7snRO+vZFcjLneFFzqfh1Jdz8IqDpO
|
||||
CkI5pBJmi8e0oSe6r68MkahiQLlYPwm7d+sjHvJhPWipNKWq/uwCgBs+Ac1lpPXR
|
||||
MwLbrZukcLMYlLmb2MrCKmjcMt0BZsZKBNYL3a3X9nHgwXdeqFYS4WQDMCCc09lz
|
||||
9YqfdoEsqRO4qN7D0hFqnwjOzb34ixZ6UO8a8ekY9QKxAgWc9fJWGMg6Pjdg4qsK
|
||||
nqymOIAdGVOJdoRM46wKGVBvbsF2gNfQU4XyzgJo5vHGFwJm6EoSnODlL5e2wsQh
|
||||
uN1oqBt/8ef/plloMEqVBweUBATqSqjRF6IhhYJvWVuQHQL1p1vnV9FebiVj34ir
|
||||
Z8ID+o0AnTJcclbUcDwannGJ0cuDcPhk/v/ahVuoMERCi12qnMBo5B/e6Omyh1yB
|
||||
4pbf4GATGGQipDQG75eC/kP2GQEqJP5WYN0Ar8Le/AA/2xyL7upW0yIByyXCwGEb
|
||||
JRwEgU3+bPyu58bFt8Pftit6J7rA3oBVVMOPrYH5eZwRaj5m2RptwKGL6BfHnhNv
|
||||
ZqmCq9EBGX6L1NI0xHMjEFfXJ8jU01XdfG8nCqkwqsHwslXLhqjJphfHcx89YwbV
|
||||
/15GCuURAv1cKe/7277sOhcvP/QpQqSWgvYExHw8PeFJcTYtF2NrRgNwcQsWS1Rj
|
||||
gXa5Ag0EY+0zcAEQANC5N6kSfezuucAgi+X3BD+MT37mxQyvICSggEJf1LDSmy0+
|
||||
bnvD7setL8CP9etTA2fcVNYKI1oboMyhoCnsRP2jDdv1iXOI/hZg4wSb/D1yUkae
|
||||
fUpxv3Wuci2QKavH2MfraDD7BFMbsQeMcHtn4Rk216T6jndZHnzT1Ih7iX0XeQPb
|
||||
li5fojOiZssgWAVT4HPXFCJB6lI35Hjp35oRYwrtMmu5INinZ79n9h1igGtt1ItZ
|
||||
b7rQKNd772Jxcn4UU71ovORSL/xT5i5sxZ+evQOxkpqUAokMOFaoHcOXLmA1NsFv
|
||||
yryXHK4Ioq9ap2jKlLTWkJWjua9JZ4AmKhbvT8X4ELxIKSCAdJKAWP8ZHbXNu5MD
|
||||
aznyzZQLxSO7uFvu356De75mI5iohZNj5wB5Wju71pBiorTKVj4+iJ4e+xVIzFdG
|
||||
hFC0DehNcl2t9w/y8qHwIQ1yUAjXHLXq0/2jsVeH6bU5q/MsgvUP1jcFe0eyOpxy
|
||||
CDvyFdzZFbI57TnB/fvcZTRZ5ewXMFpH8gzuoFzAjUAP95UjYKgaGdrNPNIy28Ii
|
||||
4zhvdghei2+n9jgiMfcGQg8lyfH5yF0vWWWynX0KcJsRwEZoL2EauVdwq4PcYOoU
|
||||
pQFhpcreCjD4LdZ4yRU4InbhcUogXjrQ9Dz01TbPmQD5b5iso21bCEFBXrhzABEB
|
||||
AAGJAjwEGAEKACYCGwwWIQQVim9TDqIC5fZRYRMU+upjRI4d+QUCaUbs9wUJCRwg
|
||||
hwAKCRAU+upjRI4d+X/XD/sH5xvHPfTJq52v8weFmB52up+DzqG2lyhGdoUQ1Muw
|
||||
dRDLTLXLJrFdfpoOo7/j4Scr0rdc7/dpCn0DLcPuCoPxu+SkjEnVehFmZrGSv7Ga
|
||||
x9dHr3DBh42fdlX/U/EnDuyosY0JU1gNF2/6FIA+bTTOFE3RxfN906RjslYQDjMZ
|
||||
UAlSeLYHOZofdltI0YIr32vrxgdWQGZXPxU4XusDUc0z163OO+TGg7iUNWFZP5Qj
|
||||
ubM7e0YbDX0NPIshk8us99YJmrWnhaix1/W5ryO3DXiGaQ7XFi9u7QofRqvRIctg
|
||||
QXavdepkzJow9V9qpMECAJePIuICq7rm+xy+njjbuF436W7390bfVBwRr+FPADsl
|
||||
jgQP4KvY5rykss30kheom8wNEbveWkhH5oTfH9b7O4KXJfpfJzrlgOWp2BD9JL8t
|
||||
/M4HvFXTr2a75H/QbHK5OFrZeGATuv9OTxv7EZvnrPXU+DYTFldpu7TrNNqKCoj3
|
||||
ZyXmc3Hhg5kskDhfHJppaeOayuhMOpT3ud1MFzROY5SLVIH8rBR12KUgsCUYQcGs
|
||||
Iy0+0QvEGkjb4cAH1NK3VlbqVNsy1RmqRt2B28R2ueewDfTOoqkzt4MmzLqTdnAx
|
||||
mTqmHmkEKhEf3K4MRNUPO2yieUg2COk5l6x9HhAnoxxeOZrTmcMsPY/UViG2HEPm
|
||||
ybkCDQRj7TRDARAA9DZuKdfKq4Bs2+NwxC0aplljWOl8VIsEVg+Q8agD7/HU6/b6
|
||||
Dry0njtWybn2x6Axf/nUdeOC01Fi1lmht/fpj6mRkgAvd/V6P10xnsUoykPSDSTh
|
||||
P25MFFGW3JAA82bwdJ4AJpEQvTZG2nTb3237vlBiI1qHQrac8GYkju2O4UfySRN6
|
||||
7cyi7bMf2pjWBBOEhaNy4b6CMDsb32P/N5J7sTE/TXgrS+u4ITIgjzSrkUkh5Z+B
|
||||
8QVRa7xPIDZJdvZWTEXWu5fgRPZvxbr154GIkWJkFzlDoB1UcO56/uzRUuKhEV6o
|
||||
HW3LMUuWdPMjpHpq8hrL0G2rDniJFUtbDFzHdZK1LUU3T2BJM8rjI3D/euph+IDT
|
||||
27vl5qo72zCYE/iKzx4FMLZcQvx1kUAxkPX8l+dzZEwKeRIIpFDxQvatRtl+z0bM
|
||||
jbkpDb+Yjv66sC4dYRpgTTGX6rok0PWHR3IxDNzyf2j8zQ4LFJ+rVBM1GjGSt6mG
|
||||
j9TeL8CVeiSp4SuJ7I/FJVPHsKb50m+BDzeB31qTydNqh2kKr0DVAUa+TUsCr7e0
|
||||
OYr8WE2adJcRXIW0qw50xXF+W7/05GqSCVD0dpeOUdBTQTsSkQmM3/0hcj9aVo9e
|
||||
UDCM9RF0WRqiDAoHzJFfg+ztamkQI5HO6CklC4Ok22qrHRf6HDNYSuT6QFkAEQEA
|
||||
AYkCPQQYAQoAJwMbIAQWIQQVim9TDqIC5fZRYRMU+upjRI4d+QUCaUbs9wUJCRwf
|
||||
tAAKCRAU+upjRI4d+Y+cD/9yllG6uo934pcHNsVppZBfREFwSc8ywlbosCuSVpay
|
||||
PjSqgrWwDrnqrsk0F2kUdC6rR3BIcXbn+lA9KqylH+cCXAJCkh8EDq6TlQ7Lt5EV
|
||||
w1U0MAMXOyxPwDymQ/BO+iDyjXWkRRYgbF5XiFhCfGeuKyhkhACisAgNZ1uA1P5k
|
||||
0SJYc14YfEhQkB46Y20SpfVHRsQ46FyNB6GHbmTmfoO8La8VTh++7GBdh85HfvkG
|
||||
VNQ3wpi5oXsOLN9+MJOezc0XsW2LQsKQj1/J7QKzGh+lxN5cemsA5aqPzh8dyxeT
|
||||
0lYRFp4AHkimqGUomVpRkbegMIPxXqOE+ZAmsddErw0UtmrKxcmMptOJwNgYzEgu
|
||||
++2vtqerL/NYp+wsdcWaBjCz2F3NiwHgNli7NSB/FPwucZZ5gN5C4SnmeFzrGdHg
|
||||
Oy+tQUN6ayQKljHeBO7CjMlsFNo/dcVrEMa1ShxBMqlj/6ivoEhktLz0Nru4FwNU
|
||||
xE5SJYDYfpjD7Ws8y4LoXgWXjFHrMO6N9GzqLN/e8LT7I+w4ps2MrgJ8QSrelmQ3
|
||||
rjkxp3uWp5v2lqy4rLfpi9iB6zIAeoN2eU1yOM9joxOYMxKYaYeYyP1Mm90wFol8
|
||||
LcTSaN+tVniPddBiL6zvsGBEMbCR9XN3EQ+mErbuw5ovWBOCrr+dvN3FxvD11y4J
|
||||
7w==
|
||||
=mXYP
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
@@ -0,0 +1,51 @@
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mQENBFZu2zwBCADfatenjH3cvhlU6AeInvp4R0JmPBG942aghFj1Qh57smRcO5Bv
|
||||
y9mqrX3UDdmVvu58V3k1k9/GzPnAG1t+c7ohdymv/AMuNY4pE2sfxx7bX+mncTHX
|
||||
5wthipn8kTNm4WjREjCJM1Bm5sozzEZetED3+0/dWlnHl8b38evnLsD+WbSrDPVp
|
||||
o6M6Eg9IfMwTfcXzdmLmSnGolBWDQ9i1a0x0r3o+sDW5UTnr7jVP+zILcnOZ1Ewl
|
||||
Rn9OJ4Qg3ULM7WTMDYpKH4BO7RLR3aJgmsFAHp17vgUnzzFBZ10MCS3UOyUNoyph
|
||||
xo3belf7Q9nrHcSNbqSeQuBnW/vafAZUreAlABEBAAG0IkVlbGNvIERvbHN0cmEg
|
||||
PGVkb2xzdHJhQGdtYWlsLmNvbT6JATwEEwEIACYCGyMHCwkIBwMCAQYVCAIJCgsE
|
||||
FgIDAQIeAQIXgAUCVm7etAIZAQAKCRCBcLRybXGY3q51B/96qt41tmcDSzrj/UTl
|
||||
O6rErfW5zFvVsJTZ95Duwu87t/DVhw5lKBQcjALqVddufw1nMzyN/tSOMVDW8xe4
|
||||
wMEdcU4+QAMzNX80enuyinsw1glxfLcK0+VbTvqNIfw0sG3MjPqNs6cK2VRfMHK4
|
||||
paJjytBVICszNX9TfjLyIpKKoSSo1vqnT47LDZ5GIMy7l9Cs2sO/rqQHSPcR79yz
|
||||
8m8tbHpDDEMZmJeklckKP2QoiqnHiIvlisDxLclYnUmNaPdaN/f++qZz5Yqvu1n+
|
||||
sNUBA5eLaZH64Uy2SwtABxO3JPJ8nQ2+SFZ7ocFm4Gcdv4aM+Ura9S6fvM91tEJp
|
||||
yAQOiQE5BBMBCAAjBQJWbts8AhsjBwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AA
|
||||
CgkQgXC0cm1xmN6sIAgAielxO8zJREqEkA2xudg/o4e9ZlNZ3X1NvY8OzJH/qlB2
|
||||
SmwKqwifhtbC1K0uavXA7eaxdtd2zrI+Yq7IooUyv7juMjHTZhLcFbR5iVkQ4Mfp
|
||||
JmeHXJ/ChYKxD5mMj/C3WbCZ91oCSNZ6Iyi5fvQj/691OC4q+y/2NEUcOI8D8cw8
|
||||
XKHbKtceFYc+nZmdOv3ZZrNTSN/kszGViNNLKgnpPdDVPtLp+vjXtbmitiFG2HL/
|
||||
WfbJ+3Gh2Yr1Vy3O9dWKH++e1AmIv7WWqmUjRFVpqC/wr7/BLaScWT8WKF5vkshU
|
||||
gq8Ez1/cuizsgs3wQIZWgXKQK5njvwnbKg+Zmh/uGbQmRWVsY28gRG9sc3RyYSA8
|
||||
ZWVsY28uZG9sc3RyYUB0d2VhZy5pbz6JAU4EEwEIADgWIQS1QdVTAScOC88Vyl2B
|
||||
cLRybXGY3gUCXELt4gIbIwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRCBcLRy
|
||||
bXGY3ujFCADfS5D1xHU8KH6TpqgssSggYVq62Wwn/Ga+4XPPetM+ajcXagyH6SwB
|
||||
mxlHICcnv9xC93ryiTI10P1ADJl+aBsI66wEdHBU+ty4RTDy4JZNUPtmRCk9LhSc
|
||||
mtUO3ry/wtWkRLdJxP49hg7BbQvWoU0M6WODp7SJjPKPWNX64mzHBeOuy+DqGCbM
|
||||
lpGNCvW8ahU/ewbm7+xwWmzqLDoWzXjHsdF4QdzMVM/vkAgWEP4y0wEqFASzIYaR
|
||||
GNEkBWU4OQVq5Bdm9+wWWAgsbM0FJAQl0GDqnz4QxWzxxCAAXdbh9F5ffafWYsA9
|
||||
bise4ZQLkvYo6iUnrcFm4dtZbT8iL3gptCtFZWxjbyBEb2xzdHJhIDxlZWxjby5k
|
||||
b2xzdHJhQGxvZ2ljYmxveC5jb20+iQE5BBMBCAAjBQJWbt6nAhsjBwsJCAcDAgEG
|
||||
FQgCCQoLBBYCAwECHgECF4AACgkQgXC0cm1xmN4b/wf8DApMV/jSPEpibekrUPQu
|
||||
Ye3Z8cxBQuRm/nOPowtPEH/ShAevrCdRiob2nuEZWNoqZ2e5/+6ud07Hs9bslvco
|
||||
cDv1jeY1dof1idxfKhH3kfSpuD2XJhuzQBxBqOrIlCS/rdnW+Y9wOGD7+bs9QpcA
|
||||
IyAeQGLLkfggAxaGYQ2Aev8pS7i3a/+lOWbFhcTe02I49KemCOJqBorG5FfILLNr
|
||||
DjO3EoutNGpuz6rZvc/BlymphWBoAdUmxgoObr7NYWgw9pI8WeE6C7bbSOO7p5aQ
|
||||
spWXU7Hm17DkzsVDpaJlyClllqK+DdKza5oWlBMe/P02jD3Y+0P/2rCCyQQwmH3D
|
||||
RbkBDQRWbts8AQgA0g556xc08dH5YNEjbCwEt1j+XoRnV4+GfbSJIXOl9joIgzRC
|
||||
4IaijvL8+4biWvX7HiybfvBKto0XB1AWLZRC3jWKX5p74I77UAcrD+VQ/roWQqlJ
|
||||
BKbiQMlRYEsj/5Xnf72G90IP4DAFKvNl+rLChe+jUySA91BCtrYoP75Sw1BE9Cyz
|
||||
xEtm4WUzKAJdXI+ZTBttA2Nbqy+GSuzBs7fSKDwREJaZmVrosvmns+pQVG4WPWf4
|
||||
0l4mPguDQmZ9wSWZvBDkpG7AgHYDRYRGkMbAGsVfc6cScN2VsSTa6cbeeAEowKxM
|
||||
qx9RbY3WOq6aKAm0qDvow1nl7WwXwe8K0wQxfQARAQABiQEfBBgBCAAJBQJWbts8
|
||||
AhsMAAoJEIFwtHJtcZjeuAAH/0YNz2Qe1IAEO5oqEZNFOccL4KxVPrBhWUen83/b
|
||||
C6PjOnOqv6q5ztAcms88WIKxBlfzIfq+dzJcbKVS/H7TEXgcaC+7EYW8sJVEsipN
|
||||
BtEZ3LQNJ5coDjm7WZygniah1lfXNuiritAXduK5FWNNndqGArEaeZ8Shzdo/Uyi
|
||||
b9lOsBIL6xc2ZcnX5f+rTu02LCEtEb0FwCycZLEWYf8hG4k8uttIOZOC+CLk/k8d
|
||||
kBmPikMwUVTTV0CdT1cemQKdTaoAaK+kurF6FYXwcnjhRlHrisSt/tVMEwTw4LUM
|
||||
3MYf6qfjjvE4HlDwZal8th7ccoQp/flfJIuRv85xCcKK+PI=
|
||||
=u5cX
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
@@ -0,0 +1,13 @@
|
||||
# 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 -->
|
||||
@@ -157,7 +157,7 @@ section_title="Release $version_full ($DATE)"
|
||||
|
||||
if ! $IS_PATCH; then
|
||||
echo
|
||||
echo "## Contributors"
|
||||
echo "# Contributors"
|
||||
echo
|
||||
VERSION=$version_full ./maintainers/release-credits
|
||||
fi
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
The release process is intended to create the following for each
|
||||
release:
|
||||
|
||||
* A Git tag
|
||||
* A signed Git tag (public keys in `maintainers/keys/`)
|
||||
|
||||
* Binary tarballs in https://releases.nixos.org/?prefix=nix/
|
||||
|
||||
* Docker images
|
||||
* Docker images (arm64 and amd64 variants, uploaded to DockerHub and GHCR)
|
||||
|
||||
* Closures in https://cache.nixos.org
|
||||
|
||||
@@ -39,6 +39,10 @@ release:
|
||||
* Proof-read / edit / rearrange the release notes if needed. Breaking changes
|
||||
and highlights should go to the top.
|
||||
|
||||
* Run `maintainers/release-credits` to make sure the credits script works
|
||||
and produces a sensible output. Some emails might not automatically map to
|
||||
a GitHub handle.
|
||||
|
||||
* Push.
|
||||
|
||||
```console
|
||||
@@ -97,21 +101,17 @@ release:
|
||||
evaluation ID (e.g. `1780832` in
|
||||
`https://hydra.nixos.org/eval/1780832`).
|
||||
|
||||
* Tag the release and upload the release artifacts to
|
||||
[`releases.nixos.org`](https://releases.nixos.org/) and [Docker Hub](https://hub.docker.com/):
|
||||
* Tag the release:
|
||||
|
||||
```console
|
||||
$ IS_LATEST=1 ./maintainers/upload-release.pl <EVAL-ID>
|
||||
$ IS_LATEST=1 ./maintainers/upload-release.pl --skip-docker --skip-s3 --project-root $PWD <EVAL-ID>
|
||||
```
|
||||
|
||||
Note: `IS_LATEST=1` causes the `latest-release` branch to be
|
||||
force-updated. This is used by the `nixos.org` website to get the
|
||||
[latest Nix manual](https://nixos.org/manual/nixpkgs/unstable/).
|
||||
|
||||
TODO: This script requires the right AWS credentials. Document.
|
||||
|
||||
TODO: This script currently requires a
|
||||
`/home/eelco/Dev/nix-pristine`.
|
||||
* 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: trigger nixos.org netlify: https://docs.netlify.com/configure-builds/build-hooks/
|
||||
|
||||
@@ -176,16 +176,18 @@ release:
|
||||
* Wait for the desired evaluation of the maintenance jobset to finish
|
||||
building.
|
||||
|
||||
* Run
|
||||
* Tag the release
|
||||
|
||||
```console
|
||||
$ IS_LATEST=1 ./maintainers/upload-release.pl <EVAL-ID>
|
||||
$ IS_LATEST=1 ./maintainers/upload-release.pl --skip-docker --skip-s3 --project-root $PWD <EVAL-ID>
|
||||
```
|
||||
|
||||
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
|
||||
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
|
||||
`2.12.2`).
|
||||
|
||||
|
||||
+128
-82
@@ -1,7 +1,8 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i perl -p perl perlPackages.LWPUserAgent perlPackages.LWPProtocolHttps perlPackages.FileSlurp perlPackages.NetAmazonS3 gnupg1
|
||||
#! nix-shell -i perl -p awscli2 perl perlPackages.LWPUserAgent perlPackages.LWPProtocolHttps perlPackages.FileSlurp perlPackages.NetAmazonS3 perlPackages.GetoptLongDescriptive gnupg1
|
||||
|
||||
use strict;
|
||||
use Getopt::Long::Descriptive;
|
||||
use Data::Dumper;
|
||||
use File::Basename;
|
||||
use File::Path;
|
||||
@@ -13,7 +14,30 @@ use Net::Amazon::S3;
|
||||
|
||||
delete $ENV{'shell'}; # shut up a LWP::UserAgent.pm warning
|
||||
|
||||
my $evalId = $ARGV[0] or die "Usage: $0 EVAL-ID\n";
|
||||
my ($opt, $usage) = describe_options(
|
||||
'%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 $channelsBucketName = "nix-channels";
|
||||
@@ -62,25 +86,38 @@ File::Path::make_path($narCache);
|
||||
my $binaryCache = "https://cache.nixos.org/?local-nar-cache=$narCache";
|
||||
|
||||
# S3 setup.
|
||||
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'} or die "No AWS_SECRET_ACCESS_KEY given.";
|
||||
my $aws_access_key_id = $ENV{'AWS_ACCESS_KEY_ID'};
|
||||
my $aws_secret_access_key = $ENV{'AWS_SECRET_ACCESS_KEY'};
|
||||
my $aws_session_token = $ENV{'AWS_SESSION_TOKEN'};
|
||||
|
||||
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",
|
||||
});
|
||||
my ($s3, $releasesBucket, $s3_channels, $channelsBucket);
|
||||
|
||||
my $releasesBucket = $s3->bucket($releasesBucketName) or die;
|
||||
unless ($opt->skip_s3) {
|
||||
$aws_access_key_id or die "No AWS_ACCESS_KEY_ID given.";
|
||||
$aws_secret_access_key or die "No AWS_SECRET_ACCESS_KEY given.";
|
||||
|
||||
my $s3_us = Net::Amazon::S3->new(
|
||||
{ aws_access_key_id => $aws_access_key_id,
|
||||
aws_secret_access_key => $aws_secret_access_key,
|
||||
retry => 1,
|
||||
});
|
||||
$s3 = 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,
|
||||
host => $opt->s3_host,
|
||||
secure => ($opt->s3_endpoint && $opt->s3_endpoint =~ /^http:/) ? 0 : 1,
|
||||
});
|
||||
|
||||
my $channelsBucket = $s3_us->bucket($channelsBucketName) or die;
|
||||
$releasesBucket = $s3->bucket($releasesBucketName) 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 {
|
||||
my ($jobName, $output) = @_;
|
||||
@@ -115,11 +152,12 @@ sub copyManual {
|
||||
File::Path::remove_tree("$tmpDir/manual.tmp", {safe => 1});
|
||||
}
|
||||
|
||||
system("aws s3 sync '$tmpDir/manual' s3://$releasesBucketName/$releaseDir/manual") == 0
|
||||
my $awsEndpoint = $opt->s3_endpoint ? "--endpoint-url " . $opt->s3_endpoint : "";
|
||||
system("aws $awsEndpoint s3 sync '$tmpDir/manual' s3://$releasesBucketName/$releaseDir/manual") == 0
|
||||
or die "syncing manual to S3\n";
|
||||
}
|
||||
|
||||
copyManual;
|
||||
copyManual unless $opt->skip_s3;
|
||||
|
||||
sub downloadFile {
|
||||
my ($jobName, $productNr, $dstName) = @_;
|
||||
@@ -158,30 +196,12 @@ sub downloadFile {
|
||||
return $sha256_expected;
|
||||
}
|
||||
|
||||
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.
|
||||
# Upload docker images.
|
||||
my $dockerManifest = "";
|
||||
my $dockerManifestLatest = "";
|
||||
my $haveDocker = 0;
|
||||
|
||||
unless ($opt->skip_docker) {
|
||||
for my $platforms (["x86_64-linux", "amd64"], ["aarch64-linux", "arm64"]) {
|
||||
my $system = $platforms->[0];
|
||||
my $dockerPlatform = $platforms->[1];
|
||||
@@ -195,8 +215,8 @@ for my $platforms (["x86_64-linux", "amd64"], ["aarch64-linux", "arm64"]) {
|
||||
print STDERR "loading docker image for $dockerPlatform...\n";
|
||||
system("docker load -i $tmpDir/$fn") == 0 or die;
|
||||
|
||||
my $tag = "nixos/nix:$version-$dockerPlatform";
|
||||
my $latestTag = "nixos/nix:latest-$dockerPlatform";
|
||||
my $tag = $opt->docker_owner . ":$version-$dockerPlatform";
|
||||
my $latestTag = $opt->docker_owner . ":latest-$dockerPlatform";
|
||||
|
||||
print STDERR "tagging $version docker image for $dockerPlatform...\n";
|
||||
system("docker tag nix:$version $tag") == 0 or die;
|
||||
@@ -219,68 +239,94 @@ for my $platforms (["x86_64-linux", "amd64"], ["aarch64-linux", "arm64"]) {
|
||||
}
|
||||
|
||||
if ($haveDocker) {
|
||||
my $dockerOwner = $opt->docker_owner;
|
||||
print STDERR "creating multi-platform docker manifest...\n";
|
||||
system("docker manifest rm nixos/nix:$version");
|
||||
system("docker manifest create nixos/nix:$version $dockerManifest") == 0 or die;
|
||||
system("docker manifest rm $dockerOwner:$version");
|
||||
system("docker manifest create $dockerOwner:$version $dockerManifest") == 0 or die;
|
||||
if ($isLatest) {
|
||||
print STDERR "creating latest multi-platform docker manifest...\n";
|
||||
system("docker manifest rm nixos/nix:latest");
|
||||
system("docker manifest create nixos/nix:latest $dockerManifestLatest") == 0 or die;
|
||||
system("docker manifest rm $dockerOwner:latest");
|
||||
system("docker manifest create $dockerOwner:latest $dockerManifestLatest") == 0 or die;
|
||||
}
|
||||
|
||||
print STDERR "pushing multi-platform docker manifest...\n";
|
||||
system("docker manifest push nixos/nix:$version") == 0 or die;
|
||||
system("docker manifest push $dockerOwner:$version") == 0 or die;
|
||||
|
||||
if ($isLatest) {
|
||||
print STDERR "pushing latest multi-platform docker manifest...\n";
|
||||
system("docker manifest push nixos/nix:latest") == 0 or die;
|
||||
system("docker manifest push $dockerOwner: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.
|
||||
for my $fn (glob "$tmpDir/*") {
|
||||
my $name = basename($fn);
|
||||
next if $name eq "manual";
|
||||
my $dstKey = "$releaseDir/" . $name;
|
||||
unless (defined $releasesBucket->head_key($dstKey)) {
|
||||
print STDERR "uploading $fn to s3://$releasesBucketName/$dstKey...\n";
|
||||
unless ($opt->skip_s3) {
|
||||
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");
|
||||
|
||||
my $configuration = ();
|
||||
$configuration->{content_type} = "application/octet-stream";
|
||||
# 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");
|
||||
|
||||
if ($fn =~ /.sha256|install|\.nix$/) {
|
||||
$configuration->{content_type} = "text/plain";
|
||||
for my $fn (glob "$tmpDir/*") {
|
||||
my $name = basename($fn);
|
||||
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;
|
||||
}
|
||||
|
||||
$releasesBucket->add_key_filename($dstKey, $fn, $configuration)
|
||||
or die $releasesBucket->err . ": " . $releasesBucket->errstr;
|
||||
}
|
||||
|
||||
# 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;
|
||||
}
|
||||
|
||||
# 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.
|
||||
chdir("/home/eelco/Dev/nix-pristine") 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 push --tags") == 0 or die;
|
||||
system("git push --force-with-lease origin $nixRev:refs/heads/latest-release") == 0 or die if $isLatest;
|
||||
unless ($opt->skip_git) {
|
||||
chdir($opt->project_root) or die "Cannot chdir to " . $opt->project_root . ": $!";
|
||||
system("git remote update origin") == 0 or die;
|
||||
system("git tag --force --sign $version $nixRev -m 'Tagging release $version'") == 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;
|
||||
}
|
||||
|
||||
File::Path::remove_tree($narCache, {safe => 1});
|
||||
File::Path::remove_tree($tmpDir, {safe => 1});
|
||||
+2
-5
@@ -1,16 +1,13 @@
|
||||
# This is just a stub project to include all the others as subprojects
|
||||
# for development shell purposes
|
||||
|
||||
project(
|
||||
'nix-dev-shell',
|
||||
'cpp',
|
||||
project('nix-dev-shell', 'cpp',
|
||||
version : files('.version'),
|
||||
subproject_dir : 'src',
|
||||
default_options : [
|
||||
'localstatedir=/nix/var',
|
||||
# hack for trailing newline
|
||||
],
|
||||
meson_version : '>= 1.1',
|
||||
meson_version : '>= 1.1'
|
||||
)
|
||||
|
||||
# Internal Libraries
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
indent_by = ' '
|
||||
space_array = true
|
||||
kwargs_force_multiline = false
|
||||
wide_colon = true
|
||||
group_arg_value = true
|
||||
indent_before_comments = ' '
|
||||
use_editor_config = true
|
||||
+3
-12
@@ -1,22 +1,13 @@
|
||||
# vim: filetype=meson
|
||||
|
||||
option(
|
||||
'doc-gen',
|
||||
type : 'boolean',
|
||||
value : false,
|
||||
option('doc-gen', type : 'boolean', value : false,
|
||||
description : 'Generate documentation',
|
||||
)
|
||||
|
||||
option(
|
||||
'unit-tests',
|
||||
type : 'boolean',
|
||||
value : true,
|
||||
option('unit-tests', type : 'boolean', value : true,
|
||||
description : 'Build unit tests',
|
||||
)
|
||||
|
||||
option(
|
||||
'bindings',
|
||||
type : 'boolean',
|
||||
value : true,
|
||||
option('bindings', type : 'boolean', value : true,
|
||||
description : 'Build language bindings (e.g. Perl)',
|
||||
)
|
||||
@@ -1,2 +1 @@
|
||||
d @localstatedir@/nix/daemon-socket 0755 root root - -
|
||||
d @localstatedir@/nix/builds 0755 root root 7d -
|
||||
d @localstatedir@/nix/daemon-socket 0755 root root - -
|
||||
@@ -0,0 +1,19 @@
|
||||
# This attempts to translate meson cpu_family and cpu_name specified via
|
||||
# --cross-file [1] into a nix *system double*. Nixpkgs mostly respects ([2]) the
|
||||
# conventions outlined in [1].
|
||||
#
|
||||
# [1]: https://mesonbuild.com/Reference-tables.html#cpu-families
|
||||
# [2]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/lib/meson.nix
|
||||
|
||||
nix_system_cpu = {'ppc64' : 'powerpc64', 'ppc' : 'powerpc', 'x86' : 'i686'}.get(
|
||||
host_machine.cpu_family(),
|
||||
host_machine.cpu_family(),
|
||||
)
|
||||
|
||||
if (host_machine.cpu_family() in [ 'ppc64', 'ppc' ]) and host_machine.endian() == 'little'
|
||||
nix_system_cpu += 'le'
|
||||
elif host_machine.cpu_family() in [ 'mips64', 'mips' ] and host_machine.endian() == 'little'
|
||||
nix_system_cpu += 'el'
|
||||
elif host_machine.cpu_family() == 'arm'
|
||||
nix_system_cpu = host_machine.cpu()
|
||||
endif
|
||||
@@ -2,5 +2,5 @@ if host_machine.system() == 'windows'
|
||||
# https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170
|
||||
# #define _WIN32_WINNT_WIN8 0x0602
|
||||
# We currently don't use any API which requires higher than this.
|
||||
add_project_arguments([ '-D_WIN32_WINNT=0x0602' ], language : 'cpp')
|
||||
add_project_arguments([ '-D_WIN32_WINNT=0x0602' ], language: 'cpp')
|
||||
endif
|
||||
@@ -54,12 +54,12 @@ let
|
||||
preConfigure =
|
||||
prevAttrs.preConfigure or ""
|
||||
+
|
||||
# Update the repo-global .version file.
|
||||
# Symlink ./.version points there, but by default only workDir is writable.
|
||||
''
|
||||
chmod u+w ./.version
|
||||
echo ${finalAttrs.version} > ./.version
|
||||
'';
|
||||
# Update the repo-global .version file.
|
||||
# Symlink ./.version points there, but by default only workDir is writable.
|
||||
''
|
||||
chmod u+w ./.version
|
||||
echo ${finalAttrs.version} > ./.version
|
||||
'';
|
||||
};
|
||||
|
||||
localSourceLayer =
|
||||
@@ -148,7 +148,8 @@ let
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
] ++ prevAttrs.nativeBuildInputs or [ ];
|
||||
]
|
||||
++ prevAttrs.nativeBuildInputs or [ ];
|
||||
mesonCheckFlags = prevAttrs.mesonCheckFlags or [ ] ++ [
|
||||
"--print-errorlogs"
|
||||
];
|
||||
|
||||
+10
-11
@@ -71,17 +71,16 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
|
||||
# We use this shell with the local checkout, not unpackPhase.
|
||||
src = null;
|
||||
|
||||
env =
|
||||
{
|
||||
# For `make format`, to work without installing pre-commit
|
||||
_NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml"
|
||||
modular.pre-commit.settings.rawConfig
|
||||
}";
|
||||
}
|
||||
// lib.optionalAttrs stdenv.hostPlatform.isLinux {
|
||||
CC_LD = "mold";
|
||||
CXX_LD = "mold";
|
||||
};
|
||||
env = {
|
||||
# For `make format`, to work without installing pre-commit
|
||||
_NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml"
|
||||
modular.pre-commit.settings.rawConfig
|
||||
}";
|
||||
}
|
||||
// lib.optionalAttrs stdenv.hostPlatform.isLinux {
|
||||
CC_LD = "mold";
|
||||
CXX_LD = "mold";
|
||||
};
|
||||
|
||||
mesonFlags =
|
||||
map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents2.nix-util.mesonFlags)
|
||||
|
||||
+31
-32
@@ -47,25 +47,25 @@
|
||||
}:
|
||||
|
||||
let
|
||||
libs =
|
||||
{
|
||||
inherit
|
||||
nix-util
|
||||
nix-util-c
|
||||
nix-store
|
||||
nix-store-c
|
||||
nix-fetchers
|
||||
nix-fetchers-c
|
||||
nix-expr
|
||||
nix-expr-c
|
||||
nix-flake
|
||||
nix-flake-c
|
||||
nix-main
|
||||
nix-main-c
|
||||
nix-cmd
|
||||
;
|
||||
}
|
||||
// lib.optionalAttrs
|
||||
libs = {
|
||||
inherit
|
||||
nix-util
|
||||
nix-util-c
|
||||
nix-store
|
||||
nix-store-c
|
||||
nix-fetchers
|
||||
nix-fetchers-c
|
||||
nix-expr
|
||||
nix-expr-c
|
||||
nix-flake
|
||||
nix-flake-c
|
||||
nix-main
|
||||
nix-main-c
|
||||
nix-cmd
|
||||
;
|
||||
}
|
||||
//
|
||||
lib.optionalAttrs
|
||||
(!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
|
||||
{
|
||||
# Currently fails in static build
|
||||
@@ -127,20 +127,19 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
*/
|
||||
dontFixup = true;
|
||||
|
||||
checkInputs =
|
||||
[
|
||||
# Make sure the unit tests have passed
|
||||
nix-util-tests.tests.run
|
||||
nix-store-tests.tests.run
|
||||
nix-expr-tests.tests.run
|
||||
nix-fetchers-tests.tests.run
|
||||
nix-flake-tests.tests.run
|
||||
checkInputs = [
|
||||
# Make sure the unit tests have passed
|
||||
nix-util-tests.tests.run
|
||||
nix-store-tests.tests.run
|
||||
nix-expr-tests.tests.run
|
||||
nix-fetchers-tests.tests.run
|
||||
nix-flake-tests.tests.run
|
||||
|
||||
# Make sure the functional tests have passed
|
||||
nix-functional-tests
|
||||
]
|
||||
++ lib.optionals
|
||||
(!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
|
||||
# Make sure the functional tests have passed
|
||||
nix-functional-tests
|
||||
]
|
||||
++
|
||||
lib.optionals (!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
|
||||
[
|
||||
# Perl currently fails in static build
|
||||
# TODO: Split out tests into a separate derivation?
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <chrono>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <condition_variable>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <locale>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <queue>
|
||||
#include <random>
|
||||
#include <regex>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <grp.h>
|
||||
# include <netdb.h>
|
||||
# include <pwd.h>
|
||||
# include <sys/resource.h>
|
||||
# include <sys/select.h>
|
||||
# include <sys/socket.h>
|
||||
# include <sys/utsname.h>
|
||||
# include <sys/wait.h>
|
||||
# include <termios.h>
|
||||
#endif
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
@@ -834,13 +834,8 @@ install_from_extracted_nix() {
|
||||
(
|
||||
cd "$EXTRACTED_NIX_PATH"
|
||||
|
||||
if is_os_darwin; then
|
||||
_sudo "to copy the basic Nix files to the new store at $NIX_ROOT/store" \
|
||||
cp -RPp ./store/* "$NIX_ROOT/store/"
|
||||
else
|
||||
_sudo "to copy the basic Nix files to the new store at $NIX_ROOT/store" \
|
||||
cp -RP --preserve=ownership,timestamps ./store/* "$NIX_ROOT/store/"
|
||||
fi
|
||||
_sudo "to copy the basic Nix files to the new store at $NIX_ROOT/store" \
|
||||
cp -RPp ./store/* "$NIX_ROOT/store/"
|
||||
|
||||
_sudo "to make the new store non-writable at $NIX_ROOT/store" \
|
||||
chmod -R ugo-w "$NIX_ROOT/store/"
|
||||
|
||||
@@ -167,11 +167,7 @@ for i in $(cd "$self/store" >/dev/null && echo ./*); do
|
||||
rm -rf "$i_tmp"
|
||||
fi
|
||||
if ! [ -e "$dest/store/$i" ]; then
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
cp -RPp "$self/store/$i" "$i_tmp"
|
||||
else
|
||||
cp -RP --preserve=ownership,timestamps "$self/store/$i" "$i_tmp"
|
||||
fi
|
||||
cp -RPp "$self/store/$i" "$i_tmp"
|
||||
chmod -R a-w "$i_tmp"
|
||||
chmod +w "$i_tmp"
|
||||
mv "$i_tmp" "$dest/store/$i"
|
||||
|
||||
@@ -323,17 +323,9 @@ static int main_build_remote(int argc, char ** argv)
|
||||
drv.inputSrcs = store->parseStorePathSet(inputs);
|
||||
optResult = sshStore->buildDerivation(*drvPath, (const BasicDerivation &) drv);
|
||||
auto & result = *optResult;
|
||||
if (!result.success()) {
|
||||
if (settings.keepFailed) {
|
||||
warn(
|
||||
"The failed build directory was kept on the remote builder due to `--keep-failed`.%s",
|
||||
(settings.thisSystem == drv.platform || settings.extraPlatforms.get().count(drv.platform) > 0)
|
||||
? " You can re-run the command with `--builders ''` to disable remote building for this invocation."
|
||||
: "");
|
||||
}
|
||||
if (!result.success())
|
||||
throw Error(
|
||||
"build of '%s' on '%s' failed: %s", store->printStorePath(*drvPath), storeUri, result.errorMsg);
|
||||
}
|
||||
} else {
|
||||
copyClosure(*store, *sshStore, StorePathSet{*drvPath}, NoRepair, NoCheckSigs, substitute);
|
||||
auto res = sshStore->buildPathsWithResults({DerivedPath::Built{
|
||||
|
||||
@@ -33,12 +33,8 @@ EvalSettings evalSettings{
|
||||
auto flakeRef = parseFlakeRef(fetchSettings, std::string{rest}, {}, true, false);
|
||||
debug("fetching flake search path element '%s''", rest);
|
||||
auto [accessor, lockedRef] = flakeRef.resolve(state.store).lazyFetch(state.store);
|
||||
auto storePath = nix::fetchToStore(
|
||||
state.fetchSettings,
|
||||
*state.store,
|
||||
SourcePath(accessor),
|
||||
FetchMode::Copy,
|
||||
lockedRef.input.getName());
|
||||
auto storePath =
|
||||
nix::fetchToStore(*state.store, SourcePath(accessor), FetchMode::Copy, lockedRef.input.getName());
|
||||
state.allowPath(storePath);
|
||||
return state.storePath(storePath);
|
||||
},
|
||||
@@ -179,7 +175,7 @@ SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * bas
|
||||
{
|
||||
if (EvalSettings::isPseudoUrl(s)) {
|
||||
auto accessor = fetchers::downloadTarball(state.store, state.fetchSettings, EvalSettings::resolvePseudoUrl(s));
|
||||
auto storePath = fetchToStore(state.fetchSettings, *state.store, SourcePath(accessor), FetchMode::Copy);
|
||||
auto storePath = fetchToStore(*state.store, SourcePath(accessor), FetchMode::Copy);
|
||||
return state.storePath(storePath);
|
||||
}
|
||||
|
||||
@@ -187,8 +183,8 @@ SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * bas
|
||||
experimentalFeatureSettings.require(Xp::Flakes);
|
||||
auto flakeRef = parseFlakeRef(fetchSettings, std::string(s.substr(6)), {}, true, false);
|
||||
auto [accessor, lockedRef] = flakeRef.resolve(state.store).lazyFetch(state.store);
|
||||
auto storePath = nix::fetchToStore(
|
||||
state.fetchSettings, *state.store, SourcePath(accessor), FetchMode::Copy, lockedRef.input.getName());
|
||||
auto storePath =
|
||||
nix::fetchToStore(*state.store, SourcePath(accessor), FetchMode::Copy, lockedRef.input.getName());
|
||||
state.allowPath(storePath);
|
||||
return state.storePath(storePath);
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ struct MixEnvironment : virtual Args
|
||||
|
||||
StringSet keepVars;
|
||||
StringSet unsetVars;
|
||||
StringMap setVars;
|
||||
std::map<std::string, std::string> setVars;
|
||||
bool ignoreEnvironment;
|
||||
|
||||
MixEnvironment();
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "nix/util/canon-path.hh"
|
||||
#include "nix/main/common-args.hh"
|
||||
#include "nix/expr/search-path.hh"
|
||||
#include "nix/expr/eval-settings.hh"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
@@ -18,25 +17,27 @@ struct Settings;
|
||||
}
|
||||
|
||||
class EvalState;
|
||||
struct EvalSettings;
|
||||
struct CompatibilitySettings;
|
||||
class Bindings;
|
||||
struct SourcePath;
|
||||
|
||||
namespace flake {
|
||||
struct Settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Get rid of global settings variables
|
||||
* @todo Get rid of global setttings variables
|
||||
*/
|
||||
extern fetchers::Settings fetchSettings;
|
||||
|
||||
/**
|
||||
* @todo Get rid of global settings variables
|
||||
* @todo Get rid of global setttings variables
|
||||
*/
|
||||
extern EvalSettings evalSettings;
|
||||
|
||||
/**
|
||||
* @todo Get rid of global settings variables
|
||||
* @todo Get rid of global setttings variables
|
||||
*/
|
||||
extern flake::Settings flakeSettings;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ std::optional<DerivedPathWithInfo>
|
||||
InstallableValue::trySinglePathToDerivedPaths(Value & v, const PosIdx pos, std::string_view errorCtx)
|
||||
{
|
||||
if (v.type() == nPath) {
|
||||
auto storePath = fetchToStore(state->fetchSettings, *state->store, v.path(), FetchMode::Copy);
|
||||
auto storePath = fetchToStore(*state->store, v.path(), FetchMode::Copy);
|
||||
return {{
|
||||
.path =
|
||||
DerivedPath::Opaque{
|
||||
|
||||
@@ -198,7 +198,7 @@ SourceExprCommand::SourceExprCommand()
|
||||
.shortName = 'f',
|
||||
.description =
|
||||
"Interpret [*installables*](@docroot@/command-ref/new-cli/nix.md#installables) as attribute paths relative to the Nix expression stored in *file*. "
|
||||
"If *file* is the character -, then a Nix expression is read from standard input. "
|
||||
"If *file* is the character -, then a Nix expression will be read from standard input. "
|
||||
"Implies `--impure`.",
|
||||
.category = installablesCategory,
|
||||
.labels = {"file"},
|
||||
@@ -818,7 +818,7 @@ RawInstallablesCommand::RawInstallablesCommand()
|
||||
void RawInstallablesCommand::applyDefaultInstallables(std::vector<std::string> & rawInstallables)
|
||||
{
|
||||
if (rawInstallables.empty()) {
|
||||
// FIXME: commands like "nix profile add" should not have a
|
||||
// FIXME: commands like "nix profile install" should not have a
|
||||
// default, probably.
|
||||
rawInstallables.push_back(".");
|
||||
}
|
||||
|
||||
@@ -53,7 +53,8 @@ mkMesonLibrary (finalAttrs: {
|
||||
|
||||
buildInputs = [
|
||||
({ inherit editline readline; }.${readlineFlavor})
|
||||
] ++ lib.optional enableMarkdown lowdown;
|
||||
]
|
||||
++ lib.optional enableMarkdown lowdown;
|
||||
|
||||
propagatedBuildInputs = [
|
||||
nix-util
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#if USE_READLINE
|
||||
# include <readline/history.h>
|
||||
# include <readline/readline.h>
|
||||
|
||||
+13
-55
@@ -66,7 +66,6 @@ struct NixRepl : AbstractNixRepl, detail::ReplCompleterMixin, gc
|
||||
|
||||
const static int envSize = 32768;
|
||||
std::shared_ptr<StaticEnv> staticEnv;
|
||||
Value lastLoaded;
|
||||
Env * env;
|
||||
int displ;
|
||||
StringSet varNames;
|
||||
@@ -97,7 +96,6 @@ struct NixRepl : AbstractNixRepl, detail::ReplCompleterMixin, gc
|
||||
void loadFiles();
|
||||
void loadFlakes();
|
||||
void reloadFilesAndFlakes();
|
||||
void showLastLoaded();
|
||||
void addAttrsToScope(Value & attrs);
|
||||
void addVarToScope(const Symbol name, Value & v);
|
||||
Expr * parseString(std::string s);
|
||||
@@ -167,8 +165,6 @@ static std::ostream & showDebugTrace(std::ostream & out, const PosTable & positi
|
||||
return out;
|
||||
}
|
||||
|
||||
MakeError(IncompleteReplExpr, ParseError);
|
||||
|
||||
static bool isFirstRepl = true;
|
||||
|
||||
ReplExitStatus NixRepl::mainLoop()
|
||||
@@ -217,8 +213,16 @@ ReplExitStatus NixRepl::mainLoop()
|
||||
default:
|
||||
unreachable();
|
||||
}
|
||||
} catch (IncompleteReplExpr &) {
|
||||
continue;
|
||||
} catch (ParseError & e) {
|
||||
if (e.msg().find("unexpected end of file") != std::string::npos) {
|
||||
// For parse errors on incomplete input, we continue waiting for the next line of
|
||||
// input without clearing the input so far.
|
||||
continue;
|
||||
} else {
|
||||
printMsg(lvlError, e.msg());
|
||||
}
|
||||
} catch (EvalError & e) {
|
||||
printMsg(lvlError, e.msg());
|
||||
} catch (Error & e) {
|
||||
printMsg(lvlError, e.msg());
|
||||
} catch (Interrupted & e) {
|
||||
@@ -303,7 +307,7 @@ StringSet NixRepl::completePrefix(const std::string & prefix)
|
||||
} catch (BadURL & e) {
|
||||
// Quietly ignore BadURL flake-related errors.
|
||||
} catch (FileNotFound & e) {
|
||||
// Quietly ignore non-existent file being `import`-ed.
|
||||
// Quietly ignore non-existent file beeing `import`-ed.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +390,6 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||
<< " current profile\n"
|
||||
<< " :l, :load <path> Load Nix expression and add it to scope\n"
|
||||
<< " :lf, :load-flake <ref> Load Nix flake and add it to scope\n"
|
||||
<< " :ll, :last-loaded Show most recently loaded variables added to scope\n"
|
||||
<< " :p, :print <expr> Evaluate and print expression recursively\n"
|
||||
<< " Strings are printed directly, without escaping.\n"
|
||||
<< " :q, :quit Exit nix-repl\n"
|
||||
@@ -475,10 +478,6 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||
loadFlake(arg);
|
||||
}
|
||||
|
||||
else if (command == ":ll" || command == ":last-loaded") {
|
||||
showLastLoaded();
|
||||
}
|
||||
|
||||
else if (command == ":r" || command == ":reload") {
|
||||
state->resetFileCache();
|
||||
reloadFilesAndFlakes();
|
||||
@@ -494,7 +493,7 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||
auto path = state->coerceToPath(noPos, v, context, "while evaluating the filename to edit");
|
||||
return {path, 0};
|
||||
} else if (v.isLambda()) {
|
||||
auto pos = state->positions[v.lambda().fun->pos];
|
||||
auto pos = state->positions[v.payload.lambda.fun->pos];
|
||||
if (auto path = std::get_if<SourcePath>(&pos.origin))
|
||||
return {*path, pos.line};
|
||||
else
|
||||
@@ -769,16 +768,6 @@ void NixRepl::initEnv()
|
||||
varNames.emplace(state->symbols[i.first]);
|
||||
}
|
||||
|
||||
void NixRepl::showLastLoaded()
|
||||
{
|
||||
RunPager pager;
|
||||
|
||||
for (auto & i : *lastLoaded.attrs()) {
|
||||
std::string_view name = state->symbols[i.name];
|
||||
logger->cout(name);
|
||||
}
|
||||
}
|
||||
|
||||
void NixRepl::reloadFilesAndFlakes()
|
||||
{
|
||||
initEnv();
|
||||
@@ -831,27 +820,6 @@ void NixRepl::addAttrsToScope(Value & attrs)
|
||||
staticEnv->sort();
|
||||
staticEnv->deduplicate();
|
||||
notice("Added %1% variables.", attrs.attrs()->size());
|
||||
|
||||
lastLoaded = attrs;
|
||||
|
||||
const int max_print = 20;
|
||||
int counter = 0;
|
||||
std::ostringstream loaded;
|
||||
for (auto & i : attrs.attrs()->lexicographicOrder(state->symbols)) {
|
||||
if (counter >= max_print)
|
||||
break;
|
||||
|
||||
if (counter > 0)
|
||||
loaded << ", ";
|
||||
|
||||
printIdentifier(loaded, state->symbols[i->name]);
|
||||
counter += 1;
|
||||
}
|
||||
|
||||
notice("%1%", loaded.str());
|
||||
|
||||
if (attrs.attrs()->size() > max_print)
|
||||
notice("... and %1% more; view with :ll", attrs.attrs()->size() - max_print);
|
||||
}
|
||||
|
||||
void NixRepl::addVarToScope(const Symbol name, Value & v)
|
||||
@@ -873,17 +841,7 @@ Expr * NixRepl::parseString(std::string s)
|
||||
|
||||
void NixRepl::evalString(std::string s, Value & v)
|
||||
{
|
||||
Expr * e;
|
||||
try {
|
||||
e = parseString(s);
|
||||
} catch (ParseError & e) {
|
||||
if (e.msg().find("unexpected end of file") != std::string::npos)
|
||||
// For parse errors on incomplete input, we continue waiting for the next line of
|
||||
// input without clearing the input so far.
|
||||
throw IncompleteReplExpr(e.msg());
|
||||
else
|
||||
throw;
|
||||
}
|
||||
Expr * e = parseString(s);
|
||||
e->eval(*state, *env, v);
|
||||
state->forceValue(v, v.determinePos(noPos));
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ const char * nix_get_path_string(nix_c_context * context, const nix_value * valu
|
||||
// We could use v.path().to_string().c_str(), but I'm concerned this
|
||||
// crashes. Looks like .path() allocates a CanonPath with a copy of the
|
||||
// string, then it gets the underlying data from that.
|
||||
return v.pathStr();
|
||||
return v.payload.path.path;
|
||||
}
|
||||
NIXC_CATCH_ERRS_NULL
|
||||
}
|
||||
@@ -324,7 +324,7 @@ nix_value * nix_get_list_byidx(nix_c_context * context, const nix_value * value,
|
||||
try {
|
||||
auto & v = check_value_in(value);
|
||||
assert(v.type() == nix::nList);
|
||||
auto * p = v.listView()[ix];
|
||||
auto * p = v.listElems()[ix];
|
||||
nix_gc_incref(nullptr, p);
|
||||
if (p != nullptr)
|
||||
state->state.forceValue(*p, nix::noPos);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
# Public headers directory
|
||||
|
||||
include_dirs = [ include_directories('../../..') ]
|
||||
include_dirs = [include_directories('../../..')]
|
||||
|
||||
headers = files(
|
||||
'libexpr.hh',
|
||||
'nix_api_expr.hh',
|
||||
'value/context.hh',
|
||||
# hack for trailing newline
|
||||
)
|
||||
@@ -392,7 +392,7 @@ TEST_F(ErrorTraceTest, filterSource)
|
||||
HintFmt("expected a function but found %s: %s", "a list", Uncolored("[ ]")),
|
||||
HintFmt("while evaluating the first argument passed to builtins.filterSource"));
|
||||
|
||||
// Unsupported by store "dummy"
|
||||
// Usupported by store "dummy"
|
||||
|
||||
// ASSERT_TRACE2("filterSource (_: 1) ./.",
|
||||
// TypeError,
|
||||
@@ -574,7 +574,7 @@ TEST_F(ErrorTraceTest, mapAttrs)
|
||||
HintFmt("expected a set but found %s: %s", "a list", Uncolored("[ ]")),
|
||||
HintFmt("while evaluating the second argument passed to builtins.mapAttrs"));
|
||||
|
||||
// XXX: deferred
|
||||
// XXX: defered
|
||||
// ASSERT_TRACE2("mapAttrs \"\" { foo.bar = 1; }",
|
||||
// TypeError,
|
||||
// HintFmt("attempt to call something which is not a function but %s", "a string"),
|
||||
@@ -605,9 +605,9 @@ TEST_F(ErrorTraceTest, zipAttrsWith)
|
||||
HintFmt("expected a set but found %s: %s", "an integer", Uncolored(ANSI_CYAN "1" ANSI_NORMAL)),
|
||||
HintFmt("while evaluating a value of the list passed as second argument to builtins.zipAttrsWith"));
|
||||
|
||||
// XXX: How to properly tell that the function takes two arguments ?
|
||||
// XXX: How to properly tell that the fucntion takes two arguments ?
|
||||
// The same question also applies to sort, and maybe others.
|
||||
// Due to laziness, we only create a thunk, and it fails later on.
|
||||
// Due to lazyness, we only create a thunk, and it fails later on.
|
||||
// ASSERT_TRACE2("zipAttrsWith (_: 1) [ { foo = 1; } ]",
|
||||
// TypeError,
|
||||
// HintFmt("attempt to call something which is not a function but %s", "an integer"),
|
||||
@@ -825,7 +825,7 @@ TEST_F(ErrorTraceTest, genList)
|
||||
HintFmt("expected a function but found %s: %s", "an integer", Uncolored(ANSI_CYAN "1" ANSI_NORMAL)),
|
||||
HintFmt("while evaluating the first argument passed to builtins.genList"));
|
||||
|
||||
// XXX: deferred
|
||||
// XXX: defered
|
||||
// ASSERT_TRACE2("genList (x: x + \"foo\") 2 #TODO",
|
||||
// TypeError,
|
||||
// HintFmt("cannot add %s to an integer", "a string"),
|
||||
|
||||
@@ -170,8 +170,8 @@ TEST_F(PrimOpTest, attrValues)
|
||||
{
|
||||
auto v = eval("builtins.attrValues { x = \"foo\"; a = 1; }");
|
||||
ASSERT_THAT(v, IsListOfSize(2));
|
||||
ASSERT_THAT(*v.listView()[0], IsIntEq(1));
|
||||
ASSERT_THAT(*v.listView()[1], IsStringEq("foo"));
|
||||
ASSERT_THAT(*v.listElems()[0], IsIntEq(1));
|
||||
ASSERT_THAT(*v.listElems()[1], IsStringEq("foo"));
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, getAttr)
|
||||
@@ -284,8 +284,8 @@ TEST_F(PrimOpTest, catAttrs)
|
||||
{
|
||||
auto v = eval("builtins.catAttrs \"a\" [{a = 1;} {b = 0;} {a = 2;}]");
|
||||
ASSERT_THAT(v, IsListOfSize(2));
|
||||
ASSERT_THAT(*v.listView()[0], IsIntEq(1));
|
||||
ASSERT_THAT(*v.listView()[1], IsIntEq(2));
|
||||
ASSERT_THAT(*v.listElems()[0], IsIntEq(1));
|
||||
ASSERT_THAT(*v.listElems()[1], IsIntEq(2));
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, functionArgs)
|
||||
@@ -341,7 +341,6 @@ TEST_F(PrimOpTest, elemtAt)
|
||||
TEST_F(PrimOpTest, elemtAtOutOfBounds)
|
||||
{
|
||||
ASSERT_THROW(eval("builtins.elemAt [0 1 2 3] 5"), Error);
|
||||
ASSERT_THROW(eval("builtins.elemAt [0] 4294967296"), Error);
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, head)
|
||||
@@ -364,8 +363,7 @@ TEST_F(PrimOpTest, tail)
|
||||
{
|
||||
auto v = eval("builtins.tail [ 3 2 1 0 ]");
|
||||
ASSERT_THAT(v, IsListOfSize(3));
|
||||
auto listView = v.listView();
|
||||
for (const auto [n, elem] : enumerate(listView))
|
||||
for (const auto [n, elem] : enumerate(v.listItems()))
|
||||
ASSERT_THAT(*elem, IsIntEq(2 - static_cast<int>(n)));
|
||||
}
|
||||
|
||||
@@ -378,17 +376,17 @@ TEST_F(PrimOpTest, map)
|
||||
{
|
||||
auto v = eval("map (x: \"foo\" + x) [ \"bar\" \"bla\" \"abc\" ]");
|
||||
ASSERT_THAT(v, IsListOfSize(3));
|
||||
auto elem = v.listView()[0];
|
||||
auto elem = v.listElems()[0];
|
||||
ASSERT_THAT(*elem, IsThunk());
|
||||
state.forceValue(*elem, noPos);
|
||||
ASSERT_THAT(*elem, IsStringEq("foobar"));
|
||||
|
||||
elem = v.listView()[1];
|
||||
elem = v.listElems()[1];
|
||||
ASSERT_THAT(*elem, IsThunk());
|
||||
state.forceValue(*elem, noPos);
|
||||
ASSERT_THAT(*elem, IsStringEq("foobla"));
|
||||
|
||||
elem = v.listView()[2];
|
||||
elem = v.listElems()[2];
|
||||
ASSERT_THAT(*elem, IsThunk());
|
||||
state.forceValue(*elem, noPos);
|
||||
ASSERT_THAT(*elem, IsStringEq("fooabc"));
|
||||
@@ -398,7 +396,7 @@ TEST_F(PrimOpTest, filter)
|
||||
{
|
||||
auto v = eval("builtins.filter (x: x == 2) [ 3 2 3 2 3 2 ]");
|
||||
ASSERT_THAT(v, IsListOfSize(3));
|
||||
for (const auto elem : v.listView())
|
||||
for (const auto elem : v.listItems())
|
||||
ASSERT_THAT(*elem, IsIntEq(2));
|
||||
}
|
||||
|
||||
@@ -418,8 +416,7 @@ TEST_F(PrimOpTest, concatLists)
|
||||
{
|
||||
auto v = eval("builtins.concatLists [[1 2] [3 4]]");
|
||||
ASSERT_THAT(v, IsListOfSize(4));
|
||||
auto listView = v.listView();
|
||||
for (const auto [i, elem] : enumerate(listView))
|
||||
for (const auto [i, elem] : enumerate(v.listItems()))
|
||||
ASSERT_THAT(*elem, IsIntEq(static_cast<int>(i) + 1));
|
||||
}
|
||||
|
||||
@@ -464,8 +461,7 @@ TEST_F(PrimOpTest, genList)
|
||||
auto v = eval("builtins.genList (x: x + 1) 3");
|
||||
ASSERT_EQ(v.type(), nList);
|
||||
ASSERT_EQ(v.listSize(), 3u);
|
||||
auto listView = v.listView();
|
||||
for (const auto [i, elem] : enumerate(listView)) {
|
||||
for (const auto [i, elem] : enumerate(v.listItems())) {
|
||||
ASSERT_THAT(*elem, IsThunk());
|
||||
state.forceValue(*elem, noPos);
|
||||
ASSERT_THAT(*elem, IsIntEq(static_cast<int>(i) + 1));
|
||||
@@ -479,8 +475,7 @@ TEST_F(PrimOpTest, sortLessThan)
|
||||
ASSERT_EQ(v.listSize(), 6u);
|
||||
|
||||
const std::vector<int> numbers = {42, 77, 147, 249, 483, 526};
|
||||
auto listView = v.listView();
|
||||
for (const auto [n, elem] : enumerate(listView))
|
||||
for (const auto [n, elem] : enumerate(v.listItems()))
|
||||
ASSERT_THAT(*elem, IsIntEq(numbers[n]));
|
||||
}
|
||||
|
||||
@@ -492,17 +487,17 @@ TEST_F(PrimOpTest, partition)
|
||||
auto right = v.attrs()->get(createSymbol("right"));
|
||||
ASSERT_NE(right, nullptr);
|
||||
ASSERT_THAT(*right->value, IsListOfSize(2));
|
||||
ASSERT_THAT(*right->value->listView()[0], IsIntEq(23));
|
||||
ASSERT_THAT(*right->value->listView()[1], IsIntEq(42));
|
||||
ASSERT_THAT(*right->value->listElems()[0], IsIntEq(23));
|
||||
ASSERT_THAT(*right->value->listElems()[1], IsIntEq(42));
|
||||
|
||||
auto wrong = v.attrs()->get(createSymbol("wrong"));
|
||||
ASSERT_NE(wrong, nullptr);
|
||||
ASSERT_EQ(wrong->value->type(), nList);
|
||||
ASSERT_EQ(wrong->value->listSize(), 3u);
|
||||
ASSERT_THAT(*wrong->value, IsListOfSize(3));
|
||||
ASSERT_THAT(*wrong->value->listView()[0], IsIntEq(1));
|
||||
ASSERT_THAT(*wrong->value->listView()[1], IsIntEq(9));
|
||||
ASSERT_THAT(*wrong->value->listView()[2], IsIntEq(3));
|
||||
ASSERT_THAT(*wrong->value->listElems()[0], IsIntEq(1));
|
||||
ASSERT_THAT(*wrong->value->listElems()[1], IsIntEq(9));
|
||||
ASSERT_THAT(*wrong->value->listElems()[2], IsIntEq(3));
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, concatMap)
|
||||
@@ -512,8 +507,7 @@ TEST_F(PrimOpTest, concatMap)
|
||||
ASSERT_EQ(v.listSize(), 6u);
|
||||
|
||||
const std::vector<int> numbers = {1, 2, 0, 3, 4, 0};
|
||||
auto listView = v.listView();
|
||||
for (const auto [n, elem] : enumerate(listView))
|
||||
for (const auto [n, elem] : enumerate(v.listItems()))
|
||||
ASSERT_THAT(*elem, IsIntEq(numbers[n]));
|
||||
}
|
||||
|
||||
@@ -677,18 +671,6 @@ TEST_F(PrimOpTest, substringSmallerString)
|
||||
ASSERT_THAT(v, IsStringEq("n"));
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, substringHugeStart)
|
||||
{
|
||||
auto v = eval("builtins.substring 4294967296 5 \"nixos\"");
|
||||
ASSERT_THAT(v, IsStringEq(""));
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, substringHugeLength)
|
||||
{
|
||||
auto v = eval("builtins.substring 0 4294967296 \"nixos\"");
|
||||
ASSERT_THAT(v, IsStringEq("nixos"));
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, substringEmptyString)
|
||||
{
|
||||
auto v = eval("builtins.substring 1 3 \"\"");
|
||||
@@ -770,8 +752,8 @@ TEST_F(PrimOpTest, derivation)
|
||||
auto v = eval("derivation");
|
||||
ASSERT_EQ(v.type(), nFunction);
|
||||
ASSERT_TRUE(v.isLambda());
|
||||
ASSERT_NE(v.lambda().fun, nullptr);
|
||||
ASSERT_TRUE(v.lambda().fun->hasFormals());
|
||||
ASSERT_NE(v.payload.lambda.fun, nullptr);
|
||||
ASSERT_TRUE(v.payload.lambda.fun->hasFormals());
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, currentTime)
|
||||
@@ -787,8 +769,7 @@ TEST_F(PrimOpTest, splitVersion)
|
||||
ASSERT_THAT(v, IsListOfSize(4));
|
||||
|
||||
const std::vector<std::string_view> strings = {"1", "2", "3", "git"};
|
||||
auto listView = v.listView();
|
||||
for (const auto [n, p] : enumerate(listView))
|
||||
for (const auto [n, p] : enumerate(v.listItems()))
|
||||
ASSERT_THAT(*p, IsStringEq(strings[n]));
|
||||
}
|
||||
|
||||
@@ -877,12 +858,12 @@ TEST_F(PrimOpTest, split1)
|
||||
auto v = eval("builtins.split \"(a)b\" \"abc\"");
|
||||
ASSERT_THAT(v, IsListOfSize(3));
|
||||
|
||||
ASSERT_THAT(*v.listView()[0], IsStringEq(""));
|
||||
ASSERT_THAT(*v.listElems()[0], IsStringEq(""));
|
||||
|
||||
ASSERT_THAT(*v.listView()[1], IsListOfSize(1));
|
||||
ASSERT_THAT(*v.listView()[1]->listView()[0], IsStringEq("a"));
|
||||
ASSERT_THAT(*v.listElems()[1], IsListOfSize(1));
|
||||
ASSERT_THAT(*v.listElems()[1]->listElems()[0], IsStringEq("a"));
|
||||
|
||||
ASSERT_THAT(*v.listView()[2], IsStringEq("c"));
|
||||
ASSERT_THAT(*v.listElems()[2], IsStringEq("c"));
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, split2)
|
||||
@@ -891,17 +872,17 @@ TEST_F(PrimOpTest, split2)
|
||||
auto v = eval("builtins.split \"([ac])\" \"abc\"");
|
||||
ASSERT_THAT(v, IsListOfSize(5));
|
||||
|
||||
ASSERT_THAT(*v.listView()[0], IsStringEq(""));
|
||||
ASSERT_THAT(*v.listElems()[0], IsStringEq(""));
|
||||
|
||||
ASSERT_THAT(*v.listView()[1], IsListOfSize(1));
|
||||
ASSERT_THAT(*v.listView()[1]->listView()[0], IsStringEq("a"));
|
||||
ASSERT_THAT(*v.listElems()[1], IsListOfSize(1));
|
||||
ASSERT_THAT(*v.listElems()[1]->listElems()[0], IsStringEq("a"));
|
||||
|
||||
ASSERT_THAT(*v.listView()[2], IsStringEq("b"));
|
||||
ASSERT_THAT(*v.listElems()[2], IsStringEq("b"));
|
||||
|
||||
ASSERT_THAT(*v.listView()[3], IsListOfSize(1));
|
||||
ASSERT_THAT(*v.listView()[3]->listView()[0], IsStringEq("c"));
|
||||
ASSERT_THAT(*v.listElems()[3], IsListOfSize(1));
|
||||
ASSERT_THAT(*v.listElems()[3]->listElems()[0], IsStringEq("c"));
|
||||
|
||||
ASSERT_THAT(*v.listView()[4], IsStringEq(""));
|
||||
ASSERT_THAT(*v.listElems()[4], IsStringEq(""));
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, split3)
|
||||
@@ -910,37 +891,37 @@ TEST_F(PrimOpTest, split3)
|
||||
ASSERT_THAT(v, IsListOfSize(5));
|
||||
|
||||
// First list element
|
||||
ASSERT_THAT(*v.listView()[0], IsStringEq(""));
|
||||
ASSERT_THAT(*v.listElems()[0], IsStringEq(""));
|
||||
|
||||
// 2nd list element is a list [ "" null ]
|
||||
ASSERT_THAT(*v.listView()[1], IsListOfSize(2));
|
||||
ASSERT_THAT(*v.listView()[1]->listView()[0], IsStringEq("a"));
|
||||
ASSERT_THAT(*v.listView()[1]->listView()[1], IsNull());
|
||||
ASSERT_THAT(*v.listElems()[1], IsListOfSize(2));
|
||||
ASSERT_THAT(*v.listElems()[1]->listElems()[0], IsStringEq("a"));
|
||||
ASSERT_THAT(*v.listElems()[1]->listElems()[1], IsNull());
|
||||
|
||||
// 3rd element
|
||||
ASSERT_THAT(*v.listView()[2], IsStringEq("b"));
|
||||
ASSERT_THAT(*v.listElems()[2], IsStringEq("b"));
|
||||
|
||||
// 4th element is a list: [ null "c" ]
|
||||
ASSERT_THAT(*v.listView()[3], IsListOfSize(2));
|
||||
ASSERT_THAT(*v.listView()[3]->listView()[0], IsNull());
|
||||
ASSERT_THAT(*v.listView()[3]->listView()[1], IsStringEq("c"));
|
||||
ASSERT_THAT(*v.listElems()[3], IsListOfSize(2));
|
||||
ASSERT_THAT(*v.listElems()[3]->listElems()[0], IsNull());
|
||||
ASSERT_THAT(*v.listElems()[3]->listElems()[1], IsStringEq("c"));
|
||||
|
||||
// 5th element is the empty string
|
||||
ASSERT_THAT(*v.listView()[4], IsStringEq(""));
|
||||
ASSERT_THAT(*v.listElems()[4], IsStringEq(""));
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, split4)
|
||||
{
|
||||
auto v = eval("builtins.split \"([[:upper:]]+)\" \" FOO \"");
|
||||
ASSERT_THAT(v, IsListOfSize(3));
|
||||
auto first = v.listView()[0];
|
||||
auto second = v.listView()[1];
|
||||
auto third = v.listView()[2];
|
||||
auto first = v.listElems()[0];
|
||||
auto second = v.listElems()[1];
|
||||
auto third = v.listElems()[2];
|
||||
|
||||
ASSERT_THAT(*first, IsStringEq(" "));
|
||||
|
||||
ASSERT_THAT(*second, IsListOfSize(1));
|
||||
ASSERT_THAT(*second->listView()[0], IsStringEq("FOO"));
|
||||
ASSERT_THAT(*second->listElems()[0], IsStringEq("FOO"));
|
||||
|
||||
ASSERT_THAT(*third, IsStringEq(" "));
|
||||
}
|
||||
@@ -961,15 +942,15 @@ TEST_F(PrimOpTest, match3)
|
||||
{
|
||||
auto v = eval("builtins.match \"a(b)(c)\" \"abc\"");
|
||||
ASSERT_THAT(v, IsListOfSize(2));
|
||||
ASSERT_THAT(*v.listView()[0], IsStringEq("b"));
|
||||
ASSERT_THAT(*v.listView()[1], IsStringEq("c"));
|
||||
ASSERT_THAT(*v.listElems()[0], IsStringEq("b"));
|
||||
ASSERT_THAT(*v.listElems()[1], IsStringEq("c"));
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, match4)
|
||||
{
|
||||
auto v = eval("builtins.match \"[[:space:]]+([[:upper:]]+)[[:space:]]+\" \" FOO \"");
|
||||
ASSERT_THAT(v, IsListOfSize(1));
|
||||
ASSERT_THAT(*v.listView()[0], IsStringEq("FOO"));
|
||||
ASSERT_THAT(*v.listElems()[0], IsStringEq("FOO"));
|
||||
}
|
||||
|
||||
TEST_F(PrimOpTest, match5)
|
||||
@@ -988,8 +969,7 @@ TEST_F(PrimOpTest, attrNames)
|
||||
|
||||
// ensure that the list is sorted
|
||||
const std::vector<std::string_view> expected{"a", "x", "y", "z"};
|
||||
auto listView = v.listView();
|
||||
for (const auto [n, elem] : enumerate(listView))
|
||||
for (const auto [n, elem] : enumerate(v.listItems()))
|
||||
ASSERT_THAT(*elem, IsStringEq(expected[n]));
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ TEST_P(AttrSetMergeTrvialExpressionTest, attrsetMergeLazy)
|
||||
// Usually Nix rejects duplicate keys in an attrset but it does allow
|
||||
// so if it is an attribute set that contains disjoint sets of keys.
|
||||
// The below is equivalent to `{a.b = 1; a.c = 2; }`.
|
||||
// The attribute set `a` will be a Thunk at first as the attributes
|
||||
// The attribute set `a` will be a Thunk at first as the attribuets
|
||||
// have to be merged (or otherwise computed) and that is done in a lazy
|
||||
// manner.
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ findAlongAttrPath(EvalState & state, const std::string & attrPath, Bindings & au
|
||||
if (*attrIndex >= v->listSize())
|
||||
throw AttrPathNotFound("list index %1% in selection path '%2%' is out of range", *attrIndex, attrPath);
|
||||
|
||||
v = v->listView()[*attrIndex];
|
||||
v = v->listElems()[*attrIndex];
|
||||
pos = noPos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ std::vector<std::string> AttrCursor::getListOfStrings()
|
||||
|
||||
std::vector<std::string> res;
|
||||
|
||||
for (auto elem : v.listView())
|
||||
for (auto & elem : v.listItems())
|
||||
res.push_back(
|
||||
std::string(root->state.forceStringNoCtx(*elem, noPos, "while evaluating an attribute for caching")));
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "nix/util/config-global.hh"
|
||||
#include "nix/util/serialise.hh"
|
||||
#include "nix/expr/eval-gc.hh"
|
||||
#include "nix/expr/value.hh"
|
||||
|
||||
#include "expr-config-private.hh"
|
||||
|
||||
@@ -53,13 +52,6 @@ static inline void initGCReal()
|
||||
|
||||
GC_INIT();
|
||||
|
||||
/* Register valid displacements in case we are using alignment niches
|
||||
for storing the type information. This way tagged pointers are considered
|
||||
to be valid, even when they are not aligned. */
|
||||
if constexpr (detail::useBitPackedValueStorage<sizeof(void *)>)
|
||||
for (std::size_t i = 1; i < sizeof(std::uintptr_t); ++i)
|
||||
GC_register_displacement(i);
|
||||
|
||||
GC_set_oom_fn(oomHandler);
|
||||
|
||||
/* Set the initial heap size to something fairly big (25% of
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
#include "nix/expr/eval-profiler-settings.hh"
|
||||
#include "nix/util/configuration.hh"
|
||||
#include "nix/util/logging.hh" /* Needs to be included before config-impl.hh */
|
||||
#include "nix/util/config-impl.hh"
|
||||
#include "nix/util/abstract-setting-to-json.hh"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace nix {
|
||||
|
||||
template<>
|
||||
EvalProfilerMode BaseSetting<EvalProfilerMode>::parse(const std::string & str) const
|
||||
{
|
||||
if (str == "disabled")
|
||||
return EvalProfilerMode::disabled;
|
||||
else if (str == "flamegraph")
|
||||
return EvalProfilerMode::flamegraph;
|
||||
else
|
||||
throw UsageError("option '%s' has invalid value '%s'", name, str);
|
||||
}
|
||||
|
||||
template<>
|
||||
struct BaseSetting<EvalProfilerMode>::trait
|
||||
{
|
||||
static constexpr bool appendable = false;
|
||||
};
|
||||
|
||||
template<>
|
||||
std::string BaseSetting<EvalProfilerMode>::to_string() const
|
||||
{
|
||||
if (value == EvalProfilerMode::disabled)
|
||||
return "disabled";
|
||||
else if (value == EvalProfilerMode::flamegraph)
|
||||
return "flamegraph";
|
||||
else
|
||||
unreachable();
|
||||
}
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(
|
||||
EvalProfilerMode,
|
||||
{
|
||||
{EvalProfilerMode::disabled, "disabled"},
|
||||
{EvalProfilerMode::flamegraph, "flamegraph"},
|
||||
});
|
||||
|
||||
/* Explicit instantiation of templates */
|
||||
template class BaseSetting<EvalProfilerMode>;
|
||||
|
||||
} // namespace nix
|
||||
@@ -1,355 +0,0 @@
|
||||
#include "nix/expr/eval-profiler.hh"
|
||||
#include "nix/expr/nixexpr.hh"
|
||||
#include "nix/expr/eval.hh"
|
||||
#include "nix/util/lru-cache.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
void EvalProfiler::preFunctionCallHook(EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos) {}
|
||||
|
||||
void EvalProfiler::postFunctionCallHook(EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos)
|
||||
{
|
||||
}
|
||||
|
||||
void MultiEvalProfiler::preFunctionCallHook(
|
||||
EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos)
|
||||
{
|
||||
for (auto & profiler : profilers) {
|
||||
if (profiler->getNeededHooks().test(Hook::preFunctionCall))
|
||||
profiler->preFunctionCallHook(state, v, args, pos);
|
||||
}
|
||||
}
|
||||
|
||||
void MultiEvalProfiler::postFunctionCallHook(
|
||||
EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos)
|
||||
{
|
||||
for (auto & profiler : profilers) {
|
||||
if (profiler->getNeededHooks().test(Hook::postFunctionCall))
|
||||
profiler->postFunctionCallHook(state, v, args, pos);
|
||||
}
|
||||
}
|
||||
|
||||
EvalProfiler::Hooks MultiEvalProfiler::getNeededHooksImpl() const
|
||||
{
|
||||
Hooks hooks;
|
||||
for (auto & p : profilers)
|
||||
hooks |= p->getNeededHooks();
|
||||
return hooks;
|
||||
}
|
||||
|
||||
void MultiEvalProfiler::addProfiler(ref<EvalProfiler> profiler)
|
||||
{
|
||||
profilers.push_back(profiler);
|
||||
invalidateNeededHooks();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class PosCache : private LRUCache<PosIdx, Pos>
|
||||
{
|
||||
const EvalState & state;
|
||||
|
||||
public:
|
||||
PosCache(const EvalState & state)
|
||||
: LRUCache(524288) /* ~40MiB */
|
||||
, state(state)
|
||||
{
|
||||
}
|
||||
|
||||
Pos lookup(PosIdx posIdx)
|
||||
{
|
||||
auto posOrNone = LRUCache::get(posIdx);
|
||||
if (posOrNone)
|
||||
return *posOrNone;
|
||||
|
||||
auto pos = state.positions[posIdx];
|
||||
upsert(posIdx, pos);
|
||||
return pos;
|
||||
}
|
||||
};
|
||||
|
||||
struct LambdaFrameInfo
|
||||
{
|
||||
ExprLambda * expr;
|
||||
/** Position where the lambda has been called. */
|
||||
PosIdx callPos = noPos;
|
||||
std::ostream & symbolize(const EvalState & state, std::ostream & os, PosCache & posCache) const;
|
||||
auto operator<=>(const LambdaFrameInfo & rhs) const = default;
|
||||
};
|
||||
|
||||
/** Primop call. */
|
||||
struct PrimOpFrameInfo
|
||||
{
|
||||
const PrimOp * expr;
|
||||
/** Position where the primop has been called. */
|
||||
PosIdx callPos = noPos;
|
||||
std::ostream & symbolize(const EvalState & state, std::ostream & os, PosCache & posCache) const;
|
||||
auto operator<=>(const PrimOpFrameInfo & rhs) const = default;
|
||||
};
|
||||
|
||||
/** Used for functor calls (attrset with __functor attr). */
|
||||
struct FunctorFrameInfo
|
||||
{
|
||||
PosIdx pos;
|
||||
std::ostream & symbolize(const EvalState & state, std::ostream & os, PosCache & posCache) const;
|
||||
auto operator<=>(const FunctorFrameInfo & rhs) const = default;
|
||||
};
|
||||
|
||||
struct DerivationStrictFrameInfo
|
||||
{
|
||||
PosIdx callPos = noPos;
|
||||
std::string drvName;
|
||||
std::ostream & symbolize(const EvalState & state, std::ostream & os, PosCache & posCache) const;
|
||||
auto operator<=>(const DerivationStrictFrameInfo & rhs) const = default;
|
||||
};
|
||||
|
||||
/** Fallback frame info. */
|
||||
struct GenericFrameInfo
|
||||
{
|
||||
PosIdx pos;
|
||||
std::ostream & symbolize(const EvalState & state, std::ostream & os, PosCache & posCache) const;
|
||||
auto operator<=>(const GenericFrameInfo & rhs) const = default;
|
||||
};
|
||||
|
||||
using FrameInfo =
|
||||
std::variant<LambdaFrameInfo, PrimOpFrameInfo, FunctorFrameInfo, DerivationStrictFrameInfo, GenericFrameInfo>;
|
||||
using FrameStack = std::vector<FrameInfo>;
|
||||
|
||||
/**
|
||||
* Stack sampling profiler.
|
||||
*/
|
||||
class SampleStack : public EvalProfiler
|
||||
{
|
||||
/* How often stack profiles should be flushed to file. This avoids the need
|
||||
to persist stack samples across the whole evaluation at the cost
|
||||
of periodically flushing data to disk. */
|
||||
static constexpr std::chrono::microseconds profileDumpInterval = std::chrono::milliseconds(2000);
|
||||
|
||||
Hooks getNeededHooksImpl() const override
|
||||
{
|
||||
return Hooks().set(preFunctionCall).set(postFunctionCall);
|
||||
}
|
||||
|
||||
FrameInfo getPrimOpFrameInfo(const PrimOp & primOp, std::span<Value *> args, PosIdx pos);
|
||||
|
||||
public:
|
||||
SampleStack(EvalState & state, std::filesystem::path profileFile, std::chrono::nanoseconds period)
|
||||
: state(state)
|
||||
, sampleInterval(period)
|
||||
, profileFd([&]() {
|
||||
AutoCloseFD fd = toDescriptor(open(profileFile.string().c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0660));
|
||||
if (!fd)
|
||||
throw SysError("opening file %s", profileFile);
|
||||
return fd;
|
||||
}())
|
||||
, posCache(state)
|
||||
{
|
||||
}
|
||||
|
||||
[[gnu::noinline]] void
|
||||
preFunctionCallHook(EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos) override;
|
||||
[[gnu::noinline]] void
|
||||
postFunctionCallHook(EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos) override;
|
||||
|
||||
void maybeSaveProfile(std::chrono::time_point<std::chrono::high_resolution_clock> now);
|
||||
void saveProfile();
|
||||
FrameInfo getFrameInfoFromValueAndPos(const Value & v, std::span<Value *> args, PosIdx pos);
|
||||
|
||||
SampleStack(SampleStack &&) = default;
|
||||
SampleStack & operator=(SampleStack &&) = delete;
|
||||
SampleStack(const SampleStack &) = delete;
|
||||
SampleStack & operator=(const SampleStack &) = delete;
|
||||
~SampleStack();
|
||||
private:
|
||||
/** Hold on to an instance of EvalState for symbolizing positions. */
|
||||
EvalState & state;
|
||||
std::chrono::nanoseconds sampleInterval;
|
||||
AutoCloseFD profileFd;
|
||||
FrameStack stack;
|
||||
std::map<FrameStack, uint32_t> callCount;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> lastStackSample =
|
||||
std::chrono::high_resolution_clock::now();
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> lastDump = std::chrono::high_resolution_clock::now();
|
||||
PosCache posCache;
|
||||
};
|
||||
|
||||
FrameInfo SampleStack::getPrimOpFrameInfo(const PrimOp & primOp, std::span<Value *> args, PosIdx pos)
|
||||
{
|
||||
auto derivationInfo = [&]() -> std::optional<FrameInfo> {
|
||||
/* Here we rely a bit on the implementation details of libexpr/primops/derivation.nix
|
||||
and derivationStrict primop. This is not ideal, but is necessary for
|
||||
the usefulness of the profiler. This might actually affect the evaluation,
|
||||
but the cost shouldn't be that high as to make the traces entirely inaccurate. */
|
||||
if (primOp.name == "derivationStrict") {
|
||||
try {
|
||||
/* Error context strings don't actually matter, since we ignore all eval errors. */
|
||||
state.forceAttrs(*args[0], pos, "");
|
||||
auto attrs = args[0]->attrs();
|
||||
auto nameAttr = state.getAttr(state.sName, attrs, "");
|
||||
auto drvName = std::string(state.forceStringNoCtx(*nameAttr->value, pos, ""));
|
||||
return DerivationStrictFrameInfo{.callPos = pos, .drvName = std::move(drvName)};
|
||||
} catch (...) {
|
||||
/* Ignore all errors, since those will be diagnosed by the evaluator itself. */
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}();
|
||||
|
||||
return derivationInfo.value_or(PrimOpFrameInfo{.expr = &primOp, .callPos = pos});
|
||||
}
|
||||
|
||||
FrameInfo SampleStack::getFrameInfoFromValueAndPos(const Value & v, std::span<Value *> args, PosIdx pos)
|
||||
{
|
||||
/* NOTE: No actual references to garbage collected values are not held in
|
||||
the profiler. */
|
||||
if (v.isLambda())
|
||||
return LambdaFrameInfo{.expr = v.lambda().fun, .callPos = pos};
|
||||
else if (v.isPrimOp()) {
|
||||
return getPrimOpFrameInfo(*v.primOp(), args, pos);
|
||||
} else if (v.isPrimOpApp())
|
||||
/* Resolve primOp eagerly. Must not hold on to a reference to a Value. */
|
||||
return PrimOpFrameInfo{.expr = v.primOpAppPrimOp(), .callPos = pos};
|
||||
else if (state.isFunctor(v)) {
|
||||
const auto functor = v.attrs()->get(state.sFunctor);
|
||||
if (auto pos_ = posCache.lookup(pos); std::holds_alternative<std::monostate>(pos_.origin))
|
||||
/* HACK: In case callsite position is unresolved. */
|
||||
return FunctorFrameInfo{.pos = functor->pos};
|
||||
return FunctorFrameInfo{.pos = pos};
|
||||
} else
|
||||
/* NOTE: Add a stack frame even for invalid cases (e.g. when calling a non-function). This is what
|
||||
* trace-function-calls does. */
|
||||
return GenericFrameInfo{.pos = pos};
|
||||
}
|
||||
|
||||
[[gnu::noinline]] void
|
||||
SampleStack::preFunctionCallHook(EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos)
|
||||
{
|
||||
stack.push_back(getFrameInfoFromValueAndPos(v, args, pos));
|
||||
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
|
||||
if (now - lastStackSample > sampleInterval) {
|
||||
callCount[stack] += 1;
|
||||
lastStackSample = now;
|
||||
}
|
||||
|
||||
/* Do this in preFunctionCallHook because we might throw an exception, but
|
||||
callFunction uses Finally, which doesn't play well with exceptions. */
|
||||
maybeSaveProfile(now);
|
||||
}
|
||||
|
||||
[[gnu::noinline]] void
|
||||
SampleStack::postFunctionCallHook(EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos)
|
||||
{
|
||||
if (!stack.empty())
|
||||
stack.pop_back();
|
||||
}
|
||||
|
||||
std::ostream & LambdaFrameInfo::symbolize(const EvalState & state, std::ostream & os, PosCache & posCache) const
|
||||
{
|
||||
if (auto pos = posCache.lookup(callPos); std::holds_alternative<std::monostate>(pos.origin))
|
||||
/* HACK: To avoid dubious «none»:0 in the generated profile if the origin can't be resolved
|
||||
resort to printing the lambda location instead of the callsite position. */
|
||||
os << posCache.lookup(expr->getPos());
|
||||
else
|
||||
os << pos;
|
||||
if (expr->name)
|
||||
os << ":" << state.symbols[expr->name];
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream & GenericFrameInfo::symbolize(const EvalState & state, std::ostream & os, PosCache & posCache) const
|
||||
{
|
||||
os << posCache.lookup(pos);
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream & FunctorFrameInfo::symbolize(const EvalState & state, std::ostream & os, PosCache & posCache) const
|
||||
{
|
||||
os << posCache.lookup(pos) << ":functor";
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream & PrimOpFrameInfo::symbolize(const EvalState & state, std::ostream & os, PosCache & posCache) const
|
||||
{
|
||||
/* Sometimes callsite position can have an unresolved origin, which
|
||||
leads to confusing «none»:0 locations in the profile. */
|
||||
auto pos = posCache.lookup(callPos);
|
||||
if (!std::holds_alternative<std::monostate>(pos.origin))
|
||||
os << posCache.lookup(callPos) << ":";
|
||||
os << *expr;
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream &
|
||||
DerivationStrictFrameInfo::symbolize(const EvalState & state, std::ostream & os, PosCache & posCache) const
|
||||
{
|
||||
/* Sometimes callsite position can have an unresolved origin, which
|
||||
leads to confusing «none»:0 locations in the profile. */
|
||||
auto pos = posCache.lookup(callPos);
|
||||
if (!std::holds_alternative<std::monostate>(pos.origin))
|
||||
os << posCache.lookup(callPos) << ":";
|
||||
os << "primop derivationStrict:" << drvName;
|
||||
return os;
|
||||
}
|
||||
|
||||
void SampleStack::maybeSaveProfile(std::chrono::time_point<std::chrono::high_resolution_clock> now)
|
||||
{
|
||||
if (now - lastDump >= profileDumpInterval)
|
||||
saveProfile();
|
||||
else
|
||||
return;
|
||||
|
||||
/* Save the last dump timepoint. Do this after actually saving data to file
|
||||
to not account for the time doing the flushing to disk. */
|
||||
lastDump = std::chrono::high_resolution_clock::now();
|
||||
|
||||
/* Free up memory used for stack sampling. This might be very significant for
|
||||
long-running evaluations, so we shouldn't hog too much memory. */
|
||||
callCount.clear();
|
||||
}
|
||||
|
||||
void SampleStack::saveProfile()
|
||||
{
|
||||
auto os = std::ostringstream{};
|
||||
for (auto & [stack, count] : callCount) {
|
||||
auto first = true;
|
||||
for (auto & pos : stack) {
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
os << ";";
|
||||
|
||||
std::visit([&](auto && info) { info.symbolize(state, os, posCache); }, pos);
|
||||
}
|
||||
os << " " << count;
|
||||
writeLine(profileFd.get(), std::move(os).str());
|
||||
/* Clear ostringstream. */
|
||||
os.str("");
|
||||
os.clear();
|
||||
}
|
||||
}
|
||||
|
||||
SampleStack::~SampleStack()
|
||||
{
|
||||
/* Guard against cases when we are already unwinding the stack. */
|
||||
try {
|
||||
saveProfile();
|
||||
} catch (...) {
|
||||
ignoreExceptionInDestructor();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ref<EvalProfiler> makeSampleStackProfiler(EvalState & state, std::filesystem::path profileFile, uint64_t frequency)
|
||||
{
|
||||
/* 0 is a special value for sampling stack after each call. */
|
||||
std::chrono::nanoseconds period = frequency == 0
|
||||
? std::chrono::nanoseconds{0}
|
||||
: std::chrono::nanoseconds{std::nano::den / frequency / std::nano::num};
|
||||
return make_ref<SampleStack>(state, profileFile, period);
|
||||
}
|
||||
|
||||
} // namespace nix
|
||||
+63
-93
@@ -2,7 +2,6 @@
|
||||
#include "nix/expr/eval-settings.hh"
|
||||
#include "nix/expr/primops.hh"
|
||||
#include "nix/expr/print-options.hh"
|
||||
#include "nix/expr/symbol-table.hh"
|
||||
#include "nix/util/exit.hh"
|
||||
#include "nix/util/types.hh"
|
||||
#include "nix/util/util.hh"
|
||||
@@ -90,16 +89,21 @@ std::string printValue(EvalState & state, Value & v)
|
||||
return out.str();
|
||||
}
|
||||
|
||||
Value * Value::toPtr(SymbolStr str) noexcept
|
||||
{
|
||||
return const_cast<Value *>(str.valuePtr());
|
||||
}
|
||||
|
||||
void Value::print(EvalState & state, std::ostream & str, PrintOptions options)
|
||||
{
|
||||
printValue(state, str, *this, options);
|
||||
}
|
||||
|
||||
const Value * getPrimOp(const Value & v)
|
||||
{
|
||||
const Value * primOp = &v;
|
||||
while (primOp->isPrimOpApp()) {
|
||||
primOp = primOp->payload.primOpApp.left;
|
||||
}
|
||||
assert(primOp->isPrimOp());
|
||||
return primOp;
|
||||
}
|
||||
|
||||
std::string_view showType(ValueType type, bool withArticle)
|
||||
{
|
||||
#define WA(a, w) withArticle ? a " " w : w
|
||||
@@ -135,13 +139,13 @@ std::string showType(const Value & v)
|
||||
// Allow selecting a subset of enum values
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wswitch-enum"
|
||||
switch (v.getInternalType()) {
|
||||
switch (v.internalType) {
|
||||
case tString:
|
||||
return v.context() ? "a string with context" : "a string";
|
||||
return v.payload.string.context ? "a string with context" : "a string";
|
||||
case tPrimOp:
|
||||
return fmt("the built-in function '%s'", std::string(v.primOp()->name));
|
||||
return fmt("the built-in function '%s'", std::string(v.payload.primOp->name));
|
||||
case tPrimOpApp:
|
||||
return fmt("the partially applied built-in function '%s'", v.primOpAppPrimOp()->name);
|
||||
return fmt("the partially applied built-in function '%s'", std::string(getPrimOp(v)->payload.primOp->name));
|
||||
case tExternal:
|
||||
return v.external()->showType();
|
||||
case tThunk:
|
||||
@@ -159,13 +163,13 @@ PosIdx Value::determinePos(const PosIdx pos) const
|
||||
// Allow selecting a subset of enum values
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wswitch-enum"
|
||||
switch (getInternalType()) {
|
||||
switch (internalType) {
|
||||
case tAttrs:
|
||||
return attrs()->pos;
|
||||
case tLambda:
|
||||
return lambda().fun->pos;
|
||||
return payload.lambda.fun->pos;
|
||||
case tApp:
|
||||
return app().left->determinePos(pos);
|
||||
return payload.app.left->determinePos(pos);
|
||||
default:
|
||||
return pos;
|
||||
}
|
||||
@@ -174,10 +178,11 @@ PosIdx Value::determinePos(const PosIdx pos) const
|
||||
|
||||
bool Value::isTrivial() const
|
||||
{
|
||||
return !isa<tApp, tPrimOpApp>()
|
||||
&& (!isa<tThunk>()
|
||||
|| (dynamic_cast<ExprAttrs *>(thunk().expr) && ((ExprAttrs *) thunk().expr)->dynamicAttrs.empty())
|
||||
|| dynamic_cast<ExprLambda *>(thunk().expr) || dynamic_cast<ExprList *>(thunk().expr));
|
||||
return internalType != tApp && internalType != tPrimOpApp
|
||||
&& (internalType != tThunk
|
||||
|| (dynamic_cast<ExprAttrs *>(payload.thunk.expr)
|
||||
&& ((ExprAttrs *) payload.thunk.expr)->dynamicAttrs.empty())
|
||||
|| dynamic_cast<ExprLambda *>(payload.thunk.expr) || dynamic_cast<ExprList *>(payload.thunk.expr));
|
||||
}
|
||||
|
||||
static Symbol getName(const AttrName & name, EvalState & state, Env & env)
|
||||
@@ -222,7 +227,6 @@ EvalState::EvalState(
|
||||
, sRight(symbols.create("right"))
|
||||
, sWrong(symbols.create("wrong"))
|
||||
, sStructuredAttrs(symbols.create("__structuredAttrs"))
|
||||
, sJson(symbols.create("__json"))
|
||||
, sAllowedReferences(symbols.create("allowedReferences"))
|
||||
, sAllowedRequisites(symbols.create("allowedRequisites"))
|
||||
, sDisallowedReferences(symbols.create("disallowedReferences"))
|
||||
@@ -383,19 +387,6 @@ EvalState::EvalState(
|
||||
);
|
||||
|
||||
createBaseEnv(settings);
|
||||
|
||||
/* Register function call tracer. */
|
||||
if (settings.traceFunctionCalls)
|
||||
profiler.addProfiler(make_ref<FunctionCallTrace>());
|
||||
|
||||
switch (settings.evalProfilerMode) {
|
||||
case EvalProfilerMode::flamegraph:
|
||||
profiler.addProfiler(
|
||||
makeSampleStackProfiler(*this, settings.evalProfileFile.get(), settings.evalProfilerFrequency));
|
||||
break;
|
||||
case EvalProfilerMode::disabled:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EvalState::~EvalState() {}
|
||||
@@ -508,7 +499,7 @@ void EvalState::addConstant(const std::string & name, Value * v, Constant info)
|
||||
/* Install value the base environment. */
|
||||
staticBaseEnv->vars.emplace_back(symbols.create(name), baseEnvDispl);
|
||||
baseEnv.values[baseEnvDispl++] = v;
|
||||
const_cast<Bindings *>(getBuiltins().attrs())->push_back(Attr(symbols.create(name2), v));
|
||||
getBuiltins().payload.attrs->push_back(Attr(symbols.create(name2), v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -527,22 +518,20 @@ std::ostream & operator<<(std::ostream & output, const PrimOp & primOp)
|
||||
|
||||
const PrimOp * Value::primOpAppPrimOp() const
|
||||
{
|
||||
Value * left = primOpApp().left;
|
||||
Value * left = payload.primOpApp.left;
|
||||
while (left && !left->isPrimOp()) {
|
||||
left = left->primOpApp().left;
|
||||
left = left->payload.primOpApp.left;
|
||||
}
|
||||
|
||||
if (!left)
|
||||
return nullptr;
|
||||
|
||||
assert(left->isPrimOp());
|
||||
return left->primOp();
|
||||
}
|
||||
|
||||
void Value::mkPrimOp(PrimOp * p)
|
||||
{
|
||||
p->check();
|
||||
setStorage(p);
|
||||
finishValue(tPrimOp, {.primOp = p});
|
||||
}
|
||||
|
||||
Value * EvalState::addPrimOp(PrimOp && primOp)
|
||||
@@ -576,7 +565,7 @@ Value * EvalState::addPrimOp(PrimOp && primOp)
|
||||
else {
|
||||
staticBaseEnv->vars.emplace_back(envName, baseEnvDispl);
|
||||
baseEnv.values[baseEnvDispl++] = v;
|
||||
const_cast<Bindings *>(getBuiltins().attrs())->push_back(Attr(symbols.create(primOp.name), v));
|
||||
getBuiltins().payload.attrs->push_back(Attr(symbols.create(primOp.name), v));
|
||||
}
|
||||
|
||||
return v;
|
||||
@@ -610,7 +599,7 @@ std::optional<EvalState::Doc> EvalState::getDoc(Value & v)
|
||||
};
|
||||
}
|
||||
if (v.isLambda()) {
|
||||
auto exprLambda = v.lambda().fun;
|
||||
auto exprLambda = v.payload.lambda.fun;
|
||||
|
||||
std::ostringstream s;
|
||||
std::string name;
|
||||
@@ -656,7 +645,7 @@ std::optional<EvalState::Doc> EvalState::getDoc(Value & v)
|
||||
Value & functor = *v.attrs()->find(sFunctor)->value;
|
||||
Value * vp[] = {&v};
|
||||
Value partiallyApplied;
|
||||
// The first parameter is not user-provided, and may be
|
||||
// The first paramater is not user-provided, and may be
|
||||
// handled by code that is opaque to the user, like lib.const = x: y: y;
|
||||
// So preferably we show docs that are relevant to the
|
||||
// "partially applied" function returned by e.g. `const`.
|
||||
@@ -1502,20 +1491,11 @@ void ExprLambda::eval(EvalState & state, Env & env, Value & v)
|
||||
v.mkLambda(&env, this);
|
||||
}
|
||||
|
||||
thread_local size_t EvalState::callDepth = 0;
|
||||
|
||||
void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes, const PosIdx pos)
|
||||
{
|
||||
auto _level = addCallDepth(pos);
|
||||
|
||||
auto neededHooks = profiler.getNeededHooks();
|
||||
if (neededHooks.test(EvalProfiler::preFunctionCall)) [[unlikely]]
|
||||
profiler.preFunctionCallHook(*this, fun, args, pos);
|
||||
|
||||
Finally traceExit_{[&]() {
|
||||
if (profiler.getNeededHooks().test(EvalProfiler::postFunctionCall)) [[unlikely]]
|
||||
profiler.postFunctionCallHook(*this, fun, args, pos);
|
||||
}};
|
||||
auto trace = settings.traceFunctionCalls ? std::make_unique<FunctionCallTrace>(positions[pos]) : nullptr;
|
||||
|
||||
forceValue(fun, pos);
|
||||
|
||||
@@ -1536,11 +1516,11 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
||||
|
||||
if (vCur.isLambda()) {
|
||||
|
||||
ExprLambda & lambda(*vCur.lambda().fun);
|
||||
ExprLambda & lambda(*vCur.payload.lambda.fun);
|
||||
|
||||
auto size = (!lambda.arg ? 0 : 1) + (lambda.hasFormals() ? lambda.formals->formals.size() : 0);
|
||||
Env & env2(allocEnv(size));
|
||||
env2.up = vCur.lambda().env;
|
||||
env2.up = vCur.payload.lambda.env;
|
||||
|
||||
Displacement displ = 0;
|
||||
|
||||
@@ -1572,7 +1552,7 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
||||
symbols[i.name])
|
||||
.atPos(lambda.pos)
|
||||
.withTrace(pos, "from call site")
|
||||
.withFrame(*vCur.lambda().env, lambda)
|
||||
.withFrame(*vCur.payload.lambda.env, lambda)
|
||||
.debugThrow();
|
||||
}
|
||||
env2.values[displ++] = i.def->maybeThunk(*this, env2);
|
||||
@@ -1600,7 +1580,7 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
||||
.atPos(lambda.pos)
|
||||
.withTrace(pos, "from call site")
|
||||
.withSuggestions(suggestions)
|
||||
.withFrame(*vCur.lambda().env, lambda)
|
||||
.withFrame(*vCur.payload.lambda.env, lambda)
|
||||
.debugThrow();
|
||||
}
|
||||
unreachable();
|
||||
@@ -1674,7 +1654,7 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
||||
Value * primOp = &vCur;
|
||||
while (primOp->isPrimOpApp()) {
|
||||
argsDone++;
|
||||
primOp = primOp->primOpApp().left;
|
||||
primOp = primOp->payload.primOpApp.left;
|
||||
}
|
||||
assert(primOp->isPrimOp());
|
||||
auto arity = primOp->primOp()->arity;
|
||||
@@ -1690,8 +1670,8 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
|
||||
|
||||
Value * vArgs[maxPrimOpArity];
|
||||
auto n = argsDone;
|
||||
for (Value * arg = &vCur; arg->isPrimOpApp(); arg = arg->primOpApp().left)
|
||||
vArgs[--n] = arg->primOpApp().right;
|
||||
for (Value * arg = &vCur; arg->isPrimOpApp(); arg = arg->payload.primOpApp.left)
|
||||
vArgs[--n] = arg->payload.primOpApp.right;
|
||||
|
||||
for (size_t i = 0; i < argsLeft; ++i)
|
||||
vArgs[argsDone + i] = args[i];
|
||||
@@ -1789,14 +1769,15 @@ void EvalState::autoCallFunction(const Bindings & args, Value & fun, Value & res
|
||||
}
|
||||
}
|
||||
|
||||
if (!fun.isLambda() || !fun.lambda().fun->hasFormals()) {
|
||||
if (!fun.isLambda() || !fun.payload.lambda.fun->hasFormals()) {
|
||||
res = fun;
|
||||
return;
|
||||
}
|
||||
|
||||
auto attrs = buildBindings(std::max(static_cast<uint32_t>(fun.lambda().fun->formals->formals.size()), args.size()));
|
||||
auto attrs =
|
||||
buildBindings(std::max(static_cast<uint32_t>(fun.payload.lambda.fun->formals->formals.size()), args.size()));
|
||||
|
||||
if (fun.lambda().fun->formals->ellipsis) {
|
||||
if (fun.payload.lambda.fun->formals->ellipsis) {
|
||||
// If the formals have an ellipsis (eg the function accepts extra args) pass
|
||||
// all available automatic arguments (which includes arguments specified on
|
||||
// the command line via --arg/--argstr)
|
||||
@@ -1804,7 +1785,7 @@ void EvalState::autoCallFunction(const Bindings & args, Value & fun, Value & res
|
||||
attrs.insert(v);
|
||||
} else {
|
||||
// Otherwise, only pass the arguments that the function accepts
|
||||
for (auto & i : fun.lambda().fun->formals->formals) {
|
||||
for (auto & i : fun.payload.lambda.fun->formals->formals) {
|
||||
auto j = args.get(i.name);
|
||||
if (j) {
|
||||
attrs.insert(*j);
|
||||
@@ -1817,7 +1798,7 @@ values, or passed explicitly with '--arg' or '--argstr'. See
|
||||
https://nixos.org/manual/nix/stable/language/constructs.html#functions.)",
|
||||
symbols[i.name])
|
||||
.atPos(i.pos)
|
||||
.withFrame(*fun.lambda().env, *fun.lambda().fun)
|
||||
.withFrame(*fun.payload.lambda.env, *fun.payload.lambda.fun)
|
||||
.debugThrow();
|
||||
}
|
||||
}
|
||||
@@ -1988,10 +1969,9 @@ void EvalState::concatLists(
|
||||
auto list = buildList(len);
|
||||
auto out = list.elems;
|
||||
for (size_t n = 0, pos = 0; n < nrLists; ++n) {
|
||||
auto listView = lists[n]->listView();
|
||||
auto l = listView.size();
|
||||
auto l = lists[n]->listSize();
|
||||
if (l)
|
||||
memcpy(out + pos, listView.data(), l * sizeof(Value *));
|
||||
memcpy(out + pos, lists[n]->listElems(), l * sizeof(Value *));
|
||||
pos += l;
|
||||
}
|
||||
v.mkList(list);
|
||||
@@ -2154,8 +2134,8 @@ void EvalState::forceValueDeep(Value & v)
|
||||
// If the value is a thunk, we're evaling. Otherwise no trace necessary.
|
||||
auto dts = debugRepl && i.value->isThunk() ? makeDebugTraceStacker(
|
||||
*this,
|
||||
*i.value->thunk().expr,
|
||||
*i.value->thunk().env,
|
||||
*i.value->payload.thunk.expr,
|
||||
*i.value->payload.thunk.env,
|
||||
i.pos,
|
||||
"while evaluating the attribute '%1%'",
|
||||
symbols[i.name])
|
||||
@@ -2169,7 +2149,7 @@ void EvalState::forceValueDeep(Value & v)
|
||||
}
|
||||
|
||||
else if (v.isList()) {
|
||||
for (auto v2 : v.listView())
|
||||
for (auto v2 : v.listItems())
|
||||
recurse(*v2);
|
||||
}
|
||||
};
|
||||
@@ -2231,16 +2211,7 @@ bool EvalState::forceBool(Value & v, const PosIdx pos, std::string_view errorCtx
|
||||
return v.boolean();
|
||||
}
|
||||
|
||||
Bindings::const_iterator EvalState::getAttr(Symbol attrSym, const Bindings * attrSet, std::string_view errorCtx)
|
||||
{
|
||||
auto value = attrSet->find(attrSym);
|
||||
if (value == attrSet->end()) {
|
||||
error<TypeError>("attribute '%s' missing", symbols[attrSym]).withTrace(noPos, errorCtx).debugThrow();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
bool EvalState::isFunctor(const Value & fun) const
|
||||
bool EvalState::isFunctor(Value & fun)
|
||||
{
|
||||
return fun.type() == nAttrs && fun.attrs()->find(sFunctor) != fun.attrs()->end();
|
||||
}
|
||||
@@ -2278,8 +2249,8 @@ std::string_view EvalState::forceString(Value & v, const PosIdx pos, std::string
|
||||
|
||||
void copyContext(const Value & v, NixStringContext & context, const ExperimentalFeatureSettings & xpSettings)
|
||||
{
|
||||
if (v.context())
|
||||
for (const char ** p = v.context(); *p; ++p)
|
||||
if (v.payload.string.context)
|
||||
for (const char ** p = v.payload.string.context; *p; ++p)
|
||||
context.insert(NixStringContextElem::parse(*p, xpSettings));
|
||||
}
|
||||
|
||||
@@ -2360,7 +2331,7 @@ BackedStringView EvalState::coerceToString(
|
||||
return !canonicalizePath && !copyToStore
|
||||
? // FIXME: hack to preserve path literals that end in a
|
||||
// slash, as in /foo/${x}.
|
||||
v.pathStr()
|
||||
v.payload.path.path
|
||||
: copyToStore ? store->printStorePath(copyPathToStore(context, v.path()))
|
||||
: std::string(v.path().path.abs());
|
||||
}
|
||||
@@ -2404,8 +2375,7 @@ BackedStringView EvalState::coerceToString(
|
||||
|
||||
if (v.isList()) {
|
||||
std::string result;
|
||||
auto listView = v.listView();
|
||||
for (auto [n, v2] : enumerate(listView)) {
|
||||
for (auto [n, v2] : enumerate(v.listItems())) {
|
||||
try {
|
||||
result += *coerceToString(
|
||||
pos,
|
||||
@@ -2442,7 +2412,6 @@ StorePath EvalState::copyPathToStore(NixStringContext & context, const SourcePat
|
||||
|
||||
auto dstPath = dstPathCached ? *dstPathCached : [&]() {
|
||||
auto dstPath = fetchToStore(
|
||||
fetchSettings,
|
||||
*store,
|
||||
path.resolveSymlinks(SymlinkResolution::Ancestors),
|
||||
settings.readOnlyMode ? FetchMode::DryRun : FetchMode::Copy,
|
||||
@@ -2484,7 +2453,7 @@ SourcePath EvalState::coerceToPath(const PosIdx pos, Value & v, NixStringContext
|
||||
}
|
||||
}
|
||||
|
||||
/* Any other value should be coercible to a string, interpreted
|
||||
/* Any other value should be coercable to a string, interpreted
|
||||
relative to the root filesystem. */
|
||||
auto path = coerceToString(pos, v, context, errorCtx, false, false, true).toOwned();
|
||||
if (path == "" || path[0] != '/')
|
||||
@@ -2625,14 +2594,14 @@ void EvalState::assertEqValues(Value & v1, Value & v2, const PosIdx pos, std::st
|
||||
return;
|
||||
|
||||
case nPath:
|
||||
if (v1.pathAccessor() != v2.pathAccessor()) {
|
||||
if (v1.payload.path.accessor != v2.payload.path.accessor) {
|
||||
error<AssertionError>(
|
||||
"path '%s' is not equal to path '%s' because their accessors are different",
|
||||
ValuePrinter(*this, v1, errorPrintOptions),
|
||||
ValuePrinter(*this, v2, errorPrintOptions))
|
||||
.debugThrow();
|
||||
}
|
||||
if (strcmp(v1.pathStr(), v2.pathStr()) != 0) {
|
||||
if (strcmp(v1.payload.path.path, v2.payload.path.path) != 0) {
|
||||
error<AssertionError>(
|
||||
"path '%s' is not equal to path '%s'",
|
||||
ValuePrinter(*this, v1, errorPrintOptions),
|
||||
@@ -2656,7 +2625,7 @@ void EvalState::assertEqValues(Value & v1, Value & v2, const PosIdx pos, std::st
|
||||
}
|
||||
for (size_t n = 0; n < v1.listSize(); ++n) {
|
||||
try {
|
||||
assertEqValues(*v1.listView()[n], *v2.listView()[n], pos, errorCtx);
|
||||
assertEqValues(*v1.listElems()[n], *v2.listElems()[n], pos, errorCtx);
|
||||
} catch (Error & e) {
|
||||
e.addTrace(positions[pos], "while comparing list element %d", n);
|
||||
throw;
|
||||
@@ -2803,7 +2772,8 @@ bool EvalState::eqValues(Value & v1, Value & v2, const PosIdx pos, std::string_v
|
||||
case nPath:
|
||||
return
|
||||
// FIXME: compare accessors by their fingerprint.
|
||||
v1.pathAccessor() == v2.pathAccessor() && strcmp(v1.pathStr(), v2.pathStr()) == 0;
|
||||
v1.payload.path.accessor == v2.payload.path.accessor
|
||||
&& strcmp(v1.payload.path.path, v2.payload.path.path) == 0;
|
||||
|
||||
case nNull:
|
||||
return true;
|
||||
@@ -2812,7 +2782,7 @@ bool EvalState::eqValues(Value & v1, Value & v2, const PosIdx pos, std::string_v
|
||||
if (v1.listSize() != v2.listSize())
|
||||
return false;
|
||||
for (size_t n = 0; n < v1.listSize(); ++n)
|
||||
if (!eqValues(*v1.listView()[n], *v2.listView()[n], pos, errorCtx))
|
||||
if (!eqValues(*v1.listElems()[n], *v2.listElems()[n], pos, errorCtx))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
@@ -2864,7 +2834,7 @@ bool EvalState::fullGC()
|
||||
GC_gcollect();
|
||||
// Check that it ran. We might replace this with a version that uses more
|
||||
// of the boehm API to get this reliably, at a maintenance cost.
|
||||
// We use a 1K margin because technically this has a race condition, but we
|
||||
// We use a 1K margin because technically this has a race condtion, but we
|
||||
// probably won't encounter it in practice, because the CLI isn't concurrent
|
||||
// like that.
|
||||
return GC_get_bytes_since_gc() < 1024;
|
||||
@@ -3017,7 +2987,7 @@ void EvalState::printStatistics()
|
||||
// XXX: overrides earlier assignment
|
||||
topObj["symbols"] = json::array();
|
||||
auto & list = topObj["symbols"];
|
||||
symbols.dump([&](std::string_view s) { list.emplace_back(s); });
|
||||
symbols.dump([&](const std::string & s) { list.emplace_back(s); });
|
||||
}
|
||||
if (outPath == "-") {
|
||||
std::cerr << topObj.dump(2) << std::endl;
|
||||
@@ -3145,7 +3115,7 @@ std::optional<SourcePath> EvalState::resolveLookupPathPath(const LookupPath::Pat
|
||||
if (EvalSettings::isPseudoUrl(value)) {
|
||||
try {
|
||||
auto accessor = fetchers::downloadTarball(store, fetchSettings, EvalSettings::resolvePseudoUrl(value));
|
||||
auto storePath = fetchToStore(fetchSettings, *store, SourcePath(accessor), FetchMode::Copy);
|
||||
auto storePath = fetchToStore(*store, SourcePath(accessor), FetchMode::Copy);
|
||||
return finish(this->storePath(storePath));
|
||||
} catch (Error & e) {
|
||||
logWarning({.msg = HintFmt("Nix search path entry '%1%' cannot be downloaded, ignoring", value)});
|
||||
|
||||
@@ -3,20 +3,19 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
void FunctionCallTrace::preFunctionCallHook(
|
||||
EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos)
|
||||
FunctionCallTrace::FunctionCallTrace(const Pos & pos)
|
||||
: pos(pos)
|
||||
{
|
||||
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
|
||||
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
|
||||
printMsg(lvlInfo, "function-trace entered %1% at %2%", state.positions[pos], ns.count());
|
||||
printMsg(lvlInfo, "function-trace entered %1% at %2%", pos, ns.count());
|
||||
}
|
||||
|
||||
void FunctionCallTrace::postFunctionCallHook(
|
||||
EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos)
|
||||
FunctionCallTrace::~FunctionCallTrace()
|
||||
{
|
||||
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
|
||||
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
|
||||
printMsg(lvlInfo, "function-trace exited %1% at %2%", state.positions[pos], ns.count());
|
||||
printMsg(lvlInfo, "function-trace exited %1% at %2%", pos, ns.count());
|
||||
}
|
||||
|
||||
} // namespace nix
|
||||
@@ -115,7 +115,7 @@ PackageInfo::Outputs PackageInfo::queryOutputs(bool withPaths, bool onlyOutputsT
|
||||
state->forceList(*i->value, i->pos, "while evaluating the 'outputs' attribute of a derivation");
|
||||
|
||||
/* For each output... */
|
||||
for (auto elem : i->value->listView()) {
|
||||
for (auto elem : i->value->listItems()) {
|
||||
std::string output(
|
||||
state->forceStringNoCtx(*elem, i->pos, "while evaluating the name of an output of a derivation"));
|
||||
|
||||
@@ -166,7 +166,7 @@ PackageInfo::Outputs PackageInfo::queryOutputs(bool withPaths, bool onlyOutputsT
|
||||
if (!outTI->isList())
|
||||
throw errMsg;
|
||||
Outputs result;
|
||||
for (auto elem : outTI->listView()) {
|
||||
for (auto elem : outTI->listItems()) {
|
||||
if (elem->type() != nString)
|
||||
throw errMsg;
|
||||
auto out = outputs.find(elem->c_str());
|
||||
@@ -216,7 +216,7 @@ bool PackageInfo::checkMeta(Value & v)
|
||||
{
|
||||
state->forceValue(v, v.determinePos(noPos));
|
||||
if (v.type() == nList) {
|
||||
for (auto elem : v.listView())
|
||||
for (auto elem : v.listItems())
|
||||
if (!checkMeta(*elem))
|
||||
return false;
|
||||
return true;
|
||||
@@ -427,8 +427,7 @@ static void getDerivations(
|
||||
}
|
||||
|
||||
else if (v.type() == nList) {
|
||||
auto listView = v.listView();
|
||||
for (auto [n, elem] : enumerate(listView)) {
|
||||
for (auto [n, elem] : enumerate(v.listItems())) {
|
||||
std::string pathPrefix2 = addToPath(pathPrefix, fmt("%d", n));
|
||||
if (getDerivation(state, *elem, pathPrefix2, drvs, done, ignoreAssertionFailures))
|
||||
getDerivations(state, *elem, pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures);
|
||||
|
||||
@@ -89,9 +89,9 @@ Env & EvalState::allocEnv(size_t size)
|
||||
void EvalState::forceValue(Value & v, const PosIdx pos)
|
||||
{
|
||||
if (v.isThunk()) {
|
||||
Env * env = v.thunk().env;
|
||||
Env * env = v.payload.thunk.env;
|
||||
assert(env || v.isBlackhole());
|
||||
Expr * expr = v.thunk().expr;
|
||||
Expr * expr = v.payload.thunk.expr;
|
||||
try {
|
||||
v.mkBlackhole();
|
||||
// checkInterrupt();
|
||||
@@ -105,7 +105,7 @@ void EvalState::forceValue(Value & v, const PosIdx pos)
|
||||
throw;
|
||||
}
|
||||
} else if (v.isApp())
|
||||
callFunction(*v.app().left, *v.app().right, v, pos);
|
||||
callFunction(*v.payload.app.left, *v.payload.app.right, v, pos);
|
||||
}
|
||||
|
||||
[[gnu::always_inline]]
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
///@file
|
||||
|
||||
#include "nix/util/configuration.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
enum struct EvalProfilerMode { disabled, flamegraph };
|
||||
|
||||
template<>
|
||||
EvalProfilerMode BaseSetting<EvalProfilerMode>::parse(const std::string & str) const;
|
||||
|
||||
template<>
|
||||
std::string BaseSetting<EvalProfilerMode>::to_string() const;
|
||||
|
||||
} // namespace nix
|
||||
@@ -1,114 +0,0 @@
|
||||
#pragma once
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Evaluation profiler interface definitions and builtin implementations.
|
||||
*/
|
||||
|
||||
#include "nix/util/ref.hh"
|
||||
|
||||
#include <vector>
|
||||
#include <span>
|
||||
#include <bitset>
|
||||
#include <optional>
|
||||
#include <filesystem>
|
||||
|
||||
namespace nix {
|
||||
|
||||
class EvalState;
|
||||
class PosIdx;
|
||||
struct Value;
|
||||
|
||||
class EvalProfiler
|
||||
{
|
||||
public:
|
||||
enum Hook {
|
||||
preFunctionCall,
|
||||
postFunctionCall,
|
||||
};
|
||||
|
||||
static constexpr std::size_t numHooks = Hook::postFunctionCall + 1;
|
||||
using Hooks = std::bitset<numHooks>;
|
||||
|
||||
private:
|
||||
std::optional<Hooks> neededHooks;
|
||||
|
||||
protected:
|
||||
/** Invalidate the cached neededHooks. */
|
||||
void invalidateNeededHooks()
|
||||
{
|
||||
neededHooks = std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get which hooks need to be called.
|
||||
*
|
||||
* This is the actual implementation which has to be defined by subclasses.
|
||||
* Public API goes through the needsHooks, which is a
|
||||
* non-virtual interface (NVI) which caches the return value.
|
||||
*/
|
||||
virtual Hooks getNeededHooksImpl() const
|
||||
{
|
||||
return Hooks{};
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Hook called in the EvalState::callFunction preamble.
|
||||
* Gets called only if (getNeededHooks().test(Hook::preFunctionCall)) is true.
|
||||
*
|
||||
* @param state Evaluator state.
|
||||
* @param v Function being invoked.
|
||||
* @param args Function arguments.
|
||||
* @param pos Function position.
|
||||
*/
|
||||
virtual void preFunctionCallHook(EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos);
|
||||
|
||||
/**
|
||||
* Hook called on EvalState::callFunction exit.
|
||||
* Gets called only if (getNeededHooks().test(Hook::postFunctionCall)) is true.
|
||||
*
|
||||
* @param state Evaluator state.
|
||||
* @param v Function being invoked.
|
||||
* @param args Function arguments.
|
||||
* @param pos Function position.
|
||||
*/
|
||||
virtual void postFunctionCallHook(EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos);
|
||||
|
||||
virtual ~EvalProfiler() = default;
|
||||
|
||||
/**
|
||||
* Get which hooks need to be invoked for this EvalProfiler instance.
|
||||
*/
|
||||
Hooks getNeededHooks()
|
||||
{
|
||||
if (neededHooks.has_value())
|
||||
return *neededHooks;
|
||||
return *(neededHooks = getNeededHooksImpl());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Profiler that invokes multiple profilers at once.
|
||||
*/
|
||||
class MultiEvalProfiler : public EvalProfiler
|
||||
{
|
||||
std::vector<ref<EvalProfiler>> profilers;
|
||||
|
||||
[[gnu::noinline]] Hooks getNeededHooksImpl() const override;
|
||||
|
||||
public:
|
||||
MultiEvalProfiler() = default;
|
||||
|
||||
/** Register a profiler instance. */
|
||||
void addProfiler(ref<EvalProfiler> profiler);
|
||||
|
||||
[[gnu::noinline]] void
|
||||
preFunctionCallHook(EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos) override;
|
||||
[[gnu::noinline]] void
|
||||
postFunctionCallHook(EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos) override;
|
||||
};
|
||||
|
||||
ref<EvalProfiler> makeSampleStackProfiler(EvalState & state, std::filesystem::path profileFile, uint64_t frequency);
|
||||
|
||||
} // namespace nix
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
///@file
|
||||
|
||||
#include "nix/expr/eval-profiler-settings.hh"
|
||||
#include "nix/util/configuration.hh"
|
||||
#include "nix/util/source-path.hh"
|
||||
|
||||
@@ -13,7 +12,7 @@ struct PrimOp;
|
||||
struct EvalSettings : Config
|
||||
{
|
||||
/**
|
||||
* Function used to interpret look path entries of a given scheme.
|
||||
* Function used to interpet look path entries of a given scheme.
|
||||
*
|
||||
* The argument is the non-scheme part of the lookup path entry (see
|
||||
* `LookupPathHooks` below).
|
||||
@@ -140,7 +139,7 @@ struct EvalSettings : Config
|
||||
false,
|
||||
"restrict-eval",
|
||||
R"(
|
||||
If set to `true`, the Nix evaluator doesn't allow access to any
|
||||
If set to `true`, the Nix evaluator will not allow access to any
|
||||
files outside of
|
||||
[`builtins.nixPath`](@docroot@/language/builtins.md#builtins-nixPath),
|
||||
or to URIs outside of
|
||||
@@ -162,17 +161,6 @@ struct EvalSettings : Config
|
||||
- [`builtins.storePath`](@docroot@/language/builtins.md#builtins-storePath)
|
||||
)"};
|
||||
|
||||
Setting<bool> traceImportFromDerivation{
|
||||
this,
|
||||
false,
|
||||
"trace-import-from-derivation",
|
||||
R"(
|
||||
By default, Nix allows [Import from Derivation](@docroot@/language/import-from-derivation.md).
|
||||
|
||||
When this setting is `true`, Nix logs a warning indicating that it performed such an import.
|
||||
This option has no effect if `allow-import-from-derivation` is disabled.
|
||||
)"};
|
||||
|
||||
Setting<bool> enableImportFromDerivation{
|
||||
this,
|
||||
true,
|
||||
@@ -180,9 +168,9 @@ struct EvalSettings : Config
|
||||
R"(
|
||||
By default, Nix allows [Import from Derivation](@docroot@/language/import-from-derivation.md).
|
||||
|
||||
With this option set to `false`, Nix throws an error when evaluating an expression that uses this feature,
|
||||
With this option set to `false`, Nix will throw an error when evaluating an expression that uses this feature,
|
||||
even when the required store object is readily available.
|
||||
This ensures that evaluation doesn't require any builds to take place,
|
||||
This ensures that evaluation will not require any builds to take place,
|
||||
regardless of the state of the store.
|
||||
)"};
|
||||
|
||||
@@ -207,8 +195,8 @@ struct EvalSettings : Config
|
||||
false,
|
||||
"trace-function-calls",
|
||||
R"(
|
||||
If set to `true`, the Nix evaluator traces every function call.
|
||||
Nix prints a log message at the "vomit" level for every function
|
||||
If set to `true`, the Nix evaluator will trace every function call.
|
||||
Nix will print a log message at the "vomit" level for every function
|
||||
entrance and function exit.
|
||||
|
||||
function-trace entered undefined position at 1565795816999559622
|
||||
@@ -223,38 +211,6 @@ struct EvalSettings : Config
|
||||
`flamegraph.pl`.
|
||||
)"};
|
||||
|
||||
Setting<EvalProfilerMode> evalProfilerMode{
|
||||
this,
|
||||
EvalProfilerMode::disabled,
|
||||
"eval-profiler",
|
||||
R"(
|
||||
Enables evaluation profiling. The following modes are supported:
|
||||
|
||||
* `flamegraph` stack sampling profiler. Outputs folded format, one line per stack (suitable for `flamegraph.pl` and compatible tools).
|
||||
|
||||
Use [`eval-profile-file`](#conf-eval-profile-file) to specify where the profile is saved.
|
||||
|
||||
See [Using the `eval-profiler`](@docroot@/advanced-topics/eval-profiler.md).
|
||||
)"};
|
||||
|
||||
Setting<Path> evalProfileFile{
|
||||
this,
|
||||
"nix.profile",
|
||||
"eval-profile-file",
|
||||
R"(
|
||||
Specifies the file where [evaluation profile](#conf-eval-profiler) is saved.
|
||||
)"};
|
||||
|
||||
Setting<uint32_t> evalProfilerFrequency{
|
||||
this,
|
||||
99,
|
||||
"eval-profiler-frequency",
|
||||
R"(
|
||||
Specifies the sampling rate in hertz for sampling evaluation profilers.
|
||||
Use `0` to sample the stack after each function call.
|
||||
See [`eval-profiler`](#conf-eval-profiler).
|
||||
)"};
|
||||
|
||||
Setting<bool> useEvalCache{
|
||||
this,
|
||||
true,
|
||||
@@ -270,8 +226,8 @@ struct EvalSettings : Config
|
||||
false,
|
||||
"ignore-try",
|
||||
R"(
|
||||
If set to true, ignore exceptions inside 'tryEval' calls when evaluating Nix expressions in
|
||||
debug mode (using the --debugger flag). By default the debugger pauses on all exceptions.
|
||||
If set to true, ignore exceptions inside 'tryEval' calls when evaluating nix expressions in
|
||||
debug mode (using the --debugger flag). By default the debugger will pause on all exceptions.
|
||||
)"};
|
||||
|
||||
Setting<bool> traceVerbose{
|
||||
@@ -289,7 +245,7 @@ struct EvalSettings : Config
|
||||
"debugger-on-trace",
|
||||
R"(
|
||||
If set to true and the `--debugger` flag is given, the following functions
|
||||
enter the debugger like [`builtins.break`](@docroot@/language/builtins.md#builtins-break):
|
||||
will enter the debugger like [`builtins.break`](@docroot@/language/builtins.md#builtins-break).
|
||||
|
||||
* [`builtins.trace`](@docroot@/language/builtins.md#builtins-trace)
|
||||
* [`builtins.traceVerbose`](@docroot@/language/builtins.md#builtins-traceVerbose)
|
||||
@@ -317,7 +273,7 @@ struct EvalSettings : Config
|
||||
false,
|
||||
"abort-on-warn",
|
||||
R"(
|
||||
If set to true, [`builtins.warn`](@docroot@/language/builtins.md#builtins-warn) throws an error when logging a warning.
|
||||
If set to true, [`builtins.warn`](@docroot@/language/builtins.md#builtins-warn) will throw an error when logging a warning.
|
||||
|
||||
This will give you a stack trace that leads to the location of the warning.
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "nix/expr/attr-set.hh"
|
||||
#include "nix/expr/eval-error.hh"
|
||||
#include "nix/expr/eval-profiler.hh"
|
||||
#include "nix/util/types.hh"
|
||||
#include "nix/expr/value.hh"
|
||||
#include "nix/expr/nixexpr.hh"
|
||||
@@ -222,11 +221,10 @@ public:
|
||||
PosTable positions;
|
||||
|
||||
const Symbol sWith, sOutPath, sDrvPath, sType, sMeta, sName, sValue, sSystem, sOverrides, sOutputs, sOutputName,
|
||||
sIgnoreNulls, sFile, sLine, sColumn, sFunctor, sToString, sRight, sWrong, sStructuredAttrs, sJson,
|
||||
sAllowedReferences, sAllowedRequisites, sDisallowedReferences, sDisallowedRequisites, sMaxSize, sMaxClosureSize,
|
||||
sBuilder, sArgs, sContentAddressed, sImpure, sOutputHash, sOutputHashAlgo, sOutputHashMode,
|
||||
sRecurseForDerivations, sDescription, sSelf, sEpsilon, sStartSet, sOperator, sKey, sPath, sPrefix,
|
||||
sOutputSpecified;
|
||||
sIgnoreNulls, sFile, sLine, sColumn, sFunctor, sToString, sRight, sWrong, sStructuredAttrs, sAllowedReferences,
|
||||
sAllowedRequisites, sDisallowedReferences, sDisallowedRequisites, sMaxSize, sMaxClosureSize, sBuilder, sArgs,
|
||||
sContentAddressed, sImpure, sOutputHash, sOutputHashAlgo, sOutputHashMode, sRecurseForDerivations, sDescription,
|
||||
sSelf, sEpsilon, sStartSet, sOperator, sKey, sPath, sPrefix, sOutputSpecified;
|
||||
|
||||
const Expr::AstSymbols exprSymbols;
|
||||
|
||||
@@ -567,11 +565,6 @@ public:
|
||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||
std::string_view forceStringNoCtx(Value & v, const PosIdx pos, std::string_view errorCtx);
|
||||
|
||||
/**
|
||||
* Get attribute from an attribute set and throw an error if it doesn't exist.
|
||||
*/
|
||||
Bindings::const_iterator getAttr(Symbol attrSym, const Bindings * attrSet, std::string_view errorCtx);
|
||||
|
||||
template<typename... Args>
|
||||
[[gnu::noinline]]
|
||||
void addErrorTrace(Error & e, const Args &... formatArgs) const;
|
||||
@@ -749,11 +742,10 @@ private:
|
||||
std::shared_ptr<StaticEnv> & staticEnv);
|
||||
|
||||
/**
|
||||
* Current Nix call stack depth, used with `max-call-depth`
|
||||
* setting to throw stack overflow hopefully before we run out of
|
||||
* system stack.
|
||||
* Current Nix call stack depth, used with `max-call-depth` setting to throw stack overflow hopefully before we run
|
||||
* out of system stack.
|
||||
*/
|
||||
thread_local static size_t callDepth;
|
||||
size_t callDepth = 0;
|
||||
|
||||
public:
|
||||
|
||||
@@ -777,7 +769,7 @@ public:
|
||||
*/
|
||||
void assertEqValues(Value & v1, Value & v2, const PosIdx pos, std::string_view errorCtx);
|
||||
|
||||
bool isFunctor(const Value & fun) const;
|
||||
bool isFunctor(Value & fun);
|
||||
|
||||
void callFunction(Value & fun, std::span<Value *> args, Value & vRes, const PosIdx pos);
|
||||
|
||||
@@ -947,9 +939,6 @@ private:
|
||||
typedef std::map<ExprLambda *, size_t> FunctionCalls;
|
||||
FunctionCalls functionCalls;
|
||||
|
||||
/** Evaluation/call profiler. */
|
||||
MultiEvalProfiler profiler;
|
||||
|
||||
void incrFunctionCall(ExprLambda * fun);
|
||||
|
||||
typedef std::map<PosIdx, size_t> AttrSelects;
|
||||
|
||||
@@ -2,24 +2,15 @@
|
||||
///@file
|
||||
|
||||
#include "nix/expr/eval.hh"
|
||||
#include "nix/expr/eval-profiler.hh"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace nix {
|
||||
|
||||
class FunctionCallTrace : public EvalProfiler
|
||||
struct FunctionCallTrace
|
||||
{
|
||||
Hooks getNeededHooksImpl() const override
|
||||
{
|
||||
return Hooks().set(preFunctionCall).set(postFunctionCall);
|
||||
}
|
||||
|
||||
public:
|
||||
FunctionCallTrace() = default;
|
||||
|
||||
[[gnu::noinline]] void
|
||||
preFunctionCallHook(EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos) override;
|
||||
[[gnu::noinline]] void
|
||||
postFunctionCallHook(EvalState & state, const Value & v, std::span<Value *> args, const PosIdx pos) override;
|
||||
const Pos pos;
|
||||
FunctionCallTrace(const Pos & pos);
|
||||
~FunctionCallTrace();
|
||||
};
|
||||
|
||||
} // namespace nix
|
||||
@@ -14,8 +14,6 @@ headers = [config_pub_h] + files(
|
||||
'eval-error.hh',
|
||||
'eval-gc.hh',
|
||||
'eval-inline.hh',
|
||||
'eval-profiler-settings.hh',
|
||||
'eval-profiler.hh',
|
||||
'eval-settings.hh',
|
||||
'eval.hh',
|
||||
'function-trace.hh',
|
||||
|
||||
@@ -391,9 +391,6 @@ struct Formal
|
||||
struct Formals
|
||||
{
|
||||
typedef std::vector<Formal> Formals_;
|
||||
/**
|
||||
* @pre Sorted according to predicate (std::tie(a.name, a.pos) < std::tie(b.name, b.pos)).
|
||||
*/
|
||||
Formals_ formals;
|
||||
bool ellipsis;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "nix/expr/value.hh"
|
||||
#include "nix/expr/symbol-table.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
||||
@@ -1,76 +1,16 @@
|
||||
#pragma once
|
||||
///@file
|
||||
|
||||
#include <memory_resource>
|
||||
#include "nix/expr/value.hh"
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "nix/util/types.hh"
|
||||
#include "nix/util/chunked-vector.hh"
|
||||
#include "nix/util/error.hh"
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/unordered/unordered_flat_set.hpp>
|
||||
|
||||
namespace nix {
|
||||
|
||||
class SymbolValue : protected Value
|
||||
{
|
||||
friend class SymbolStr;
|
||||
friend class SymbolTable;
|
||||
|
||||
uint32_t size_;
|
||||
uint32_t idx;
|
||||
|
||||
SymbolValue() = default;
|
||||
|
||||
public:
|
||||
operator std::string_view() const noexcept
|
||||
{
|
||||
return {c_str(), size_};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Symbols have the property that they can be compared efficiently
|
||||
* (using an equality test), because the symbol table stores only one
|
||||
* copy of each string.
|
||||
*/
|
||||
class Symbol
|
||||
{
|
||||
friend class SymbolStr;
|
||||
friend class SymbolTable;
|
||||
|
||||
private:
|
||||
uint32_t id;
|
||||
|
||||
explicit Symbol(uint32_t id) noexcept
|
||||
: id(id)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
Symbol() noexcept
|
||||
: id(0)
|
||||
{
|
||||
}
|
||||
|
||||
[[gnu::always_inline]]
|
||||
explicit operator bool() const noexcept
|
||||
{
|
||||
return id > 0;
|
||||
}
|
||||
|
||||
auto operator<=>(const Symbol other) const noexcept
|
||||
{
|
||||
return id <=> other.id;
|
||||
}
|
||||
|
||||
bool operator==(const Symbol other) const noexcept
|
||||
{
|
||||
return id == other.id;
|
||||
}
|
||||
|
||||
friend class std::hash<Symbol>;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class mainly exists to give us an operator<< for ostreams. We could also
|
||||
* return plain strings from SymbolTable, but then we'd have to wrap every
|
||||
@@ -80,134 +20,77 @@ class SymbolStr
|
||||
{
|
||||
friend class SymbolTable;
|
||||
|
||||
constexpr static size_t chunkSize{8192};
|
||||
using SymbolValueStore = ChunkedVector<SymbolValue, chunkSize>;
|
||||
private:
|
||||
const std::string * s;
|
||||
|
||||
const SymbolValue * s;
|
||||
|
||||
struct Key
|
||||
explicit SymbolStr(const std::string & symbol)
|
||||
: s(&symbol)
|
||||
{
|
||||
using HashType = boost::hash<std::string_view>;
|
||||
|
||||
SymbolValueStore & store;
|
||||
std::string_view s;
|
||||
std::size_t hash;
|
||||
std::pmr::polymorphic_allocator<char> & alloc;
|
||||
|
||||
Key(SymbolValueStore & store, std::string_view s, std::pmr::polymorphic_allocator<char> & stringAlloc)
|
||||
: store(store)
|
||||
, s(s)
|
||||
, hash(HashType{}(s))
|
||||
, alloc(stringAlloc)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public:
|
||||
SymbolStr(const SymbolValue & s) noexcept
|
||||
: s(&s)
|
||||
{
|
||||
}
|
||||
|
||||
SymbolStr(const Key & key)
|
||||
{
|
||||
auto size = key.s.size();
|
||||
if (size >= std::numeric_limits<uint32_t>::max()) {
|
||||
throw Error("Size of symbol exceeds 4GiB and cannot be stored");
|
||||
}
|
||||
// for multi-threaded implementations: lock store and allocator here
|
||||
const auto & [v, idx] = key.store.add(SymbolValue{});
|
||||
if (size == 0) {
|
||||
v.mkString("", nullptr);
|
||||
} else {
|
||||
auto s = key.alloc.allocate(size + 1);
|
||||
memcpy(s, key.s.data(), size);
|
||||
s[size] = '\0';
|
||||
v.mkString(s, nullptr);
|
||||
}
|
||||
v.size_ = size;
|
||||
v.idx = idx;
|
||||
this->s = &v;
|
||||
}
|
||||
|
||||
bool operator==(std::string_view s2) const noexcept
|
||||
bool operator==(std::string_view s2) const
|
||||
{
|
||||
return *s == s2;
|
||||
}
|
||||
|
||||
[[gnu::always_inline]]
|
||||
const char * c_str() const noexcept
|
||||
const char * c_str() const
|
||||
{
|
||||
return s->c_str();
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] operator std::string_view() const noexcept
|
||||
operator const std::string_view() const
|
||||
{
|
||||
return *s;
|
||||
}
|
||||
|
||||
friend std::ostream & operator<<(std::ostream & os, const SymbolStr & symbol);
|
||||
|
||||
[[gnu::always_inline]]
|
||||
bool empty() const noexcept
|
||||
bool empty() const
|
||||
{
|
||||
return s->empty();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Symbols have the property that they can be compared efficiently
|
||||
* (using an equality test), because the symbol table stores only one
|
||||
* copy of each string.
|
||||
*/
|
||||
class Symbol
|
||||
{
|
||||
friend class SymbolTable;
|
||||
|
||||
private:
|
||||
uint32_t id;
|
||||
|
||||
explicit Symbol(uint32_t id)
|
||||
: id(id)
|
||||
{
|
||||
return s->size_ == 0;
|
||||
}
|
||||
|
||||
[[gnu::always_inline]]
|
||||
size_t size() const noexcept
|
||||
public:
|
||||
Symbol()
|
||||
: id(0)
|
||||
{
|
||||
return s->size_;
|
||||
}
|
||||
|
||||
[[gnu::always_inline]]
|
||||
const Value * valuePtr() const noexcept
|
||||
explicit operator bool() const
|
||||
{
|
||||
return s;
|
||||
return id > 0;
|
||||
}
|
||||
|
||||
explicit operator Symbol() const noexcept
|
||||
auto operator<=>(const Symbol other) const
|
||||
{
|
||||
return Symbol{s->idx + 1};
|
||||
return id <=> other.id;
|
||||
}
|
||||
|
||||
struct Hash
|
||||
bool operator==(const Symbol other) const
|
||||
{
|
||||
using is_transparent = void;
|
||||
using is_avalanching = std::true_type;
|
||||
return id == other.id;
|
||||
}
|
||||
|
||||
std::size_t operator()(SymbolStr str) const
|
||||
{
|
||||
return Key::HashType{}(*str.s);
|
||||
}
|
||||
|
||||
std::size_t operator()(const Key & key) const noexcept
|
||||
{
|
||||
return key.hash;
|
||||
}
|
||||
};
|
||||
|
||||
struct Equal
|
||||
{
|
||||
using is_transparent = void;
|
||||
|
||||
bool operator()(SymbolStr a, SymbolStr b) const noexcept
|
||||
{
|
||||
// strings are unique, so that a pointer comparison is OK
|
||||
return a.s == b.s;
|
||||
}
|
||||
|
||||
bool operator()(SymbolStr a, const Key & b) const noexcept
|
||||
{
|
||||
return a == b.s;
|
||||
}
|
||||
|
||||
[[gnu::always_inline]]
|
||||
bool operator()(const Key & a, SymbolStr b) const noexcept
|
||||
{
|
||||
return operator()(b, a);
|
||||
}
|
||||
};
|
||||
friend class std::hash<Symbol>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -218,18 +101,11 @@ class SymbolTable
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* SymbolTable is an append only data structure.
|
||||
* During its lifetime the monotonic buffer holds all strings and nodes, if the symbol set is node based.
|
||||
*/
|
||||
std::pmr::monotonic_buffer_resource buffer;
|
||||
std::pmr::polymorphic_allocator<char> stringAlloc{&buffer};
|
||||
SymbolStr::SymbolValueStore store{16};
|
||||
|
||||
/**
|
||||
* Transparent lookup of string view for a pointer to a ChunkedVector entry -> return offset into the store.
|
||||
* Map from string view (backed by ChunkedVector) -> offset into the store.
|
||||
* ChunkedVector references are never invalidated.
|
||||
*/
|
||||
boost::unordered_flat_set<SymbolStr, SymbolStr::Hash, SymbolStr::Equal> symbols{SymbolStr::chunkSize};
|
||||
std::unordered_map<std::string_view, uint32_t> symbols;
|
||||
ChunkedVector<std::string, 8192> store{16};
|
||||
|
||||
public:
|
||||
|
||||
@@ -241,7 +117,13 @@ public:
|
||||
// Most symbols are looked up more than once, so we trade off insertion performance
|
||||
// for lookup performance.
|
||||
// FIXME: make this thread-safe.
|
||||
return Symbol(*symbols.insert(SymbolStr::Key{store, s, stringAlloc}).first);
|
||||
auto it = symbols.find(s);
|
||||
if (it != symbols.end())
|
||||
return Symbol(it->second + 1);
|
||||
|
||||
const auto & [rawSym, idx] = store.add(s);
|
||||
symbols.emplace(rawSym, idx);
|
||||
return Symbol(idx + 1);
|
||||
}
|
||||
|
||||
std::vector<SymbolStr> resolve(const std::vector<Symbol> & symbols) const
|
||||
@@ -255,14 +137,12 @@ public:
|
||||
|
||||
SymbolStr operator[](Symbol s) const
|
||||
{
|
||||
uint32_t idx = s.id - uint32_t(1);
|
||||
if (idx >= store.size())
|
||||
if (s.id == 0 || s.id > store.size())
|
||||
unreachable();
|
||||
return store[idx];
|
||||
return SymbolStr(store[s.id - 1]);
|
||||
}
|
||||
|
||||
[[gnu::always_inline]]
|
||||
size_t size() const noexcept
|
||||
size_t size() const
|
||||
{
|
||||
return store.size();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
// including the generated headers twice leads to errors
|
||||
// inluding the generated headers twice leads to errors
|
||||
#ifndef BISON_HEADER
|
||||
# include "lexer-tab.hh"
|
||||
# include "parser-tab.hh"
|
||||
|
||||
@@ -72,6 +72,12 @@ toml11 = dependency(
|
||||
method : 'cmake',
|
||||
include_type: 'system',
|
||||
)
|
||||
|
||||
configdata_priv.set(
|
||||
'HAVE_TOML11_4',
|
||||
toml11.version().version_compare('>= 4.0.0').to_int(),
|
||||
)
|
||||
|
||||
deps_other += toml11
|
||||
|
||||
config_priv_h = configure_file(
|
||||
@@ -140,8 +146,6 @@ sources = files(
|
||||
'eval-cache.cc',
|
||||
'eval-error.cc',
|
||||
'eval-gc.cc',
|
||||
'eval-profiler-settings.cc',
|
||||
'eval-profiler.cc',
|
||||
'eval-settings.cc',
|
||||
'eval.cc',
|
||||
'function-trace.cc',
|
||||
|
||||
@@ -612,7 +612,7 @@ void ExprLambda::setDocComment(DocComment docComment)
|
||||
size_t SymbolTable::totalSize() const
|
||||
{
|
||||
size_t n = 0;
|
||||
dump([&](SymbolStr s) { n += s.size(); });
|
||||
dump([&](const std::string & s) { n += s.size(); });
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,13 +70,15 @@ mkMesonLibrary (finalAttrs: {
|
||||
nix-util
|
||||
nix-store
|
||||
nix-fetchers
|
||||
] ++ finalAttrs.passthru.externalPropagatedBuildInputs;
|
||||
]
|
||||
++ finalAttrs.passthru.externalPropagatedBuildInputs;
|
||||
|
||||
# Hack for sake of the dev shell
|
||||
passthru.externalPropagatedBuildInputs = [
|
||||
boost
|
||||
nlohmann_json
|
||||
] ++ lib.optional enableGC boehmgc;
|
||||
]
|
||||
++ lib.optional enableGC boehmgc;
|
||||
|
||||
mesonFlags = [
|
||||
(lib.mesonEnable "gc" enableGC)
|
||||
|
||||
+160
-215
@@ -14,7 +14,6 @@
|
||||
#include "nix/expr/value-to-xml.hh"
|
||||
#include "nix/expr/primops.hh"
|
||||
#include "nix/fetchers/fetch-to-store.hh"
|
||||
#include "nix/util/sort.hh"
|
||||
|
||||
#include <boost/container/small_vector.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
@@ -94,16 +93,11 @@ StringMap EvalState::realiseContext(const NixStringContext & context, StorePathS
|
||||
if (drvs.empty())
|
||||
return {};
|
||||
|
||||
if (isIFD) {
|
||||
if (!settings.enableImportFromDerivation)
|
||||
error<IFDError>(
|
||||
"cannot build '%1%' during evaluation because the option 'allow-import-from-derivation' is disabled",
|
||||
drvs.begin()->to_string(*store))
|
||||
.debugThrow();
|
||||
|
||||
if (settings.traceImportFromDerivation)
|
||||
warn("built '%1%' during evaluation due to an import from derivation", drvs.begin()->to_string(*store));
|
||||
}
|
||||
if (isIFD && !settings.enableImportFromDerivation)
|
||||
error<IFDError>(
|
||||
"cannot build '%1%' during evaluation because the option 'allow-import-from-derivation' is disabled",
|
||||
drvs.begin()->to_string(*store))
|
||||
.debugThrow();
|
||||
|
||||
/* Build/substitute the context. */
|
||||
std::vector<DerivedPath> buildReqs;
|
||||
@@ -356,7 +350,7 @@ static RegisterPrimOp primop_import(
|
||||
> }
|
||||
> ```
|
||||
>
|
||||
> then the following `foo.nix` throws an error:
|
||||
> then the following `foo.nix` will give an error:
|
||||
>
|
||||
> ```nix
|
||||
> # foo.nix
|
||||
@@ -426,7 +420,7 @@ void prim_importNative(EvalState & state, const PosIdx pos, Value ** args, Value
|
||||
void prim_exec(EvalState & state, const PosIdx pos, Value ** args, Value & v)
|
||||
{
|
||||
state.forceList(*args[0], pos, "while evaluating the first argument passed to builtins.exec");
|
||||
auto elems = args[0]->listView();
|
||||
auto elems = args[0]->listElems();
|
||||
auto count = args[0]->listSize();
|
||||
if (count == 0)
|
||||
state.error<EvalError>("at least one argument to 'exec' required").atPos(pos).debugThrow();
|
||||
@@ -441,7 +435,7 @@ void prim_exec(EvalState & state, const PosIdx pos, Value ** args, Value & v)
|
||||
false)
|
||||
.toOwned();
|
||||
Strings commandArgs;
|
||||
for (size_t i = 1; i < count; ++i) {
|
||||
for (unsigned int i = 1; i < args[0]->listSize(); ++i) {
|
||||
commandArgs.push_back(state
|
||||
.coerceToString(
|
||||
pos,
|
||||
@@ -695,7 +689,7 @@ struct CompareValues
|
||||
// Note: we don't take the accessor into account
|
||||
// since it's not obvious how to compare them in a
|
||||
// reproducible way.
|
||||
return strcmp(v1->pathStr(), v2->pathStr()) < 0;
|
||||
return strcmp(v1->payload.path.path, v2->payload.path.path) < 0;
|
||||
case nList:
|
||||
// Lexicographic comparison
|
||||
for (size_t i = 0;; i++) {
|
||||
@@ -703,8 +697,8 @@ struct CompareValues
|
||||
return false;
|
||||
} else if (i == v1->listSize()) {
|
||||
return true;
|
||||
} else if (!state.eqValues(*v1->listView()[i], *v2->listView()[i], pos, errorCtx)) {
|
||||
return (*this)(v1->listView()[i], v2->listView()[i], "while comparing two list elements");
|
||||
} else if (!state.eqValues(*v1->listElems()[i], *v2->listElems()[i], pos, errorCtx)) {
|
||||
return (*this)(v1->listElems()[i], v2->listElems()[i], "while comparing two list elements");
|
||||
}
|
||||
}
|
||||
default:
|
||||
@@ -724,13 +718,25 @@ struct CompareValues
|
||||
|
||||
typedef std::list<Value *, gc_allocator<Value *>> ValueList;
|
||||
|
||||
static Bindings::const_iterator
|
||||
getAttr(EvalState & state, Symbol attrSym, const Bindings * attrSet, std::string_view errorCtx)
|
||||
{
|
||||
auto value = attrSet->find(attrSym);
|
||||
if (value == attrSet->end()) {
|
||||
state.error<TypeError>("attribute '%s' missing", state.symbols[attrSym])
|
||||
.withTrace(noPos, errorCtx)
|
||||
.debugThrow();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static void prim_genericClosure(EvalState & state, const PosIdx pos, Value ** args, Value & v)
|
||||
{
|
||||
state.forceAttrs(*args[0], noPos, "while evaluating the first argument passed to builtins.genericClosure");
|
||||
|
||||
/* Get the start set. */
|
||||
auto startSet = state.getAttr(
|
||||
state.sStartSet, args[0]->attrs(), "in the attrset passed as argument to builtins.genericClosure");
|
||||
auto startSet = getAttr(
|
||||
state, state.sStartSet, args[0]->attrs(), "in the attrset passed as argument to builtins.genericClosure");
|
||||
|
||||
state.forceList(
|
||||
*startSet->value,
|
||||
@@ -738,7 +744,7 @@ static void prim_genericClosure(EvalState & state, const PosIdx pos, Value ** ar
|
||||
"while evaluating the 'startSet' attribute passed as argument to builtins.genericClosure");
|
||||
|
||||
ValueList workSet;
|
||||
for (auto elem : startSet->value->listView())
|
||||
for (auto elem : startSet->value->listItems())
|
||||
workSet.push_back(elem);
|
||||
|
||||
if (startSet->value->listSize() == 0) {
|
||||
@@ -747,8 +753,8 @@ static void prim_genericClosure(EvalState & state, const PosIdx pos, Value ** ar
|
||||
}
|
||||
|
||||
/* Get the operator. */
|
||||
auto op = state.getAttr(
|
||||
state.sOperator, args[0]->attrs(), "in the attrset passed as argument to builtins.genericClosure");
|
||||
auto op = getAttr(
|
||||
state, state.sOperator, args[0]->attrs(), "in the attrset passed as argument to builtins.genericClosure");
|
||||
state.forceFunction(
|
||||
*op->value, noPos, "while evaluating the 'operator' attribute passed as argument to builtins.genericClosure");
|
||||
|
||||
@@ -769,7 +775,8 @@ static void prim_genericClosure(EvalState & state, const PosIdx pos, Value ** ar
|
||||
noPos,
|
||||
"while evaluating one of the elements generated by (or initially passed to) builtins.genericClosure");
|
||||
|
||||
auto key = state.getAttr(
|
||||
auto key = getAttr(
|
||||
state,
|
||||
state.sKey,
|
||||
e->attrs(),
|
||||
"in one of the attrsets generated by (or initially passed to) builtins.genericClosure");
|
||||
@@ -788,7 +795,7 @@ static void prim_genericClosure(EvalState & state, const PosIdx pos, Value ** ar
|
||||
"while evaluating the return value of the `operator` passed to builtins.genericClosure");
|
||||
|
||||
/* Add the values returned by the operator to the work set. */
|
||||
for (auto elem : newElements.listView()) {
|
||||
for (auto elem : newElements.listItems()) {
|
||||
state.forceValue(*elem, noPos); // "while evaluating one one of the elements returned by the `operator`
|
||||
// passed to builtins.genericClosure");
|
||||
workSet.push_back(elem);
|
||||
@@ -976,7 +983,7 @@ static void prim_ceil(EvalState & state, const PosIdx pos, Value ** args, Value
|
||||
if (arg != res) {
|
||||
state
|
||||
.error<EvalError>(
|
||||
"Due to a bug (see https://github.com/NixOS/nix/issues/12899) a loss of precision occurred in previous Nix versions because the NixInt argument %1% was rounded to %2%.\n\tFuture Nix versions might implement the correct behavior.",
|
||||
"Due to a bug (see https://github.com/NixOS/nix/issues/12899) a loss of precision occured in previous Nix versions because the NixInt argument %1% was rounded to %2%.\n\tFuture Nix versions might implement the correct behavior.",
|
||||
arg,
|
||||
res)
|
||||
.atPos(pos)
|
||||
@@ -997,7 +1004,7 @@ static RegisterPrimOp primop_ceil({
|
||||
a NixInt and if `*number* < -9007199254740992` or `*number* > 9007199254740992`.
|
||||
|
||||
If the datatype of *number* is neither a NixInt (signed 64-bit integer) nor a NixFloat
|
||||
(IEEE-754 double-precision floating-point number), an evaluation error is thrown.
|
||||
(IEEE-754 double-precision floating-point number), an evaluation error will be thrown.
|
||||
)",
|
||||
.fun = prim_ceil,
|
||||
});
|
||||
@@ -1031,7 +1038,7 @@ static void prim_floor(EvalState & state, const PosIdx pos, Value ** args, Value
|
||||
if (arg != res) {
|
||||
state
|
||||
.error<EvalError>(
|
||||
"Due to a bug (see https://github.com/NixOS/nix/issues/12899) a loss of precision occurred in previous Nix versions because the NixInt argument %1% was rounded to %2%.\n\tFuture Nix versions might implement the correct behavior.",
|
||||
"Due to a bug (see https://github.com/NixOS/nix/issues/12899) a loss of precision occured in previous Nix versions because the NixInt argument %1% was rounded to %2%.\n\tFuture Nix versions might implement the correct behavior.",
|
||||
arg,
|
||||
res)
|
||||
.atPos(pos)
|
||||
@@ -1068,7 +1075,7 @@ static void prim_tryEval(EvalState & state, const PosIdx pos, Value ** args, Val
|
||||
|
||||
ReplExitStatus (*savedDebugRepl)(ref<EvalState> es, const ValMap & extraEnv) = nullptr;
|
||||
if (state.debugRepl && state.settings.ignoreExceptionsDuringTry) {
|
||||
/* to prevent starting the repl from exceptions within a tryEval, null it. */
|
||||
/* to prevent starting the repl from exceptions withing a tryEval, null it. */
|
||||
savedDebugRepl = state.debugRepl;
|
||||
state.debugRepl = nullptr;
|
||||
}
|
||||
@@ -1097,15 +1104,15 @@ static RegisterPrimOp primop_tryEval({
|
||||
Try to shallowly evaluate *e*. Return a set containing the
|
||||
attributes `success` (`true` if *e* evaluated successfully,
|
||||
`false` if an error was thrown) and `value`, equalling *e* if
|
||||
successful and `false` otherwise. `tryEval` only prevents
|
||||
successful and `false` otherwise. `tryEval` will only prevent
|
||||
errors created by `throw` or `assert` from being thrown.
|
||||
Errors `tryEval` doesn't catch are, for example, those created
|
||||
Errors `tryEval` will not catch are for example those created
|
||||
by `abort` and type errors generated by builtins. Also note that
|
||||
this doesn't evaluate *e* deeply, so `let e = { x = throw ""; };
|
||||
in (builtins.tryEval e).success` is `true`. Using
|
||||
in (builtins.tryEval e).success` will be `true`. Using
|
||||
`builtins.deepSeq` one can get the expected result:
|
||||
`let e = { x = throw ""; }; in
|
||||
(builtins.tryEval (builtins.deepSeq e e)).success` is
|
||||
(builtins.tryEval (builtins.deepSeq e e)).success` will be
|
||||
`false`.
|
||||
|
||||
`tryEval` intentionally does not return the error message, because that risks bringing non-determinism into the evaluation result, and it would become very difficult to improve error reporting without breaking existing expressions.
|
||||
@@ -1204,7 +1211,7 @@ static RegisterPrimOp primop_trace({
|
||||
If the
|
||||
[`debugger-on-trace`](@docroot@/command-ref/conf-file.md#conf-debugger-on-trace)
|
||||
option is set to `true` and the `--debugger` flag is given, the
|
||||
interactive debugger is started when `trace` is called (like
|
||||
interactive debugger will be started when `trace` is called (like
|
||||
[`break`](@docroot@/language/builtins.md#builtins-break)).
|
||||
)",
|
||||
.fun = prim_trace,
|
||||
@@ -1256,7 +1263,7 @@ static RegisterPrimOp primop_warn({
|
||||
|
||||
If the
|
||||
[`abort-on-warn`](@docroot@/command-ref/conf-file.md#conf-abort-on-warn)
|
||||
option is set, the evaluation is aborted after the warning is printed.
|
||||
option is set, the evaluation will be aborted after the warning is printed.
|
||||
This is useful to reveal the stack trace of the warning, when the context is non-interactive and a debugger can not be launched.
|
||||
)",
|
||||
.fun = prim_warn,
|
||||
@@ -1275,7 +1282,7 @@ static void prim_second(EvalState & state, const PosIdx pos, Value ** args, Valu
|
||||
* Derivations
|
||||
*************************************************************/
|
||||
|
||||
static void derivationStrictInternal(EvalState & state, std::string_view name, const Bindings * attrs, Value & v);
|
||||
static void derivationStrictInternal(EvalState & state, const std::string & name, const Bindings * attrs, Value & v);
|
||||
|
||||
/* Construct (as a unobservable side effect) a Nix derivation
|
||||
expression that performs the derivation described by the argument
|
||||
@@ -1291,9 +1298,10 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value **
|
||||
auto attrs = args[0]->attrs();
|
||||
|
||||
/* Figure out the name first (for stack backtraces). */
|
||||
auto nameAttr = state.getAttr(state.sName, attrs, "in the attrset passed as argument to builtins.derivationStrict");
|
||||
auto nameAttr =
|
||||
getAttr(state, state.sName, attrs, "in the attrset passed as argument to builtins.derivationStrict");
|
||||
|
||||
std::string_view drvName;
|
||||
std::string drvName;
|
||||
try {
|
||||
drvName = state.forceStringNoCtx(
|
||||
*nameAttr->value, pos, "while evaluating the `name` attribute passed to builtins.derivationStrict");
|
||||
@@ -1357,7 +1365,7 @@ static void checkDerivationName(EvalState & state, std::string_view drvName)
|
||||
}
|
||||
}
|
||||
|
||||
static void derivationStrictInternal(EvalState & state, std::string_view drvName, const Bindings * attrs, Value & v)
|
||||
static void derivationStrictInternal(EvalState & state, const std::string & drvName, const Bindings * attrs, Value & v)
|
||||
{
|
||||
checkDerivationName(state, drvName);
|
||||
|
||||
@@ -1466,7 +1474,7 @@ static void derivationStrictInternal(EvalState & state, std::string_view drvName
|
||||
command-line arguments to the builder. */
|
||||
else if (i->name == state.sArgs) {
|
||||
state.forceList(*i->value, pos, context_below);
|
||||
for (auto elem : i->value->listView()) {
|
||||
for (auto elem : i->value->listItems()) {
|
||||
auto s = state
|
||||
.coerceToString(
|
||||
pos, *elem, context, "while evaluating an element of the argument list", true)
|
||||
@@ -1500,7 +1508,7 @@ static void derivationStrictInternal(EvalState & state, std::string_view drvName
|
||||
/* Require ‘outputs’ to be a list of strings. */
|
||||
state.forceList(*i->value, pos, context_below);
|
||||
Strings ss;
|
||||
for (auto elem : i->value->listView())
|
||||
for (auto elem : i->value->listItems())
|
||||
ss.emplace_back(state.forceStringNoCtx(*elem, pos, context_below));
|
||||
handleOutputs(ss);
|
||||
}
|
||||
@@ -1545,10 +1553,6 @@ static void derivationStrictInternal(EvalState & state, std::string_view drvName
|
||||
handleHashMode(s);
|
||||
else if (i->name == state.sOutputs)
|
||||
handleOutputs(tokenizeString<Strings>(s));
|
||||
else if (i->name == state.sJson)
|
||||
warn(
|
||||
"In derivation '%s': setting structured attributes via '__json' is deprecated, and may be disallowed in future versions of Nix. Set '__structuredAttrs = true' instead.",
|
||||
drvName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1752,7 +1756,7 @@ static RegisterPrimOp primop_placeholder({
|
||||
.name = "placeholder",
|
||||
.args = {"output"},
|
||||
.doc = R"(
|
||||
Return an
|
||||
Return at
|
||||
[output placeholder string](@docroot@/store/derivation/index.md#output-placeholder)
|
||||
for the specified *output* that will be substituted by the corresponding
|
||||
[output path](@docroot@/glossary.md#gloss-output-path)
|
||||
@@ -1915,7 +1919,7 @@ static RegisterPrimOp primop_baseNameOf({
|
||||
|
||||
After this, the *base name* is returned as previously described, assuming `/` as the directory separator. (Note that evaluation must be platform independent.)
|
||||
|
||||
This is somewhat similar to the [GNU `basename`](https://www.gnu.org/software/coreutils/manual/html_node/basename-invocation.html) command, but GNU `basename` strips any number of trailing slashes.
|
||||
This is somewhat similar to the [GNU `basename`](https://www.gnu.org/software/coreutils/manual/html_node/basename-invocation.html) command, but GNU `basename` will strip any number of trailing slashes.
|
||||
)",
|
||||
.fun = prim_baseNameOf,
|
||||
});
|
||||
@@ -1933,8 +1937,13 @@ static void prim_dirOf(EvalState & state, const PosIdx pos, Value ** args, Value
|
||||
NixStringContext context;
|
||||
auto path = state.coerceToString(
|
||||
pos, *args[0], context, "while evaluating the first argument passed to 'builtins.dirOf'", false, false);
|
||||
auto dir = dirOf(*path);
|
||||
v.mkString(dir, context);
|
||||
auto pos = path->rfind('/');
|
||||
if (pos == path->npos)
|
||||
v.mkStringMove(".", context);
|
||||
else if (pos == 0)
|
||||
v.mkStringMove("/", context);
|
||||
else
|
||||
v.mkString(path->substr(0, pos), context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1996,7 +2005,7 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value ** args, Va
|
||||
|
||||
LookupPath lookupPath;
|
||||
|
||||
for (auto v2 : args[0]->listView()) {
|
||||
for (auto v2 : args[0]->listItems()) {
|
||||
state.forceAttrs(*v2, pos, "while evaluating an element of the list passed to builtins.findFile");
|
||||
|
||||
std::string prefix;
|
||||
@@ -2007,7 +2016,7 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value ** args, Va
|
||||
pos,
|
||||
"while evaluating the `prefix` attribute of an element of the list passed to builtins.findFile");
|
||||
|
||||
i = state.getAttr(state.sPath, v2->attrs(), "in an element of the __nixPath");
|
||||
i = getAttr(state, state.sPath, v2->attrs(), "in an element of the __nixPath");
|
||||
|
||||
NixStringContext context;
|
||||
auto path =
|
||||
@@ -2023,7 +2032,7 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value ** args, Va
|
||||
|
||||
try {
|
||||
auto rewrites = state.realiseContext(context);
|
||||
path = rewriteStrings(std::move(path), rewrites);
|
||||
path = rewriteStrings(path, rewrites);
|
||||
} catch (InvalidPathError & e) {
|
||||
state.error<EvalError>("cannot find '%1%', since path '%2%' is not valid", path, e.path)
|
||||
.atPos(pos)
|
||||
@@ -2032,8 +2041,8 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value ** args, Va
|
||||
|
||||
lookupPath.elements.emplace_back(
|
||||
LookupPath::Elem{
|
||||
.prefix = LookupPath::Prefix{.s = std::move(prefix)},
|
||||
.path = LookupPath::Path{.s = std::move(path)},
|
||||
.prefix = LookupPath::Prefix{.s = prefix},
|
||||
.path = LookupPath::Path{.s = path},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2124,9 +2133,9 @@ static RegisterPrimOp primop_findFile(
|
||||
> ]
|
||||
> ```
|
||||
>
|
||||
> and a *lookup-path* value `"nixos-config"` causes Nix to try `/home/eelco/Dev/nixos-config` and `/etc/nixos` in that order and return the first path that exists.
|
||||
> and a *lookup-path* value `"nixos-config"` will cause Nix to try `/home/eelco/Dev/nixos-config` and `/etc/nixos` in that order and return the first path that exists.
|
||||
|
||||
If `path` starts with `http://` or `https://`, it is interpreted as the URL of a tarball to be downloaded and unpacked to a temporary location.
|
||||
If `path` starts with `http://` or `https://`, it is interpreted as the URL of a tarball that will be downloaded and unpacked to a temporary location.
|
||||
The tarball must consist of a single top-level directory.
|
||||
|
||||
The URLs of the tarballs from the official `nixos.org` channels can be abbreviated as `channel:<channel-name>`.
|
||||
@@ -2273,7 +2282,7 @@ static RegisterPrimOp primop_readDir({
|
||||
Return the contents of the directory *path* as a set mapping
|
||||
directory entries to the corresponding file type. For instance, if
|
||||
directory `A` contains a regular file `B` and another directory
|
||||
`C`, then `builtins.readDir ./A` returns the set
|
||||
`C`, then `builtins.readDir ./A` will return the set
|
||||
|
||||
```nix
|
||||
{ B = "regular"; C = "directory"; }
|
||||
@@ -2310,8 +2319,8 @@ static RegisterPrimOp primop_outputOf({
|
||||
[input placeholder string](@docroot@/store/derivation/index.md#input-placeholder)
|
||||
if needed.
|
||||
|
||||
If the derivation has a statically-known output path (i.e. the derivation output is input-addressed, or fixed content-addressed), the output path is returned.
|
||||
But if the derivation is content-addressed or if the derivation is itself not-statically produced (i.e. is the output of another derivation), an input placeholder is returned instead.
|
||||
If the derivation has a statically-known output path (i.e. the derivation output is input-addressed, or fixed content-addresed), the output path will just be returned.
|
||||
But if the derivation is content-addressed or if the derivation is itself not-statically produced (i.e. is the output of another derivation), an input placeholder will be returned instead.
|
||||
|
||||
*`derivation reference`* must be a string that may contain a regular store path to a derivation, or may be an input placeholder reference.
|
||||
If the derivation is produced by a derivation, you must explicitly select `drv.outPath`.
|
||||
@@ -2324,7 +2333,7 @@ static RegisterPrimOp primop_outputOf({
|
||||
"out"
|
||||
```
|
||||
|
||||
returns an input placeholder for the output of the output of `myDrv`.
|
||||
will return a input placeholder for the output of the output of `myDrv`.
|
||||
|
||||
This primop corresponds to the `^` sigil for [deriving paths](@docroot@/glossary.md#gloss-deriving-paths), e.g. as part of installable syntax on the command line.
|
||||
)",
|
||||
@@ -2501,9 +2510,10 @@ static RegisterPrimOp primop_fromJSON({
|
||||
static void prim_toFile(EvalState & state, const PosIdx pos, Value ** args, Value & v)
|
||||
{
|
||||
NixStringContext context;
|
||||
auto name = state.forceStringNoCtx(*args[0], pos, "while evaluating the first argument passed to builtins.toFile");
|
||||
auto contents =
|
||||
state.forceString(*args[1], context, pos, "while evaluating the second argument passed to builtins.toFile");
|
||||
std::string name(
|
||||
state.forceStringNoCtx(*args[0], pos, "while evaluating the first argument passed to builtins.toFile"));
|
||||
std::string contents(
|
||||
state.forceString(*args[1], context, pos, "while evaluating the second argument passed to builtins.toFile"));
|
||||
|
||||
StorePathSet refs;
|
||||
|
||||
@@ -2674,7 +2684,6 @@ static void addPath(
|
||||
|
||||
if (!expectedHash || !state.store->isValidPath(*expectedStorePath)) {
|
||||
auto dstPath = fetchToStore(
|
||||
state.fetchSettings,
|
||||
*state.store,
|
||||
path.resolveSymlinks(),
|
||||
settings.readOnlyMode ? FetchMode::DryRun : FetchMode::Copy,
|
||||
@@ -2717,12 +2726,12 @@ static RegisterPrimOp primop_filterSource({
|
||||
>
|
||||
> `filterSource` should not be used to filter store paths. Since
|
||||
> `filterSource` uses the name of the input directory while naming
|
||||
> the output directory, doing so produces a directory name in
|
||||
> the output directory, doing so will produce a directory name in
|
||||
> the form of `<hash2>-<hash>-<name>`, where `<hash>-<name>` is
|
||||
> the name of the input directory. Since `<hash>` depends on the
|
||||
> unfiltered directory, the name of the output directory
|
||||
> indirectly depends on files that are filtered out by the
|
||||
> function. This triggers a rebuild even when a filtered out
|
||||
> unfiltered directory, the name of the output directory will
|
||||
> indirectly depend on files that are filtered out by the
|
||||
> function. This will trigger a rebuild even when a filtered out
|
||||
> file is changed. Use `builtins.path` instead, which allows
|
||||
> specifying the name of the output directory.
|
||||
|
||||
@@ -2737,8 +2746,8 @@ static RegisterPrimOp primop_filterSource({
|
||||
}
|
||||
```
|
||||
|
||||
However, if `source-dir` is a Subversion working copy, then all of
|
||||
those annoying `.svn` subdirectories are also copied to the
|
||||
However, if `source-dir` is a Subversion working copy, then all
|
||||
those annoying `.svn` subdirectories will also be copied to the
|
||||
store. Worse, the contents of those directories may change a lot,
|
||||
causing lots of spurious rebuilds. With `filterSource` you can
|
||||
filter out the `.svn` directories:
|
||||
@@ -2758,8 +2767,8 @@ static RegisterPrimOp primop_filterSource({
|
||||
`"regular"`, `"directory"`, `"symlink"` or `"unknown"` (for other
|
||||
kinds of files such as device nodes or fifos — but note that those
|
||||
cannot be copied to the Nix store, so if the predicate returns
|
||||
`true` for them, the copy fails). If you exclude a directory,
|
||||
the entire corresponding subtree of *e2* is excluded.
|
||||
`true` for them, the copy will fail). If you exclude a directory,
|
||||
the entire corresponding subtree of *e2* will be excluded.
|
||||
)",
|
||||
.fun = prim_filterSource,
|
||||
});
|
||||
@@ -2767,7 +2776,7 @@ static RegisterPrimOp primop_filterSource({
|
||||
static void prim_path(EvalState & state, const PosIdx pos, Value ** args, Value & v)
|
||||
{
|
||||
std::optional<SourcePath> path;
|
||||
std::string_view name;
|
||||
std::string name;
|
||||
Value * filterFun = nullptr;
|
||||
auto method = ContentAddressMethod::Raw::NixArchive;
|
||||
std::optional<Hash> expectedHash;
|
||||
@@ -2839,7 +2848,7 @@ static RegisterPrimOp primop_path({
|
||||
|
||||
- sha256\
|
||||
When provided, this is the expected hash of the file at the
|
||||
path. Evaluation fails if the hash is incorrect, and
|
||||
path. Evaluation will fail if the hash is incorrect, and
|
||||
providing a hash allows `builtins.path` to be used even when the
|
||||
`pure-eval` nix config option is on.
|
||||
)",
|
||||
@@ -2859,7 +2868,7 @@ static void prim_attrNames(EvalState & state, const PosIdx pos, Value ** args, V
|
||||
auto list = state.buildList(args[0]->attrs()->size());
|
||||
|
||||
for (const auto & [n, i] : enumerate(*args[0]->attrs()))
|
||||
list[n] = Value::toPtr(state.symbols[i.name]);
|
||||
(list[n] = state.allocValue())->mkString(state.symbols[i.name]);
|
||||
|
||||
std::sort(list.begin(), list.end(), [](Value * v1, Value * v2) { return strcmp(v1->c_str(), v2->c_str()) < 0; });
|
||||
|
||||
@@ -2914,7 +2923,7 @@ void prim_getAttr(EvalState & state, const PosIdx pos, Value ** args, Value & v)
|
||||
{
|
||||
auto attr = state.forceStringNoCtx(*args[0], pos, "while evaluating the first argument passed to builtins.getAttr");
|
||||
state.forceAttrs(*args[1], pos, "while evaluating the second argument passed to builtins.getAttr");
|
||||
auto i = state.getAttr(state.symbols.create(attr), args[1]->attrs(), "in the attribute set under consideration");
|
||||
auto i = getAttr(state, state.symbols.create(attr), args[1]->attrs(), "in the attribute set under consideration");
|
||||
// !!! add to stack trace?
|
||||
if (state.countCalls && i->pos)
|
||||
state.attrSelects[i->pos]++;
|
||||
@@ -2960,7 +2969,7 @@ static RegisterPrimOp primop_unsafeGetAttrPos(
|
||||
.fun = prim_unsafeGetAttrPos,
|
||||
});
|
||||
|
||||
// access to exact position information (ie, line and column numbers) is deferred
|
||||
// access to exact position information (ie, line and colum numbers) is deferred
|
||||
// due to the cost associated with calculating that information and how rarely
|
||||
// it is used in practice. this is achieved by creating thunks to otherwise
|
||||
// inaccessible primops that are not exposed as __op or under builtins to turn
|
||||
@@ -2972,7 +2981,7 @@ static RegisterPrimOp primop_unsafeGetAttrPos(
|
||||
// but each type of thunk has an associated runtime cost in the current evaluator.
|
||||
// as with black holes this cost is too high to justify another thunk type to check
|
||||
// for in the very hot path that is forceValue.
|
||||
static struct LazyPosAccessors
|
||||
static struct LazyPosAcessors
|
||||
{
|
||||
PrimOp primop_lineOfPos{.arity = 1, .fun = [](EvalState & state, PosIdx pos, Value ** args, Value & v) {
|
||||
v.mkInt(state.positions[PosIdx(args[0]->integer().value)].line);
|
||||
@@ -2983,7 +2992,7 @@ static struct LazyPosAccessors
|
||||
|
||||
Value lineOfPos, columnOfPos;
|
||||
|
||||
LazyPosAccessors()
|
||||
LazyPosAcessors()
|
||||
{
|
||||
lineOfPos.mkPrimOp(&primop_lineOfPos);
|
||||
columnOfPos.mkPrimOp(&primop_columnOfPos);
|
||||
@@ -3049,7 +3058,7 @@ static void prim_removeAttrs(EvalState & state, const PosIdx pos, Value ** args,
|
||||
// 64: large enough to fit the attributes of a derivation
|
||||
boost::container::small_vector<Attr, 64> names;
|
||||
names.reserve(args[1]->listSize());
|
||||
for (auto elem : args[1]->listView()) {
|
||||
for (auto elem : args[1]->listItems()) {
|
||||
state.forceStringNoCtx(
|
||||
*elem, pos, "while evaluating the values of the second argument passed to builtins.removeAttrs");
|
||||
names.emplace_back(state.symbols.create(elem->string_view()), nullptr);
|
||||
@@ -3090,51 +3099,28 @@ static void prim_listToAttrs(EvalState & state, const PosIdx pos, Value ** args,
|
||||
{
|
||||
state.forceList(*args[0], pos, "while evaluating the argument passed to builtins.listToAttrs");
|
||||
|
||||
// Step 1. Sort the name-value attrsets in place using the memory we allocate for the result
|
||||
auto listView = args[0]->listView();
|
||||
size_t listSize = listView.size();
|
||||
auto & bindings = *state.allocBindings(listSize);
|
||||
using ElemPtr = decltype(&bindings[0].value);
|
||||
auto attrs = state.buildBindings(args[0]->listSize());
|
||||
|
||||
for (const auto & [n, v2] : enumerate(listView)) {
|
||||
std::set<Symbol> seen;
|
||||
|
||||
for (auto v2 : args[0]->listItems()) {
|
||||
state.forceAttrs(*v2, pos, "while evaluating an element of the list passed to builtins.listToAttrs");
|
||||
|
||||
auto j = state.getAttr(state.sName, v2->attrs(), "in a {name=...; value=...;} pair");
|
||||
auto j = getAttr(state, state.sName, v2->attrs(), "in a {name=...; value=...;} pair");
|
||||
|
||||
auto name = state.forceStringNoCtx(
|
||||
*j->value,
|
||||
j->pos,
|
||||
"while evaluating the `name` attribute of an element of the list passed to builtins.listToAttrs");
|
||||
|
||||
auto sym = state.symbols.create(name);
|
||||
|
||||
// (ab)use Attr to store a Value * * instead of a Value *, so that we can stabilize the sort using the Value * *
|
||||
bindings[n] = Attr(sym, std::bit_cast<Value *>(&v2));
|
||||
}
|
||||
|
||||
std::sort(&bindings[0], &bindings[listSize], [](const Attr & a, const Attr & b) {
|
||||
// Note that .value is actually a Value * * that corresponds to the position in the list
|
||||
return a < b || (!(a > b) && std::bit_cast<ElemPtr>(a.value) < std::bit_cast<ElemPtr>(b.value));
|
||||
});
|
||||
|
||||
// Step 2. Unpack the bindings in place and skip name-value pairs with duplicate names
|
||||
Symbol prev;
|
||||
for (size_t n = 0; n < listSize; n++) {
|
||||
auto attr = bindings[n];
|
||||
if (prev == attr.name) {
|
||||
continue;
|
||||
if (seen.insert(sym).second) {
|
||||
auto j2 = getAttr(state, state.sValue, v2->attrs(), "in a {name=...; value=...;} pair");
|
||||
attrs.insert(sym, j2->value, j2->pos);
|
||||
}
|
||||
// Note that .value is actually a Value * *; see earlier comments
|
||||
Value * v2 = *std::bit_cast<ElemPtr>(attr.value);
|
||||
}
|
||||
|
||||
auto j = state.getAttr(state.sValue, v2->attrs(), "in a {name=...; value=...;} pair");
|
||||
prev = attr.name;
|
||||
bindings.push_back({prev, j->value, j->pos});
|
||||
}
|
||||
// help GC and clear end of allocated array
|
||||
for (size_t n = bindings.size(); n < listSize; n++) {
|
||||
bindings[n] = Attr{};
|
||||
}
|
||||
v.mkAttrs(&bindings);
|
||||
v.mkAttrs(attrs);
|
||||
}
|
||||
|
||||
static RegisterPrimOp primop_listToAttrs({
|
||||
@@ -3254,7 +3240,7 @@ static void prim_catAttrs(EvalState & state, const PosIdx pos, Value ** args, Va
|
||||
SmallValueVector<nonRecursiveStackReservation> res(args[1]->listSize());
|
||||
size_t found = 0;
|
||||
|
||||
for (auto v2 : args[1]->listView()) {
|
||||
for (auto v2 : args[1]->listItems()) {
|
||||
state.forceAttrs(
|
||||
*v2, pos, "while evaluating an element in the list passed as second argument to builtins.catAttrs");
|
||||
if (auto i = v2->attrs()->get(attrName))
|
||||
@@ -3262,7 +3248,7 @@ static void prim_catAttrs(EvalState & state, const PosIdx pos, Value ** args, Va
|
||||
}
|
||||
|
||||
auto list = state.buildList(found);
|
||||
for (size_t n = 0; n < found; ++n)
|
||||
for (unsigned int n = 0; n < found; ++n)
|
||||
list[n] = res[n];
|
||||
v.mkList(list);
|
||||
}
|
||||
@@ -3294,21 +3280,15 @@ static void prim_functionArgs(EvalState & state, const PosIdx pos, Value ** args
|
||||
if (!args[0]->isLambda())
|
||||
state.error<TypeError>("'functionArgs' requires a function").atPos(pos).debugThrow();
|
||||
|
||||
if (!args[0]->lambda().fun->hasFormals()) {
|
||||
if (!args[0]->payload.lambda.fun->hasFormals()) {
|
||||
v.mkAttrs(&state.emptyBindings);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto & formals = args[0]->lambda().fun->formals->formals;
|
||||
auto attrs = state.buildBindings(formals.size());
|
||||
for (auto & i : formals)
|
||||
auto attrs = state.buildBindings(args[0]->payload.lambda.fun->formals->formals.size());
|
||||
for (auto & i : args[0]->payload.lambda.fun->formals->formals)
|
||||
attrs.insert(i.name, state.getBool(i.def), i.pos);
|
||||
/* Optimization: avoid sorting bindings. `formals` must already be sorted according to
|
||||
(std::tie(a.name, a.pos) < std::tie(b.name, b.pos)) predicate, so the following assertion
|
||||
always holds:
|
||||
assert(std::is_sorted(attrs.alreadySorted()->begin(), attrs.alreadySorted()->end()));
|
||||
.*/
|
||||
v.mkAttrs(attrs.alreadySorted());
|
||||
v.mkAttrs(attrs);
|
||||
}
|
||||
|
||||
static RegisterPrimOp primop_functionArgs({
|
||||
@@ -3336,8 +3316,9 @@ static void prim_mapAttrs(EvalState & state, const PosIdx pos, Value ** args, Va
|
||||
auto attrs = state.buildBindings(args[1]->attrs()->size());
|
||||
|
||||
for (auto & i : *args[1]->attrs()) {
|
||||
Value * vName = Value::toPtr(state.symbols[i.name]);
|
||||
Value * vName = state.allocValue();
|
||||
Value * vFun2 = state.allocValue();
|
||||
vName->mkString(state.symbols[i.name]);
|
||||
vFun2->mkApp(args[0], vName);
|
||||
attrs.alloc(i.name).mkApp(vFun2, i.value);
|
||||
}
|
||||
@@ -3380,7 +3361,7 @@ static void prim_zipAttrsWith(EvalState & state, const PosIdx pos, Value ** args
|
||||
|
||||
state.forceFunction(*args[0], pos, "while evaluating the first argument passed to builtins.zipAttrsWith");
|
||||
state.forceList(*args[1], pos, "while evaluating the second argument passed to builtins.zipAttrsWith");
|
||||
const auto listItems = args[1]->listView();
|
||||
const auto listItems = args[1]->listItems();
|
||||
|
||||
for (auto & vElem : listItems) {
|
||||
state.forceAttrs(
|
||||
@@ -3402,7 +3383,8 @@ static void prim_zipAttrsWith(EvalState & state, const PosIdx pos, Value ** args
|
||||
auto attrs = state.buildBindings(attrsSeen.size());
|
||||
|
||||
for (auto & [sym, elem] : attrsSeen) {
|
||||
auto name = Value::toPtr(state.symbols[sym]);
|
||||
auto name = state.allocValue();
|
||||
name->mkString(state.symbols[sym]);
|
||||
auto call1 = state.allocValue();
|
||||
call1->mkApp(args[0], name);
|
||||
auto call2 = state.allocValue();
|
||||
@@ -3473,12 +3455,12 @@ static void prim_elemAt(EvalState & state, const PosIdx pos, Value ** args, Valu
|
||||
NixInt::Inner n =
|
||||
state.forceInt(*args[1], pos, "while evaluating the second argument passed to 'builtins.elemAt'").value;
|
||||
state.forceList(*args[0], pos, "while evaluating the first argument passed to 'builtins.elemAt'");
|
||||
if (n < 0 || std::make_unsigned_t<NixInt::Inner>(n) >= args[0]->listSize())
|
||||
if (n < 0 || (unsigned int) n >= args[0]->listSize())
|
||||
state.error<EvalError>("'builtins.elemAt' called with index %d on a list of size %d", n, args[0]->listSize())
|
||||
.atPos(pos)
|
||||
.debugThrow();
|
||||
state.forceValue(*args[0]->listView()[n], pos);
|
||||
v = *args[0]->listView()[n];
|
||||
state.forceValue(*args[0]->listElems()[n], pos);
|
||||
v = *args[0]->listElems()[n];
|
||||
}
|
||||
|
||||
static RegisterPrimOp primop_elemAt({
|
||||
@@ -3497,8 +3479,8 @@ static void prim_head(EvalState & state, const PosIdx pos, Value ** args, Value
|
||||
state.forceList(*args[0], pos, "while evaluating the first argument passed to 'builtins.head'");
|
||||
if (args[0]->listSize() == 0)
|
||||
state.error<EvalError>("'builtins.head' called on an empty list").atPos(pos).debugThrow();
|
||||
state.forceValue(*args[0]->listView()[0], pos);
|
||||
v = *args[0]->listView()[0];
|
||||
state.forceValue(*args[0]->listElems()[0], pos);
|
||||
v = *args[0]->listElems()[0];
|
||||
}
|
||||
|
||||
static RegisterPrimOp primop_head({
|
||||
@@ -3523,7 +3505,7 @@ static void prim_tail(EvalState & state, const PosIdx pos, Value ** args, Value
|
||||
|
||||
auto list = state.buildList(args[0]->listSize() - 1);
|
||||
for (const auto & [n, v] : enumerate(list))
|
||||
v = args[0]->listView()[n + 1];
|
||||
v = args[0]->listElems()[n + 1];
|
||||
v.mkList(list);
|
||||
}
|
||||
|
||||
@@ -3557,7 +3539,7 @@ static void prim_map(EvalState & state, const PosIdx pos, Value ** args, Value &
|
||||
|
||||
auto list = state.buildList(args[1]->listSize());
|
||||
for (const auto & [n, v] : enumerate(list))
|
||||
(v = state.allocValue())->mkApp(args[0], args[1]->listView()[n]);
|
||||
(v = state.allocValue())->mkApp(args[0], args[1]->listElems()[n]);
|
||||
v.mkList(list);
|
||||
}
|
||||
|
||||
@@ -3591,17 +3573,16 @@ static void prim_filter(EvalState & state, const PosIdx pos, Value ** args, Valu
|
||||
|
||||
state.forceFunction(*args[0], pos, "while evaluating the first argument passed to builtins.filter");
|
||||
|
||||
auto len = args[1]->listSize();
|
||||
SmallValueVector<nonRecursiveStackReservation> vs(len);
|
||||
SmallValueVector<nonRecursiveStackReservation> vs(args[1]->listSize());
|
||||
size_t k = 0;
|
||||
|
||||
bool same = true;
|
||||
for (size_t n = 0; n < len; ++n) {
|
||||
for (unsigned int n = 0; n < args[1]->listSize(); ++n) {
|
||||
Value res;
|
||||
state.callFunction(*args[0], *args[1]->listView()[n], res, noPos);
|
||||
state.callFunction(*args[0], *args[1]->listElems()[n], res, noPos);
|
||||
if (state.forceBool(
|
||||
res, pos, "while evaluating the return value of the filtering function passed to builtins.filter"))
|
||||
vs[k++] = args[1]->listView()[n];
|
||||
vs[k++] = args[1]->listElems()[n];
|
||||
else
|
||||
same = false;
|
||||
}
|
||||
@@ -3631,7 +3612,7 @@ static void prim_elem(EvalState & state, const PosIdx pos, Value ** args, Value
|
||||
{
|
||||
bool res = false;
|
||||
state.forceList(*args[1], pos, "while evaluating the second argument passed to builtins.elem");
|
||||
for (auto elem : args[1]->listView())
|
||||
for (auto elem : args[1]->listItems())
|
||||
if (state.eqValues(*args[0], *elem, pos, "while searching for the presence of the given element in the list")) {
|
||||
res = true;
|
||||
break;
|
||||
@@ -3653,11 +3634,10 @@ static RegisterPrimOp primop_elem({
|
||||
static void prim_concatLists(EvalState & state, const PosIdx pos, Value ** args, Value & v)
|
||||
{
|
||||
state.forceList(*args[0], pos, "while evaluating the first argument passed to builtins.concatLists");
|
||||
auto listView = args[0]->listView();
|
||||
state.concatLists(
|
||||
v,
|
||||
args[0]->listSize(),
|
||||
listView.data(),
|
||||
args[0]->listElems(),
|
||||
pos,
|
||||
"while evaluating a value of the list passed to builtins.concatLists");
|
||||
}
|
||||
@@ -3697,8 +3677,7 @@ static void prim_foldlStrict(EvalState & state, const PosIdx pos, Value ** args,
|
||||
if (args[2]->listSize()) {
|
||||
Value * vCur = args[1];
|
||||
|
||||
auto listView = args[2]->listView();
|
||||
for (auto [n, elem] : enumerate(listView)) {
|
||||
for (auto [n, elem] : enumerate(args[2]->listItems())) {
|
||||
Value * vs[]{vCur, elem};
|
||||
vCur = n == args[2]->listSize() - 1 ? &v : state.allocValue();
|
||||
state.callFunction(*args[0], vs, *vCur, pos);
|
||||
@@ -3741,7 +3720,7 @@ static void anyOrAll(bool any, EvalState & state, const PosIdx pos, Value ** arg
|
||||
: "while evaluating the return value of the function passed to builtins.all";
|
||||
|
||||
Value vTmp;
|
||||
for (auto elem : args[1]->listView()) {
|
||||
for (auto elem : args[1]->listItems()) {
|
||||
state.callFunction(*args[0], *elem, vTmp, pos);
|
||||
bool res = state.forceBool(vTmp, pos, errorCtx);
|
||||
if (res == any) {
|
||||
@@ -3787,12 +3766,12 @@ static void prim_genList(EvalState & state, const PosIdx pos, Value ** args, Val
|
||||
{
|
||||
auto len_ = state.forceInt(*args[1], pos, "while evaluating the second argument passed to builtins.genList").value;
|
||||
|
||||
if (len_ < 0 || std::make_unsigned_t<NixInt::Inner>(len_) > std::numeric_limits<size_t>::max())
|
||||
if (len_ < 0)
|
||||
state.error<EvalError>("cannot create list of size %1%", len_).atPos(pos).debugThrow();
|
||||
|
||||
size_t len = size_t(len_);
|
||||
|
||||
// More strict than strictly (!) necessary, but acceptable
|
||||
// More strict than striclty (!) necessary, but acceptable
|
||||
// as evaluating map without accessing any values makes little sense.
|
||||
state.forceFunction(*args[0], noPos, "while evaluating the first argument passed to builtins.genList");
|
||||
|
||||
@@ -3837,7 +3816,7 @@ static void prim_sort(EvalState & state, const PosIdx pos, Value ** args, Value
|
||||
|
||||
auto list = state.buildList(len);
|
||||
for (const auto & [n, v] : enumerate(list))
|
||||
state.forceValue(*(v = args[1]->listView()[n]), pos);
|
||||
state.forceValue(*(v = args[1]->listElems()[n]), pos);
|
||||
|
||||
auto comparator = [&](Value * a, Value * b) {
|
||||
/* Optimization: if the comparator is lessThan, bypass
|
||||
@@ -3856,14 +3835,10 @@ static void prim_sort(EvalState & state, const PosIdx pos, Value ** args, Value
|
||||
vBool, pos, "while evaluating the return value of the sorting function passed to builtins.sort");
|
||||
};
|
||||
|
||||
/* NOTE: Using custom implementation because std::sort and std::stable_sort
|
||||
are not resilient to comparators that violate strict weak ordering. Diagnosing
|
||||
incorrect implementations is a O(n^3) problem, so doing the checks is much more
|
||||
expensive that doing the sorting. For this reason we choose to use sorting algorithms
|
||||
that are can't be broken by invalid comprators. peeksort (mergesort)
|
||||
doesn't misbehave when any of the strict weak order properties is
|
||||
violated - output is always a reordering of the input. */
|
||||
peeksort(list.begin(), list.end(), comparator);
|
||||
/* FIXME: std::sort can segfault if the comparator is not a strict
|
||||
weak ordering. What to do? std::stable_sort() seems more
|
||||
resilient, but no guarantees... */
|
||||
std::stable_sort(list.begin(), list.end(), comparator);
|
||||
|
||||
v.mkList(list);
|
||||
}
|
||||
@@ -3885,32 +3860,6 @@ static RegisterPrimOp primop_sort({
|
||||
|
||||
This is a stable sort: it preserves the relative order of elements
|
||||
deemed equal by the comparator.
|
||||
|
||||
*comparator* must impose a strict weak ordering on the set of values
|
||||
in the *list*. This means that for any elements *a*, *b* and *c* from the
|
||||
*list*, *comparator* must satisfy the following relations:
|
||||
|
||||
1. Transitivity
|
||||
|
||||
```nix
|
||||
comparator a b && comparator b c -> comparator a c
|
||||
```
|
||||
|
||||
1. Irreflexivity
|
||||
|
||||
```nix
|
||||
comparator a a == false
|
||||
```
|
||||
|
||||
1. Transitivity of equivalence
|
||||
|
||||
```nix
|
||||
let equiv = a: b: (!comparator a b && !comparator b a); in
|
||||
equiv a b && equiv b c -> equiv a c
|
||||
```
|
||||
|
||||
If the *comparator* violates any of these properties, then `builtins.sort`
|
||||
reorders elements in an unspecified manner.
|
||||
)",
|
||||
.fun = prim_sort,
|
||||
});
|
||||
@@ -3924,8 +3873,8 @@ static void prim_partition(EvalState & state, const PosIdx pos, Value ** args, V
|
||||
|
||||
ValueVector right, wrong;
|
||||
|
||||
for (size_t n = 0; n < len; ++n) {
|
||||
auto vElem = args[1]->listView()[n];
|
||||
for (unsigned int n = 0; n < len; ++n) {
|
||||
auto vElem = args[1]->listElems()[n];
|
||||
state.forceValue(*vElem, pos);
|
||||
Value res;
|
||||
state.callFunction(*args[0], *vElem, res, pos);
|
||||
@@ -3983,7 +3932,7 @@ static void prim_groupBy(EvalState & state, const PosIdx pos, Value ** args, Val
|
||||
|
||||
ValueVectorMap attrs;
|
||||
|
||||
for (auto vElem : args[1]->listView()) {
|
||||
for (auto vElem : args[1]->listItems()) {
|
||||
Value res;
|
||||
state.callFunction(*args[0], *vElem, res, pos);
|
||||
auto name = state.forceStringNoCtx(
|
||||
@@ -4039,8 +3988,8 @@ static void prim_concatMap(EvalState & state, const PosIdx pos, Value ** args, V
|
||||
SmallTemporaryValueVector<conservativeStackReservation> lists(nrLists);
|
||||
size_t len = 0;
|
||||
|
||||
for (size_t n = 0; n < nrLists; ++n) {
|
||||
Value * vElem = args[1]->listView()[n];
|
||||
for (unsigned int n = 0; n < nrLists; ++n) {
|
||||
Value * vElem = args[1]->listElems()[n];
|
||||
state.callFunction(*args[0], *vElem, lists[n], pos);
|
||||
state.forceList(
|
||||
lists[n],
|
||||
@@ -4051,11 +4000,10 @@ static void prim_concatMap(EvalState & state, const PosIdx pos, Value ** args, V
|
||||
|
||||
auto list = state.buildList(len);
|
||||
auto out = list.elems;
|
||||
for (size_t n = 0, pos = 0; n < nrLists; ++n) {
|
||||
auto listView = lists[n].listView();
|
||||
auto l = listView.size();
|
||||
for (unsigned int n = 0, pos = 0; n < nrLists; ++n) {
|
||||
auto l = lists[n].listSize();
|
||||
if (l)
|
||||
memcpy(out + pos, listView.data(), l * sizeof(Value *));
|
||||
memcpy(out + pos, lists[n].listElems(), l * sizeof(Value *));
|
||||
pos += l;
|
||||
}
|
||||
v.mkList(list);
|
||||
@@ -4263,9 +4211,9 @@ static RegisterPrimOp primop_lessThan({
|
||||
.name = "__lessThan",
|
||||
.args = {"e1", "e2"},
|
||||
.doc = R"(
|
||||
Return `true` if the value *e1* is less than the value *e2*, and `false` otherwise.
|
||||
Evaluation aborts if either *e1* or *e2* does not evaluate to a number, string or path.
|
||||
Furthermore, it aborts if *e2* does not match *e1*'s type according to the aforementioned classification of number, string or path.
|
||||
Return `true` if the number *e1* is less than the number *e2*, and
|
||||
`false` otherwise. Evaluation aborts if either *e1* or *e2* does not
|
||||
evaluate to a number.
|
||||
)",
|
||||
.fun = prim_lessThan,
|
||||
});
|
||||
@@ -4315,7 +4263,6 @@ static RegisterPrimOp primop_toString({
|
||||
non-negative. */
|
||||
static void prim_substring(EvalState & state, const PosIdx pos, Value ** args, Value & v)
|
||||
{
|
||||
using NixUInt = std::make_unsigned_t<NixInt::Inner>;
|
||||
NixInt::Inner start =
|
||||
state
|
||||
.forceInt(
|
||||
@@ -4335,10 +4282,12 @@ static void prim_substring(EvalState & state, const PosIdx pos, Value ** args, V
|
||||
|
||||
// Negative length may be idiomatically passed to builtins.substring to get
|
||||
// the tail of the string.
|
||||
auto _len = std::numeric_limits<std::string::size_type>::max();
|
||||
if (len < 0) {
|
||||
len = std::numeric_limits<NixInt::Inner>::max();
|
||||
}
|
||||
|
||||
// Special-case on empty substring to avoid O(n) strlen
|
||||
// This allows for the use of empty substrings to efficiently capture string context
|
||||
// This allows for the use of empty substrings to efficently capture string context
|
||||
if (len == 0) {
|
||||
state.forceValue(*args[2], pos);
|
||||
if (args[2]->type() == nString) {
|
||||
@@ -4347,15 +4296,11 @@ static void prim_substring(EvalState & state, const PosIdx pos, Value ** args, V
|
||||
}
|
||||
}
|
||||
|
||||
if (len >= 0 && NixUInt(len) < _len) {
|
||||
_len = len;
|
||||
}
|
||||
|
||||
NixStringContext context;
|
||||
auto s = state.coerceToString(
|
||||
pos, *args[2], context, "while evaluating the third argument (the string) passed to builtins.substring");
|
||||
|
||||
v.mkString(NixUInt(start) >= s->size() ? "" : s->substr(start, _len), context);
|
||||
v.mkString((unsigned int) start >= s->size() ? "" : s->substr(start, len), context);
|
||||
}
|
||||
|
||||
static RegisterPrimOp primop_substring({
|
||||
@@ -4429,7 +4374,7 @@ static void prim_convertHash(EvalState & state, const PosIdx pos, Value ** args,
|
||||
state.forceAttrs(*args[0], pos, "while evaluating the first argument passed to builtins.convertHash");
|
||||
auto inputAttrs = args[0]->attrs();
|
||||
|
||||
auto iteratorHash = state.getAttr(state.symbols.create("hash"), inputAttrs, "while locating the attribute 'hash'");
|
||||
auto iteratorHash = getAttr(state, state.symbols.create("hash"), inputAttrs, "while locating the attribute 'hash'");
|
||||
auto hash = state.forceStringNoCtx(*iteratorHash->value, pos, "while evaluating the attribute 'hash'");
|
||||
|
||||
auto iteratorHashAlgo = inputAttrs->get(state.symbols.create("hashAlgo"));
|
||||
@@ -4438,8 +4383,8 @@ static void prim_convertHash(EvalState & state, const PosIdx pos, Value ** args,
|
||||
ha = parseHashAlgo(
|
||||
state.forceStringNoCtx(*iteratorHashAlgo->value, pos, "while evaluating the attribute 'hashAlgo'"));
|
||||
|
||||
auto iteratorToHashFormat = state.getAttr(
|
||||
state.symbols.create("toHashFormat"), args[0]->attrs(), "while locating the attribute 'toHashFormat'");
|
||||
auto iteratorToHashFormat = getAttr(
|
||||
state, state.symbols.create("toHashFormat"), args[0]->attrs(), "while locating the attribute 'toHashFormat'");
|
||||
HashFormat hf = parseHashFormat(
|
||||
state.forceStringNoCtx(*iteratorToHashFormat->value, pos, "while evaluating the attribute 'toHashFormat'"));
|
||||
|
||||
@@ -4663,7 +4608,7 @@ void prim_split(EvalState & state, const PosIdx pos, Value ** args, Value & v)
|
||||
// Add a list for matched substrings.
|
||||
const size_t slen = match.size() - 1;
|
||||
|
||||
// Start at 1, because the first match is the whole string.
|
||||
// Start at 1, beacause the first match is the whole string.
|
||||
auto list2 = state.buildList(slen);
|
||||
for (const auto & [si, v2] : enumerate(list2)) {
|
||||
if (!match[si + 1].matched)
|
||||
@@ -4747,7 +4692,7 @@ static void prim_concatStringsSep(EvalState & state, const PosIdx pos, Value **
|
||||
res.reserve((args[1]->listSize() + 32) * sep.size());
|
||||
bool first = true;
|
||||
|
||||
for (auto elem : args[1]->listView()) {
|
||||
for (auto elem : args[1]->listItems()) {
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
@@ -4782,14 +4727,14 @@ static void prim_replaceStrings(EvalState & state, const PosIdx pos, Value ** ar
|
||||
.atPos(pos)
|
||||
.debugThrow();
|
||||
|
||||
std::vector<std::string_view> from;
|
||||
std::vector<std::string> from;
|
||||
from.reserve(args[0]->listSize());
|
||||
for (auto elem : args[0]->listView())
|
||||
for (auto elem : args[0]->listItems())
|
||||
from.emplace_back(state.forceString(
|
||||
*elem, pos, "while evaluating one of the strings to replace passed to builtins.replaceStrings"));
|
||||
|
||||
std::unordered_map<size_t, std::string_view> cache;
|
||||
auto to = args[1]->listView();
|
||||
std::unordered_map<size_t, std::string> cache;
|
||||
auto to = args[1]->listItems();
|
||||
|
||||
NixStringContext context;
|
||||
auto s = state.forceString(
|
||||
@@ -5046,7 +4991,7 @@ void EvalState::createBaseEnv(const EvalSettings & evalSettings)
|
||||
.type = nInt,
|
||||
.doc = R"(
|
||||
Return the [Unix time](https://en.wikipedia.org/wiki/Unix_time) at first evaluation.
|
||||
Repeated references to that name re-use the initially obtained value.
|
||||
Repeated references to that name will re-use the initially obtained value.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -5061,7 +5006,7 @@ void EvalState::createBaseEnv(const EvalSettings & evalSettings)
|
||||
1683705525
|
||||
```
|
||||
|
||||
The [store path](@docroot@/store/store-path.md) of a derivation depending on `currentTime` differs for each evaluation, unless both evaluate `builtins.currentTime` in the same second.
|
||||
The [store path](@docroot@/store/store-path.md) of a derivation depending on `currentTime` will differ for each evaluation, unless both evaluate `builtins.currentTime` in the same second.
|
||||
)",
|
||||
.impureOnly = true,
|
||||
});
|
||||
@@ -5255,7 +5200,7 @@ void EvalState::createBaseEnv(const EvalSettings & evalSettings)
|
||||
|
||||
/* Now that we've added all primops, sort the `builtins' set,
|
||||
because attribute lookups expect it to be sorted. */
|
||||
const_cast<Bindings *>(getBuiltins().attrs())->sort();
|
||||
getBuiltins().payload.attrs->sort();
|
||||
|
||||
staticBaseEnv->sort();
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ static RegisterPrimOp primop_getContext(
|
||||
The string context tracks references to derivations within a string.
|
||||
It is represented as an attribute set of [store derivation](@docroot@/glossary.md#gloss-store-derivation) paths mapping to output names.
|
||||
|
||||
Using [string interpolation](@docroot@/language/string-interpolation.md) on a derivation adds that derivation to the string context.
|
||||
Using [string interpolation](@docroot@/language/string-interpolation.md) on a derivation will add that derivation to the string context.
|
||||
For example,
|
||||
|
||||
```nix
|
||||
@@ -308,7 +308,7 @@ static void prim_appendContext(EvalState & state, const PosIdx pos, Value ** arg
|
||||
.atPos(i.pos)
|
||||
.debugThrow();
|
||||
}
|
||||
for (auto elem : attr->value->listView()) {
|
||||
for (auto elem : attr->value->listItems()) {
|
||||
auto outputName =
|
||||
state.forceStringNoCtx(*elem, attr->pos, "while evaluating an output name within a string context");
|
||||
context.emplace(
|
||||
|
||||
@@ -131,7 +131,7 @@ static void prim_fetchClosure(EvalState & state, const PosIdx pos, Value ** args
|
||||
for (auto & attr : *args[0]->attrs()) {
|
||||
const auto & attrName = state.symbols[attr.name];
|
||||
auto attrHint = [&]() -> std::string {
|
||||
return fmt("while evaluating the attribute '%s' passed to builtins.fetchClosure", attrName);
|
||||
return "while evaluating the '" + attrName + "' attribute passed to builtins.fetchClosure";
|
||||
};
|
||||
|
||||
if (attrName == "fromPath") {
|
||||
@@ -212,7 +212,7 @@ static RegisterPrimOp primop_fetchClosure({
|
||||
.doc = R"(
|
||||
Fetch a store path [closure](@docroot@/glossary.md#gloss-closure) from a binary cache, and return the store path as a string with context.
|
||||
|
||||
This function can be invoked in three ways that we will discuss in order of preference.
|
||||
This function can be invoked in three ways, that we will discuss in order of preference.
|
||||
|
||||
**Fetch a content-addressed store path**
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ static void fetchTree(
|
||||
else
|
||||
state
|
||||
.error<EvalError>(
|
||||
"in pure evaluation mode, '%s' doesn't fetch unlocked input '%s'", fetcher, input.to_string())
|
||||
"in pure evaluation mode, '%s' will not fetch unlocked input '%s'", fetcher, input.to_string())
|
||||
.atPos(pos)
|
||||
.debugThrow();
|
||||
}
|
||||
@@ -257,7 +257,7 @@ static RegisterPrimOp primop_fetchTree({
|
||||
That is, `fetchTree` is idempotent.
|
||||
|
||||
Downloads are cached in `$XDG_CACHE_HOME/nix`.
|
||||
The remote source is fetched from the network if both are true:
|
||||
The remote source will be fetched from the network if both are true:
|
||||
- A NAR hash is supplied and the corresponding store path is not [valid](@docroot@/glossary.md#gloss-validity), that is, not available in the store
|
||||
|
||||
> **Note**
|
||||
@@ -319,7 +319,7 @@ static RegisterPrimOp primop_fetchTree({
|
||||
- `"tarball"`
|
||||
|
||||
Download a tar archive and extract it into the Nix store.
|
||||
This has the same underlying implementation as [`builtins.fetchTarball`](@docroot@/language/builtins.md#builtins-fetchTarball)
|
||||
This has the same underyling implementation as [`builtins.fetchTarball`](@docroot@/language/builtins.md#builtins-fetchTarball)
|
||||
|
||||
- `url` (String, required)
|
||||
|
||||
@@ -352,7 +352,7 @@ static RegisterPrimOp primop_fetchTree({
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> If the URL points to a local directory, and no `ref` or `rev` is given, Nix only considers files added to the Git index, as listed by `git ls-files` but use the *current file contents* of the Git working directory.
|
||||
> If the URL points to a local directory, and no `ref` or `rev` is given, Nix will only consider files added to the Git index, as listed by `git ls-files` but use the *current file contents* of the Git working directory.
|
||||
|
||||
- `ref` (String, optional)
|
||||
|
||||
@@ -570,12 +570,11 @@ static void fetch(
|
||||
// TODO: fetching may fail, yet the path may be substitutable.
|
||||
// https://github.com/NixOS/nix/issues/4313
|
||||
auto storePath = unpack ? fetchToStore(
|
||||
state.fetchSettings,
|
||||
*state.store,
|
||||
fetchers::downloadTarball(state.store, state.fetchSettings, *url),
|
||||
FetchMode::Copy,
|
||||
name)
|
||||
: fetchers::downloadFile(state.store, state.fetchSettings, *url, name).storePath;
|
||||
: fetchers::downloadFile(state.store, *url, name).storePath;
|
||||
|
||||
if (expectedHash) {
|
||||
auto hash = unpack ? state.store->queryPathInfo(storePath)->narHash
|
||||
@@ -710,7 +709,7 @@ static RegisterPrimOp primop_fetchGit({
|
||||
This option has no effect once `shallow` cloning is enabled.
|
||||
|
||||
By default, the `ref` value is prefixed with `refs/heads/`.
|
||||
As of 2.3.0, Nix doesn't prefix `refs/heads/` if `ref` starts with `refs/`.
|
||||
As of 2.3.0, Nix will not prefix `refs/heads/` if `ref` starts with `refs/`.
|
||||
|
||||
- `submodules` (default: `false`)
|
||||
|
||||
@@ -869,7 +868,7 @@ static RegisterPrimOp primop_fetchGit({
|
||||
}
|
||||
```
|
||||
|
||||
Nix refetches the branch according to the [`tarball-ttl`](@docroot@/command-ref/conf-file.md#conf-tarball-ttl) setting.
|
||||
Nix will refetch the branch according to the [`tarball-ttl`](@docroot@/command-ref/conf-file.md#conf-tarball-ttl) setting.
|
||||
|
||||
This behavior is disabled in [pure evaluation mode](@docroot@/command-ref/conf-file.md#conf-pure-eval).
|
||||
|
||||
@@ -880,9 +879,9 @@ static RegisterPrimOp primop_fetchGit({
|
||||
```
|
||||
|
||||
If the URL points to a local directory, and no `ref` or `rev` is
|
||||
given, `fetchGit` uses the current content of the checked-out
|
||||
files, even if they are not committed or added to Git's index. It
|
||||
only considers files added to the Git repository, as listed by `git ls-files`.
|
||||
given, `fetchGit` will use the current content of the checked-out
|
||||
files, even if they are not committed or added to Git's index. It will
|
||||
only consider files added to the Git repository, as listed by `git ls-files`.
|
||||
)",
|
||||
.fun = prim_fetchGit,
|
||||
});
|
||||
|
||||
@@ -1,73 +1,140 @@
|
||||
#include "nix/expr/primops.hh"
|
||||
#include "nix/expr/eval-inline.hh"
|
||||
|
||||
#include "expr-config-private.hh"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <toml.hpp>
|
||||
|
||||
namespace nix {
|
||||
|
||||
#if HAVE_TOML11_4
|
||||
|
||||
/**
|
||||
* This is what toml11 < 4.0 did when choosing the subsecond precision.
|
||||
* TOML 1.0.0 spec doesn't define how sub-millisecond ranges should be handled and calls it
|
||||
* implementation defined behavior. For a lack of a better choice we stick with what older versions
|
||||
* of toml11 did [1].
|
||||
*
|
||||
* [1]: https://github.com/ToruNiina/toml11/blob/dcfe39a783a94e8d52c885e5883a6fbb21529019/toml/datetime.hpp#L282
|
||||
*/
|
||||
static size_t normalizeSubsecondPrecision(toml::local_time lt)
|
||||
{
|
||||
auto millis = lt.millisecond;
|
||||
auto micros = lt.microsecond;
|
||||
auto nanos = lt.nanosecond;
|
||||
if (millis != 0 || micros != 0 || nanos != 0) {
|
||||
if (micros != 0 || nanos != 0) {
|
||||
if (nanos != 0)
|
||||
return 9;
|
||||
return 6;
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize date/time formats to serialize to the same strings as versions prior to toml11 4.0.
|
||||
*
|
||||
* Several things to consider:
|
||||
*
|
||||
* 1. Sub-millisecond range is represented the same way as in toml11 versions prior to 4.0. Precisioun is rounded
|
||||
* towards the next multiple of 3 or capped at 9 digits.
|
||||
* 2. Seconds must be specified. This may become optional in (yet unreleased) TOML 1.1.0, but 1.0.0 defined local time
|
||||
* in terms of RFC3339 [1].
|
||||
* 3. date-time separator (`t`, `T` or space ` `) is canonicalized to an upper T. This is compliant with RFC3339
|
||||
* [1] 5.6:
|
||||
* > Applications that generate this format SHOULD use upper case letters.
|
||||
*
|
||||
* [1]: https://datatracker.ietf.org/doc/html/rfc3339#section-5.6
|
||||
*/
|
||||
static void normalizeDatetimeFormat(toml::value & t)
|
||||
{
|
||||
if (t.is_local_datetime()) {
|
||||
auto & ldt = t.as_local_datetime();
|
||||
t.as_local_datetime_fmt() = {
|
||||
.delimiter = toml::datetime_delimiter_kind::upper_T,
|
||||
// https://datatracker.ietf.org/doc/html/rfc3339#section-5.6
|
||||
.has_seconds = true, // Mandated by TOML 1.0.0
|
||||
.subsecond_precision = normalizeSubsecondPrecision(ldt.time),
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
if (t.is_offset_datetime()) {
|
||||
auto & odt = t.as_offset_datetime();
|
||||
t.as_offset_datetime_fmt() = {
|
||||
.delimiter = toml::datetime_delimiter_kind::upper_T,
|
||||
// https://datatracker.ietf.org/doc/html/rfc3339#section-5.6
|
||||
.has_seconds = true, // Mandated by TOML 1.0.0
|
||||
.subsecond_precision = normalizeSubsecondPrecision(odt.time),
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
if (t.is_local_time()) {
|
||||
auto & lt = t.as_local_time();
|
||||
t.as_local_time_fmt() = {
|
||||
.has_seconds = true, // Mandated by TOML 1.0.0
|
||||
.subsecond_precision = normalizeSubsecondPrecision(lt),
|
||||
};
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void prim_fromTOML(EvalState & state, const PosIdx pos, Value ** args, Value & val)
|
||||
{
|
||||
auto toml = state.forceStringNoCtx(*args[0], pos, "while evaluating the argument passed to builtins.fromTOML");
|
||||
|
||||
std::istringstream tomlStream(std::string{toml});
|
||||
|
||||
std::function<void(Value &, toml::value)> visit;
|
||||
|
||||
visit = [&](Value & v, toml::value t) {
|
||||
auto visit = [&](auto & self, Value & v, toml::value t) -> void {
|
||||
switch (t.type()) {
|
||||
case toml::value_t::table: {
|
||||
auto table = toml::get<toml::table>(t);
|
||||
|
||||
size_t size = 0;
|
||||
for (auto & i : table) {
|
||||
(void) i;
|
||||
size++;
|
||||
}
|
||||
|
||||
auto attrs = state.buildBindings(size);
|
||||
auto attrs = state.buildBindings(table.size());
|
||||
|
||||
for (auto & elem : table) {
|
||||
forceNoNullByte(elem.first);
|
||||
visit(attrs.alloc(elem.first), elem.second);
|
||||
self(self, attrs.alloc(elem.first), elem.second);
|
||||
}
|
||||
|
||||
v.mkAttrs(attrs);
|
||||
} break;
|
||||
;
|
||||
case toml::value_t::array: {
|
||||
auto array = toml::get<std::vector<toml::value>>(t);
|
||||
|
||||
auto list = state.buildList(array.size());
|
||||
for (const auto & [n, v] : enumerate(list))
|
||||
visit(*(v = state.allocValue()), array[n]);
|
||||
self(self, *(v = state.allocValue()), array[n]);
|
||||
v.mkList(list);
|
||||
} break;
|
||||
;
|
||||
case toml::value_t::boolean:
|
||||
v.mkBool(toml::get<bool>(t));
|
||||
break;
|
||||
;
|
||||
case toml::value_t::integer:
|
||||
v.mkInt(toml::get<int64_t>(t));
|
||||
break;
|
||||
;
|
||||
case toml::value_t::floating:
|
||||
v.mkFloat(toml::get<NixFloat>(t));
|
||||
break;
|
||||
;
|
||||
case toml::value_t::string: {
|
||||
auto s = toml::get<std::string_view>(t);
|
||||
forceNoNullByte(s);
|
||||
v.mkString(s);
|
||||
} break;
|
||||
;
|
||||
case toml::value_t::local_datetime:
|
||||
case toml::value_t::offset_datetime:
|
||||
case toml::value_t::local_date:
|
||||
case toml::value_t::local_time: {
|
||||
if (experimentalFeatureSettings.isEnabled(Xp::ParseTomlTimestamps)) {
|
||||
#if HAVE_TOML11_4
|
||||
normalizeDatetimeFormat(t);
|
||||
#endif
|
||||
auto attrs = state.buildBindings(2);
|
||||
attrs.alloc("_type").mkString("timestamp");
|
||||
std::ostringstream s;
|
||||
@@ -80,16 +147,24 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value ** args, Va
|
||||
throw std::runtime_error("Dates and times are not supported");
|
||||
}
|
||||
} break;
|
||||
;
|
||||
case toml::value_t::empty:
|
||||
v.mkNull();
|
||||
break;
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
visit(val, toml::parse(tomlStream, "fromTOML" /* the "filename" */));
|
||||
visit(
|
||||
visit,
|
||||
val,
|
||||
toml::parse(
|
||||
tomlStream,
|
||||
"fromTOML" /* the "filename" */
|
||||
#if HAVE_TOML11_4
|
||||
,
|
||||
toml::spec::v(1, 0, 0) // Be explicit that we are parsing TOML 1.0.0 without extensions
|
||||
#endif
|
||||
));
|
||||
} catch (std::exception & e) { // TODO: toml::syntax_error
|
||||
state.error<EvalError>("while parsing TOML: %s", e.what()).atPos(pos).debugThrow();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generated_headers += gen_header.process(
|
||||
'derivation.nix',
|
||||
preserve_path_from : meson.project_source_root(),
|
||||
preserve_path_from: meson.project_source_root(),
|
||||
)
|
||||
|
||||
sources += files(
|
||||
|
||||
@@ -46,13 +46,11 @@ void printAmbiguous(
|
||||
break;
|
||||
}
|
||||
case nList:
|
||||
/* Use pointer to the Value instead of pointer to the elements, because
|
||||
that would need to explicitly handle the case of SmallList. */
|
||||
if (seen && v.listSize() && !seen->insert(&v).second)
|
||||
if (seen && v.listSize() && !seen->insert(v.listElems()).second)
|
||||
str << "«repeated»";
|
||||
else {
|
||||
str << "[ ";
|
||||
for (auto v2 : v.listView()) {
|
||||
for (auto v2 : v.listItems()) {
|
||||
if (v2)
|
||||
printAmbiguous(*v2, symbols, str, seen, depth - 1);
|
||||
else
|
||||
|
||||
@@ -415,8 +415,8 @@ private:
|
||||
if (depth < options.maxDepth) {
|
||||
increaseIndent();
|
||||
output << "[";
|
||||
auto listItems = v.listView();
|
||||
auto prettyPrint = shouldPrettyPrintList(listItems.span());
|
||||
auto listItems = v.listItems();
|
||||
auto prettyPrint = shouldPrettyPrintList(listItems);
|
||||
|
||||
size_t currentListItemsPrinted = 0;
|
||||
|
||||
@@ -453,13 +453,13 @@ private:
|
||||
|
||||
if (v.isLambda()) {
|
||||
output << "lambda";
|
||||
if (v.lambda().fun) {
|
||||
if (v.lambda().fun->name) {
|
||||
output << " " << state.symbols[v.lambda().fun->name];
|
||||
if (v.payload.lambda.fun) {
|
||||
if (v.payload.lambda.fun->name) {
|
||||
output << " " << state.symbols[v.payload.lambda.fun->name];
|
||||
}
|
||||
|
||||
std::ostringstream s;
|
||||
s << state.positions[v.lambda().fun->pos];
|
||||
s << state.positions[v.payload.lambda.fun->pos];
|
||||
output << " @ " << filterANSIEscapes(toView(s));
|
||||
}
|
||||
} else if (v.isPrimOp()) {
|
||||
|
||||
Loaded 100 of 347 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user