Compare commits
40 Commits
warn-non-o
...
2.26.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3e9204833 | ||
|
|
0ff190107f | ||
|
|
dffcc184d7 | ||
|
|
49f226e87b | ||
|
|
d308228497 | ||
|
|
dfbd030d3f | ||
|
|
83306bb841 | ||
|
|
4c3786dd40 | ||
|
|
0531f1299c | ||
|
|
df8d5e61ad | ||
|
|
30435e0559 | ||
|
|
31bdb2a8ff | ||
|
|
8e4cd2f537 | ||
|
|
1fe33c13d9 | ||
|
|
727cf59997 | ||
|
|
acba2c6f4f | ||
|
|
491aaaf116 | ||
|
|
862b3f41a4 | ||
|
|
28684af74b | ||
|
|
1c1f8b2343 | ||
|
|
a02e814b4b | ||
|
|
a75cf57702 | ||
|
|
605bd06ca4 | ||
|
|
84efd3ecf2 | ||
|
|
527e68ac3e | ||
|
|
2fce659c7d | ||
|
|
791d6cf433 | ||
|
|
3e0d9ff937 | ||
|
|
f629d81df0 | ||
|
|
32aed360b8 | ||
|
|
6cb17fd836 | ||
|
|
36bd92736f | ||
|
|
90159cb197 | ||
|
|
4cfeb8d1bb | ||
|
|
9cf3d3368e | ||
|
|
aab6419b63 | ||
|
|
832221650b | ||
|
|
2301d86f32 | ||
|
|
91e60321f6 | ||
|
|
28752fe288 |
@@ -8,7 +8,7 @@ BraceWrapping:
|
||||
AfterUnion: true
|
||||
SplitEmptyRecord: false
|
||||
PointerAlignment: Middle
|
||||
FixNamespaceComments: true
|
||||
FixNamespaceComments: false
|
||||
SortIncludes: Never
|
||||
#IndentPPDirectives: BeforeHash
|
||||
SpaceAfterCStyleCast: true
|
||||
@@ -32,4 +32,3 @@ IndentPPDirectives: AfterHash
|
||||
PPIndentWidth: 2
|
||||
BinPackArguments: false
|
||||
BreakBeforeTernaryOperators: true
|
||||
SeparateDefinitionBlocks: Always
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
|
||||
# Disable CodeRabbit auto-review to prevent verbose comments on PRs.
|
||||
# When enabled: false, CodeRabbit won't attempt reviews and won't post
|
||||
# "Review skipped" or other automated comments.
|
||||
reviews:
|
||||
auto_review:
|
||||
enabled: false
|
||||
review_status: false
|
||||
high_level_summary: false
|
||||
poem: false
|
||||
sequence_diagrams: false
|
||||
changed_files_summary: false
|
||||
tools:
|
||||
github-checks:
|
||||
enabled: false
|
||||
chat:
|
||||
art: false
|
||||
auto_reply: false
|
||||
@@ -1,6 +0,0 @@
|
||||
# bulk initial re-formatting with clang-format
|
||||
e4f62e46088919428a68bd8014201dc8e379fed7 # !autorebase ./maintainers/format.sh --until-stable
|
||||
# meson re-formatting
|
||||
385e2c3542c707d95e3784f7f6d623f67e77ab61 # !autorebase ./maintainers/format.sh --until-stable
|
||||
# nixfmt 1.0.0
|
||||
1d943f581908f35075a84a3d89c2eba3ff35067f # !autorebase ./maintainers/format.sh --until-stable
|
||||
11
.github/CODEOWNERS
vendored
11
.github/CODEOWNERS
vendored
@@ -11,7 +11,16 @@
|
||||
.github/CODEOWNERS @edolstra
|
||||
|
||||
# Documentation of built-in functions
|
||||
src/libexpr/primops.cc @roberth
|
||||
src/libexpr/primops.cc @roberth @fricklerhandwerk
|
||||
|
||||
# Documentation of settings
|
||||
src/libexpr/eval-settings.hh @fricklerhandwerk
|
||||
src/libstore/globals.hh @fricklerhandwerk
|
||||
|
||||
# Documentation
|
||||
doc/manual @fricklerhandwerk
|
||||
maintainers/*.md @fricklerhandwerk
|
||||
src/**/*.md @fricklerhandwerk
|
||||
|
||||
# Libstore layer
|
||||
/src/libstore @ericson2314
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -45,7 +45,7 @@ assignees: ''
|
||||
- [ ] checked [latest Nix manual] \([source])
|
||||
- [ ] checked [open bug issues and pull requests] for possible duplicates
|
||||
|
||||
[latest Nix manual]: https://nix.dev/manual/nix/development/
|
||||
[latest Nix manual]: https://nixos.org/manual/nix/unstable/
|
||||
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
|
||||
[open bug issues and pull requests]: https://github.com/NixOS/nix/labels/bug
|
||||
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -30,7 +30,7 @@ assignees: ''
|
||||
- [ ] checked [latest Nix manual] \([source])
|
||||
- [ ] checked [open feature issues and pull requests] for possible duplicates
|
||||
|
||||
[latest Nix manual]: https://nix.dev/manual/nix/development/
|
||||
[latest Nix manual]: https://nixos.org/manual/nix/unstable/
|
||||
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
|
||||
[open feature issues and pull requests]: https://github.com/NixOS/nix/labels/feature
|
||||
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/installer.md
vendored
2
.github/ISSUE_TEMPLATE/installer.md
vendored
@@ -38,7 +38,7 @@ assignees: ''
|
||||
- [ ] checked [latest Nix manual] \([source])
|
||||
- [ ] checked [open installer issues and pull requests] for possible duplicates
|
||||
|
||||
[latest Nix manual]: https://nix.dev/manual/nix/development/
|
||||
[latest Nix manual]: https://nixos.org/manual/nix/unstable/
|
||||
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
|
||||
[open installer issues and pull requests]: https://github.com/NixOS/nix/labels/installer
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ assignees: ''
|
||||
- [ ] checked [latest Nix manual] \([source])
|
||||
- [ ] checked [open documentation issues and pull requests] for possible duplicates
|
||||
|
||||
[latest Nix manual]: https://nix.dev/manual/nix/development/
|
||||
[latest Nix manual]: https://nixos.org/manual/nix/unstable/
|
||||
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
|
||||
[open documentation issues and pull requests]: https://github.com/NixOS/nix/labels/documentation
|
||||
|
||||
|
||||
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -15,10 +15,6 @@ so you understand the process and the expectations.
|
||||
- volunteering contributions effectively
|
||||
- how to get help and our review process.
|
||||
|
||||
PR stuck in review? We have two Nix team meetings per week online that are open for everyone in a jitsi conference:
|
||||
|
||||
- https://calendar.google.com/calendar/u/0/embed?src=b9o52fobqjak8oq8lfkhg3t0qg@group.calendar.google.com
|
||||
|
||||
-->
|
||||
|
||||
## Motivation
|
||||
|
||||
2
.github/STALE-BOT.md
vendored
2
.github/STALE-BOT.md
vendored
@@ -3,7 +3,7 @@
|
||||
- Thanks for your contribution!
|
||||
- To remove the stale label, just leave a new comment.
|
||||
- _How to find the right people to ping?_ → [`git blame`](https://git-scm.com/docs/git-blame) to the rescue! (or GitHub's history and blame buttons.)
|
||||
- You can always ask for help on [our Discourse Forum](https://discourse.nixos.org/) or on [Matrix - #users:nixos.org](https://matrix.to/#/#users:nixos.org).
|
||||
- You can always ask for help on [our Discourse Forum](https://discourse.nixos.org/) or on [Matrix - #nix:nixos.org](https://matrix.to/#/#nix:nixos.org).
|
||||
|
||||
## Suggestions for PRs
|
||||
|
||||
|
||||
131
.github/actions/install-nix-action/action.yaml
vendored
131
.github/actions/install-nix-action/action.yaml
vendored
@@ -1,131 +0,0 @@
|
||||
name: "Install Nix"
|
||||
description: "Helper action for installing Nix with support for dogfooding from master"
|
||||
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.32.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 magic-nix-cache"
|
||||
default: true
|
||||
required: false
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Download nix install artifact from master"
|
||||
shell: bash
|
||||
id: download-nix-installer
|
||||
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")
|
||||
|
||||
if [ "$RUNNER_OS" == "Linux" ]; then
|
||||
INSTALLER_ARTIFACT="installer-linux"
|
||||
elif [ "$RUNNER_OS" == "macOS" ]; then
|
||||
INSTALLER_ARTIFACT="installer-darwin"
|
||||
else
|
||||
echo "::error ::Unsupported RUNNER_OS: $RUNNER_OS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
INSTALLER_DOWNLOAD_DIR="$GITHUB_WORKSPACE/$INSTALLER_ARTIFACT"
|
||||
mkdir -p "$INSTALLER_DOWNLOAD_DIR"
|
||||
|
||||
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 == '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 }}
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@565684385bcd71bad329742eefe8d12f2e765b39 # v13
|
||||
if: ${{ inputs.use_cache == 'true' }}
|
||||
with:
|
||||
diagnostic-endpoint: ''
|
||||
use-flakehub: false
|
||||
use-gha-cache: true
|
||||
source-revision: 92d9581367be2233c2d5714a2640e1339f4087d8 # main
|
||||
37
.github/workflows/backport.yml
vendored
37
.github/workflows/backport.yml
vendored
@@ -1,37 +0,0 @@
|
||||
name: Backport
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [closed, labeled]
|
||||
permissions:
|
||||
contents: read
|
||||
jobs:
|
||||
backport:
|
||||
name: Backport Pull Request
|
||||
permissions:
|
||||
# for korthout/backport-action
|
||||
contents: write
|
||||
pull-requests: write
|
||||
if: github.repository_owner == 'NixOS' && github.event.pull_request.merged == true && (github.event_name != 'labeled' || startsWith('backport', github.event.label.name))
|
||||
runs-on: ubuntu-24.04-arm
|
||||
steps:
|
||||
- name: Generate GitHub App token
|
||||
id: generate-token
|
||||
uses: actions/create-github-app-token@v2
|
||||
with:
|
||||
app-id: ${{ vars.CI_APP_ID }}
|
||||
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
# required to find all branches
|
||||
fetch-depth: 0
|
||||
- name: Create backport PRs
|
||||
uses: korthout/backport-action@d07416681cab29bf2661702f925f020aaa962997 # v3.4.1
|
||||
id: backport
|
||||
with:
|
||||
# Config README: https://github.com/korthout/backport-action#backport-action
|
||||
github_token: ${{ steps.generate-token.outputs.token }}
|
||||
github_workspace: ${{ github.workspace }}
|
||||
auto_merge_enabled: true
|
||||
pull_description: |-
|
||||
Automatic backport to `${target_branch}`, triggered by a label in #${pull_number}.
|
||||
224
.github/workflows/ci.yml
vendored
224
.github/workflows/ci.yml
vendored
@@ -2,21 +2,7 @@ name: "CI"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
merge_group:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
dogfood:
|
||||
description: 'Use dogfood Nix build'
|
||||
required: false
|
||||
default: true
|
||||
type: boolean
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: read-all
|
||||
|
||||
@@ -24,43 +10,13 @@ jobs:
|
||||
eval:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: ./.github/actions/install-nix-action
|
||||
with:
|
||||
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
|
||||
extra_nix_config:
|
||||
experimental-features = nix-command flakes
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
use_cache: false
|
||||
- run: nix flake show --all-systems --json
|
||||
|
||||
pre-commit-checks:
|
||||
name: pre-commit checks
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: ./.github/actions/install-nix-action
|
||||
with:
|
||||
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
|
||||
extra_nix_config: experimental-features = nix-command flakes
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: ./ci/gha/tests/pre-commit-checks
|
||||
|
||||
basic-checks:
|
||||
name: aggregate basic checks
|
||||
if: ${{ always() }}
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [pre-commit-checks, eval]
|
||||
steps:
|
||||
- name: Exit with any errors
|
||||
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
|
||||
run: |
|
||||
exit 1
|
||||
- uses: cachix/install-nix-action@v30
|
||||
- run: nix --experimental-features 'nix-command flakes' flake show --all-systems --json
|
||||
|
||||
tests:
|
||||
needs: basic-checks
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -68,74 +24,34 @@ jobs:
|
||||
- scenario: on ubuntu
|
||||
runs-on: ubuntu-24.04
|
||||
os: linux
|
||||
instrumented: false
|
||||
primary: true
|
||||
stdenv: stdenv
|
||||
- scenario: on macos
|
||||
runs-on: macos-14
|
||||
os: darwin
|
||||
instrumented: false
|
||||
primary: true
|
||||
stdenv: stdenv
|
||||
- scenario: on ubuntu (with sanitizers / coverage)
|
||||
runs-on: ubuntu-24.04
|
||||
os: linux
|
||||
instrumented: true
|
||||
primary: false
|
||||
stdenv: clangStdenv
|
||||
name: tests ${{ matrix.scenario }}
|
||||
runs-on: ${{ matrix.runs-on }}
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: ./.github/actions/install-nix-action
|
||||
- uses: cachix/install-nix-action@v30
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
|
||||
# The sandbox would otherwise be disabled by default on Darwin
|
||||
extra_nix_config: "sandbox = true"
|
||||
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
|
||||
if: matrix.os == 'linux'
|
||||
- name: Run component tests
|
||||
run: |
|
||||
nix build --file ci/gha/tests/wrapper.nix componentTests -L \
|
||||
--arg withInstrumentation ${{ matrix.instrumented }} \
|
||||
--argstr stdenv "${{ matrix.stdenv }}"
|
||||
- name: Run VM tests
|
||||
run: |
|
||||
nix build --file ci/gha/tests/wrapper.nix vmTests -L \
|
||||
--arg withInstrumentation ${{ matrix.instrumented }} \
|
||||
--argstr stdenv "${{ matrix.stdenv }}"
|
||||
if: ${{ matrix.os == 'linux' }}
|
||||
- name: Run flake checks and prepare the installer tarball
|
||||
run: |
|
||||
ci/gha/tests/build-checks
|
||||
ci/gha/tests/prepare-installer-for-github-actions
|
||||
if: ${{ matrix.primary }}
|
||||
- name: Collect code coverage
|
||||
run: |
|
||||
nix build --file ci/gha/tests/wrapper.nix codeCoverage.coverageReports -L \
|
||||
--arg withInstrumentation ${{ matrix.instrumented }} \
|
||||
--argstr stdenv "${{ matrix.stdenv }}" \
|
||||
--out-link coverage-reports
|
||||
cat coverage-reports/index.txt >> $GITHUB_STEP_SUMMARY
|
||||
if: ${{ matrix.instrumented }}
|
||||
- name: Upload coverage reports
|
||||
uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: coverage-reports
|
||||
path: coverage-reports/
|
||||
if: ${{ matrix.instrumented }}
|
||||
- run: scripts/build-checks
|
||||
- run: scripts/prepare-installer-for-github-actions
|
||||
- name: Upload installer tarball
|
||||
uses: actions/upload-artifact@v5
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: installer-${{matrix.os}}
|
||||
path: out/*
|
||||
if: ${{ matrix.primary }}
|
||||
|
||||
installer_test:
|
||||
needs: [tests]
|
||||
@@ -146,46 +62,25 @@ jobs:
|
||||
- scenario: on ubuntu
|
||||
runs-on: ubuntu-24.04
|
||||
os: linux
|
||||
experimental-installer: false
|
||||
- scenario: on macos
|
||||
runs-on: macos-14
|
||||
os: darwin
|
||||
experimental-installer: false
|
||||
- scenario: on ubuntu (experimental)
|
||||
runs-on: ubuntu-24.04
|
||||
os: linux
|
||||
experimental-installer: true
|
||||
- scenario: on macos (experimental)
|
||||
runs-on: macos-14
|
||||
os: darwin
|
||||
experimental-installer: true
|
||||
name: installer test ${{ matrix.scenario }}
|
||||
runs-on: ${{ matrix.runs-on }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download installer tarball
|
||||
uses: actions/download-artifact@v6
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: installer-${{matrix.os}}
|
||||
path: out
|
||||
- name: Looking up the installer tarball URL
|
||||
id: installer-tarball-url
|
||||
run: |
|
||||
echo "installer-url=file://$GITHUB_WORKSPACE/out" >> "$GITHUB_OUTPUT"
|
||||
TARBALL_PATH="$(find "$GITHUB_WORKSPACE/out" -name 'nix*.tar.xz' -print | head -n 1)"
|
||||
echo "tarball-path=file://$TARBALL_PATH" >> "$GITHUB_OUTPUT"
|
||||
- uses: cachix/install-nix-action@0b0e072294b088b73964f1d72dfdac0951439dbd # v31.8.4
|
||||
if: ${{ !matrix.experimental-installer }}
|
||||
- name: Serving installer
|
||||
id: serving_installer
|
||||
run: ./scripts/serve-installer-for-github-actions
|
||||
- uses: cachix/install-nix-action@v30
|
||||
with:
|
||||
install_url: ${{ format('{0}/install', steps.installer-tarball-url.outputs.installer-url) }}
|
||||
install_options: ${{ format('--tarball-url-prefix {0}', steps.installer-tarball-url.outputs.installer-url) }}
|
||||
- uses: ./.github/actions/install-nix-action
|
||||
if: ${{ matrix.experimental-installer }}
|
||||
with:
|
||||
dogfood: false
|
||||
experimental-installer: true
|
||||
tarball_url: ${{ steps.installer-tarball-url.outputs.tarball-path }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
install_url: 'http://localhost:8126/install'
|
||||
install_options: "--tarball-url-prefix http://localhost:8126/"
|
||||
- run: sudo apt install fish zsh
|
||||
if: matrix.os == 'linux'
|
||||
- run: brew install fish
|
||||
@@ -204,20 +99,20 @@ jobs:
|
||||
check_secrets:
|
||||
permissions:
|
||||
contents: none
|
||||
name: Check presence of secrets
|
||||
name: Check Docker secrets present for installer tests
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
docker: ${{ steps.secret.outputs.docker }}
|
||||
steps:
|
||||
- name: Check for DockerHub secrets
|
||||
- name: Check for secrets
|
||||
id: secret
|
||||
env:
|
||||
_DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }}
|
||||
run: |
|
||||
echo "docker=${{ env._DOCKER_SECRETS != '' }}" >> $GITHUB_OUTPUT
|
||||
echo "::set-output name=docker::${{ env._DOCKER_SECRETS != '' }}"
|
||||
|
||||
docker_push_image:
|
||||
needs: [tests, check_secrets]
|
||||
needs: [tests, vm_tests, check_secrets]
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
@@ -227,16 +122,21 @@ jobs:
|
||||
github.ref_name == 'master'
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- 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: ./.github/actions/install-nix-action
|
||||
- uses: cachix/install-nix-action@v30
|
||||
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
|
||||
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
|
||||
@@ -271,48 +171,36 @@ jobs:
|
||||
docker tag nix:$NIX_VERSION $IMAGE_ID:master
|
||||
docker push $IMAGE_ID:master
|
||||
|
||||
vm_tests:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
- run: |
|
||||
nix build -L \
|
||||
.#hydraJobs.tests.functional_user \
|
||||
.#hydraJobs.tests.githubFlakes \
|
||||
.#hydraJobs.tests.nix-docker \
|
||||
.#hydraJobs.tests.tarballFlakes \
|
||||
;
|
||||
|
||||
flake_regressions:
|
||||
needs: tests
|
||||
needs: vm_tests
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout nix
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout flake-regressions
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: NixOS/flake-regressions
|
||||
path: flake-regressions
|
||||
- name: Checkout flake-regressions-data
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: NixOS/flake-regressions-data
|
||||
path: flake-regressions/tests
|
||||
- uses: ./.github/actions/install-nix-action
|
||||
with:
|
||||
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
|
||||
extra_nix_config:
|
||||
experimental-features = nix-command flakes
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
- 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
|
||||
|
||||
profile_build:
|
||||
needs: tests
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 60
|
||||
if: >-
|
||||
github.event_name == 'push' &&
|
||||
github.ref_name == 'master'
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: ./.github/actions/install-nix-action
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
|
||||
extra_nix_config: |
|
||||
experimental-features = flakes nix-command ca-derivations impure-derivations
|
||||
max-jobs = 1
|
||||
- run: |
|
||||
nix build -L --file ./ci/gha/profile-build buildTimeReport --out-link build-time-report.md
|
||||
cat build-time-report.md >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
2
.github/workflows/labels.yml
vendored
2
.github/workflows/labels.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
if: github.repository_owner == 'NixOS'
|
||||
steps:
|
||||
- uses: actions/labeler@v6
|
||||
- uses: actions/labeler@v5
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
sync-labels: false
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -14,7 +14,7 @@
|
||||
/tests/functional/lang/*.err
|
||||
/tests/functional/lang/*.ast
|
||||
|
||||
/outputs
|
||||
outputs/
|
||||
|
||||
*~
|
||||
|
||||
@@ -47,6 +47,3 @@ result-*
|
||||
.DS_Store
|
||||
|
||||
flake-regressions
|
||||
|
||||
# direnv
|
||||
.direnv/
|
||||
|
||||
108
.mergify.yml
Normal file
108
.mergify.yml
Normal file
@@ -0,0 +1,108 @@
|
||||
queue_rules:
|
||||
- name: default
|
||||
# all required tests need to go here
|
||||
merge_conditions:
|
||||
- check-success=tests on macos
|
||||
- check-success=tests on ubuntu
|
||||
- check-success=installer test on macos
|
||||
- check-success=installer test on ubuntu
|
||||
- check-success=vm_tests
|
||||
batch_size: 5
|
||||
|
||||
pull_request_rules:
|
||||
- name: merge using the merge queue
|
||||
conditions:
|
||||
- base~=master|.+-maintenance
|
||||
- label~=merge-queue|dependencies
|
||||
actions:
|
||||
queue: {}
|
||||
|
||||
# The rules below will first create backport pull requests and put those in a merge queue.
|
||||
|
||||
- name: backport patches to 2.18
|
||||
conditions:
|
||||
- label=backport 2.18-maintenance
|
||||
actions:
|
||||
backport:
|
||||
branches:
|
||||
- 2.18-maintenance
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
|
||||
- name: backport patches to 2.19
|
||||
conditions:
|
||||
- label=backport 2.19-maintenance
|
||||
actions:
|
||||
backport:
|
||||
branches:
|
||||
- 2.19-maintenance
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
|
||||
- name: backport patches to 2.20
|
||||
conditions:
|
||||
- label=backport 2.20-maintenance
|
||||
actions:
|
||||
backport:
|
||||
branches:
|
||||
- 2.20-maintenance
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
|
||||
- name: backport patches to 2.21
|
||||
conditions:
|
||||
- label=backport 2.21-maintenance
|
||||
actions:
|
||||
backport:
|
||||
branches:
|
||||
- 2.21-maintenance
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
|
||||
- name: backport patches to 2.22
|
||||
conditions:
|
||||
- label=backport 2.22-maintenance
|
||||
actions:
|
||||
backport:
|
||||
branches:
|
||||
- 2.22-maintenance
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
|
||||
- name: backport patches to 2.23
|
||||
conditions:
|
||||
- label=backport 2.23-maintenance
|
||||
actions:
|
||||
backport:
|
||||
branches:
|
||||
- 2.23-maintenance
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
|
||||
- name: backport patches to 2.24
|
||||
conditions:
|
||||
- label=backport 2.24-maintenance
|
||||
actions:
|
||||
backport:
|
||||
branches:
|
||||
- "2.24-maintenance"
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
|
||||
- name: backport patches to 2.25
|
||||
conditions:
|
||||
- label=backport 2.25-maintenance
|
||||
actions:
|
||||
backport:
|
||||
branches:
|
||||
- "2.25-maintenance"
|
||||
labels:
|
||||
- automatic backport
|
||||
- merge-queue
|
||||
@@ -89,13 +89,11 @@ Check out the [security policy](https://github.com/NixOS/nix/security/policy).
|
||||
|
||||
## Making changes to the Nix manual
|
||||
|
||||
The Nix reference manual is hosted on https://nix.dev/manual/nix.
|
||||
The Nix reference manual is hosted on https://nixos.org/manual/nix.
|
||||
The underlying source files are located in [`doc/manual/source`](./doc/manual/source).
|
||||
For small changes you can [use GitHub to edit these files](https://docs.github.com/en/repositories/working-with-files/managing-files/editing-files)
|
||||
For larger changes see the [Nix reference manual](https://nix.dev/manual/nix/development/development/contributing.html).
|
||||
|
||||
You're encouraged to add line breaks at semantic boundaries, per [sembr](https://sembr.org).
|
||||
|
||||
## Getting help
|
||||
|
||||
Whenever you're stuck or do not know how to proceed, you can always ask for help.
|
||||
|
||||
25
COPYING
25
COPYING
@@ -1,8 +1,8 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
@@ -112,7 +112,7 @@ modification follow. Pay close attention to the difference between a
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
@@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
@@ -432,7 +432,7 @@ decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
@@ -455,7 +455,7 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
@@ -484,7 +484,8 @@ convey the exclusion of warranty; and each file should have at least the
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, see <https://www.gnu.org/licenses/>.
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
@@ -495,7 +496,9 @@ necessary. Here is a sample; alter the names:
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Moe Ghoul>, 1 April 1990
|
||||
Moe Ghoul, President of Vice
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ Today, a world-wide developer community contributes to Nix and the ecosystem tha
|
||||
- [Nixpkgs](https://github.com/NixOS/nixpkgs) is [the largest, most up-to-date free software repository in the world](https://repology.org/repositories/graphs)
|
||||
- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos) is a Linux distribution that can be configured fully declaratively
|
||||
- [Discourse](https://discourse.nixos.org/)
|
||||
- Matrix: [#users:nixos.org](https://matrix.to/#/#users:nixos.org) for user support and [#nix-dev:nixos.org](https://matrix.to/#/#nix-dev:nixos.org) for development
|
||||
- [Matrix](https://matrix.to/#/#nix:nixos.org)
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
{
|
||||
nixFlake ? builtins.getFlake ("git+file://" + toString ../../..),
|
||||
system ? builtins.currentSystem,
|
||||
pkgs ? nixFlake.inputs.nixpkgs.legacyPackages.${system},
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
|
||||
nixComponentsInstrumented =
|
||||
(nixFlake.lib.makeComponents {
|
||||
inherit pkgs;
|
||||
getStdenv = p: p.clangStdenv;
|
||||
}).overrideScope
|
||||
(
|
||||
_: _: {
|
||||
mesonComponentOverrides = finalAttrs: prevAttrs: {
|
||||
outputs = (prevAttrs.outputs or [ "out" ]) ++ [ "buildprofile" ];
|
||||
nativeBuildInputs = [ pkgs.clangbuildanalyzer ] ++ prevAttrs.nativeBuildInputs or [ ];
|
||||
__impure = true;
|
||||
|
||||
env = {
|
||||
CFLAGS = "-ftime-trace";
|
||||
CXXFLAGS = "-ftime-trace";
|
||||
};
|
||||
|
||||
preBuild = ''
|
||||
ClangBuildAnalyzer --start $PWD
|
||||
'';
|
||||
|
||||
postBuild = ''
|
||||
ClangBuildAnalyzer --stop $PWD $buildprofile
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
componentsToProfile = {
|
||||
"nix-util" = { };
|
||||
"nix-util-c" = { };
|
||||
"nix-util-test-support" = { };
|
||||
"nix-util-tests" = { };
|
||||
"nix-store" = { };
|
||||
"nix-store-c" = { };
|
||||
"nix-store-test-support" = { };
|
||||
"nix-store-tests" = { };
|
||||
"nix-fetchers" = { };
|
||||
"nix-fetchers-c" = { };
|
||||
"nix-fetchers-tests" = { };
|
||||
"nix-expr" = { };
|
||||
"nix-expr-c" = { };
|
||||
"nix-expr-test-support" = { };
|
||||
"nix-expr-tests" = { };
|
||||
"nix-flake" = { };
|
||||
"nix-flake-c" = { };
|
||||
"nix-flake-tests" = { };
|
||||
"nix-main" = { };
|
||||
"nix-main-c" = { };
|
||||
"nix-cmd" = { };
|
||||
"nix-cli" = { };
|
||||
};
|
||||
|
||||
componentDerivationsToProfile = builtins.intersectAttrs componentsToProfile nixComponentsInstrumented;
|
||||
componentBuildProfiles = lib.mapAttrs (
|
||||
n: v: lib.getOutput "buildprofile" v
|
||||
) componentDerivationsToProfile;
|
||||
|
||||
buildTimeReport =
|
||||
pkgs.runCommand "build-time-report"
|
||||
{
|
||||
__impure = true;
|
||||
__structuredAttrs = true;
|
||||
nativeBuildInputs = [ pkgs.clangbuildanalyzer ];
|
||||
inherit componentBuildProfiles;
|
||||
}
|
||||
''
|
||||
{
|
||||
echo "# Build time performance profile for components:"
|
||||
echo
|
||||
echo "This reports the build profile collected via \`-ftime-trace\` for each component."
|
||||
echo
|
||||
} >> $out
|
||||
|
||||
for name in "''\${!componentBuildProfiles[@]}"; do
|
||||
{
|
||||
echo "<details><summary><strong>$name</strong></summary>"
|
||||
echo
|
||||
echo '````'
|
||||
ClangBuildAnalyzer --analyze "''\${componentBuildProfiles[$name]}"
|
||||
echo '````'
|
||||
echo
|
||||
echo "</details>"
|
||||
} >> $out
|
||||
done
|
||||
'';
|
||||
in
|
||||
|
||||
{
|
||||
inherit buildTimeReport;
|
||||
inherit componentDerivationsToProfile;
|
||||
}
|
||||
@@ -1,257 +0,0 @@
|
||||
{
|
||||
nixFlake ? builtins.getFlake ("git+file://" + toString ../../..),
|
||||
system ? builtins.currentSystem,
|
||||
pkgs ? nixFlake.inputs.nixpkgs.legacyPackages.${system},
|
||||
nixComponents ? (
|
||||
nixFlake.lib.makeComponents {
|
||||
inherit pkgs;
|
||||
inherit getStdenv;
|
||||
}
|
||||
),
|
||||
getStdenv ? p: p.stdenv,
|
||||
componentTestsPrefix ? "",
|
||||
withSanitizers ? false,
|
||||
withCoverage ? false,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
hydraJobs = nixFlake.hydraJobs;
|
||||
packages' = nixFlake.packages.${system};
|
||||
stdenv = (getStdenv pkgs);
|
||||
|
||||
collectCoverageLayer = finalAttrs: prevAttrs: {
|
||||
env =
|
||||
let
|
||||
# https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#the-code-coverage-workflow
|
||||
coverageFlags = [
|
||||
"-fprofile-instr-generate"
|
||||
"-fcoverage-mapping"
|
||||
];
|
||||
in
|
||||
{
|
||||
CFLAGS = toString coverageFlags;
|
||||
CXXFLAGS = toString coverageFlags;
|
||||
};
|
||||
|
||||
# Done in a pre-configure hook, because $NIX_BUILD_TOP needs to be substituted.
|
||||
preConfigure = prevAttrs.preConfigure or "" + ''
|
||||
mappingFlag=" -fcoverage-prefix-map=$NIX_BUILD_TOP/${finalAttrs.src.name}=${finalAttrs.src}"
|
||||
CFLAGS+="$mappingFlag"
|
||||
CXXFLAGS+="$mappingFlag"
|
||||
'';
|
||||
};
|
||||
|
||||
componentOverrides = (lib.optional withCoverage collectCoverageLayer);
|
||||
in
|
||||
|
||||
rec {
|
||||
nixComponentsInstrumented = nixComponents.overrideScope (
|
||||
final: prev: {
|
||||
withASan = withSanitizers;
|
||||
withUBSan = withSanitizers;
|
||||
|
||||
nix-store-tests = prev.nix-store-tests.override { withBenchmarks = true; };
|
||||
# Boehm is incompatible with ASAN.
|
||||
nix-expr = prev.nix-expr.override { enableGC = !withSanitizers; };
|
||||
|
||||
mesonComponentOverrides = lib.composeManyExtensions componentOverrides;
|
||||
# Unclear how to make Perl bindings work with a dynamically linked ASAN.
|
||||
nix-perl-bindings = if withSanitizers then null else prev.nix-perl-bindings;
|
||||
}
|
||||
);
|
||||
|
||||
# Import NixOS tests using the instrumented components
|
||||
nixosTests = import ../../../tests/nixos {
|
||||
inherit lib pkgs;
|
||||
nixComponents = nixComponentsInstrumented;
|
||||
nixpkgs = nixFlake.inputs.nixpkgs;
|
||||
inherit (nixFlake.inputs) nixpkgs-23-11;
|
||||
};
|
||||
|
||||
/**
|
||||
Top-level tests for the flake outputs, as they would be built by hydra.
|
||||
These tests generally can't be overridden to run with sanitizers.
|
||||
*/
|
||||
topLevel = {
|
||||
installerScriptForGHA = hydraJobs.installerScriptForGHA.${system};
|
||||
installTests = hydraJobs.installTests.${system};
|
||||
nixpkgsLibTests = hydraJobs.tests.nixpkgsLibTests.${system};
|
||||
rl-next = pkgs.buildPackages.runCommand "test-rl-next-release-notes" { } ''
|
||||
LANG=C.UTF-8 ${pkgs.changelog-d}/bin/changelog-d ${../../../doc/manual/rl-next} >$out
|
||||
'';
|
||||
repl-completion = pkgs.callPackage ../../../tests/repl-completion.nix { inherit (packages') nix; };
|
||||
|
||||
/**
|
||||
Checks for our packaging expressions.
|
||||
This shouldn't build anything significant; just check that things
|
||||
(including derivations) are _set up_ correctly.
|
||||
*/
|
||||
packaging-overriding =
|
||||
let
|
||||
nix = packages'.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;
|
||||
};
|
||||
};
|
||||
|
||||
disable =
|
||||
let
|
||||
inherit (pkgs.stdenv) hostPlatform;
|
||||
in
|
||||
args@{
|
||||
pkgName,
|
||||
testName,
|
||||
test,
|
||||
}:
|
||||
lib.any (b: b) [
|
||||
# FIXME: Nix manual is impure and does not produce all settings on darwin
|
||||
(hostPlatform.isDarwin && pkgName == "nix-manual" && testName == "linkcheck")
|
||||
];
|
||||
|
||||
componentTests =
|
||||
(lib.concatMapAttrs (
|
||||
pkgName: pkg:
|
||||
lib.concatMapAttrs (
|
||||
testName: test:
|
||||
lib.optionalAttrs (!disable { inherit pkgName testName test; }) {
|
||||
"${componentTestsPrefix}${pkgName}-${testName}" = test;
|
||||
}
|
||||
) (pkg.tests or { })
|
||||
) nixComponentsInstrumented)
|
||||
// lib.optionalAttrs (pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) {
|
||||
"${componentTestsPrefix}nix-functional-tests" = nixComponentsInstrumented.nix-functional-tests;
|
||||
"${componentTestsPrefix}nix-json-schema-checks" = nixComponentsInstrumented.nix-json-schema-checks;
|
||||
};
|
||||
|
||||
codeCoverage =
|
||||
let
|
||||
componentsTestsToProfile =
|
||||
(builtins.mapAttrs (n: v: nixComponentsInstrumented.${n}.tests.run) {
|
||||
"nix-util-tests" = { };
|
||||
"nix-store-tests" = { };
|
||||
"nix-fetchers-tests" = { };
|
||||
"nix-expr-tests" = { };
|
||||
"nix-flake-tests" = { };
|
||||
})
|
||||
// {
|
||||
inherit (nixComponentsInstrumented) nix-functional-tests;
|
||||
};
|
||||
|
||||
coverageProfileDrvs = lib.mapAttrs (
|
||||
n: v:
|
||||
v.overrideAttrs (
|
||||
finalAttrs: prevAttrs: {
|
||||
outputs = (prevAttrs.outputs or [ "out" ]) ++ [ "profraw" ];
|
||||
env = {
|
||||
LLVM_PROFILE_FILE = "${placeholder "profraw"}/%m";
|
||||
};
|
||||
}
|
||||
)
|
||||
) componentsTestsToProfile;
|
||||
|
||||
coverageProfiles = lib.mapAttrsToList (n: v: lib.getOutput "profraw" v) coverageProfileDrvs;
|
||||
|
||||
mergedProfdata =
|
||||
pkgs.runCommand "merged-profdata"
|
||||
{
|
||||
__structuredAttrs = true;
|
||||
nativeBuildInputs = [ pkgs.llvmPackages.libllvm ];
|
||||
inherit coverageProfiles;
|
||||
}
|
||||
''
|
||||
rawProfiles=()
|
||||
for dir in "''\${coverageProfiles[@]}"; do
|
||||
rawProfiles+=($dir/*)
|
||||
done
|
||||
llvm-profdata merge -sparse -output $out "''\${rawProfiles[@]}"
|
||||
'';
|
||||
|
||||
coverageReports =
|
||||
let
|
||||
nixComponentDrvs = lib.filter (lib.isDerivation) (lib.attrValues nixComponentsInstrumented);
|
||||
in
|
||||
pkgs.runCommand "code-coverage-report"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
pkgs.llvmPackages.libllvm
|
||||
pkgs.jq
|
||||
];
|
||||
__structuredAttrs = true;
|
||||
nixComponents = nixComponentDrvs;
|
||||
}
|
||||
''
|
||||
# ${toString (lib.map (v: v.src) nixComponentDrvs)}
|
||||
|
||||
binaryFiles=()
|
||||
for dir in "''\${nixComponents[@]}"; do
|
||||
readarray -t filesInDir < <(find "$dir" -type f -executable)
|
||||
binaryFiles+=("''\${filesInDir[@]}")
|
||||
done
|
||||
|
||||
arguments=$(concatStringsSep " -object " binaryFiles)
|
||||
llvm-cov show $arguments -instr-profile ${mergedProfdata} -output-dir $out -format=html
|
||||
|
||||
{
|
||||
echo "# Code coverage summary (generated via \`llvm-cov\`):"
|
||||
echo
|
||||
echo '```'
|
||||
llvm-cov report $arguments -instr-profile ${mergedProfdata} -format=text -use-color=false
|
||||
echo '```'
|
||||
echo
|
||||
} >> $out/index.txt
|
||||
|
||||
llvm-cov export $arguments -instr-profile ${mergedProfdata} -format=text > $out/coverage.json
|
||||
|
||||
mkdir -p $out/nix-support
|
||||
|
||||
coverageTotals=$(jq ".data[0].totals" $out/coverage.json)
|
||||
|
||||
# Mostly inline from pkgs/build-support/setup-hooks/make-coverage-analysis-report.sh [1],
|
||||
# which we can't use here, because we rely on LLVM's infra for source code coverage collection.
|
||||
# [1]: https://github.com/NixOS/nixpkgs/blob/67bb48c4c8e327417d6d5aa7e538244b209e852b/pkgs/build-support/setup-hooks/make-coverage-analysis-report.sh#L16
|
||||
declare -A metricsArray=(["lineCoverage"]="lines" ["functionCoverage"]="functions" ["branchCoverage"]="branches")
|
||||
|
||||
for metricName in "''\${!metricsArray[@]}"; do
|
||||
key="''\${metricsArray[$metricName]}"
|
||||
metric=$(echo "$coverageTotals" | jq ".$key.percent * 10 | round / 10")
|
||||
echo "$metricName $metric %" >> $out/nix-support/hydra-metrics
|
||||
done
|
||||
|
||||
echo "report coverage $out" >> $out/nix-support/hydra-build-products
|
||||
'';
|
||||
in
|
||||
assert withCoverage;
|
||||
assert stdenv.cc.isClang;
|
||||
{
|
||||
inherit coverageProfileDrvs mergedProfdata coverageReports;
|
||||
};
|
||||
|
||||
vmTests = {
|
||||
inherit (nixosTests) s3-binary-cache-store;
|
||||
}
|
||||
// lib.optionalAttrs (!withSanitizers && !withCoverage) {
|
||||
# evalNixpkgs uses non-instrumented components from hydraJobs, so only run it
|
||||
# when not testing with sanitizers to avoid rebuilding nix
|
||||
inherit (hydraJobs.tests) evalNixpkgs;
|
||||
# FIXME: CI times out when building vm tests instrumented
|
||||
inherit (nixosTests)
|
||||
functional_user
|
||||
githubFlakes
|
||||
nix-docker
|
||||
tarballFlakes
|
||||
;
|
||||
};
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
system=$(nix eval --raw --impure --expr builtins.currentSystem)
|
||||
|
||||
echo "::group::Running pre-commit checks"
|
||||
|
||||
if nix build ".#checks.$system.pre-commit" -L; then
|
||||
echo "::endgroup::"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "::error ::Changes do not pass pre-commit checks"
|
||||
|
||||
cat <<EOF
|
||||
The code isn't formatted or doesn't pass lints. You can run pre-commit locally with:
|
||||
|
||||
nix develop -c ./maintainers/format.sh
|
||||
EOF
|
||||
|
||||
echo "::endgroup::"
|
||||
|
||||
exit 1
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
nixFlake ? builtins.getFlake ("git+file://" + toString ../../..),
|
||||
system ? builtins.currentSystem,
|
||||
pkgs ? nixFlake.inputs.nixpkgs.legacyPackages.${system},
|
||||
stdenv ? "stdenv",
|
||||
componentTestsPrefix ? "",
|
||||
withInstrumentation ? false,
|
||||
}@args:
|
||||
import ./. (
|
||||
args
|
||||
// {
|
||||
getStdenv = p: p.${stdenv};
|
||||
withSanitizers = withInstrumentation;
|
||||
withCoverage = withInstrumentation;
|
||||
}
|
||||
)
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
|
||||
def transform_anchors_html:
|
||||
. | gsub($empty_anchor_regex; "<a id=\"" + .anchor + "\"></a>")
|
||||
. | gsub($empty_anchor_regex; "<a name=\"" + .anchor + "\"></a>")
|
||||
| gsub($anchor_regex; "<a href=\"#" + .anchor + "\" id=\"" + .anchor + "\">" + .text + "</a>");
|
||||
|
||||
|
||||
@@ -24,15 +24,8 @@ def map_contents_recursively(transformer):
|
||||
def process_command:
|
||||
.[0] as $context |
|
||||
.[1] as $body |
|
||||
# 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;
|
||||
$body + {
|
||||
sections: $body.sections | map(map_contents_recursively(if $context.renderer == "html" then transform_anchors_html else transform_anchors_strip end)),
|
||||
};
|
||||
|
||||
process_command
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[book]
|
||||
title = "Nix @version@ Reference Manual"
|
||||
title = "Nix Reference Manual"
|
||||
src = "source"
|
||||
|
||||
[output.html]
|
||||
@@ -7,7 +7,6 @@ additional-css = ["custom.css"]
|
||||
additional-js = ["redirects.js"]
|
||||
edit-url-template = "https://github.com/NixOS/nix/tree/master/doc/manual/{path}"
|
||||
git-repository-url = "https://github.com/NixOS/nix"
|
||||
mathjax-support = true
|
||||
|
||||
# Handles replacing @docroot@ with a path to ./source relative to that markdown file,
|
||||
# {{#include handlebars}}, and the @generated@ syntax used within these. it mostly
|
||||
@@ -24,3 +23,12 @@ 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"
|
||||
@@ -1,223 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Standalone markdown preprocessor for manpage generation.
|
||||
|
||||
Expands {{#include}} directives and handles @docroot@ references
|
||||
without requiring mdbook.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import argparse
|
||||
import re
|
||||
|
||||
|
||||
def expand_includes(
|
||||
content: str,
|
||||
current_file: Path,
|
||||
source_root: Path,
|
||||
generated_root: Path | None,
|
||||
visited: set[Path] | None = None,
|
||||
) -> str:
|
||||
"""
|
||||
Recursively expand {{#include path}} directives.
|
||||
|
||||
Args:
|
||||
content: Markdown content to process
|
||||
current_file: Path to the current file (for resolving relative includes)
|
||||
source_root: Root of the source directory
|
||||
generated_root: Root of generated files (for @generated@/ includes)
|
||||
visited: Set of already-visited files (for cycle detection)
|
||||
"""
|
||||
if visited is None:
|
||||
visited = set()
|
||||
|
||||
# Track current file to detect cycles
|
||||
visited.add(current_file.resolve())
|
||||
|
||||
lines = []
|
||||
include_pattern = re.compile(r'^\s*\{\{#include\s+(.+?)\}\}\s*$')
|
||||
|
||||
for line in content.splitlines(keepends=True):
|
||||
match = include_pattern.match(line)
|
||||
if not match:
|
||||
lines.append(line)
|
||||
continue
|
||||
|
||||
# Found an include directive
|
||||
include_path_str = match.group(1).strip()
|
||||
|
||||
# Resolve the include path
|
||||
if include_path_str.startswith("@generated@/"):
|
||||
# Generated file
|
||||
if generated_root is None:
|
||||
raise ValueError(
|
||||
f"Cannot resolve @generated@ path '{include_path_str}' "
|
||||
f"without --generated-root"
|
||||
)
|
||||
include_path = generated_root / include_path_str[12:]
|
||||
else:
|
||||
# Relative to current file
|
||||
include_path = (current_file.parent / include_path_str).resolve()
|
||||
|
||||
# Check for cycles
|
||||
if include_path.resolve() in visited:
|
||||
raise RuntimeError(
|
||||
f"Include cycle detected: {include_path} is already being processed"
|
||||
)
|
||||
|
||||
# Check that file exists
|
||||
if not include_path.exists():
|
||||
raise FileNotFoundError(
|
||||
f"Include file not found: {include_path_str}\n"
|
||||
f" Resolved to: {include_path}\n"
|
||||
f" From: {current_file}"
|
||||
)
|
||||
|
||||
# Recursively expand the included file
|
||||
included_content = include_path.read_text()
|
||||
expanded = expand_includes(
|
||||
included_content,
|
||||
include_path,
|
||||
source_root,
|
||||
generated_root,
|
||||
visited.copy(), # Copy visited set for this branch
|
||||
)
|
||||
lines.append(expanded)
|
||||
# Add newline if the included content doesn't end with one
|
||||
if not expanded.endswith('\n'):
|
||||
lines.append('\n')
|
||||
|
||||
return ''.join(lines)
|
||||
|
||||
|
||||
def resolve_docroot(content: str, current_file: Path, source_root: Path, docroot_url: str) -> str:
|
||||
"""
|
||||
Replace @docroot@ with nix.dev URL and convert .md to .html.
|
||||
|
||||
For manpages, absolute URLs are more useful than relative paths since
|
||||
manpages are viewed standalone. lowdown will display these as proper
|
||||
references in the manpage output.
|
||||
"""
|
||||
# Replace @docroot@ with the base URL
|
||||
content = content.replace("@docroot@", docroot_url)
|
||||
|
||||
# Convert .md extensions to .html for web links
|
||||
# Use lookahead to ensure that .md occurs before a fragment or a possible URL end.
|
||||
content = re.sub(
|
||||
r'(https://nix\.dev/[^)\s]*?)\.md(?=[#)\s]|$)',
|
||||
r'\1.html',
|
||||
content
|
||||
)
|
||||
|
||||
return content
|
||||
|
||||
|
||||
def resolve_at_escapes(content: str) -> str:
|
||||
"""Replace @_at_ with @"""
|
||||
return content.replace("@_at_", "@")
|
||||
|
||||
|
||||
def process_file(
|
||||
input_file: Path,
|
||||
source_root: Path,
|
||||
generated_root: Path | None,
|
||||
docroot_url: str,
|
||||
) -> str:
|
||||
"""Process a single markdown file."""
|
||||
content = input_file.read_text()
|
||||
|
||||
# Expand includes
|
||||
content = expand_includes(content, input_file, source_root, generated_root)
|
||||
|
||||
# Resolve @docroot@ references
|
||||
content = resolve_docroot(content, input_file, source_root, docroot_url)
|
||||
|
||||
# Resolve @_at_ escapes
|
||||
content = resolve_at_escapes(content)
|
||||
|
||||
return content
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Expand markdown includes for manpage generation",
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
epilog="""
|
||||
Examples:
|
||||
# Expand a manpage source file
|
||||
%(prog)s \\
|
||||
--source-root doc/manual/source \\
|
||||
--generated-root build/doc/manual/source \\
|
||||
doc/manual/source/command-ref/nix-store/query.md
|
||||
|
||||
# Pipe to lowdown for manpage generation
|
||||
%(prog)s -s doc/manual/source -g build/doc/manual/source \\
|
||||
doc/manual/source/command-ref/nix-env.md | \\
|
||||
lowdown -sT man -M section=1 -o nix-env.1
|
||||
""",
|
||||
)
|
||||
parser.add_argument(
|
||||
"input_file",
|
||||
type=Path,
|
||||
help="Input markdown file to process",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s", "--source-root",
|
||||
type=Path,
|
||||
required=True,
|
||||
help="Root directory of markdown sources",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-g", "--generated-root",
|
||||
type=Path,
|
||||
help="Root directory of generated files (for @generated@/ includes)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-o", "--output",
|
||||
type=Path,
|
||||
help="Output file (default: stdout)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-u", "--doc-url",
|
||||
type=str,
|
||||
default="https://nix.dev/manual/nix/latest",
|
||||
help="Base URL for documentation links (default: https://nix.dev/manual/nix/latest)",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Validate paths
|
||||
if not args.input_file.exists():
|
||||
print(f"Error: Input file not found: {args.input_file}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
if not args.source_root.is_dir():
|
||||
print(f"Error: Source root is not a directory: {args.source_root}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
if args.generated_root and not args.generated_root.is_dir():
|
||||
print(f"Error: Generated root is not a directory: {args.generated_root}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
try:
|
||||
# Process the file
|
||||
output = process_file(args.input_file, args.source_root, args.generated_root, args.doc_url)
|
||||
|
||||
# Write output
|
||||
if args.output:
|
||||
args.output.write_text(output)
|
||||
else:
|
||||
print(output, end='')
|
||||
|
||||
return 0
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error processing {args.input_file}: {e}", file=sys.stderr)
|
||||
import traceback
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -14,7 +14,7 @@ import sys
|
||||
# literally. since the rules for these aren't even the same for
|
||||
# all three we will just fail when we encounter any of them (if
|
||||
# asserts are off for some reason the depfile will likely point
|
||||
# to nonexistent paths, making everything phony and thus fine.)
|
||||
# to nonexistant paths, making everything phony and thus fine.)
|
||||
for path in glob.glob(sys.argv[1] + '/**', recursive=True):
|
||||
assert '\\' not in path
|
||||
assert ' ' not in path
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate redirects.js from template and JSON data."""
|
||||
|
||||
import sys
|
||||
|
||||
template_path, json_path, output_path = sys.argv[1:]
|
||||
|
||||
with open(json_path) as f:
|
||||
json_content = f.read().rstrip()
|
||||
|
||||
with open(template_path) as f:
|
||||
template = f.read()
|
||||
|
||||
with open(output_path, 'w') as f:
|
||||
f.write(template.replace('@REDIRECTS_JSON@', json_content))
|
||||
@@ -33,7 +33,6 @@ let
|
||||
{
|
||||
settings,
|
||||
doc,
|
||||
uri-schemes,
|
||||
experimentalFeature,
|
||||
}:
|
||||
let
|
||||
|
||||
@@ -24,9 +24,9 @@ let
|
||||
in
|
||||
concatStringsSep "\n" (map showEntry storesList);
|
||||
|
||||
"index.md" = replaceStrings [ "@store-types@" ] [ index ] (
|
||||
readFile ./source/store/types/index.md.in
|
||||
);
|
||||
"index.md" =
|
||||
replaceStrings [ "@store-types@" ] [ index ]
|
||||
(readFile ./source/store/types/index.md.in);
|
||||
|
||||
tableOfContents =
|
||||
let
|
||||
|
||||
@@ -1,71 +1,50 @@
|
||||
project(
|
||||
'nix-manual',
|
||||
project('nix-manual',
|
||||
version : files('.version'),
|
||||
meson_version : '>= 1.1',
|
||||
license : 'LGPL-2.1-or-later',
|
||||
)
|
||||
|
||||
# Compute documentation URL based on version and release type
|
||||
version = meson.project_version()
|
||||
official_release = get_option('official-release')
|
||||
|
||||
if official_release
|
||||
# For official releases, use versioned URL (dropping patch version)
|
||||
version_parts = version.split('.')
|
||||
major_minor = '@0@.@1@'.format(version_parts[0], version_parts[1])
|
||||
doc_url = 'https://nix.dev/manual/nix/@0@'.format(major_minor)
|
||||
else
|
||||
# For development builds, use /latest
|
||||
doc_url = 'https://nix.dev/manual/nix/latest'
|
||||
endif
|
||||
|
||||
nix = find_program('nix', native : true)
|
||||
|
||||
mdbook = find_program('mdbook', native : true)
|
||||
bash = find_program('bash', native : true)
|
||||
|
||||
# HTML manual dependencies (conditional)
|
||||
if get_option('html-manual')
|
||||
mdbook = find_program('mdbook', native : true)
|
||||
rsync = find_program('rsync', required : true, native : true)
|
||||
endif
|
||||
|
||||
pymod = import('python')
|
||||
python = pymod.find_installation('python3')
|
||||
|
||||
nix_env_for_docs = {
|
||||
'HOME' : '/dummy',
|
||||
'NIX_CONF_DIR' : '/dummy',
|
||||
'NIX_SSL_CERT_FILE' : '/dummy/no-ca-bundle.crt',
|
||||
'NIX_STATE_DIR' : '/dummy',
|
||||
'NIX_CONFIG' : 'cores = 0',
|
||||
'HOME': '/dummy',
|
||||
'NIX_CONF_DIR': '/dummy',
|
||||
'NIX_SSL_CERT_FILE': '/dummy/no-ca-bundle.crt',
|
||||
'NIX_STATE_DIR': '/dummy',
|
||||
'NIX_CONFIG': 'cores = 0',
|
||||
}
|
||||
|
||||
nix_for_docs = [ nix, '--experimental-features', 'nix-command' ]
|
||||
nix_for_docs = [nix, '--experimental-features', 'nix-command']
|
||||
nix_eval_for_docs_common = nix_for_docs + [
|
||||
'eval',
|
||||
'-I',
|
||||
'nix=' + meson.current_source_dir(),
|
||||
'-I', 'nix=' + meson.current_source_dir(),
|
||||
'--store', 'dummy://',
|
||||
'--impure',
|
||||
]
|
||||
nix_eval_for_docs = nix_eval_for_docs_common + '--raw'
|
||||
|
||||
conf_file_json = custom_target(
|
||||
command : nix_for_docs + [ 'config', 'show', '--json' ],
|
||||
command : nix_for_docs + ['config', 'show', '--json'],
|
||||
capture : true,
|
||||
output : 'conf-file.json',
|
||||
env : nix_env_for_docs,
|
||||
)
|
||||
|
||||
language_json = custom_target(
|
||||
command : [ nix, '__dump-language' ],
|
||||
command: [nix, '__dump-language'],
|
||||
output : 'language.json',
|
||||
capture : true,
|
||||
env : nix_env_for_docs,
|
||||
)
|
||||
|
||||
nix3_cli_json = custom_target(
|
||||
command : [ nix, '__dump-cli' ],
|
||||
command : [nix, '__dump-cli'],
|
||||
capture : true,
|
||||
output : 'nix.json',
|
||||
env : nix_env_for_docs,
|
||||
@@ -75,24 +54,6 @@ generate_manual_deps = files(
|
||||
'generate-deps.py',
|
||||
)
|
||||
|
||||
# Generate redirects.js from template and JSON data
|
||||
redirects_js = custom_target(
|
||||
'redirects.js',
|
||||
command : [
|
||||
python,
|
||||
'@INPUT0@',
|
||||
'@INPUT1@',
|
||||
'@INPUT2@',
|
||||
'@OUTPUT@',
|
||||
],
|
||||
input : [
|
||||
'generate-redirects.py',
|
||||
'redirects.js.in',
|
||||
'redirects.json',
|
||||
],
|
||||
output : 'redirects.js',
|
||||
)
|
||||
|
||||
# Generates types
|
||||
subdir('source/store')
|
||||
# Generates builtins.md and builtin-constants.md.
|
||||
@@ -106,82 +67,69 @@ subdir('source/release-notes')
|
||||
subdir('source')
|
||||
|
||||
# Hacky way to figure out if `nix` is an `ExternalProgram` or
|
||||
# `Executable`. Only the latter can occur in custom target input lists.
|
||||
# `Exectuable`. Only the latter can occur in custom target input lists.
|
||||
if nix.full_path().startswith(meson.build_root())
|
||||
nix_input = nix
|
||||
else
|
||||
nix_input = []
|
||||
endif
|
||||
|
||||
# HTML manual build (conditional)
|
||||
if get_option('html-manual')
|
||||
manual = custom_target(
|
||||
manual = custom_target(
|
||||
'manual',
|
||||
command : [
|
||||
bash,
|
||||
'-euo', 'pipefail',
|
||||
'-c',
|
||||
'''
|
||||
@0@ @INPUT0@ @CURRENT_SOURCE_DIR@ > @DEPFILE@
|
||||
@0@ @INPUT1@ summary @2@ < @CURRENT_SOURCE_DIR@/source/SUMMARY.md.in > @2@/source/SUMMARY.md
|
||||
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
|
||||
find @2@/manual -iname meson.build -delete
|
||||
'''.format(
|
||||
python.full_path(),
|
||||
mdbook.full_path(),
|
||||
meson.current_build_dir(),
|
||||
),
|
||||
],
|
||||
input : [
|
||||
generate_manual_deps,
|
||||
'substitute.py',
|
||||
'book.toml',
|
||||
'anchors.jq',
|
||||
'custom.css',
|
||||
nix3_cli_files,
|
||||
experimental_features_shortlist_md,
|
||||
experimental_feature_descriptions_md,
|
||||
types_dir,
|
||||
conf_file_md,
|
||||
builtins_md,
|
||||
rl_next_generated,
|
||||
summary_rl_next,
|
||||
nix_input,
|
||||
],
|
||||
output : [
|
||||
'manual',
|
||||
command : [
|
||||
bash,
|
||||
'-euo',
|
||||
'pipefail',
|
||||
'-c',
|
||||
'''
|
||||
@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 -L --exclude='*.drv' --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
|
||||
(cd @2@; RUST_LOG=warn @1@ build -d @2@ 3>&2 2>&1 1>&3) | { grep -Fv "because fragment resolution isn't implemented" || :; } 3>&2 2>&1 1>&3
|
||||
rm -rf @2@/manual
|
||||
mv @2@/html @2@/manual
|
||||
# Remove Mathjax 2.7, because we will actually use MathJax 3.x
|
||||
find @2@/manual | grep .html | xargs sed -i -e '/2.7.1.MathJax.js/d'
|
||||
find @2@/manual -iname meson.build -delete
|
||||
'''.format(
|
||||
python.full_path(),
|
||||
mdbook.full_path(),
|
||||
meson.current_build_dir(),
|
||||
meson.project_version(),
|
||||
rsync.full_path(),
|
||||
),
|
||||
],
|
||||
input : [
|
||||
generate_manual_deps,
|
||||
'substitute.py',
|
||||
'book.toml.in',
|
||||
'anchors.jq',
|
||||
'custom.css',
|
||||
redirects_js,
|
||||
nix3_cli_files,
|
||||
experimental_features_shortlist_md,
|
||||
experimental_feature_descriptions_md,
|
||||
types_dir,
|
||||
conf_file_md,
|
||||
builtins_md,
|
||||
rl_next_generated,
|
||||
summary_rl_next,
|
||||
json_schema_generated_files,
|
||||
nix_input,
|
||||
],
|
||||
output : [
|
||||
'manual',
|
||||
'markdown',
|
||||
],
|
||||
depfile : 'manual.d',
|
||||
build_by_default : true,
|
||||
env : {
|
||||
'RUST_LOG' : 'info',
|
||||
'MDBOOK_SUBSTITUTE_SEARCH' : meson.current_build_dir() / 'source',
|
||||
},
|
||||
)
|
||||
manual_html = manual[0]
|
||||
manual_md = manual[1]
|
||||
'markdown',
|
||||
],
|
||||
depfile : 'manual.d',
|
||||
env : {
|
||||
'RUST_LOG': 'info',
|
||||
'MDBOOK_SUBSTITUTE_SEARCH': meson.current_build_dir() / 'source',
|
||||
},
|
||||
)
|
||||
manual_html = manual[0]
|
||||
manual_md = manual[1]
|
||||
|
||||
install_subdir(
|
||||
manual_html.full_path(),
|
||||
install_dir : get_option('datadir') / 'doc/nix',
|
||||
)
|
||||
endif
|
||||
install_subdir(
|
||||
manual_html.full_path(),
|
||||
install_dir : get_option('datadir') / 'doc/nix',
|
||||
)
|
||||
|
||||
nix_nested_manpages = [
|
||||
[
|
||||
'nix-env',
|
||||
[ 'nix-env',
|
||||
[
|
||||
'delete-generations',
|
||||
'install',
|
||||
@@ -196,8 +144,7 @@ nix_nested_manpages = [
|
||||
'upgrade',
|
||||
],
|
||||
],
|
||||
[
|
||||
'nix-store',
|
||||
[ 'nix-store',
|
||||
[
|
||||
'add-fixed',
|
||||
'add',
|
||||
@@ -223,7 +170,6 @@ nix_nested_manpages = [
|
||||
],
|
||||
]
|
||||
|
||||
# Manpage generation (standalone, no mdbook dependency)
|
||||
foreach command : nix_nested_manpages
|
||||
foreach page : command[1]
|
||||
title = command[0] + ' --' + page
|
||||
@@ -231,19 +177,15 @@ foreach command : nix_nested_manpages
|
||||
custom_target(
|
||||
command : [
|
||||
bash,
|
||||
'@INPUT0@',
|
||||
files('./render-manpage.sh'),
|
||||
'--out-no-smarty',
|
||||
title,
|
||||
section,
|
||||
meson.current_source_dir() / 'source',
|
||||
meson.current_build_dir() / 'source',
|
||||
doc_url,
|
||||
meson.current_source_dir() / 'source/command-ref' / command[0] / (page + '.md'),
|
||||
'@INPUT0@/command-ref' / command[0] / (page + '.md'),
|
||||
'@OUTPUT0@',
|
||||
],
|
||||
input : [
|
||||
files('./render-manpage.sh'),
|
||||
files('./expand-includes.py'),
|
||||
manual_md,
|
||||
nix_input,
|
||||
],
|
||||
output : command[0] + '-' + page + '.1',
|
||||
@@ -302,11 +244,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',
|
||||
@@ -337,6 +279,7 @@ nix3_manpages = [
|
||||
'nix3-store',
|
||||
'nix3-store-optimise',
|
||||
'nix3-store-path-from-hash-part',
|
||||
'nix3-store-ping',
|
||||
'nix3-store-prefetch-file',
|
||||
'nix3-store-repair',
|
||||
'nix3-store-sign',
|
||||
@@ -352,21 +295,14 @@ foreach page : nix3_manpages
|
||||
command : [
|
||||
bash,
|
||||
'@INPUT0@',
|
||||
# Note: no --out-no-smarty flag (original behavior)
|
||||
page,
|
||||
section,
|
||||
meson.current_source_dir() / 'source',
|
||||
meson.current_build_dir() / 'source',
|
||||
doc_url,
|
||||
meson.current_build_dir() / 'source/command-ref/new-cli/@0@.md'.format(
|
||||
page,
|
||||
),
|
||||
'@INPUT1@/command-ref/new-cli/@0@.md'.format(page),
|
||||
'@OUTPUT@',
|
||||
],
|
||||
input : [
|
||||
files('./render-manpage.sh'),
|
||||
files('./expand-includes.py'),
|
||||
nix3_cli_files,
|
||||
manual_md,
|
||||
nix_input,
|
||||
],
|
||||
output : page + '.1',
|
||||
@@ -386,12 +322,7 @@ nix_manpages = [
|
||||
[ 'nix-channel', 1 ],
|
||||
[ 'nix-hash', 1 ],
|
||||
[ 'nix-copy-closure', 1 ],
|
||||
[
|
||||
'nix.conf',
|
||||
5,
|
||||
conf_file_md.full_path(),
|
||||
[ conf_file_md, experimental_features_shortlist_md ],
|
||||
],
|
||||
[ 'nix.conf', 5, conf_file_md.full_path() ],
|
||||
[ 'nix-daemon', 8 ],
|
||||
[ 'nix-profiles', 5, 'files/profiles.md' ],
|
||||
]
|
||||
@@ -403,24 +334,19 @@ foreach entry : nix_manpages
|
||||
# Therefore we use an optional third element of this array to override the name pattern
|
||||
md_file = entry.get(2, title + '.md')
|
||||
section = entry[1].to_string()
|
||||
input_file = meson.current_source_dir() / 'source/command-ref' / md_file
|
||||
|
||||
md_file_resolved = join_paths('@INPUT1@/command-ref/', md_file)
|
||||
custom_target(
|
||||
command : [
|
||||
bash,
|
||||
'@INPUT0@',
|
||||
# Note: no --out-no-smarty flag (original behavior)
|
||||
title,
|
||||
section,
|
||||
meson.current_source_dir() / 'source',
|
||||
meson.current_build_dir() / 'source',
|
||||
doc_url,
|
||||
input_file,
|
||||
md_file_resolved,
|
||||
'@OUTPUT@',
|
||||
],
|
||||
input : [
|
||||
files('./render-manpage.sh'),
|
||||
files('./expand-includes.py'),
|
||||
manual_md,
|
||||
entry.get(3, []),
|
||||
nix_input,
|
||||
],
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
option(
|
||||
'official-release',
|
||||
type : 'boolean',
|
||||
value : true,
|
||||
description : 'Whether this is an official release build (affects documentation URLs)',
|
||||
)
|
||||
|
||||
option(
|
||||
'html-manual',
|
||||
type : 'boolean',
|
||||
value : true,
|
||||
description : 'Whether to build the HTML manual (requires mdbook)',
|
||||
)
|
||||
@@ -1,32 +1,20 @@
|
||||
{
|
||||
lib,
|
||||
callPackage,
|
||||
mkMesonDerivation,
|
||||
runCommand,
|
||||
|
||||
meson,
|
||||
ninja,
|
||||
lowdown-unsandboxed,
|
||||
mdbook,
|
||||
mdbook-linkcheck,
|
||||
jq,
|
||||
python3,
|
||||
rsync,
|
||||
nix-cli,
|
||||
changelog-d,
|
||||
json-schema-for-humans,
|
||||
officialRelease,
|
||||
|
||||
# Configuration Options
|
||||
|
||||
version,
|
||||
/**
|
||||
Whether to build the HTML manual.
|
||||
When false, only manpages are built, avoiding the mdbook dependency.
|
||||
*/
|
||||
buildHtmlManual ? true,
|
||||
|
||||
# `tests` attribute
|
||||
testers,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -42,18 +30,6 @@ mkMesonDerivation (finalAttrs: {
|
||||
fileset.difference
|
||||
(fileset.unions [
|
||||
../../.version
|
||||
# For example JSON
|
||||
../../src/libutil-tests/data/memory-source-accessor
|
||||
../../src/libutil-tests/data/hash
|
||||
../../src/libstore-tests/data/content-address
|
||||
../../src/libstore-tests/data/store-path
|
||||
../../src/libstore-tests/data/realisation
|
||||
../../src/libstore-tests/data/derivation
|
||||
../../src/libstore-tests/data/derived-path
|
||||
../../src/libstore-tests/data/path-info
|
||||
../../src/libstore-tests/data/nar-info
|
||||
../../src/libstore-tests/data/build-result
|
||||
../../src/libstore-tests/data/dummy-store
|
||||
# Too many different types of files to filter for now
|
||||
../../doc/manual
|
||||
./.
|
||||
@@ -62,42 +38,25 @@ mkMesonDerivation (finalAttrs: {
|
||||
../../doc/manual/package.nix;
|
||||
|
||||
# TODO the man pages should probably be separate
|
||||
outputs =
|
||||
if buildHtmlManual then
|
||||
[
|
||||
"out"
|
||||
"man"
|
||||
]
|
||||
else
|
||||
[ "out" ]; # Only one output when HTML manual is disabled; use "out" for manpages
|
||||
|
||||
# When HTML manual is disabled, install manpages to "out" instead of "man"
|
||||
mesonFlags = [
|
||||
(lib.mesonBool "official-release" officialRelease)
|
||||
(lib.mesonBool "html-manual" buildHtmlManual)
|
||||
]
|
||||
++ lib.optionals (!buildHtmlManual) [
|
||||
"--mandir=${placeholder "out"}/share/man"
|
||||
outputs = [
|
||||
"out"
|
||||
"man"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
nix-cli
|
||||
# Hack for sake of the dev shell
|
||||
passthru.externalNativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
(lib.getBin lowdown-unsandboxed)
|
||||
mdbook
|
||||
mdbook-linkcheck
|
||||
jq
|
||||
python3
|
||||
]
|
||||
++ lib.optionals buildHtmlManual [
|
||||
mdbook
|
||||
rsync
|
||||
json-schema-for-humans
|
||||
]
|
||||
++ lib.optionals (!officialRelease && buildHtmlManual) [
|
||||
# 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
|
||||
];
|
||||
|
||||
preConfigure = ''
|
||||
@@ -105,49 +64,11 @@ mkMesonDerivation (finalAttrs: {
|
||||
echo ${finalAttrs.version} > ./.version
|
||||
'';
|
||||
|
||||
postInstall = lib.optionalString buildHtmlManual ''
|
||||
postInstall = ''
|
||||
mkdir -p ''$out/nix-support
|
||||
echo "doc manual ''$out/share/doc/nix/manual" >> ''$out/nix-support/hydra-build-products
|
||||
'';
|
||||
|
||||
passthru = lib.optionalAttrs buildHtmlManual {
|
||||
/**
|
||||
The root of the HTML manual.
|
||||
E.g. "${nix-manual.site}/index.html" exists.
|
||||
*/
|
||||
|
||||
site = finalAttrs.finalPackage + "/share/doc/nix/manual";
|
||||
|
||||
tests =
|
||||
let
|
||||
redirect-targets = callPackage ./redirect-targets-html.nix { };
|
||||
in
|
||||
{
|
||||
# https://nixos.org/manual/nixpkgs/stable/index.html#tester-lycheeLinkCheck
|
||||
linkcheck = testers.lycheeLinkCheck {
|
||||
site =
|
||||
let
|
||||
plain = finalAttrs.finalPackage.site;
|
||||
in
|
||||
runCommand "nix-manual-with-redirect-targets" { } ''
|
||||
cp -r ${plain} $out
|
||||
chmod -R u+w $out
|
||||
cp ${redirect-targets}/redirect-targets.html $out/redirect-targets.html
|
||||
'';
|
||||
extraConfig = {
|
||||
exclude = [
|
||||
# Exclude auto-generated JSON schema documentation which has
|
||||
# auto-generated fragment IDs that don't match the link references
|
||||
".*/protocols/json/.*\\.html"
|
||||
# Exclude undocumented builtins
|
||||
".*/language/builtins\\.html#builtins-addErrorContext"
|
||||
".*/language/builtins\\.html#builtins-appendContext"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
# Generates redirect-targets.html containing all redirect targets for link checking.
|
||||
# Used by: doc/manual/package.nix (passthru.tests.linkcheck)
|
||||
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
jq,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "redirect-targets-html";
|
||||
|
||||
src = lib.fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = ./redirects.json;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ jq ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
|
||||
{
|
||||
echo '<!DOCTYPE html>'
|
||||
echo '<html><head><title>Nix Manual Redirect Targets</title></head><body>'
|
||||
echo '<h1>Redirect Targets to Check</h1>'
|
||||
echo '<p>This document contains all redirect targets from the Nix manual.</p>'
|
||||
|
||||
echo '<h2>Client-side redirects (from redirects.json)</h2>'
|
||||
echo '<ul>'
|
||||
|
||||
# Extract all redirects with their source pages to properly resolve relative paths
|
||||
jq -r 'to_entries[] | .key as $page | .value | to_entries[] | "\($page)\t\(.value)"' \
|
||||
redirects.json | while IFS=$'\t' read -r page target; do
|
||||
|
||||
page_dir=$(dirname "$page")
|
||||
|
||||
# Handle fragment-only targets (e.g., #primitives)
|
||||
if [[ "$target" == \#* ]]; then
|
||||
# Fragment is on the same page
|
||||
resolved="$page$target"
|
||||
echo "<li><a href=\"$resolved\">$resolved</a> (fragment on $page)</li>"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Resolve relative path based on the source page location
|
||||
resolved="$page_dir/$target"
|
||||
|
||||
echo "<li><a href=\"$resolved\">$resolved</a> (from $page)</li>"
|
||||
done
|
||||
|
||||
echo '</ul>'
|
||||
echo '</body></html>'
|
||||
} > $out/redirect-targets.html
|
||||
|
||||
echo "Generated redirect targets document with $(grep -c '<li>' $out/redirect-targets.html) links"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "HTML document listing all Nix manual redirect targets for link checking";
|
||||
};
|
||||
}
|
||||
455
doc/manual/redirects.js
Normal file
455
doc/manual/redirects.js
Normal file
@@ -0,0 +1,455 @@
|
||||
// redirect rules for URL fragments (client-side) to prevent link rot.
|
||||
// this must be done on the client side, as web servers do not see the fragment part of the URL.
|
||||
// it will only work with JavaScript enabled in the browser, but this is the best we can do here.
|
||||
// see source/_redirects for path redirects (server-side)
|
||||
|
||||
// redirects are declared as follows:
|
||||
// each entry has as its key a path matching the requested URL path, relative to the mdBook document root.
|
||||
//
|
||||
// IMPORTANT: it must specify the full path with file name and suffix
|
||||
//
|
||||
// each entry is itself a set of key-value pairs, where
|
||||
// - keys are anchors on the matched path.
|
||||
// - values are redirection targets relative to the current path.
|
||||
|
||||
const redirects = {
|
||||
"index.html": {
|
||||
"part-advanced-topics": "advanced-topics/index.html",
|
||||
"chap-tuning-cores-and-jobs": "advanced-topics/cores-vs-jobs.html",
|
||||
"chap-diff-hook": "advanced-topics/diff-hook.html",
|
||||
"check-dirs-are-unregistered": "advanced-topics/diff-hook.html#check-dirs-are-unregistered",
|
||||
"chap-distributed-builds": "command-ref/conf-file.html#conf-builders",
|
||||
"chap-post-build-hook": "advanced-topics/post-build-hook.html",
|
||||
"chap-post-build-hook-caveats": "advanced-topics/post-build-hook.html#implementation-caveats",
|
||||
"chap-writing-nix-expressions": "language/index.html",
|
||||
"part-command-ref": "command-ref/index.html",
|
||||
"conf-allow-import-from-derivation": "command-ref/conf-file.html#conf-allow-import-from-derivation",
|
||||
"conf-allow-new-privileges": "command-ref/conf-file.html#conf-allow-new-privileges",
|
||||
"conf-allowed-uris": "command-ref/conf-file.html#conf-allowed-uris",
|
||||
"conf-allowed-users": "command-ref/conf-file.html#conf-allowed-users",
|
||||
"conf-auto-optimise-store": "command-ref/conf-file.html#conf-auto-optimise-store",
|
||||
"conf-binary-cache-public-keys": "command-ref/conf-file.html#conf-binary-cache-public-keys",
|
||||
"conf-binary-caches": "command-ref/conf-file.html#conf-binary-caches",
|
||||
"conf-build-compress-log": "command-ref/conf-file.html#conf-build-compress-log",
|
||||
"conf-build-cores": "command-ref/conf-file.html#conf-build-cores",
|
||||
"conf-build-extra-chroot-dirs": "command-ref/conf-file.html#conf-build-extra-chroot-dirs",
|
||||
"conf-build-extra-sandbox-paths": "command-ref/conf-file.html#conf-build-extra-sandbox-paths",
|
||||
"conf-build-fallback": "command-ref/conf-file.html#conf-build-fallback",
|
||||
"conf-build-max-jobs": "command-ref/conf-file.html#conf-build-max-jobs",
|
||||
"conf-build-max-log-size": "command-ref/conf-file.html#conf-build-max-log-size",
|
||||
"conf-build-max-silent-time": "command-ref/conf-file.html#conf-build-max-silent-time",
|
||||
"conf-build-timeout": "command-ref/conf-file.html#conf-build-timeout",
|
||||
"conf-build-use-chroot": "command-ref/conf-file.html#conf-build-use-chroot",
|
||||
"conf-build-use-sandbox": "command-ref/conf-file.html#conf-build-use-sandbox",
|
||||
"conf-build-use-substitutes": "command-ref/conf-file.html#conf-build-use-substitutes",
|
||||
"conf-build-users-group": "command-ref/conf-file.html#conf-build-users-group",
|
||||
"conf-builders": "command-ref/conf-file.html#conf-builders",
|
||||
"conf-builders-use-substitutes": "command-ref/conf-file.html#conf-builders-use-substitutes",
|
||||
"conf-compress-build-log": "command-ref/conf-file.html#conf-compress-build-log",
|
||||
"conf-connect-timeout": "command-ref/conf-file.html#conf-connect-timeout",
|
||||
"conf-cores": "command-ref/conf-file.html#conf-cores",
|
||||
"conf-diff-hook": "command-ref/conf-file.html#conf-diff-hook",
|
||||
"conf-env-keep-derivations": "command-ref/conf-file.html#conf-env-keep-derivations",
|
||||
"conf-extra-binary-caches": "command-ref/conf-file.html#conf-extra-binary-caches",
|
||||
"conf-extra-platforms": "command-ref/conf-file.html#conf-extra-platforms",
|
||||
"conf-extra-sandbox-paths": "command-ref/conf-file.html#conf-extra-sandbox-paths",
|
||||
"conf-extra-substituters": "command-ref/conf-file.html#conf-extra-substituters",
|
||||
"conf-fallback": "command-ref/conf-file.html#conf-fallback",
|
||||
"conf-fsync-metadata": "command-ref/conf-file.html#conf-fsync-metadata",
|
||||
"conf-gc-keep-derivations": "command-ref/conf-file.html#conf-gc-keep-derivations",
|
||||
"conf-gc-keep-outputs": "command-ref/conf-file.html#conf-gc-keep-outputs",
|
||||
"conf-hashed-mirrors": "command-ref/conf-file.html#conf-hashed-mirrors",
|
||||
"conf-http-connections": "command-ref/conf-file.html#conf-http-connections",
|
||||
"conf-keep-build-log": "command-ref/conf-file.html#conf-keep-build-log",
|
||||
"conf-keep-derivations": "command-ref/conf-file.html#conf-keep-derivations",
|
||||
"conf-keep-env-derivations": "command-ref/conf-file.html#conf-keep-env-derivations",
|
||||
"conf-keep-outputs": "command-ref/conf-file.html#conf-keep-outputs",
|
||||
"conf-max-build-log-size": "command-ref/conf-file.html#conf-max-build-log-size",
|
||||
"conf-max-free": "command-ref/conf-file.html#conf-max-free",
|
||||
"conf-max-jobs": "command-ref/conf-file.html#conf-max-jobs",
|
||||
"conf-max-silent-time": "command-ref/conf-file.html#conf-max-silent-time",
|
||||
"conf-min-free": "command-ref/conf-file.html#conf-min-free",
|
||||
"conf-narinfo-cache-negative-ttl": "command-ref/conf-file.html#conf-narinfo-cache-negative-ttl",
|
||||
"conf-narinfo-cache-positive-ttl": "command-ref/conf-file.html#conf-narinfo-cache-positive-ttl",
|
||||
"conf-netrc-file": "command-ref/conf-file.html#conf-netrc-file",
|
||||
"conf-plugin-files": "command-ref/conf-file.html#conf-plugin-files",
|
||||
"conf-post-build-hook": "command-ref/conf-file.html#conf-post-build-hook",
|
||||
"conf-pre-build-hook": "command-ref/conf-file.html#conf-pre-build-hook",
|
||||
"conf-require-sigs": "command-ref/conf-file.html#conf-require-sigs",
|
||||
"conf-restrict-eval": "command-ref/conf-file.html#conf-restrict-eval",
|
||||
"conf-run-diff-hook": "command-ref/conf-file.html#conf-run-diff-hook",
|
||||
"conf-sandbox": "command-ref/conf-file.html#conf-sandbox",
|
||||
"conf-sandbox-dev-shm-size": "command-ref/conf-file.html#conf-sandbox-dev-shm-size",
|
||||
"conf-sandbox-paths": "command-ref/conf-file.html#conf-sandbox-paths",
|
||||
"conf-secret-key-files": "command-ref/conf-file.html#conf-secret-key-files",
|
||||
"conf-show-trace": "command-ref/conf-file.html#conf-show-trace",
|
||||
"conf-stalled-download-timeout": "command-ref/conf-file.html#conf-stalled-download-timeout",
|
||||
"conf-substitute": "command-ref/conf-file.html#conf-substitute",
|
||||
"conf-substituters": "command-ref/conf-file.html#conf-substituters",
|
||||
"conf-system": "command-ref/conf-file.html#conf-system",
|
||||
"conf-system-features": "command-ref/conf-file.html#conf-system-features",
|
||||
"conf-tarball-ttl": "command-ref/conf-file.html#conf-tarball-ttl",
|
||||
"conf-timeout": "command-ref/conf-file.html#conf-timeout",
|
||||
"conf-trace-function-calls": "command-ref/conf-file.html#conf-trace-function-calls",
|
||||
"conf-trusted-binary-caches": "command-ref/conf-file.html#conf-trusted-binary-caches",
|
||||
"conf-trusted-public-keys": "command-ref/conf-file.html#conf-trusted-public-keys",
|
||||
"conf-trusted-substituters": "command-ref/conf-file.html#conf-trusted-substituters",
|
||||
"conf-trusted-users": "command-ref/conf-file.html#conf-trusted-users",
|
||||
"extra-sandbox-paths": "command-ref/conf-file.html#extra-sandbox-paths",
|
||||
"sec-conf-file": "command-ref/conf-file.html",
|
||||
"env-NIX_PATH": "command-ref/env-common.html#env-NIX_PATH",
|
||||
"env-common": "command-ref/env-common.html",
|
||||
"envar-remote": "command-ref/env-common.html#env-NIX_REMOTE",
|
||||
"sec-common-env": "command-ref/env-common.html",
|
||||
"ch-files": "command-ref/files.html",
|
||||
"ch-main-commands": "command-ref/main-commands.html",
|
||||
"opt-out-link": "command-ref/nix-build.html#opt-out-link",
|
||||
"sec-nix-build": "command-ref/nix-build.html",
|
||||
"sec-nix-channel": "command-ref/nix-channel.html",
|
||||
"sec-nix-collect-garbage": "command-ref/nix-collect-garbage.html",
|
||||
"sec-nix-copy-closure": "command-ref/nix-copy-closure.html",
|
||||
"sec-nix-daemon": "command-ref/nix-daemon.html",
|
||||
"refsec-nix-env-install-examples": "command-ref/nix-env.html#examples",
|
||||
"rsec-nix-env-install": "command-ref/nix-env.html#operation---install",
|
||||
"rsec-nix-env-set": "command-ref/nix-env.html#operation---set",
|
||||
"rsec-nix-env-set-flag": "command-ref/nix-env.html#operation---set-flag",
|
||||
"rsec-nix-env-upgrade": "command-ref/nix-env.html#operation---upgrade",
|
||||
"sec-nix-env": "command-ref/nix-env.html",
|
||||
"ssec-version-comparisons": "command-ref/nix-env.html#versions",
|
||||
"sec-nix-hash": "command-ref/nix-hash.html",
|
||||
"sec-nix-instantiate": "command-ref/nix-instantiate.html",
|
||||
"sec-nix-prefetch-url": "command-ref/nix-prefetch-url.html",
|
||||
"sec-nix-shell": "command-ref/nix-shell.html",
|
||||
"ssec-nix-shell-shebang": "command-ref/nix-shell.html#use-as-a--interpreter",
|
||||
"nixref-queries": "command-ref/nix-store.html#queries",
|
||||
"opt-add-root": "command-ref/nix-store.html#opt-add-root",
|
||||
"refsec-nix-store-dump": "command-ref/nix-store.html#operation---dump",
|
||||
"refsec-nix-store-export": "command-ref/nix-store.html#operation---export",
|
||||
"refsec-nix-store-import": "command-ref/nix-store.html#operation---import",
|
||||
"refsec-nix-store-query": "command-ref/nix-store.html#operation---query",
|
||||
"refsec-nix-store-verify": "command-ref/nix-store.html#operation---verify",
|
||||
"rsec-nix-store-gc": "command-ref/nix-store.html#operation---gc",
|
||||
"rsec-nix-store-generate-binary-cache-key": "command-ref/nix-store.html#operation---generate-binary-cache-key",
|
||||
"rsec-nix-store-realise": "command-ref/nix-store.html#operation---realise",
|
||||
"rsec-nix-store-serve": "command-ref/nix-store.html#operation---serve",
|
||||
"sec-nix-store": "command-ref/nix-store.html",
|
||||
"opt-I": "command-ref/opt-common.html#opt-I",
|
||||
"opt-attr": "command-ref/opt-common.html#opt-attr",
|
||||
"opt-common": "command-ref/opt-common.html",
|
||||
"opt-cores": "command-ref/opt-common.html#opt-cores",
|
||||
"opt-log-format": "command-ref/opt-common.html#opt-log-format",
|
||||
"opt-max-jobs": "command-ref/opt-common.html#opt-max-jobs",
|
||||
"opt-max-silent-time": "command-ref/opt-common.html#opt-max-silent-time",
|
||||
"opt-timeout": "command-ref/opt-common.html#opt-timeout",
|
||||
"sec-common-options": "command-ref/opt-common.html",
|
||||
"ch-utilities": "command-ref/utilities.html",
|
||||
"chap-hacking": "development/building.html",
|
||||
"adv-attr-allowSubstitutes": "language/advanced-attributes.html#adv-attr-allowSubstitutes",
|
||||
"adv-attr-allowedReferences": "language/advanced-attributes.html#adv-attr-allowedReferences",
|
||||
"adv-attr-allowedRequisites": "language/advanced-attributes.html#adv-attr-allowedRequisites",
|
||||
"adv-attr-disallowedReferences": "language/advanced-attributes.html#adv-attr-disallowedReferences",
|
||||
"adv-attr-disallowedRequisites": "language/advanced-attributes.html#adv-attr-disallowedRequisites",
|
||||
"adv-attr-exportReferencesGraph": "language/advanced-attributes.html#adv-attr-exportReferencesGraph",
|
||||
"adv-attr-impureEnvVars": "language/advanced-attributes.html#adv-attr-impureEnvVars",
|
||||
"adv-attr-outputHash": "language/advanced-attributes.html#adv-attr-outputHash",
|
||||
"adv-attr-outputHashAlgo": "language/advanced-attributes.html#adv-attr-outputHashAlgo",
|
||||
"adv-attr-outputHashMode": "language/advanced-attributes.html#adv-attr-outputHashMode",
|
||||
"adv-attr-passAsFile": "language/advanced-attributes.html#adv-attr-passAsFile",
|
||||
"adv-attr-preferLocalBuild": "language/advanced-attributes.html#adv-attr-preferLocalBuild",
|
||||
"fixed-output-drvs": "language/advanced-attributes.html#adv-attr-outputHash",
|
||||
"sec-advanced-attributes": "language/advanced-attributes.html",
|
||||
"builtin-abort": "language/builtins.html#builtins-abort",
|
||||
"builtin-add": "language/builtins.html#builtins-add",
|
||||
"builtin-all": "language/builtins.html#builtins-all",
|
||||
"builtin-any": "language/builtins.html#builtins-any",
|
||||
"builtin-attrNames": "language/builtins.html#builtins-attrNames",
|
||||
"builtin-attrValues": "language/builtins.html#builtins-attrValues",
|
||||
"builtin-baseNameOf": "language/builtins.html#builtins-baseNameOf",
|
||||
"builtin-bitAnd": "language/builtins.html#builtins-bitAnd",
|
||||
"builtin-bitOr": "language/builtins.html#builtins-bitOr",
|
||||
"builtin-bitXor": "language/builtins.html#builtins-bitXor",
|
||||
"builtin-builtins": "language/builtins.html#builtins-builtins",
|
||||
"builtin-compareVersions": "language/builtins.html#builtins-compareVersions",
|
||||
"builtin-concatLists": "language/builtins.html#builtins-concatLists",
|
||||
"builtin-concatStringsSep": "language/builtins.html#builtins-concatStringsSep",
|
||||
"builtin-currentSystem": "language/builtins.html#builtins-currentSystem",
|
||||
"builtin-deepSeq": "language/builtins.html#builtins-deepSeq",
|
||||
"builtin-derivation": "language/builtins.html#builtins-derivation",
|
||||
"builtin-dirOf": "language/builtins.html#builtins-dirOf",
|
||||
"builtin-div": "language/builtins.html#builtins-div",
|
||||
"builtin-elem": "language/builtins.html#builtins-elem",
|
||||
"builtin-elemAt": "language/builtins.html#builtins-elemAt",
|
||||
"builtin-fetchGit": "language/builtins.html#builtins-fetchGit",
|
||||
"builtin-fetchTarball": "language/builtins.html#builtins-fetchTarball",
|
||||
"builtin-fetchurl": "language/builtins.html#builtins-fetchurl",
|
||||
"builtin-filterSource": "language/builtins.html#builtins-filterSource",
|
||||
"builtin-foldl-prime": "language/builtins.html#builtins-foldl-prime",
|
||||
"builtin-fromJSON": "language/builtins.html#builtins-fromJSON",
|
||||
"builtin-functionArgs": "language/builtins.html#builtins-functionArgs",
|
||||
"builtin-genList": "language/builtins.html#builtins-genList",
|
||||
"builtin-getAttr": "language/builtins.html#builtins-getAttr",
|
||||
"builtin-getEnv": "language/builtins.html#builtins-getEnv",
|
||||
"builtin-hasAttr": "language/builtins.html#builtins-hasAttr",
|
||||
"builtin-hashFile": "language/builtins.html#builtins-hashFile",
|
||||
"builtin-hashString": "language/builtins.html#builtins-hashString",
|
||||
"builtin-head": "language/builtins.html#builtins-head",
|
||||
"builtin-import": "language/builtins.html#builtins-import",
|
||||
"builtin-intersectAttrs": "language/builtins.html#builtins-intersectAttrs",
|
||||
"builtin-isAttrs": "language/builtins.html#builtins-isAttrs",
|
||||
"builtin-isBool": "language/builtins.html#builtins-isBool",
|
||||
"builtin-isFloat": "language/builtins.html#builtins-isFloat",
|
||||
"builtin-isFunction": "language/builtins.html#builtins-isFunction",
|
||||
"builtin-isInt": "language/builtins.html#builtins-isInt",
|
||||
"builtin-isList": "language/builtins.html#builtins-isList",
|
||||
"builtin-isNull": "language/builtins.html#builtins-isNull",
|
||||
"builtin-isString": "language/builtins.html#builtins-isString",
|
||||
"builtin-length": "language/builtins.html#builtins-length",
|
||||
"builtin-lessThan": "language/builtins.html#builtins-lessThan",
|
||||
"builtin-listToAttrs": "language/builtins.html#builtins-listToAttrs",
|
||||
"builtin-map": "language/builtins.html#builtins-map",
|
||||
"builtin-match": "language/builtins.html#builtins-match",
|
||||
"builtin-mul": "language/builtins.html#builtins-mul",
|
||||
"builtin-parseDrvName": "language/builtins.html#builtins-parseDrvName",
|
||||
"builtin-path": "language/builtins.html#builtins-path",
|
||||
"builtin-pathExists": "language/builtins.html#builtins-pathExists",
|
||||
"builtin-placeholder": "language/builtins.html#builtins-placeholder",
|
||||
"builtin-readDir": "language/builtins.html#builtins-readDir",
|
||||
"builtin-readFile": "language/builtins.html#builtins-readFile",
|
||||
"builtin-removeAttrs": "language/builtins.html#builtins-removeAttrs",
|
||||
"builtin-replaceStrings": "language/builtins.html#builtins-replaceStrings",
|
||||
"builtin-seq": "language/builtins.html#builtins-seq",
|
||||
"builtin-sort": "language/builtins.html#builtins-sort",
|
||||
"builtin-split": "language/builtins.html#builtins-split",
|
||||
"builtin-splitVersion": "language/builtins.html#builtins-splitVersion",
|
||||
"builtin-stringLength": "language/builtins.html#builtins-stringLength",
|
||||
"builtin-sub": "language/builtins.html#builtins-sub",
|
||||
"builtin-substring": "language/builtins.html#builtins-substring",
|
||||
"builtin-tail": "language/builtins.html#builtins-tail",
|
||||
"builtin-throw": "language/builtins.html#builtins-throw",
|
||||
"builtin-toFile": "language/builtins.html#builtins-toFile",
|
||||
"builtin-toJSON": "language/builtins.html#builtins-toJSON",
|
||||
"builtin-toPath": "language/builtins.html#builtins-toPath",
|
||||
"builtin-toString": "language/builtins.html#builtins-toString",
|
||||
"builtin-toXML": "language/builtins.html#builtins-toXML",
|
||||
"builtin-trace": "language/builtins.html#builtins-trace",
|
||||
"builtin-tryEval": "language/builtins.html#builtins-tryEval",
|
||||
"builtin-typeOf": "language/builtins.html#builtins-typeOf",
|
||||
"ssec-builtins": "language/builtins.html",
|
||||
"attr-system": "language/derivations.html#attr-system",
|
||||
"ssec-derivation": "language/derivations.html",
|
||||
"ch-expression-language": "language/index.html",
|
||||
"sec-constructs": "language/syntax.html",
|
||||
"sect-let-language": "language/syntax.html#let-expressions",
|
||||
"ss-functions": "language/syntax.html#functions",
|
||||
"sec-language-operators": "language/operators.html",
|
||||
"table-operators": "language/operators.html",
|
||||
"ssec-values": "language/types.html",
|
||||
"gloss-closure": "glossary.html#gloss-closure",
|
||||
"gloss-derivation": "glossary.html#gloss-derivation",
|
||||
"gloss-deriver": "glossary.html#gloss-deriver",
|
||||
"gloss-nar": "glossary.html#gloss-nar",
|
||||
"gloss-output-path": "glossary.html#gloss-output-path",
|
||||
"gloss-profile": "glossary.html#gloss-profile",
|
||||
"gloss-reachable": "glossary.html#gloss-reachable",
|
||||
"gloss-reference": "glossary.html#gloss-reference",
|
||||
"gloss-substitute": "glossary.html#gloss-substitute",
|
||||
"gloss-user-env": "glossary.html#gloss-user-env",
|
||||
"gloss-validity": "glossary.html#gloss-validity",
|
||||
"part-glossary": "glossary.html",
|
||||
"sec-building-source": "installation/building-source.html",
|
||||
"ch-env-variables": "installation/env-variables.html",
|
||||
"sec-installer-proxy-settings": "installation/env-variables.html#proxy-environment-variables",
|
||||
"sec-nix-ssl-cert-file": "installation/env-variables.html#nix_ssl_cert_file",
|
||||
"sec-nix-ssl-cert-file-with-nix-daemon-and-macos": "installation/env-variables.html#nix_ssl_cert_file-with-macos-and-the-nix-daemon",
|
||||
"chap-installation": "installation/index.html",
|
||||
"ch-installing-binary": "installation/installing-binary.html",
|
||||
"sect-macos-installation": "installation/installing-binary.html#macos-installation",
|
||||
"sect-macos-installation-change-store-prefix": "installation/installing-binary.html#macos-installation",
|
||||
"sect-macos-installation-encrypted-volume": "installation/installing-binary.html#macos-installation",
|
||||
"sect-macos-installation-recommended-notes": "installation/installing-binary.html#macos-installation",
|
||||
"sect-macos-installation-symlink": "installation/installing-binary.html#macos-installation",
|
||||
"sect-multi-user-installation": "installation/installing-binary.html#multi-user-installation",
|
||||
"sect-nix-install-binary-tarball": "installation/installing-binary.html#installing-from-a-binary-tarball",
|
||||
"sect-nix-install-pinned-version-url": "installation/installing-binary.html#installing-a-pinned-nix-version-from-a-url",
|
||||
"sect-single-user-installation": "installation/installing-binary.html#single-user-installation",
|
||||
"ch-installing-source": "installation/installing-source.html",
|
||||
"ssec-multi-user": "installation/multi-user.html",
|
||||
"ch-nix-security": "installation/nix-security.html",
|
||||
"sec-obtaining-source": "installation/obtaining-source.html",
|
||||
"sec-prerequisites-source": "installation/prerequisites-source.html",
|
||||
"sec-single-user": "installation/single-user.html",
|
||||
"ch-supported-platforms": "installation/supported-platforms.html",
|
||||
"ch-upgrading-nix": "installation/upgrading.html",
|
||||
"ch-about-nix": "introduction.html",
|
||||
"chap-introduction": "introduction.html",
|
||||
"ch-basic-package-mgmt": "package-management/basic-package-mgmt.html",
|
||||
"ssec-binary-cache-substituter": "package-management/binary-cache-substituter.html",
|
||||
"sec-channels": "command-ref/nix-channel.html",
|
||||
"ssec-copy-closure": "command-ref/nix-copy-closure.html",
|
||||
"sec-garbage-collection": "package-management/garbage-collection.html",
|
||||
"ssec-gc-roots": "package-management/garbage-collector-roots.html",
|
||||
"chap-package-management": "package-management/index.html",
|
||||
"sec-profiles": "package-management/profiles.html",
|
||||
"ssec-s3-substituter": "store/types/s3-substituter.html",
|
||||
"ssec-s3-substituter-anonymous-reads": "store/types/s3-substituter.html#anonymous-reads-to-your-s3-compatible-binary-cache",
|
||||
"ssec-s3-substituter-authenticated-reads": "store/types/s3-substituter.html#authenticated-reads-to-your-s3-binary-cache",
|
||||
"ssec-s3-substituter-authenticated-writes": "store/types/s3-substituter.html#authenticated-writes-to-your-s3-compatible-binary-cache",
|
||||
"sec-sharing-packages": "package-management/sharing-packages.html",
|
||||
"ssec-ssh-substituter": "package-management/ssh-substituter.html",
|
||||
"chap-quick-start": "quick-start.html",
|
||||
"sec-relnotes": "release-notes/index.html",
|
||||
"ch-relnotes-0.10.1": "release-notes/rl-0.10.1.html",
|
||||
"ch-relnotes-0.10": "release-notes/rl-0.10.html",
|
||||
"ssec-relnotes-0.11": "release-notes/rl-0.11.html",
|
||||
"ssec-relnotes-0.12": "release-notes/rl-0.12.html",
|
||||
"ssec-relnotes-0.13": "release-notes/rl-0.13.html",
|
||||
"ssec-relnotes-0.14": "release-notes/rl-0.14.html",
|
||||
"ssec-relnotes-0.15": "release-notes/rl-0.15.html",
|
||||
"ssec-relnotes-0.16": "release-notes/rl-0.16.html",
|
||||
"ch-relnotes-0.5": "release-notes/rl-0.5.html",
|
||||
"ch-relnotes-0.6": "release-notes/rl-0.6.html",
|
||||
"ch-relnotes-0.7": "release-notes/rl-0.7.html",
|
||||
"ch-relnotes-0.8.1": "release-notes/rl-0.8.1.html",
|
||||
"ch-relnotes-0.8": "release-notes/rl-0.8.html",
|
||||
"ch-relnotes-0.9.1": "release-notes/rl-0.9.1.html",
|
||||
"ch-relnotes-0.9.2": "release-notes/rl-0.9.2.html",
|
||||
"ch-relnotes-0.9": "release-notes/rl-0.9.html",
|
||||
"ssec-relnotes-1.0": "release-notes/rl-1.0.html",
|
||||
"ssec-relnotes-1.1": "release-notes/rl-1.1.html",
|
||||
"ssec-relnotes-1.10": "release-notes/rl-1.10.html",
|
||||
"ssec-relnotes-1.11.10": "release-notes/rl-1.11.10.html",
|
||||
"ssec-relnotes-1.11": "release-notes/rl-1.11.html",
|
||||
"ssec-relnotes-1.2": "release-notes/rl-1.2.html",
|
||||
"ssec-relnotes-1.3": "release-notes/rl-1.3.html",
|
||||
"ssec-relnotes-1.4": "release-notes/rl-1.4.html",
|
||||
"ssec-relnotes-1.5.1": "release-notes/rl-1.5.1.html",
|
||||
"ssec-relnotes-1.5.2": "release-notes/rl-1.5.2.html",
|
||||
"ssec-relnotes-1.5": "release-notes/rl-1.5.html",
|
||||
"ssec-relnotes-1.6.1": "release-notes/rl-1.6.1.html",
|
||||
"ssec-relnotes-1.6.0": "release-notes/rl-1.6.html",
|
||||
"ssec-relnotes-1.7": "release-notes/rl-1.7.html",
|
||||
"ssec-relnotes-1.8": "release-notes/rl-1.8.html",
|
||||
"ssec-relnotes-1.9": "release-notes/rl-1.9.html",
|
||||
"ssec-relnotes-2.0": "release-notes/rl-2.0.html",
|
||||
"ssec-relnotes-2.1": "release-notes/rl-2.1.html",
|
||||
"ssec-relnotes-2.2": "release-notes/rl-2.2.html",
|
||||
"ssec-relnotes-2.3": "release-notes/rl-2.3.html",
|
||||
},
|
||||
"language/types.html": {
|
||||
"simple-values": "#primitives",
|
||||
"lists": "#list",
|
||||
"strings": "#string",
|
||||
"attribute-sets": "#attribute-set",
|
||||
"type-number": "#type-int",
|
||||
},
|
||||
"language/syntax.html": {
|
||||
"scoping-rules": "scoping.html",
|
||||
"string-literal": "string-literals.html",
|
||||
},
|
||||
"installation/installing-binary.html": {
|
||||
"linux": "uninstall.html#linux",
|
||||
"macos": "uninstall.html#macos",
|
||||
"uninstalling": "uninstall.html",
|
||||
},
|
||||
"development/building.html": {
|
||||
"nix-with-flakes": "#building-nix-with-flakes",
|
||||
"classic-nix": "#building-nix",
|
||||
"running-tests": "testing.html#running-tests",
|
||||
"unit-tests": "testing.html#unit-tests",
|
||||
"functional-tests": "testing.html#functional-tests",
|
||||
"debugging-failing-functional-tests": "testing.html#debugging-failing-functional-tests",
|
||||
"integration-tests": "testing.html#integration-tests",
|
||||
"installer-tests": "testing.html#installer-tests",
|
||||
"one-time-setup": "testing.html#one-time-setup",
|
||||
"using-the-ci-generated-installer-for-manual-testing": "testing.html#using-the-ci-generated-installer-for-manual-testing",
|
||||
"characterization-testing": "testing.html#characterisation-testing-unit",
|
||||
"add-a-release-note": "contributing.html#add-a-release-note",
|
||||
"add-an-entry": "contributing.html#add-an-entry",
|
||||
"build-process": "contributing.html#build-process",
|
||||
"reverting": "contributing.html#reverting",
|
||||
"branches": "contributing.html#branches",
|
||||
},
|
||||
"glossary.html": {
|
||||
"gloss-local-store": "store/types/local-store.html",
|
||||
"gloss-chroot-store": "store/types/local-store.html",
|
||||
},
|
||||
};
|
||||
|
||||
// the following code matches the current page's URL against the set of redirects.
|
||||
//
|
||||
// it is written to minimize the latency between page load and redirect.
|
||||
// therefore we avoid function calls, copying data, and unnecessary loops.
|
||||
// IMPORTANT: we use stateful array operations and their order matters!
|
||||
//
|
||||
// matching URLs is more involved than it should be:
|
||||
//
|
||||
// 1. `document.location.pathname` can have an arbitrary prefix.
|
||||
//
|
||||
// 2. `path_to_root` is set by mdBook. it consists only of `../`s and
|
||||
// determines the depth of `<path>` relative to the prefix:
|
||||
//
|
||||
// `document.location.pathname`
|
||||
// |------------------------------|
|
||||
// /<prefix>/<path>/[<file>[.html]][#<anchor>]
|
||||
// |----|
|
||||
// `path_to_root` has same number of path segments
|
||||
//
|
||||
// source: https://phaiax.github.io/mdBook/format/theme/index-hbs.html#data
|
||||
//
|
||||
// 3. the following paths are equivalent:
|
||||
//
|
||||
// /foo/bar/
|
||||
// /foo/bar/index.html
|
||||
// /foo/bar/index
|
||||
//
|
||||
// 4. the following paths are also equivalent:
|
||||
//
|
||||
// /foo/bar/baz
|
||||
// /foo/bar/baz.html
|
||||
//
|
||||
|
||||
let segments = document.location.pathname.split('/');
|
||||
|
||||
let file = segments.pop();
|
||||
|
||||
// normalize file name
|
||||
if (file === '') { file = "index.html"; }
|
||||
else if (!file.endsWith('.html')) { file = file + '.html'; }
|
||||
|
||||
segments.push(file);
|
||||
|
||||
// use `path_to_root` to discern prefix from path.
|
||||
const depth = path_to_root.split('/').length;
|
||||
|
||||
// remove segments containing prefix. the following works because
|
||||
// 1. the original `document.location.pathname` is absolute,
|
||||
// hence first element of `segments` is always empty.
|
||||
// 2. last element of splitting `path_to_root` is also always empty.
|
||||
// 3. last element of `segments` is the file name.
|
||||
//
|
||||
// visual example:
|
||||
//
|
||||
// '/foo/bar/baz.html'.split('/') -> [ '', 'foo', 'bar', 'baz.html' ]
|
||||
// '../'.split('/') -> [ '..', '' ]
|
||||
//
|
||||
// the following operations will then result in
|
||||
//
|
||||
// path = 'bar/baz.html'
|
||||
//
|
||||
segments.splice(0, segments.length - depth);
|
||||
const path = segments.join('/');
|
||||
|
||||
// anchor starts with the hash character (`#`),
|
||||
// but our redirect declarations don't, so we strip it.
|
||||
// example:
|
||||
// document.location.hash -> '#foo'
|
||||
// document.location.hash.substring(1) -> 'foo'
|
||||
const anchor = document.location.hash.substring(1);
|
||||
|
||||
const redirect = redirects[path];
|
||||
if (redirect) {
|
||||
const target = redirect[anchor];
|
||||
if (target) {
|
||||
document.location.href = target;
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
// redirect rules for URL fragments (client-side) to prevent link rot.
|
||||
// this must be done on the client side, as web servers do not see the fragment part of the URL.
|
||||
// it will only work with JavaScript enabled in the browser, but this is the best we can do here.
|
||||
// see source/_redirects for path redirects (server-side)
|
||||
|
||||
// redirects are declared as follows:
|
||||
// each entry has as its key a path matching the requested URL path, relative to the mdBook document root.
|
||||
//
|
||||
// IMPORTANT: it must specify the full path with file name and suffix
|
||||
//
|
||||
// each entry is itself a set of key-value pairs, where
|
||||
// - keys are anchors on the matched path.
|
||||
// - values are redirection targets relative to the current path.
|
||||
|
||||
const redirects = @REDIRECTS_JSON@;
|
||||
|
||||
// the following code matches the current page's URL against the set of redirects.
|
||||
//
|
||||
// it is written to minimize the latency between page load and redirect.
|
||||
// therefore we avoid function calls, copying data, and unnecessary loops.
|
||||
// IMPORTANT: we use stateful array operations and their order matters!
|
||||
//
|
||||
// matching URLs is more involved than it should be:
|
||||
//
|
||||
// 1. `document.location.pathname` can have an arbitrary prefix.
|
||||
//
|
||||
// 2. `path_to_root` is set by mdBook. it consists only of `../`s and
|
||||
// determines the depth of `<path>` relative to the prefix:
|
||||
//
|
||||
// `document.location.pathname`
|
||||
// |------------------------------|
|
||||
// /<prefix>/<path>/[<file>[.html]][#<anchor>]
|
||||
// |----|
|
||||
// `path_to_root` has same number of path segments
|
||||
//
|
||||
// source: https://phaiax.github.io/mdBook/format/theme/index-hbs.html#data
|
||||
//
|
||||
// 3. the following paths are equivalent:
|
||||
//
|
||||
// /foo/bar/
|
||||
// /foo/bar/index.html
|
||||
// /foo/bar/index
|
||||
//
|
||||
// 4. the following paths are also equivalent:
|
||||
//
|
||||
// /foo/bar/baz
|
||||
// /foo/bar/baz.html
|
||||
//
|
||||
|
||||
let segments = document.location.pathname.split('/');
|
||||
|
||||
let file = segments.pop();
|
||||
|
||||
// normalize file name
|
||||
if (file === '') { file = "index.html"; }
|
||||
else if (!file.endsWith('.html')) { file = file + '.html'; }
|
||||
|
||||
segments.push(file);
|
||||
|
||||
// use `path_to_root` to discern prefix from path.
|
||||
const depth = path_to_root.split('/').length;
|
||||
|
||||
// remove segments containing prefix. the following works because
|
||||
// 1. the original `document.location.pathname` is absolute,
|
||||
// hence first element of `segments` is always empty.
|
||||
// 2. last element of splitting `path_to_root` is also always empty.
|
||||
// 3. last element of `segments` is the file name.
|
||||
//
|
||||
// visual example:
|
||||
//
|
||||
// '/foo/bar/baz.html'.split('/') -> [ '', 'foo', 'bar', 'baz.html' ]
|
||||
// '../'.split('/') -> [ '..', '' ]
|
||||
//
|
||||
// the following operations will then result in
|
||||
//
|
||||
// path = 'bar/baz.html'
|
||||
//
|
||||
segments.splice(0, segments.length - depth);
|
||||
const path = segments.join('/');
|
||||
|
||||
// anchor starts with the hash character (`#`),
|
||||
// but our redirect declarations don't, so we strip it.
|
||||
// example:
|
||||
// document.location.hash -> '#foo'
|
||||
// document.location.hash.substring(1) -> 'foo'
|
||||
const anchor = document.location.hash.substring(1);
|
||||
|
||||
const redirect = redirects[path];
|
||||
if (redirect) {
|
||||
const target = redirect[anchor];
|
||||
if (target) {
|
||||
document.location.href = target;
|
||||
}
|
||||
}
|
||||
@@ -1,372 +0,0 @@
|
||||
{
|
||||
"index.html": {
|
||||
"part-advanced-topics": "advanced-topics/index.html",
|
||||
"chap-tuning-cores-and-jobs": "advanced-topics/cores-vs-jobs.html",
|
||||
"chap-diff-hook": "advanced-topics/diff-hook.html",
|
||||
"check-dirs-are-unregistered": "advanced-topics/diff-hook.html#check-dirs-are-unregistered",
|
||||
"chap-distributed-builds": "command-ref/conf-file.html#conf-builders",
|
||||
"chap-post-build-hook": "advanced-topics/post-build-hook.html",
|
||||
"chap-post-build-hook-caveats": "advanced-topics/post-build-hook.html#implementation-caveats",
|
||||
"chap-writing-nix-expressions": "language/index.html",
|
||||
"part-command-ref": "command-ref/index.html",
|
||||
"conf-allow-import-from-derivation": "command-ref/conf-file.html#conf-allow-import-from-derivation",
|
||||
"conf-allow-new-privileges": "command-ref/conf-file.html#conf-allow-new-privileges",
|
||||
"conf-allowed-uris": "command-ref/conf-file.html#conf-allowed-uris",
|
||||
"conf-allowed-users": "command-ref/conf-file.html#conf-allowed-users",
|
||||
"conf-auto-optimise-store": "command-ref/conf-file.html#conf-auto-optimise-store",
|
||||
"conf-binary-cache-public-keys": "command-ref/conf-file.html#conf-trusted-public-keys",
|
||||
"conf-binary-caches": "command-ref/conf-file.html#conf-substituters",
|
||||
"conf-build-compress-log": "command-ref/conf-file.html#conf-compress-build-log",
|
||||
"conf-build-cores": "command-ref/conf-file.html#conf-cores",
|
||||
"conf-build-extra-chroot-dirs": "command-ref/conf-file.html#conf-sandbox-paths",
|
||||
"conf-build-extra-sandbox-paths": "command-ref/conf-file.html#conf-sandbox-paths",
|
||||
"conf-build-fallback": "command-ref/conf-file.html#conf-fallback",
|
||||
"conf-build-max-jobs": "command-ref/conf-file.html#conf-max-jobs",
|
||||
"conf-build-max-log-size": "command-ref/conf-file.html#conf-max-build-log-size",
|
||||
"conf-build-max-silent-time": "command-ref/conf-file.html#conf-max-silent-time",
|
||||
"conf-build-timeout": "command-ref/conf-file.html#conf-timeout",
|
||||
"conf-build-use-chroot": "command-ref/conf-file.html#conf-sandbox",
|
||||
"conf-build-use-sandbox": "command-ref/conf-file.html#conf-sandbox",
|
||||
"conf-build-use-substitutes": "command-ref/conf-file.html#conf-substitute",
|
||||
"conf-build-users-group": "command-ref/conf-file.html#conf-build-users-group",
|
||||
"conf-builders": "command-ref/conf-file.html#conf-builders",
|
||||
"conf-builders-use-substitutes": "command-ref/conf-file.html#conf-builders-use-substitutes",
|
||||
"conf-compress-build-log": "command-ref/conf-file.html#conf-compress-build-log",
|
||||
"conf-connect-timeout": "command-ref/conf-file.html#conf-connect-timeout",
|
||||
"conf-cores": "command-ref/conf-file.html#conf-cores",
|
||||
"conf-diff-hook": "command-ref/conf-file.html#conf-diff-hook",
|
||||
"conf-env-keep-derivations": "command-ref/conf-file.html#conf-keep-env-derivations",
|
||||
"conf-extra-binary-caches": "command-ref/conf-file.html#conf-substituters",
|
||||
"conf-extra-platforms": "command-ref/conf-file.html#conf-extra-platforms",
|
||||
"conf-extra-sandbox-paths": "command-ref/conf-file.html#conf-sandbox-paths",
|
||||
"conf-extra-substituters": "command-ref/conf-file.html#conf-substituters",
|
||||
"conf-fallback": "command-ref/conf-file.html#conf-fallback",
|
||||
"conf-fsync-metadata": "command-ref/conf-file.html#conf-fsync-metadata",
|
||||
"conf-gc-keep-derivations": "command-ref/conf-file.html#conf-keep-derivations",
|
||||
"conf-gc-keep-outputs": "command-ref/conf-file.html#conf-keep-outputs",
|
||||
"conf-hashed-mirrors": "command-ref/conf-file.html#conf-hashed-mirrors",
|
||||
"conf-http-connections": "command-ref/conf-file.html#conf-http-connections",
|
||||
"conf-keep-build-log": "command-ref/conf-file.html#conf-keep-build-log",
|
||||
"conf-keep-derivations": "command-ref/conf-file.html#conf-keep-derivations",
|
||||
"conf-keep-env-derivations": "command-ref/conf-file.html#conf-keep-env-derivations",
|
||||
"conf-keep-outputs": "command-ref/conf-file.html#conf-keep-outputs",
|
||||
"conf-max-build-log-size": "command-ref/conf-file.html#conf-max-build-log-size",
|
||||
"conf-max-free": "command-ref/conf-file.html#conf-max-free",
|
||||
"conf-max-jobs": "command-ref/conf-file.html#conf-max-jobs",
|
||||
"conf-max-silent-time": "command-ref/conf-file.html#conf-max-silent-time",
|
||||
"conf-min-free": "command-ref/conf-file.html#conf-min-free",
|
||||
"conf-narinfo-cache-negative-ttl": "command-ref/conf-file.html#conf-narinfo-cache-negative-ttl",
|
||||
"conf-narinfo-cache-positive-ttl": "command-ref/conf-file.html#conf-narinfo-cache-positive-ttl",
|
||||
"conf-netrc-file": "command-ref/conf-file.html#conf-netrc-file",
|
||||
"conf-plugin-files": "command-ref/conf-file.html#conf-plugin-files",
|
||||
"conf-post-build-hook": "command-ref/conf-file.html#conf-post-build-hook",
|
||||
"conf-pre-build-hook": "command-ref/conf-file.html#conf-pre-build-hook",
|
||||
"conf-require-sigs": "command-ref/conf-file.html#conf-require-sigs",
|
||||
"conf-restrict-eval": "command-ref/conf-file.html#conf-restrict-eval",
|
||||
"conf-run-diff-hook": "command-ref/conf-file.html#conf-run-diff-hook",
|
||||
"conf-sandbox": "command-ref/conf-file.html#conf-sandbox",
|
||||
"conf-sandbox-dev-shm-size": "command-ref/conf-file.html#conf-sandbox-dev-shm-size",
|
||||
"conf-sandbox-paths": "command-ref/conf-file.html#conf-sandbox-paths",
|
||||
"conf-secret-key-files": "command-ref/conf-file.html#conf-secret-key-files",
|
||||
"conf-show-trace": "command-ref/conf-file.html#conf-show-trace",
|
||||
"conf-stalled-download-timeout": "command-ref/conf-file.html#conf-stalled-download-timeout",
|
||||
"conf-substitute": "command-ref/conf-file.html#conf-substitute",
|
||||
"conf-substituters": "command-ref/conf-file.html#conf-substituters",
|
||||
"conf-system": "command-ref/conf-file.html#conf-system",
|
||||
"conf-system-features": "command-ref/conf-file.html#conf-system-features",
|
||||
"conf-tarball-ttl": "command-ref/conf-file.html#conf-tarball-ttl",
|
||||
"conf-timeout": "command-ref/conf-file.html#conf-timeout",
|
||||
"conf-trace-function-calls": "command-ref/conf-file.html#conf-trace-function-calls",
|
||||
"conf-trusted-binary-caches": "command-ref/conf-file.html#conf-trusted-substituters",
|
||||
"conf-trusted-public-keys": "command-ref/conf-file.html#conf-trusted-public-keys",
|
||||
"conf-trusted-substituters": "command-ref/conf-file.html#conf-trusted-substituters",
|
||||
"conf-trusted-users": "command-ref/conf-file.html#conf-trusted-users",
|
||||
"extra-sandbox-paths": "command-ref/conf-file.html#conf-sandbox-paths",
|
||||
"sec-conf-file": "command-ref/conf-file.html",
|
||||
"env-NIX_PATH": "command-ref/env-common.html#env-NIX_PATH",
|
||||
"env-common": "command-ref/env-common.html",
|
||||
"envar-remote": "command-ref/env-common.html#env-NIX_REMOTE",
|
||||
"sec-common-env": "command-ref/env-common.html",
|
||||
"ch-files": "command-ref/files.html",
|
||||
"ch-main-commands": "command-ref/main-commands.html",
|
||||
"opt-out-link": "command-ref/nix-build.html#opt-out-link",
|
||||
"sec-nix-build": "command-ref/nix-build.html",
|
||||
"sec-nix-channel": "command-ref/nix-channel.html",
|
||||
"sec-nix-collect-garbage": "command-ref/nix-collect-garbage.html",
|
||||
"sec-nix-copy-closure": "command-ref/nix-copy-closure.html",
|
||||
"sec-nix-daemon": "command-ref/nix-daemon.html",
|
||||
"refsec-nix-env-install-examples": "command-ref/nix-env/install.html#examples",
|
||||
"rsec-nix-env-install": "command-ref/nix-env/install.html",
|
||||
"rsec-nix-env-set": "command-ref/nix-env/set.html",
|
||||
"rsec-nix-env-set-flag": "command-ref/nix-env/set-flag.html",
|
||||
"rsec-nix-env-upgrade": "command-ref/nix-env/upgrade.html",
|
||||
"sec-nix-env": "command-ref/nix-env.html",
|
||||
"ssec-version-comparisons": "command-ref/nix-env.html#selectors",
|
||||
"sec-nix-hash": "command-ref/nix-hash.html",
|
||||
"sec-nix-instantiate": "command-ref/nix-instantiate.html",
|
||||
"sec-nix-prefetch-url": "command-ref/nix-prefetch-url.html",
|
||||
"sec-nix-shell": "command-ref/nix-shell.html",
|
||||
"ssec-nix-shell-shebang": "command-ref/nix-shell.html#use-as-a--interpreter",
|
||||
"nixref-queries": "command-ref/nix-store/query.html#queries",
|
||||
"opt-add-root": "command-ref/nix-store/query.html#opt-add-root",
|
||||
"refsec-nix-store-dump": "command-ref/nix-store/dump.html",
|
||||
"refsec-nix-store-export": "command-ref/nix-store/export.html",
|
||||
"refsec-nix-store-import": "command-ref/nix-store/import.html",
|
||||
"refsec-nix-store-query": "command-ref/nix-store/query.html",
|
||||
"refsec-nix-store-verify": "command-ref/nix-store/verify.html",
|
||||
"rsec-nix-store-gc": "command-ref/nix-store/gc.html",
|
||||
"rsec-nix-store-generate-binary-cache-key": "command-ref/nix-store/generate-binary-cache-key.html",
|
||||
"rsec-nix-store-realise": "command-ref/nix-store/realise.html",
|
||||
"rsec-nix-store-serve": "command-ref/nix-store/serve.html",
|
||||
"sec-nix-store": "command-ref/nix-store.html",
|
||||
"opt-I": "command-ref/opt-common.html#opt-I",
|
||||
"opt-attr": "command-ref/opt-common.html#opt-attr",
|
||||
"opt-common": "command-ref/opt-common.html",
|
||||
"opt-cores": "command-ref/opt-common.html#opt-cores",
|
||||
"opt-log-format": "command-ref/opt-common.html#opt-log-format",
|
||||
"opt-max-jobs": "command-ref/opt-common.html#opt-max-jobs",
|
||||
"opt-max-silent-time": "command-ref/opt-common.html#opt-max-silent-time",
|
||||
"opt-timeout": "command-ref/opt-common.html#opt-timeout",
|
||||
"sec-common-options": "command-ref/opt-common.html",
|
||||
"ch-utilities": "command-ref/utilities.html",
|
||||
"chap-hacking": "development/building.html",
|
||||
"adv-attr-allowSubstitutes": "language/advanced-attributes.html#adv-attr-allowSubstitutes",
|
||||
"adv-attr-allowedReferences": "language/advanced-attributes.html#adv-attr-allowedReferences",
|
||||
"adv-attr-allowedRequisites": "language/advanced-attributes.html#adv-attr-allowedRequisites",
|
||||
"adv-attr-disallowedReferences": "language/advanced-attributes.html#adv-attr-disallowedReferences",
|
||||
"adv-attr-disallowedRequisites": "language/advanced-attributes.html#adv-attr-disallowedRequisites",
|
||||
"adv-attr-exportReferencesGraph": "language/advanced-attributes.html#adv-attr-exportReferencesGraph",
|
||||
"adv-attr-impureEnvVars": "language/advanced-attributes.html#adv-attr-impureEnvVars",
|
||||
"adv-attr-outputHash": "language/advanced-attributes.html#adv-attr-outputHash",
|
||||
"adv-attr-outputHashAlgo": "language/advanced-attributes.html#adv-attr-outputHashAlgo",
|
||||
"adv-attr-outputHashMode": "language/advanced-attributes.html#adv-attr-outputHashMode",
|
||||
"adv-attr-passAsFile": "language/advanced-attributes.html#adv-attr-passAsFile",
|
||||
"adv-attr-preferLocalBuild": "language/advanced-attributes.html#adv-attr-preferLocalBuild",
|
||||
"fixed-output-drvs": "language/advanced-attributes.html#adv-attr-outputHash",
|
||||
"sec-advanced-attributes": "language/advanced-attributes.html",
|
||||
"builtin-abort": "language/builtins.html#builtins-abort",
|
||||
"builtin-add": "language/builtins.html#builtins-add",
|
||||
"builtin-all": "language/builtins.html#builtins-all",
|
||||
"builtin-any": "language/builtins.html#builtins-any",
|
||||
"builtin-attrNames": "language/builtins.html#builtins-attrNames",
|
||||
"builtin-attrValues": "language/builtins.html#builtins-attrValues",
|
||||
"builtin-baseNameOf": "language/builtins.html#builtins-baseNameOf",
|
||||
"builtin-bitAnd": "language/builtins.html#builtins-bitAnd",
|
||||
"builtin-bitOr": "language/builtins.html#builtins-bitOr",
|
||||
"builtin-bitXor": "language/builtins.html#builtins-bitXor",
|
||||
"builtin-builtins": "language/builtins.html#builtins-builtins",
|
||||
"builtin-compareVersions": "language/builtins.html#builtins-compareVersions",
|
||||
"builtin-concatLists": "language/builtins.html#builtins-concatLists",
|
||||
"builtin-concatStringsSep": "language/builtins.html#builtins-concatStringsSep",
|
||||
"builtin-currentSystem": "language/builtins.html#builtins-currentSystem",
|
||||
"builtin-deepSeq": "language/builtins.html#builtins-deepSeq",
|
||||
"builtin-derivation": "language/builtins.html#builtins-derivation",
|
||||
"builtin-dirOf": "language/builtins.html#builtins-dirOf",
|
||||
"builtin-div": "language/builtins.html#builtins-div",
|
||||
"builtin-elem": "language/builtins.html#builtins-elem",
|
||||
"builtin-elemAt": "language/builtins.html#builtins-elemAt",
|
||||
"builtin-fetchGit": "language/builtins.html#builtins-fetchGit",
|
||||
"builtin-fetchTarball": "language/builtins.html#builtins-fetchTarball",
|
||||
"builtin-fetchurl": "language/builtins.html#builtins-fetchurl",
|
||||
"builtin-filterSource": "language/builtins.html#builtins-filterSource",
|
||||
"builtin-foldl-prime": "language/builtins.html#builtins-foldl'",
|
||||
"builtin-fromJSON": "language/builtins.html#builtins-fromJSON",
|
||||
"builtin-functionArgs": "language/builtins.html#builtins-functionArgs",
|
||||
"builtin-genList": "language/builtins.html#builtins-genList",
|
||||
"builtin-getAttr": "language/builtins.html#builtins-getAttr",
|
||||
"builtin-getEnv": "language/builtins.html#builtins-getEnv",
|
||||
"builtin-hasAttr": "language/builtins.html#builtins-hasAttr",
|
||||
"builtin-hashFile": "language/builtins.html#builtins-hashFile",
|
||||
"builtin-hashString": "language/builtins.html#builtins-hashString",
|
||||
"builtin-head": "language/builtins.html#builtins-head",
|
||||
"builtin-import": "language/builtins.html#builtins-import",
|
||||
"builtin-intersectAttrs": "language/builtins.html#builtins-intersectAttrs",
|
||||
"builtin-isAttrs": "language/builtins.html#builtins-isAttrs",
|
||||
"builtin-isBool": "language/builtins.html#builtins-isBool",
|
||||
"builtin-isFloat": "language/builtins.html#builtins-isFloat",
|
||||
"builtin-isFunction": "language/builtins.html#builtins-isFunction",
|
||||
"builtin-isInt": "language/builtins.html#builtins-isInt",
|
||||
"builtin-isList": "language/builtins.html#builtins-isList",
|
||||
"builtin-isNull": "language/builtins.html#builtins-isNull",
|
||||
"builtin-isString": "language/builtins.html#builtins-isString",
|
||||
"builtin-length": "language/builtins.html#builtins-length",
|
||||
"builtin-lessThan": "language/builtins.html#builtins-lessThan",
|
||||
"builtin-listToAttrs": "language/builtins.html#builtins-listToAttrs",
|
||||
"builtin-map": "language/builtins.html#builtins-map",
|
||||
"builtin-match": "language/builtins.html#builtins-match",
|
||||
"builtin-mul": "language/builtins.html#builtins-mul",
|
||||
"builtin-parseDrvName": "language/builtins.html#builtins-parseDrvName",
|
||||
"builtin-path": "language/builtins.html#builtins-path",
|
||||
"builtin-pathExists": "language/builtins.html#builtins-pathExists",
|
||||
"builtin-placeholder": "language/builtins.html#builtins-placeholder",
|
||||
"builtin-readDir": "language/builtins.html#builtins-readDir",
|
||||
"builtin-readFile": "language/builtins.html#builtins-readFile",
|
||||
"builtin-removeAttrs": "language/builtins.html#builtins-removeAttrs",
|
||||
"builtin-replaceStrings": "language/builtins.html#builtins-replaceStrings",
|
||||
"builtin-seq": "language/builtins.html#builtins-seq",
|
||||
"builtin-sort": "language/builtins.html#builtins-sort",
|
||||
"builtin-split": "language/builtins.html#builtins-split",
|
||||
"builtin-splitVersion": "language/builtins.html#builtins-splitVersion",
|
||||
"builtin-stringLength": "language/builtins.html#builtins-stringLength",
|
||||
"builtin-sub": "language/builtins.html#builtins-sub",
|
||||
"builtin-substring": "language/builtins.html#builtins-substring",
|
||||
"builtin-tail": "language/builtins.html#builtins-tail",
|
||||
"builtin-throw": "language/builtins.html#builtins-throw",
|
||||
"builtin-toFile": "language/builtins.html#builtins-toFile",
|
||||
"builtin-toJSON": "language/builtins.html#builtins-toJSON",
|
||||
"builtin-toPath": "language/builtins.html#builtins-toPath",
|
||||
"builtin-toString": "language/builtins.html#builtins-toString",
|
||||
"builtin-toXML": "language/builtins.html#builtins-toXML",
|
||||
"builtin-trace": "language/builtins.html#builtins-trace",
|
||||
"builtin-tryEval": "language/builtins.html#builtins-tryEval",
|
||||
"builtin-typeOf": "language/builtins.html#builtins-typeOf",
|
||||
"ssec-builtins": "language/builtins.html",
|
||||
"attr-system": "language/derivations.html#attr-system",
|
||||
"ssec-derivation": "language/derivations.html",
|
||||
"ch-expression-language": "language/index.html",
|
||||
"sec-constructs": "language/syntax.html",
|
||||
"sect-let-language": "language/syntax.html#let-expressions",
|
||||
"ss-functions": "language/syntax.html#functions",
|
||||
"sec-language-operators": "language/operators.html",
|
||||
"table-operators": "language/operators.html",
|
||||
"ssec-values": "language/types.html",
|
||||
"gloss-closure": "glossary.html#gloss-closure",
|
||||
"gloss-derivation": "glossary.html#gloss-derivation",
|
||||
"gloss-deriver": "glossary.html#gloss-deriver",
|
||||
"gloss-nar": "glossary.html#gloss-nar",
|
||||
"gloss-output-path": "glossary.html#gloss-output-path",
|
||||
"gloss-profile": "glossary.html#gloss-profile",
|
||||
"gloss-reachable": "glossary.html#gloss-reachable",
|
||||
"gloss-reference": "glossary.html#gloss-reference",
|
||||
"gloss-substitute": "glossary.html#gloss-substitute",
|
||||
"gloss-user-env": "glossary.html#gloss-user-env",
|
||||
"gloss-validity": "glossary.html#gloss-validity",
|
||||
"part-glossary": "glossary.html",
|
||||
"sec-building-source": "installation/building-source.html",
|
||||
"ch-env-variables": "installation/env-variables.html",
|
||||
"sec-installer-proxy-settings": "installation/env-variables.html#proxy-environment-variables",
|
||||
"sec-nix-ssl-cert-file": "installation/env-variables.html#nix_ssl_cert_file",
|
||||
"sec-nix-ssl-cert-file-with-nix-daemon-and-macos": "installation/env-variables.html#nix_ssl_cert_file",
|
||||
"chap-installation": "installation/index.html",
|
||||
"ch-installing-binary": "installation/installing-binary.html",
|
||||
"sect-macos-installation": "installation/installing-binary.html#macos-installation",
|
||||
"sect-macos-installation-change-store-prefix": "installation/installing-binary.html#macos-installation",
|
||||
"sect-macos-installation-encrypted-volume": "installation/installing-binary.html#macos-installation",
|
||||
"sect-macos-installation-recommended-notes": "installation/installing-binary.html#macos-installation",
|
||||
"sect-macos-installation-symlink": "installation/installing-binary.html#macos-installation",
|
||||
"sect-multi-user-installation": "installation/installing-binary.html#multi-user-installation",
|
||||
"sect-nix-install-binary-tarball": "installation/installing-binary.html#installing-from-a-binary-tarball",
|
||||
"sect-nix-install-pinned-version-url":
|
||||
"installation/installing-binary.html#installing-a-pinned-nix-version-from-a-url",
|
||||
"sect-single-user-installation": "installation/installing-binary.html#single-user-installation",
|
||||
"ch-installing-source": "installation/installing-source.html",
|
||||
"ssec-multi-user": "installation/multi-user.html",
|
||||
"ch-nix-security": "installation/nix-security.html",
|
||||
"sec-obtaining-source": "installation/obtaining-source.html",
|
||||
"sec-prerequisites-source": "installation/prerequisites-source.html",
|
||||
"sec-single-user": "installation/single-user.html",
|
||||
"ch-supported-platforms": "installation/supported-platforms.html",
|
||||
"ch-upgrading-nix": "installation/upgrading.html",
|
||||
"ch-about-nix": "introduction.html",
|
||||
"chap-introduction": "introduction.html",
|
||||
"ch-basic-package-mgmt": "package-management/index.html",
|
||||
"ssec-binary-cache-substituter": "package-management/binary-cache-substituter.html",
|
||||
"sec-channels": "command-ref/nix-channel.html",
|
||||
"ssec-copy-closure": "command-ref/nix-copy-closure.html",
|
||||
"sec-garbage-collection": "package-management/garbage-collection.html",
|
||||
"ssec-gc-roots": "package-management/garbage-collector-roots.html",
|
||||
"chap-package-management": "package-management/index.html",
|
||||
"sec-profiles": "package-management/profiles.html",
|
||||
"ssec-s3-substituter": "store/types/s3-binary-cache-store.html",
|
||||
"ssec-s3-substituter-anonymous-reads":
|
||||
"store/types/s3-binary-cache-store.html#anonymous-reads-to-your-s3-compatible-binary-cache",
|
||||
"ssec-s3-substituter-authenticated-reads":
|
||||
"store/types/s3-binary-cache-store.html#authenticated-reads-to-your-s3-binary-cache",
|
||||
"ssec-s3-substituter-authenticated-writes":
|
||||
"store/types/s3-binary-cache-store.html#authenticated-writes-to-your-s3-compatible-binary-cache",
|
||||
"sec-sharing-packages": "package-management/sharing-packages.html",
|
||||
"ssec-ssh-substituter": "package-management/ssh-substituter.html",
|
||||
"chap-quick-start": "quick-start.html",
|
||||
"sec-relnotes": "release-notes/index.html",
|
||||
"ch-relnotes-0.10.1": "release-notes/rl-0.10.1.html",
|
||||
"ch-relnotes-0.10": "release-notes/rl-0.10.html",
|
||||
"ssec-relnotes-0.11": "release-notes/rl-0.11.html",
|
||||
"ssec-relnotes-0.12": "release-notes/rl-0.12.html",
|
||||
"ssec-relnotes-0.13": "release-notes/rl-0.13.html",
|
||||
"ssec-relnotes-0.14": "release-notes/rl-0.14.html",
|
||||
"ssec-relnotes-0.15": "release-notes/rl-0.15.html",
|
||||
"ssec-relnotes-0.16": "release-notes/rl-0.16.html",
|
||||
"ch-relnotes-0.5": "release-notes/rl-0.5.html",
|
||||
"ch-relnotes-0.6": "release-notes/rl-0.6.html",
|
||||
"ch-relnotes-0.7": "release-notes/rl-0.7.html",
|
||||
"ch-relnotes-0.8.1": "release-notes/rl-0.8.1.html",
|
||||
"ch-relnotes-0.8": "release-notes/rl-0.8.html",
|
||||
"ch-relnotes-0.9.1": "release-notes/rl-0.9.1.html",
|
||||
"ch-relnotes-0.9.2": "release-notes/rl-0.9.2.html",
|
||||
"ch-relnotes-0.9": "release-notes/rl-0.9.html",
|
||||
"ssec-relnotes-1.0": "release-notes/rl-1.0.html",
|
||||
"ssec-relnotes-1.1": "release-notes/rl-1.1.html",
|
||||
"ssec-relnotes-1.10": "release-notes/rl-1.10.html",
|
||||
"ssec-relnotes-1.11.10": "release-notes/rl-1.11.10.html",
|
||||
"ssec-relnotes-1.11": "release-notes/rl-1.11.html",
|
||||
"ssec-relnotes-1.2": "release-notes/rl-1.2.html",
|
||||
"ssec-relnotes-1.3": "release-notes/rl-1.3.html",
|
||||
"ssec-relnotes-1.4": "release-notes/rl-1.4.html",
|
||||
"ssec-relnotes-1.5.1": "release-notes/rl-1.5.html",
|
||||
"ssec-relnotes-1.5.2": "release-notes/rl-1.5.2.html",
|
||||
"ssec-relnotes-1.5": "release-notes/rl-1.5.html",
|
||||
"ssec-relnotes-1.6.1": "release-notes/rl-1.6.1.html",
|
||||
"ssec-relnotes-1.6.0": "release-notes/rl-1.6.html",
|
||||
"ssec-relnotes-1.7": "release-notes/rl-1.7.html",
|
||||
"ssec-relnotes-1.8": "release-notes/rl-1.8.html",
|
||||
"ssec-relnotes-1.9": "release-notes/rl-1.9.html",
|
||||
"ssec-relnotes-2.0": "release-notes/rl-2.0.html",
|
||||
"ssec-relnotes-2.1": "release-notes/rl-2.1.html",
|
||||
"ssec-relnotes-2.2": "release-notes/rl-2.2.html",
|
||||
"ssec-relnotes-2.3": "release-notes/rl-2.3.html"
|
||||
},
|
||||
"language/types.html": {
|
||||
"simple-values": "#primitives",
|
||||
"lists": "#type-list",
|
||||
"strings": "#type-string",
|
||||
"attribute-sets": "#type-attrs",
|
||||
"type-number": "#type-int"
|
||||
},
|
||||
"language/syntax.html": {
|
||||
"scoping-rules": "scope.html",
|
||||
"string-literal": "string-literals.html"
|
||||
},
|
||||
"language/derivations.html": {
|
||||
"builder-execution": "../store/building.html#builder-execution"
|
||||
},
|
||||
"installation/installing-binary.html": {
|
||||
"linux": "uninstall.html#linux",
|
||||
"macos": "uninstall.html#macos",
|
||||
"uninstalling": "uninstall.html"
|
||||
},
|
||||
"development/building.html": {
|
||||
"nix-with-flakes": "#building-nix-with-flakes",
|
||||
"classic-nix": "#building-nix",
|
||||
"running-tests": "testing.html#running-tests",
|
||||
"unit-tests": "testing.html#unit-tests",
|
||||
"functional-tests": "testing.html#functional-tests",
|
||||
"debugging-failing-functional-tests": "testing.html#debugging-failing-functional-tests",
|
||||
"integration-tests": "testing.html#integration-tests",
|
||||
"installer-tests": "testing.html#installer-tests",
|
||||
"one-time-setup": "testing.html#one-time-setup",
|
||||
"using-the-ci-generated-installer-for-manual-testing":
|
||||
"testing.html#using-the-ci-generated-installer-for-manual-testing",
|
||||
"characterization-testing": "testing.html#characterisation-testing-unit",
|
||||
"add-a-release-note": "contributing.html#add-a-release-note",
|
||||
"add-an-entry": "contributing.html#add-an-entry",
|
||||
"build-process": "contributing.html#build-process",
|
||||
"reverting": "contributing.html#reverting",
|
||||
"branches": "contributing.html#branches"
|
||||
},
|
||||
"glossary.html": {
|
||||
"gloss-local-store": "store/types/local-store.html",
|
||||
"package-attribute-set": "#package",
|
||||
"gloss-chroot-store": "store/types/local-store.html",
|
||||
"gloss-content-addressed-derivation": "#gloss-content-addressing-derivation"
|
||||
}
|
||||
}
|
||||
40
doc/manual/render-manpage.sh
Normal file → Executable file
40
doc/manual/render-manpage.sh
Normal file → Executable file
@@ -1,55 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Standalone manpage renderer that doesn't require mdbook.
|
||||
# Uses expand-includes.py to preprocess markdown, then lowdown to generate manpages.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
lowdown_args=
|
||||
|
||||
# Optional --out-no-smarty flag for compatibility with nix_nested_manpages
|
||||
if [ "$1" = --out-no-smarty ]; then
|
||||
lowdown_args=--out-no-smarty
|
||||
shift
|
||||
fi
|
||||
|
||||
[ "$#" = 7 ] || {
|
||||
cat >&2 <<EOF
|
||||
Usage: $0 [--out-no-smarty] <title> <section> <source-root> <generated-root> <doc-url> <infile> <outfile>
|
||||
|
||||
Arguments:
|
||||
title - Manpage title (e.g., "nix-env --install")
|
||||
section - Manpage section number (1, 5, 8, etc.)
|
||||
source-root - Root directory of markdown sources
|
||||
generated-root - Root directory of generated markdown files
|
||||
doc-url - Base URL for documentation links
|
||||
infile - Input markdown file (relative to build directory)
|
||||
outfile - Output manpage file
|
||||
|
||||
Examples:
|
||||
$0 "nix-store --query" 1 doc/manual/source build/doc/manual/source \\
|
||||
https://nix.dev/manual/nix/latest \\
|
||||
build/doc/manual/source/command-ref/nix-store/query.md nix-store-query.1
|
||||
EOF
|
||||
[ "$#" = 4 ] || {
|
||||
echo "wrong number of args passed" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
title="$1"
|
||||
section="$2"
|
||||
source_root="$3"
|
||||
generated_root="$4"
|
||||
doc_url="$5"
|
||||
infile="$6"
|
||||
outfile="$7"
|
||||
infile="$3"
|
||||
outfile="$4"
|
||||
|
||||
# Expand includes and pipe to lowdown
|
||||
(
|
||||
printf "Title: %s\n\n" "$title"
|
||||
python3 "$script_dir/expand-includes.py" \
|
||||
--source-root "$source_root" \
|
||||
--generated-root "$generated_root" \
|
||||
--doc-url "$doc_url" \
|
||||
"$infile"
|
||||
cat "$infile"
|
||||
) | lowdown -sT man --nroff-nolinks $lowdown_args -M section="$section" -o "$outfile"
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
---
|
||||
synopsis: Channel URLs migrated to channels.nixos.org subdomain
|
||||
prs: [14518]
|
||||
issues: [14517]
|
||||
---
|
||||
|
||||
Channel URLs have been updated from `https://nixos.org/channels/` to `https://channels.nixos.org/` throughout Nix.
|
||||
|
||||
The subdomain provides better reliability with IPv6 support and improved CDN distribution. The old domain apex (`nixos.org/channels/`) currently redirects to the new location but may be deprecated in the future.
|
||||
@@ -1,88 +0,0 @@
|
||||
---
|
||||
synopsis: "JSON format changes for store path info and derivations"
|
||||
prs: []
|
||||
issues: []
|
||||
---
|
||||
|
||||
JSON formats for store path info and derivations have been updated with new versions and structured fields.
|
||||
|
||||
## Store Path Info JSON
|
||||
|
||||
`nix path-info --json` now requires a `--json-format` flag to specify the output format version.
|
||||
Using `--json` without `--json-format` is deprecated and will become an error in a future release.
|
||||
For now, it defaults to version 1 with a warning, for a smoother migration.
|
||||
|
||||
### Version 1 (`--json-format 1`)
|
||||
|
||||
This is the legacy format, preserved for backwards compatibility:
|
||||
|
||||
- String-based hash values (e.g., `"narHash": "sha256:FePFYIlM..."`)
|
||||
- String-based content addresses (e.g., `"ca": "fixed:r:sha256:1abc..."`)
|
||||
- Full store paths for map keys and references (e.g., `"/nix/store/abc...-foo"`)
|
||||
- Now includes `"storeDir"` field at the top level
|
||||
|
||||
### Version 2 (`--json-format 2`)
|
||||
|
||||
The new structured format follows the [JSON guidelines](@docroot@/development/json-guideline.md) with the following changes:
|
||||
|
||||
- **Nested structure with top-level metadata**:
|
||||
|
||||
The output is now wrapped in an object with `version`, `storeDir`, and `info` fields:
|
||||
|
||||
```json
|
||||
{
|
||||
"version": 2,
|
||||
"storeDir": "/nix/store",
|
||||
"info": { ... }
|
||||
}
|
||||
```
|
||||
|
||||
The map from store bath base names to store object info is nested under the `info` field.
|
||||
|
||||
- **Store path base names instead of full paths**:
|
||||
|
||||
Map keys and references use store path base names (e.g., `"abc...-foo"`) instead of full absolute store paths.
|
||||
Combined with `storeDir`, the full path can be reconstructed.
|
||||
|
||||
- **Structured `ca` field**:
|
||||
|
||||
Content address is now a structured JSON object instead of a string:
|
||||
|
||||
- Old: `"ca": "fixed:r:sha256:1abc..."`
|
||||
- New: `"ca": {"method": "nar", "hash": "sha256-ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0="}`
|
||||
- Still `null` values for input-addressed store objects
|
||||
|
||||
The `hash` field uses the [SRI](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) format like other hashes.
|
||||
|
||||
Nix currently only produces, and doesn't consume this format.
|
||||
|
||||
Additionally the following field is added to both formats.
|
||||
(The `version` tracks breaking changes, and adding fields to outputted JSON is not a breaking change.)
|
||||
|
||||
- **`version` field**:
|
||||
|
||||
All store path info JSON now includes `"version": <1|2>`.
|
||||
|
||||
- **`storeDir` field**:
|
||||
|
||||
Top-level `"storeDir"` field contains the store directory path (e.g., `"/nix/store"`).
|
||||
|
||||
## Derivation JSON (Version 4)
|
||||
|
||||
The derivation JSON format has been updated from version 3 to version 4:
|
||||
|
||||
- **Restructured inputs**:
|
||||
|
||||
Inputs are now nested under an `inputs` object:
|
||||
|
||||
- Old: `"inputSrcs": [...], "inputDrvs": {...}`
|
||||
- New: `"inputs": {"srcs": [...], "drvs": {...}}`
|
||||
|
||||
- **Consistent content addresses**:
|
||||
|
||||
Fixed content-addressed outputs now use structured JSON format.
|
||||
This is the same format as `ca` in store path info (after the new version).
|
||||
|
||||
Version 3 and earlier formats are *not* accepted when reading.
|
||||
|
||||
**Affected command**: `nix derivation`, namely its `show` and `add` sub-commands.
|
||||
@@ -1,12 +0,0 @@
|
||||
---
|
||||
synopsis: Fix "download buffer is full; consider increasing the 'download-buffer-size' setting" warning
|
||||
prs: [14614]
|
||||
issues: [11728]
|
||||
---
|
||||
|
||||
The underlying issue that led to [#11728](https://github.com/NixOS/nix/issues/11728) has been resolved by utilizing
|
||||
[libcurl write pausing functionality](https://curl.se/libcurl/c/curl_easy_pause.html) to control backpressure when unpacking to slow destinations like the git-backed tarball cache. The default value of `download-buffer-size` is now 1 MiB and it's no longer recommended to increase it, since the root cause has been fixed.
|
||||
|
||||
This is expected to improve download performance on fast connections, since previously a single slow download consumer would stall the thread and prevent any other transfers from progressing.
|
||||
|
||||
Many thanks go out to the [Lix project](https://lix.systems/) for the [implementation](https://git.lix.systems/lix-project/lix/commit/4ae6fb5a8f0d456b8d2ba2aaca3712b4e49057fc) that served as inspiration for this change and for triaging libcurl [issues with pausing](https://github.com/curl/curl/issues/19334).
|
||||
@@ -1,8 +0,0 @@
|
||||
---
|
||||
synopsis: Interrupting REPL commands works more than once
|
||||
issues: [13481]
|
||||
---
|
||||
|
||||
Previously, this only worked once per REPL session; further attempts would be ignored.
|
||||
This issue is now fixed, so REPL commands such as `:b` or `:p` can be canceled consistently.
|
||||
This is a cherry-pick of the change from the [Lix project](https://gerrit.lix.systems/c/lix/+/1097).
|
||||
@@ -1,40 +0,0 @@
|
||||
---
|
||||
synopsis: "Improved S3 binary cache support via HTTP"
|
||||
prs: [13752, 13823, 14026, 14120, 14131, 14135, 14144, 14170, 14190, 14198, 14206, 14209, 14222, 14223, 14330, 14333, 14335, 14336, 14337, 14350, 14356, 14357, 14374, 14375, 14376, 14377, 14391, 14393, 14420, 14421]
|
||||
issues: [13084, 12671, 11748, 12403]
|
||||
---
|
||||
|
||||
S3 binary cache operations now happen via HTTP, leveraging `libcurl`'s native
|
||||
AWS SigV4 authentication instead of the AWS C++ SDK, providing significant
|
||||
improvements:
|
||||
|
||||
- **Reduced memory usage**: Eliminates memory buffering issues that caused
|
||||
segfaults with large files
|
||||
- **Fixed upload reliability**: Resolves AWS SDK chunking errors
|
||||
(`InvalidChunkSizeError`)
|
||||
- **Lighter dependencies**: Uses lightweight `aws-crt-cpp` instead of full
|
||||
`aws-cpp-sdk`, reducing build complexity
|
||||
|
||||
The new implementation requires curl >= 7.75.0 and `aws-crt-cpp` for credential
|
||||
management.
|
||||
|
||||
All existing S3 URL formats and parameters remain supported, however the store
|
||||
settings for configuring multipart uploads have changed:
|
||||
|
||||
- **`multipart-upload`** (default: `false`): Enable multipart uploads for large
|
||||
files. When enabled, files exceeding the multipart threshold will be uploaded
|
||||
in multiple parts.
|
||||
|
||||
- **`multipart-threshold`** (default: `100 MiB`): Minimum file size for using
|
||||
multipart uploads. Files smaller than this will use regular PUT requests.
|
||||
Only takes effect when `multipart-upload` is enabled.
|
||||
|
||||
- **`multipart-chunk-size`** (default: `5 MiB`): Size of each part in multipart
|
||||
uploads. Must be at least 5 MiB (AWS S3 requirement). Larger chunk sizes
|
||||
reduce the number of requests but use more memory.
|
||||
|
||||
- **`buffer-size`**: Has been replaced by `multipart-chunk-size` and is now an alias to it.
|
||||
|
||||
Note that this change also means Nix now supports S3 binary cache stores even
|
||||
if built without `aws-crt-cpp`, but only for public buckets which do not
|
||||
require authentication.
|
||||
@@ -1,14 +0,0 @@
|
||||
---
|
||||
synopsis: "S3 URLs now support object versioning via versionId parameter"
|
||||
prs: [14274]
|
||||
issues: [13955]
|
||||
---
|
||||
|
||||
S3 URLs now support a `versionId` query parameter to fetch specific versions
|
||||
of objects from S3 buckets with versioning enabled. This allows pinning to
|
||||
exact object versions for reproducibility and protection against unexpected
|
||||
changes:
|
||||
|
||||
```
|
||||
s3://bucket/key?region=us-east-1&versionId=abc123def456
|
||||
```
|
||||
@@ -1,21 +0,0 @@
|
||||
---
|
||||
synopsis: "S3 binary cache stores now support storage class configuration"
|
||||
prs: [14464]
|
||||
issues: [7015]
|
||||
---
|
||||
|
||||
S3 binary cache stores now support configuring the storage class for uploaded objects via the `storage-class` parameter. This allows users to optimize costs by selecting appropriate storage tiers based on access patterns.
|
||||
|
||||
Example usage:
|
||||
|
||||
```bash
|
||||
# Use Glacier storage for long-term archival
|
||||
nix copy --to 's3://my-bucket?storage-class=GLACIER' /nix/store/...
|
||||
|
||||
# Use Intelligent Tiering for automatic cost optimization
|
||||
nix copy --to 's3://my-bucket?storage-class=INTELLIGENT_TIERING' /nix/store/...
|
||||
```
|
||||
|
||||
The storage class applies to both regular uploads and multipart uploads. When not specified, objects use the bucket's default storage class.
|
||||
|
||||
See the [S3 storage classes documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-class-intro.html) for available storage classes and their characteristics.
|
||||
@@ -22,22 +22,12 @@
|
||||
- [Store Object](store/store-object.md)
|
||||
- [Content-Addressing Store Objects](store/store-object/content-address.md)
|
||||
- [Store Path](store/store-path.md)
|
||||
- [Store Derivation and Deriving Path](store/derivation/index.md)
|
||||
- [Derivation Outputs and Types of Derivations](store/derivation/outputs/index.md)
|
||||
- [Content-addressing derivation outputs](store/derivation/outputs/content-address.md)
|
||||
- [Input-addressing derivation outputs](store/derivation/outputs/input-address.md)
|
||||
- [Build Trace](store/build-trace.md)
|
||||
- [Derivation Resolution](store/resolution.md)
|
||||
- [Building](store/building.md)
|
||||
- [Secrets](store/secrets.md)
|
||||
- [Store Types](store/types/index.md)
|
||||
{{#include ./store/types/SUMMARY.md}}
|
||||
- [Appendix: Math notation](store/math-notation.md)
|
||||
- [Nix Language](language/index.md)
|
||||
- [Data Types](language/types.md)
|
||||
- [String context](language/string-context.md)
|
||||
- [Syntax and semantics](language/syntax.md)
|
||||
- [Evaluation](language/evaluation.md)
|
||||
- [Variables](language/variables.md)
|
||||
- [String literals](language/string-literals.md)
|
||||
- [Identifiers](language/identifiers.md)
|
||||
@@ -61,7 +51,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)
|
||||
@@ -121,27 +110,17 @@
|
||||
- [Architecture and Design](architecture/architecture.md)
|
||||
- [Formats and Protocols](protocols/index.md)
|
||||
- [JSON Formats](protocols/json/index.md)
|
||||
- [File System Object](protocols/json/file-system-object.md)
|
||||
- [Hash](protocols/json/hash.md)
|
||||
- [Content Address](protocols/json/content-address.md)
|
||||
- [Store Path](protocols/json/store-path.md)
|
||||
- [Store Object Info](protocols/json/store-object-info.md)
|
||||
- [Derivation](protocols/json/derivation/index.md)
|
||||
- [Derivation Options](protocols/json/derivation/options.md)
|
||||
- [Deriving Path](protocols/json/deriving-path.md)
|
||||
- [Build Trace Entry](protocols/json/build-trace-entry.md)
|
||||
- [Build Result](protocols/json/build-result.md)
|
||||
- [Store](protocols/json/store.md)
|
||||
- [Derivation](protocols/json/derivation.md)
|
||||
- [Serving Tarball Flakes](protocols/tarball-fetcher.md)
|
||||
- [Store Path Specification](protocols/store-path.md)
|
||||
- [Nix Archive (NAR) Format](protocols/nix-archive/index.md)
|
||||
- [Nix Archive (NAR) Format](protocols/nix-archive.md)
|
||||
- [Derivation "ATerm" file format](protocols/derivation-aterm.md)
|
||||
- [C API](c-api.md)
|
||||
- [Glossary](glossary.md)
|
||||
- [Development](development/index.md)
|
||||
- [Building](development/building.md)
|
||||
- [Testing](development/testing.md)
|
||||
- [Benchmarking](development/benchmarking.md)
|
||||
- [Debugging](development/debugging.md)
|
||||
- [Documentation](development/documentation.md)
|
||||
- [CLI guideline](development/cli-guideline.md)
|
||||
@@ -151,12 +130,6 @@
|
||||
- [Contributing](development/contributing.md)
|
||||
- [Releases](release-notes/index.md)
|
||||
{{#include ./SUMMARY-rl-next.md}}
|
||||
- [Release 2.32 (2025-10-06)](release-notes/rl-2.32.md)
|
||||
- [Release 2.31 (2025-08-21)](release-notes/rl-2.31.md)
|
||||
- [Release 2.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)
|
||||
- [Release 2.26 (2025-01-22)](release-notes/rl-2.26.md)
|
||||
- [Release 2.25 (2024-11-07)](release-notes/rl-2.25.md)
|
||||
- [Release 2.24 (2024-07-31)](release-notes/rl-2.24.md)
|
||||
|
||||
@@ -20,14 +20,14 @@ For a local machine to forward a build to a remote machine, the remote machine m
|
||||
|
||||
## Testing
|
||||
|
||||
To test connecting to a remote [Nix instance] (in this case `mac`), run:
|
||||
To test connecting to a remote Nix instance (in this case `mac`), run:
|
||||
|
||||
```console
|
||||
nix store info --store ssh://username@mac
|
||||
```
|
||||
|
||||
To specify an SSH identity file as part of the remote store URI add a
|
||||
query parameter, e.g.
|
||||
query paramater, e.g.
|
||||
|
||||
```console
|
||||
nix store info --store ssh://username@mac?ssh-key=/home/alice/my-key
|
||||
@@ -106,5 +106,3 @@ file included in `builders` via the syntax `@/path/to/file`. For example,
|
||||
|
||||
causes the list of machines in `/etc/nix/machines` to be included.
|
||||
(This is the default.)
|
||||
|
||||
[Nix instance]: @docroot@/glossary.md#gloss-nix-instance
|
||||
@@ -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`.
|
||||
@@ -22,9 +22,9 @@ The following [concept map] shows its main components (rectangles), the objects
|
||||
| |
|
||||
+----------|-------------------|--------------------------------+
|
||||
| Nix | V |
|
||||
| | +------------------------+ |
|
||||
| | | command line interface |------. |
|
||||
| | +------------------------+ | |
|
||||
| | +-------------------------+ |
|
||||
| | | commmand line interface |------. |
|
||||
| | +-------------------------+ | |
|
||||
| | | | |
|
||||
| evaluated by calls manages |
|
||||
| | | | |
|
||||
@@ -69,7 +69,7 @@ It can also execute build plans to produce new data, which are made available to
|
||||
A build plan itself is a series of *build tasks*, together with their build inputs.
|
||||
|
||||
> **Important**
|
||||
> A build task in Nix is called [store derivation](@docroot@/glossary.md#gloss-store-derivation).
|
||||
> A build task in Nix is called [derivation](@docroot@/glossary.md#gloss-derivation).
|
||||
|
||||
Each build task has a special build input executed as *build instructions* in order to perform the build.
|
||||
The result of a build task can be input to another build task.
|
||||
|
||||
@@ -75,7 +75,7 @@ Most Nix commands interpret the following environment variables:
|
||||
- <span id="env-NIX_CONF_DIR">[`NIX_CONF_DIR`](#env-NIX_CONF_DIR)</span>
|
||||
|
||||
Overrides the location of the system Nix configuration directory
|
||||
(default `sysconfdir/nix`, i.e. `/etc/nix` on most systems).
|
||||
(default `prefix/etc/nix`).
|
||||
|
||||
- <span id="env-NIX_CONFIG">[`NIX_CONFIG`](#env-NIX_CONFIG)</span>
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
xp_features_json = custom_target(
|
||||
command : [ nix, '__dump-xp-features' ],
|
||||
command : [nix, '__dump-xp-features'],
|
||||
capture : true,
|
||||
output : 'xp-features.json',
|
||||
env : nix_env_for_docs,
|
||||
)
|
||||
|
||||
experimental_features_shortlist_md = custom_target(
|
||||
command : nix_eval_for_docs + [
|
||||
'--expr', 'import @INPUT0@ (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
|
||||
'--expr',
|
||||
'import @INPUT0@ (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
|
||||
],
|
||||
input : [
|
||||
'../../generate-xp-features-shortlist.nix',
|
||||
@@ -19,8 +19,14 @@ experimental_features_shortlist_md = custom_target(
|
||||
)
|
||||
|
||||
nix3_cli_files = custom_target(
|
||||
command : [ python.full_path(), '@INPUT0@', '@OUTPUT@', '--' ] + nix_eval_for_docs + [
|
||||
'--expr', 'import @INPUT1@ true (builtins.readFile ./@INPUT2@)',
|
||||
command : [
|
||||
python.full_path(),
|
||||
'@INPUT0@',
|
||||
'@OUTPUT@',
|
||||
'--'
|
||||
] + nix_eval_for_docs + [
|
||||
'--expr',
|
||||
'import @INPUT1@ true (builtins.readFile ./@INPUT2@)',
|
||||
],
|
||||
input : [
|
||||
'../../remove_before_wrapper.py',
|
||||
@@ -34,7 +40,8 @@ nix3_cli_files = custom_target(
|
||||
conf_file_md_body = custom_target(
|
||||
command : [
|
||||
nix_eval_for_docs,
|
||||
'--expr', 'import @INPUT0@ { prefix = "conf"; } (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
|
||||
'--expr',
|
||||
'import @INPUT0@ { prefix = "conf"; } (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
|
||||
],
|
||||
capture : true,
|
||||
input : [
|
||||
|
||||
@@ -36,7 +36,7 @@ to a temporary location. The tarball must include a single top-level
|
||||
directory containing at least a file named `default.nix`.
|
||||
|
||||
`nix-build` is essentially a wrapper around
|
||||
[`nix-instantiate`](./nix-instantiate.md) (to translate a high-level Nix
|
||||
[`nix-instantiate`](nix-instantiate.md) (to translate a high-level Nix
|
||||
expression to a low-level [store derivation]) and [`nix-store
|
||||
--realise`](@docroot@/command-ref/nix-store/realise.md) (to build the store
|
||||
derivation).
|
||||
@@ -52,8 +52,8 @@ derivation).
|
||||
# Options
|
||||
|
||||
All options not listed here are passed to
|
||||
[`nix-store --realise`](./nix-store/realise.md),
|
||||
except for `--arg` and `--attr` / `-A` which are passed to [`nix-instantiate`](./nix-instantiate.md).
|
||||
[`nix-store --realise`](nix-store/realise.md),
|
||||
except for `--arg` and `--attr` / `-A` which are passed to [`nix-instantiate`](nix-instantiate.md).
|
||||
|
||||
- <span id="opt-no-out-link">[`--no-out-link`](#opt-no-out-link)<span>
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
Channels are a mechanism for referencing remote Nix expressions and conveniently retrieving their latest version.
|
||||
|
||||
The moving parts of channels are:
|
||||
- The official channels listed at <https://channels.nixos.org>
|
||||
- The official channels listed at <https://nixos.org/channels>
|
||||
- The user-specific list of [subscribed channels](#subscribed-channels)
|
||||
- The [downloaded channel contents](#channels)
|
||||
- The [Nix expression search path](@docroot@/command-ref/conf-file.md#conf-nix-path), set with the [`-I` option](#opt-I) or the [`NIX_PATH` environment variable](#env-NIX_PATH)
|
||||
- The [Nix expression search path](@docroot@/command-ref/conf-file.md#conf-nix-path), set with the [`-I` option](#opt-i) or the [`NIX_PATH` environment variable](#env-NIX_PATH)
|
||||
|
||||
> **Note**
|
||||
>
|
||||
@@ -53,11 +53,6 @@ This command has the following operations:
|
||||
Download the Nix expressions of subscribed channels and create a new generation.
|
||||
Update all channels if none is specified, and only those included in *names* otherwise.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> Downloaded channel contents are cached.
|
||||
> Use `--tarball-ttl` or the [`tarball-ttl` configuration option](@docroot@/command-ref/conf-file.md#conf-tarball-ttl) to change the validity period of cached downloads.
|
||||
|
||||
- `--list-generations`
|
||||
|
||||
Prints a list of all the current existing generations for the
|
||||
@@ -88,9 +83,9 @@ This command has the following operations:
|
||||
Subscribe to the Nixpkgs channel and run `hello` from the GNU Hello package:
|
||||
|
||||
```console
|
||||
$ nix-channel --add https://channels.nixos.org/nixpkgs-unstable
|
||||
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
||||
$ nix-channel --list
|
||||
nixpkgs https://channels.nixos.org/nixpkgs
|
||||
nixpkgs https://nixos.org/channels/nixpkgs
|
||||
$ nix-channel --update
|
||||
$ nix-shell -p hello --run hello
|
||||
hello
|
||||
|
||||
@@ -27,7 +27,7 @@ This operation deletes the specified generations of the current profile.
|
||||
>
|
||||
> Older *and newer* generations will be deleted by this operation.
|
||||
>
|
||||
> One might expect this to just delete older generations than the current one, but that is only true if the current generation is also the latest.
|
||||
> One might expect this to just delete older generations than the curent one, but that is only true if the current generation is also the latest.
|
||||
> Because one can roll back to a previous generation, it is possible to have generations newer than the current one.
|
||||
> They will also be deleted.
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ It is based on the current generation of the active [profile](@docroot@/command-
|
||||
|
||||
The arguments *args* map to store paths in a number of possible ways:
|
||||
|
||||
- By default, *args* is a set of names denoting derivations in the [default Nix expression].
|
||||
- By default, *args* is a set of [derivation] names denoting derivations in the [default Nix expression].
|
||||
These are [realised], and the resulting output paths are installed.
|
||||
Currently installed derivations with a name equal to the name of a derivation being added are removed unless the option `--preserve-installed` is specified.
|
||||
|
||||
[derivation expression]: @docroot@/glossary.md#gloss-derivation-expression
|
||||
[derivation]: @docroot@/glossary.md#gloss-derivation
|
||||
[default Nix expression]: @docroot@/command-ref/files/default-nix-expression.md
|
||||
[realised]: @docroot@/glossary.md#gloss-realise
|
||||
|
||||
@@ -66,11 +66,11 @@ The arguments *args* map to store paths in a number of possible ways:
|
||||
This can be used to override the priority of the derivations being installed.
|
||||
This is useful if *args* are [store paths], which don't have any priority information.
|
||||
|
||||
- If *args* are [store paths] that point to [store derivations][store derivation], then those store derivations are [realised], and the resulting output paths are installed.
|
||||
- If *args* are [store derivations](@docroot@/glossary.md#gloss-store-derivation), then these are [realised], and the resulting output paths are installed.
|
||||
|
||||
- If *args* are [store paths] that do not point to store derivations, then these are [realised] and installed.
|
||||
- If *args* are [store paths] that are not store derivations, then these are [realised] and installed.
|
||||
|
||||
- By default all [outputs](@docroot@/language/derivations.md#attr-outputs) are installed for each [store derivation].
|
||||
- By default all [outputs](@docroot@/language/derivations.md#attr-outputs) are installed for each [derivation].
|
||||
This can be overridden by adding a `meta.outputsToInstall` attribute on the derivation listing a subset of the output names.
|
||||
|
||||
Example:
|
||||
@@ -122,8 +122,6 @@ The arguments *args* map to store paths in a number of possible ways:
|
||||
manifest.nix
|
||||
```
|
||||
|
||||
[store derivation]: @docroot@/glossary.md#gloss-store-derivation
|
||||
|
||||
# Options
|
||||
|
||||
- `--prebuilt-only` / `-b`
|
||||
|
||||
@@ -125,10 +125,7 @@ derivation is shown unless `--no-name` is specified.
|
||||
|
||||
- `--drv-path`
|
||||
|
||||
Print the [store path] to the [store derivation].
|
||||
|
||||
[store path]: @docroot@/glossary.md#gloss-store-path
|
||||
[store derivation]: @docroot@/glossary.md#gloss-derivation
|
||||
Print the path of the [store derivation](@docroot@/glossary.md#gloss-store-derivation).
|
||||
|
||||
- `--out-path`
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ left untouched; this is not an error. It is also not an error if an
|
||||
element of *args* matches no installed derivations.
|
||||
|
||||
For a description of how *args* is mapped to a set of store paths, see
|
||||
[`--install`](./install.md). If *args* describes multiple
|
||||
[`--install`](#operation---install). If *args* describes multiple
|
||||
store paths with the same symbolic name, only the one with the highest
|
||||
version is installed.
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ md5sum`.
|
||||
Print the cryptographic hash of the contents of each regular file *path*.
|
||||
That is, instead of computing
|
||||
the hash of the [Nix Archive (NAR)](@docroot@/store/file-system-object/content-address.md#serial-nix-archive) of *path*,
|
||||
just [directly hash](@docroot@/store/file-system-object/content-address.md#serial-flat) *path* as is.
|
||||
just [directly hash]((@docroot@/store/file-system-object/content-address.md#serial-flat) *path* as is.
|
||||
This requires *path* to resolve to a regular file rather than directory.
|
||||
The result is identical to that produced by the GNU commands
|
||||
`md5sum` and `sha1sum`.
|
||||
@@ -67,7 +67,7 @@ md5sum`.
|
||||
- `--type` *hashAlgo*
|
||||
|
||||
Use the specified cryptographic hash algorithm, which can be one of
|
||||
`blake3`, `md5`, `sha1`, `sha256`, and `sha512`.
|
||||
`md5`, `sha1`, `sha256`, and `sha512`.
|
||||
|
||||
- `--to-base16`
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ standard input.
|
||||
|
||||
- `--add-root` *path*
|
||||
|
||||
See the [corresponding option](./nix-store.md) in `nix-store`.
|
||||
See the [corresponding option](nix-store.md) in `nix-store`.
|
||||
|
||||
- `--parse`
|
||||
|
||||
@@ -42,8 +42,8 @@ standard input.
|
||||
- `--eval`
|
||||
|
||||
Just parse and evaluate the input files, and print the resulting
|
||||
values on standard output.
|
||||
Store derivations are not serialized and written to the store, but instead just hashed and discarded.
|
||||
values on standard output. No instantiation of store derivations
|
||||
takes place.
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
|
||||
@@ -42,7 +42,7 @@ the path of the downloaded file in the Nix store is also printed.
|
||||
- `--type` *hashAlgo*
|
||||
|
||||
Use the specified cryptographic hash algorithm,
|
||||
which can be one of `blake3`, `md5`, `sha1`, `sha256`, and `sha512`.
|
||||
which can be one of `md5`, `sha1`, `sha256`, and `sha512`.
|
||||
The default is `sha256`.
|
||||
|
||||
- `--print-path`
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
This man page describes the command `nix-shell`, which is distinct from `nix
|
||||
shell`. For documentation on the latter, run `nix shell --help` or see `man
|
||||
nix3-env-shell`.
|
||||
nix3-shell`.
|
||||
|
||||
# Description
|
||||
|
||||
@@ -242,21 +242,16 @@ print(t)
|
||||
```
|
||||
|
||||
Similarly, the following is a Perl script that specifies that it
|
||||
requires Perl and the `HTML::TokeParser::Simple`, `LWP` and
|
||||
`LWP::Protocol::Https` packages:
|
||||
requires Perl and the `HTML::TokeParser::Simple` and `LWP` packages:
|
||||
|
||||
```perl
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i perl
|
||||
#! nix-shell --packages perl
|
||||
#! nix-shell --packages perlPackages.HTMLTokeParserSimple
|
||||
#! nix-shell --packages perlPackages.LWP
|
||||
#! nix-shell --packages perlPackages.LWPProtocolHttps
|
||||
#! nix-shell -i perl --packages perl perlPackages.HTMLTokeParserSimple perlPackages.LWP
|
||||
|
||||
use HTML::TokeParser::Simple;
|
||||
|
||||
# Fetch nixos.org and print all hrefs.
|
||||
my $p = HTML::TokeParser::Simple->new(url => 'https://nixos.org/');
|
||||
my $p = HTML::TokeParser::Simple->new(url => 'http://nixos.org/');
|
||||
|
||||
while (my $token = $p->get_tag("a")) {
|
||||
my $href = $token->get_attr("href");
|
||||
@@ -321,7 +316,7 @@ contains:
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
|
||||
runCommand "dummy" { buildInputs = [ python3 python3Packages.prettytable ]; } ""
|
||||
runCommand "dummy" { buildInputs = [ python pythonPackages.prettytable ]; } ""
|
||||
```
|
||||
|
||||
The script's file name is passed as the first argument to the interpreter specified by the `-i` flag.
|
||||
|
||||
@@ -48,7 +48,8 @@ The behaviour of the collector is also influenced by the
|
||||
configuration file.
|
||||
|
||||
By default, the collector prints the total number of freed bytes when it
|
||||
finishes (or when it is interrupted).
|
||||
finishes (or when it is interrupted). With `--print-dead`, it prints the
|
||||
number of bytes that would be freed.
|
||||
|
||||
{{#include ./opt-common.md}}
|
||||
|
||||
|
||||
@@ -45,19 +45,10 @@ symlink.
|
||||
|
||||
[output paths]: @docroot@/glossary.md#gloss-output-path
|
||||
|
||||
- `--references`
|
||||
|
||||
Prints the set of [references] of the store paths
|
||||
*paths*, that is, their immediate dependencies. (For *all*
|
||||
dependencies, use `--requisites`.)
|
||||
|
||||
[references]: @docroot@/glossary.md#gloss-reference
|
||||
|
||||
- `--requisites` / `-R`
|
||||
|
||||
Prints out the set of [*requisites*][requisite] (better known as the [closure]) of the store path *paths*.
|
||||
Prints out the [closure] of the store path *paths*.
|
||||
|
||||
[requisite]: @docroot@/glossary.md#gloss-requisite
|
||||
[closure]: @docroot@/glossary.md#gloss-closure
|
||||
|
||||
This query has one option:
|
||||
@@ -74,25 +65,29 @@ symlink.
|
||||
dependencies) is obtained by distributing the closure of a store
|
||||
derivation and specifying the option `--include-outputs`.
|
||||
|
||||
- `--references`
|
||||
|
||||
Prints the set of [references] of the store paths
|
||||
*paths*, that is, their immediate dependencies. (For *all*
|
||||
dependencies, use `--requisites`.)
|
||||
|
||||
[references]: @docroot@/glossary.md#gloss-reference
|
||||
|
||||
- `--referrers`
|
||||
|
||||
Prints the set of [*referrers*][referrer] of the store paths *paths*, that is,
|
||||
Prints the set of *referrers* of the store paths *paths*, that is,
|
||||
the store paths currently existing in the Nix store that refer to
|
||||
one of *paths*. Note that contrary to the references, the set of
|
||||
referrers is not constant; it can change as store paths are added or
|
||||
removed.
|
||||
|
||||
[referrer]: @docroot@/glossary.md#gloss-referrer
|
||||
|
||||
- `--referrers-closure`
|
||||
|
||||
Prints the closure of the set of store paths *paths* under the
|
||||
[referrers relation][referrer]; that is, all store paths that directly or
|
||||
referrers relation; that is, all store paths that directly or
|
||||
indirectly refer to one of *paths*. These are all the path currently
|
||||
in the Nix store that are dependent on *paths*.
|
||||
|
||||
[referrer]: @docroot@/glossary.md#gloss-referrer
|
||||
|
||||
- `--deriver` / `-d`
|
||||
|
||||
Prints the [deriver] that was used to build the store paths *paths*. If
|
||||
|
||||
@@ -15,7 +15,7 @@ Each of *paths* is processed as follows:
|
||||
1. If it is not [valid], substitute the store derivation file itself.
|
||||
2. Realise its [output paths]:
|
||||
- Try to fetch from [substituters] the [store objects] associated with the output paths in the store derivation's [closure].
|
||||
- With [content-addressing derivations] (experimental):
|
||||
- With [content-addressed derivations] (experimental):
|
||||
Determine the output paths to realise by querying content-addressed realisation entries in the [Nix database].
|
||||
- For any store paths that cannot be substituted, produce the required store objects:
|
||||
1. Realise all outputs of the derivation's dependencies
|
||||
@@ -32,7 +32,7 @@ If no substitutes are available and no store derivation is given, realisation fa
|
||||
[store objects]: @docroot@/store/store-object.md
|
||||
[closure]: @docroot@/glossary.md#gloss-closure
|
||||
[substituters]: @docroot@/command-ref/conf-file.md#conf-substituters
|
||||
[content-addressing derivations]: @docroot@/development/experimental-features.md#xp-feature-ca-derivations
|
||||
[content-addressed derivations]: @docroot@/development/experimental-features.md#xp-feature-ca-derivations
|
||||
[Nix database]: @docroot@/glossary.md#gloss-nix-database
|
||||
|
||||
The resulting paths are printed on standard output.
|
||||
|
||||
@@ -1,187 +0,0 @@
|
||||
# Running Benchmarks
|
||||
|
||||
This guide explains how to build and run performance benchmarks in the Nix codebase.
|
||||
|
||||
## Overview
|
||||
|
||||
Nix uses the [Google Benchmark](https://github.com/google/benchmark) framework for performance testing. Benchmarks help measure and track the performance of critical operations like derivation parsing.
|
||||
|
||||
## Building Benchmarks
|
||||
|
||||
Benchmarks are disabled by default and must be explicitly enabled during the build configuration. For accurate results, use a debug-optimized release build.
|
||||
|
||||
### Development Environment Setup
|
||||
|
||||
First, enter the development shell which includes the necessary dependencies:
|
||||
|
||||
```bash
|
||||
nix develop .#native-ccacheStdenv
|
||||
```
|
||||
|
||||
### Configure Build with Benchmarks
|
||||
|
||||
From the project root, configure the build with benchmarks enabled and optimization:
|
||||
|
||||
```bash
|
||||
cd build
|
||||
meson configure -Dbenchmarks=true -Dbuildtype=debugoptimized
|
||||
```
|
||||
|
||||
The `debugoptimized` build type provides:
|
||||
- Compiler optimizations for realistic performance measurements
|
||||
- Debug symbols for profiling and analysis
|
||||
- Balance between performance and debuggability
|
||||
|
||||
### Build the Benchmarks
|
||||
|
||||
Build the project including benchmarks:
|
||||
|
||||
```bash
|
||||
ninja
|
||||
```
|
||||
|
||||
This will create benchmark executables in the build directory. Currently available:
|
||||
- `build/src/libstore-tests/nix-store-benchmarks` - Store-related performance benchmarks
|
||||
|
||||
Additional benchmark executables will be created as more benchmarks are added to the codebase.
|
||||
|
||||
## Running Benchmarks
|
||||
|
||||
### Basic Usage
|
||||
|
||||
Run benchmark executables directly. For example, to run store benchmarks:
|
||||
|
||||
```bash
|
||||
./build/src/libstore-tests/nix-store-benchmarks
|
||||
```
|
||||
|
||||
As more benchmark executables are added, run them similarly from their respective build directories.
|
||||
|
||||
### Filtering Benchmarks
|
||||
|
||||
Run specific benchmarks using regex patterns:
|
||||
|
||||
```bash
|
||||
# Run only derivation parser benchmarks
|
||||
./build/src/libstore-tests/nix-store-benchmarks --benchmark_filter="derivation.*"
|
||||
|
||||
# Run only benchmarks for hello.drv
|
||||
./build/src/libstore-tests/nix-store-benchmarks --benchmark_filter=".*hello.*"
|
||||
```
|
||||
|
||||
### Output Formats
|
||||
|
||||
Generate benchmark results in different formats:
|
||||
|
||||
```bash
|
||||
# JSON output
|
||||
./build/src/libstore-tests/nix-store-benchmarks --benchmark_format=json > results.json
|
||||
|
||||
# CSV output
|
||||
./build/src/libstore-tests/nix-store-benchmarks --benchmark_format=csv > results.csv
|
||||
```
|
||||
|
||||
### Advanced Options
|
||||
|
||||
```bash
|
||||
# Run benchmarks multiple times for better statistics
|
||||
./build/src/libstore-tests/nix-store-benchmarks --benchmark_repetitions=10
|
||||
|
||||
# Set minimum benchmark time (useful for micro-benchmarks)
|
||||
./build/src/libstore-tests/nix-store-benchmarks --benchmark_min_time=2
|
||||
|
||||
# Compare against baseline
|
||||
./build/src/libstore-tests/nix-store-benchmarks --benchmark_baseline=baseline.json
|
||||
|
||||
# Display time in custom units
|
||||
./build/src/libstore-tests/nix-store-benchmarks --benchmark_time_unit=ms
|
||||
```
|
||||
|
||||
## Writing New Benchmarks
|
||||
|
||||
To add new benchmarks:
|
||||
|
||||
1. Create a new `.cc` file in the appropriate `*-tests` directory
|
||||
2. Include the benchmark header:
|
||||
```cpp
|
||||
#include <benchmark/benchmark.h>
|
||||
```
|
||||
|
||||
3. Write benchmark functions:
|
||||
```cpp
|
||||
static void BM_YourBenchmark(benchmark::State & state)
|
||||
{
|
||||
// Setup code here
|
||||
|
||||
for (auto _ : state) {
|
||||
// Code to benchmark
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_YourBenchmark);
|
||||
```
|
||||
|
||||
4. Add the file to the corresponding `meson.build`:
|
||||
```meson
|
||||
benchmarks_sources = files(
|
||||
'your-benchmark.cc',
|
||||
# existing benchmarks...
|
||||
)
|
||||
```
|
||||
|
||||
## Profiling with Benchmarks
|
||||
|
||||
For deeper performance analysis, combine benchmarks with profiling tools:
|
||||
|
||||
```bash
|
||||
# Using Linux perf
|
||||
perf record ./build/src/libstore-tests/nix-store-benchmarks
|
||||
perf report
|
||||
```
|
||||
|
||||
### Using Valgrind Callgrind
|
||||
|
||||
Valgrind's callgrind tool provides detailed profiling information that can be visualized with kcachegrind:
|
||||
|
||||
```bash
|
||||
# Profile with callgrind
|
||||
valgrind --tool=callgrind ./build/src/libstore-tests/nix-store-benchmarks
|
||||
|
||||
# Visualize the results with kcachegrind
|
||||
kcachegrind callgrind.out.*
|
||||
```
|
||||
|
||||
This provides:
|
||||
- Function call graphs
|
||||
- Instruction-level profiling
|
||||
- Source code annotation
|
||||
- Interactive visualization of performance bottlenecks
|
||||
|
||||
## Continuous Performance Testing
|
||||
|
||||
```bash
|
||||
# Save baseline results
|
||||
./build/src/libstore-tests/nix-store-benchmarks --benchmark_format=json > baseline.json
|
||||
|
||||
# Compare against baseline in CI
|
||||
./build/src/libstore-tests/nix-store-benchmarks --benchmark_baseline=baseline.json
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Benchmarks not building
|
||||
|
||||
Ensure benchmarks are enabled:
|
||||
```bash
|
||||
meson configure build | grep benchmarks
|
||||
# Should show: benchmarks true
|
||||
```
|
||||
|
||||
### Inconsistent results
|
||||
|
||||
- Ensure your system is not under heavy load
|
||||
- Disable CPU frequency scaling for consistent results
|
||||
- Run benchmarks multiple times with `--benchmark_repetitions`
|
||||
|
||||
## See Also
|
||||
|
||||
- [Google Benchmark documentation](https://github.com/google/benchmark/blob/main/docs/user_guide.md)
|
||||
@@ -23,18 +23,18 @@ $ nix-shell
|
||||
To get a shell with one of the other [supported compilation environments](#compilation-environments):
|
||||
|
||||
```console
|
||||
$ nix-shell --attr devShells.x86_64-linux.native-clangStdenv
|
||||
$ nix-shell --attr devShells.x86_64-linux.native-clangStdenvPackages
|
||||
```
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> You can use `native-ccacheStdenv` to drastically improve rebuild time.
|
||||
> You can use `native-ccacheStdenvPackages` to drastically improve rebuild time.
|
||||
> By default, [ccache](https://ccache.dev) keeps artifacts in `~/.cache/ccache/`.
|
||||
|
||||
To build Nix itself in this shell:
|
||||
|
||||
```console
|
||||
[nix-shell]$ out="$(pwd)/outputs/out" dev=$out debug=$out mesonFlags+=" --prefix=${out}"
|
||||
[nix-shell]$ mesonFlags+=" --prefix=$(pwd)/outputs/out"
|
||||
[nix-shell]$ dontAddPrefix=1 configurePhase
|
||||
[nix-shell]$ buildPhase
|
||||
```
|
||||
@@ -66,7 +66,7 @@ You can also build Nix for one of the [supported platforms](#platforms).
|
||||
This section assumes you are using Nix with the [`flakes`] and [`nix-command`] experimental features enabled.
|
||||
|
||||
[`flakes`]: @docroot@/development/experimental-features.md#xp-feature-flakes
|
||||
[`nix-command`]: @docroot@/development/experimental-features.md#xp-feature-nix-command
|
||||
[`nix-command`]: @docroot@/development/experimental-features.md#xp-nix-command
|
||||
|
||||
To build all dependencies and start a shell in which all environment variables are set up so that those dependencies can be found:
|
||||
|
||||
@@ -79,7 +79,7 @@ This shell also adds `./outputs/bin/nix` to your `$PATH` so you can run `nix` im
|
||||
To get a shell with one of the other [supported compilation environments](#compilation-environments):
|
||||
|
||||
```console
|
||||
$ nix develop .#native-clangStdenv
|
||||
$ nix develop .#native-clangStdenvPackages
|
||||
```
|
||||
|
||||
> **Note**
|
||||
@@ -167,13 +167,11 @@ It is useful to perform multiple cross and native builds on the same source tree
|
||||
for example to ensure that better support for one platform doesn't break the build for another.
|
||||
Meson thankfully makes this very easy by confining all build products to the build directory --- one simple shares the source directory between multiple build directories, each of which contains the build for Nix to a different platform.
|
||||
|
||||
Here's how to do that:
|
||||
Nixpkgs's `configurePhase` always chooses `build` in the current directory as the name and location of the build.
|
||||
This makes having multiple build directories slightly more inconvenient.
|
||||
The good news is that Meson/Ninja seem to cope well with relocating the build directory after it is created.
|
||||
|
||||
1. Instruct Nixpkgs's infra where we want Meson to put its build directory
|
||||
|
||||
```bash
|
||||
mesonBuildDir=build-my-variant-name
|
||||
```
|
||||
Here's how to do that
|
||||
|
||||
1. Configure as usual
|
||||
|
||||
@@ -181,12 +179,24 @@ Here's how to do that:
|
||||
configurePhase
|
||||
```
|
||||
|
||||
2. Rename the build directory
|
||||
|
||||
```bash
|
||||
cd .. # since `configurePhase` cd'd inside
|
||||
mv build build-linux # or whatever name we want
|
||||
cd build-linux
|
||||
```
|
||||
|
||||
3. Build as usual
|
||||
|
||||
```bash
|
||||
buildPhase
|
||||
```
|
||||
|
||||
> **N.B.**
|
||||
> [`nixpkgs#335818`](https://github.com/NixOS/nixpkgs/issues/335818) tracks giving `mesonConfigurePhase` proper support for custom build directories.
|
||||
> When it is fixed, we can simplify these instructions and then remove this notice.
|
||||
|
||||
## System type
|
||||
|
||||
Nix uses a string with the following format to identify the *system type* or *platform* it runs on:
|
||||
@@ -195,38 +205,28 @@ Nix uses a string with the following format to identify the *system type* or *pl
|
||||
<cpu>-<os>[-<abi>]
|
||||
```
|
||||
|
||||
It is set when Nix is compiled for the given system, and based on the output of Meson's [`host_machine` information](https://mesonbuild.com/Reference-manual_builtin_host_machine.html)>
|
||||
It is set when Nix is compiled for the given system, and based on the output of [`config.guess`](https://github.com/nixos/nix/blob/master/config/config.guess) ([upstream](https://git.savannah.gnu.org/cgit/config.git/tree/config.guess)):
|
||||
|
||||
```
|
||||
<cpu>-<vendor>-<os>[<version>][-<abi>]
|
||||
```
|
||||
|
||||
When cross-compiling Nix with Meson for local development, you need to specify a [cross-file](https://mesonbuild.com/Cross-compilation.html) using the `--cross-file` option. Cross-files define the target architecture and toolchain. When cross-compiling Nix with Nix, Nixpkgs takes care of this for you.
|
||||
|
||||
In the nix flake we also have some cross-compilation targets available:
|
||||
When Nix is built such that `./configure` is passed any of the `--host`, `--build`, `--target` options, the value is based on the output of [`config.sub`](https://github.com/nixos/nix/blob/master/config/config.sub) ([upstream](https://git.savannah.gnu.org/cgit/config.git/tree/config.sub)):
|
||||
|
||||
```
|
||||
nix build .#nix-everything-riscv64-unknown-linux-gnu
|
||||
nix build .#nix-everything-armv7l-unknown-linux-gnueabihf
|
||||
nix build .#nix-everything-armv7l-unknown-linux-gnueabihf
|
||||
nix build .#nix-everything-x86_64-unknown-freebsd
|
||||
nix build .#nix-everything-x86_64-w64-mingw32
|
||||
<cpu>-<vendor>[-<kernel>]-<os>
|
||||
```
|
||||
|
||||
For historic reasons and backward-compatibility, some CPU and OS identifiers are translated as follows:
|
||||
For historic reasons and backward-compatibility, some CPU and OS identifiers are translated from the GNU Autotools naming convention in [`configure.ac`](https://github.com/nixos/nix/blob/master/configure.ac) as follows:
|
||||
|
||||
| `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` |
|
||||
| `config.guess` | Nix |
|
||||
|----------------------------|---------------------|
|
||||
| `amd64` | `x86_64` |
|
||||
| `i*86` | `i686` |
|
||||
| `arm6` | `arm6l` |
|
||||
| `arm7` | `arm7l` |
|
||||
| `linux-gnu*` | `linux` |
|
||||
| `linux-musl*` | `linux` |
|
||||
|
||||
## Compilation environments
|
||||
|
||||
@@ -240,29 +240,28 @@ Nix can be compiled using multiple environments:
|
||||
To build with one of those environments, you can use
|
||||
|
||||
```console
|
||||
$ nix build .#nix-cli-ccacheStdenv
|
||||
$ nix build .#nix-ccacheStdenv
|
||||
```
|
||||
|
||||
for flake-enabled Nix, or
|
||||
|
||||
```console
|
||||
$ nix-build --attr nix-cli-ccacheStdenv
|
||||
$ nix-build --attr nix-ccacheStdenv
|
||||
```
|
||||
|
||||
for classic Nix.
|
||||
|
||||
You can use any of the other supported environments in place of `nix-cli-ccacheStdenv`.
|
||||
You can use any of the other supported environments in place of `nix-ccacheStdenv`.
|
||||
|
||||
## Editor integration
|
||||
|
||||
The `clangd` LSP server is installed by default on the `clang`-based `devShell`s.
|
||||
See [supported compilation environments](#compilation-environments) and instructions how to set up a shell [with flakes](#building-nix-with-flakes) or in [classic Nix](#building-nix).
|
||||
See [supported compilation environments](#compilation-environments) and instructions how to set up a shell [with flakes](#nix-with-flakes) or in [classic Nix](#classic-nix).
|
||||
|
||||
To use the LSP with your editor, you will want a `compile_commands.json` file telling `clangd` how we are compiling the code.
|
||||
Meson's configure always produces this inside the build directory.
|
||||
|
||||
Configure your editor to use the `clangd` from the `.#native-clangStdenv` shell.
|
||||
You can do that either by running it inside the development shell, or by using [nix-direnv](https://github.com/nix-community/nix-direnv) and [the appropriate editor plugin](https://github.com/direnv/direnv/wiki#editor-integration).
|
||||
Configure your editor to use the `clangd` from the `.#native-clangStdenvPackages` shell. You can do that either by running it inside the development shell, or by using [nix-direnv](https://github.com/nix-community/nix-direnv) and [the appropriate editor plugin](https://github.com/direnv/direnv/wiki#editor-integration).
|
||||
|
||||
> **Note**
|
||||
>
|
||||
@@ -278,8 +277,6 @@ You may run the formatters as a one-off using:
|
||||
./maintainers/format.sh
|
||||
```
|
||||
|
||||
### Pre-commit hooks
|
||||
|
||||
If you'd like to run the formatters before every commit, install the hooks:
|
||||
|
||||
```
|
||||
@@ -294,30 +291,3 @@ If it fails, run `git add --patch` to approve the suggestions _and commit again_
|
||||
To refresh pre-commit hook's config file, do the following:
|
||||
1. Exit the development shell and start it again by running `nix develop`.
|
||||
2. If you also use the pre-commit hook, also run `pre-commit-hooks-install` again.
|
||||
|
||||
### VSCode
|
||||
|
||||
Insert the following json into your `.vscode/settings.json` file to configure `nixfmt`.
|
||||
This will be picked up by the _Format Document_ command, `"editor.formatOnSave"`, etc.
|
||||
|
||||
```json
|
||||
{
|
||||
"nix.formatterPath": "nixfmt",
|
||||
"nix.serverSettings": {
|
||||
"nixd": {
|
||||
"formatting": {
|
||||
"command": [
|
||||
"nixfmt"
|
||||
],
|
||||
},
|
||||
},
|
||||
"nil": {
|
||||
"formatting": {
|
||||
"command": [
|
||||
"nixfmt"
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
@@ -170,9 +170,9 @@ sensitive.
|
||||
|
||||
|
||||
```shell
|
||||
$ nix init --template=template#python
|
||||
$ nix init --template=template#pyton
|
||||
------------------------------------------------------------------------
|
||||
Error! Template `template#python` not found.
|
||||
Error! Template `template#pyton` not found.
|
||||
------------------------------------------------------------------------
|
||||
Initializing Nix project at `/path/to/here`.
|
||||
Select a template for you new project:
|
||||
|
||||
@@ -20,9 +20,8 @@ prs: 1238
|
||||
Here's one or more paragraphs that describe the change.
|
||||
|
||||
- It's markdown
|
||||
- Add references to the manual using [links like this](@_at_docroot@/example.md)
|
||||
- Add references to the manual using @docroot@
|
||||
```
|
||||
<!-- for the raw markdown readers: that means using @docroot@ -->
|
||||
|
||||
Significant changes should add the following header, which moves them to the top.
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
This section shows how to build and debug Nix with debug symbols enabled.
|
||||
|
||||
Additionally, see [Testing Nix](./testing.md) for further instructions on how to debug Nix in the context of a unit test or functional test.
|
||||
|
||||
## Building Nix with Debug Symbols
|
||||
|
||||
In the development shell, set the `mesonBuildType` environment variable to `debug` before configuring the build:
|
||||
@@ -15,28 +13,6 @@ In the development shell, set the `mesonBuildType` environment variable to `debu
|
||||
Then, proceed to build Nix as described in [Building Nix](./building.md).
|
||||
This will build Nix with debug symbols, which are essential for effective debugging.
|
||||
|
||||
It is also possible to build without optimization for faster build:
|
||||
|
||||
```console
|
||||
[nix-shell]$ NIX_HARDENING_ENABLE=$(printLines $NIX_HARDENING_ENABLE | grep -v fortify)
|
||||
[nix-shell]$ export mesonBuildType=debug
|
||||
```
|
||||
|
||||
(The first line is needed because `fortify` hardening requires at least some optimization.)
|
||||
|
||||
## Building Nix with sanitizers
|
||||
|
||||
Nix can be built with [Address](https://clang.llvm.org/docs/AddressSanitizer.html) and
|
||||
[UB](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html) sanitizers using LLVM
|
||||
or GCC. This is useful when debugging memory corruption issues.
|
||||
|
||||
```console
|
||||
[nix-shell]$ export mesonBuildType=debugoptimized
|
||||
[nix-shell]$ appendToVar mesonFlags "-Dlibexpr:gc=disabled" # Disable Boehm
|
||||
[nix-shell]$ appendToVar mesonFlags "-Dbindings=false" # Disable nix-perl
|
||||
[nix-shell]$ appendToVar mesonFlags "-Db_sanitize=address,undefined"
|
||||
```
|
||||
|
||||
## Debugging the Nix Binary
|
||||
|
||||
Obtain your preferred debugger within the development shell:
|
||||
|
||||
@@ -25,31 +25,20 @@ nix build .#nix-manual
|
||||
and open `./result/share/doc/nix/manual/index.html`.
|
||||
|
||||
|
||||
To build the manual incrementally, [enter the development shell](./building.md) and configure with `doc-gen` enabled:
|
||||
|
||||
**If using interactive `nix develop`:**
|
||||
To build the manual incrementally, [enter the development shell](./building.md) and run:
|
||||
|
||||
```console
|
||||
$ nix develop
|
||||
$ mesonFlags="$mesonFlags -Ddoc-gen=true" mesonConfigurePhase
|
||||
make manual-html-open -j $NIX_BUILD_CORES
|
||||
```
|
||||
|
||||
**If using direnv:**
|
||||
In order to reflect changes to the [Makefile for the manual], clear all generated files before re-building:
|
||||
|
||||
[Makefile for the manual]: https://github.com/NixOS/nix/blob/master/doc/manual/local.mk
|
||||
|
||||
```console
|
||||
$ direnv allow
|
||||
$ bash -c 'source $stdenv/setup && mesonFlags="$mesonFlags -Ddoc-gen=true" mesonConfigurePhase'
|
||||
rm $(git ls-files doc/manual/ -o | grep -F '.md') && rmdir doc/manual/source/command-ref/new-cli && make manual-html -j $NIX_BUILD_CORES
|
||||
```
|
||||
|
||||
Then build the manual:
|
||||
|
||||
```console
|
||||
$ cd build
|
||||
$ meson compile manual
|
||||
```
|
||||
|
||||
The HTML manual will be generated at `build/src/nix-manual/manual/index.html`.
|
||||
|
||||
## Style guide
|
||||
|
||||
The goal of this style guide is to make it such that
|
||||
@@ -240,9 +229,3 @@ $ configurePhase
|
||||
$ ninja src/external-api-docs/html
|
||||
$ xdg-open src/external-api-docs/html/index.html
|
||||
```
|
||||
|
||||
If you use direnv, or otherwise want to run `configurePhase` in a transient shell, use:
|
||||
|
||||
```bash
|
||||
nix-shell -A devShells.x86_64-linux.native-clangStdenv --command 'appendToVar mesonFlags "-Ddoc-gen=true"; mesonConfigurePhase'
|
||||
```
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
experimental_feature_descriptions_md = custom_target(
|
||||
command : nix_eval_for_docs + [
|
||||
'--expr', 'import @INPUT0@ (builtins.fromJSON (builtins.readFile @INPUT1@))',
|
||||
'--expr',
|
||||
'import @INPUT0@ (builtins.fromJSON (builtins.readFile @INPUT1@))',
|
||||
],
|
||||
input : [
|
||||
'../../generate-xp-features.nix',
|
||||
xp_features_json,
|
||||
],
|
||||
capture : true,
|
||||
env : nix_env_for_docs,
|
||||
output : 'experimental-feature-descriptions.md',
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ The unit tests are defined using the [googletest] and [rapidcheck] frameworks.
|
||||
> src
|
||||
> ├── libexpr
|
||||
> │ ├── meson.build
|
||||
> │ ├── include/nix/expr/value/context.hh
|
||||
> │ ├── value/context.hh
|
||||
> │ ├── value/context.cc
|
||||
> │ …
|
||||
> │
|
||||
@@ -46,12 +46,8 @@ The unit tests are defined using the [googletest] and [rapidcheck] frameworks.
|
||||
> │ │
|
||||
> │ ├── libexpr-test-support
|
||||
> │ │ ├── meson.build
|
||||
> │ │ ├── include/nix/expr
|
||||
> │ │ │ ├── meson.build
|
||||
> │ │ │ └── tests
|
||||
> │ │ │ ├── value/context.hh
|
||||
> │ │ │ …
|
||||
> │ │ └── tests
|
||||
> │ │ ├── value/context.hh
|
||||
> │ │ ├── value/context.cc
|
||||
> │ │ …
|
||||
> │ │
|
||||
@@ -63,7 +59,7 @@ The unit tests are defined using the [googletest] and [rapidcheck] frameworks.
|
||||
> ```
|
||||
|
||||
The tests for each Nix library (`libnixexpr`, `libnixstore`, etc..) live inside a directory `src/${library_name_without-nix}-test`.
|
||||
Given an interface (header) and implementation pair in the original library, say, `src/libexpr/include/nix/expr/value/context.hh` and `src/libexpr/value/context.cc`, we write tests for it in `src/libexpr-tests/value/context.cc`, and (possibly) declare/define additional interfaces for testing purposes in `src/libexpr-test-support/include/nix/expr/tests/value/context.hh` and `src/libexpr-test-support/tests/value/context.cc`.
|
||||
Given an interface (header) and implementation pair in the original library, say, `src/libexpr/value/context.{hh,cc}`, we write tests for it in `src/libexpr-tests/value/context.cc`, and (possibly) declare/define additional interfaces for testing purposes in `src/libexpr-test-support/tests/value/context.{hh,cc}`.
|
||||
|
||||
Data for unit tests is stored in a `data` subdir of the directory for each unit test executable.
|
||||
For example, `libnixstore` code is in `src/libstore`, and its test data is in `src/libstore-tests/data`.
|
||||
@@ -71,7 +67,7 @@ The path to the `src/${library_name_without-nix}-test/data` directory is passed
|
||||
Note that each executable only gets the data for its tests.
|
||||
|
||||
The unit test libraries are in `src/${library_name_without-nix}-test-support`.
|
||||
All headers are in a `tests` subdirectory so they are included with `#include "nix/tests/"`.
|
||||
All headers are in a `tests` subdirectory so they are included with `#include "tests/"`.
|
||||
|
||||
The use of all these separate directories for the unit tests might seem inconvenient, as for example the tests are not "right next to" the part of the code they are testing.
|
||||
But organizing the tests this way has one big benefit:
|
||||
@@ -91,11 +87,7 @@ A environment variables that Google Test accepts are also worth knowing:
|
||||
|
||||
This is used to avoid logging passing tests.
|
||||
|
||||
3. [`GTEST_BREAK_ON_FAILURE`](https://google.github.io/googletest/advanced.html#turning-assertion-failures-into-break-points)
|
||||
|
||||
This is used to create a debugger breakpoint when an assertion failure occurs.
|
||||
|
||||
Putting the first two together, one might run
|
||||
Putting the two together, one might run
|
||||
|
||||
```bash
|
||||
GTEST_BRIEF=1 GTEST_FILTER='ErrorTraceTest.*' meson test nix-expr-tests -v
|
||||
@@ -103,23 +95,7 @@ GTEST_BRIEF=1 GTEST_FILTER='ErrorTraceTest.*' meson test nix-expr-tests -v
|
||||
|
||||
for short but comprensive output.
|
||||
|
||||
### Debugging tests
|
||||
|
||||
For debugging, it is useful to combine the third option above with Meson's [`--gdb`](https://mesonbuild.com/Unit-tests.html#other-test-options) flag:
|
||||
|
||||
```bash
|
||||
GTEST_BRIEF=1 GTEST_FILTER='Group.my-failing-test' meson test nix-expr-tests --gdb
|
||||
```
|
||||
|
||||
This will:
|
||||
|
||||
1. Run the unit test with GDB
|
||||
|
||||
2. Run just `Group.my-failing-test`
|
||||
|
||||
3. Stop the program when the test fails, allowing the user to then issue arbitrary commands to GDB.
|
||||
|
||||
### Characterisation testing { #characterisation-testing-unit }
|
||||
### Characterisation testing { #characaterisation-testing-unit }
|
||||
|
||||
See [functional characterisation testing](#characterisation-testing-functional) for a broader discussion of characterisation testing.
|
||||
|
||||
@@ -137,12 +113,6 @@ $ _NIX_TEST_ACCEPT=1 meson test nix-store-tests -v
|
||||
will regenerate the "golden master" expected result for the `libnixstore` characterisation tests.
|
||||
The characterisation tests will mark themselves "skipped" since they regenerated the expected result instead of actually testing anything.
|
||||
|
||||
### JSON Schema testing
|
||||
|
||||
In `doc/manual/source/protocols/json/` we have a number of manual pages generated from [JSON Schema](https://json-schema.org/).
|
||||
That JSON schema is tested against the JSON file test data used in [characterisation tests](#characterisation-testing-unit ) for JSON (de)serialization, in `src/json-schema-checks`.
|
||||
Between the JSON (de)serialization testing, and this testing of the same data against the schema, we make sure that the manual, the implementation, and a machine-readable schema are are all in sync.
|
||||
|
||||
### Unit test support libraries
|
||||
|
||||
There are headers and code which are not just used to test the library in question, but also downstream libraries.
|
||||
@@ -174,7 +144,7 @@ $ checkPhase
|
||||
|
||||
Sometimes it is useful to group related tests so they can be easily run together without running the entire test suite.
|
||||
Each test group is in a subdirectory of `tests`.
|
||||
For example, `tests/functional/ca/meson.build` defines a `ca` test group for content-addressing derivation outputs.
|
||||
For example, `tests/functional/ca/meson.build` defines a `ca` test group for content-addressed derivation outputs.
|
||||
|
||||
That test group can be run like this:
|
||||
|
||||
@@ -243,10 +213,10 @@ edit it like so:
|
||||
bar
|
||||
```
|
||||
|
||||
Then, running the test with [`--interactive`](https://mesonbuild.com/Unit-tests.html#other-test-options) will prevent Meson from hijacking the terminal so you can drop you into GDB once the script reaches that point:
|
||||
Then, running the test with `./mk/debug-test.sh` will drop you into GDB once the script reaches that point:
|
||||
|
||||
```shell-session
|
||||
$ meson test ${testName} --interactive
|
||||
$ ./mk/debug-test.sh tests/functional/${testName}.sh
|
||||
...
|
||||
+ gdb blash blub
|
||||
GNU gdb (GDB) 12.1
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
# Glossary
|
||||
|
||||
- [build system]{#gloss-build-system}
|
||||
|
||||
Generic term for software that facilitates the building of software by automating the invocation of compilers, linkers, and other tools.
|
||||
|
||||
Nix can be used as a generic build system.
|
||||
It has no knowledge of any particular programming language or toolchain.
|
||||
These details are specified in [derivation expressions](#gloss-derivation-expression).
|
||||
|
||||
- [content address]{#gloss-content-address}
|
||||
|
||||
A
|
||||
@@ -21,62 +13,37 @@
|
||||
|
||||
- [Content-Addressing File System Objects](@docroot@/store/file-system-object/content-address.md)
|
||||
- [Content-Addressing Store Objects](@docroot@/store/store-object/content-address.md)
|
||||
- [content-addressing derivation](#gloss-content-addressing-derivation)
|
||||
- [content-addressed derivation](#gloss-content-addressed-derivation)
|
||||
|
||||
Software Heritage's writing on [*Intrinsic and Extrinsic identifiers*](https://www.softwareheritage.org/2020/07/09/intrinsic-vs-extrinsic-identifiers) is also a good introduction to the value of content-addressing over other referencing schemes.
|
||||
|
||||
Besides content addressing, the Nix store also uses [input addressing](#gloss-input-addressed-store-object).
|
||||
|
||||
- [content-addressed storage]{#gloss-content-addressed-store}
|
||||
|
||||
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].
|
||||
A description of a build task. The result of a derivation is a
|
||||
store object. Derivations declared in Nix expressions are specified
|
||||
using the [`derivation` primitive](./language/derivations.md). These are
|
||||
translated into low-level *store derivations* (implicitly by
|
||||
`nix-build`, or explicitly by `nix-instantiate`).
|
||||
|
||||
[derivation]: #gloss-derivation
|
||||
|
||||
- [store derivation]{#gloss-store-derivation}
|
||||
|
||||
A [derivation] represented as a [store object].
|
||||
A [derivation] represented as a `.drv` file in the [store].
|
||||
It has a [store path], like any [store object].
|
||||
It is the [instantiated][instantiate] form of a derivation.
|
||||
|
||||
See [Store Derivation](@docroot@/store/derivation/index.md#store-derivation) for details.
|
||||
Example: `/nix/store/g946hcz4c8mdvq2g8vxx42z51qb71rvp-git-2.38.1.drv`
|
||||
|
||||
See [`nix derivation show`](./command-ref/new-cli/nix3-derivation-show.md) (experimental) for displaying the contents of store derivations.
|
||||
|
||||
[store derivation]: #gloss-store-derivation
|
||||
|
||||
- [directed acyclic graph]{#gloss-directed-acyclic-graph}
|
||||
|
||||
A [directed acyclic graph](https://en.wikipedia.org/wiki/Directed_acyclic_graph) (DAG) is graph whose edges are given a direction ("a to b" is not the same edge as "b to a"), and for which no possible path (created by joining together edges) forms a cycle.
|
||||
|
||||
DAGs are very important to Nix.
|
||||
In particular, the non-self-[references][reference] of [store object][store object] form a cycle.
|
||||
|
||||
- [derivation path]{#gloss-derivation-path}
|
||||
|
||||
A [store path] which uniquely identifies a [store derivation].
|
||||
|
||||
See [Referencing Store Derivations](@docroot@/store/derivation/index.md#derivation-path) for details.
|
||||
|
||||
Not to be confused with [deriving path].
|
||||
|
||||
[derivation path]: #gloss-derivation-path
|
||||
|
||||
- [derivation expression]{#gloss-derivation-expression}
|
||||
|
||||
A description of a [store derivation] using the [`derivation` primitive](./language/derivations.md) in the [Nix language].
|
||||
|
||||
[derivation expression]: #gloss-derivation-expression
|
||||
|
||||
- [instantiate]{#gloss-instantiate}, instantiation
|
||||
|
||||
Translate a [derivation expression] into a [store derivation].
|
||||
Save an evaluated [derivation] as a [store derivation] in the Nix [store].
|
||||
|
||||
See [`nix-instantiate`](./command-ref/nix-instantiate.md), which produces a store derivation from a Nix expression that evaluates to a derivation.
|
||||
|
||||
@@ -88,8 +55,9 @@
|
||||
|
||||
This can be achieved by:
|
||||
- Fetching a pre-built [store object] from a [substituter]
|
||||
- [Building](@docroot@/store/building.md) the corresponding [store derivation]
|
||||
- Running the [`builder`](@docroot@/language/derivations.md#attr-builder) executable as specified in the corresponding [derivation]
|
||||
- Delegating to a [remote machine](@docroot@/command-ref/conf-file.md#conf-builders) and retrieving the outputs
|
||||
<!-- TODO: link [running] to build process page, #8888 -->
|
||||
|
||||
See [`nix-store --realise`](@docroot@/command-ref/nix-store/realise.md) for a detailed description of the algorithm.
|
||||
|
||||
@@ -97,7 +65,7 @@
|
||||
|
||||
[realise]: #gloss-realise
|
||||
|
||||
- [content-addressing derivation]{#gloss-content-addressing-derivation}
|
||||
- [content-addressed derivation]{#gloss-content-addressed-derivation}
|
||||
|
||||
A derivation which has the
|
||||
[`__contentAddressed`](./language/advanced-attributes.md#adv-attr-__contentAddressed)
|
||||
@@ -105,7 +73,7 @@
|
||||
|
||||
- [fixed-output derivation]{#gloss-fixed-output-derivation} (FOD)
|
||||
|
||||
A [store derivation] where a cryptographic hash of the [output] is determined in advance using the [`outputHash`](./language/advanced-attributes.md#adv-attr-outputHash) attribute, and where the [`builder`](@docroot@/language/derivations.md#attr-builder) executable has access to the network.
|
||||
A [derivation] where a cryptographic hash of the [output] is determined in advance using the [`outputHash`](./language/advanced-attributes.md#adv-attr-outputHash) attribute, and where the [`builder`](@docroot@/language/derivations.md#attr-builder) executable has access to the network.
|
||||
|
||||
- [store]{#gloss-store}
|
||||
|
||||
@@ -116,12 +84,6 @@
|
||||
|
||||
[store]: #gloss-store
|
||||
|
||||
- [Nix instance]{#gloss-nix-instance}
|
||||
<!-- ambiguous -->
|
||||
1. An installation of Nix, which includes the presence of a [store], and the Nix package manager which operates on that store.
|
||||
A local Nix installation and a [remote builder](@docroot@/advanced-topics/distributed-builds.md) are two examples of Nix instances.
|
||||
2. A running Nix process, such as the `nix` command.
|
||||
|
||||
- [binary cache]{#gloss-binary-cache}
|
||||
|
||||
A *binary cache* is a Nix store which uses a different format: its
|
||||
@@ -168,17 +130,15 @@
|
||||
- [input-addressed store object]{#gloss-input-addressed-store-object}
|
||||
|
||||
A store object produced by building a
|
||||
non-[content-addressed](#gloss-content-addressing-derivation),
|
||||
non-[content-addressed](#gloss-content-addressed-derivation),
|
||||
non-[fixed-output](#gloss-fixed-output-derivation)
|
||||
derivation.
|
||||
|
||||
See [input-addressing derivation outputs](store/derivation/outputs/input-address.md) for details.
|
||||
|
||||
- [content-addressed store object]{#gloss-content-addressed-store-object}
|
||||
|
||||
A [store object] which is [content-addressed](#gloss-content-address),
|
||||
i.e. whose [store path] is determined by its contents.
|
||||
This includes derivations, the outputs of [content-addressing derivations](#gloss-content-addressing-derivation), and the outputs of [fixed-output derivations](#gloss-fixed-output-derivation).
|
||||
This includes derivations, the outputs of [content-addressed derivations](#gloss-content-addressed-derivation), and the outputs of [fixed-output derivations](#gloss-fixed-output-derivation).
|
||||
|
||||
See [Content-Addressing Store Objects](@docroot@/store/store-object/content-address.md) for details.
|
||||
|
||||
@@ -208,7 +168,7 @@
|
||||
|
||||
- [impure derivation]{#gloss-impure-derivation}
|
||||
|
||||
[An experimental feature](@docroot@/development/experimental-features.md#xp-feature-impure-derivations) that allows derivations to be explicitly marked as impure,
|
||||
[An experimental feature](#@docroot@/development/experimental-features.md#xp-feature-impure-derivations) that allows derivations to be explicitly marked as impure,
|
||||
so that they are always rebuilt, and their outputs not reused by subsequent calls to realise them.
|
||||
|
||||
- [Nix database]{#gloss-nix-database}
|
||||
@@ -228,37 +188,35 @@
|
||||
>
|
||||
> The contents of a `.nix` file form a Nix expression.
|
||||
|
||||
Nix expressions specify [derivation expressions][derivation expression], which are [instantiated][instantiate] into the Nix store as [store derivations][store derivation].
|
||||
Nix expressions specify [derivations][derivation], which are [instantiated][instantiate] into the Nix store as [store derivations][store derivation].
|
||||
These derivations can then be [realised][realise] to produce [outputs][output].
|
||||
|
||||
> **Example**
|
||||
>
|
||||
> Building and deploying software using Nix entails writing Nix expressions to describe [packages][package] and compositions thereof.
|
||||
> Building and deploying software using Nix entails writing Nix expressions as a high-level description of packages and compositions thereof.
|
||||
|
||||
- [reference]{#gloss-reference}
|
||||
|
||||
An edge from one [store object] to another.
|
||||
A [store object] `O` is said to have a *reference* to a store object `P` if a [store path] to `P` appears in the contents of `O`.
|
||||
|
||||
See [References](@docroot@/store/store-object.md#references) for details.
|
||||
Store objects can refer to both other store objects and themselves.
|
||||
References from a store object to itself are called *self-references*.
|
||||
References other than a self-reference must not form a cycle.
|
||||
|
||||
[reference]: #gloss-reference
|
||||
|
||||
See [References](@docroot@/store/store-object.md#references) for details.
|
||||
|
||||
- [reachable]{#gloss-reachable}
|
||||
|
||||
A store path `Q` is reachable from another store path `P` if `Q`
|
||||
is in the *closure* of the *references* relation.
|
||||
|
||||
See [References](@docroot@/store/store-object.md#references) for details.
|
||||
|
||||
- [closure]{#gloss-closure}
|
||||
|
||||
The closure of a store path is the set of store paths that are
|
||||
directly or indirectly “reachable” from that store path; that is,
|
||||
it’s the closure of the path under the *references* relation. For
|
||||
a package, the closure of its derivation is equivalent to the
|
||||
build-time dependencies, while the closure of its [output path] is
|
||||
build-time dependencies, while the closure of its output path is
|
||||
equivalent to its runtime dependencies. For correct deployment it
|
||||
is necessary to deploy whole closures, since otherwise at runtime
|
||||
files could be missing. The command `nix-store --query --requisites ` prints out
|
||||
@@ -268,31 +226,18 @@
|
||||
to a store object at path `Q`, then `Q` is in the closure of `P`. Further, if `Q`
|
||||
references `R` then `R` is also in the closure of `P`.
|
||||
|
||||
See [References](@docroot@/store/store-object.md#references) for details.
|
||||
|
||||
[closure]: #gloss-closure
|
||||
|
||||
- [requisite]{#gloss-requisite}
|
||||
|
||||
A store object [reachable] by a path (chain of references) from a given [store object].
|
||||
The [closure] is the set of requisites.
|
||||
|
||||
See [References](@docroot@/store/store-object.md#references) for details.
|
||||
|
||||
- [referrer]{#gloss-referrer}
|
||||
|
||||
A reversed edge from one [store object] to another.
|
||||
|
||||
- [output]{#gloss-output}
|
||||
|
||||
A [store object] produced by a [store derivation].
|
||||
A [store object] produced by a [derivation].
|
||||
See [the `outputs` argument to the `derivation` function](@docroot@/language/derivations.md#attr-outputs) for details.
|
||||
|
||||
[output]: #gloss-output
|
||||
|
||||
- [output path]{#gloss-output-path}
|
||||
|
||||
The [store path] to the [output] of a [store derivation].
|
||||
The [store path] to the [output] of a [derivation].
|
||||
|
||||
[output path]: #gloss-output-path
|
||||
|
||||
@@ -301,11 +246,14 @@
|
||||
|
||||
- [deriving path]{#gloss-deriving-path}
|
||||
|
||||
Deriving paths are a way to refer to [store objects][store object] that might not yet be [realised][realise].
|
||||
Deriving paths are a way to refer to [store objects][store object] that ar not yet [realised][realise].
|
||||
This is necessary because, in general and particularly for [content-addressed derivations][content-addressed derivation], the [output path] of an [output] is not known in advance.
|
||||
There are two forms:
|
||||
|
||||
See [Deriving Path](./store/derivation/index.md#deriving-path) for details.
|
||||
- *constant*: just a [store path]
|
||||
It can be made [valid][validity] by copying it into the store: from the evaluator, command line interface or another store.
|
||||
|
||||
Not to be confused with [derivation path].
|
||||
- *output*: a pair of a [store path] to a [derivation] and an [output] name.
|
||||
|
||||
- [deriver]{#gloss-deriver}
|
||||
|
||||
@@ -353,7 +301,7 @@
|
||||
|
||||
See [Nix Archive](store/file-system-object/content-address.html#serial-nix-archive) for details.
|
||||
|
||||
- [`∅`]{#gloss-empty-set}
|
||||
- [`∅`]{#gloss-emtpy-set}
|
||||
|
||||
The empty set symbol. In the context of profile history, this denotes a package is not present in a particular version of the profile.
|
||||
|
||||
@@ -363,17 +311,18 @@
|
||||
|
||||
- [package]{#package}
|
||||
|
||||
A software package; files that belong together for a particular purpose, and metadata.
|
||||
1. A software package; a collection of files and other data.
|
||||
|
||||
Nix represents files as [file system objects][file system object], and how they belong together is encoded as [references][reference] between [store objects][store object] that contain these file system objects.
|
||||
2. A [package attribute set].
|
||||
|
||||
The [Nix language] allows denoting packages in terms of [attribute sets](@docroot@/language/types.md#type-attrs) containing:
|
||||
- attributes that refer to the files of a package, typically in the form of [derivation outputs](#gloss-output),
|
||||
- attributes with metadata, such as information about how the package is supposed to be used.
|
||||
- [package attribute set]{#package-attribute-set}
|
||||
|
||||
The exact shape of these attribute sets is up to convention.
|
||||
An [attribute set](@docroot@/language/types.md#attribute-set) containing the attribute `type = "derivation";` (derivation for historical reasons), as well as other attributes, such as
|
||||
- attributes that refer to the files of a [package], typically in the form of [derivation outputs](#output),
|
||||
- attributes that declare something about how the package is supposed to be installed or used,
|
||||
- other metadata or arbitrary attributes.
|
||||
|
||||
[package]: #package
|
||||
[package attribute set]: #package-attribute-set
|
||||
|
||||
- [string interpolation]{#gloss-string-interpolation}
|
||||
|
||||
@@ -383,7 +332,7 @@
|
||||
|
||||
[string]: ./language/types.md#type-string
|
||||
[path]: ./language/types.md#type-path
|
||||
[attribute name]: ./language/types.md#type-attrs
|
||||
[attribute name]: ./language/types.md#attribute-set
|
||||
|
||||
- [base directory]{#gloss-base-directory}
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@ $ curl -L https://nixos.org/nix/install | sh -s -- --daemon
|
||||
|
||||
> Single-user is not supported on Mac.
|
||||
|
||||
> `warning: installing Nix as root is not supported by this script!`
|
||||
|
||||
This installation has less requirements than the multi-user install, however it
|
||||
cannot offer equivalent sharing, isolation, or security.
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ This performs the default type of installation for your platform:
|
||||
|
||||
We recommend the multi-user installation if it supports your platform and you can authenticate with `sudo`.
|
||||
|
||||
The installer can be configured with various command line arguments and environment variables.
|
||||
The installer can configured with various command line arguments and environment variables.
|
||||
To show available command line flags:
|
||||
|
||||
```console
|
||||
|
||||
@@ -3,21 +3,19 @@
|
||||
To run the latest stable release of Nix with Docker run the following command:
|
||||
|
||||
```console
|
||||
$ docker run -ti docker.io/nixos/nix
|
||||
Unable to find image 'docker.io/nixos/nix:latest' locally
|
||||
latest: Pulling from docker.io/nixos/nix
|
||||
$ docker run -ti ghcr.io/nixos/nix
|
||||
Unable to find image 'ghcr.io/nixos/nix:latest' locally
|
||||
latest: Pulling from ghcr.io/nixos/nix
|
||||
5843afab3874: Pull complete
|
||||
b52bf13f109c: Pull complete
|
||||
1e2415612aa3: Pull complete
|
||||
Digest: sha256:27f6e7f60227e959ee7ece361f75d4844a40e1cc6878b6868fe30140420031ff
|
||||
Status: Downloaded newer image for docker.io/nixos/nix:latest
|
||||
Status: Downloaded newer image for ghcr.io/nixos/nix:latest
|
||||
35ca4ada6e96:/# nix --version
|
||||
nix (Nix) 2.3.12
|
||||
35ca4ada6e96:/# exit
|
||||
```
|
||||
|
||||
> If you want the latest pre-release you can use ghcr.io/nixos/nix and view them at https://github.com/nixos/nix/pkgs/container/nix
|
||||
|
||||
# What is included in Nix's Docker image?
|
||||
|
||||
The official Docker image is created using `pkgs.dockerTools.buildLayeredImage`
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
- Bash Shell. The `./configure` script relies on bashisms, so Bash is
|
||||
required.
|
||||
|
||||
- A version of GCC or Clang that supports C++23.
|
||||
- A version of GCC or Clang that supports C++20.
|
||||
|
||||
- `pkg-config` to locate dependencies. If your distribution does not
|
||||
provide it, you can get it from
|
||||
|
||||
@@ -41,38 +41,6 @@ There may also be references to Nix in
|
||||
|
||||
which you may remove.
|
||||
|
||||
### FreeBSD
|
||||
|
||||
1. Stop and remove the Nix daemon service:
|
||||
|
||||
```console
|
||||
sudo service nix-daemon stop
|
||||
sudo rm -f /usr/local/etc/rc.d/nix-daemon
|
||||
sudo sysrc -x nix_daemon_enable
|
||||
```
|
||||
|
||||
2. Remove files created by Nix:
|
||||
|
||||
```console
|
||||
sudo rm -rf /etc/nix /usr/local/etc/profile.d/nix.sh /nix ~root/.nix-channels ~root/.nix-defexpr ~root/.nix-profile ~root/.cache/nix
|
||||
```
|
||||
|
||||
3. Remove build users and their group:
|
||||
|
||||
```console
|
||||
for i in $(seq 1 32); do
|
||||
sudo pw userdel nixbld$i
|
||||
done
|
||||
sudo pw groupdel nixbld
|
||||
```
|
||||
|
||||
4. There may also be references to Nix in:
|
||||
- `/usr/local/etc/bashrc`
|
||||
- `/usr/local/etc/zshrc`
|
||||
- Shell configuration files in users' home directories
|
||||
|
||||
which you may remove.
|
||||
|
||||
### macOS
|
||||
|
||||
> **Updating to macOS 15 Sequoia**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Introduction
|
||||
|
||||
Nix is a _purely functional package manager_. This means that it
|
||||
treats packages like values in a purely functional programming language
|
||||
— packages are built by functions that don’t have
|
||||
treats packages like values in purely functional programming languages
|
||||
such as Haskell — they are built by functions that don’t have
|
||||
side-effects, and they never change after they have been built. Nix
|
||||
stores packages in the _Nix store_, usually the directory
|
||||
`/nix/store`, where each package has its own unique subdirectory such
|
||||
|
||||
@@ -2,75 +2,6 @@
|
||||
|
||||
Derivations can declare some infrequently used optional attributes.
|
||||
|
||||
## Inputs
|
||||
|
||||
- [`exportReferencesGraph`]{#adv-attr-exportReferencesGraph}\
|
||||
This attribute allows builders access to the references graph of
|
||||
their inputs. The attribute is a list of inputs in the Nix store
|
||||
whose references graph the builder needs to know. The value of
|
||||
this attribute should be a list of pairs `[ name1 path1 name2
|
||||
path2 ... ]`. The references graph of each *pathN* will be stored
|
||||
in a text file *nameN* in the temporary build directory. The text
|
||||
files have the format used by `nix-store --register-validity`
|
||||
(with the deriver fields left empty). For example, when the
|
||||
following derivation is built:
|
||||
|
||||
```nix
|
||||
derivation {
|
||||
...
|
||||
exportReferencesGraph = [ "libfoo-graph" libfoo ];
|
||||
};
|
||||
```
|
||||
|
||||
the references graph of `libfoo` is placed in the file
|
||||
`libfoo-graph` in the temporary build directory.
|
||||
|
||||
`exportReferencesGraph` is useful for builders that want to do
|
||||
something with the closure of a store path. Examples include the
|
||||
builders in NixOS that generate the initial ramdisk for booting
|
||||
Linux (a `cpio` archive containing the closure of the boot script)
|
||||
and the ISO-9660 image for the installation CD (which is populated
|
||||
with a Nix store containing the closure of a bootable NixOS
|
||||
configuration).
|
||||
|
||||
- [`passAsFile`]{#adv-attr-passAsFile}\
|
||||
A list of names of attributes that should be passed via files rather
|
||||
than environment variables. For example, if you have
|
||||
|
||||
```nix
|
||||
passAsFile = ["big"];
|
||||
big = "a very long string";
|
||||
```
|
||||
|
||||
then when the builder runs, the environment variable `bigPath`
|
||||
will contain the absolute path to a temporary file containing `a
|
||||
very long string`. That is, for any attribute *x* listed in
|
||||
`passAsFile`, Nix will pass an environment variable `xPath`
|
||||
holding the path of the file containing the value of attribute
|
||||
*x*. This is useful when you need to pass large strings to a
|
||||
builder, since most operating systems impose a limit on the size
|
||||
of the environment (typically, a few hundred kilobyte).
|
||||
|
||||
- [`__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.
|
||||
|
||||
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.
|
||||
|
||||
See the [corresponding section in the derivation page](@docroot@/store/derivation/index.md#structured-attrs) for further details.
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> If set to `true`, other advanced attributes such as [`allowedReferences`](#adv-attr-allowedReferences), [`allowedRequisites`](#adv-attr-allowedRequisites),
|
||||
[`disallowedReferences`](#adv-attr-disallowedReferences) and [`disallowedRequisites`](#adv-attr-disallowedRequisites), maxSize, and maxClosureSize.
|
||||
will have no effect.
|
||||
|
||||
## Output checks
|
||||
|
||||
See the [corresponding section in the derivation output page](@docroot@/store/derivation/outputs/index.md).
|
||||
|
||||
- [`allowedReferences`]{#adv-attr-allowedReferences}\
|
||||
The optional attribute `allowedReferences` specifies a list of legal
|
||||
references (dependencies) of the output of the builder. For example,
|
||||
@@ -124,6 +55,259 @@ See the [corresponding section in the derivation output page](@docroot@/store/de
|
||||
dependency on `foobar` or any other derivation depending recursively
|
||||
on `foobar`.
|
||||
|
||||
- [`exportReferencesGraph`]{#adv-attr-exportReferencesGraph}\
|
||||
This attribute allows builders access to the references graph of
|
||||
their inputs. The attribute is a list of inputs in the Nix store
|
||||
whose references graph the builder needs to know. The value of
|
||||
this attribute should be a list of pairs `[ name1 path1 name2
|
||||
path2 ... ]`. The references graph of each *pathN* will be stored
|
||||
in a text file *nameN* in the temporary build directory. The text
|
||||
files have the format used by `nix-store --register-validity`
|
||||
(with the deriver fields left empty). For example, when the
|
||||
following derivation is built:
|
||||
|
||||
```nix
|
||||
derivation {
|
||||
...
|
||||
exportReferencesGraph = [ "libfoo-graph" libfoo ];
|
||||
};
|
||||
```
|
||||
|
||||
the references graph of `libfoo` is placed in the file
|
||||
`libfoo-graph` in the temporary build directory.
|
||||
|
||||
`exportReferencesGraph` is useful for builders that want to do
|
||||
something with the closure of a store path. Examples include the
|
||||
builders in NixOS that generate the initial ramdisk for booting
|
||||
Linux (a `cpio` archive containing the closure of the boot script)
|
||||
and the ISO-9660 image for the installation CD (which is populated
|
||||
with a Nix store containing the closure of a bootable NixOS
|
||||
configuration).
|
||||
|
||||
- [`impureEnvVars`]{#adv-attr-impureEnvVars}\
|
||||
This attribute allows you to specify a list of environment variables
|
||||
that should be passed from the environment of the calling user to
|
||||
the builder. Usually, the environment is cleared completely when the
|
||||
builder is executed, but with this attribute you can allow specific
|
||||
environment variables to be passed unmodified. For example,
|
||||
`fetchurl` in Nixpkgs has the line
|
||||
|
||||
```nix
|
||||
impureEnvVars = [ "http_proxy" "https_proxy" ... ];
|
||||
```
|
||||
|
||||
to make it use the proxy server configuration specified by the user
|
||||
in the environment variables `http_proxy` and friends.
|
||||
|
||||
This attribute is only allowed in *fixed-output derivations* (see
|
||||
below), where impurities such as these are okay since (the hash
|
||||
of) the output is known in advance. It is ignored for all other
|
||||
derivations.
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> `impureEnvVars` implementation takes environment variables from
|
||||
> the current builder process. When a daemon is building its
|
||||
> environmental variables are used. Without the daemon, the
|
||||
> environmental variables come from the environment of the
|
||||
> `nix-build`.
|
||||
|
||||
If the [`configurable-impure-env` experimental
|
||||
feature](@docroot@/development/experimental-features.md#xp-feature-configurable-impure-env)
|
||||
is enabled, these environment variables can also be controlled
|
||||
through the
|
||||
[`impure-env`](@docroot@/command-ref/conf-file.md#conf-impure-env)
|
||||
configuration setting.
|
||||
|
||||
- [`outputHash`]{#adv-attr-outputHash}; [`outputHashAlgo`]{#adv-attr-outputHashAlgo}; [`outputHashMode`]{#adv-attr-outputHashMode}\
|
||||
These attributes declare that the derivation is a so-called *fixed-output derivation* (FOD), which means that a cryptographic hash of the output is already known in advance.
|
||||
|
||||
As opposed to regular derivations, the [`builder`] executable of a fixed-output derivation has access to the network.
|
||||
Nix computes a cryptographic hash of its output and compares that to the hash declared with these attributes.
|
||||
If there is a mismatch, the derivation fails.
|
||||
|
||||
The rationale for fixed-output derivations is derivations such as
|
||||
those produced by the `fetchurl` function. This function downloads a
|
||||
file from a given URL. To ensure that the downloaded file has not
|
||||
been modified, the caller must also specify a cryptographic hash of
|
||||
the file. For example,
|
||||
|
||||
```nix
|
||||
fetchurl {
|
||||
url = "http://ftp.gnu.org/pub/gnu/hello/hello-2.1.1.tar.gz";
|
||||
sha256 = "1md7jsfd8pa45z73bz1kszpp01yw6x5ljkjk2hx7wl800any6465";
|
||||
}
|
||||
```
|
||||
|
||||
It sometimes happens that the URL of the file changes, e.g., because
|
||||
servers are reorganised or no longer available. We then must update
|
||||
the call to `fetchurl`, e.g.,
|
||||
|
||||
```nix
|
||||
fetchurl {
|
||||
url = "ftp://ftp.nluug.nl/pub/gnu/hello/hello-2.1.1.tar.gz";
|
||||
sha256 = "1md7jsfd8pa45z73bz1kszpp01yw6x5ljkjk2hx7wl800any6465";
|
||||
}
|
||||
```
|
||||
|
||||
If a `fetchurl` derivation was treated like a normal derivation, the
|
||||
output paths of the derivation and *all derivations depending on it*
|
||||
would change. For instance, if we were to change the URL of the
|
||||
Glibc source distribution in Nixpkgs (a package on which almost all
|
||||
other packages depend) massive rebuilds would be needed. This is
|
||||
unfortunate for a change which we know cannot have a real effect as
|
||||
it propagates upwards through the dependency graph.
|
||||
|
||||
For fixed-output derivations, on the other hand, the name of the
|
||||
output path only depends on the `outputHash*` and `name` attributes,
|
||||
while all other attributes are ignored for the purpose of computing
|
||||
the output path. (The `name` attribute is included because it is
|
||||
part of the path.)
|
||||
|
||||
As an example, here is the (simplified) Nix expression for
|
||||
`fetchurl`:
|
||||
|
||||
```nix
|
||||
{ stdenv, curl }: # The curl program is used for downloading.
|
||||
|
||||
{ url, sha256 }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = baseNameOf (toString url);
|
||||
builder = ./builder.sh;
|
||||
buildInputs = [ curl ];
|
||||
|
||||
# This is a fixed-output derivation; the output must be a regular
|
||||
# file with SHA256 hash sha256.
|
||||
outputHashMode = "flat";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHash = sha256;
|
||||
|
||||
inherit url;
|
||||
}
|
||||
```
|
||||
|
||||
The `outputHash` attribute must be a string containing the hash in either hexadecimal or "nix32" encoding, or following the format for integrity metadata as defined by [SRI](https://www.w3.org/TR/SRI/).
|
||||
The "nix32" encoding is an adaptation of base-32 encoding.
|
||||
The [`convertHash`](@docroot@/language/builtins.md#builtins-convertHash) function shows how to convert between different encodings, and the [`nix-hash` command](../command-ref/nix-hash.md) has information about obtaining the hash for some contents, as well as converting to and from encodings.
|
||||
|
||||
The `outputHashAlgo` attribute specifies the hash algorithm used to compute the hash.
|
||||
It can currently be `"sha1"`, `"sha256"`, `"sha512"`, or `null`.
|
||||
`outputHashAlgo` can only be `null` when `outputHash` follows the SRI format.
|
||||
|
||||
The `outputHashMode` attribute determines how the hash is computed.
|
||||
It must be one of the following values:
|
||||
|
||||
- [`"flat"`](@docroot@/store/store-object/content-address.md#method-flat)
|
||||
|
||||
This is the default.
|
||||
|
||||
- [`"recursive"` or `"nar"`](@docroot@/store/store-object/content-address.md#method-nix-archive)
|
||||
|
||||
> **Compatibility**
|
||||
>
|
||||
> `"recursive"` is the traditional way of indicating this,
|
||||
> and is supported since 2005 (virtually the entire history of Nix).
|
||||
> `"nar"` is more clear, and consistent with other parts of Nix (such as the CLI),
|
||||
> however support for it is only added in Nix version 2.21.
|
||||
|
||||
- [`"text"`](@docroot@/store/store-object/content-address.md#method-text)
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> The use of this method for derivation outputs is part of the [`dynamic-derivations`][xp-feature-dynamic-derivations] experimental feature.
|
||||
|
||||
- [`"git"`](@docroot@/store/store-object/content-address.md#method-git)
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> This method is part of the [`git-hashing`][xp-feature-git-hashing] experimental feature.
|
||||
|
||||
- [`__contentAddressed`]{#adv-attr-__contentAddressed}
|
||||
|
||||
> **Warning**
|
||||
> This attribute is part of an [experimental feature](@docroot@/development/experimental-features.md).
|
||||
>
|
||||
> To use this attribute, you must enable the
|
||||
> [`ca-derivations`][xp-feature-ca-derivations] experimental feature.
|
||||
> For example, in [nix.conf](../command-ref/conf-file.md) you could add:
|
||||
>
|
||||
> ```
|
||||
> extra-experimental-features = ca-derivations
|
||||
> ```
|
||||
|
||||
If this attribute is set to `true`, then the derivation
|
||||
outputs will be stored in a content-addressed location rather than the
|
||||
traditional input-addressed one.
|
||||
|
||||
Setting this attribute also requires setting
|
||||
[`outputHashMode`](#adv-attr-outputHashMode)
|
||||
and
|
||||
[`outputHashAlgo`](#adv-attr-outputHashAlgo)
|
||||
like for *fixed-output derivations* (see above).
|
||||
|
||||
It also implicitly requires that the machine to build the derivation must have the `ca-derivations` [system feature](@docroot@/command-ref/conf-file.md#conf-system-features).
|
||||
|
||||
- [`passAsFile`]{#adv-attr-passAsFile}\
|
||||
A list of names of attributes that should be passed via files rather
|
||||
than environment variables. For example, if you have
|
||||
|
||||
```nix
|
||||
passAsFile = ["big"];
|
||||
big = "a very long string";
|
||||
```
|
||||
|
||||
then when the builder runs, the environment variable `bigPath`
|
||||
will contain the absolute path to a temporary file containing `a
|
||||
very long string`. That is, for any attribute *x* listed in
|
||||
`passAsFile`, Nix will pass an environment variable `xPath`
|
||||
holding the path of the file containing the value of attribute
|
||||
*x*. This is useful when you need to pass large strings to a
|
||||
builder, since most operating systems impose a limit on the size
|
||||
of the environment (typically, a few hundred kilobyte).
|
||||
|
||||
- [`preferLocalBuild`]{#adv-attr-preferLocalBuild}\
|
||||
If this attribute is set to `true` and [distributed building is enabled](@docroot@/command-ref/conf-file.md#conf-builders), then, if possible, the derivation will be built locally instead of being forwarded to a remote machine.
|
||||
This is useful for derivations that are cheapest to build locally.
|
||||
|
||||
- [`allowSubstitutes`]{#adv-attr-allowSubstitutes}\
|
||||
If this attribute is set to `false`, then Nix will always build this derivation (locally or remotely); it will not try to substitute its outputs.
|
||||
This is useful for derivations that are cheaper to build than to substitute.
|
||||
|
||||
This attribute can be ignored by setting [`always-allow-substitutes`](@docroot@/command-ref/conf-file.md#conf-always-allow-substitutes) to `true`.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> If set to `false`, the [`builder`] should be able to run on the system type specified in the [`system` attribute](./derivations.md#attr-system), since the derivation cannot be substituted.
|
||||
|
||||
[`builder`]: ./derivations.md#attr-builder
|
||||
|
||||
- [`__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. 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.
|
||||
|
||||
It also makes it possible to tweak derivation settings in a structured way; see
|
||||
[`outputChecks`](#adv-attr-outputChecks) for example.
|
||||
|
||||
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**
|
||||
>
|
||||
> If set to `true`, other advanced attributes such as [`allowedReferences`](#adv-attr-allowedReferences), [`allowedReferences`](#adv-attr-allowedReferences), [`allowedRequisites`](#adv-attr-allowedRequisites),
|
||||
[`disallowedReferences`](#adv-attr-disallowedReferences) and [`disallowedRequisites`](#adv-attr-disallowedRequisites), maxSize, and maxClosureSize.
|
||||
will have no effect.
|
||||
|
||||
- [`outputChecks`]{#adv-attr-outputChecks}\
|
||||
When using [structured attributes](#adv-attr-structuredAttrs), the `outputChecks`
|
||||
attribute allows defining checks per-output.
|
||||
@@ -157,9 +341,8 @@ See the [corresponding section in the derivation output page](@docroot@/store/de
|
||||
};
|
||||
```
|
||||
|
||||
## Other output modifications
|
||||
|
||||
- [`unsafeDiscardReferences`]{#adv-attr-unsafeDiscardReferences}\
|
||||
|
||||
When using [structured attributes](#adv-attr-structuredAttrs), the
|
||||
attribute `unsafeDiscardReferences` is an attribute set with a boolean value for each output name.
|
||||
If set to `true`, it disables scanning the output for runtime dependencies.
|
||||
@@ -175,25 +358,8 @@ See the [corresponding section in the derivation output page](@docroot@/store/de
|
||||
their own embedded Nix store: hashes found inside such an image refer
|
||||
to the embedded store and not to the host's Nix store.
|
||||
|
||||
## Build scheduling
|
||||
|
||||
- [`preferLocalBuild`]{#adv-attr-preferLocalBuild}\
|
||||
If this attribute is set to `true` and [distributed building is enabled](@docroot@/command-ref/conf-file.md#conf-builders), then, if possible, the derivation will be built locally instead of being forwarded to a remote machine.
|
||||
This is useful for derivations that are cheapest to build locally.
|
||||
|
||||
- [`allowSubstitutes`]{#adv-attr-allowSubstitutes}\
|
||||
If this attribute is set to `false`, then Nix will always build this derivation (locally or remotely); it will not try to substitute its outputs.
|
||||
This is useful for derivations that are cheaper to build than to substitute.
|
||||
|
||||
This attribute can be ignored by setting [`always-allow-substitutes`](@docroot@/command-ref/conf-file.md#conf-always-allow-substitutes) to `true`.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> If set to `false`, the [`builder`] should be able to run on the system type specified in the [`system` attribute](./derivations.md#attr-system), since the derivation cannot be substituted.
|
||||
|
||||
[`builder`]: ./derivations.md#attr-builder
|
||||
|
||||
- [`requiredSystemFeatures`]{#adv-attr-requiredSystemFeatures}\
|
||||
|
||||
If a derivation has the `requiredSystemFeatures` attribute, then Nix will only build it on a machine that has the corresponding features set in its [`system-features` configuration](@docroot@/command-ref/conf-file.md#conf-system-features).
|
||||
|
||||
For example, setting
|
||||
@@ -204,171 +370,6 @@ See the [corresponding section in the derivation output page](@docroot@/store/de
|
||||
|
||||
ensures that the derivation can only be built on a machine with the `kvm` feature.
|
||||
|
||||
# Impure builder configuration
|
||||
|
||||
- [`impureEnvVars`]{#adv-attr-impureEnvVars}\
|
||||
This attribute allows you to specify a list of environment variables
|
||||
that should be passed from the environment of the calling user to
|
||||
the builder. Usually, the environment is cleared completely when the
|
||||
builder is executed, but with this attribute you can allow specific
|
||||
environment variables to be passed unmodified. For example,
|
||||
`fetchurl` in Nixpkgs has the line
|
||||
|
||||
```nix
|
||||
impureEnvVars = [ "http_proxy" "https_proxy" ... ];
|
||||
```
|
||||
|
||||
to make it use the proxy server configuration specified by the user
|
||||
in the environment variables `http_proxy` and friends.
|
||||
|
||||
This attribute is only allowed in [fixed-output derivations][fixed-output derivation],
|
||||
where impurities such as these are okay since (the hash
|
||||
of) the output is known in advance. It is ignored for all other
|
||||
derivations.
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> `impureEnvVars` implementation takes environment variables from
|
||||
> the current builder process. When a daemon is building its
|
||||
> environmental variables are used. Without the daemon, the
|
||||
> environmental variables come from the environment of the
|
||||
> `nix-build`.
|
||||
|
||||
If the [`configurable-impure-env` experimental
|
||||
feature](@docroot@/development/experimental-features.md#xp-feature-configurable-impure-env)
|
||||
is enabled, these environment variables can also be controlled
|
||||
through the
|
||||
[`impure-env`](@docroot@/command-ref/conf-file.md#conf-impure-env)
|
||||
configuration setting.
|
||||
|
||||
## Setting the derivation type
|
||||
|
||||
As discussed in [Derivation Outputs and Types of Derivations](@docroot@/store/derivation/outputs/index.md), there are multiples kinds of derivations / kinds of derivation outputs.
|
||||
The choice of the following attributes determines which kind of derivation we are making.
|
||||
|
||||
- [`__contentAddressed`]
|
||||
|
||||
- [`outputHash`]
|
||||
|
||||
- [`outputHashAlgo`]
|
||||
|
||||
- [`outputHashMode`]
|
||||
|
||||
The three types of derivations are chosen based on the following combinations of these attributes.
|
||||
All other combinations are invalid.
|
||||
|
||||
- [Input-addressing derivations](@docroot@/store/derivation/outputs/input-address.md)
|
||||
|
||||
This is the default for `builtins.derivation`.
|
||||
Nix only currently supports one kind of input-addressing, so no other information is needed.
|
||||
|
||||
`__contentAddressed = false;` may also be included, but is not needed, and will trigger the experimental feature check.
|
||||
|
||||
- [Fixed-output derivations][fixed-output derivation]
|
||||
|
||||
All of [`outputHash`], [`outputHashAlgo`], and [`outputHashMode`].
|
||||
|
||||
<!--
|
||||
|
||||
`__contentAddressed` is ignored, because fixed-output derivations always content-address their outputs, by definition.
|
||||
|
||||
**TODO CHECK**
|
||||
|
||||
-->
|
||||
|
||||
- [(Floating) content-addressing derivations](@docroot@/store/derivation/outputs/content-address.md)
|
||||
|
||||
Both [`outputHashAlgo`] and [`outputHashMode`], `__contentAddressed = true;`, and *not* `outputHash`.
|
||||
|
||||
If an output hash was given, then the derivation output would be "fixed" not "floating".
|
||||
|
||||
Here is more information on the `output*` attributes, and what values they may be set to:
|
||||
|
||||
- [`outputHashMode`]{#adv-attr-outputHashMode}
|
||||
|
||||
This specifies how the files of a content-addressing derivation output are digested to produce a content address.
|
||||
|
||||
This works in conjunction with [`outputHashAlgo`](#adv-attr-outputHashAlgo).
|
||||
Specifying one without the other is an error (unless [`outputHash` is also specified and includes its own hash algorithm as described below).
|
||||
|
||||
The `outputHashMode` attribute determines how the hash is computed.
|
||||
It must be one of the following values:
|
||||
|
||||
- [`"flat"`](@docroot@/store/store-object/content-address.md#method-flat)
|
||||
|
||||
This is the default.
|
||||
|
||||
- [`"recursive"` or `"nar"`](@docroot@/store/store-object/content-address.md#method-nix-archive)
|
||||
|
||||
> **Compatibility**
|
||||
>
|
||||
> `"recursive"` is the traditional way of indicating this,
|
||||
> and is supported since 2005 (virtually the entire history of Nix).
|
||||
> `"nar"` is more clear, and consistent with other parts of Nix (such as the CLI),
|
||||
> however support for it is only added in Nix version 2.21.
|
||||
|
||||
- [`"text"`](@docroot@/store/store-object/content-address.md#method-text)
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> The use of this method for derivation outputs is part of the [`dynamic-derivations`][xp-feature-dynamic-derivations] experimental feature.
|
||||
|
||||
- [`"git"`](@docroot@/store/store-object/content-address.md#method-git)
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> This method is part of the [`git-hashing`][xp-feature-git-hashing] experimental feature.
|
||||
|
||||
See [content-addressing store objects](@docroot@/store/store-object/content-address.md) for more information about the process this flag controls.
|
||||
|
||||
- [`outputHashAlgo`]{#adv-attr-outputHashAlgo}
|
||||
|
||||
This specifies the hash algorithm used to digest the [file system object] data of a content-addressing derivation output.
|
||||
|
||||
This works in conjunction with [`outputHashMode`](#adv-attr-outputHashAlgo).
|
||||
Specifying one without the other is an error (unless `outputHash` is also specified and includes its own hash algorithm as described below).
|
||||
|
||||
The `outputHashAlgo` attribute specifies the hash algorithm used to compute the hash.
|
||||
It can currently be `"blake3"`, `"sha1"`, `"sha256"`, `"sha512"`, or `null`.
|
||||
|
||||
`outputHashAlgo` can only be `null` when `outputHash` follows the SRI format, because in that case the choice of hash algorithm is determined by `outputHash`.
|
||||
|
||||
- [`outputHash`]{#adv-attr-outputHash}
|
||||
|
||||
This will specify the output hash of the single output of a [fixed-output derivation].
|
||||
|
||||
The `outputHash` attribute must be a string containing the hash in either hexadecimal or "nix32" encoding, or following the format for integrity metadata as defined by [SRI](https://www.w3.org/TR/SRI/).
|
||||
The "nix32" encoding is an adaptation of base-32 encoding.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> The [`convertHash`](@docroot@/language/builtins.md#builtins-convertHash) function shows how to convert between different encodings.
|
||||
> The [`nix-hash` command](../command-ref/nix-hash.md) has information about obtaining the hash for some contents, as well as converting to and from encodings.
|
||||
|
||||
- [`__contentAddressed`]{#adv-attr-__contentAddressed}
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> This attribute is part of an [experimental feature](@docroot@/development/experimental-features.md).
|
||||
>
|
||||
> To use this attribute, you must enable the
|
||||
> [`ca-derivations`][xp-feature-ca-derivations] experimental feature.
|
||||
> For example, in [nix.conf](../command-ref/conf-file.md) you could add:
|
||||
>
|
||||
> ```
|
||||
> extra-experimental-features = ca-derivations
|
||||
> ```
|
||||
|
||||
This is a boolean with a default of `false`.
|
||||
It determines whether the derivation is floating content-addressing.
|
||||
|
||||
[`__contentAddressed`]: #adv-attr-__contentAddressed
|
||||
[`outputHash`]: #adv-attr-outputHash
|
||||
[`outputHashAlgo`]: #adv-attr-outputHashAlgo
|
||||
[`outputHashMode`]: #adv-attr-outputHashMode
|
||||
|
||||
[fixed-output derivation]: @docroot@/glossary.md#gloss-fixed-output-derivation
|
||||
[file system object]: @docroot@/store/file-system-object.md
|
||||
[store object]: @docroot@/store/store-object.md
|
||||
[xp-feature-ca-derivations]: @docroot@/development/experimental-features.md#xp-feature-ca-derivations
|
||||
[xp-feature-dynamic-derivations]: @docroot@/development/experimental-features.md#xp-feature-dynamic-derivations
|
||||
[xp-feature-git-hashing]: @docroot@/development/experimental-features.md#xp-feature-git-hashing
|
||||
|
||||
@@ -5,28 +5,12 @@ All built-ins are available through the global [`builtins`](#builtins-builtins)
|
||||
|
||||
Some built-ins are also exposed directly in the global scope:
|
||||
|
||||
<!-- TODO(@rhendric, #10970): this list is incomplete -->
|
||||
|
||||
- [`derivation`](#builtins-derivation)
|
||||
- `derivationStrict`
|
||||
- [`abort`](#builtins-abort)
|
||||
- [`baseNameOf`](#builtins-baseNameOf)
|
||||
- [`break`](#builtins-break)
|
||||
- [`dirOf`](#builtins-dirOf)
|
||||
- [`false`](#builtins-false)
|
||||
- [`fetchGit`](#builtins-fetchGit)
|
||||
- `fetchMercurial`
|
||||
- [`fetchTarball`](#builtins-fetchTarball)
|
||||
- [`fetchTree`](#builtins-fetchTree)
|
||||
- [`fromTOML`](#builtins-fromTOML)
|
||||
- [`import`](#builtins-import)
|
||||
- [`isNull`](#builtins-isNull)
|
||||
- [`map`](#builtins-map)
|
||||
- [`null`](#builtins-null)
|
||||
- [`placeholder`](#builtins-placeholder)
|
||||
- [`removeAttrs`](#builtins-removeAttrs)
|
||||
- [`scopedImport`](#builtins-scopedImport)
|
||||
- [`abort`](#builtins-abort)
|
||||
- [`throw`](#builtins-throw)
|
||||
- [`toString`](#builtins-toString)
|
||||
- [`true`](#builtins-true)
|
||||
|
||||
<dl>
|
||||
<dt id="builtins-derivation"><a href="#builtins-derivation"><code>derivation <var>attrs</var></code></a></dt>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
# Derivations
|
||||
|
||||
The most important built-in function is `derivation`, which is used to describe a single store-layer [store derivation].
|
||||
Consult the [store chapter](@docroot@/store/derivation/index.md) for what a store derivation is;
|
||||
this section just concerns how to create one from the Nix language.
|
||||
The most important built-in function is `derivation`, which is used to describe a single derivation:
|
||||
a specification for running an executable on precisely defined input files to repeatably produce output files at uniquely determined file system paths.
|
||||
|
||||
This builtin function takes as input an attribute set, the attributes of which specify the inputs to the process.
|
||||
It takes as input an attribute set, the attributes of which specify the inputs to the process.
|
||||
It outputs an attribute set, and produces a [store derivation] as a side effect of evaluation.
|
||||
|
||||
[store derivation]: @docroot@/glossary.md#gloss-store-derivation
|
||||
@@ -16,7 +15,7 @@ It outputs an attribute set, and produces a [store derivation] as a side effect
|
||||
- [`name`]{#attr-name} ([String](@docroot@/language/types.md#type-string))
|
||||
|
||||
A symbolic name for the derivation.
|
||||
See [derivation outputs](@docroot@/store/derivation/outputs/index.md#outputs) for what this is affects.
|
||||
It is added to the [store path] of the corresponding [store derivation] as well as to its [output paths](@docroot@/glossary.md#gloss-output-path).
|
||||
|
||||
[store path]: @docroot@/store/store-path.md
|
||||
|
||||
@@ -29,12 +28,17 @@ It outputs an attribute set, and produces a [store derivation] as a side effect
|
||||
> }
|
||||
> ```
|
||||
>
|
||||
> The derivation's path will be `/nix/store/<hash>-hello.drv`.
|
||||
> The store derivation's path will be `/nix/store/<hash>-hello.drv`.
|
||||
> The [output](#attr-outputs) paths will be of the form `/nix/store/<hash>-hello[-<output>]`
|
||||
|
||||
- [`system`]{#attr-system} ([String](@docroot@/language/types.md#type-string))
|
||||
|
||||
See [system](@docroot@/store/derivation/index.md#system).
|
||||
The system type on which the [`builder`](#attr-builder) executable is meant to be run.
|
||||
|
||||
A necessary condition for Nix to build derivations locally is that the `system` attribute matches the current [`system` configuration option].
|
||||
It can automatically [build on other platforms](@docroot@/language/derivations.md#attr-builder) by forwarding build requests to other machines.
|
||||
|
||||
[`system` configuration option]: @docroot@/command-ref/conf-file.md#conf-system
|
||||
|
||||
> **Example**
|
||||
>
|
||||
@@ -64,7 +68,7 @@ It outputs an attribute set, and produces a [store derivation] as a side effect
|
||||
|
||||
- [`builder`]{#attr-builder} ([Path](@docroot@/language/types.md#type-path) | [String](@docroot@/language/types.md#type-string))
|
||||
|
||||
See [builder](@docroot@/store/derivation/index.md#builder).
|
||||
Path to an executable that will perform the build.
|
||||
|
||||
> **Example**
|
||||
>
|
||||
@@ -113,7 +117,7 @@ It outputs an attribute set, and produces a [store derivation] as a side effect
|
||||
|
||||
Default: `[ ]`
|
||||
|
||||
See [args](@docroot@/store/derivation/index.md#args).
|
||||
Command-line arguments to be passed to the [`builder`](#attr-builder) executable.
|
||||
|
||||
> **Example**
|
||||
>
|
||||
@@ -235,3 +239,77 @@ It outputs an attribute set, and produces a [store derivation] as a side effect
|
||||
passed as an empty string.
|
||||
|
||||
<!-- FIXME: add a section on output attributes -->
|
||||
|
||||
## Builder execution
|
||||
|
||||
The [`builder`](#attr-builder) is executed as follows:
|
||||
|
||||
- A temporary directory is created under the directory specified by
|
||||
`TMPDIR` (default `/tmp`) where the build will take place. The
|
||||
current directory is changed to this directory.
|
||||
|
||||
- The environment is cleared and set to the derivation attributes, as
|
||||
specified above.
|
||||
|
||||
- In addition, the following variables are set:
|
||||
|
||||
- `NIX_BUILD_TOP` contains the path of the temporary directory for
|
||||
this build.
|
||||
|
||||
- Also, `TMPDIR`, `TEMPDIR`, `TMP`, `TEMP` are set to point to the
|
||||
temporary directory. This is to prevent the builder from
|
||||
accidentally writing temporary files anywhere else. Doing so
|
||||
might cause interference by other processes.
|
||||
|
||||
- `PATH` is set to `/path-not-set` to prevent shells from
|
||||
initialising it to their built-in default value.
|
||||
|
||||
- `HOME` is set to `/homeless-shelter` to prevent programs from
|
||||
using `/etc/passwd` or the like to find the user's home
|
||||
directory, which could cause impurity. Usually, when `HOME` is
|
||||
set, it is used as the location of the home directory, even if
|
||||
it points to a non-existent path.
|
||||
|
||||
- `NIX_STORE` is set to the path of the top-level Nix store
|
||||
directory (typically, `/nix/store`).
|
||||
|
||||
- `NIX_ATTRS_JSON_FILE` & `NIX_ATTRS_SH_FILE` if `__structuredAttrs`
|
||||
is set to `true` for the derivation. A detailed explanation of this
|
||||
behavior can be found in the
|
||||
[section about structured attrs](./advanced-attributes.md#adv-attr-structuredAttrs).
|
||||
|
||||
- For each output declared in `outputs`, the corresponding
|
||||
environment variable is set to point to the intended path in the
|
||||
Nix store for that output. Each output path is a concatenation
|
||||
of the cryptographic hash of all build inputs, the `name`
|
||||
attribute and the output name. (The output name is omitted if
|
||||
it’s `out`.)
|
||||
|
||||
- If an output path already exists, it is removed. Also, locks are
|
||||
acquired to prevent multiple Nix instances from performing the same
|
||||
build at the same time.
|
||||
|
||||
- A log of the combined standard output and error is written to
|
||||
`/nix/var/log/nix`.
|
||||
|
||||
- The builder is executed with the arguments specified by the
|
||||
attribute `args`. If it exits with exit code 0, it is considered to
|
||||
have succeeded.
|
||||
|
||||
- The temporary directory is removed (unless the `-K` option was
|
||||
specified).
|
||||
|
||||
- If the build was successful, Nix scans each output path for
|
||||
references to input paths by looking for the hash parts of the input
|
||||
paths. Since these are potential runtime dependencies, Nix registers
|
||||
them as dependencies of the output paths.
|
||||
|
||||
- After the build, Nix sets the last-modified timestamp on all files
|
||||
in the build result to 1 (00:00:01 1/1/1970 UTC), sets the group to
|
||||
the default group, and sets the mode of the file to 0444 or 0555
|
||||
(i.e., read-only, with execute permission enabled if the file was
|
||||
originally executable). Note that possible `setuid` and `setgid`
|
||||
bits are cleared. Setuid and setgid programs are not currently
|
||||
supported by Nix. This is because the Nix archives used in
|
||||
deployment have no concept of ownership information, and because it
|
||||
makes the build result dependent on the user performing the build.
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
# Evaluation
|
||||
|
||||
Evaluation is the process of turning a Nix expression into a [Nix value](types.md).
|
||||
|
||||
This happens by a number of rules, such as:
|
||||
- Constructing values from literals.
|
||||
For example the number literal `1` is turned into the number value `1`.
|
||||
- Applying operators
|
||||
For example the addition operator `+` is applied to two number values to produce a new number value.
|
||||
- Applying built-in functions
|
||||
For example the expression `builtins.isInt 1` is evaluated to `true`.
|
||||
- Applying user-defined functions
|
||||
For example the expression `(x: x + 1) 10` can[*](#laziness) be thought of rewriting `x` in the function body to the argument, `10 + 1`, which is then evaluated to `11`.
|
||||
|
||||
These rules are applied as needed, driven by the specific use of the expression. For example, this can occur in the Nix command line interface or interactively with the [repl (read-eval-print loop)](@docroot@/command-ref/new-cli/nix3-repl.md), which is a useful tool when learning about evaluation.
|
||||
|
||||
# Details
|
||||
|
||||
## Values {#values}
|
||||
|
||||
Nix values can be thought of as a subset of Nix expressions.
|
||||
For example, the expression `1 + 2` is not a value, because it can be reduced to `3`. The expression `3` is a value, because it cannot be reduced any further.
|
||||
|
||||
Evaluation normally happens by applying rules to the "head" of the expression, which is the outermost part of the expression. The head of an expression like `[ 1 2 ]` is the list literal (`[ a1 a2 ]`), for `1 + 2` it is the addition operator (`+`), and for `f 1` it is the function application "operator" (` `).
|
||||
|
||||
After applying all possible rules to the head until no rules can be applied, the expression is in "weak head normal form" (WHNF). This means that the outermost constructor of the expression is evaluated, but the inner values may or may not be. "Weak" only signifies that the expression may be a function. This is an historical or academic artifact, and Nix has no use for the non-weak "head normal form".
|
||||
|
||||
## Laziness and thunks {#laziness}
|
||||
|
||||
The Nix language implements _call by need_ (as opposed to _call by value_ or _call by reference_). <!-- No wikipedia link, which would be a huge distraction. --> Call by need is commonly known as laziness in functional programming, as it is a specific implementation of the concept where evaluation is deferred until the result is required, aiming to only evaluate the parts of an expression that are needed to produce the final result.
|
||||
|
||||
Furthermore, the result of evaluation is preserved, in values, in `let` bindings, in function _parameters_, which behave a lot like `let` bindings, but with the notable exception of function _calls_. Results of function calls rely on being put into `let` bindings, etc to be reused. <!-- which would be prohibitively expensive and too strict, or we wouldn't have a cache key for the argument -->
|
||||
|
||||
When discussing the process of evaluation in lower level terms, we may define values not as a subset of expressions, but separately, where each "value" is either a data constructor, a function or a _thunk_. A thunk is a delayed computation, represented by an expression reference and a "closure" – the values for the lexical scope around the delayed expression.
|
||||
|
||||
As a user of the language, you generally don't have to think about thunks, as they are not part of the language semantics, but you may encounter them in the repl, in the [C API] or in discussions.
|
||||
|
||||
## Strictness
|
||||
|
||||
Instead of thinking about thunks, it is often more productive to think in terms of _strictness_.
|
||||
This term is used in functional programming to refer to the opposite of laziness, i.e. not just for something like error propagation. It refers to the need to evaluate certain expressions before evaluation can produce any result.
|
||||
|
||||
Statements about strictness usually implicitly refer to weak head normal form.
|
||||
For example, we can say that the following function is strict in its argument:
|
||||
|
||||
```nix
|
||||
x: isAttrs x || isFunction x
|
||||
```
|
||||
|
||||
The above function must be strict in its argument `x` because determining its type requires evaluating `x` to at least some degree.
|
||||
|
||||
The following function is not strict in its argument:
|
||||
|
||||
```nix
|
||||
x: { isOk = isAttrs x || isFunction x; }
|
||||
```
|
||||
|
||||
It is not strict, because it can return the attribute set before evaluating `x`.
|
||||
The attribute value for `isOk` _is_ strict in `x`.
|
||||
|
||||
A function with a _set pattern_ is always strict in its argument, as a consequence of checking the argument's type and/or attribute names:
|
||||
|
||||
```nix
|
||||
let f = { ... }: "ok";
|
||||
in f (throw "kablam")
|
||||
=> error: kablam
|
||||
```
|
||||
|
||||
However, a set pattern does not add any strictness beyond WHNF of the attribute set argument.
|
||||
|
||||
```nix
|
||||
let f = orig@{ x, ... }: "ok";
|
||||
in f { x = throw "error"; y = throw "error"; }
|
||||
=> "ok"
|
||||
```
|
||||
|
||||
## Evaluation order
|
||||
|
||||
The order in which expressions are evaluated is generally unspecified, because it does not affect successful evaluation outcomes.
|
||||
This allows more freedom for the evaluator to evolve and to evaluate efficiently.
|
||||
|
||||
Data dependencies naturally impose some ordering constraints: a value cannot be used before it is computed.
|
||||
Beyond these constraints, the evaluator is free to choose any order.
|
||||
|
||||
The order in which side effects such as [`builtins.trace`](@docroot@/language/builtins.md#builtins-trace) output occurs is not defined, but may be expected to follow data dependencies. <!-- we may want to be more specific about this. -->
|
||||
|
||||
In a lazy language, evaluation order is often opposite to expectations from strict languages.
|
||||
For example, in `let wrap = x: { wrapped = x; }; in wrap (1 + 2)`, the function body produces a result (`{ wrapped = ...; }`) *before* evaluating `x`.
|
||||
|
||||
## Infinite recursion and stack overflow
|
||||
|
||||
During evaluation, two types of errors can occur when expressions reference themselves or call functions too deeply:
|
||||
|
||||
### Infinite recursion
|
||||
|
||||
This error occurs when a value depends on itself through a cycle, making it impossible to compute.
|
||||
|
||||
```nix
|
||||
let x = x; in x
|
||||
=> error: infinite recursion encountered
|
||||
```
|
||||
|
||||
Infinite recursion happens at the value level when evaluating an expression requires evaluating the same expression again.
|
||||
|
||||
Despite the name, infinite recursion is cheap to compute and does not involve a stack overflow.
|
||||
The cycle is finite and fairly easy to detect.
|
||||
|
||||
### Stack overflow
|
||||
|
||||
This error occurs when the call depth exceeds the maximum allowed limit.
|
||||
|
||||
```nix
|
||||
let f = x: f (x + 1);
|
||||
in f 0
|
||||
=> error: stack overflow; max-call-depth exceeded
|
||||
```
|
||||
|
||||
Stack overflow happens when too many function calls are nested without returning.
|
||||
The maximum call depth is controlled by the [`max-call-depth` setting](@docroot@/command-ref/conf-file.md#conf-max-call-depth).
|
||||
|
||||
[C API]: @docroot@/c-api.md
|
||||
@@ -16,7 +16,7 @@ An *identifier* is an [ASCII](https://en.wikipedia.org/wiki/ASCII) character seq
|
||||
|
||||
# Names
|
||||
|
||||
A *name* can be written as an [identifier](#identifiers) or a [string literal](./string-literals.md).
|
||||
A *name* can be written as an [identifier](#identifier) or a [string literal](./string-literals.md).
|
||||
|
||||
> **Syntax**
|
||||
>
|
||||
|
||||
@@ -71,9 +71,8 @@ Boxes are data structures, arrow labels are transformations.
|
||||
| evaluate | | |
|
||||
| | | | |
|
||||
| V | | |
|
||||
| .------------. | | |
|
||||
| | derivation | | | .------------------. |
|
||||
| | expression |----|-instantiate-|->| store derivation | |
|
||||
| .------------. | | .------------------. |
|
||||
| | derivation |----|-instantiate-|->| store derivation | |
|
||||
| '------------' | | '------------------' |
|
||||
| | | | |
|
||||
| | | realise |
|
||||
|
||||
@@ -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**
|
||||
>
|
||||
@@ -11,14 +11,7 @@ The language is:
|
||||
|
||||
- *domain-specific*
|
||||
|
||||
The Nix language is purpose-built for working with text files.
|
||||
Its most characteristic features are:
|
||||
|
||||
- [File system path primitives](@docroot@/language/types.md#type-path), for accessing source files
|
||||
- [Indented strings](@docroot@/language/string-literals.md) and [string interpolation](@docroot@/language/string-interpolation.md), for creating file contents
|
||||
- [Strings with contexts](@docroot@/language/string-context.md), for transparently linking files
|
||||
|
||||
It comes with [built-in functions](@docroot@/language/builtins.md) to integrate with the [Nix store](@docroot@/store/index.md), which manages files and enables [realising](@docroot@/glossary.md#gloss-realise) derivations declared in the Nix language.
|
||||
It comes with [built-in functions](@docroot@/language/builtins.md) to integrate with the Nix store, which manages files and performs the derivations declared in the Nix language.
|
||||
|
||||
- *declarative*
|
||||
|
||||
@@ -137,7 +130,7 @@ This is an incomplete overview of language features, by example.
|
||||
</td>
|
||||
<td>
|
||||
|
||||
[Booleans](@docroot@/language/types.md#type-bool)
|
||||
[Booleans](@docroot@/language/types.md#type-boolean)
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@@ -245,7 +238,7 @@ This is an incomplete overview of language features, by example.
|
||||
</td>
|
||||
<td>
|
||||
|
||||
An [attribute set](@docroot@/language/types.md#type-attrs) with attributes named `x` and `y`
|
||||
An [attribute set](@docroot@/language/types.md#attribute-set) with attributes named `x` and `y`
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@@ -285,7 +278,7 @@ This is an incomplete overview of language features, by example.
|
||||
</td>
|
||||
<td>
|
||||
|
||||
[Lists](@docroot@/language/types.md#type-list) with three elements.
|
||||
[Lists](@docroot@/language/types.md#list) with three elements.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@@ -369,7 +362,7 @@ This is an incomplete overview of language features, by example.
|
||||
</td>
|
||||
<td>
|
||||
|
||||
[Attribute selection](@docroot@/language/types.md#type-attrs) (evaluates to `1`)
|
||||
[Attribute selection](@docroot@/language/types.md#attribute-set) (evaluates to `1`)
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@@ -381,7 +374,7 @@ This is an incomplete overview of language features, by example.
|
||||
</td>
|
||||
<td>
|
||||
|
||||
[Attribute selection](@docroot@/language/types.md#type-attrs) with default (evaluates to `3`)
|
||||
[Attribute selection](@docroot@/language/types.md#attribute-set) with default (evaluates to `3`)
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
builtins_md = custom_target(
|
||||
command : [ python.full_path(), '@INPUT0@', '@OUTPUT@', '--' ] + nix_eval_for_docs + [
|
||||
'--expr', '(builtins.readFile @INPUT3@) + import @INPUT1@ (builtins.fromJSON (builtins.readFile ./@INPUT2@)) + (builtins.readFile @INPUT4@)',
|
||||
command : [
|
||||
python.full_path(),
|
||||
'@INPUT0@',
|
||||
'@OUTPUT@',
|
||||
'--'
|
||||
] + nix_eval_for_docs + [
|
||||
'--expr',
|
||||
'(builtins.readFile @INPUT3@) + import @INPUT1@ (builtins.fromJSON (builtins.readFile ./@INPUT2@)) + (builtins.readFile @INPUT4@)',
|
||||
],
|
||||
input : [
|
||||
'../../remove_before_wrapper.py',
|
||||
'../../generate-builtins.nix',
|
||||
language_json,
|
||||
'builtins-prefix.md',
|
||||
'builtins-suffix.md',
|
||||
'builtins-suffix.md'
|
||||
],
|
||||
output : 'builtins.md',
|
||||
env : nix_env_for_docs,
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
| [Greater than or equal to][Comparison] | *expr* `>=` *expr* | none | 10 |
|
||||
| [Equality] | *expr* `==` *expr* | none | 11 |
|
||||
| Inequality | *expr* `!=` *expr* | none | 11 |
|
||||
| [Logical conjunction] (`AND`) | *bool* `&&` *bool* | left | [12](#precedence-and-disjunctive-normal-form) |
|
||||
| [Logical disjunction] (`OR`) | *bool* <code>\|\|</code> *bool* | left | [13](#precedence-and-disjunctive-normal-form) |
|
||||
| Logical conjunction (`AND`) | *bool* `&&` *bool* | left | 12 |
|
||||
| Logical disjunction (`OR`) | *bool* <code>\|\|</code> *bool* | left | 13 |
|
||||
| [Logical implication] | *bool* `->` *bool* | right | 14 |
|
||||
| [Pipe operator] (experimental) | *expr* `\|>` *func* | left | 15 |
|
||||
| [Pipe operator] (experimental) | *func* `<\|` *expr* | right | 15 |
|
||||
@@ -162,9 +162,6 @@ Update [attribute set] *attrset1* with names and values from *attrset2*.
|
||||
The returned attribute set will have all of the attributes in *attrset1* and *attrset2*.
|
||||
If an attribute name is present in both, the attribute value from the latter is taken.
|
||||
|
||||
This operator is [strict](@docroot@/language/evaluation.md#strictness) in both *attrset1* and *attrset2*.
|
||||
That means that both arguments are evaluated to [weak head normal form](@docroot@/language/evaluation.md#values), so the attribute sets themselves are evaluated, but their attribute values are not evaluated.
|
||||
|
||||
[Update]: #update
|
||||
|
||||
## Comparison
|
||||
@@ -188,95 +185,18 @@ All comparison operators are implemented in terms of `<`, and the following equi
|
||||
|
||||
## Equality
|
||||
|
||||
- [Attribute sets][attribute set] are compared first by attribute names and then by items until a difference is found.
|
||||
- [Lists][list] are compared first by length and then by items until a difference is found.
|
||||
- Comparison of distinct [functions][function] returns `false`, but identical functions may be subject to [value identity optimization](#value-identity-optimization).
|
||||
- [Attribute sets][attribute set] and [lists][list] are compared recursively, and therefore are fully evaluated.
|
||||
- Comparison of [functions][function] always returns `false`.
|
||||
- Numbers are type-compatible, see [arithmetic] operators.
|
||||
- Floating point numbers only differ up to a limited precision.
|
||||
|
||||
The `==` operator is [strict](@docroot@/language/evaluation.md#strictness) in both arguments; when comparing composite types ([attribute sets][attribute set] and [lists][list]), it is partially strict in their contained values: they are evaluated until a difference is found. <!-- this is woefully underspecified, affecting which expressions evaluate correctly; not just "ordering" or error messages. -->
|
||||
|
||||
### Value identity optimization
|
||||
|
||||
Nix performs equality comparisons of nested values by pointer equality or more abstractly, _identity_.
|
||||
Nix semantics ideally do not assign a unique identity to values as they are created, but equality is an exception to this rule.
|
||||
The disputable benefit of this is that it is more efficient, and it allows cyclical structures to be compared, e.g. `let x = { x = x; }; in x == x` evaluates to `true`.
|
||||
However, as a consequence, it makes a function equal to itself when the comparison is made in a list or attribute set, in contradiction to a simple direct comparison.
|
||||
|
||||
[function]: ./syntax.md#functions
|
||||
|
||||
[Equality]: #equality
|
||||
|
||||
## Logical conjunction
|
||||
|
||||
> **Syntax**
|
||||
>
|
||||
> *bool1* `&&` *bool2*
|
||||
|
||||
Logical AND. Equivalent to `if` *bool1* `then` *bool2* `else false`.
|
||||
|
||||
This operator is [strict](@docroot@/language/evaluation.md#strictness) in *bool1*, but only evaluates *bool2* if *bool1* is `true`.
|
||||
|
||||
> **Example**
|
||||
>
|
||||
> ```nix
|
||||
> true && false
|
||||
> => false
|
||||
>
|
||||
> false && throw "never evaluated"
|
||||
> => false
|
||||
> ```
|
||||
|
||||
[Logical conjunction]: #logical-conjunction
|
||||
|
||||
## Logical disjunction
|
||||
|
||||
> **Syntax**
|
||||
>
|
||||
> *bool1* `||` *bool2*
|
||||
|
||||
Logical OR. Equivalent to `if` *bool1* `then true` `else` *bool2*.
|
||||
|
||||
This operator is [strict](@docroot@/language/evaluation.md#strictness) in *bool1*, but only evaluates *bool2* if *bool1* is `false`.
|
||||
|
||||
> **Example**
|
||||
>
|
||||
> ```nix
|
||||
> true || false
|
||||
> => true
|
||||
>
|
||||
> true || throw "never evaluated"
|
||||
> => true
|
||||
> ```
|
||||
|
||||
[Logical disjunction]: #logical-disjunction
|
||||
|
||||
### Precedence and disjunctive normal form
|
||||
|
||||
The precedence of `&&` and `||` aligns with disjunctive normal form.
|
||||
Without parentheses, an expression describes multiple "permissible situations" (connected by `||`), where each situation consists of multiple simultaneous conditions (connected by `&&`).
|
||||
|
||||
For example, `A || B && C || D && E` is parsed as `A || (B && C) || (D && E)`, describing three permissible situations: A holds, or both B and C hold, or both D and E hold.
|
||||
|
||||
## Logical implication
|
||||
|
||||
> **Syntax**
|
||||
>
|
||||
> *bool1* `->` *bool2*
|
||||
|
||||
Logical implication. Equivalent to `!`*bool1* `||` *bool2* (or `if` *bool1* `then` *bool2* `else true`).
|
||||
|
||||
This operator is [strict](@docroot@/language/evaluation.md#strictness) in *bool1*, but only evaluates *bool2* if *bool1* is `true`.
|
||||
|
||||
> **Example**
|
||||
>
|
||||
> ```nix
|
||||
> true -> false
|
||||
> => false
|
||||
>
|
||||
> false -> throw "never evaluated"
|
||||
> => true
|
||||
> ```
|
||||
Equivalent to `!`*b1* `||` *b2*.
|
||||
|
||||
[Logical implication]: #logical-implication
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ The purpose of string contexts is to collect non-string values attached to strin
|
||||
[string concatenation](./operators.md#string-concatenation),
|
||||
[string interpolation](./string-interpolation.md),
|
||||
and similar operations.
|
||||
The idea is that a user can reference other files when creating text files through Nix expressions, without manually keeping track of the exact paths.
|
||||
Nix will ensure that the all referenced files are accessible – that all [store paths](@docroot@/glossary.md#gloss-store-path) are [valid](@docroot@/glossary.md#gloss-validity).
|
||||
The idea is that a user can combine together values to create a build instructions for derivations without manually keeping track of where they come from.
|
||||
Then the Nix language implicitly does that bookkeeping to efficiently obtain the closure of derivation inputs.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
@@ -111,11 +111,11 @@ It creates an [attribute set] representing the string context, which can be insp
|
||||
|
||||
[`builtins.hasContext`]: ./builtins.md#builtins-hasContext
|
||||
[`builtins.getContext`]: ./builtins.md#builtins-getContext
|
||||
[attribute set]: ./types.md#type-attrs
|
||||
[attribute set]: ./types.md#attribute-set
|
||||
|
||||
## Clearing string contexts
|
||||
|
||||
[`builtins.unsafeDiscardStringContext`](./builtins.md#builtins-unsafeDiscardStringContext) will make a copy of a string, but with an empty string context.
|
||||
[`buitins.unsafeDiscardStringContext`](./builtins.md#builtins-unsafeDiscardStringContext) will make a copy of a string, but with an empty string context.
|
||||
The returned string can be used in more ways, e.g. by operators that require the string context to be empty.
|
||||
The requirement to explicitly discard the string context in such use cases helps ensure that string context elements are not lost by mistake.
|
||||
The "unsafe" marker is only there to remind that Nix normally guarantees that dependencies are tracked, whereas the returned string has lost them.
|
||||
|
||||
@@ -6,7 +6,7 @@ Such a construct is called *interpolated string*, and the expression inside is a
|
||||
|
||||
[string]: ./types.md#type-string
|
||||
[path]: ./types.md#type-path
|
||||
[attribute set]: ./types.md#type-attrs
|
||||
[attribute set]: ./types.md#attribute-set
|
||||
|
||||
> **Syntax**
|
||||
>
|
||||
@@ -22,9 +22,9 @@ Rather than writing
|
||||
"--with-freetype2-library=" + freetype + "/lib"
|
||||
```
|
||||
|
||||
(where `freetype` is a [derivation expression]), you can instead write
|
||||
(where `freetype` is a [derivation]), you can instead write
|
||||
|
||||
[derivation expression]: @docroot@/glossary.md#gloss-derivation-expression
|
||||
[derivation]: @docroot@/glossary.md#gloss-derivation
|
||||
|
||||
```nix
|
||||
"--with-freetype2-library=${freetype}/lib"
|
||||
@@ -148,7 +148,7 @@ An expression that is interpolated must evaluate to one of the following:
|
||||
- `__toString` must be a function that takes the attribute set itself and returns a string
|
||||
- `outPath` must be a string
|
||||
|
||||
This includes [derivation expressions](./derivations.md) or [flake inputs](@docroot@/command-ref/new-cli/nix3-flake.md#flake-inputs) (experimental).
|
||||
This includes [derivations](./derivations.md) or [flake inputs](@docroot@/command-ref/new-cli/nix3-flake.md#flake-inputs) (experimental).
|
||||
|
||||
A string interpolates to itself.
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ See [String literals](string-literals.md).
|
||||
|
||||
Path literals can also include [string interpolation], besides being [interpolated into other expressions].
|
||||
|
||||
[interpolated into other expressions]: ./string-interpolation.md#interpolated-expression
|
||||
[interpolated into other expressions]: ./string-interpolation.md#interpolated-expressions
|
||||
|
||||
At least one slash (`/`) must appear *before* any interpolated expression for the result to be recognized as a path.
|
||||
|
||||
@@ -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
|
||||
@@ -235,7 +235,7 @@ of object-oriented programming, for example.
|
||||
|
||||
## Recursive sets
|
||||
|
||||
Recursive sets are like normal [attribute sets](./types.md#type-attrs), but the attributes can refer to each other.
|
||||
Recursive sets are like normal [attribute sets](./types.md#attribute-set), but the attributes can refer to each other.
|
||||
|
||||
> *rec-attrset* = `rec {` [ *name* `=` *expr* `;` `]`... `}`
|
||||
|
||||
@@ -287,7 +287,7 @@ This evaluates to `"foobar"`.
|
||||
|
||||
## Inheriting attributes
|
||||
|
||||
When defining an [attribute set](./types.md#type-attrs) or in a [let-expression](#let-expressions) it is often convenient to copy variables from the surrounding lexical scope (e.g., when you want to propagate attributes).
|
||||
When defining an [attribute set](./types.md#attribute-set) or in a [let-expression](#let-expressions) it is often convenient to copy variables from the surrounding lexical scope (e.g., when you want to propagate attributes).
|
||||
This can be shortened using the `inherit` keyword.
|
||||
|
||||
Example:
|
||||
@@ -443,7 +443,7 @@ three kinds of patterns:
|
||||
This works on any set that contains at least the three named
|
||||
attributes.
|
||||
|
||||
- It is possible to provide *default values* for attributes, in
|
||||
It is possible to provide *default values* for attributes, in
|
||||
which case they are allowed to be missing. A default value is
|
||||
specified by writing `name ? e`, where *e* is an arbitrary
|
||||
expression. For example,
|
||||
@@ -503,45 +503,6 @@ three kinds of patterns:
|
||||
> [ 23 {} ]
|
||||
> ```
|
||||
|
||||
- All bindings introduced by the function are in scope in the entire function expression; not just in the body.
|
||||
It can therefore be used in default values.
|
||||
|
||||
> **Example**
|
||||
>
|
||||
> A parameter (`x`), is used in the default value for another parameter (`y`):
|
||||
>
|
||||
> ```nix
|
||||
> let
|
||||
> f = { x, y ? [x] }: { inherit y; };
|
||||
> in
|
||||
> f { x = 3; }
|
||||
> ```
|
||||
>
|
||||
> This evaluates to:
|
||||
>
|
||||
> ```nix
|
||||
> {
|
||||
> y = [ 3 ];
|
||||
> }
|
||||
> ```
|
||||
|
||||
> **Example**
|
||||
>
|
||||
> The binding of an `@` pattern, `args`, is used in the default value for a parameter, `x`:
|
||||
>
|
||||
> ```nix
|
||||
> let
|
||||
> f = args@{ x ? args.a, ... }: x;
|
||||
> in
|
||||
> f { a = 1; }
|
||||
> ```
|
||||
>
|
||||
> This evaluates to:
|
||||
>
|
||||
> ```nix
|
||||
> 1
|
||||
> ```
|
||||
|
||||
Note that functions do not have names. If you want to give them a name,
|
||||
you can bind them to an attribute, e.g.,
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
# Process JSON schema documentation
|
||||
subdir('protocols')
|
||||
|
||||
summary_rl_next = custom_target(
|
||||
command : [
|
||||
bash,
|
||||
'-euo',
|
||||
'pipefail',
|
||||
'-euo', 'pipefail',
|
||||
'-c',
|
||||
'''
|
||||
if [ -e "@INPUT@" ]; then
|
||||
@@ -16,6 +12,6 @@ summary_rl_next = custom_target(
|
||||
input : [
|
||||
rl_next_generated,
|
||||
],
|
||||
capture : true,
|
||||
capture: true,
|
||||
output : 'SUMMARY-rl-next.md',
|
||||
)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
# Derivation "ATerm" file format
|
||||
|
||||
For historical reasons, [store derivations][store derivation] are stored on-disk in "Annotated Term" (ATerm) format
|
||||
([guide](https://homepages.cwi.nl/~daybuild/daily-books/technology/aterm-guide/aterm-guide.html),
|
||||
[paper](https://doi.org/10.1002/(SICI)1097-024X(200003)30:3%3C259::AID-SPE298%3E3.0.CO;2-Y)).
|
||||
|
||||
## The ATerm format used
|
||||
For historical reasons, [derivations](@docroot@/glossary.md#gloss-store-derivation) are stored on-disk in [ATerm](https://homepages.cwi.nl/~daybuild/daily-books/technology/aterm-guide/aterm-guide.html) format.
|
||||
|
||||
Derivations are serialised in one of the following formats:
|
||||
|
||||
@@ -21,20 +17,3 @@ Derivations are serialised in one of the following formats:
|
||||
The only `version-string`s that are in use today are for [experimental features](@docroot@/development/experimental-features.md):
|
||||
|
||||
- `"xp-dyn-drv"` for the [`dynamic-derivations`](@docroot@/development/experimental-features.md#xp-feature-dynamic-derivations) experimental feature.
|
||||
|
||||
## Use for encoding to store object
|
||||
|
||||
When derivation is encoded to a [store object] we make the following choices:
|
||||
|
||||
- The store path name is the derivation name with `.drv` suffixed at the end
|
||||
|
||||
Indeed, the ATerm format above does *not* contain the name of the derivation, on the assumption that a store path will also be provided out-of-band.
|
||||
|
||||
- The derivation is content-addressed using the ["Text" method] of content-addressing derivations
|
||||
|
||||
Currently we always encode derivations to store object using the ATerm format (and the previous two choices),
|
||||
but we reserve the option to encode new sorts of derivations differently in the future.
|
||||
|
||||
[store derivation]: @docroot@/glossary.md#gloss-store-derivation
|
||||
[store object]: @docroot@/glossary.md#gloss-store-object
|
||||
["Text" method]: @docroot@/store/store-object/content-address.md#method-text
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
{{#include build-result-v1-fixed.md}}
|
||||
|
||||
## Examples
|
||||
|
||||
### Successful build
|
||||
|
||||
```json
|
||||
{{#include schema/build-result-v1/success.json}}
|
||||
```
|
||||
|
||||
### Failed build (output rejected)
|
||||
|
||||
```json
|
||||
{{#include schema/build-result-v1/output-rejected.json}}
|
||||
```
|
||||
|
||||
### Failed build (non-deterministic)
|
||||
|
||||
```json
|
||||
{{#include schema/build-result-v1/not-deterministic.json}}
|
||||
```
|
||||
@@ -1,27 +0,0 @@
|
||||
{{#include build-trace-entry-v1-fixed.md}}
|
||||
|
||||
## Examples
|
||||
|
||||
### Simple build trace entry
|
||||
|
||||
```json
|
||||
{{#include schema/build-trace-entry-v1/simple.json}}
|
||||
```
|
||||
|
||||
### Build trace entry with dependencies
|
||||
|
||||
```json
|
||||
{{#include schema/build-trace-entry-v1/with-dependent-realisations.json}}
|
||||
```
|
||||
|
||||
### Build trace entry with signature
|
||||
|
||||
```json
|
||||
{{#include schema/build-trace-entry-v1/with-signature.json}}
|
||||
```
|
||||
|
||||
<!--
|
||||
## Raw Schema
|
||||
|
||||
[JSON Schema for Build Trace Entry v1](schema/build-trace-entry-v1.json)
|
||||
-->
|
||||
@@ -1,21 +0,0 @@
|
||||
{{#include content-address-v1-fixed.md}}
|
||||
|
||||
## Examples
|
||||
|
||||
### [Text](@docroot@/store/store-object/content-address.html#method-text) method
|
||||
|
||||
```json
|
||||
{{#include schema/content-address-v1/text.json}}
|
||||
```
|
||||
|
||||
### [Nix Archive](@docroot@/store/store-object/content-address.html#method-nix-archive) method
|
||||
|
||||
```json
|
||||
{{#include schema/content-address-v1/nar.json}}
|
||||
```
|
||||
|
||||
<!-- need to convert YAML to JSON first
|
||||
## Raw Schema
|
||||
|
||||
[JSON Schema for Hash v1](schema/content-address-v1.json)
|
||||
-->
|
||||
92
doc/manual/source/protocols/json/derivation.md
Normal file
92
doc/manual/source/protocols/json/derivation.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# Derivation JSON Format
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> This JSON format is currently
|
||||
> [**experimental**](@docroot@/development/experimental-features.md#xp-feature-nix-command)
|
||||
> and subject to change.
|
||||
|
||||
The JSON serialization of a
|
||||
[derivations](@docroot@/glossary.md#gloss-store-derivation)
|
||||
is a JSON object with the following fields:
|
||||
|
||||
* `name`:
|
||||
The name of the derivation.
|
||||
This is used when calculating the store paths of the derivation's outputs.
|
||||
|
||||
* `outputs`:
|
||||
Information about the output paths of the derivation.
|
||||
This is a JSON object with one member per output, where the key is the output name and the value is a JSON object with these fields:
|
||||
|
||||
* `path`:
|
||||
The output path, if it is known in advanced.
|
||||
Otherwise, `null`.
|
||||
|
||||
|
||||
* `method`:
|
||||
For an output which will be [content addresed], a string representing the [method](@docroot@/store/store-object/content-address.md) of content addressing that is chosen.
|
||||
Valid method strings are:
|
||||
|
||||
- [`flat`](@docroot@/store/store-object/content-address.md#method-flat)
|
||||
- [`nar`](@docroot@/store/store-object/content-address.md#method-nix-archive)
|
||||
- [`text`](@docroot@/store/store-object/content-address.md#method-text)
|
||||
- [`git`](@docroot@/store/store-object/content-address.md#method-git)
|
||||
|
||||
Otherwise, `null`.
|
||||
|
||||
* `hashAlgo`:
|
||||
For an output which will be [content addresed], the name of the hash algorithm used.
|
||||
Valid algorithm strings are:
|
||||
|
||||
- `md5`
|
||||
- `sha1`
|
||||
- `sha256`
|
||||
- `sha512`
|
||||
|
||||
* `hash`:
|
||||
For fixed-output derivations, the expected content hash in base-16.
|
||||
|
||||
> **Example**
|
||||
>
|
||||
> ```json
|
||||
> "outputs": {
|
||||
> "out": {
|
||||
> "path": "/nix/store/2543j7c6jn75blc3drf4g5vhb1rhdq29-source",
|
||||
> "method": "nar",
|
||||
> "hashAlgo": "sha256",
|
||||
> "hash": "6fc80dcc62179dbc12fc0b5881275898f93444833d21b89dfe5f7fbcbb1d0d62"
|
||||
> }
|
||||
> }
|
||||
> ```
|
||||
|
||||
* `inputSrcs`:
|
||||
A list of store paths on which this derivation depends.
|
||||
|
||||
* `inputDrvs`:
|
||||
A JSON object specifying the derivations on which this derivation depends, and what outputs of those derivations.
|
||||
|
||||
> **Example**
|
||||
>
|
||||
> ```json
|
||||
> "inputDrvs": {
|
||||
> "/nix/store/6lkh5yi7nlb7l6dr8fljlli5zfd9hq58-curl-7.73.0.drv": ["dev"],
|
||||
> "/nix/store/fn3kgnfzl5dzym26j8g907gq3kbm8bfh-unzip-6.0.drv": ["out"]
|
||||
> }
|
||||
> ```
|
||||
|
||||
specifies that this derivation depends on the `dev` output of `curl`, and the `out` output of `unzip`.
|
||||
|
||||
* `system`:
|
||||
The system type on which this derivation is to be built
|
||||
(e.g. `x86_64-linux`).
|
||||
|
||||
* `builder`:
|
||||
The absolute path of the program to be executed to run the build.
|
||||
Typically this is the `bash` shell
|
||||
(e.g. `/nix/store/r3j288vpmczbl500w6zz89gyfa4nr0b1-bash-4.4-p23/bin/bash`).
|
||||
|
||||
* `args`:
|
||||
The command-line arguments passed to the `builder`.
|
||||
|
||||
* `env`:
|
||||
The environment passed to the `builder`.
|
||||
@@ -1,7 +0,0 @@
|
||||
{{#include ../derivation-v4-fixed.md}}
|
||||
|
||||
<!-- need to convert YAML to JSON first
|
||||
## Raw Schema
|
||||
|
||||
[JSON Schema for Derivation v4](schema/derivation-v4.json)
|
||||
-->
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user