Compare commits

..
Author SHA1 Message Date
DavHau 032122400b enable nixos tests for fetchGit and remote builds 2024-11-20 15:16:23 -05:00
1908 changed files with 54523 additions and 95068 deletions

No files matched your search

+1 -2
View File
@@ -8,7 +8,7 @@ BraceWrapping:
AfterUnion: true AfterUnion: true
SplitEmptyRecord: false SplitEmptyRecord: false
PointerAlignment: Middle PointerAlignment: Middle
FixNamespaceComments: true FixNamespaceComments: false
SortIncludes: Never SortIncludes: Never
#IndentPPDirectives: BeforeHash #IndentPPDirectives: BeforeHash
SpaceAfterCStyleCast: true SpaceAfterCStyleCast: true
@@ -32,4 +32,3 @@ IndentPPDirectives: AfterHash
PPIndentWidth: 2 PPIndentWidth: 2
BinPackArguments: false BinPackArguments: false
BreakBeforeTernaryOperators: true BreakBeforeTernaryOperators: true
SeparateDefinitionBlocks: Always
-18
View File
@@ -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
-6
View File
@@ -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
+10 -1
View File
@@ -11,7 +11,16 @@
.github/CODEOWNERS @edolstra .github/CODEOWNERS @edolstra
# Documentation of built-in functions # 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 # Libstore layer
/src/libstore @ericson2314 /src/libstore @ericson2314
+16 -34
View File
@@ -1,54 +1,36 @@
--- ---
name: Bug report name: Bug report
about: Report unexpected or incorrect behaviour about: Create a report to help us improve
title: '' title: ''
labels: bug labels: bug
assignees: '' assignees: ''
--- ---
## Describe the bug **Describe the bug**
<!-- A clear and concise description of what the bug is.
A clear and concise description of what the bug is.
If you have a problem with a specific package or NixOS, If you have a problem with a specific package or NixOS,
you probably want to file an issue at https://github.com/NixOS/nixpkgs/issues. you probably want to file an issue at https://github.com/NixOS/nixpkgs/issues.
-->
## Steps To Reproduce **Steps To Reproduce**
<!-- 1. Go to '...'
Example: 2. Click on '....'
3. Scroll down to '....'
4. See error
1. Clone this repository: ... **Expected behavior**
2. Run `nix-... ...`
3. Observe unexpected behaviour
-->
## Expected behavior A clear and concise description of what you expected to happen.
<!-- A clear and concise description of what you expected to happen. --> **`nix-env --version` output**
## Metadata **Additional context**
<!-- Please insert the output of running `nix-env --version` below this line --> Add any other context about the problem here.
## Additional context **Priorities**
<!-- Add any other context about the problem here. -->
## Checklist
<!-- make sure this issue is not redundant or obsolete -->
- [ ] checked [latest Nix manual] \([source])
- [ ] checked [open bug issues and pull requests] for possible duplicates
[latest Nix manual]: https://nix.dev/manual/nix/development/
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
[open bug issues and pull requests]: https://github.com/NixOS/nix/labels/bug
---
Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc). Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
+10 -25
View File
@@ -1,39 +1,24 @@
--- ---
name: Feature request name: Feature request
about: Suggest a new feature about: Suggest an idea for this project
title: '' title: ''
labels: feature labels: feature
assignees: '' assignees: ''
--- ---
## Is your feature request related to a problem? **Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] --> **Describe the solution you'd like**
A clear and concise description of what you want to happen.
## Proposed solution **Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
<!-- A clear and concise description of what you want to happen. --> **Additional context**
Add any other context or screenshots about the feature request here.
## Alternative solutions **Priorities**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
## Additional context
<!-- Add any other context or screenshots about the feature request here. -->
## Checklist
<!-- make sure this issue is not redundant or obsolete -->
- [ ] checked [latest Nix manual] \([source])
- [ ] checked [open feature issues and pull requests] for possible duplicates
[latest Nix manual]: https://nix.dev/manual/nix/development/
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
[open feature issues and pull requests]: https://github.com/NixOS/nix/labels/feature
---
Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc). Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
+3 -14
View File
@@ -23,25 +23,14 @@ assignees: ''
<details><summary>Output</summary> <details><summary>Output</summary>
<!-- paste console output inside the below code block -->
```log ```log
<!-- paste console output here and remove this comment -->
``` ```
</details> </details>
## Checklist ## Priorities
<!-- make sure this issue is not redundant or obsolete -->
- [ ] checked [latest Nix manual] \([source])
- [ ] checked [open installer issues and pull requests] for possible duplicates
[latest Nix manual]: https://nix.dev/manual/nix/development/
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
[open installer issues and pull requests]: https://github.com/NixOS/nix/labels/installer
---
Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc). Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
@@ -22,10 +22,10 @@ assignees: ''
- [ ] checked [latest Nix manual] \([source]) - [ ] checked [latest Nix manual] \([source])
- [ ] checked [open documentation issues and pull requests] for possible duplicates - [ ] 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 [source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
[open documentation issues and pull requests]: https://github.com/NixOS/nix/labels/documentation [open documentation issues and pull requests]: https://github.com/NixOS/nix/labels/documentation
--- ## Priorities
Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc). Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
+3 -9
View File
@@ -15,18 +15,12 @@ so you understand the process and the expectations.
- volunteering contributions effectively - volunteering contributions effectively
- how to get help and our review process. - 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 # Motivation
<!-- Briefly explain what the change is about and why it is desirable. --> <!-- Briefly explain what the change is about and why it is desirable. -->
## Context # Context
<!-- Provide context. Reference open issues if available. --> <!-- Provide context. Reference open issues if available. -->
<!-- Non-trivial change: Briefly outline the implementation strategy. --> <!-- Non-trivial change: Briefly outline the implementation strategy. -->
@@ -35,7 +29,7 @@ PR stuck in review? We have two Nix team meetings per week online that are open
<!-- Large change: Provide instructions to reviewers how to read the diff. --> <!-- Large change: Provide instructions to reviewers how to read the diff. -->
--- # Priorities and Process
Add :+1: to [pull requests you find important](https://github.com/NixOS/nix/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc). Add :+1: to [pull requests you find important](https://github.com/NixOS/nix/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc).
+1 -1
View File
@@ -3,7 +3,7 @@
- Thanks for your contribution! - Thanks for your contribution!
- To remove the stale label, just leave a new comment. - To remove the stale label, just leave a new comment.
- _How to find the right people to ping?_ &rarr; [`git blame`](https://git-scm.com/docs/git-blame) to the rescue! (or GitHub's history and blame buttons.) - _How to find the right people to ping?_ &rarr; [`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 ## Suggestions for PRs
@@ -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
View File
@@ -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@v5
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}.
+123 -224
View File
@@ -2,194 +2,124 @@ name: "CI"
on: on:
pull_request: pull_request:
merge_group:
push: 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 permissions: read-all
jobs: jobs:
eval:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
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@v5
- 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
tests: tests:
needs: basic-checks needs: [check_secrets]
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: os: [ubuntu-latest, macos-latest]
- scenario: on ubuntu runs-on: ${{ matrix.os }}
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 timeout-minutes: 60
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: ./.github/actions/install-nix-action - uses: cachix/install-nix-action@v30
with: 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 # The sandbox would otherwise be disabled by default on Darwin
extra_nix_config: "sandbox = true" extra_nix_config: "sandbox = true"
# Since ubuntu 22.30, unprivileged usernamespaces are no longer allowed to map to the root user: - run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
# https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces - uses: cachix/cachix-action@v15
- run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 if: needs.check_secrets.outputs.cachix == 'true'
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: with:
name: coverage-reports name: '${{ env.CACHIX_NAME }}'
path: coverage-reports/ signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
if: ${{ matrix.instrumented }} authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Upload installer tarball - if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v5 run: |
free -h
swapon --show
swap=$(swapon --show --noheadings | head -n 1 | awk '{print $1}')
echo "Found swap: $swap"
sudo swapoff $swap
# resize it (fallocate)
sudo fallocate -l 10G $swap
sudo mkswap $swap
sudo swapon $swap
free -h
(
while sleep 60; do
free -h
done
) &
- run: nix --experimental-features 'nix-command flakes' flake check -L
- run: nix --experimental-features 'nix-command flakes' flake show --all-systems --json
# Steps to test CI automation in your own fork.
# Cachix:
# 1. Sign-up for https://www.cachix.org/
# 2. Create a cache for $githubuser-nix-install-tests
# 3. Create a cachix auth token and save it in https://github.com/$githubuser/nix/settings/secrets/actions in "Repository secrets" as CACHIX_AUTH_TOKEN
# Dockerhub:
# 1. Sign-up for https://hub.docker.com/
# 2. Store your dockerhub username as DOCKERHUB_USERNAME in "Repository secrets" of your fork repository settings (https://github.com/$githubuser/nix/settings/secrets/actions)
# 3. Create an access token in https://hub.docker.com/settings/security and store it as DOCKERHUB_TOKEN in "Repository secrets" of your fork
check_secrets:
permissions:
contents: none
name: Check Cachix and Docker secrets present for installer tests
runs-on: ubuntu-latest
outputs:
cachix: ${{ steps.secret.outputs.cachix }}
docker: ${{ steps.secret.outputs.docker }}
steps:
- name: Check for secrets
id: secret
env:
_CACHIX_SECRETS: ${{ secrets.CACHIX_SIGNING_KEY }}${{ secrets.CACHIX_AUTH_TOKEN }}
_DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }}
run: |
echo "::set-output name=cachix::${{ env._CACHIX_SECRETS != '' }}"
echo "::set-output name=docker::${{ env._DOCKER_SECRETS != '' }}"
installer:
needs: [tests, check_secrets]
if: github.event_name == 'push' && needs.check_secrets.outputs.cachix == 'true'
runs-on: ubuntu-latest
outputs:
installerURL: ${{ steps.prepare-installer.outputs.installerURL }}
steps:
- uses: actions/checkout@v4
with: with:
name: installer-${{matrix.os}} fetch-depth: 0
path: out/* - run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
if: ${{ matrix.primary }} - uses: cachix/install-nix-action@v30
with:
install_url: https://releases.nixos.org/nix/nix-2.20.3/install
- uses: cachix/cachix-action@v15
with:
name: '${{ env.CACHIX_NAME }}'
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
cachixArgs: '-v'
- id: prepare-installer
run: scripts/prepare-installer-for-github-actions
installer_test: installer_test:
needs: [tests] needs: [installer, check_secrets]
if: github.event_name == 'push' && needs.check_secrets.outputs.cachix == 'true'
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: os: [ubuntu-latest, macos-latest]
- scenario: on ubuntu runs-on: ${{ matrix.os }}
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: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v4
- name: Download installer tarball - run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
uses: actions/download-artifact@v6 - uses: cachix/install-nix-action@v30
with: with:
name: installer-${{matrix.os}} install_url: '${{needs.installer.outputs.installerURL}}'
path: out install_options: "--tarball-url-prefix https://${{ env.CACHIX_NAME }}.cachix.org/serve"
- 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 }}
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 }}
- run: sudo apt install fish zsh - run: sudo apt install fish zsh
if: matrix.os == 'linux' if: matrix.os == 'ubuntu-latest'
- run: brew install fish - run: brew install fish
if: matrix.os == 'darwin' if: matrix.os == 'macos-latest'
- run: exec bash -c "nix-instantiate -E 'builtins.currentTime' --eval" - run: exec bash -c "nix-instantiate -E 'builtins.currentTime' --eval"
- run: exec sh -c "nix-instantiate -E 'builtins.currentTime' --eval" - run: exec sh -c "nix-instantiate -E 'builtins.currentTime' --eval"
- run: exec zsh -c "nix-instantiate -E 'builtins.currentTime' --eval" - run: exec zsh -c "nix-instantiate -E 'builtins.currentTime' --eval"
@@ -197,46 +127,33 @@ jobs:
- run: exec bash -c "nix-channel --add https://releases.nixos.org/nixos/unstable/nixos-23.05pre466020.60c1d71f2ba nixpkgs" - run: exec bash -c "nix-channel --add https://releases.nixos.org/nixos/unstable/nixos-23.05pre466020.60c1d71f2ba nixpkgs"
- run: exec bash -c "nix-channel --update && nix-env -iA nixpkgs.hello && hello" - run: exec bash -c "nix-channel --update && nix-env -iA nixpkgs.hello && hello"
# Steps to test CI automation in your own fork.
# 1. Sign-up for https://hub.docker.com/
# 2. Store your dockerhub username as DOCKERHUB_USERNAME in "Repository secrets" of your fork repository settings (https://github.com/$githubuser/nix/settings/secrets/actions)
# 3. Create an access token in https://hub.docker.com/settings/security and store it as DOCKERHUB_TOKEN in "Repository secrets" of your fork
check_secrets:
permissions:
contents: none
name: Check presence of secrets
runs-on: ubuntu-24.04
outputs:
docker: ${{ steps.secret.outputs.docker }}
steps:
- name: Check for DockerHub secrets
id: secret
env:
_DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }}
run: |
echo "docker=${{ env._DOCKER_SECRETS != '' }}" >> $GITHUB_OUTPUT
docker_push_image: docker_push_image:
needs: [tests, check_secrets] needs: [check_secrets, tests]
permissions: permissions:
contents: read contents: read
packages: write packages: write
if: >- if: >-
needs.check_secrets.outputs.docker == 'true' &&
github.event_name == 'push' && github.event_name == 'push' &&
github.ref_name == 'master' github.ref_name == 'master' &&
runs-on: ubuntu-24.04 needs.check_secrets.outputs.cachix == 'true' &&
needs.check_secrets.outputs.docker == 'true'
runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: ./.github/actions/install-nix-action - uses: cachix/install-nix-action@v30
with: with:
dogfood: false install_url: https://releases.nixos.org/nix/nix-2.20.3/install
extra_nix_config: | - run: echo CACHIX_NAME="$(echo $GITHUB_REPOSITORY-install-tests | tr "[A-Z]/" "[a-z]-")" >> $GITHUB_ENV
experimental-features = flakes nix-command - run: echo NIX_VERSION="$(nix --experimental-features 'nix-command flakes' eval .\#nix.version | tr -d \")" >> $GITHUB_ENV
- run: echo NIX_VERSION="$(nix eval .\#nix.version | tr -d \")" >> $GITHUB_ENV - uses: cachix/cachix-action@v15
- run: nix build .#dockerImage -L if: needs.check_secrets.outputs.cachix == 'true'
with:
name: '${{ env.CACHIX_NAME }}'
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix --experimental-features 'nix-command flakes' build .#dockerImage -L
- run: docker load -i ./result/image.tar.gz - 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:$NIX_VERSION
- run: docker tag nix:$NIX_VERSION ${{ secrets.DOCKERHUB_USERNAME }}/nix:master - run: docker tag nix:$NIX_VERSION ${{ secrets.DOCKERHUB_USERNAME }}/nix:master
@@ -271,48 +188,30 @@ jobs:
docker tag nix:$NIX_VERSION $IMAGE_ID:master docker tag nix:$NIX_VERSION $IMAGE_ID:master
docker push $IMAGE_ID:master docker push $IMAGE_ID:master
vm_tests:
runs-on: ubuntu-22.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.githubFlakes .#hydraJobs.tests.tarballFlakes .#hydraJobs.tests.functional_user
flake_regressions: flake_regressions:
needs: tests needs: vm_tests
runs-on: ubuntu-24.04 runs-on: ubuntu-22.04
steps: steps:
- name: Checkout nix - name: Checkout nix
uses: actions/checkout@v5 uses: actions/checkout@v4
- name: Checkout flake-regressions - name: Checkout flake-regressions
uses: actions/checkout@v5 uses: actions/checkout@v4
with: with:
repository: NixOS/flake-regressions repository: NixOS/flake-regressions
path: flake-regressions path: flake-regressions
- name: Checkout flake-regressions-data - name: Checkout flake-regressions-data
uses: actions/checkout@v5 uses: actions/checkout@v4
with: with:
repository: NixOS/flake-regressions-data repository: NixOS/flake-regressions-data
path: flake-regressions/tests path: flake-regressions/tests
- uses: ./.github/actions/install-nix-action - uses: DeterminateSystems/nix-installer-action@main
with: - uses: DeterminateSystems/magic-nix-cache-action@main
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }} - run: nix build --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh
extra_nix_config:
experimental-features = nix-command flakes
github_token: ${{ secrets.GITHUB_TOKEN }}
- 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@v5
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 -2
View File
@@ -15,10 +15,10 @@ permissions:
jobs: jobs:
labels: labels:
runs-on: ubuntu-24.04 runs-on: ubuntu-latest
if: github.repository_owner == 'NixOS' if: github.repository_owner == 'NixOS'
steps: steps:
- uses: actions/labeler@v6 - uses: actions/labeler@v5
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
sync-labels: false sync-labels: false
+120 -7
View File
@@ -1,12 +1,110 @@
Makefile.config
perl/Makefile.config
# /
/aclocal.m4
/autom4te.cache
/precompiled-headers.h.gch
/config.*
/configure
/stamp-h1
/svn-revision
/libtool
/config/config.*
# Default meson build dir # Default meson build dir
/build /build
# /doc/manual/
/doc/manual/*.1
/doc/manual/*.5
/doc/manual/*.8
/doc/manual/generated/*
/doc/manual/nix.json
/doc/manual/conf-file.json
/doc/manual/language.json
/doc/manual/xp-features.json
/doc/manual/source/SUMMARY.md
/doc/manual/source/SUMMARY-rl-next.md
/doc/manual/source/store/types/*
!/doc/manual/source/store/types/index.md.in
/doc/manual/source/command-ref/new-cli
/doc/manual/source/command-ref/conf-file.md
/doc/manual/source/command-ref/experimental-features-shortlist.md
/doc/manual/source/contributing/experimental-feature-descriptions.md
/doc/manual/source/language/builtins.md
/doc/manual/source/language/builtin-constants.md
/doc/manual/source/release-notes/rl-next.md
# /scripts/
/scripts/nix-profile.sh
/scripts/nix-profile-daemon.sh
/scripts/nix-profile.fish
/scripts/nix-profile-daemon.fish
# /src/libexpr/
/src/libexpr/lexer-tab.cc
/src/libexpr/lexer-tab.hh
/src/libexpr/parser-tab.cc
/src/libexpr/parser-tab.hh
/src/libexpr/parser-tab.output
/src/libexpr/nix.tbl
/src/libexpr/tests
/src/libexpr-tests/libnixexpr-tests
# /src/libfetchers
/src/libfetchers-tests/libnixfetchers-tests
# /src/libflake
/src/libflake-tests/libnixflake-tests
# /src/libstore/
*.gen.*
/src/libstore/tests
/src/libstore-tests/libnixstore-tests
# /src/libutil/
/src/libutil/tests
/src/libutil-tests/libnixutil-tests
/src/nix/nix
/src/nix/generated-doc
# /src/nix-env/
/src/nix-env/nix-env
# /src/nix-instantiate/
/src/nix-instantiate/nix-instantiate
# /src/nix-store/
/src/nix-store/nix-store
/src/nix-prefetch-url/nix-prefetch-url
/src/nix-collect-garbage/nix-collect-garbage
# /src/nix-channel/
/src/nix-channel/nix-channel
# /src/nix-build/
/src/nix-build/nix-build
/src/nix-copy-closure/nix-copy-closure
/src/error-demo/error-demo
/src/build-remote/build-remote
# /tests/functional/ # /tests/functional/
/tests/functional/test-tmp
/tests/functional/common/subst-vars.sh /tests/functional/common/subst-vars.sh
/tests/functional/result*
/tests/functional/restricted-innocent /tests/functional/restricted-innocent
/tests/functional/shell
/tests/functional/shell.drv
/tests/functional/repl-result-out
/tests/functional/debugger-test-out /tests/functional/debugger-test-out
/tests/functional/test-libstoreconsumer/test-libstoreconsumer /tests/functional/test-libstoreconsumer/test-libstoreconsumer
/tests/functional/nix-shell
# /tests/functional/lang/ # /tests/functional/lang/
/tests/functional/lang/*.out /tests/functional/lang/*.out
@@ -14,9 +112,27 @@
/tests/functional/lang/*.err /tests/functional/lang/*.err
/tests/functional/lang/*.ast /tests/functional/lang/*.ast
/outputs /perl/lib/Nix/Config.pm
/perl/lib/Nix/Store.cc
/misc/systemd/nix-daemon.service
/misc/systemd/nix-daemon.socket
/misc/systemd/nix-daemon.conf
/misc/upstart/nix-daemon.conf
outputs/
*.a
*.o
*.o.tmp
*.so
*.dylib
*.dll
*.exe
*.dep
*~ *~
*.pc
*.plist
# GNU Global # GNU Global
GPATH GPATH
@@ -31,6 +147,8 @@ GTAGS
compile_commands.json compile_commands.json
*.compile_commands.json *.compile_commands.json
nix-rust/target
result result
result-* result-*
@@ -45,8 +163,3 @@ result-*
# Mac OS # Mac OS
.DS_Store .DS_Store
flake-regressions
# direnv
.direnv/
+92
View File
@@ -0,0 +1,92 @@
queue_rules:
- name: default
# all required tests need to go here
merge_conditions:
- check-success=installer
- check-success=installer_test (macos-latest)
- check-success=installer_test (ubuntu-latest)
- check-success=tests (macos-latest)
- check-success=tests (ubuntu-latest)
- check-success=vm_tests
merge_method: rebase
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:
- merge-queue
- name: backport patches to 2.19
conditions:
- label=backport 2.19-maintenance
actions:
backport:
branches:
- 2.19-maintenance
labels:
- merge-queue
- name: backport patches to 2.20
conditions:
- label=backport 2.20-maintenance
actions:
backport:
branches:
- 2.20-maintenance
labels:
- merge-queue
- name: backport patches to 2.21
conditions:
- label=backport 2.21-maintenance
actions:
backport:
branches:
- 2.21-maintenance
labels:
- merge-queue
- name: backport patches to 2.22
conditions:
- label=backport 2.22-maintenance
actions:
backport:
branches:
- 2.22-maintenance
labels:
- merge-queue
- name: backport patches to 2.23
conditions:
- label=backport 2.23-maintenance
actions:
backport:
branches:
- 2.23-maintenance
labels:
- merge-queue
- name: backport patches to 2.24
conditions:
- label=backport 2.24-maintenance
actions:
backport:
branches:
- "2.24-maintenance"
labels:
- merge-queue
+1 -1
View File
@@ -1 +1 @@
2.33.0 2.25.0
+1 -1
View File
@@ -89,7 +89,7 @@ Check out the [security policy](https://github.com/NixOS/nix/security/policy).
## Making changes to the Nix manual ## 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). 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 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). For larger changes see the [Nix reference manual](https://nix.dev/manual/nix/development/development/contributing.html).
+14 -11
View File
@@ -1,8 +1,8 @@
GNU LESSER GENERAL PUBLIC LICENSE GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999 Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc. 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 Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. 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 as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.] the version number 2.1.]
Preamble Preamble
The licenses for most software are designed to take away your The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public 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 former contains code derived from the library, whereas the latter must
be combined with the library in order to run. 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 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other 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 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 writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does. and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's 1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an 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 of all derivatives of our free software and of promoting the sharing
and reuse of software generally. and reuse of software generally.
NO WARRANTY NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 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 SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES. DAMAGES.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries 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. Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public 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. 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 Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker. library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Moe Ghoul>, 1 April 1990 <signature of Ty Coon>, 1 April 1990
Moe Ghoul, President of Vice Ty Coon, President of Vice
That's all there is to it! That's all there is to it!
+1 -1
View File
@@ -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) - [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 - [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos) is a Linux distribution that can be configured fully declaratively
- [Discourse](https://discourse.nixos.org/) - [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 ## License
@@ -6,7 +6,7 @@
# *interface*. # *interface*.
# #
# See `man pkg-config` for some details. # See `man pkg-config` for some details.
deps_private = [] deps_private = [ ]
# These are public dependencies with pkg-config files. Public is the # These are public dependencies with pkg-config files. Public is the
# opposite of private: these dependencies are used in installed header # opposite of private: these dependencies are used in installed header
@@ -23,14 +23,14 @@ deps_private = []
# N.B. For distributions that care about "ABI" stability and not just # N.B. For distributions that care about "ABI" stability and not just
# "API" stability, the private dependencies also matter as they can # "API" stability, the private dependencies also matter as they can
# potentially affect the public ABI. # potentially affect the public ABI.
deps_public = [] deps_public = [ ]
# These are subproject deps (type == "internal"). They are other # These are subproject deps (type == "internal"). They are other
# packages in `/src` in this repo. The private vs public distinction is # packages in `/src` in this repo. The private vs public distinction is
# the same as above. # the same as above.
deps_private_subproject = [] deps_private_subproject = [ ]
deps_public_subproject = [] deps_public_subproject = [ ]
# These are dependencencies without pkg-config files. Ideally they are # These are dependencencies without pkg-config files. Ideally they are
# just private, but they may also be public (e.g. boost). # just private, but they may also be public (e.g. boost).
deps_other = [] deps_other = [ ]
+11
View File
@@ -0,0 +1,11 @@
add_project_arguments(
'-Wdeprecated-copy',
'-Werror=suggest-override',
'-Werror=switch',
'-Werror=switch-enum',
'-Werror=unused-result',
'-Wignored-qualifiers',
'-Wimplicit-fallthrough',
'-Wno-deprecated-declarations',
language : 'cpp',
)
@@ -5,7 +5,7 @@ if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
# and not detail with this yet. # and not detail with this yet.
# #
# TODO do not do this, and instead do fine-grained export annotations. # TODO do not do this, and instead do fine-grained export annotations.
linker_export_flags = [ '-Wl,--export-all-symbols' ] linker_export_flags = ['-Wl,--export-all-symbols']
else else
linker_export_flags = [] linker_export_flags = []
endif endif
@@ -1,41 +1,33 @@
requires_private = [] requires_private = []
foreach dep : deps_private_subproject foreach dep : deps_private_subproject
requires_private += dep.name() requires_private += dep.name()
endforeach endforeach
requires_private += deps_private requires_private += deps_private
requires_public = [] requires_public = []
foreach dep : deps_public_subproject foreach dep : deps_public_subproject
requires_public += dep.name() requires_public += dep.name()
endforeach endforeach
requires_public += deps_public requires_public += deps_public
extra_pkg_config_variables = get_variable('extra_pkg_config_variables', {}) extra_pkg_config_variables = get_variable('extra_pkg_config_variables', {})
extra_cflags = []
if not meson.project_name().endswith('-c')
extra_cflags += [ '-std=c++23' ]
endif
import('pkgconfig').generate( import('pkgconfig').generate(
this_library, this_library,
filebase : meson.project_name(), filebase : meson.project_name(),
name : 'Nix', name : 'Nix',
description : 'Nix Package Manager', description : 'Nix Package Manager',
extra_cflags : extra_cflags, subdirs : ['nix'],
extra_cflags : ['-std=c++2a'],
requires : requires_public, requires : requires_public,
requires_private : requires_private, requires_private : requires_private,
libraries_private : libraries_private, libraries_private : libraries_private,
variables : extra_pkg_config_variables, variables : extra_pkg_config_variables,
) )
meson.override_dependency( meson.override_dependency(meson.project_name(), declare_dependency(
meson.project_name(), include_directories : include_dirs,
declare_dependency( link_with : this_library,
include_directories : include_dirs, compile_args : ['-std=c++2a'],
link_with : this_library, dependencies : deps_public_subproject + deps_public,
compile_args : [ '-std=c++23' ], variables : extra_pkg_config_variables,
dependencies : deps_public_subproject + deps_public, ))
variables : extra_pkg_config_variables,
),
)
@@ -0,0 +1,7 @@
bash = find_program('bash', native: true)
gen_header = generator(
bash,
arguments : [ '-c', '{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"', '_ignored_argv0', '@OUTPUT@' ],
output : '@PLAINNAME@.gen.hh',
)
@@ -3,6 +3,6 @@
# This is needed for std::atomic on some platforms # This is needed for std::atomic on some platforms
# We did not manage to test this reliably on all platforms, so we hardcode # We did not manage to test this reliably on all platforms, so we hardcode
# it for now. # it for now.
if host_machine.cpu_family() in [ 'arm', 'ppc' ] if host_machine.cpu_family() == 'arm'
deps_other += cxx.find_library('atomic') deps_other += cxx.find_library('atomic')
endif endif
+6
View File
@@ -0,0 +1,6 @@
# This is only conditional to work around
# https://github.com/mesonbuild/meson/issues/13293. It should be
# unconditional.
if not (host_machine.system() == 'windows' and cxx.get_id() == 'gcc')
deps_private += dependency('threads')
endif
@@ -2,5 +2,5 @@ if host_machine.system() == 'windows'
# https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170 # https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170
# #define _WIN32_WINNT_WIN8 0x0602 # #define _WIN32_WINNT_WIN8 0x0602
# We currently don't use any API which requires higher than this. # We currently don't use any API which requires higher than this.
add_project_arguments([ '-D_WIN32_WINNT=0x0602' ], language : 'cpp') add_project_arguments([ '-D_WIN32_WINNT=0x0602' ], language: 'cpp')
endif endif
-101
View File
@@ -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;
}
-6
View File
@@ -1,6 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
system=$(nix eval --raw --impure --expr builtins.currentSystem)
nix eval --json ".#checks.$system" --apply builtins.attrNames | \
jq -r '.[]' | \
xargs -P0 -I '{}' sh -c "nix build -L .#checks.$system.{} || { echo 'FAILED: \033[0;31mnix build -L .#checks.$system.{}\\033[0m'; kill 0; }"
-257
View File
@@ -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
;
};
}
-24
View File
@@ -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,11 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
nix build -L ".#installerScriptForGHA" ".#binaryTarball"
mkdir -p out
cp ./result/install "out/install"
name="$(basename "$(realpath ./result-1)")"
# everything before the first dash
cp -r ./result-1 "out/${name%%-*}"
-16
View File
@@ -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;
}
)
+10 -9
View File
@@ -1,9 +1,10 @@
(import ( (import
let (
lock = builtins.fromJSON (builtins.readFile ./flake.lock); let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
in fetchTarball {
fetchTarball { url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; sha256 = lock.nodes.flake-compat.locked.narHash;
sha256 = lock.nodes.flake-compat.locked.narHash; }
} )
) { src = ./.; }).defaultNix { src = ./.; }
).defaultNix
+1 -1
View File
@@ -3,7 +3,7 @@
def transform_anchors_html: 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>"); | gsub($anchor_regex; "<a href=\"#" + .anchor + "\" id=\"" + .anchor + "\">" + .text + "</a>");
@@ -1,5 +1,5 @@
[book] [book]
title = "Nix @version@ Reference Manual" title = "Nix Reference Manual"
src = "source" src = "source"
[output.html] [output.html]
@@ -7,7 +7,6 @@ additional-css = ["custom.css"]
additional-js = ["redirects.js"] additional-js = ["redirects.js"]
edit-url-template = "https://github.com/NixOS/nix/tree/master/doc/manual/{path}" edit-url-template = "https://github.com/NixOS/nix/tree/master/doc/manual/{path}"
git-repository-url = "https://github.com/NixOS/nix" git-repository-url = "https://github.com/NixOS/nix"
mathjax-support = true
# Handles replacing @docroot@ with a path to ./source relative to that markdown file, # Handles replacing @docroot@ with a path to ./source relative to that markdown file,
# {{#include handlebars}}, and the @generated@ syntax used within these. it mostly # {{#include handlebars}}, and the @generated@ syntax used within these. it mostly
+1 -9
View File
@@ -5,15 +5,7 @@ in
builtinsInfo: builtinsInfo:
let let
showBuiltin = showBuiltin = name: { doc, type ? null, args ? [ ], experimental-feature ? null, impure-only ? false }:
name:
{
doc,
type ? null,
args ? [ ],
experimental-feature ? null,
impure-only ? false,
}:
let let
type' = optionalString (type != null) " (${type})"; type' = optionalString (type != null) " (${type})";
+1 -1
View File
@@ -14,7 +14,7 @@ import sys
# literally. since the rules for these aren't even the same for # 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 # all three we will just fail when we encounter any of them (if
# asserts are off for some reason the depfile will likely point # 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): for path in glob.glob(sys.argv[1] + '/**', recursive=True):
assert '\\' not in path assert '\\' not in path
assert ' ' not in path assert ' ' not in path
+62 -90
View File
@@ -32,13 +32,7 @@ let
commandInfo = fromJSON commandDump; commandInfo = fromJSON commandDump;
showCommand = showCommand = { command, details, filename, toplevel }:
{
command,
details,
filename,
toplevel,
}:
let let
result = '' result = ''
@@ -62,27 +56,26 @@ let
${maybeOptions} ${maybeOptions}
''; '';
showSynopsis = showSynopsis = command: args:
command: args:
let let
showArgument = arg: "*${arg.label}*" + optionalString (!arg ? arity) "..."; showArgument = arg: "*${arg.label}*" + optionalString (! arg ? arity) "...";
arguments = concatStringsSep " " (map showArgument args); arguments = concatStringsSep " " (map showArgument args);
in in ''
''
`${command}` [*option*...] ${arguments} `${command}` [*option*...] ${arguments}
''; '';
maybeSubcommands = optionalString (details ? commands && details.commands != { }) '' maybeSubcommands = optionalString (details ? commands && details.commands != {})
where *subcommand* is one of the following: ''
where *subcommand* is one of the following:
${subcommands} ${subcommands}
''; '';
subcommands = if length categories > 1 then listCategories else listSubcommands details.commands; subcommands = if length categories > 1
then listCategories
else listSubcommands details.commands;
categories = sort (x: y: x.id < y.id) ( categories = sort (x: y: x.id < y.id) (unique (map (cmd: cmd.category) (attrValues details.commands)));
unique (map (cmd: cmd.category) (attrValues details.commands))
);
listCategories = concatStrings (map showCategory categories); listCategories = concatStrings (map showCategory categories);
@@ -106,39 +99,38 @@ let
${allStores} ${allStores}
''; '';
index = index = replaceStrings
replaceStrings [ "@store-types@" "./local-store.md" "./local-daemon-store.md" ]
[ "@store-types@" "./local-store.md" "./local-daemon-store.md" ] [ storesOverview "#local-store" "#local-daemon-store" ]
[ storesOverview "#local-store" "#local-daemon-store" ] details.doc;
details.doc;
storesOverview = storesOverview =
let let
showEntry = store: "- [${store.name}](#${store.slug})"; showEntry = store:
"- [${store.name}](#${store.slug})";
in in
concatStringsSep "\n" (map showEntry storesList) + "\n"; concatStringsSep "\n" (map showEntry storesList) + "\n";
allStores = concatStringsSep "\n" (attrValues storePages); allStores = concatStringsSep "\n" (attrValues storePages);
storePages = listToAttrs ( storePages = listToAttrs
map (s: { (map (s: { name = s.filename; value = s.page; }) storesList);
name = s.filename;
value = s.page;
}) storesList
);
storesList = showStoreDocs { storesList = showStoreDocs {
storeInfo = commandInfo.stores; storeInfo = commandInfo.stores;
inherit inlineHTML; inherit inlineHTML;
}; };
hasInfix = hasInfix = infix: content:
infix: content:
builtins.stringLength content != builtins.stringLength (replaceStrings [ infix ] [ "" ] content); builtins.stringLength content != builtins.stringLength (replaceStrings [ infix ] [ "" ] content);
in in
optionalString (details ? doc) ( optionalString (details ? doc) (
# An alternate implementation with builtins.match stack overflowed on some systems. # An alternate implementation with builtins.match stack overflowed on some systems.
if hasInfix "@store-types@" details.doc then help-stores else details.doc if hasInfix "@store-types@" details.doc
then help-stores
else details.doc
); );
maybeOptions = maybeOptions =
let let
allVisibleOptions = filterAttrs (_: o: !o.hiddenCategory) (details.flags // toplevel.flags); allVisibleOptions = filterAttrs
(_: o: ! o.hiddenCategory)
(details.flags // toplevel.flags);
in in
optionalString (allVisibleOptions != { }) '' optionalString (allVisibleOptions != { }) ''
# Options # Options
@@ -150,73 +142,55 @@ let
> See [`man nix.conf`](@docroot@/command-ref/conf-file.md#command-line-flags) for overriding configuration settings with command line flags. > See [`man nix.conf`](@docroot@/command-ref/conf-file.md#command-line-flags) for overriding configuration settings with command line flags.
''; '';
showOptions = showOptions = inlineHTML: allOptions:
inlineHTML: allOptions:
let let
showCategory = cat: opts: '' showCategory = cat: opts: ''
${optionalString (cat != "") "## ${cat}"} ${optionalString (cat != "") "## ${cat}"}
${concatStringsSep "\n" (attrValues (mapAttrs showOption opts))} ${concatStringsSep "\n" (attrValues (mapAttrs showOption opts))}
''; '';
showOption = showOption = name: option:
name: option:
let let
result = trim '' result = trim ''
- ${item} - ${item}
${option.description} ${option.description}
''; '';
item = item = if inlineHTML
if inlineHTML then then ''<span id="opt-${name}">[`--${name}`](#opt-${name})</span> ${shortName} ${labels}''
''<span id="opt-${name}">[`--${name}`](#opt-${name})</span> ${shortName} ${labels}'' else "`--${name}` ${shortName} ${labels}";
else shortName = optionalString
"`--${name}` ${shortName} ${labels}"; (option ? shortName)
shortName = optionalString (option ? shortName) ("/ `-${option.shortName}`"); ("/ `-${option.shortName}`");
labels = optionalString (option ? labels) (concatStringsSep " " (map (s: "*${s}*") option.labels)); labels = optionalString
in (option ? labels)
result; (concatStringsSep " " (map (s: "*${s}*") option.labels));
categories = in result;
mapAttrs categories = mapAttrs
# Convert each group from a list of key-value pairs back to an attrset # Convert each group from a list of key-value pairs back to an attrset
(_: listToAttrs) (_: listToAttrs)
(groupBy (cmd: cmd.value.category) (attrsToList allOptions)); (groupBy
in (cmd: cmd.value.category)
concatStrings (attrValues (mapAttrs showCategory categories)); (attrsToList allOptions));
in in concatStrings (attrValues (mapAttrs showCategory categories));
squash result; in squash result;
appendName = filename: name: (if filename == "nix" then "nix3" else filename) + "-" + name; appendName = filename: name: (if filename == "nix" then "nix3" else filename) + "-" + name;
processCommand = processCommand = { command, details, filename, toplevel }:
{
command,
details,
filename,
toplevel,
}:
let let
cmd = { cmd = {
inherit command; inherit command;
name = filename + ".md"; name = filename + ".md";
value = showCommand { value = showCommand { inherit command details filename toplevel; };
inherit
command
details
filename
toplevel
;
};
}; };
subcommand = subcommand = subCmd: processCommand {
subCmd: command = command + " " + subCmd;
processCommand { details = details.commands.${subCmd};
command = command + " " + subCmd; filename = appendName filename subCmd;
details = details.commands.${subCmd}; inherit toplevel;
filename = appendName filename subCmd; };
inherit toplevel; in [ cmd ] ++ concatMap subcommand (attrNames details.commands or {});
};
in
[ cmd ] ++ concatMap subcommand (attrNames details.commands or { });
manpages = processCommand { manpages = processCommand {
command = "nix"; command = "nix";
@@ -225,11 +199,9 @@ let
toplevel = commandInfo.args; toplevel = commandInfo.args;
}; };
tableOfContents = tableOfContents = let
let showEntry = page:
showEntry = page: " - [${page.command}](command-ref/new-cli/${page.name})"; " - [${page.command}](command-ref/new-cli/${page.name})";
in in concatStringsSep "\n" (map showEntry manpages) + "\n";
concatStringsSep "\n" (map showEntry manpages) + "\n";
in in (listToAttrs manpages) // { "SUMMARY.md" = tableOfContents; }
(listToAttrs manpages) // { "SUMMARY.md" = tableOfContents; }
+42 -74
View File
@@ -1,99 +1,67 @@
let let
inherit (builtins) inherit (builtins) attrValues concatStringsSep isAttrs isBool mapAttrs;
attrValues inherit (import <nix/utils.nix>) concatStrings indent optionalString squash;
concatStringsSep
isAttrs
isBool
mapAttrs
;
inherit (import <nix/utils.nix>)
concatStrings
indent
optionalString
squash
;
in in
# `inlineHTML` is a hack to accommodate inconsistent output from `lowdown` # `inlineHTML` is a hack to accommodate inconsistent output from `lowdown`
{ { prefix, inlineHTML ? true }: settingsInfo:
prefix,
inlineHTML ? true,
}:
settingsInfo:
let let
showSetting = showSetting = prefix: setting: { description, documentDefault, defaultValue, aliases, value, experimentalFeature }:
prefix: setting:
{
description,
documentDefault,
defaultValue,
aliases,
value,
experimentalFeature,
}:
let let
result = squash '' result = squash ''
- ${item} - ${item}
${indent " " body} ${indent " " body}
''; '';
item = item = if inlineHTML
if inlineHTML then then ''<span id="${prefix}-${setting}">[`${setting}`](#${prefix}-${setting})</span>''
''<span id="${prefix}-${setting}">[`${setting}`](#${prefix}-${setting})</span>'' else "`${setting}`";
else
"`${setting}`";
# separate body to cleanly handle indentation # separate body to cleanly handle indentation
body = '' body = ''
${experimentalFeatureNote} ${experimentalFeatureNote}
${description} ${description}
**Default:** ${showDefault documentDefault defaultValue} **Default:** ${showDefault documentDefault defaultValue}
${showAliases aliases} ${showAliases aliases}
''; '';
experimentalFeatureNote = optionalString (experimentalFeature != null) '' experimentalFeatureNote = optionalString (experimentalFeature != null) ''
> **Warning** > **Warning**
> >
> This setting is part of an > This setting is part of an
> [experimental feature](@docroot@/development/experimental-features.md). > [experimental feature](@docroot@/development/experimental-features.md).
> >
> To change this setting, make sure the > To change this setting, make sure the
> [`${experimentalFeature}` experimental feature](@docroot@/development/experimental-features.md#xp-feature-${experimentalFeature}) > [`${experimentalFeature}` experimental feature](@docroot@/development/experimental-features.md#xp-feature-${experimentalFeature})
> is enabled. > is enabled.
> For example, include the following in [`nix.conf`](@docroot@/command-ref/conf-file.md): > For example, include the following in [`nix.conf`](@docroot@/command-ref/conf-file.md):
> >
> ``` > ```
> extra-experimental-features = ${experimentalFeature} > extra-experimental-features = ${experimentalFeature}
> ${setting} = ... > ${setting} = ...
> ``` > ```
''; '';
showDefault = showDefault = documentDefault: defaultValue:
documentDefault: defaultValue:
if documentDefault then if documentDefault then
# a StringMap value type is specified as a string, but # a StringMap value type is specified as a string, but
# this shows the value type. The empty stringmap is `null` in # this shows the value type. The empty stringmap is `null` in
# JSON, but that converts to `{ }` here. # JSON, but that converts to `{ }` here.
if defaultValue == "" || defaultValue == [ ] || isAttrs defaultValue then if defaultValue == "" || defaultValue == [] || isAttrs defaultValue
"*empty*" then "*empty*"
else if isBool defaultValue then else if isBool defaultValue then
if defaultValue then "`true`" else "`false`" if defaultValue then "`true`" else "`false`"
else else "`${toString defaultValue}`"
"`${toString defaultValue}`" else "*machine-specific*";
else
"*machine-specific*";
showAliases = showAliases = aliases:
aliases: optionalString (aliases != [])
optionalString (aliases != [ ]) "**Deprecated alias:** ${(concatStringsSep ", " (map (s: "`${s}`") aliases))}";
"**Deprecated alias:** ${(concatStringsSep ", " (map (s: "`${s}`") aliases))}";
in in result;
result;
in in concatStrings (attrValues (mapAttrs (showSetting prefix) settingsInfo))
concatStrings (attrValues (mapAttrs (showSetting prefix) settingsInfo))
+14 -38
View File
@@ -1,20 +1,6 @@
let let
inherit (builtins) inherit (builtins) attrNames listToAttrs concatStringsSep readFile replaceStrings;
attrNames inherit (import <nix/utils.nix>) optionalString filterAttrs trim squash toLower unique indent;
listToAttrs
concatStringsSep
readFile
replaceStrings
;
inherit (import <nix/utils.nix>)
optionalString
filterAttrs
trim
squash
toLower
unique
indent
;
showSettings = import <nix/generate-settings.nix>; showSettings = import <nix/generate-settings.nix>;
in in
@@ -28,14 +14,7 @@ in
let let
showStore = showStore = { name, slug }: { settings, doc, experimentalFeature }:
{ name, slug }:
{
settings,
doc,
uri-schemes,
experimentalFeature,
}:
let let
result = squash '' result = squash ''
# ${name} # ${name}
@@ -46,10 +25,7 @@ let
## Settings ## Settings
${showSettings { ${showSettings { prefix = "store-${slug}"; inherit inlineHTML; } settings}
prefix = "store-${slug}";
inherit inlineHTML;
} settings}
''; '';
experimentalFeatureNote = optionalString (experimentalFeature != null) '' experimentalFeatureNote = optionalString (experimentalFeature != null) ''
@@ -67,15 +43,15 @@ let
> extra-experimental-features = ${experimentalFeature} > extra-experimental-features = ${experimentalFeature}
> ``` > ```
''; '';
in in result;
result;
storesList = map (name: rec { storesList = map
inherit name; (name: rec {
slug = replaceStrings [ " " ] [ "-" ] (toLower name); inherit name;
filename = "${slug}.md"; slug = replaceStrings [ " " ] [ "-" ] (toLower name);
page = showStore { inherit name slug; } storeInfo.${name}; filename = "${slug}.md";
}) (attrNames storeInfo); page = showStore { inherit name slug; } storeInfo.${name};
})
(attrNames storeInfo);
in in storesList
storesList
+10 -18
View File
@@ -1,11 +1,5 @@
let let
inherit (builtins) inherit (builtins) attrNames listToAttrs concatStringsSep readFile replaceStrings;
attrNames
listToAttrs
concatStringsSep
readFile
replaceStrings
;
showSettings = import <nix/generate-settings.nix>; showSettings = import <nix/generate-settings.nix>;
showStoreDocs = import <nix/generate-store-info.nix>; showStoreDocs = import <nix/generate-store-info.nix>;
in in
@@ -20,28 +14,26 @@ let
index = index =
let let
showEntry = store: "- [${store.name}](./${store.filename})"; showEntry = store:
"- [${store.name}](./${store.filename})";
in in
concatStringsSep "\n" (map showEntry storesList); concatStringsSep "\n" (map showEntry storesList);
"index.md" = replaceStrings [ "@store-types@" ] [ index ] ( "index.md" = replaceStrings
readFile ./source/store/types/index.md.in [ "@store-types@" ] [ index ]
); (readFile ./source/store/types/index.md.in);
tableOfContents = tableOfContents =
let let
showEntry = store: " - [${store.name}](store/types/${store.filename})"; showEntry = store:
" - [${store.name}](store/types/${store.filename})";
in in
concatStringsSep "\n" (map showEntry storesList) + "\n"; concatStringsSep "\n" (map showEntry storesList) + "\n";
"SUMMARY.md" = tableOfContents; "SUMMARY.md" = tableOfContents;
storePages = listToAttrs ( storePages = listToAttrs
map (s: { (map (s: { name = s.filename; value = s.page; }) storesList);
name = s.filename;
value = s.page;
}) storesList
);
in in
storePages // { inherit "index.md" "SUMMARY.md"; } storePages // { inherit "index.md" "SUMMARY.md"; }
@@ -2,8 +2,8 @@ with builtins;
with import <nix/utils.nix>; with import <nix/utils.nix>;
let let
showExperimentalFeature = name: doc: '' showExperimentalFeature = name: doc:
- [`${name}`](@docroot@/development/experimental-features.md#xp-feature-${name}) ''
''; - [`${name}`](@docroot@/development/experimental-features.md#xp-feature-${name})
in '';
xps: indent " " (concatStrings (attrValues (mapAttrs showExperimentalFeature xps))) in xps: indent " " (concatStrings (attrValues (mapAttrs showExperimentalFeature xps)))
+1 -2
View File
@@ -2,8 +2,7 @@ with builtins;
with import <nix/utils.nix>; with import <nix/utils.nix>;
let let
showExperimentalFeature = showExperimentalFeature = name: doc:
name: doc:
squash '' squash ''
## [`${name}`]{#xp-feature-${name}} ## [`${name}`]{#xp-feature-${name}}
+24 -39
View File
@@ -1,5 +1,4 @@
project( project('nix-manual',
'nix-manual',
version : files('.version'), version : files('.version'),
meson_version : '>= 1.1', meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later', license : 'LGPL-2.1-or-later',
@@ -9,45 +8,43 @@ nix = find_program('nix', native : true)
mdbook = find_program('mdbook', native : true) mdbook = find_program('mdbook', native : true)
bash = find_program('bash', native : true) bash = find_program('bash', native : true)
rsync = find_program('rsync', required : true, native : true)
pymod = import('python') pymod = import('python')
python = pymod.find_installation('python3') python = pymod.find_installation('python3')
nix_env_for_docs = { nix_env_for_docs = {
'HOME' : '/dummy', 'HOME': '/dummy',
'NIX_CONF_DIR' : '/dummy', 'NIX_CONF_DIR': '/dummy',
'NIX_SSL_CERT_FILE' : '/dummy/no-ca-bundle.crt', 'NIX_SSL_CERT_FILE': '/dummy/no-ca-bundle.crt',
'NIX_STATE_DIR' : '/dummy', 'NIX_STATE_DIR': '/dummy',
'NIX_CONFIG' : 'cores = 0', '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 + [ nix_eval_for_docs_common = nix_for_docs + [
'eval', 'eval',
'-I', '-I', 'nix=' + meson.current_source_dir(),
'nix=' + meson.current_source_dir(),
'--store', 'dummy://', '--store', 'dummy://',
'--impure', '--impure',
] ]
nix_eval_for_docs = nix_eval_for_docs_common + '--raw' nix_eval_for_docs = nix_eval_for_docs_common + '--raw'
conf_file_json = custom_target( conf_file_json = custom_target(
command : nix_for_docs + [ 'config', 'show', '--json' ], command : nix_for_docs + ['config', 'show', '--json'],
capture : true, capture : true,
output : 'conf-file.json', output : 'conf-file.json',
env : nix_env_for_docs, env : nix_env_for_docs,
) )
language_json = custom_target( language_json = custom_target(
command : [ nix, '__dump-language' ], command: [nix, '__dump-language'],
output : 'language.json', output : 'language.json',
capture : true, capture : true,
env : nix_env_for_docs, env : nix_env_for_docs,
) )
nix3_cli_json = custom_target( nix3_cli_json = custom_target(
command : [ nix, '__dump-cli' ], command : [nix, '__dump-cli'],
capture : true, capture : true,
output : 'nix.json', output : 'nix.json',
env : nix_env_for_docs, env : nix_env_for_docs,
@@ -70,7 +67,7 @@ subdir('source/release-notes')
subdir('source') subdir('source')
# Hacky way to figure out if `nix` is an `ExternalProgram` or # 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()) if nix.full_path().startswith(meson.build_root())
nix_input = nix nix_input = nix
else else
@@ -81,32 +78,26 @@ manual = custom_target(
'manual', 'manual',
command : [ command : [
bash, bash,
'-euo', '-euo', 'pipefail',
'pipefail',
'-c', '-c',
''' '''
@0@ @INPUT0@ @CURRENT_SOURCE_DIR@ > @DEPFILE@ @0@ @INPUT0@ @CURRENT_SOURCE_DIR@ > @DEPFILE@
@0@ @INPUT1@ summary @2@ < @CURRENT_SOURCE_DIR@/source/SUMMARY.md.in > @2@/source/SUMMARY.md @0@ @INPUT1@ summary @2@ < @CURRENT_SOURCE_DIR@/source/SUMMARY.md.in > @2@/source/SUMMARY.md
sed -e 's|@version@|@3@|g' < @INPUT2@ > @2@/book.toml rsync -r --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
@4@ -r -L --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
(cd @2@; RUST_LOG=warn @1@ build -d @2@ 3>&2 2>&1 1>&3) | { grep -Fv "because fragment resolution isn't implemented" || :; } 3>&2 2>&1 1>&3 (cd @2@; RUST_LOG=warn @1@ build -d @2@ 3>&2 2>&1 1>&3) | { grep -Fv "because fragment resolution isn't implemented" || :; } 3>&2 2>&1 1>&3
rm -rf @2@/manual rm -rf @2@/manual
mv @2@/html @2@/manual mv @2@/html @2@/manual
# 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 find @2@/manual -iname meson.build -delete
'''.format( '''.format(
python.full_path(), python.full_path(),
mdbook.full_path(), mdbook.full_path(),
meson.current_build_dir(), meson.current_build_dir(),
meson.project_version(),
rsync.full_path(),
), ),
], ],
input : [ input : [
generate_manual_deps, generate_manual_deps,
'substitute.py', 'substitute.py',
'book.toml.in', 'book.toml',
'anchors.jq', 'anchors.jq',
'custom.css', 'custom.css',
nix3_cli_files, nix3_cli_files,
@@ -117,7 +108,6 @@ manual = custom_target(
builtins_md, builtins_md,
rl_next_generated, rl_next_generated,
summary_rl_next, summary_rl_next,
json_schema_generated_files,
nix_input, nix_input,
], ],
output : [ output : [
@@ -126,8 +116,8 @@ manual = custom_target(
], ],
depfile : 'manual.d', depfile : 'manual.d',
env : { env : {
'RUST_LOG' : 'info', 'RUST_LOG': 'info',
'MDBOOK_SUBSTITUTE_SEARCH' : meson.current_build_dir() / 'source', 'MDBOOK_SUBSTITUTE_SEARCH': meson.current_build_dir() / 'source',
}, },
) )
manual_html = manual[0] manual_html = manual[0]
@@ -139,8 +129,7 @@ install_subdir(
) )
nix_nested_manpages = [ nix_nested_manpages = [
[ [ 'nix-env',
'nix-env',
[ [
'delete-generations', 'delete-generations',
'install', 'install',
@@ -155,8 +144,7 @@ nix_nested_manpages = [
'upgrade', 'upgrade',
], ],
], ],
[ [ 'nix-store',
'nix-store',
[ [
'add-fixed', 'add-fixed',
'add', 'add',
@@ -211,7 +199,6 @@ nix3_manpages = [
'nix3-build', 'nix3-build',
'nix3-bundle', 'nix3-bundle',
'nix3-config', 'nix3-config',
'nix3-config-check',
'nix3-config-show', 'nix3-config-show',
'nix3-copy', 'nix3-copy',
'nix3-daemon', 'nix3-daemon',
@@ -219,8 +206,8 @@ nix3_manpages = [
'nix3-derivation', 'nix3-derivation',
'nix3-derivation-show', 'nix3-derivation-show',
'nix3-develop', 'nix3-develop',
#'nix3-doctor',
'nix3-edit', 'nix3-edit',
'nix3-env-shell',
'nix3-eval', 'nix3-eval',
'nix3-flake-archive', 'nix3-flake-archive',
'nix3-flake-check', 'nix3-flake-check',
@@ -237,7 +224,6 @@ nix3_manpages = [
'nix3-fmt', 'nix3-fmt',
'nix3-hash-file', 'nix3-hash-file',
'nix3-hash', 'nix3-hash',
'nix3-hash-convert',
'nix3-hash-path', 'nix3-hash-path',
'nix3-hash-to-base16', 'nix3-hash-to-base16',
'nix3-hash-to-base32', 'nix3-hash-to-base32',
@@ -252,15 +238,14 @@ nix3_manpages = [
'nix3-nar-cat', 'nix3-nar-cat',
'nix3-nar-dump-path', 'nix3-nar-dump-path',
'nix3-nar-ls', 'nix3-nar-ls',
'nix3-nar-pack',
'nix3-nar', 'nix3-nar',
'nix3-path-info', 'nix3-path-info',
'nix3-print-dev-env', 'nix3-print-dev-env',
'nix3-profile',
'nix3-profile-add',
'nix3-profile-diff-closures', 'nix3-profile-diff-closures',
'nix3-profile-history', 'nix3-profile-history',
'nix3-profile-install',
'nix3-profile-list', 'nix3-profile-list',
'nix3-profile',
'nix3-profile-remove', 'nix3-profile-remove',
'nix3-profile-rollback', 'nix3-profile-rollback',
'nix3-profile-upgrade', 'nix3-profile-upgrade',
@@ -275,7 +260,7 @@ nix3_manpages = [
'nix3-repl', 'nix3-repl',
'nix3-run', 'nix3-run',
'nix3-search', 'nix3-search',
'nix3-store-add', #'nix3-shell',
'nix3-store-add-file', 'nix3-store-add-file',
'nix3-store-add-path', 'nix3-store-add-path',
'nix3-store-cat', 'nix3-store-cat',
@@ -285,12 +270,12 @@ nix3_manpages = [
'nix3-store-diff-closures', 'nix3-store-diff-closures',
'nix3-store-dump-path', 'nix3-store-dump-path',
'nix3-store-gc', 'nix3-store-gc',
'nix3-store-info',
'nix3-store-ls', 'nix3-store-ls',
'nix3-store-make-content-addressed', 'nix3-store-make-content-addressed',
'nix3-store', 'nix3-store',
'nix3-store-optimise', 'nix3-store-optimise',
'nix3-store-path-from-hash-part', 'nix3-store-path-from-hash-part',
'nix3-store-ping',
'nix3-store-prefetch-file', 'nix3-store-prefetch-file',
'nix3-store-repair', 'nix3-store-repair',
'nix3-store-sign', 'nix3-store-sign',
+35 -81
View File
@@ -1,26 +1,19 @@
{ { lib
lib, , mkMesonDerivation
mkMesonDerivation,
meson, , meson
ninja, , ninja
lowdown-unsandboxed, , lowdown
mdbook, , mdbook
mdbook-linkcheck, , mdbook-linkcheck
jq, , jq
python3, , python3
rsync, , rsync
nix-cli, , nix-cli
changelog-d,
json-schema-for-humans,
officialRelease,
# Configuration Options # Configuration Options
version, , version
# `tests` attribute
testers,
}: }:
let let
@@ -32,85 +25,46 @@ mkMesonDerivation (finalAttrs: {
inherit version; inherit version;
workDir = ./.; workDir = ./.;
fileset = fileset = fileset.difference
fileset.difference (fileset.unions [
(fileset.unions [ ../../.version
../../.version # Too many different types of files to filter for now
# For example JSON ../../doc/manual
../../src/libutil-tests/data/hash ./.
../../src/libstore-tests/data/content-address ])
../../src/libstore-tests/data/store-path # Do a blacklist instead
../../src/libstore-tests/data/realisation ../../doc/manual/package.nix;
../../src/libstore-tests/data/derived-path
../../src/libstore-tests/data/path-info
../../src/libstore-tests/data/nar-info
../../src/libstore-tests/data/build-result
# Too many different types of files to filter for now
../../doc/manual
./.
])
# Do a blacklist instead
../../doc/manual/package.nix;
# TODO the man pages should probably be separate # TODO the man pages should probably be separate
outputs = [ outputs = [ "out" "man" ];
"out"
"man"
];
nativeBuildInputs = [ # Hack for sake of the dev shell
nix-cli passthru.externalNativeBuildInputs = [
meson meson
ninja ninja
(lib.getBin lowdown-unsandboxed) (lib.getBin lowdown)
mdbook mdbook
mdbook-linkcheck mdbook-linkcheck
jq jq
python3 python3
rsync rsync
json-schema-for-humans
changelog-d
]
++ lib.optionals (!officialRelease) [
# When not an official release, we likely have changelog entries that have
# yet to be rendered.
# When released, these are rendered into a committed file to save a dependency.
changelog-d
]; ];
preConfigure = '' nativeBuildInputs = finalAttrs.passthru.externalNativeBuildInputs ++ [
chmod u+w ./.version nix-cli
echo ${finalAttrs.version} > ./.version ];
'';
preConfigure =
''
chmod u+w ./.version
echo ${finalAttrs.version} > ./.version
'';
postInstall = '' postInstall = ''
mkdir -p ''$out/nix-support mkdir -p ''$out/nix-support
echo "doc manual ''$out/share/doc/nix/manual" >> ''$out/nix-support/hydra-build-products echo "doc manual ''$out/share/doc/nix/manual" >> ''$out/nix-support/hydra-build-products
''; '';
/**
The root of the HTML manual.
E.g. "${nix-manual.site}/index.html" exists.
*/
passthru.site = finalAttrs.finalPackage + "/share/doc/nix/manual";
passthru.tests = {
# https://nixos.org/manual/nixpkgs/stable/index.html#tester-lycheeLinkCheck
linkcheck = testers.lycheeLinkCheck {
inherit (finalAttrs.finalPackage) site;
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 = { meta = {
platforms = lib.platforms.all; platforms = lib.platforms.all;
}; };
-5
View File
@@ -346,9 +346,6 @@ const redirects = {
"scoping-rules": "scoping.html", "scoping-rules": "scoping.html",
"string-literal": "string-literals.html", "string-literal": "string-literals.html",
}, },
"language/derivations.md": {
"builder-execution": "store/drv/building.md#builder-execution",
},
"installation/installing-binary.html": { "installation/installing-binary.html": {
"linux": "uninstall.html#linux", "linux": "uninstall.html#linux",
"macos": "uninstall.html#macos", "macos": "uninstall.html#macos",
@@ -374,9 +371,7 @@ const redirects = {
}, },
"glossary.html": { "glossary.html": {
"gloss-local-store": "store/types/local-store.html", "gloss-local-store": "store/types/local-store.html",
"package-attribute-set": "#package",
"gloss-chroot-store": "store/types/local-store.html", "gloss-chroot-store": "store/types/local-store.html",
"gloss-content-addressed-derivation": "#gloss-content-addressing-derivation",
}, },
}; };
+14
View File
@@ -0,0 +1,14 @@
---
synopsis: Use envvars NIX_CACHE_HOME, NIX_CONFIG_HOME, NIX_DATA_HOME, NIX_STATE_HOME if defined
prs: [11351]
---
Added new environment variables:
- `NIX_CACHE_HOME`
- `NIX_CONFIG_HOME`
- `NIX_DATA_HOME`
- `NIX_STATE_HOME`
Each, if defined, takes precedence over the corresponding [XDG environment variable](@docroot@/command-ref/env-common.md#xdg-base-directories).
This provides more fine-grained control over where Nix looks for files, and allows to have a stand-alone Nix environment, which only uses files in a specific directory, and doesn't interfere with the user environment.
@@ -0,0 +1,21 @@
---
synopsis: Define integer overflow in the Nix language as an error
issues: [10968]
prs: [11188]
---
Previously, integer overflow in the Nix language invoked C++ level signed overflow, which was undefined behaviour, but *usually* manifested as wrapping around on overflow.
Since prior to the public release of Lix, Lix had C++ signed overflow defined to crash the process and nobody noticed this having accidentally removed overflow from the Nix language for three months until it was caught by fiddling around.
Given the significant body of actual Nix code that has been evaluated by Lix in that time, it does not appear that nixpkgs or much of importance depends on integer overflow, so it appears safe to turn into an error.
Some other overflows were fixed:
- `builtins.fromJSON` of values greater than the maximum representable value in a signed 64-bit integer will generate an error.
- `nixConfig` in flakes will no longer accept negative values for configuration options.
Integer overflow now looks like the following:
```
$ nix eval --expr '9223372036854775807 + 1'
error: integer overflow in adding 9223372036854775807 + 1
```
+22
View File
@@ -0,0 +1,22 @@
---
synopsis: |-
The `build-hook` setting's default is less useful when using `libnixstore` as a library
prs:
- 11178
---
*This is an obscure issue that only affects usage of the `libnixstore` library outside of the Nix executable.*
As part the ongoing [rewrite of the build system](https://github.com/NixOS/nix/issues/2503) to use [Meson](https://mesonbuild.com/), we are also switching to packaging individual Nix components separately (and building them in separate derivations).
This means that when building `libnixstore` we do not know where the Nix binaries will be installed --- `libnixstore` doesn't know about downstream consumers like the Nix binaries at all.
*This is also unrelated to the _`post`_-`build-hook`*, which is often used for pushing to a cache.*
This has a small adverse affect on remote building --- the `build-remote` executable that is specified from the [`build-hook`](@docroot@/command-ref/conf-file.md#conf-build-hook) setting will not be gotten from the (presumed) installation location, but instead looked up on the `PATH`.
This means that other applications linking `libnixstore` that wish to use remote building must arrange for the `nix` command to be on the PATH (or manually overriding `build-hook`) in order for that to work.
Long term we don't envision this being a downside, because we plan to [get rid of `build-remote` and the build hook setting entirely](https://github.com/NixOS/nix/issues/1221).
There should simply be no need to have an extra, intermediate layer of remote-procedure-calling when we want to connect to a remote builder.
The build hook protocol did in principle support custom ways of remote building, but that can also be accomplished with a custom service for the ssh or daemon/ssh-ng protocols, or with a custom [store type](@docroot@/store/types/index.md) i.e. `Store` subclass. <!-- we normally don't mention classes, but consider that this release note is about a library use case -->
The Perl bindings no longer expose `getBinDir` either, since the underlying C++ libraries those bindings wrap no longer know the location of installed binaries as described above.
-9
View File
@@ -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.
+14
View File
@@ -0,0 +1,14 @@
---
synopsis: wrap filesystem exceptions more correctly
issues: []
prs: [11378]
---
With the switch to `std::filesystem` in different places, Nix started to throw `std::filesystem::filesystem_error` in many places instead of its own exceptions.
This lead to no longer generating error traces, for example when listing a non-existing directory, and can also lead to crashes inside the Nix REPL.
This version catches these types of exception correctly and wrap them into Nix's own exeception type.
Author: [**@Mic92**](https://github.com/Mic92)
+9
View File
@@ -0,0 +1,9 @@
---
synopsis: Add setting `fsync-store-paths`
issues: [1218]
prs: [7126]
---
Nix now has a setting `fsync-store-paths` that ensures that new store paths are durably written to disk before they are registered as "valid" in Nix's database. This can prevent Nix store corruption if the system crashes or there is a power loss. This setting defaults to `false`.
Author: [**@squalus**](https://github.com/squalus)
-55
View File
@@ -1,55 +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 (Version 2)
The store path info JSON format has been updated from version 1 to version 2:
- **Added `version` field**:
All store path info JSON now includes `"version": 2`.
- **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": {"algorithm": "sha256", "format": "base64", "hash": "EMIJ+giQ..."}}`
- Still `null` values for input-addressed store objects
- **Structured hash fields**:
Hash values (`narHash` and `downloadHash`) are now structured JSON objects instead of strings:
- Old: `"narHash": "sha256:FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="`
- New: `"narHash": {"algorithm": "sha256", "format": "base64", "hash": "FePFYIlM..."}`
- Same structure applies to `downloadHash` in NAR info contexts
Nix currently only produces, and doesn't consume this format.
**Affected command**: `nix path-info --json`
## 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**:
Floating content-addressed outputs now use structured JSON format.
This is the same format as `ca` in in store path info (after the new version).
Version 3 and earlier formats are *not* accepted when reading.
**Affected command**: `nix derivation`, namely it's `show` and `add` sub-commands.
@@ -0,0 +1,17 @@
---
synopsis: Removing the default argument passed to the `nix fmt` formatter
issues: []
prs: [11438]
---
The underlying formatter no longer receives the ". " default argument when `nix fmt` is called with no arguments.
This change was necessary as the formatter wasn't able to distinguish between
a user wanting to format the current folder with `nix fmt .` or the generic
`nix fmt`.
The default behaviour is now the responsibility of the formatter itself, and
allows tools such as treefmt to format the whole tree instead of only the
current directory and below.
Author: [**@zimbatm**](https://github.com/zimbatm)
@@ -0,0 +1,8 @@
---
synopsis: Flakes are no longer substituted
prs: [10612]
---
Nix will no longer attempt to substitute the source code of flakes from a binary cache. This functionality was broken because it could lead to different evaluation results depending on whether the flake was available in the binary cache, or even depending on whether the flake was already in the local store.
Author: [**@edolstra**](https://github.com/edolstra)
@@ -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
```
-21
View File
@@ -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.
+8
View File
@@ -0,0 +1,8 @@
---
synopsis: "`<nix/fetchurl.nix>` uses TLS verification"
prs: [11585]
---
Previously `<nix/fetchurl.nix>` did not do TLS verification. This was because the Nix sandbox in the past did not have access to TLS certificates, and Nix checks the hash of the fetched file anyway. However, this can expose authentication data from `netrc` and URLs to man-in-the-middle attackers. In addition, Nix now in some cases (such as when using impure derivations) does *not* check the hash. Therefore we have now enabled TLS verification. This means that downloads by `<nix/fetchurl.nix>` will now fail if you're fetching from a HTTPS server that does not have a valid certificate.
`<nix/fetchurl.nix>` is also known as the builtin derivation builder `builtin:fetchurl`. It's not to be confused with the evaluation-time function `builtins.fetchurl`, which was not affected by this issue.
+1 -27
View File
@@ -22,22 +22,12 @@
- [Store Object](store/store-object.md) - [Store Object](store/store-object.md)
- [Content-Addressing Store Objects](store/store-object/content-address.md) - [Content-Addressing Store Objects](store/store-object/content-address.md)
- [Store Path](store/store-path.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) - [Store Types](store/types/index.md)
{{#include ./store/types/SUMMARY.md}} {{#include ./store/types/SUMMARY.md}}
- [Appendix: Math notation](store/math-notation.md)
- [Nix Language](language/index.md) - [Nix Language](language/index.md)
- [Data Types](language/types.md) - [Data Types](language/types.md)
- [String context](language/string-context.md) - [String context](language/string-context.md)
- [Syntax and semantics](language/syntax.md) - [Syntax and semantics](language/syntax.md)
- [Evaluation](language/evaluation.md)
- [Variables](language/variables.md) - [Variables](language/variables.md)
- [String literals](language/string-literals.md) - [String literals](language/string-literals.md)
- [Identifiers](language/identifiers.md) - [Identifiers](language/identifiers.md)
@@ -61,7 +51,6 @@
- [Tuning Cores and Jobs](advanced-topics/cores-vs-jobs.md) - [Tuning Cores and Jobs](advanced-topics/cores-vs-jobs.md)
- [Verifying Build Reproducibility](advanced-topics/diff-hook.md) - [Verifying Build Reproducibility](advanced-topics/diff-hook.md)
- [Using the `post-build-hook`](advanced-topics/post-build-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) - [Command Reference](command-ref/index.md)
- [Common Options](command-ref/opt-common.md) - [Common Options](command-ref/opt-common.md)
- [Common Environment Variables](command-ref/env-common.md) - [Common Environment Variables](command-ref/env-common.md)
@@ -121,24 +110,17 @@
- [Architecture and Design](architecture/architecture.md) - [Architecture and Design](architecture/architecture.md)
- [Formats and Protocols](protocols/index.md) - [Formats and Protocols](protocols/index.md)
- [JSON Formats](protocols/json/index.md) - [JSON Formats](protocols/json/index.md)
- [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) - [Store Object Info](protocols/json/store-object-info.md)
- [Derivation](protocols/json/derivation.md) - [Derivation](protocols/json/derivation.md)
- [Deriving Path](protocols/json/deriving-path.md)
- [Build Trace Entry](protocols/json/build-trace-entry.md)
- [Build Result](protocols/json/build-result.md)
- [Serving Tarball Flakes](protocols/tarball-fetcher.md) - [Serving Tarball Flakes](protocols/tarball-fetcher.md)
- [Store Path Specification](protocols/store-path.md) - [Store Path Specification](protocols/store-path.md)
- [Nix Archive (NAR) Format](protocols/nix-archive/index.md) - [Nix Archive (NAR) Format](protocols/nix-archive.md)
- [Derivation "ATerm" file format](protocols/derivation-aterm.md) - [Derivation "ATerm" file format](protocols/derivation-aterm.md)
- [C API](c-api.md) - [C API](c-api.md)
- [Glossary](glossary.md) - [Glossary](glossary.md)
- [Development](development/index.md) - [Development](development/index.md)
- [Building](development/building.md) - [Building](development/building.md)
- [Testing](development/testing.md) - [Testing](development/testing.md)
- [Benchmarking](development/benchmarking.md)
- [Debugging](development/debugging.md) - [Debugging](development/debugging.md)
- [Documentation](development/documentation.md) - [Documentation](development/documentation.md)
- [CLI guideline](development/cli-guideline.md) - [CLI guideline](development/cli-guideline.md)
@@ -148,14 +130,6 @@
- [Contributing](development/contributing.md) - [Contributing](development/contributing.md)
- [Releases](release-notes/index.md) - [Releases](release-notes/index.md)
{{#include ./SUMMARY-rl-next.md}} {{#include ./SUMMARY-rl-next.md}}
- [Release 2.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) - [Release 2.24 (2024-07-31)](release-notes/rl-2.24.md)
- [Release 2.23 (2024-06-03)](release-notes/rl-2.23.md) - [Release 2.23 (2024-06-03)](release-notes/rl-2.23.md)
- [Release 2.22 (2024-04-23)](release-notes/rl-2.22.md) - [Release 2.22 (2024-04-23)](release-notes/rl-2.22.md)
@@ -20,14 +20,14 @@ For a local machine to forward a build to a remote machine, the remote machine m
## Testing ## 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 ```console
nix store info --store ssh://username@mac nix store info --store ssh://username@mac
``` ```
To specify an SSH identity file as part of the remote store URI add a To specify an SSH identity file as part of the remote store URI add a
query parameter, e.g. query paramater, e.g.
```console ```console
nix store info --store ssh://username@mac?ssh-key=/home/alice/my-key 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. causes the list of machines in `/etc/nix/machines` to be included.
(This is the default.) (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 | | Nix | V |
| | +------------------------+ | | | +-------------------------+ |
| | | command line interface |------. | | | | commmand line interface |------. |
| | +------------------------+ | | | | +-------------------------+ | |
| | | | | | | | | |
| evaluated by calls manages | | 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. A build plan itself is a series of *build tasks*, together with their build inputs.
> **Important** > **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. 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. The result of a build task can be input to another build task.
+1 -1
View File
@@ -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> - <span id="env-NIX_CONF_DIR">[`NIX_CONF_DIR`](#env-NIX_CONF_DIR)</span>
Overrides the location of the system Nix configuration directory 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> - <span id="env-NIX_CONFIG">[`NIX_CONFIG`](#env-NIX_CONFIG)</span>
+13 -6
View File
@@ -1,13 +1,13 @@
xp_features_json = custom_target( xp_features_json = custom_target(
command : [ nix, '__dump-xp-features' ], command : [nix, '__dump-xp-features'],
capture : true, capture : true,
output : 'xp-features.json', output : 'xp-features.json',
env : nix_env_for_docs,
) )
experimental_features_shortlist_md = custom_target( experimental_features_shortlist_md = custom_target(
command : nix_eval_for_docs + [ command : nix_eval_for_docs + [
'--expr', 'import @INPUT0@ (builtins.fromJSON (builtins.readFile ./@INPUT1@))', '--expr',
'import @INPUT0@ (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
], ],
input : [ input : [
'../../generate-xp-features-shortlist.nix', '../../generate-xp-features-shortlist.nix',
@@ -19,8 +19,14 @@ experimental_features_shortlist_md = custom_target(
) )
nix3_cli_files = custom_target( nix3_cli_files = custom_target(
command : [ python.full_path(), '@INPUT0@', '@OUTPUT@', '--' ] + nix_eval_for_docs + [ command : [
'--expr', 'import @INPUT1@ true (builtins.readFile ./@INPUT2@)', python.full_path(),
'@INPUT0@',
'@OUTPUT@',
'--'
] + nix_eval_for_docs + [
'--expr',
'import @INPUT1@ true (builtins.readFile ./@INPUT2@)',
], ],
input : [ input : [
'../../remove_before_wrapper.py', '../../remove_before_wrapper.py',
@@ -34,7 +40,8 @@ nix3_cli_files = custom_target(
conf_file_md_body = custom_target( conf_file_md_body = custom_target(
command : [ command : [
nix_eval_for_docs, 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, capture : true,
input : [ input : [
+3 -3
View File
@@ -36,7 +36,7 @@ to a temporary location. The tarball must include a single top-level
directory containing at least a file named `default.nix`. directory containing at least a file named `default.nix`.
`nix-build` is essentially a wrapper around `nix-build` is essentially a wrapper around
[`nix-instantiate`](./nix-instantiate.md) (to translate a high-level Nix [`nix-instantiate`](nix-instantiate.md) (to translate a high-level Nix
expression to a low-level [store derivation]) and [`nix-store expression to a low-level [store derivation]) and [`nix-store
--realise`](@docroot@/command-ref/nix-store/realise.md) (to build the store --realise`](@docroot@/command-ref/nix-store/realise.md) (to build the store
derivation). derivation).
@@ -52,8 +52,8 @@ derivation).
# Options # Options
All options not listed here are passed to All options not listed here are passed to
[`nix-store --realise`](./nix-store/realise.md), [`nix-store --realise`](nix-store/realise.md),
except for `--arg` and `--attr` / `-A` which are passed to [`nix-instantiate`](./nix-instantiate.md). except for `--arg` and `--attr` / `-A` which are passed to [`nix-instantiate`](nix-instantiate.md).
- <span id="opt-no-out-link">[`--no-out-link`](#opt-no-out-link)<span> - <span id="opt-no-out-link">[`--no-out-link`](#opt-no-out-link)<span>
+4 -9
View File
@@ -11,10 +11,10 @@
Channels are a mechanism for referencing remote Nix expressions and conveniently retrieving their latest version. Channels are a mechanism for referencing remote Nix expressions and conveniently retrieving their latest version.
The moving parts of channels are: 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 user-specific list of [subscribed channels](#subscribed-channels)
- The [downloaded channel contents](#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** > **Note**
> >
@@ -53,11 +53,6 @@ This command has the following operations:
Download the Nix expressions of subscribed channels and create a new generation. 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. 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` - `--list-generations`
Prints a list of all the current existing generations for the 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: Subscribe to the Nixpkgs channel and run `hello` from the GNU Hello package:
```console ```console
$ nix-channel --add https://channels.nixos.org/nixpkgs-unstable $ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
$ nix-channel --list $ nix-channel --list
nixpkgs https://channels.nixos.org/nixpkgs nixpkgs https://nixos.org/channels/nixpkgs
$ nix-channel --update $ nix-channel --update
$ nix-shell -p hello --run hello $ nix-shell -p hello --run hello
hello hello
@@ -36,7 +36,7 @@ Instead, it looks in a few locations, and acts on all profiles it finds there:
> >
> Not stable; subject to change > Not stable; subject to change
> >
> Do not rely on this functionality; it just exists for migration purposes and may change in the future. > Do not rely on this functionality; it just exists for migration purposes and is may change in the future.
> These deprecated paths remain a private implementation detail of Nix. > These deprecated paths remain a private implementation detail of Nix.
`$NIX_STATE_DIR/profiles` and `$NIX_STATE_DIR/profiles/per-user`. `$NIX_STATE_DIR/profiles` and `$NIX_STATE_DIR/profiles/per-user`.
@@ -62,15 +62,6 @@ These options are for deleting old [profiles] prior to deleting unreachable [sto
This is the equivalent of invoking [`nix-env --delete-generations <period>`](@docroot@/command-ref/nix-env/delete-generations.md#generations-time) on each found profile. This is the equivalent of invoking [`nix-env --delete-generations <period>`](@docroot@/command-ref/nix-env/delete-generations.md#generations-time) on each found profile.
See the documentation of that command for additional information about the *period* argument. See the documentation of that command for additional information about the *period* argument.
- <span id="opt-max-freed">[`--max-freed`](#opt-max-freed)</span> *bytes*
<!-- duplication from https://github.com/NixOS/nix/blob/442a2623e48357ff72c77bb11cf2cf06d94d2f90/doc/manual/source/command-ref/nix-store/gc.md?plain=1#L39-L44 -->
Keep deleting paths until at least *bytes* bytes have been deleted,
then stop. The argument *bytes* can be followed by the
multiplicative suffix `K`, `M`, `G` or `T`, denoting KiB, MiB, GiB
or TiB units.
{{#include ./opt-common.md}} {{#include ./opt-common.md}}
{{#include ./env-common.md}} {{#include ./env-common.md}}
@@ -84,7 +84,7 @@ When using public key authentication, you can avoid typing the passphrase with `
> Copy GNU Hello from a remote machine using a known store path, and run it: > Copy GNU Hello from a remote machine using a known store path, and run it:
> >
> ```shell-session > ```shell-session
> $ storePath="$(nix-instantiate --eval --raw '<nixpkgs>' -I nixpkgs=channel:nixpkgs-unstable -A hello.outPath)" > $ storePath="$(nix-instantiate --eval '<nixpkgs>' -I nixpkgs=channel:nixpkgs-unstable -A hello.outPath | tr -d '"')"
> $ nix-copy-closure --from alice@itchy.example.org "$storePath" > $ nix-copy-closure --from alice@itchy.example.org "$storePath"
> $ "$storePath"/bin/hello > $ "$storePath"/bin/hello
> Hello, world! > Hello, world!
@@ -27,7 +27,7 @@ This operation deletes the specified generations of the current profile.
> >
> Older *and newer* generations will be deleted by this operation. > 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. > 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. > They will also be deleted.
@@ -11,7 +11,6 @@
[`--from-profile` *path*] [`--from-profile` *path*]
[`--preserve-installed` | `-P`] [`--preserve-installed` | `-P`]
[`--remove-all` | `-r`] [`--remove-all` | `-r`]
[`--priority` *priority*]
# Description # Description
@@ -22,11 +21,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: 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. 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. 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 [default Nix expression]: @docroot@/command-ref/files/default-nix-expression.md
[realised]: @docroot@/glossary.md#gloss-realise [realised]: @docroot@/glossary.md#gloss-realise
@@ -62,15 +61,11 @@ The arguments *args* map to store paths in a number of possible ways:
The derivations returned by those function calls are installed. The derivations returned by those function calls are installed.
This allows derivations to be specified in an unambiguous way, which is necessary if there are multiple derivations with the same name. This allows derivations to be specified in an unambiguous way, which is necessary if there are multiple derivations with the same name.
- If `--priority` *priority* is given, the priority of the derivations being installed is set to *priority*. - If *args* are [store derivations](@docroot@/glossary.md#gloss-store-derivation), then these are [realised], and the resulting output paths are installed.
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 paths] that are not store derivations, then these are [realised] and installed.
- If *args* are [store paths] that do not point to store derivations, then these are [realised] and installed. - By default all [outputs](@docroot@/language/derivations.md#attr-outputs) are installed for each [derivation].
- By default all [outputs](@docroot@/language/derivations.md#attr-outputs) are installed for each [store derivation].
This can be overridden by adding a `meta.outputsToInstall` attribute on the derivation listing a subset of the output names. This can be overridden by adding a `meta.outputsToInstall` attribute on the derivation listing a subset of the output names.
Example: Example:
@@ -122,8 +117,6 @@ The arguments *args* map to store paths in a number of possible ways:
manifest.nix manifest.nix
``` ```
[store derivation]: @docroot@/glossary.md#gloss-store-derivation
# Options # Options
- `--prebuilt-only` / `-b` - `--prebuilt-only` / `-b`
@@ -242,3 +235,4 @@ channel:
```console ```console
$ nix-env --file https://github.com/NixOS/nixpkgs/archive/nixos-14.12.tar.gz --install --attr firefox $ nix-env --file https://github.com/NixOS/nixpkgs/archive/nixos-14.12.tar.gz --install --attr firefox
``` ```
@@ -125,10 +125,7 @@ derivation is shown unless `--no-name` is specified.
- `--drv-path` - `--drv-path`
Print the [store path] to the [store derivation]. Print the path of the [store derivation](@docroot@/glossary.md#gloss-store-derivation).
[store path]: @docroot@/glossary.md#gloss-store-path
[store derivation]: @docroot@/glossary.md#gloss-derivation
- `--out-path` - `--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. element of *args* matches no installed derivations.
For a description of how *args* is mapped to a set of store paths, see 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 store paths with the same symbolic name, only the one with the highest
version is installed. version is installed.
+1 -1
View File
@@ -67,7 +67,7 @@ md5sum`.
- `--type` *hashAlgo* - `--type` *hashAlgo*
Use the specified cryptographic hash algorithm, which can be one of Use the specified cryptographic hash algorithm, which can be one of
`blake3`, `md5`, `sha1`, `sha256`, and `sha512`. `md5`, `sha1`, `sha256`, and `sha512`.
- `--to-base16` - `--to-base16`
@@ -5,7 +5,7 @@
# Synopsis # Synopsis
`nix-instantiate` `nix-instantiate`
[`--parse` | `--eval` [`--strict`] [`--raw` | `--json` | `--xml`] ] [`--parse` | `--eval` [`--strict`] [`--json`] [`--xml`] ]
[`--read-write-mode`] [`--read-write-mode`]
[`--arg` *name* *value*] [`--arg` *name* *value*]
[{`--attr`| `-A`} *attrPath*] [{`--attr`| `-A`} *attrPath*]
@@ -32,7 +32,7 @@ standard input.
- `--add-root` *path* - `--add-root` *path*
See the [corresponding option](./nix-store.md) in `nix-store`. See the [corresponding option](nix-store.md) in `nix-store`.
- `--parse` - `--parse`
@@ -42,8 +42,8 @@ standard input.
- `--eval` - `--eval`
Just parse and evaluate the input files, and print the resulting Just parse and evaluate the input files, and print the resulting
values on standard output. values on standard output. No instantiation of store derivations
Store derivations are not serialized and written to the store, but instead just hashed and discarded. takes place.
> **Warning** > **Warning**
> >
@@ -102,11 +102,6 @@ standard input.
> This option can cause non-termination, because lazy data > This option can cause non-termination, because lazy data
> structures can be infinitely large. > structures can be infinitely large.
- `--raw`
When used with `--eval`, the evaluation result must be a string,
which is printed verbatim, without quoting, escaping or trailing newline.
- `--json` - `--json`
When used with `--eval`, print the resulting value as an JSON When used with `--eval`, print the resulting value as an JSON
@@ -42,7 +42,7 @@ the path of the downloaded file in the Nix store is also printed.
- `--type` *hashAlgo* - `--type` *hashAlgo*
Use the specified cryptographic hash algorithm, 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`. The default is `sha256`.
- `--print-path` - `--print-path`
+10 -36
View File
@@ -19,7 +19,7 @@
This man page describes the command `nix-shell`, which is distinct from `nix 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 shell`. For documentation on the latter, run `nix shell --help` or see `man
nix3-env-shell`. nix3-shell`.
# Description # Description
@@ -88,9 +88,7 @@ All options not listed here are passed to `nix-store
cleared before the interactive shell is started, so you get an cleared before the interactive shell is started, so you get an
environment that more closely corresponds to the “real” Nix build. A environment that more closely corresponds to the “real” Nix build. A
few variables, in particular `HOME`, `USER` and `DISPLAY`, are few variables, in particular `HOME`, `USER` and `DISPLAY`, are
retained. Note that the shell used to run commands is obtained from retained.
[`NIX_BUILD_SHELL`](#env-NIX_BUILD_SHELL) / `<nixpkgs>` from
`NIX_PATH`, and therefore not affected by `--pure`.
- `--packages` / `-p` *packages*… - `--packages` / `-p` *packages*…
@@ -114,30 +112,11 @@ All options not listed here are passed to `nix-store
# Environment variables # Environment variables
- <span id="env-NIX_BUILD_SHELL">[`NIX_BUILD_SHELL`](#env-NIX_BUILD_SHELL)</span> - `NIX_BUILD_SHELL`
Shell used to start the interactive environment. Shell used to start the interactive environment. Defaults to the
Defaults to the `bash` from `bashInteractive` found in `<nixpkgs>`, falling back to the `bash` found in `PATH` if not found. `bash` found in `<nixpkgs>`, falling back to the `bash` found in
`PATH` if not found.
> **Note**
>
> The shell obtained using this method may not necessarily be the same as any shells requested in *path*.
<!-- -->
> **Example
>
> Despite `--pure`, this invocation will not result in a fully reproducible shell environment:
>
> ```nix
> #!/usr/bin/env -S nix-shell --pure
> let
> pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/854fdc68881791812eddd33b2fed94b954979a8e.tar.gz") {};
> in
> pkgs.mkShell {
> buildInputs = pkgs.bashInteractive;
> }
> ```
{{#include ./env-common.md}} {{#include ./env-common.md}}
@@ -242,21 +221,16 @@ print(t)
``` ```
Similarly, the following is a Perl script that specifies that it Similarly, the following is a Perl script that specifies that it
requires Perl and the `HTML::TokeParser::Simple`, `LWP` and requires Perl and the `HTML::TokeParser::Simple` and `LWP` packages:
`LWP::Protocol::Https` packages:
```perl ```perl
#! /usr/bin/env nix-shell #! /usr/bin/env nix-shell
#! nix-shell -i perl #! nix-shell -i perl --packages perl perlPackages.HTMLTokeParserSimple perlPackages.LWP
#! nix-shell --packages perl
#! nix-shell --packages perlPackages.HTMLTokeParserSimple
#! nix-shell --packages perlPackages.LWP
#! nix-shell --packages perlPackages.LWPProtocolHttps
use HTML::TokeParser::Simple; use HTML::TokeParser::Simple;
# Fetch nixos.org and print all hrefs. # 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")) { while (my $token = $p->get_tag("a")) {
my $href = $token->get_attr("href"); my $href = $token->get_attr("href");
@@ -321,7 +295,7 @@ contains:
```nix ```nix
with import <nixpkgs> {}; 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. The script's file name is passed as the first argument to the interpreter specified by the `-i` flag.
@@ -21,9 +21,6 @@ This operation has the following options:
Use recursive instead of flat hashing mode, used when adding Use recursive instead of flat hashing mode, used when adding
directories to the store. directories to the store.
*paths* that refer to symlinks are not dereferenced, but added to the store
as symlinks with the same target.
{{#include ./opt-common.md}} {{#include ./opt-common.md}}
{{#include ../opt-common.md}} {{#include ../opt-common.md}}
@@ -11,9 +11,6 @@
The operation `--add` adds the specified paths to the Nix store. It The operation `--add` adds the specified paths to the Nix store. It
prints the resulting paths in the Nix store on standard output. prints the resulting paths in the Nix store on standard output.
*paths* that refer to symlinks are not dereferenced, but added to the store
as symlinks with the same target.
{{#include ./opt-common.md}} {{#include ./opt-common.md}}
{{#include ../opt-common.md}} {{#include ../opt-common.md}}
@@ -48,7 +48,8 @@ The behaviour of the collector is also influenced by the
configuration file. configuration file.
By default, the collector prints the total number of freed bytes when it 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}} {{#include ./opt-common.md}}
@@ -45,19 +45,10 @@ symlink.
[output paths]: @docroot@/glossary.md#gloss-output-path [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` - `--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 [closure]: @docroot@/glossary.md#gloss-closure
This query has one option: This query has one option:
@@ -74,25 +65,29 @@ symlink.
dependencies) is obtained by distributing the closure of a store dependencies) is obtained by distributing the closure of a store
derivation and specifying the option `--include-outputs`. 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` - `--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 the store paths currently existing in the Nix store that refer to
one of *paths*. Note that contrary to the references, the set of 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 referrers is not constant; it can change as store paths are added or
removed. removed.
[referrer]: @docroot@/glossary.md#gloss-referrer
- `--referrers-closure` - `--referrers-closure`
Prints the closure of the set of store paths *paths* under the 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 indirectly refer to one of *paths*. These are all the path currently
in the Nix store that are dependent on *paths*. in the Nix store that are dependent on *paths*.
[referrer]: @docroot@/glossary.md#gloss-referrer
- `--deriver` / `-d` - `--deriver` / `-d`
Prints the [deriver] that was used to build the store paths *paths*. If 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. 1. If it is not [valid], substitute the store derivation file itself.
2. Realise its [output paths]: 2. Realise its [output paths]:
- Try to fetch from [substituters] the [store objects] associated with the output paths in the store derivation's [closure]. - 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]. 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: - For any store paths that cannot be substituted, produce the required store objects:
1. Realise all outputs of the derivation's dependencies 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 [store objects]: @docroot@/store/store-object.md
[closure]: @docroot@/glossary.md#gloss-closure [closure]: @docroot@/glossary.md#gloss-closure
[substituters]: @docroot@/command-ref/conf-file.md#conf-substituters [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 [Nix database]: @docroot@/glossary.md#gloss-nix-database
The resulting paths are printed on standard output. 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)
+48 -78
View File
@@ -23,32 +23,32 @@ $ nix-shell
To get a shell with one of the other [supported compilation environments](#compilation-environments): To get a shell with one of the other [supported compilation environments](#compilation-environments):
```console ```console
$ nix-shell --attr devShells.x86_64-linux.native-clangStdenv $ nix-shell --attr devShells.x86_64-linux.native-clangStdenvPackages
``` ```
> **Note** > **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/`. > By default, [ccache](https://ccache.dev) keeps artifacts in `~/.cache/ccache/`.
To build Nix itself in this shell: To build Nix itself in this shell:
```console ```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]$ dontAddPrefix=1 mesonConfigurePhase
[nix-shell]$ buildPhase [nix-shell]$ ninjaBuildPhase
``` ```
To test it: To test it:
```console ```console
[nix-shell]$ checkPhase [nix-shell]$ mesonCheckPhase
``` ```
To install it in `$(pwd)/outputs`: To install it in `$(pwd)/outputs`:
```console ```console
[nix-shell]$ installPhase [nix-shell]$ ninjaInstallPhase
[nix-shell]$ ./outputs/out/bin/nix --version [nix-shell]$ ./outputs/out/bin/nix --version
nix (Nix) 2.12 nix (Nix) 2.12
``` ```
@@ -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. 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 [`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: 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): To get a shell with one of the other [supported compilation environments](#compilation-environments):
```console ```console
$ nix develop .#native-clangStdenv $ nix develop .#native-clangStdenvPackages
``` ```
> **Note** > **Note**
@@ -90,20 +90,20 @@ $ nix develop .#native-clangStdenv
To build Nix itself in this shell: To build Nix itself in this shell:
```console ```console
[nix-shell]$ configurePhase [nix-shell]$ mesonConfigurePhase
[nix-shell]$ buildPhase [nix-shell]$ ninjaBuildPhase
``` ```
To test it: To test it:
```console ```console
[nix-shell]$ checkPhase [nix-shell]$ mesonCheckPhase
``` ```
To install it in `$(pwd)/outputs`: To install it in `$(pwd)/outputs`:
```console ```console
[nix-shell]$ installPhase [nix-shell]$ ninjaInstallPhase
[nix-shell]$ nix --version [nix-shell]$ nix --version
nix (Nix) 2.12 nix (Nix) 2.12
``` ```
@@ -167,26 +167,36 @@ 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. 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. 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 `mesonConfigurePhase` 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 Here's how to do that
```bash
mesonBuildDir=build-my-variant-name
```
1. Configure as usual 1. Configure as usual
```bash ```bash
configurePhase mesonConfigurePhase
```
2. Rename the build directory
```bash
cd .. # since `mesonConfigurePhase` cd'd inside
mv build build-linux # or whatever name we want
cd build-linux
``` ```
3. Build as usual 3. Build as usual
```bash ```bash
buildPhase ninjaBuildPhase
``` ```
> **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 ## System type
Nix uses a string with the following format to identify the *system type* or *platform* it runs on: 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>] <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>] <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. 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)):
In the nix flake we also have some cross-compilation targets available:
``` ```
nix build .#nix-everything-riscv64-unknown-linux-gnu <cpu>-<vendor>[-<kernel>]-<os>
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
``` ```
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 | | `config.guess` | Nix |
|-----------------------------|-------------------------|---------------------| |----------------------------|---------------------|
| `x86` | | `i686` | | `amd64` | `x86_64` |
| `arm` | | `host_machine.cpu()`| | `i*86` | `i686` |
| `ppc` | `little` | `powerpcle` | | `arm6` | `arm6l` |
| `ppc64` | `little` | `powerpc64le` | | `arm7` | `arm7l` |
| `ppc` | `big` | `powerpc` | | `linux-gnu*` | `linux` |
| `ppc64` | `big` | `powerpc64` | | `linux-musl*` | `linux` |
| `mips` | `little` | `mipsel` |
| `mips64` | `little` | `mips64el` |
| `mips` | `big` | `mips` |
| `mips64` | `big` | `mips64` |
## Compilation environments ## Compilation environments
@@ -240,29 +240,28 @@ Nix can be compiled using multiple environments:
To build with one of those environments, you can use To build with one of those environments, you can use
```console ```console
$ nix build .#nix-cli-ccacheStdenv $ nix build .#nix-ccacheStdenv
``` ```
for flake-enabled Nix, or for flake-enabled Nix, or
```console ```console
$ nix-build --attr nix-cli-ccacheStdenv $ nix-build --attr nix-ccacheStdenv
``` ```
for classic Nix. 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 ## Editor integration
The `clangd` LSP server is installed by default on the `clang`-based `devShell`s. 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. 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. Meson's configure always produces this inside the build directory.
Configure your editor to use the `clangd` from the `.#native-clangStdenv` shell. 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).
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** > **Note**
> >
@@ -278,8 +277,6 @@ You may run the formatters as a one-off using:
./maintainers/format.sh ./maintainers/format.sh
``` ```
### Pre-commit hooks
If you'd like to run the formatters before every commit, install the 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: To refresh pre-commit hook's config file, do the following:
1. Exit the development shell and start it again by running `nix develop`. 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. 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 ```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`. Initializing Nix project at `/path/to/here`.
Select a template for you new project: Select a template for you new project:
@@ -20,9 +20,8 @@ prs: 1238
Here's one or more paragraphs that describe the change. Here's one or more paragraphs that describe the change.
- It's markdown - 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. 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. 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 ## Building Nix with Debug Symbols
In the development shell, set the `mesonBuildType` environment variable to `debug` before configuring the build: 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). Then, proceed to build Nix as described in [Building Nix](./building.md).
This will build Nix with debug symbols, which are essential for effective debugging. This will build Nix with debug symbols, which are essential for effective debugging.
It is also possible to build without debugging for faster build:
```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 ## Debugging the Nix Binary
Obtain your preferred debugger within the development shell: Obtain your preferred debugger within the development shell:
+10 -28
View File
@@ -19,37 +19,25 @@ nix-build -E '(import ./.).packages.${builtins.currentSystem}.nix.doc'
or or
```console ```console
nix build .#nix-manual nix build .#nix^doc
``` ```
and open `./result/share/doc/nix/manual/index.html`. and open `./result-doc/share/doc/nix/manual/index.html`.
To build the manual incrementally, [enter the development shell](./building.md) and run:
To build the manual incrementally, [enter the development shell](./building.md) and configure with `doc-gen` enabled:
**If using interactive `nix develop`:**
```console ```console
$ nix develop make manual-html-open -j $NIX_BUILD_CORES
$ mesonFlags="$mesonFlags -Ddoc-gen=true" mesonConfigurePhase
``` ```
**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 ```console
$ direnv allow 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
$ bash -c 'source $stdenv/setup && mesonFlags="$mesonFlags -Ddoc-gen=true" mesonConfigurePhase'
``` ```
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 ## Style guide
The goal of this style guide is to make it such that The goal of this style guide is to make it such that
@@ -215,7 +203,7 @@ $ xdg-open ./result/share/doc/nix/internal-api/html/index.html
or inside `nix-shell` or `nix develop`: or inside `nix-shell` or `nix develop`:
```console ```console
$ configurePhase $ mesonConfigurePhase
$ ninja src/internal-api-docs/html $ ninja src/internal-api-docs/html
$ xdg-open src/internal-api-docs/html/index.html $ xdg-open src/internal-api-docs/html/index.html
``` ```
@@ -236,13 +224,7 @@ $ xdg-open ./result/share/doc/nix/external-api/html/index.html
or inside `nix-shell` or `nix develop`: or inside `nix-shell` or `nix develop`:
``` ```
$ configurePhase $ mesonConfigurePhase
$ ninja src/external-api-docs/html $ ninja src/external-api-docs/html
$ xdg-open src/external-api-docs/html/index.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'
```
+2 -2
View File
@@ -1,12 +1,12 @@
experimental_feature_descriptions_md = custom_target( experimental_feature_descriptions_md = custom_target(
command : nix_eval_for_docs + [ command : nix_eval_for_docs + [
'--expr', 'import @INPUT0@ (builtins.fromJSON (builtins.readFile @INPUT1@))', '--expr',
'import @INPUT0@ (builtins.fromJSON (builtins.readFile @INPUT1@))',
], ],
input : [ input : [
'../../generate-xp-features.nix', '../../generate-xp-features.nix',
xp_features_json, xp_features_json,
], ],
capture : true, capture : true,
env : nix_env_for_docs,
output : 'experimental-feature-descriptions.md', output : 'experimental-feature-descriptions.md',
) )
+11 -35
View File
@@ -30,7 +30,7 @@ The unit tests are defined using the [googletest] and [rapidcheck] frameworks.
> src > src
> ├── libexpr > ├── libexpr
> │ ├── meson.build > │ ├── meson.build
> │ ├── include/nix/expr/value/context.hh > │ ├── value/context.hh
> │ ├── value/context.cc > │ ├── value/context.cc
> │ … > │ …
> │ > │
@@ -46,12 +46,8 @@ The unit tests are defined using the [googletest] and [rapidcheck] frameworks.
> │ │ > │ │
> │ ├── libexpr-test-support > │ ├── libexpr-test-support
> │ │ ├── meson.build > │ │ ├── meson.build
> │ │ ├── include/nix/expr
> │ │ │ ├── meson.build
> │ │ │ └── tests
> │ │ │ ├── value/context.hh
> │ │ │ …
> │ │ └── tests > │ │ └── tests
> │ │ ├── value/context.hh
> │ │ ├── value/context.cc > │ │ ├── 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`. 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. 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`. 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. Note that each executable only gets the data for its tests.
The unit test libraries are in `src/${library_name_without-nix}-test-support`. 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. 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: 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. 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) Putting the two together, one might run
This is used to create a debugger breakpoint when an assertion failure occurs.
Putting the first two together, one might run
```bash ```bash
GTEST_BRIEF=1 GTEST_FILTER='ErrorTraceTest.*' meson test nix-expr-tests -v 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. for short but comprensive output.
### Debugging tests ### Characterisation testing { #characaterisation-testing-unit }
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 }
See [functional characterisation testing](#characterisation-testing-functional) for a broader discussion of characterisation testing. See [functional characterisation testing](#characterisation-testing-functional) for a broader discussion of characterisation testing.
@@ -161,14 +137,14 @@ Functional tests are run during `installCheck` in the `nix` package build, as we
The whole test suite (functional and unit tests) can be run with: The whole test suite (functional and unit tests) can be run with:
```shell-session ```shell-session
$ checkPhase $ mesonCheckPhase
``` ```
### Grouping tests ### Grouping tests
Sometimes it is useful to group related tests so they can be easily run together without running the entire test suite. 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`. 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: That test group can be run like this:
@@ -237,10 +213,10 @@ edit it like so:
bar 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 ```shell-session
$ meson test ${testName} --interactive $ ./mk/debug-test.sh tests/functional/${testName}.sh
... ...
+ gdb blash blub + gdb blash blub
GNU gdb (GDB) 12.1 GNU gdb (GDB) 12.1
@@ -321,7 +297,7 @@ Creating a Cachix cache for your installer tests and adding its authorisation to
- `armv7l-linux` - `armv7l-linux`
- `x86_64-darwin` - `x86_64-darwin`
- The `installer_test` job (which runs on `ubuntu-24.04` and `macos-14`) will try to install Nix with the cached installer and run a trivial Nix command. - The `installer_test` job (which runs on `ubuntu-latest` and `macos-latest`) will try to install Nix with the cached installer and run a trivial Nix command.
### One-time setup ### One-time setup
+45 -96
View File
@@ -1,13 +1,5 @@
# Glossary # 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} - [content address]{#gloss-content-address}
A A
@@ -21,62 +13,37 @@
- [Content-Addressing File System Objects](@docroot@/store/file-system-object/content-address.md) - [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 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. 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). 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} - [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. A description of a build task. The result of a derivation is a
store object. Derivations declared in Nix expressions are specified
Derivations are implemented as [operating system processes that run in a sandbox](@docroot@/store/building.md#builder-execution). using the [`derivation` primitive](./language/derivations.md). These are
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). translated into low-level *store derivations* (implicitly by
`nix-build`, or explicitly by `nix-instantiate`).
A derivation is typically specified as a [derivation expression] in the [Nix language], and [instantiated][instantiate] to a [store derivation].
There are multiple ways of obtaining store objects from store derivatons, collectively called [realisation][realise].
[derivation]: #gloss-derivation [derivation]: #gloss-derivation
- [store derivation]{#gloss-store-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 [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 - [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. 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: This can be achieved by:
- Fetching a pre-built [store object] from a [substituter] - 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 - 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. 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 [realise]: #gloss-realise
- [content-addressing derivation]{#gloss-content-addressing-derivation} - [content-addressed derivation]{#gloss-content-addressed-derivation}
A derivation which has the A derivation which has the
[`__contentAddressed`](./language/advanced-attributes.md#adv-attr-__contentAddressed) [`__contentAddressed`](./language/advanced-attributes.md#adv-attr-__contentAddressed)
@@ -105,7 +73,7 @@
- [fixed-output derivation]{#gloss-fixed-output-derivation} (FOD) - [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} - [store]{#gloss-store}
@@ -116,12 +84,6 @@
[store]: #gloss-store [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} - [binary cache]{#gloss-binary-cache}
A *binary cache* is a Nix store which uses a different format: its 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} - [input-addressed store object]{#gloss-input-addressed-store-object}
A store object produced by building a 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) non-[fixed-output](#gloss-fixed-output-derivation)
derivation. derivation.
See [input-addressing derivation outputs](store/derivation/outputs/input-address.md) for details.
- [content-addressed store object]{#gloss-content-addressed-store-object} - [content-addressed store object]{#gloss-content-addressed-store-object}
A [store object] which is [content-addressed](#gloss-content-address), A [store object] which is [content-addressed](#gloss-content-address),
i.e. whose [store path] is determined by its contents. 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. See [Content-Addressing Store Objects](@docroot@/store/store-object/content-address.md) for details.
@@ -208,7 +168,7 @@
- [impure derivation]{#gloss-impure-derivation} - [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. so that they are always rebuilt, and their outputs not reused by subsequent calls to realise them.
- [Nix database]{#gloss-nix-database} - [Nix database]{#gloss-nix-database}
@@ -228,37 +188,35 @@
> >
> The contents of a `.nix` file form a Nix expression. > 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]. These derivations can then be [realised][realise] to produce [outputs][output].
> **Example** > **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} - [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 [reference]: #gloss-reference
See [References](@docroot@/store/store-object.md#references) for details.
- [reachable]{#gloss-reachable} - [reachable]{#gloss-reachable}
A store path `Q` is reachable from another store path `P` if `Q` A store path `Q` is reachable from another store path `P` if `Q`
is in the *closure* of the *references* relation. is in the *closure* of the *references* relation.
See [References](@docroot@/store/store-object.md#references) for details.
- [closure]{#gloss-closure} - [closure]{#gloss-closure}
The closure of a store path is the set of store paths that are The closure of a store path is the set of store paths that are
directly or indirectly “reachable” from that store path; that is, directly or indirectly “reachable” from that store path; that is,
it’s the closure of the path under the *references* relation. For it’s the closure of the path under the *references* relation. For
a package, the closure of its derivation is equivalent to the 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 equivalent to its runtime dependencies. For correct deployment it
is necessary to deploy whole closures, since otherwise at runtime is necessary to deploy whole closures, since otherwise at runtime
files could be missing. The command `nix-store --query --requisites ` prints out 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` 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`. references `R` then `R` is also in the closure of `P`.
See [References](@docroot@/store/store-object.md#references) for details.
[closure]: #gloss-closure [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} - [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. See [the `outputs` argument to the `derivation` function](@docroot@/language/derivations.md#attr-outputs) for details.
[output]: #gloss-output [output]: #gloss-output
- [output path]{#gloss-output-path} - [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 [output path]: #gloss-output-path
@@ -301,11 +246,14 @@
- [deriving path]{#gloss-deriving-path} - [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} - [deriver]{#gloss-deriver}
@@ -353,7 +301,7 @@
See [Nix Archive](store/file-system-object/content-address.html#serial-nix-archive) for details. 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. 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} - [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: - [package attribute set]{#package-attribute-set}
- 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.
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} - [string interpolation]{#gloss-string-interpolation}
@@ -383,7 +332,7 @@
[string]: ./language/types.md#type-string [string]: ./language/types.md#type-string
[path]: ./language/types.md#type-path [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} - [base directory]{#gloss-base-directory}
-2
View File
@@ -30,8 +30,6 @@ $ curl -L https://nixos.org/nix/install | sh -s -- --daemon
> Single-user is not supported on Mac. > 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 This installation has less requirements than the multi-user install, however it
cannot offer equivalent sharing, isolation, or security. 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`. 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: To show available command line flags:
```console ```console
@@ -3,21 +3,19 @@
To run the latest stable release of Nix with Docker run the following command: To run the latest stable release of Nix with Docker run the following command:
```console ```console
$ docker run -ti docker.io/nixos/nix $ docker run -ti ghcr.io/nixos/nix
Unable to find image 'docker.io/nixos/nix:latest' locally Unable to find image 'ghcr.io/nixos/nix:latest' locally
latest: Pulling from docker.io/nixos/nix latest: Pulling from ghcr.io/nixos/nix
5843afab3874: Pull complete 5843afab3874: Pull complete
b52bf13f109c: Pull complete b52bf13f109c: Pull complete
1e2415612aa3: Pull complete 1e2415612aa3: Pull complete
Digest: sha256:27f6e7f60227e959ee7ece361f75d4844a40e1cc6878b6868fe30140420031ff 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 35ca4ada6e96:/# nix --version
nix (Nix) 2.3.12 nix (Nix) 2.3.12
35ca4ada6e96:/# exit 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? # What is included in Nix's Docker image?
The official Docker image is created using `pkgs.dockerTools.buildLayeredImage` The official Docker image is created using `pkgs.dockerTools.buildLayeredImage`
@@ -59,21 +57,3 @@ $ nix build ./\#hydraJobs.dockerImage.x86_64-linux
$ docker load -i ./result/image.tar.gz $ docker load -i ./result/image.tar.gz
$ docker run -ti nix:2.5pre20211105 $ docker run -ti nix:2.5pre20211105
``` ```
# Docker image with non-root Nix
If you would like to run Nix in a container under a user other than `root`,
you can build an image with a non-root single-user installation of Nix
by specifying the `uid`, `gid`, `uname`, and `gname` arguments to `docker.nix`:
```console
$ nix build --file docker.nix \
--arg uid 1000 \
--arg gid 1000 \
--argstr uname user \
--argstr gname user \
--argstr name nix-user \
--out-link nix-user.tar.gz
$ docker load -i nix-user.tar.gz
$ docker run -ti nix-user
```
@@ -10,7 +10,7 @@
- Bash Shell. The `./configure` script relies on bashisms, so Bash is - Bash Shell. The `./configure` script relies on bashisms, so Bash is
required. 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 - `pkg-config` to locate dependencies. If your distribution does not
provide it, you can get it from provide it, you can get it from
+1 -33
View File
@@ -41,38 +41,6 @@ There may also be references to Nix in
which you may remove. 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 ### macOS
> **Updating to macOS 15 Sequoia** > **Updating to macOS 15 Sequoia**
@@ -192,6 +160,6 @@ which you may remove.
To remove a [single-user installation](./installing-binary.md#single-user-installation) of Nix, run: To remove a [single-user installation](./installing-binary.md#single-user-installation) of Nix, run:
```console ```console
rm -rf /nix ~/.nix-channels ~/.nix-defexpr ~/.nix-profile $ rm -rf /nix ~/.nix-channels ~/.nix-defexpr ~/.nix-profile
``` ```
You might also want to manually remove references to Nix from your `~/.profile`. You might also want to manually remove references to Nix from your `~/.profile`.
+2 -2
View File
@@ -1,8 +1,8 @@
# Introduction # Introduction
Nix is a _purely functional package manager_. This means that it Nix is a _purely functional package manager_. This means that it
treats packages like values in a purely functional programming language treats packages like values in purely functional programming languages
— packages are built by functions that don’t have such as Haskell — they are built by functions that don’t have
side-effects, and they never change after they have been built. Nix side-effects, and they never change after they have been built. Nix
stores packages in the _Nix store_, usually the directory stores packages in the _Nix store_, usually the directory
`/nix/store`, where each package has its own unique subdirectory such `/nix/store`, where each package has its own unique subdirectory such
Loaded 100 of 1908 files, more files were not shown because too many files have changed in this diff. Show more