1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-28 13:11:00 +01:00

Merge remote-tracking branch 'origin/master' into gdennis/git-filter-config

This commit is contained in:
Graham Dennis 2025-09-15 10:43:05 +10:00
commit 9bba7ac3e8
887 changed files with 34455 additions and 28681 deletions

View file

@ -8,7 +8,7 @@ BraceWrapping:
AfterUnion: true AfterUnion: true
SplitEmptyRecord: false SplitEmptyRecord: false
PointerAlignment: Middle PointerAlignment: Middle
FixNamespaceComments: false FixNamespaceComments: true
SortIncludes: Never SortIncludes: Never
#IndentPPDirectives: BeforeHash #IndentPPDirectives: BeforeHash
SpaceAfterCStyleCast: true SpaceAfterCStyleCast: true
@ -32,3 +32,4 @@ IndentPPDirectives: AfterHash
PPIndentWidth: 2 PPIndentWidth: 2
BinPackArguments: false BinPackArguments: false
BreakBeforeTernaryOperators: true BreakBeforeTernaryOperators: true
SeparateDefinitionBlocks: Always

6
.git-blame-ignore-revs Normal file
View file

@ -0,0 +1,6 @@
# 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

View file

@ -45,7 +45,7 @@ assignees: ''
- [ ] checked [latest Nix manual] \([source]) - [ ] checked [latest Nix manual] \([source])
- [ ] checked [open bug issues and pull requests] for possible duplicates - [ ] checked [open bug issues and pull requests] for possible duplicates
[latest Nix manual]: https://nixos.org/manual/nix/unstable/ [latest Nix manual]: https://nix.dev/manual/nix/development/
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source [source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
[open bug issues and pull requests]: https://github.com/NixOS/nix/labels/bug [open bug issues and pull requests]: https://github.com/NixOS/nix/labels/bug

View file

@ -30,7 +30,7 @@ assignees: ''
- [ ] checked [latest Nix manual] \([source]) - [ ] checked [latest Nix manual] \([source])
- [ ] checked [open feature issues and pull requests] for possible duplicates - [ ] checked [open feature issues and pull requests] for possible duplicates
[latest Nix manual]: https://nixos.org/manual/nix/unstable/ [latest Nix manual]: https://nix.dev/manual/nix/development/
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source [source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
[open feature issues and pull requests]: https://github.com/NixOS/nix/labels/feature [open feature issues and pull requests]: https://github.com/NixOS/nix/labels/feature

View file

@ -38,7 +38,7 @@ assignees: ''
- [ ] checked [latest Nix manual] \([source]) - [ ] checked [latest Nix manual] \([source])
- [ ] checked [open installer issues and pull requests] for possible duplicates - [ ] checked [open installer issues and pull requests] for possible duplicates
[latest Nix manual]: https://nixos.org/manual/nix/unstable/ [latest Nix manual]: https://nix.dev/manual/nix/development/
[source]: https://github.com/NixOS/nix/tree/master/doc/manual/source [source]: https://github.com/NixOS/nix/tree/master/doc/manual/source
[open installer issues and pull requests]: https://github.com/NixOS/nix/labels/installer [open installer issues and pull requests]: https://github.com/NixOS/nix/labels/installer

View file

@ -22,7 +22,7 @@ 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://nixos.org/manual/nix/unstable/ [latest Nix manual]: https://nix.dev/manual/nix/development/
[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

View file

@ -0,0 +1,50 @@
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
extra_nix_config:
description: "Gets appended to `/etc/nix/nix.conf` if passed."
install_url:
description: "URL of the Nix installer"
required: false
default: "https://releases.nixos.org/nix/nix-2.30.2/install"
github_token:
description: "Github token"
required: true
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"
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"
- uses: cachix/install-nix-action@c134e4c9e34bac6cab09cf239815f9339aaaf84e # v31.5.1
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 }}

View file

@ -2,7 +2,15 @@ name: "CI"
on: on:
pull_request: pull_request:
merge_group:
push: push:
workflow_dispatch:
inputs:
dogfood:
description: 'Use dogfood Nix build'
required: false
default: true
type: boolean
permissions: read-all permissions: read-all
@ -10,11 +18,16 @@ jobs:
eval: eval:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v5
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: cachix/install-nix-action@v31 - uses: ./.github/actions/install-nix-action
- run: nix --experimental-features 'nix-command flakes' flake show --all-systems --json 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: nix flake show --all-systems --json
tests: tests:
strategy: strategy:
@ -24,34 +37,69 @@ jobs:
- scenario: on ubuntu - scenario: on ubuntu
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
os: linux os: linux
instrumented: false
primary: true
stdenv: stdenv
- scenario: on macos - scenario: on macos
runs-on: macos-14 runs-on: macos-14
os: darwin 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 }} name: tests ${{ matrix.scenario }}
runs-on: ${{ matrix.runs-on }} runs-on: ${{ matrix.runs-on }}
timeout-minutes: 60 timeout-minutes: 60
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v5
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: cachix/install-nix-action@v31 - uses: ./.github/actions/install-nix-action
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: | extra_nix_config: "sandbox = true"
sandbox = true
max-jobs = 1
- uses: DeterminateSystems/magic-nix-cache-action@main - uses: DeterminateSystems/magic-nix-cache-action@main
# Since ubuntu 22.30, unprivileged usernamespaces are no longer allowed to map to the root user: # Since ubuntu 22.30, unprivileged usernamespaces are no longer allowed to map to the root user:
# https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces # https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces
- run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 - run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
if: matrix.os == 'linux' if: matrix.os == 'linux'
- run: scripts/build-checks - name: Run component tests
- run: scripts/prepare-installer-for-github-actions run: |
nix build --file ci/gha/tests/wrapper.nix componentTests -L \
--arg withInstrumentation ${{ matrix.instrumented }} \
--argstr stdenv "${{ matrix.stdenv }}"
- 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@v4
with:
name: coverage-reports
path: coverage-reports/
if: ${{ matrix.instrumented }}
- name: Upload installer tarball - name: Upload installer tarball
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: installer-${{matrix.os}} name: installer-${{matrix.os}}
path: out/* path: out/*
if: ${{ matrix.primary }}
installer_test: installer_test:
needs: [tests] needs: [tests]
@ -68,19 +116,19 @@ jobs:
name: installer test ${{ matrix.scenario }} name: installer test ${{ matrix.scenario }}
runs-on: ${{ matrix.runs-on }} runs-on: ${{ matrix.runs-on }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v5
- name: Download installer tarball - name: Download installer tarball
uses: actions/download-artifact@v4 uses: actions/download-artifact@v5
with: with:
name: installer-${{matrix.os}} name: installer-${{matrix.os}}
path: out path: out
- name: Serving installer - name: Looking up the installer tarball URL
id: serving_installer id: installer-tarball-url
run: ./scripts/serve-installer-for-github-actions run: echo "installer-url=file://$GITHUB_WORKSPACE/out" >> "$GITHUB_OUTPUT"
- uses: cachix/install-nix-action@v31 - uses: cachix/install-nix-action@v31
with: with:
install_url: 'http://localhost:8126/install' install_url: ${{ format('{0}/install', steps.installer-tarball-url.outputs.installer-url) }}
install_options: "--tarball-url-prefix http://localhost:8126/" install_options: ${{ format('--tarball-url-prefix {0}', steps.installer-tarball-url.outputs.installer-url) }}
- run: sudo apt install fish zsh - run: sudo apt install fish zsh
if: matrix.os == 'linux' if: matrix.os == 'linux'
- run: brew install fish - run: brew install fish
@ -99,17 +147,17 @@ jobs:
check_secrets: check_secrets:
permissions: permissions:
contents: none contents: none
name: Check Docker secrets present for installer tests name: Check presence of secrets
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
outputs: outputs:
docker: ${{ steps.secret.outputs.docker }} docker: ${{ steps.secret.outputs.docker }}
steps: steps:
- name: Check for secrets - name: Check for DockerHub secrets
id: secret id: secret
env: env:
_DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }} _DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }}
run: | run: |
echo "::set-output name=docker::${{ env._DOCKER_SECRETS != '' }}" echo "docker=${{ env._DOCKER_SECRETS != '' }}" >> $GITHUB_OUTPUT
docker_push_image: docker_push_image:
needs: [tests, vm_tests, check_secrets] needs: [tests, vm_tests, check_secrets]
@ -122,13 +170,7 @@ jobs:
github.ref_name == 'master' github.ref_name == 'master'
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
steps: steps:
- name: Check for secrets - uses: actions/checkout@v5
id: secret
env:
_DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }}
run: |
echo "::set-output name=docker::${{ env._DOCKER_SECRETS != '' }}"
- uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: cachix/install-nix-action@v31 - uses: cachix/install-nix-action@v31
@ -174,8 +216,13 @@ jobs:
vm_tests: vm_tests:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v5
- uses: DeterminateSystems/nix-installer-action@main - uses: ./.github/actions/install-nix-action
with:
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
extra_nix_config:
experimental-features = nix-command flakes
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: DeterminateSystems/magic-nix-cache-action@main - uses: DeterminateSystems/magic-nix-cache-action@main
- run: | - run: |
nix build -L \ nix build -L \
@ -190,17 +237,45 @@ jobs:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
steps: steps:
- name: Checkout nix - name: Checkout nix
uses: actions/checkout@v4 uses: actions/checkout@v5
- name: Checkout flake-regressions - name: Checkout flake-regressions
uses: actions/checkout@v4 uses: actions/checkout@v5
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@v4 uses: actions/checkout@v5
with: with:
repository: NixOS/flake-regressions-data repository: NixOS/flake-regressions-data
path: flake-regressions/tests path: flake-regressions/tests
- uses: DeterminateSystems/nix-installer-action@main - uses: ./.github/actions/install-nix-action
with:
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
extra_nix_config:
experimental-features = nix-command flakes
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: DeterminateSystems/magic-nix-cache-action@main - uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix build -L --out-link ./new-nix && PATH=$(pwd)/new-nix/bin:$PATH MAX_FLAKES=25 flake-regressions/eval-all.sh - 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
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: |
nix build -L --file ./ci/gha/profile-build buildTimeReport --out-link build-time-report.md
cat build-time-report.md >> $GITHUB_STEP_SUMMARY

View file

@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
if: github.repository_owner == 'NixOS' if: github.repository_owner == 'NixOS'
steps: steps:
- uses: actions/labeler@v5 - uses: actions/labeler@v6
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
sync-labels: false sync-labels: false

View file

@ -150,3 +150,25 @@ pull_request_rules:
labels: labels:
- automatic backport - automatic backport
- merge-queue - merge-queue
- name: backport patches to 2.30
conditions:
- label=backport 2.30-maintenance
actions:
backport:
branches:
- "2.30-maintenance"
labels:
- automatic backport
- merge-queue
- name: backport patches to 2.31
conditions:
- label=backport 2.31-maintenance
actions:
backport:
branches:
- "2.31-maintenance"
labels:
- automatic backport
- merge-queue

View file

@ -1 +1 @@
2.30.0 2.32.0

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://nixos.org/manual/nix. The Nix reference manual is hosted on https://nix.dev/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).

View file

@ -0,0 +1,101 @@
{
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;
}

229
ci/gha/tests/default.nix Normal file
View file

@ -0,0 +1,229 @@
{
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);
enableSanitizersLayer = finalAttrs: prevAttrs: {
mesonFlags =
(prevAttrs.mesonFlags or [ ])
++ [
# Run all tests with UBSAN enabled. Running both with ubsan and
# without doesn't seem to have much immediate benefit for doubling
# the GHA CI workaround.
#
# TODO: Work toward enabling "address,undefined" if it seems feasible.
# This would maybe require dropping Boost coroutines and ignoring intentional
# memory leaks with detect_leaks=0.
(lib.mesonOption "b_sanitize" "undefined")
]
++ (lib.optionals stdenv.cc.isClang [
# https://www.github.com/mesonbuild/meson/issues/764
(lib.mesonBool "b_lundef" false)
]);
};
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 withSanitizers enableSanitizersLayer)
++ (lib.optional withCoverage collectCoverageLayer);
in
rec {
nixComponentsInstrumented = nixComponents.overrideScope (
final: prev: {
nix-store-tests = prev.nix-store-tests.override { withBenchmarks = true; };
mesonComponentOverrides = lib.composeManyExtensions componentOverrides;
}
);
/**
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;
};
};
componentTests =
(lib.concatMapAttrs (
pkgName: pkg:
lib.concatMapAttrs (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;
};
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;
};
}

16
ci/gha/tests/wrapper.nix Normal file
View file

@ -0,0 +1,16 @@
{
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;
}
)

View file

@ -1,4 +1,5 @@
project('nix-manual', project(
'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',
@ -8,43 +9,45 @@ 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', 'nix=' + meson.current_source_dir(), '-I',
'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,
@ -78,13 +81,14 @@ manual = custom_target(
'manual', 'manual',
command : [ command : [
bash, bash,
'-euo', 'pipefail', '-euo',
'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 sed -e 's|@version@|@3@|g' < @INPUT2@ > @2@/book.toml
rsync -r --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/ @4@ -r --include='*.md' @CURRENT_SOURCE_DIR@/ @2@/
(cd @2@; RUST_LOG=warn @1@ build -d @2@ 3>&2 2>&1 1>&3) | { grep -Fv "because fragment resolution isn't implemented" || :; } 3>&2 2>&1 1>&3 (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
@ -94,6 +98,7 @@ manual = custom_target(
mdbook.full_path(), mdbook.full_path(),
meson.current_build_dir(), meson.current_build_dir(),
meson.project_version(), meson.project_version(),
rsync.full_path(),
), ),
], ],
input : [ input : [
@ -118,8 +123,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]
@ -131,7 +136,8 @@ install_subdir(
) )
nix_nested_manpages = [ nix_nested_manpages = [
[ 'nix-env', [
'nix-env',
[ [
'delete-generations', 'delete-generations',
'install', 'install',
@ -146,7 +152,8 @@ nix_nested_manpages = [
'upgrade', 'upgrade',
], ],
], ],
[ 'nix-store', [
'nix-store',
[ [
'add-fixed', 'add-fixed',
'add', 'add',

View file

@ -46,24 +46,23 @@ mkMesonDerivation (finalAttrs: {
]; ];
# Hack for sake of the dev shell # Hack for sake of the dev shell
passthru.externalNativeBuildInputs = passthru.externalNativeBuildInputs = [
[ meson
meson ninja
ninja (lib.getBin lowdown-unsandboxed)
(lib.getBin lowdown-unsandboxed) mdbook
mdbook mdbook-linkcheck
mdbook-linkcheck jq
jq python3
python3 rsync
rsync changelog-d
changelog-d ]
] ++ lib.optionals (!officialRelease) [
++ lib.optionals (!officialRelease) [ # When not an official release, we likely have changelog entries that have
# When not an official release, we likely have changelog entries that have # yet to be rendered.
# yet to be rendered. # When released, these are rendered into a committed file to save a dependency.
# When released, these are rendered into a committed file to save a dependency. changelog-d
changelog-d ];
];
nativeBuildInputs = finalAttrs.passthru.externalNativeBuildInputs ++ [ nativeBuildInputs = finalAttrs.passthru.externalNativeBuildInputs ++ [
nix-cli nix-cli

View file

@ -0,0 +1,6 @@
---
synopsis: "Removed support for daemons and clients older than Nix 2.0"
prs: [13951]
---
We have dropped support in the daemon worker protocol for daemons and clients that don't speak at least version 18 of the protocol. This first Nix release that supports this version is Nix 2.0, released in February 2018.

View file

@ -0,0 +1,6 @@
---
synopsis: "Temporary build directories no longer include derivation names"
prs: [13839]
---
Temporary build directories created during derivation builds no longer include the derivation name in their path to avoid build failures when the derivation name is too long. This change ensures predictable prefix lengths for build directories under `/nix/var/nix/builds`.

View file

@ -128,6 +128,7 @@
- [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)
@ -137,6 +138,7 @@
- [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.31 (2025-08-21)](release-notes/rl-2.31.md)
- [Release 2.30 (2025-07-07)](release-notes/rl-2.30.md) - [Release 2.30 (2025-07-07)](release-notes/rl-2.30.md)
- [Release 2.29 (2025-05-14)](release-notes/rl-2.29.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.28 (2025-04-02)](release-notes/rl-2.28.md)

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 `prefix/etc/nix`). (default `sysconfdir/nix`, i.e. `/etc/nix` on most systems).
- <span id="env-NIX_CONFIG">[`NIX_CONFIG`](#env-NIX_CONFIG)</span> - <span id="env-NIX_CONFIG">[`NIX_CONFIG`](#env-NIX_CONFIG)</span>

View file

@ -1,13 +1,12 @@
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',
) )
experimental_features_shortlist_md = custom_target( experimental_features_shortlist_md = custom_target(
command : nix_eval_for_docs + [ command : nix_eval_for_docs + [
'--expr', '--expr', 'import @INPUT0@ (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
'import @INPUT0@ (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
], ],
input : [ input : [
'../../generate-xp-features-shortlist.nix', '../../generate-xp-features-shortlist.nix',
@ -19,14 +18,8 @@ experimental_features_shortlist_md = custom_target(
) )
nix3_cli_files = custom_target( nix3_cli_files = custom_target(
command : [ command : [ python.full_path(), '@INPUT0@', '@OUTPUT@', '--' ] + nix_eval_for_docs + [
python.full_path(), '--expr', 'import @INPUT1@ true (builtins.readFile ./@INPUT2@)',
'@INPUT0@',
'@OUTPUT@',
'--'
] + nix_eval_for_docs + [
'--expr',
'import @INPUT1@ true (builtins.readFile ./@INPUT2@)',
], ],
input : [ input : [
'../../remove_before_wrapper.py', '../../remove_before_wrapper.py',
@ -40,8 +33,7 @@ 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', '--expr', 'import @INPUT0@ { prefix = "conf"; } (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
'import @INPUT0@ { prefix = "conf"; } (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
], ],
capture : true, capture : true,
input : [ input : [

View file

@ -0,0 +1,187 @@
# 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)

View file

@ -34,7 +34,7 @@ $ nix-shell --attr devShells.x86_64-linux.native-clangStdenvPackages
To build Nix itself in this shell: To build Nix itself in this shell:
```console ```console
[nix-shell]$ mesonFlags+=" --prefix=$(pwd)/outputs/out" [nix-shell]$ out="$(pwd)/outputs/out" dev=$out debug=$out mesonFlags+=" --prefix=${out}"
[nix-shell]$ dontAddPrefix=1 configurePhase [nix-shell]$ dontAddPrefix=1 configurePhase
[nix-shell]$ buildPhase [nix-shell]$ buildPhase
``` ```
@ -215,14 +215,18 @@ nix build .#nix-everything-x86_64-w64-mingw32
For historic reasons and backward-compatibility, some CPU and OS identifiers are translated as follows: For historic reasons and backward-compatibility, some CPU and OS identifiers are translated as follows:
| `config.guess` | Nix | | `host_machine.cpu_family()` | `host_machine.endian()` | Nix |
|----------------------------|---------------------| |-----------------------------|-------------------------|---------------------|
| `amd64` | `x86_64` | | `x86` | | `i686` |
| `i*86` | `i686` | | `arm` | | `host_machine.cpu()`|
| `arm6` | `arm6l` | | `ppc` | `little` | `powerpcle` |
| `arm7` | `arm7l` | | `ppc64` | `little` | `powerpc64le` |
| `linux-gnu*` | `linux` | | `ppc` | `big` | `powerpc` |
| `linux-musl*` | `linux` | | `ppc64` | `big` | `powerpc64` |
| `mips` | `little` | `mipsel` |
| `mips64` | `little` | `mips64el` |
| `mips` | `big` | `mips` |
| `mips64` | `big` | `mips64` |
## Compilation environments ## Compilation environments

View file

@ -1,7 +1,6 @@
experimental_feature_descriptions_md = custom_target( experimental_feature_descriptions_md = custom_target(
command : nix_eval_for_docs + [ command : nix_eval_for_docs + [
'--expr', '--expr', 'import @INPUT0@ (builtins.fromJSON (builtins.readFile @INPUT1@))',
'import @INPUT0@ (builtins.fromJSON (builtins.readFile @INPUT1@))',
], ],
input : [ input : [
'../../generate-xp-features.nix', '../../generate-xp-features.nix',

View file

@ -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++20. - A version of GCC or Clang that supports C++23.
- `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

View file

@ -41,6 +41,38 @@ 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**

View file

@ -160,7 +160,6 @@ See the [corresponding section in the derivation output page](@docroot@/store/de
## Other output modifications ## Other output modifications
- [`unsafeDiscardReferences`]{#adv-attr-unsafeDiscardReferences}\ - [`unsafeDiscardReferences`]{#adv-attr-unsafeDiscardReferences}\
When using [structured attributes](#adv-attr-structuredAttrs), the When using [structured attributes](#adv-attr-structuredAttrs), the
attribute `unsafeDiscardReferences` is an attribute set with a boolean value for each output name. attribute `unsafeDiscardReferences` is an attribute set with a boolean value for each output name.
If set to `true`, it disables scanning the output for runtime dependencies. If set to `true`, it disables scanning the output for runtime dependencies.
@ -195,7 +194,6 @@ See the [corresponding section in the derivation output page](@docroot@/store/de
[`builder`]: ./derivations.md#attr-builder [`builder`]: ./derivations.md#attr-builder
- [`requiredSystemFeatures`]{#adv-attr-requiredSystemFeatures}\ - [`requiredSystemFeatures`]{#adv-attr-requiredSystemFeatures}\
If a derivation has the `requiredSystemFeatures` attribute, then Nix will only build it on a machine that has the corresponding features set in its [`system-features` configuration](@docroot@/command-ref/conf-file.md#conf-system-features). If a derivation has the `requiredSystemFeatures` attribute, then Nix will only build it on a machine that has the corresponding features set in its [`system-features` configuration](@docroot@/command-ref/conf-file.md#conf-system-features).
For example, setting For example, setting

View file

@ -1,19 +1,13 @@
builtins_md = custom_target( builtins_md = custom_target(
command : [ command : [ python.full_path(), '@INPUT0@', '@OUTPUT@', '--' ] + nix_eval_for_docs + [
python.full_path(), '--expr', '(builtins.readFile @INPUT3@) + import @INPUT1@ (builtins.fromJSON (builtins.readFile ./@INPUT2@)) + (builtins.readFile @INPUT4@)',
'@INPUT0@',
'@OUTPUT@',
'--'
] + nix_eval_for_docs + [
'--expr',
'(builtins.readFile @INPUT3@) + import @INPUT1@ (builtins.fromJSON (builtins.readFile ./@INPUT2@)) + (builtins.readFile @INPUT4@)',
], ],
input : [ input : [
'../../remove_before_wrapper.py', '../../remove_before_wrapper.py',
'../../generate-builtins.nix', '../../generate-builtins.nix',
language_json, language_json,
'builtins-prefix.md', 'builtins-prefix.md',
'builtins-suffix.md' 'builtins-suffix.md',
], ],
output : 'builtins.md', output : 'builtins.md',
env : nix_env_for_docs, env : nix_env_for_docs,

View file

@ -1,7 +1,8 @@
summary_rl_next = custom_target( summary_rl_next = custom_target(
command : [ command : [
bash, bash,
'-euo', 'pipefail', '-euo',
'pipefail',
'-c', '-c',
''' '''
if [ -e "@INPUT@" ]; then if [ -e "@INPUT@" ]; then
@ -12,6 +13,6 @@ summary_rl_next = custom_target(
input : [ input : [
rl_next_generated, rl_next_generated,
], ],
capture: true, capture : true,
output : 'SUMMARY-rl-next.md', output : 'SUMMARY-rl-next.md',
) )

View file

@ -12,7 +12,7 @@ $ ln -s /nix/store/d718ef...-foo /nix/var/nix/gcroots/bar
That is, after this command, the garbage collector will not remove That is, after this command, the garbage collector will not remove
`/nix/store/d718ef...-foo` or any of its dependencies. `/nix/store/d718ef...-foo` or any of its dependencies.
Subdirectories of `prefix/nix/var/nix/gcroots` are also searched for Subdirectories of `prefix/nix/var/nix/gcroots` are searched
symlinks. Symlinks to non-store paths are followed and searched for recursively. Symlinks to store paths count as roots. Symlinks to
roots, but symlinks to non-store paths *inside* the paths reached in non-store paths are ignored, unless the non-store path is itself a
that way are not followed to prevent infinite recursion. symlink to a store path.

View file

@ -24,7 +24,7 @@ nar-obj-inner
| str("type"), str("directory") directory | str("type"), str("directory") directory
; ;
regular = [ str("executable"), str("") ], str("contents"), str(contents); regular = [ str("executable") ], str("contents"), str(contents);
symlink = str("target"), str(target); symlink = str("target"), str(target);

View file

@ -0,0 +1,96 @@
# Release 2.31.0 (2025-08-21)
- `build-cores = 0` now auto-detects CPU cores [#13402](https://github.com/NixOS/nix/pull/13402)
When `build-cores` is set to `0`, Nix now automatically detects the number of available CPU cores and passes this value via `NIX_BUILD_CORES`, instead of passing `0` directly. This matches the behavior when `build-cores` is unset. This prevents the builder from having to detect the number of cores.
- Fix Git LFS SSH issues [#13337](https://github.com/NixOS/nix/issues/13337) [#13743](https://github.com/NixOS/nix/pull/13743)
Fixed some outstanding issues with Git LFS and SSH.
* Added support for `NIX_SSHOPTS`.
* Properly use the parsed port from URL.
* Better use of the response of `git-lfs-authenticate` to determine API endpoint when the API is not exposed on port 443.
- Add support for `user@address:port` syntax in store URIs [#7044](https://github.com/NixOS/nix/issues/7044) [#3425](https://github.com/NixOS/nix/pull/3425)
It's now possible to specify the port used for SSH stores directly in the store URL in accordance with [RFC3986](https://datatracker.ietf.org/doc/html/rfc3986). Previously the only way to specify custom ports was via `ssh_config` or the `NIX_SSHOPTS` environment variable, because Nix incorrectly passed the port number together with the host name to the SSH executable.
This change affects [store references](@docroot@/store/types/index.md#store-url-format) passed via the `--store` and similar flags in CLI as well as in the configuration for [remote builders](@docroot@/command-ref/conf-file.md#conf-builders). For example, the following store URIs now work:
- `ssh://127.0.0.1:2222`
- `ssh://[b573:6a48:e224:840b:6007:6275:f8f7:ebf3]:22`
- `ssh-ng://[b573:6a48:e224:840b:6007:6275:f8f7:ebf3]:22`
- Represent IPv6 RFC4007 ZoneId literals in conformance with RFC6874 [#13445](https://github.com/NixOS/nix/pull/13445)
Prior versions of Nix since [#4646](https://github.com/NixOS/nix/pull/4646) accepted [IPv6 scoped addresses](https://datatracker.ietf.org/doc/html/rfc4007) in URIs like [store references](@docroot@/store/types/index.md#store-url-format) in the textual representation with a literal percent character: `[fe80::1%18]`. This was ambiguous, because the the percent literal `%` is reserved by [RFC3986](https://datatracker.ietf.org/doc/html/rfc3986), since it's used to indicate percent encoding. Nix now requires that the percent `%` symbol is percent-encoded as `%25`. This implements [RFC6874](https://datatracker.ietf.org/doc/html/rfc6874), which defines the representation of zone identifiers in URIs. The example from above now has to be specified as `[fe80::1%2518]`.
- Use WAL mode for SQLite cache databases [#13800](https://github.com/NixOS/nix/pull/13800)
Previously, Nix used SQLite's "truncate" mode for caches. However, this could cause a Nix process to block if another process was updating the cache. This was a problem for the flake evaluation cache in particular, since it uses long-running transactions. Thus, concurrent Nix commands operating on the same flake could be blocked for an unbounded amount of time. WAL mode avoids this problem.
This change required updating the versions of the SQLite caches. For instance, `eval-cache-v5.sqlite` is now `eval-cache-v6.sqlite`.
- Enable parallel marking in bdwgc [#13708](https://github.com/NixOS/nix/pull/13708)
Previously marking was done by only one thread, which takes a long time if the heap gets big. Enabling parallel marking speeds up evaluation a lot, for example (on a Ryzen 9 5900X 12-Core):
* `nix search nixpkgs` from 24.3s to 18.9s.
* Evaluating the `NixOS/nix/2.21.2` flake regression test from 86.1s to 71.2s.
- New command `nix flake prefetch-inputs` [#13565](https://github.com/NixOS/nix/pull/13565)
This command fetches all inputs of a flake in parallel. This can be a lot faster than the serialized on-demand fetching during regular flake evaluation. The downside is that it may fetch inputs that aren't normally used.
- Add `warn-short-path-literals` setting [#13489](https://github.com/NixOS/nix/pull/13489)
This setting, when enabled, causes Nix to emit warnings when encountering relative path literals that don't start with `.` or `/`, for instance suggesting that `foo/bar` should be rewritten to `./foo/bar`.
- When updating a lock, respect the input's lock file [#13437](https://github.com/NixOS/nix/pull/13437)
For example, if a flake has a lock for `a` and `a/b`, and we change the flakeref for `a`, previously Nix would fetch the latest version of `b` rather than using the lock for `b` from `a`.
- Implement support for Git hashing with SHA-256 [#13543](https://github.com/NixOS/nix/pull/13543)
The experimental support for [Git-hashing](@docroot@/development/experimental-features.md#xp-feature-git-hashing) store objects now also includes support for SHA-256, not just SHA-1, in line with upstream Git.
## Contributors
This release was made possible by the following 34 contributors:
- John Soo [**(@jsoo1)**](https://github.com/jsoo1)
- Alan Urmancheev [**(@alurm)**](https://github.com/alurm)
- Manse [**(@PedroManse)**](https://github.com/PedroManse)
- Pol Dellaiera [**(@drupol)**](https://github.com/drupol)
- DavHau [**(@DavHau)**](https://github.com/DavHau)
- Leandro Emmanuel Reina Kiperman [**(@kip93)**](https://github.com/kip93)
- h0nIg [**(@h0nIg)**](https://github.com/h0nIg)
- Philip Taron [**(@philiptaron)**](https://github.com/philiptaron)
- Eelco Dolstra [**(@edolstra)**](https://github.com/edolstra)
- Connor Baker [**(@ConnorBaker)**](https://github.com/ConnorBaker)
- kenji [**(@a-kenji)**](https://github.com/a-kenji)
- Oleksandr Knyshuk [**(@k1gen)**](https://github.com/k1gen)
- Maciej Krüger [**(@mkg20001)**](https://github.com/mkg20001)
- Justin Bailey [**(@jgbailey-well)**](https://github.com/jgbailey-well)
- Emily [**(@emilazy)**](https://github.com/emilazy)
- Volker Diels-Grabsch [**(@vog)**](https://github.com/vog)
- gustavderdrache [**(@gustavderdrache)**](https://github.com/gustavderdrache)
- Elliot Cameron [**(@de11n)**](https://github.com/de11n)
- Alexander V. Nikolaev [**(@avnik)**](https://github.com/avnik)
- tomberek [**(@tomberek)**](https://github.com/tomberek)
- Matthew Kenigsberg [**(@mkenigs)**](https://github.com/mkenigs)
- Sergei Zimmerman [**(@xokdvium)**](https://github.com/xokdvium)
- Cosima Neidahl [**(@OPNA2608)**](https://github.com/OPNA2608)
- John Ericson [**(@Ericson2314)**](https://github.com/Ericson2314)
- m4dc4p [**(@m4dc4p)**](https://github.com/m4dc4p)
- Graham Christensen [**(@grahamc)**](https://github.com/grahamc)
- Jason Yundt [**(@Jayman2000)**](https://github.com/Jayman2000)
- Jens Petersen [**(@juhp)**](https://github.com/juhp)
- the-sun-will-rise-tomorrow [**(@the-sun-will-rise-tomorrow)**](https://github.com/the-sun-will-rise-tomorrow)
- Farid Zakaria [**(@fzakaria)**](https://github.com/fzakaria)
- AGawas [**(@aln730)**](https://github.com/aln730)
- Robert Hensing [**(@roberth)**](https://github.com/roberth)
- Dmitry Bogatov [**(@KAction)**](https://github.com/KAction)
- Jörg Thalheim [**(@Mic92)**](https://github.com/Mic92)
- Philipp Otterbein

View file

@ -48,6 +48,6 @@
* `nix run` is now stricter in what it accepts: members of the `apps` * `nix run` is now stricter in what it accepts: members of the `apps`
flake output are now required to be apps (as defined in [the flake output are now required to be apps (as defined in [the
manual](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-run.html#apps)), manual](https://nix.dev/manual/nix/stable/command-ref/new-cli/nix3-run.html#apps)),
and members of `packages` or `legacyPackages` must be derivations and members of `packages` or `legacyPackages` must be derivations
(not apps). (not apps).

View file

@ -9,7 +9,7 @@ This is where Nix distinguishes itself.
## Store Derivation {#store-derivation} ## Store Derivation {#store-derivation}
A derivation is a specification for running an executable on precisely defined input to produce on more [store objects][store object]. A derivation is a specification for running an executable on precisely defined input to produce one or more [store objects][store object].
These store objects are known as the derivation's *outputs*. These store objects are known as the derivation's *outputs*.
Derivations are *built*, in which case the process is spawned according to the spec, and when it exits, required to leave behind files which will (after post-processing) become the outputs of the derivation. Derivations are *built*, in which case the process is spawned according to the spec, and when it exits, required to leave behind files which will (after post-processing) become the outputs of the derivation.

View file

@ -1,12 +1,6 @@
types_dir = custom_target( types_dir = custom_target(
command : [ command : [ python.full_path(), '@INPUT0@', '@OUTPUT@', '--' ] + nix_eval_for_docs + [
python.full_path(), '--expr', 'import @INPUT1@ (builtins.fromJSON (builtins.readFile ./@INPUT2@)).stores',
'@INPUT0@',
'@OUTPUT@',
'--'
] + nix_eval_for_docs + [
'--expr',
'import @INPUT1@ (builtins.fromJSON (builtins.readFile ./@INPUT2@)).stores',
], ],
input : [ input : [
'../../remove_before_wrapper.py', '../../remove_before_wrapper.py',

View file

@ -20,7 +20,8 @@ The graph of references excluding self-references thus forms a [directed acyclic
[directed acyclic graph]: @docroot@/glossary.md#gloss-directed-acyclic-graph [directed acyclic graph]: @docroot@/glossary.md#gloss-directed-acyclic-graph
We can take the [transitive closure] of the references graph, which any pair of store objects have an edge not if there is a single reference from the first to the second, but a path of one or more references from the first to the second. We can take the [transitive closure] of the references graph, in which any pair of store objects have an edge if a *path* of one or more references exists from the first to the second object.
(A single reference always forms a path which is one reference long, but longer paths may connect objects which have no direct reference between them.)
The *requisites* of a store object are all store objects reachable by paths of references which start with given store object's references. The *requisites* of a store object are all store objects reachable by paths of references which start with given store object's references.
[transitive closure]: https://en.wikipedia.org/wiki/Transitive_closure [transitive closure]: https://en.wikipedia.org/wiki/Transitive_closure

View file

@ -1,10 +1,10 @@
{ {
# Core dependencies # Core dependencies
pkgs, pkgs ? import <nixpkgs> { },
lib, lib ? pkgs.lib,
dockerTools, dockerTools ? pkgs.dockerTools,
runCommand, runCommand ? pkgs.runCommand,
buildPackages, buildPackages ? pkgs.buildPackages,
# Image configuration # Image configuration
name ? "nix", name ? "nix",
tag ? "latest", tag ? "latest",
@ -28,24 +28,24 @@
}, },
Cmd ? [ (lib.getExe bashInteractive) ], Cmd ? [ (lib.getExe bashInteractive) ],
# Default Packages # Default Packages
nix, nix ? pkgs.nix,
bashInteractive, bashInteractive ? pkgs.bashInteractive,
coreutils-full, coreutils-full ? pkgs.coreutils-full,
gnutar, gnutar ? pkgs.gnutar,
gzip, gzip ? pkgs.gzip,
gnugrep, gnugrep ? pkgs.gnugrep,
which, which ? pkgs.which,
curl, curl ? pkgs.curl,
less, less ? pkgs.less,
wget, wget ? pkgs.wget,
man, man ? pkgs.man,
cacert, cacert ? pkgs.cacert,
findutils, findutils ? pkgs.findutils,
iana-etc, iana-etc ? pkgs.iana-etc,
gitMinimal, gitMinimal ? pkgs.gitMinimal,
openssh, openssh ? pkgs.openssh,
# Other dependencies # Other dependencies
shadow, shadow ? pkgs.shadow,
}: }:
let let
defaultPkgs = [ defaultPkgs = [
@ -65,62 +65,61 @@ let
iana-etc iana-etc
gitMinimal gitMinimal
openssh openssh
] ++ extraPkgs; ]
++ extraPkgs;
users = users = {
{
root = { root = {
uid = 0; uid = 0;
shell = lib.getExe bashInteractive; shell = lib.getExe bashInteractive;
home = "/root"; home = "/root";
gid = 0; gid = 0;
groups = [ "root" ]; groups = [ "root" ];
description = "System administrator"; description = "System administrator";
};
nobody = {
uid = 65534;
shell = lib.getExe' shadow "nologin";
home = "/var/empty";
gid = 65534;
groups = [ "nobody" ];
description = "Unprivileged account (don't use!)";
};
}
// lib.optionalAttrs (uid != 0) {
"${uname}" = {
uid = uid;
shell = lib.getExe bashInteractive;
home = "/home/${uname}";
gid = gid;
groups = [ "${gname}" ];
description = "Nix user";
};
}
// lib.listToAttrs (
map (n: {
name = "nixbld${toString n}";
value = {
uid = 30000 + n;
gid = 30000;
groups = [ "nixbld" ];
description = "Nix build user ${toString n}";
};
}) (lib.lists.range 1 32)
);
groups =
{
root.gid = 0;
nixbld.gid = 30000;
nobody.gid = 65534;
}
// lib.optionalAttrs (gid != 0) {
"${gname}".gid = gid;
}; };
nobody = {
uid = 65534;
shell = lib.getExe' shadow "nologin";
home = "/var/empty";
gid = 65534;
groups = [ "nobody" ];
description = "Unprivileged account (don't use!)";
};
}
// lib.optionalAttrs (uid != 0) {
"${uname}" = {
uid = uid;
shell = lib.getExe bashInteractive;
home = "/home/${uname}";
gid = gid;
groups = [ "${gname}" ];
description = "Nix user";
};
}
// lib.listToAttrs (
map (n: {
name = "nixbld${toString n}";
value = {
uid = 30000 + n;
gid = 30000;
groups = [ "nixbld" ];
description = "Nix build user ${toString n}";
};
}) (lib.lists.range 1 32)
);
groups = {
root.gid = 0;
nixbld.gid = 30000;
nobody.gid = 65534;
}
// lib.optionalAttrs (gid != 0) {
"${gname}".gid = gid;
};
userToPasswd = ( userToPasswd = (
k: k:
{ {
@ -184,11 +183,14 @@ let
} " = "; } " = ";
}; };
nixConfContents = toConf { nixConfContents = toConf (
sandbox = false; {
build-users-group = "nixbld"; sandbox = false;
trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ]; build-users-group = "nixbld";
}; trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ];
}
// nixConf
);
userHome = if uid == 0 then "/root" else "/home/${uname}"; userHome = if uid == 0 then "/root" else "/home/${uname}";
@ -279,7 +281,10 @@ let
# may get replaced by pkgs.dockerTools.caCertificates # may get replaced by pkgs.dockerTools.caCertificates
mkdir -p $out/etc/ssl/certs mkdir -p $out/etc/ssl/certs
# Old NixOS compatibility.
ln -s /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt $out/etc/ssl/certs ln -s /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt $out/etc/ssl/certs
# NixOS canonical location
ln -s /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt $out/etc/ssl/certs/ca-certificates.crt
cat $passwdContentsPath > $out/etc/passwd cat $passwdContentsPath > $out/etc/passwd
echo "" >> $out/etc/passwd echo "" >> $out/etc/passwd
@ -308,6 +313,7 @@ let
# see doc/manual/source/command-ref/files/profiles.md # see doc/manual/source/command-ref/files/profiles.md
ln -s ${profile} $out/nix/var/nix/profiles/default-1-link ln -s ${profile} $out/nix/var/nix/profiles/default-1-link
ln -s /nix/var/nix/profiles/default-1-link $out/nix/var/nix/profiles/default ln -s /nix/var/nix/profiles/default-1-link $out/nix/var/nix/profiles/default
ln -s /nix/var/nix/profiles/default $out${userHome}/.nix-profile
# see doc/manual/source/command-ref/files/channels.md # see doc/manual/source/command-ref/files/channels.md
ln -s ${channel} $out/nix/var/nix/profiles/per-user/${uname}/channels-1-link ln -s ${channel} $out/nix/var/nix/profiles/per-user/${uname}/channels-1-link

8
flake.lock generated
View file

@ -63,16 +63,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1747179050, "lastModified": 1756178832,
"narHash": "sha256-qhFMmDkeJX9KJwr5H32f1r7Prs7XbQWtO0h3V0a0rFY=", "narHash": "sha256-O2CIn7HjZwEGqBrwu9EU76zlmA5dbmna7jL1XUmAId8=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "adaa24fbf46737f3f1b5497bf64bae750f82942e", "rev": "d98ce345cdab58477ca61855540999c86577d19d",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-unstable", "ref": "nixos-25.05-small",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }

318
flake.nix
View file

@ -1,7 +1,7 @@
{ {
description = "The purely functional package manager"; description = "The purely functional package manager";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05-small";
inputs.nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2"; inputs.nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2";
inputs.nixpkgs-23-11.url = "github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446"; inputs.nixpkgs-23-11.url = "github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446";
@ -131,31 +131,107 @@
} }
); );
overlayFor = /**
getStdenv: final: prev: Produce the `nixComponents` and `nixDependencies` package sets (scopes) for
a given `pkgs` and `getStdenv`.
*/
packageSetsFor =
let let
stdenv = getStdenv final; /**
Removes a prefix from the attribute names of a set of splices.
This is a completely uninteresting and exists for compatibility only.
Example:
```nix
renameSplicesFrom "pkgs" { pkgsBuildBuild = ...; ... }
=> { buildBuild = ...; ... }
```
*/
renameSplicesFrom = prefix: x: {
buildBuild = x."${prefix}BuildBuild";
buildHost = x."${prefix}BuildHost";
buildTarget = x."${prefix}BuildTarget";
hostHost = x."${prefix}HostHost";
hostTarget = x."${prefix}HostTarget";
targetTarget = x."${prefix}TargetTarget";
};
/**
Adds a prefix to the attribute names of a set of splices.
This is a completely uninteresting and exists for compatibility only.
Example:
```nix
renameSplicesTo "self" { buildBuild = ...; ... }
=> { selfBuildBuild = ...; ... }
```
*/
renameSplicesTo = prefix: x: {
"${prefix}BuildBuild" = x.buildBuild;
"${prefix}BuildHost" = x.buildHost;
"${prefix}BuildTarget" = x.buildTarget;
"${prefix}HostHost" = x.hostHost;
"${prefix}HostTarget" = x.hostTarget;
"${prefix}TargetTarget" = x.targetTarget;
};
/**
Takes a function `f` and returns a function that applies `f` pointwise to each splice.
Example:
```nix
mapSplices (x: x * 10) { buildBuild = 1; buildHost = 2; ... }
=> { buildBuild = 10; buildHost = 20; ... }
```
*/
mapSplices =
f:
{
buildBuild,
buildHost,
buildTarget,
hostHost,
hostTarget,
targetTarget,
}:
{
buildBuild = f buildBuild;
buildHost = f buildHost;
buildTarget = f buildTarget;
hostHost = f hostHost;
hostTarget = f hostTarget;
targetTarget = f targetTarget;
};
in in
{ args@{
nixStable = prev.nix; pkgs,
getStdenv ? pkgs: pkgs.stdenv,
}:
let
nixComponentsSplices = mapSplices (
pkgs': (packageSetsFor (args // { pkgs = pkgs'; })).nixComponents
) (renameSplicesFrom "pkgs" pkgs);
nixDependenciesSplices = mapSplices (
pkgs': (packageSetsFor (args // { pkgs = pkgs'; })).nixDependencies
) (renameSplicesFrom "pkgs" pkgs);
# A new scope, so that we can use `callPackage` to inject our own interdependencies # A new scope, so that we can use `callPackage` to inject our own interdependencies
# without "polluting" the top level "`pkgs`" attrset. # without "polluting" the top level "`pkgs`" attrset.
# This also has the benefit of providing us with a distinct set of packages # This also has the benefit of providing us with a distinct set of packages
# we can iterate over. # we can iterate over.
# The `2` suffix is here because otherwise it interferes with `nixVersions.latest`, which is used in daemon compat tests. nixComponents =
nixComponents2 =
lib.makeScopeWithSplicing' lib.makeScopeWithSplicing'
{ {
inherit (final) splicePackages; inherit (pkgs) splicePackages;
inherit (final.nixDependencies2) newScope; inherit (nixDependencies) newScope;
} }
{ {
otherSplices = final.generateSplicesForMkScope "nixComponents2"; otherSplices = renameSplicesTo "self" nixComponentsSplices;
f = import ./packaging/components.nix { f = import ./packaging/components.nix {
inherit (final) lib; inherit (pkgs) lib;
inherit officialRelease; inherit officialRelease;
pkgs = final; inherit pkgs;
src = self; src = self;
maintainers = [ ]; maintainers = [ ];
}; };
@ -163,29 +239,71 @@
# The dependencies are in their own scope, so that they don't have to be # The dependencies are in their own scope, so that they don't have to be
# in Nixpkgs top level `pkgs` or `nixComponents2`. # in Nixpkgs top level `pkgs` or `nixComponents2`.
# The `2` suffix is here because otherwise it interferes with `nixVersions.latest`, which is used in daemon compat tests. nixDependencies =
nixDependencies2 =
lib.makeScopeWithSplicing' lib.makeScopeWithSplicing'
{ {
inherit (final) splicePackages; inherit (pkgs) splicePackages;
inherit (final) newScope; # layered directly on pkgs, unlike nixComponents2 above inherit (pkgs) newScope; # layered directly on pkgs, unlike nixComponents2 above
} }
{ {
otherSplices = final.generateSplicesForMkScope "nixDependencies2"; otherSplices = renameSplicesTo "self" nixDependenciesSplices;
f = import ./packaging/dependencies.nix { f = import ./packaging/dependencies.nix {
inherit inputs stdenv; inherit inputs pkgs;
pkgs = final; stdenv = getStdenv pkgs;
}; };
}; };
# If the package set is largely empty, we should(?) return empty sets
# This is what most package sets in Nixpkgs do. Otherwise, we get
# an error message that indicates that some stdenv attribute is missing,
# and indeed it will be missing, as seemingly `pkgsTargetTarget` is
# very incomplete.
fixup = lib.mapAttrs (k: v: if !(pkgs ? nix) then { } else v);
in
fixup {
inherit nixDependencies;
inherit nixComponents;
};
overlayFor =
getStdenv: final: prev:
let
packageSets = packageSetsFor {
inherit getStdenv;
pkgs = final;
};
in
{
nixStable = prev.nix;
# The `2` suffix is here because otherwise it interferes with `nixVersions.latest`, which is used in daemon compat tests.
nixComponents2 = packageSets.nixComponents;
# The dependencies are in their own scope, so that they don't have to be
# in Nixpkgs top level `pkgs` or `nixComponents2`.
# The `2` suffix is here because otherwise it interferes with `nixVersions.latest`, which is used in daemon compat tests.
nixDependencies2 = packageSets.nixDependencies;
nix = final.nixComponents2.nix-cli; nix = final.nixComponents2.nix-cli;
}; };
in in
{ {
# A Nixpkgs overlay that overrides the 'nix' and overlays.internal = overlayFor (p: p.stdenv);
# 'nix-perl-bindings' packages.
overlays.default = overlayFor (p: p.stdenv); /**
A Nixpkgs overlay that sets `nix` to something like `packages.<system>.nix-everything`,
except dependencies aren't taken from (flake) `nix.inputs.nixpkgs`, but from the Nixpkgs packages
where the overlay is used.
*/
overlays.default =
final: prev:
let
packageSets = packageSetsFor { pkgs = final; };
in
{
nix = packageSets.nixComponents.nix-everything;
};
hydraJobs = import ./packaging/hydra.nix { hydraJobs = import ./packaging/hydra.nix {
inherit inherit
@ -202,43 +320,11 @@
checks = forAllSystems ( checks = forAllSystems (
system: system:
{ (import ./ci/gha/tests {
installerScriptForGHA = self.hydraJobs.installerScriptForGHA.${system}; inherit system;
installTests = self.hydraJobs.installTests.${system}; pkgs = nixpkgsFor.${system}.native;
nixpkgsLibTests = self.hydraJobs.tests.nixpkgsLibTests.${system}; nixFlake = self;
rl-next = }).topLevel
let
pkgs = nixpkgsFor.${system}.native;
in
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 = nixpkgsFor.${system}.native.callPackage ./tests/repl-completion.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
pkgs = nixpkgsFor.${system}.native;
nix = self.packages.${system}.nix;
in
assert (nix.appendPatches [ pkgs.emptyFile ]).libs.nix-util.src.patches == [ pkgs.emptyFile ];
if pkgs.stdenv.buildPlatform.isDarwin then
lib.warn "packaging-overriding check currently disabled because of a permissions issue on macOS" pkgs.emptyFile
else
# If this fails, something might be wrong with how we've wired the scope,
# or something could be broken in Nixpkgs.
pkgs.testers.testEqualContents {
assertion = "trivial patch does not change source contents";
expected = "${./.}";
actual =
# Same for all components; nix-util is an arbitrary pick
(nix.appendPatches [ pkgs.emptyFile ]).libs.nix-util.src;
};
}
// (lib.optionalAttrs (builtins.elem system linux64BitSystems)) { // (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
dockerImage = self.hydraJobs.dockerImage.${system}; dockerImage = self.hydraJobs.dockerImage.${system};
} }
@ -251,58 +337,20 @@
# Add "passthru" tests # Add "passthru" tests
// //
flatMapAttrs flatMapAttrs
{
"" = {
pkgs = nixpkgsFor.${system}.native;
};
}
( (
{ nixpkgsPrefix: args:
# Run all tests with UBSAN enabled. Running both with ubsan and (import ./ci/gha/tests (
# without doesn't seem to have much immediate benefit for doubling args
# the GHA CI workaround. // {
# nixFlake = self;
# TODO: Work toward enabling "address,undefined" if it seems feasible. componentTestsPrefix = nixpkgsPrefix;
# This would maybe require dropping Boost coroutines and ignoring intentional }
# memory leaks with detect_leaks=0. )).componentTests
"" = rec {
nixpkgs = nixpkgsFor.${system}.native;
nixComponents = nixpkgs.nixComponents2.overrideScope (
nixCompFinal: nixCompPrev: {
mesonComponentOverrides = _finalAttrs: prevAttrs: {
mesonFlags =
(prevAttrs.mesonFlags or [ ])
# TODO: Macos builds instrumented with ubsan take very long
# to run functional tests.
++ lib.optionals (!nixpkgs.stdenv.hostPlatform.isDarwin) [
(lib.mesonOption "b_sanitize" "undefined")
];
};
}
);
};
}
// lib.optionalAttrs (!nixpkgsFor.${system}.native.stdenv.hostPlatform.isDarwin) {
# TODO: enable static builds for darwin, blocked on:
# https://github.com/NixOS/nixpkgs/issues/320448
# TODO: disabled to speed up GHA CI.
# "static-" = {
# nixpkgs = nixpkgsFor.${system}.native.pkgsStatic;
# };
}
)
(
nixpkgsPrefix:
{
nixpkgs,
nixComponents ? nixpkgs.nixComponents2,
}:
flatMapAttrs nixComponents (
pkgName: pkg:
flatMapAttrs pkg.tests or { } (
testName: test: {
"${nixpkgsPrefix}${pkgName}-${testName}" = test;
}
)
)
// lib.optionalAttrs (nixpkgs.stdenv.hostPlatform == nixpkgs.stdenv.buildPlatform) {
"${nixpkgsPrefix}nix-functional-tests" = nixComponents.nix-functional-tests;
}
) )
// devFlake.checks.${system} or { } // devFlake.checks.${system} or { }
); );
@ -465,5 +513,53 @@
default = self.devShells.${system}.native; default = self.devShells.${system}.native;
} }
); );
lib = {
/**
Creates a package set for a given Nixpkgs instance and stdenv.
# Inputs
- `pkgs`: The Nixpkgs instance to use.
- `getStdenv`: _Optional_ A function that takes a package set and returns the stdenv to use.
This needs to be a function in order to support cross compilation - the `pkgs` passed to `getStdenv` can be `pkgsBuildHost` or any other variation needed.
# Outputs
The return value is a fresh Nixpkgs scope containing all the packages that are defined in the Nix repository,
as well as some internals and parameters, which may be subject to change.
# Example
```console
nix repl> :lf NixOS/nix
nix-repl> ps = lib.makeComponents { pkgs = import inputs.nixpkgs { crossSystem = "riscv64-linux"; }; }
nix-repl> ps
{
appendPatches = «lambda appendPatches @ ...»;
callPackage = «lambda callPackageWith @ ...»;
overrideAllMesonComponents = «lambda overrideSource @ ...»;
overrideSource = «lambda overrideSource @ ...»;
# ...
nix-everything
# ...
nix-store
nix-store-c
# ...
}
```
*/
makeComponents =
{
pkgs,
getStdenv ? pkgs: pkgs.stdenv,
}:
let
packageSets = packageSetsFor { inherit getStdenv pkgs; };
in
packageSets.nixComponents;
};
}; };
} }

View file

@ -46,7 +46,7 @@ The team meets twice a week (times are denoted in the [Europe/Amsterdam](https:/
- mark it as draft if it is blocked on the contributor - mark it as draft if it is blocked on the contributor
- escalate it back to the team by moving it to To discuss, and leaving a comment as to why the issue needs to be discussed again. - escalate it back to the team by moving it to To discuss, and leaving a comment as to why the issue needs to be discussed again.
- Work meeting: Mondays 14:00-16:00 Europe/Amsterdam see [calendar](https://calendar.google.com/calendar/u/0/embed?src=b9o52fobqjak8oq8lfkhg3t0qg@group.calendar.google.com). - Work meeting: Mondays 18:00-20:00 Europe/Amsterdam; see [calendar](https://calendar.google.com/calendar/u/0/embed?src=b9o52fobqjak8oq8lfkhg3t0qg@group.calendar.google.com).
1. Code review on pull requests from [In review](#in-review). 1. Code review on pull requests from [In review](#in-review).
2. Other chores and tasks. 2. Other chores and tasks.

View file

@ -185,5 +185,23 @@
"gwenn.lebihan7@gmail.com": "gwennlbh", "gwenn.lebihan7@gmail.com": "gwennlbh",
"hey@ewen.works": "gwennlbh", "hey@ewen.works": "gwennlbh",
"matt@sturgeon.me.uk": "MattSturgeon", "matt@sturgeon.me.uk": "MattSturgeon",
"pbsds@hotmail.com": "pbsds" "pbsds@hotmail.com": "pbsds",
"sergei@zimmerman.foo": "xokdvium",
"v@njh.eu": "vog",
"pedro.manse@dmk3.com.br": "PedroManse",
"arnavgawas707@gmail.com": "aln730",
"mkg20001@gmail.com": "mkg20001",
"avn@avnik.info": "avnik",
"olk@disr.it": "k1gen",
"108410815+alurm@users.noreply.github.com": "alurm",
"kaction.cc@gmail.com": "KAction",
"juhpetersen@gmail.com": "juhp",
"opna2608@protonmail.com": "OPNA2608",
"jgbailey@gmail.com": "m4dc4p",
"justin.bailey@well.co": "jgbailey-well",
"130508846+de11n@users.noreply.github.com": "de11n",
"ConnorBaker01@Gmail.com": "ConnorBaker",
"jsoo1@asu.edu": "jsoo1",
"hsngrmpf+github@gmail.com": "DavHau",
"matthew@floxdev.com": "mkenigs"
} }

View file

@ -162,5 +162,20 @@
"pbsds": "Peder Bergebakken Sundt", "pbsds": "Peder Bergebakken Sundt",
"egorkonovalov": "Egor Konovalov", "egorkonovalov": "Egor Konovalov",
"jayeshv": "jayeshv", "jayeshv": "jayeshv",
"vcunat": "Vladim\u00edr \u010cun\u00e1t" "vcunat": "Vladim\u00edr \u010cun\u00e1t",
"mkenigs": "Matthew Kenigsberg",
"alurm": "Alan Urmancheev",
"jgbailey-well": "Justin Bailey",
"k1gen": "Oleksandr Knyshuk",
"juhp": "Jens Petersen",
"de11n": "Elliot Cameron",
"jsoo1": "John Soo",
"m4dc4p": null,
"PedroManse": "Manse",
"OPNA2608": "Cosima Neidahl",
"mkg20001": "Maciej Kr\u00fcger",
"avnik": "Alexander V. Nikolaev",
"DavHau": null,
"aln730": "AGawas",
"vog": "Volker Diels-Grabsch"
} }

View file

@ -37,118 +37,29 @@
fi fi
''}"; ''}";
}; };
meson-format = { meson-format =
enable = true; let
files = "(meson.build|meson.options)$"; meson = pkgs.meson.overrideAttrs {
entry = "${pkgs.writeScript "format-meson" '' doCheck = false;
#!${pkgs.runtimeShell} doInstallCheck = false;
for file in "$@"; do patches = [
${lib.getExe pkgs.meson} format -ic ${../meson.format} "$file" (pkgs.fetchpatch {
done url = "https://github.com/mesonbuild/meson/commit/38d29b4dd19698d5cad7b599add2a69b243fd88a.patch";
''}"; hash = "sha256-PgPBvGtCISKn1qQQhzBW5XfknUe91i5XGGBcaUK4yeE=";
excludes = [ })
# We haven't applied formatting to these files yet ];
''^doc/manual/meson.build$'' };
''^doc/manual/source/command-ref/meson.build$'' in
''^doc/manual/source/development/meson.build$'' {
''^doc/manual/source/language/meson.build$'' enable = true;
''^doc/manual/source/meson.build$'' files = "(meson.build|meson.options)$";
''^doc/manual/source/release-notes/meson.build$'' entry = "${pkgs.writeScript "format-meson" ''
''^doc/manual/source/store/meson.build$'' #!${pkgs.runtimeShell}
''^misc/bash/meson.build$'' for file in "$@"; do
''^misc/fish/meson.build$'' ${lib.getExe meson} format -ic ${../meson.format} "$file"
''^misc/launchd/meson.build$'' done
''^misc/meson.build$'' ''}";
''^misc/systemd/meson.build$'' };
''^misc/zsh/meson.build$''
''^nix-meson-build-support/$''
''^nix-meson-build-support/big-objs/meson.build$''
''^nix-meson-build-support/common/meson.build$''
''^nix-meson-build-support/deps-lists/meson.build$''
''^nix-meson-build-support/export/meson.build$''
''^nix-meson-build-support/export-all-symbols/meson.build$''
''^nix-meson-build-support/generate-header/meson.build$''
''^nix-meson-build-support/libatomic/meson.build$''
''^nix-meson-build-support/subprojects/meson.build$''
''^scripts/meson.build$''
''^src/external-api-docs/meson.build$''
''^src/internal-api-docs/meson.build$''
''^src/libcmd/include/nix/cmd/meson.build$''
''^src/libcmd/meson.build$''
''^src/libcmd/nix-meson-build-support$''
''^src/libexpr/include/nix/expr/meson.build$''
''^src/libexpr/meson.build$''
''^src/libexpr/nix-meson-build-support$''
''^src/libexpr-c/meson.build$''
''^src/libexpr-c/nix-meson-build-support$''
''^src/libexpr-test-support/meson.build$''
''^src/libexpr-test-support/nix-meson-build-support$''
''^src/libexpr-tests/meson.build$''
''^src/libexpr-tests/nix-meson-build-support$''
''^src/libfetchers/include/nix/fetchers/meson.build$''
''^src/libfetchers/meson.build$''
''^src/libfetchers/nix-meson-build-support$''
''^src/libfetchers-c/meson.build$''
''^src/libfetchers-c/nix-meson-build-support$''
''^src/libfetchers-tests/meson.build$''
''^src/libfetchers-tests/nix-meson-build-support$''
''^src/libflake/include/nix/flake/meson.build$''
''^src/libflake/meson.build$''
''^src/libflake/nix-meson-build-support$''
''^src/libflake-c/meson.build$''
''^src/libflake-c/nix-meson-build-support$''
''^src/libflake-tests/meson.build$''
''^src/libflake-tests/nix-meson-build-support$''
''^src/libmain/include/nix/main/meson.build$''
''^src/libmain/meson.build$''
''^src/libmain/nix-meson-build-support$''
''^src/libmain-c/meson.build$''
''^src/libmain-c/nix-meson-build-support$''
''^src/libstore/include/nix/store/meson.build$''
''^src/libstore/meson.build$''
''^src/libstore/nix-meson-build-support$''
''^src/libstore/unix/include/nix/store/meson.build$''
''^src/libstore/unix/meson.build$''
''^src/libstore/windows/meson.build$''
''^src/libstore-c/meson.build$''
''^src/libstore-c/nix-meson-build-support$''
''^src/libstore-test-support/include/nix/store/tests/meson.build$''
''^src/libstore-test-support/meson.build$''
''^src/libstore-test-support/nix-meson-build-support$''
''^src/libstore-tests/meson.build$''
''^src/libstore-tests/nix-meson-build-support$''
''^src/libutil/meson.build$''
''^src/libutil/nix-meson-build-support$''
''^src/libutil/unix/include/nix/util/meson.build$''
''^src/libutil/unix/meson.build$''
''^src/libutil/windows/meson.build$''
''^src/libutil-c/meson.build$''
''^src/libutil-c/nix-meson-build-support$''
''^src/libutil-test-support/include/nix/util/tests/meson.build$''
''^src/libutil-test-support/meson.build$''
''^src/libutil-test-support/nix-meson-build-support$''
''^src/libutil-tests/meson.build$''
''^src/libutil-tests/nix-meson-build-support$''
''^src/nix/meson.build$''
''^src/nix/nix-meson-build-support$''
''^src/perl/lib/Nix/meson.build$''
''^src/perl/meson.build$''
''^tests/functional/ca/meson.build$''
''^tests/functional/common/meson.build$''
''^tests/functional/dyn-drv/meson.build$''
''^tests/functional/flakes/meson.build$''
''^tests/functional/git-hashing/meson.build$''
''^tests/functional/local-overlay-store/meson.build$''
''^tests/functional/meson.build$''
''^src/libcmd/meson.options$''
''^src/libexpr/meson.options$''
''^src/libstore/meson.options$''
''^src/libutil/meson.options$''
''^src/libutil-c/meson.options$''
''^src/nix/meson.options$''
''^src/perl/meson.options$''
];
};
nixfmt-rfc-style = { nixfmt-rfc-style = {
enable = true; enable = true;
excludes = [ excludes = [
@ -189,467 +100,6 @@
# Don't format vendored code # Don't format vendored code
''^doc/manual/redirects\.js$'' ''^doc/manual/redirects\.js$''
''^doc/manual/theme/highlight\.js$'' ''^doc/manual/theme/highlight\.js$''
# We haven't applied formatting to these files yet
''^doc/manual/redirects\.js$''
''^doc/manual/theme/highlight\.js$''
''^src/build-remote/build-remote\.cc$''
''^src/libcmd/built-path\.cc$''
''^src/libcmd/include/nix/cmd/built-path\.hh$''
''^src/libcmd/common-eval-args\.cc$''
''^src/libcmd/include/nix/cmd/common-eval-args\.hh$''
''^src/libcmd/editor-for\.cc$''
''^src/libcmd/installable-attr-path\.cc$''
''^src/libcmd/include/nix/cmd/installable-attr-path\.hh$''
''^src/libcmd/installable-derived-path\.cc$''
''^src/libcmd/include/nix/cmd/installable-derived-path\.hh$''
''^src/libcmd/installable-flake\.cc$''
''^src/libcmd/include/nix/cmd/installable-flake\.hh$''
''^src/libcmd/installable-value\.cc$''
''^src/libcmd/include/nix/cmd/installable-value\.hh$''
''^src/libcmd/installables\.cc$''
''^src/libcmd/include/nix/cmd/installables\.hh$''
''^src/libcmd/include/nix/cmd/legacy\.hh$''
''^src/libcmd/markdown\.cc$''
''^src/libcmd/misc-store-flags\.cc$''
''^src/libcmd/repl-interacter\.cc$''
''^src/libcmd/include/nix/cmd/repl-interacter\.hh$''
''^src/libcmd/repl\.cc$''
''^src/libcmd/include/nix/cmd/repl\.hh$''
''^src/libexpr-c/nix_api_expr\.cc$''
''^src/libexpr-c/nix_api_external\.cc$''
''^src/libexpr/attr-path\.cc$''
''^src/libexpr/include/nix/expr/attr-path\.hh$''
''^src/libexpr/attr-set\.cc$''
''^src/libexpr/include/nix/expr/attr-set\.hh$''
''^src/libexpr/eval-cache\.cc$''
''^src/libexpr/include/nix/expr/eval-cache\.hh$''
''^src/libexpr/eval-error\.cc$''
''^src/libexpr/include/nix/expr/eval-inline\.hh$''
''^src/libexpr/eval-settings\.cc$''
''^src/libexpr/include/nix/expr/eval-settings\.hh$''
''^src/libexpr/eval\.cc$''
''^src/libexpr/include/nix/expr/eval\.hh$''
''^src/libexpr/function-trace\.cc$''
''^src/libexpr/include/nix/expr/gc-small-vector\.hh$''
''^src/libexpr/get-drvs\.cc$''
''^src/libexpr/include/nix/expr/get-drvs\.hh$''
''^src/libexpr/json-to-value\.cc$''
''^src/libexpr/nixexpr\.cc$''
''^src/libexpr/include/nix/expr/nixexpr\.hh$''
''^src/libexpr/include/nix/expr/parser-state\.hh$''
''^src/libexpr/primops\.cc$''
''^src/libexpr/include/nix/expr/primops\.hh$''
''^src/libexpr/primops/context\.cc$''
''^src/libexpr/primops/fetchClosure\.cc$''
''^src/libexpr/primops/fetchMercurial\.cc$''
''^src/libexpr/primops/fetchTree\.cc$''
''^src/libexpr/primops/fromTOML\.cc$''
''^src/libexpr/print-ambiguous\.cc$''
''^src/libexpr/include/nix/expr/print-ambiguous\.hh$''
''^src/libexpr/include/nix/expr/print-options\.hh$''
''^src/libexpr/print\.cc$''
''^src/libexpr/include/nix/expr/print\.hh$''
''^src/libexpr/search-path\.cc$''
''^src/libexpr/include/nix/expr/symbol-table\.hh$''
''^src/libexpr/value-to-json\.cc$''
''^src/libexpr/include/nix/expr/value-to-json\.hh$''
''^src/libexpr/value-to-xml\.cc$''
''^src/libexpr/include/nix/expr/value-to-xml\.hh$''
''^src/libexpr/value/context\.cc$''
''^src/libexpr/include/nix/expr/value/context\.hh$''
''^src/libfetchers/attrs\.cc$''
''^src/libfetchers/cache\.cc$''
''^src/libfetchers/include/nix/fetchers/cache\.hh$''
''^src/libfetchers/fetch-settings\.cc$''
''^src/libfetchers/include/nix/fetchers/fetch-settings\.hh$''
''^src/libfetchers/fetch-to-store\.cc$''
''^src/libfetchers/fetchers\.cc$''
''^src/libfetchers/include/nix/fetchers/fetchers\.hh$''
''^src/libfetchers/filtering-source-accessor\.cc$''
''^src/libfetchers/include/nix/fetchers/filtering-source-accessor\.hh$''
''^src/libfetchers/fs-source-accessor\.cc$''
''^src/libfetchers/include/nix/fs-source-accessor\.hh$''
''^src/libfetchers/git-utils\.cc$''
''^src/libfetchers/include/nix/fetchers/git-utils\.hh$''
''^src/libfetchers/github\.cc$''
''^src/libfetchers/indirect\.cc$''
''^src/libfetchers/memory-source-accessor\.cc$''
''^src/libfetchers/path\.cc$''
''^src/libfetchers/registry\.cc$''
''^src/libfetchers/include/nix/fetchers/registry\.hh$''
''^src/libfetchers/tarball\.cc$''
''^src/libfetchers/include/nix/fetchers/tarball\.hh$''
''^src/libfetchers/git\.cc$''
''^src/libfetchers/mercurial\.cc$''
''^src/libflake/config\.cc$''
''^src/libflake/flake\.cc$''
''^src/libflake/include/nix/flake/flake\.hh$''
''^src/libflake/flakeref\.cc$''
''^src/libflake/include/nix/flake/flakeref\.hh$''
''^src/libflake/lockfile\.cc$''
''^src/libflake/include/nix/flake/lockfile\.hh$''
''^src/libflake/url-name\.cc$''
''^src/libmain/common-args\.cc$''
''^src/libmain/include/nix/main/common-args\.hh$''
''^src/libmain/loggers\.cc$''
''^src/libmain/include/nix/main/loggers\.hh$''
''^src/libmain/progress-bar\.cc$''
''^src/libmain/shared\.cc$''
''^src/libmain/include/nix/main/shared\.hh$''
''^src/libmain/unix/stack\.cc$''
''^src/libstore/binary-cache-store\.cc$''
''^src/libstore/include/nix/store/binary-cache-store\.hh$''
''^src/libstore/include/nix/store/build-result\.hh$''
''^src/libstore/include/nix/store/builtins\.hh$''
''^src/libstore/builtins/buildenv\.cc$''
''^src/libstore/include/nix/store/builtins/buildenv\.hh$''
''^src/libstore/include/nix/store/common-protocol-impl\.hh$''
''^src/libstore/common-protocol\.cc$''
''^src/libstore/include/nix/store/common-protocol\.hh$''
''^src/libstore/include/nix/store/common-ssh-store-config\.hh$''
''^src/libstore/content-address\.cc$''
''^src/libstore/include/nix/store/content-address\.hh$''
''^src/libstore/daemon\.cc$''
''^src/libstore/include/nix/store/daemon\.hh$''
''^src/libstore/derivations\.cc$''
''^src/libstore/include/nix/store/derivations\.hh$''
''^src/libstore/derived-path-map\.cc$''
''^src/libstore/include/nix/store/derived-path-map\.hh$''
''^src/libstore/derived-path\.cc$''
''^src/libstore/include/nix/store/derived-path\.hh$''
''^src/libstore/downstream-placeholder\.cc$''
''^src/libstore/include/nix/store/downstream-placeholder\.hh$''
''^src/libstore/dummy-store\.cc$''
''^src/libstore/export-import\.cc$''
''^src/libstore/filetransfer\.cc$''
''^src/libstore/include/nix/store/filetransfer\.hh$''
''^src/libstore/include/nix/store/gc-store\.hh$''
''^src/libstore/globals\.cc$''
''^src/libstore/include/nix/store/globals\.hh$''
''^src/libstore/http-binary-cache-store\.cc$''
''^src/libstore/legacy-ssh-store\.cc$''
''^src/libstore/include/nix/store/legacy-ssh-store\.hh$''
''^src/libstore/include/nix/store/length-prefixed-protocol-helper\.hh$''
''^src/libstore/linux/personality\.cc$''
''^src/libstore/linux/include/nix/store/personality\.hh$''
''^src/libstore/local-binary-cache-store\.cc$''
''^src/libstore/local-fs-store\.cc$''
''^src/libstore/include/nix/store/local-fs-store\.hh$''
''^src/libstore/log-store\.cc$''
''^src/libstore/include/nix/store/log-store\.hh$''
''^src/libstore/machines\.cc$''
''^src/libstore/include/nix/store/machines\.hh$''
''^src/libstore/make-content-addressed\.cc$''
''^src/libstore/include/nix/store/make-content-addressed\.hh$''
''^src/libstore/misc\.cc$''
''^src/libstore/names\.cc$''
''^src/libstore/include/nix/store/names\.hh$''
''^src/libstore/nar-accessor\.cc$''
''^src/libstore/include/nix/store/nar-accessor\.hh$''
''^src/libstore/nar-info-disk-cache\.cc$''
''^src/libstore/include/nix/store/nar-info-disk-cache\.hh$''
''^src/libstore/nar-info\.cc$''
''^src/libstore/include/nix/store/nar-info\.hh$''
''^src/libstore/outputs-spec\.cc$''
''^src/libstore/include/nix/store/outputs-spec\.hh$''
''^src/libstore/parsed-derivations\.cc$''
''^src/libstore/path-info\.cc$''
''^src/libstore/include/nix/store/path-info\.hh$''
''^src/libstore/path-references\.cc$''
''^src/libstore/include/nix/store/path-regex\.hh$''
''^src/libstore/path-with-outputs\.cc$''
''^src/libstore/path\.cc$''
''^src/libstore/include/nix/store/path\.hh$''
''^src/libstore/pathlocks\.cc$''
''^src/libstore/include/nix/store/pathlocks\.hh$''
''^src/libstore/profiles\.cc$''
''^src/libstore/include/nix/store/profiles\.hh$''
''^src/libstore/realisation\.cc$''
''^src/libstore/include/nix/store/realisation\.hh$''
''^src/libstore/remote-fs-accessor\.cc$''
''^src/libstore/include/nix/store/remote-fs-accessor\.hh$''
''^src/libstore/include/nix/store/remote-store-connection\.hh$''
''^src/libstore/remote-store\.cc$''
''^src/libstore/include/nix/store/remote-store\.hh$''
''^src/libstore/s3-binary-cache-store\.cc$''
''^src/libstore/include/nix/store/s3\.hh$''
''^src/libstore/serve-protocol-impl\.cc$''
''^src/libstore/include/nix/store/serve-protocol-impl\.hh$''
''^src/libstore/serve-protocol\.cc$''
''^src/libstore/include/nix/store/serve-protocol\.hh$''
''^src/libstore/sqlite\.cc$''
''^src/libstore/include/nix/store/sqlite\.hh$''
''^src/libstore/ssh-store\.cc$''
''^src/libstore/ssh\.cc$''
''^src/libstore/include/nix/store/ssh\.hh$''
''^src/libstore/store-api\.cc$''
''^src/libstore/include/nix/store/store-api\.hh$''
''^src/libstore/include/nix/store/store-dir-config\.hh$''
''^src/libstore/build/derivation-building-goal\.cc$''
''^src/libstore/include/nix/store/build/derivation-building-goal\.hh$''
''^src/libstore/build/derivation-goal\.cc$''
''^src/libstore/include/nix/store/build/derivation-goal\.hh$''
''^src/libstore/build/drv-output-substitution-goal\.cc$''
''^src/libstore/include/nix/store/build/drv-output-substitution-goal\.hh$''
''^src/libstore/build/entry-points\.cc$''
''^src/libstore/build/goal\.cc$''
''^src/libstore/include/nix/store/build/goal\.hh$''
''^src/libstore/unix/build/hook-instance\.cc$''
''^src/libstore/unix/build/derivation-builder\.cc$''
''^src/libstore/unix/include/nix/store/build/derivation-builder\.hh$''
''^src/libstore/build/substitution-goal\.cc$''
''^src/libstore/include/nix/store/build/substitution-goal\.hh$''
''^src/libstore/build/worker\.cc$''
''^src/libstore/include/nix/store/build/worker\.hh$''
''^src/libstore/builtins/fetchurl\.cc$''
''^src/libstore/builtins/unpack-channel\.cc$''
''^src/libstore/gc\.cc$''
''^src/libstore/local-overlay-store\.cc$''
''^src/libstore/include/nix/store/local-overlay-store\.hh$''
''^src/libstore/local-store\.cc$''
''^src/libstore/include/nix/store/local-store\.hh$''
''^src/libstore/unix/user-lock\.cc$''
''^src/libstore/unix/include/nix/store/user-lock\.hh$''
''^src/libstore/optimise-store\.cc$''
''^src/libstore/unix/pathlocks\.cc$''
''^src/libstore/posix-fs-canonicalise\.cc$''
''^src/libstore/include/nix/store/posix-fs-canonicalise\.hh$''
''^src/libstore/uds-remote-store\.cc$''
''^src/libstore/include/nix/store/uds-remote-store\.hh$''
''^src/libstore/windows/build\.cc$''
''^src/libstore/include/nix/store/worker-protocol-impl\.hh$''
''^src/libstore/worker-protocol\.cc$''
''^src/libstore/include/nix/store/worker-protocol\.hh$''
''^src/libutil-c/nix_api_util_internal\.h$''
''^src/libutil/archive\.cc$''
''^src/libutil/include/nix/util/archive\.hh$''
''^src/libutil/args\.cc$''
''^src/libutil/include/nix/util/args\.hh$''
''^src/libutil/include/nix/util/args/root\.hh$''
''^src/libutil/include/nix/util/callback\.hh$''
''^src/libutil/canon-path\.cc$''
''^src/libutil/include/nix/util/canon-path\.hh$''
''^src/libutil/include/nix/util/chunked-vector\.hh$''
''^src/libutil/include/nix/util/closure\.hh$''
''^src/libutil/include/nix/util/comparator\.hh$''
''^src/libutil/compute-levels\.cc$''
''^src/libutil/include/nix/util/config-impl\.hh$''
''^src/libutil/configuration\.cc$''
''^src/libutil/include/nix/util/configuration\.hh$''
''^src/libutil/current-process\.cc$''
''^src/libutil/include/nix/util/current-process\.hh$''
''^src/libutil/english\.cc$''
''^src/libutil/include/nix/util/english\.hh$''
''^src/libutil/error\.cc$''
''^src/libutil/include/nix/util/error\.hh$''
''^src/libutil/include/nix/util/exit\.hh$''
''^src/libutil/experimental-features\.cc$''
''^src/libutil/include/nix/util/experimental-features\.hh$''
''^src/libutil/file-content-address\.cc$''
''^src/libutil/include/nix/util/file-content-address\.hh$''
''^src/libutil/file-descriptor\.cc$''
''^src/libutil/include/nix/util/file-descriptor\.hh$''
''^src/libutil/include/nix/util/file-path-impl\.hh$''
''^src/libutil/include/nix/util/file-path\.hh$''
''^src/libutil/file-system\.cc$''
''^src/libutil/include/nix/util/file-system\.hh$''
''^src/libutil/include/nix/util/finally\.hh$''
''^src/libutil/include/nix/util/fmt\.hh$''
''^src/libutil/fs-sink\.cc$''
''^src/libutil/include/nix/util/fs-sink\.hh$''
''^src/libutil/git\.cc$''
''^src/libutil/include/nix/util/git\.hh$''
''^src/libutil/hash\.cc$''
''^src/libutil/include/nix/util/hash\.hh$''
''^src/libutil/hilite\.cc$''
''^src/libutil/include/nix/util/hilite\.hh$''
''^src/libutil/source-accessor\.hh$''
''^src/libutil/include/nix/util/json-impls\.hh$''
''^src/libutil/json-utils\.cc$''
''^src/libutil/include/nix/util/json-utils\.hh$''
''^src/libutil/linux/cgroup\.cc$''
''^src/libutil/linux/linux-namespaces\.cc$''
''^src/libutil/logging\.cc$''
''^src/libutil/include/nix/util/logging\.hh$''
''^src/libutil/memory-source-accessor\.cc$''
''^src/libutil/include/nix/util/memory-source-accessor\.hh$''
''^src/libutil/include/nix/util/pool\.hh$''
''^src/libutil/position\.cc$''
''^src/libutil/include/nix/util/position\.hh$''
''^src/libutil/posix-source-accessor\.cc$''
''^src/libutil/include/nix/util/posix-source-accessor\.hh$''
''^src/libutil/include/nix/util/processes\.hh$''
''^src/libutil/include/nix/util/ref\.hh$''
''^src/libutil/references\.cc$''
''^src/libutil/include/nix/util/references\.hh$''
''^src/libutil/regex-combinators\.hh$''
''^src/libutil/serialise\.cc$''
''^src/libutil/include/nix/util/serialise\.hh$''
''^src/libutil/include/nix/util/signals\.hh$''
''^src/libutil/signature/local-keys\.cc$''
''^src/libutil/include/nix/util/signature/local-keys\.hh$''
''^src/libutil/signature/signer\.cc$''
''^src/libutil/include/nix/util/signature/signer\.hh$''
''^src/libutil/source-accessor\.cc$''
''^src/libutil/include/nix/util/source-accessor\.hh$''
''^src/libutil/source-path\.cc$''
''^src/libutil/include/nix/util/source-path\.hh$''
''^src/libutil/include/nix/util/split\.hh$''
''^src/libutil/suggestions\.cc$''
''^src/libutil/include/nix/util/suggestions\.hh$''
''^src/libutil/include/nix/util/sync\.hh$''
''^src/libutil/terminal\.cc$''
''^src/libutil/include/nix/util/terminal\.hh$''
''^src/libutil/thread-pool\.cc$''
''^src/libutil/include/nix/util/thread-pool\.hh$''
''^src/libutil/include/nix/util/topo-sort\.hh$''
''^src/libutil/include/nix/util/types\.hh$''
''^src/libutil/unix/file-descriptor\.cc$''
''^src/libutil/unix/file-path\.cc$''
''^src/libutil/unix/processes\.cc$''
''^src/libutil/unix/include/nix/util/signals-impl\.hh$''
''^src/libutil/unix/signals\.cc$''
''^src/libutil/unix-domain-socket\.cc$''
''^src/libutil/unix/users\.cc$''
''^src/libutil/include/nix/util/url-parts\.hh$''
''^src/libutil/url\.cc$''
''^src/libutil/include/nix/util/url\.hh$''
''^src/libutil/users\.cc$''
''^src/libutil/include/nix/util/users\.hh$''
''^src/libutil/util\.cc$''
''^src/libutil/include/nix/util/util\.hh$''
''^src/libutil/include/nix/util/variant-wrapper\.hh$''
''^src/libutil/widecharwidth/widechar_width\.h$'' # vendored source
''^src/libutil/windows/file-descriptor\.cc$''
''^src/libutil/windows/file-path\.cc$''
''^src/libutil/windows/processes\.cc$''
''^src/libutil/windows/users\.cc$''
''^src/libutil/windows/windows-error\.cc$''
''^src/libutil/windows/include/nix/util/windows-error\.hh$''
''^src/libutil/xml-writer\.cc$''
''^src/libutil/include/nix/util/xml-writer\.hh$''
''^src/nix-build/nix-build\.cc$''
''^src/nix-channel/nix-channel\.cc$''
''^src/nix-collect-garbage/nix-collect-garbage\.cc$''
''^src/nix-env/buildenv.nix$''
''^src/nix-env/nix-env\.cc$''
''^src/nix-env/user-env\.cc$''
''^src/nix-env/user-env\.hh$''
''^src/nix-instantiate/nix-instantiate\.cc$''
''^src/nix-store/dotgraph\.cc$''
''^src/nix-store/graphml\.cc$''
''^src/nix-store/nix-store\.cc$''
''^src/nix/add-to-store\.cc$''
''^src/nix/app\.cc$''
''^src/nix/build\.cc$''
''^src/nix/bundle\.cc$''
''^src/nix/cat\.cc$''
''^src/nix/config-check\.cc$''
''^src/nix/config\.cc$''
''^src/nix/copy\.cc$''
''^src/nix/derivation-add\.cc$''
''^src/nix/derivation-show\.cc$''
''^src/nix/derivation\.cc$''
''^src/nix/develop\.cc$''
''^src/nix/diff-closures\.cc$''
''^src/nix/dump-path\.cc$''
''^src/nix/edit\.cc$''
''^src/nix/eval\.cc$''
''^src/nix/flake\.cc$''
''^src/nix/fmt\.cc$''
''^src/nix/hash\.cc$''
''^src/nix/log\.cc$''
''^src/nix/ls\.cc$''
''^src/nix/main\.cc$''
''^src/nix/make-content-addressed\.cc$''
''^src/nix/nar\.cc$''
''^src/nix/optimise-store\.cc$''
''^src/nix/path-from-hash-part\.cc$''
''^src/nix/path-info\.cc$''
''^src/nix/prefetch\.cc$''
''^src/nix/profile\.cc$''
''^src/nix/realisation\.cc$''
''^src/nix/registry\.cc$''
''^src/nix/repl\.cc$''
''^src/nix/run\.cc$''
''^src/nix/run\.hh$''
''^src/nix/search\.cc$''
''^src/nix/sigs\.cc$''
''^src/nix/store-copy-log\.cc$''
''^src/nix/store-delete\.cc$''
''^src/nix/store-gc\.cc$''
''^src/nix/store-info\.cc$''
''^src/nix/store-repair\.cc$''
''^src/nix/store\.cc$''
''^src/nix/unix/daemon\.cc$''
''^src/nix/upgrade-nix\.cc$''
''^src/nix/verify\.cc$''
''^src/nix/why-depends\.cc$''
''^tests/functional/plugins/plugintest\.cc''
''^tests/functional/test-libstoreconsumer/main\.cc''
''^tests/nixos/ca-fd-leak/sender\.c''
''^tests/nixos/ca-fd-leak/smuggler\.c''
''^tests/nixos/user-sandboxing/attacker\.c''
''^src/libexpr-test-support/include/nix/expr/tests/libexpr\.hh''
''^src/libexpr-test-support/tests/value/context\.cc''
''^src/libexpr-test-support/include/nix/expr/tests/value/context\.hh''
''^src/libexpr-tests/derived-path\.cc''
''^src/libexpr-tests/error_traces\.cc''
''^src/libexpr-tests/eval\.cc''
''^src/libexpr-tests/json\.cc''
''^src/libexpr-tests/main\.cc''
''^src/libexpr-tests/primops\.cc''
''^src/libexpr-tests/search-path\.cc''
''^src/libexpr-tests/trivial\.cc''
''^src/libexpr-tests/value/context\.cc''
''^src/libexpr-tests/value/print\.cc''
''^src/libfetchers-tests/public-key\.cc''
''^src/libflake-tests/flakeref\.cc''
''^src/libflake-tests/url-name\.cc''
''^src/libstore-test-support/tests/derived-path\.cc''
''^src/libstore-test-support/include/nix/store/tests/derived-path\.hh''
''^src/libstore-test-support/include/nix/store/tests/nix_api_store\.hh''
''^src/libstore-test-support/tests/outputs-spec\.cc''
''^src/libstore-test-support/include/nix/store/tests/outputs-spec\.hh''
''^src/libstore-test-support/path\.cc''
''^src/libstore-test-support/include/nix/store/tests/path\.hh''
''^src/libstore-test-support/include/nix/store/tests/protocol\.hh''
''^src/libstore-tests/common-protocol\.cc''
''^src/libstore-tests/content-address\.cc''
''^src/libstore-tests/derivation\.cc''
''^src/libstore-tests/derived-path\.cc''
''^src/libstore-tests/downstream-placeholder\.cc''
''^src/libstore-tests/machines\.cc''
''^src/libstore-tests/nar-info-disk-cache\.cc''
''^src/libstore-tests/nar-info\.cc''
''^src/libstore-tests/outputs-spec\.cc''
''^src/libstore-tests/path-info\.cc''
''^src/libstore-tests/path\.cc''
''^src/libstore-tests/serve-protocol\.cc''
''^src/libstore-tests/worker-protocol\.cc''
''^src/libutil-test-support/include/nix/util/tests/characterization\.hh''
''^src/libutil-test-support/hash\.cc''
''^src/libutil-test-support/include/nix/util/tests/hash\.hh''
''^src/libutil-tests/args\.cc''
''^src/libutil-tests/canon-path\.cc''
''^src/libutil-tests/chunked-vector\.cc''
''^src/libutil-tests/closure\.cc''
''^src/libutil-tests/compression\.cc''
''^src/libutil-tests/config\.cc''
''^src/libutil-tests/file-content-address\.cc''
''^src/libutil-tests/git\.cc''
''^src/libutil-tests/hash\.cc''
''^src/libutil-tests/hilite\.cc''
''^src/libutil-tests/json-utils\.cc''
''^src/libutil-tests/logging\.cc''
''^src/libutil-tests/lru-cache\.cc''
''^src/libutil-tests/pool\.cc''
''^src/libutil-tests/references\.cc''
''^src/libutil-tests/suggestions\.cc''
''^src/libutil-tests/url\.cc''
''^src/libutil-tests/xml-writer\.cc''
]; ];
}; };
shellcheck = { shellcheck = {
@ -723,8 +173,6 @@
''^tests/functional/gc-concurrent\.sh$'' ''^tests/functional/gc-concurrent\.sh$''
''^tests/functional/gc-concurrent2\.builder\.sh$'' ''^tests/functional/gc-concurrent2\.builder\.sh$''
''^tests/functional/gc-non-blocking\.sh$'' ''^tests/functional/gc-non-blocking\.sh$''
''^tests/functional/git-hashing/common\.sh$''
''^tests/functional/git-hashing/simple\.sh$''
''^tests/functional/hash-convert\.sh$'' ''^tests/functional/hash-convert\.sh$''
''^tests/functional/impure-derivations\.sh$'' ''^tests/functional/impure-derivations\.sh$''
''^tests/functional/impure-eval\.sh$'' ''^tests/functional/impure-eval\.sh$''
@ -800,7 +248,6 @@
''^tests/functional/user-envs\.builder\.sh$'' ''^tests/functional/user-envs\.builder\.sh$''
''^tests/functional/user-envs\.sh$'' ''^tests/functional/user-envs\.sh$''
''^tests/functional/why-depends\.sh$'' ''^tests/functional/why-depends\.sh$''
''^src/libutil-tests/data/git/check-data\.sh$''
]; ];
}; };
}; };

View file

@ -1,11 +1,16 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if ! type -p pre-commit &>/dev/null; then if ! type -p pre-commit &>/dev/null; then
echo "format.sh: pre-commit not found. Please use \`nix develop\`."; echo "format.sh: pre-commit not found. Please use \`nix develop -c ./maintainers/format.sh\`.";
exit 1; exit 1;
fi; fi;
if test -z "$_NIX_PRE_COMMIT_HOOKS_CONFIG"; then if test -z "$_NIX_PRE_COMMIT_HOOKS_CONFIG"; then
echo "format.sh: _NIX_PRE_COMMIT_HOOKS_CONFIG not set. Please use \`nix develop\`."; echo "format.sh: _NIX_PRE_COMMIT_HOOKS_CONFIG not set. Please use \`nix develop -c ./maintainers/format.sh\`.";
exit 1; exit 1;
fi; fi;
pre-commit run --config "$_NIX_PRE_COMMIT_HOOKS_CONFIG" --all-files
while ! pre-commit run --config "$_NIX_PRE_COMMIT_HOOKS_CONFIG" --all-files; do
if [ "${1:-}" != "--until-stable" ]; then
exit 1
fi
done

View file

@ -3,5 +3,9 @@
- https://github.com/NixOS/nixos-homepage/ - https://github.com/NixOS/nixos-homepage/
- https://github.com/orgs/NixOS/teams/nix-team - https://github.com/orgs/NixOS/teams/nix-team
- Matrix room - Matrix rooms
- [private] Nix maintainer team
- Nix Lix devs (also private)
- any open security issues if present and needed
- Team member should subscribe to notifications for the [Nix development category on Discourse](https://discourse.nixos.org/c/dev/nix/50) - Team member should subscribe to notifications for the [Nix development category on Discourse](https://discourse.nixos.org/c/dev/nix/50)

58
maintainers/release-notes-todo Executable file
View file

@ -0,0 +1,58 @@
#!/usr/bin/env bash
set -euo pipefail
# debug:
# set -x
START_REF="${1}"
END_REF="${2:-upstream/master}"
# Get the merge base
MERGE_BASE=$(git merge-base "$START_REF" "$END_REF")
unset START_REF
# Get date range
START_DATE=$(git show -s --format=%cI "$MERGE_BASE")
END_DATE=$(git show -s --format=%cI "$END_REF")
echo "Checking PRs merged between $START_DATE and $END_DATE" >&2
# Get all commits between merge base and HEAD
COMMITS=$(git rev-list "$MERGE_BASE..$END_REF")
# Convert to set for fast lookup
declare -A commit_set
for commit in $COMMITS; do
commit_set["$commit"]=1
done
# Get the current changelog
LOG_DONE="$(changelog-d doc/manual/rl-next)"
is_done(){
local nr="$1"
echo "$LOG_DONE" | grep -E "^- .*/pull/$nr)"
}
# Query merged PRs in date range
gh pr list \
--repo NixOS/nix \
--state merged \
--limit 1000 \
--json number,title,author,mergeCommit \
--search "merged:$START_DATE..$END_DATE" | \
jq -r '.[] | [.number, .mergeCommit.oid, .title, .author.login] | @tsv' | \
while IFS=$'\t' read -r pr_num merge_commit _title author; do
# Check if this PR's merge commit is in our branch
if [[ -n "${commit_set[$merge_commit]:-}" ]]; then
# Full detail, not suitable for comment due to mass ping and duplicate title
# echo "- #$pr_num $_title (@$author)"
echo "- #$pr_num ($author)"
if is_done "$pr_num"
then
echo " - [x] has note"
else
echo " - [ ] has note"
fi
echo " - [ ] skip"
fi
done

View file

@ -24,11 +24,18 @@ release:
* In a checkout of the Nix repo, make sure you're on `master` and run * In a checkout of the Nix repo, make sure you're on `master` and run
`git pull`. `git pull`.
* Compile a release notes to-do list by running
```console
$ ./maintainers/release-notes-todo PREV_RELEASE HEAD
```
* Compile the release notes by running * Compile the release notes by running
```console ```console
$ export VERSION=X.YY $ export VERSION=X.YY
$ git checkout -b release-notes $ git checkout -b release-notes
$ export GITHUB_TOKEN=...
$ ./maintainers/release-notes $ ./maintainers/release-notes
``` ```
@ -39,10 +46,6 @@ release:
* Proof-read / edit / rearrange the release notes if needed. Breaking changes * Proof-read / edit / rearrange the release notes if needed. Breaking changes
and highlights should go to the top. and highlights should go to the top.
* Run `maintainers/release-credits` to make sure the credits script works
and produces a sensible output. Some emails might not automatically map to
a GitHub handle.
* Push. * Push.
```console ```console
@ -130,6 +133,8 @@ release:
Commit and push this to the maintenance branch. Commit and push this to the maintenance branch.
* Create a backport label.
* Bump the version of `master`: * Bump the version of `master`:
```console ```console
@ -137,6 +142,7 @@ release:
$ git pull $ git pull
$ NEW_VERSION=2.13.0 $ NEW_VERSION=2.13.0
$ echo $NEW_VERSION > .version $ echo $NEW_VERSION > .version
$ ... edit .mergify.yml to add the previous version ...
$ git checkout -b bump-$NEW_VERSION $ git checkout -b bump-$NEW_VERSION
$ git commit -a -m 'Bump version' $ git commit -a -m 'Bump version'
$ git push --set-upstream origin bump-$NEW_VERSION $ git push --set-upstream origin bump-$NEW_VERSION
@ -144,10 +150,6 @@ release:
Make a pull request and auto-merge it. Make a pull request and auto-merge it.
* Create a backport label.
* Add the new backport label to `.mergify.yml`.
* Post an [announcement on Discourse](https://discourse.nixos.org/c/announcements/8), including the contents of * Post an [announcement on Discourse](https://discourse.nixos.org/c/announcements/8), including the contents of
`rl-$VERSION.md`. `rl-$VERSION.md`.

View file

@ -8,7 +8,6 @@ project(
subproject_dir : 'src', subproject_dir : 'src',
default_options : [ default_options : [
'localstatedir=/nix/var', 'localstatedir=/nix/var',
# hack for trailing newline
], ],
meson_version : '>= 1.1', meson_version : '>= 1.1',
) )
@ -29,7 +28,7 @@ subproject('nix')
if get_option('doc-gen') if get_option('doc-gen')
subproject('internal-api-docs') subproject('internal-api-docs')
subproject('external-api-docs') subproject('external-api-docs')
if not meson.is_cross_build() if meson.can_run_host_binaries()
subproject('nix-manual') subproject('nix-manual')
endif endif
endif endif

View file

@ -20,3 +20,10 @@ option(
value : true, value : true,
description : 'Build language bindings (e.g. Perl)', description : 'Build language bindings (e.g. Perl)',
) )
option(
'benchmarks',
type : 'boolean',
value : false,
description : 'Build benchmarks (requires gbenchmark)',
)

10
misc/freebsd/meson.build Normal file
View file

@ -0,0 +1,10 @@
configure_file(
input : 'nix-daemon.in',
output : 'nix-daemon',
install : true,
install_dir : get_option('prefix') / 'etc/rc.d',
install_mode : 'rwxr-xr-x',
configuration : {
'bindir' : bindir,
},
)

View file

@ -0,0 +1,49 @@
#!/bin/sh
#
# PROVIDE: nix_daemon
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable nix-daemon:
#
# nix_daemon_enable="YES"
#
# shellcheck source=/dev/null
. /etc/rc.subr
name="nix_daemon"
# shellcheck disable=SC2034
rcvar="nix_daemon_enable"
load_rc_config $name
: "${nix_daemon_enable:=NO}"
command="@bindir@/nix-daemon"
command_args=""
pidfile="/var/run/nix-daemon.pid"
# shellcheck disable=SC2034
start_cmd="${name}_start"
# shellcheck disable=SC2034
stop_cmd="${name}_stop"
nix_daemon_start() {
echo "Starting ${name}."
# command_args is intentionally unquoted to allow multiple arguments
# shellcheck disable=SC2086
/usr/sbin/daemon -c -f -p "${pidfile}" "${command}" ${command_args}
}
nix_daemon_stop() {
if [ -f "${pidfile}" ]; then
echo "Stopping ${name}."
kill -TERM "$(cat "${pidfile}")"
rm -f "${pidfile}"
else
echo "${name} is not running."
fi
}
run_rc_command "$1"

View file

@ -9,5 +9,5 @@ configure_file(
# 'storedir' : store_dir, # 'storedir' : store_dir,
# 'localstatedir' : localstatedir, # 'localstatedir' : localstatedir,
# 'bindir' : bindir, # 'bindir' : bindir,
}, },
) )

View file

@ -9,3 +9,7 @@ endif
if host_machine.system() == 'darwin' if host_machine.system() == 'darwin'
subdir('launchd') subdir('launchd')
endif endif
if host_machine.system() == 'freebsd'
subdir('freebsd')
endif

View file

@ -2,5 +2,5 @@ if host_machine.system() == 'windows'
# libexpr's primops creates a large object # libexpr's primops creates a large object
# Without the following flag, we'll get errors when cross-compiling to mingw32: # Without the following flag, we'll get errors when cross-compiling to mingw32:
# Fatal error: can't write 66 bytes to section .text of src/libexpr/libnixexpr.dll.p/primops.cc.obj: 'file too big' # Fatal error: can't write 66 bytes to section .text of src/libexpr/libnixexpr.dll.p/primops.cc.obj: 'file too big'
add_project_arguments([ '-Wa,-mbig-obj' ], language: 'cpp') add_project_arguments([ '-Wa,-mbig-obj' ], language : 'cpp')
endif endif

View file

@ -18,3 +18,25 @@ add_project_arguments(
'-Wno-deprecated-declarations', '-Wno-deprecated-declarations',
language : 'cpp', language : 'cpp',
) )
# GCC doesn't benefit much from precompiled headers.
do_pch = cxx.get_id() == 'clang'
# This is a clang-only option for improving build times.
# It forces the instantiation of templates in the PCH itself and
# not every translation unit it's included in.
# It's available starting from clang 11, which is old enough to not
# bother checking the version.
# This feature helps in particular with the expensive nlohmann::json template
# instantiations in libutil and libstore.
if cxx.get_id() == 'clang'
add_project_arguments('-fpch-instantiate-templates', language : 'cpp')
endif
# Clang gets grumpy about missing libasan symbols if -shared-libasan is not
# passed when building shared libs, at least on Linux
if cxx.get_id() == 'clang' and ('address' in get_option('b_sanitize') or 'undefined' in get_option(
'b_sanitize',
))
add_project_link_arguments('-shared-libasan', language : 'cpp')
endif

View file

@ -0,0 +1,19 @@
# This attempts to translate meson cpu_family and cpu_name specified via
# --cross-file [1] into a nix *system double*. Nixpkgs mostly respects ([2]) the
# conventions outlined in [1].
#
# [1]: https://mesonbuild.com/Reference-tables.html#cpu-families
# [2]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/lib/meson.nix
nix_system_cpu = {'ppc64' : 'powerpc64', 'ppc' : 'powerpc', 'x86' : 'i686'}.get(
host_machine.cpu_family(),
host_machine.cpu_family(),
)
if (host_machine.cpu_family() in [ 'ppc64', 'ppc' ]) and host_machine.endian() == 'little'
nix_system_cpu += 'le'
elif host_machine.cpu_family() in [ 'mips64', 'mips' ] and host_machine.endian() == 'little'
nix_system_cpu += 'el'
elif host_machine.cpu_family() == 'arm'
nix_system_cpu = host_machine.cpu()
endif

View file

@ -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 = []

View file

@ -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

View file

@ -1,12 +1,12 @@
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
@ -14,7 +14,7 @@ extra_pkg_config_variables = get_variable('extra_pkg_config_variables', {})
extra_cflags = [] extra_cflags = []
if not meson.project_name().endswith('-c') if not meson.project_name().endswith('-c')
extra_cflags += ['-std=c++2a'] extra_cflags += [ '-std=c++23' ]
endif endif
import('pkgconfig').generate( import('pkgconfig').generate(
@ -29,10 +29,13 @@ import('pkgconfig').generate(
variables : extra_pkg_config_variables, variables : extra_pkg_config_variables,
) )
meson.override_dependency(meson.project_name(), declare_dependency( meson.override_dependency(
include_directories : include_dirs, meson.project_name(),
link_with : this_library, declare_dependency(
compile_args : ['-std=c++2a'], include_directories : include_dirs,
dependencies : deps_public_subproject + deps_public, link_with : this_library,
variables : extra_pkg_config_variables, compile_args : [ '-std=c++23' ],
)) dependencies : deps_public_subproject + deps_public,
variables : extra_pkg_config_variables,
),
)

View file

@ -1,7 +1,12 @@
bash = find_program('bash', native: true) bash = find_program('bash', native : true)
gen_header = generator( gen_header = generator(
bash, bash,
arguments : [ '-c', '{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"', '_ignored_argv0', '@OUTPUT@' ], arguments : [
'-c',
'{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"',
'_ignored_argv0',
'@OUTPUT@',
],
output : '@PLAINNAME@.gen.hh', output : '@PLAINNAME@.gen.hh',
) )

View file

@ -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() == 'arm' if host_machine.cpu_family() in [ 'arm', 'ppc' ]
deps_other += cxx.find_library('atomic') deps_other += cxx.find_library('atomic')
endif endif

View file

@ -37,6 +37,9 @@ runCommand "nix-binary-tarball-${version}" env ''
substitute ${../scripts/install-systemd-multi-user.sh} $TMPDIR/install-systemd-multi-user.sh \ substitute ${../scripts/install-systemd-multi-user.sh} $TMPDIR/install-systemd-multi-user.sh \
--subst-var-by nix ${nix} \ --subst-var-by nix ${nix} \
--subst-var-by cacert ${cacert} --subst-var-by cacert ${cacert}
substitute ${../scripts/install-freebsd-multi-user.sh} $TMPDIR/install-freebsd-multi-user.sh \
--subst-var-by nix ${nix} \
--subst-var-by cacert ${cacert}
substitute ${../scripts/install-multi-user.sh} $TMPDIR/install-multi-user \ substitute ${../scripts/install-multi-user.sh} $TMPDIR/install-multi-user \
--subst-var-by nix ${nix} \ --subst-var-by nix ${nix} \
--subst-var-by cacert ${cacert} --subst-var-by cacert ${cacert}
@ -48,6 +51,7 @@ runCommand "nix-binary-tarball-${version}" env ''
shellcheck $TMPDIR/create-darwin-volume.sh shellcheck $TMPDIR/create-darwin-volume.sh
shellcheck $TMPDIR/install-darwin-multi-user.sh shellcheck $TMPDIR/install-darwin-multi-user.sh
shellcheck $TMPDIR/install-systemd-multi-user.sh shellcheck $TMPDIR/install-systemd-multi-user.sh
shellcheck $TMPDIR/install-freebsd-multi-user.sh
# SC1091: Don't panic about not being able to source # SC1091: Don't panic about not being able to source
# /etc/profile # /etc/profile
@ -64,6 +68,7 @@ runCommand "nix-binary-tarball-${version}" env ''
chmod +x $TMPDIR/create-darwin-volume.sh chmod +x $TMPDIR/create-darwin-volume.sh
chmod +x $TMPDIR/install-darwin-multi-user.sh chmod +x $TMPDIR/install-darwin-multi-user.sh
chmod +x $TMPDIR/install-systemd-multi-user.sh chmod +x $TMPDIR/install-systemd-multi-user.sh
chmod +x $TMPDIR/install-freebsd-multi-user.sh
chmod +x $TMPDIR/install-multi-user chmod +x $TMPDIR/install-multi-user
dir=nix-${version}-${system} dir=nix-${version}-${system}
fn=$out/$dir.tar.xz fn=$out/$dir.tar.xz
@ -82,6 +87,7 @@ runCommand "nix-binary-tarball-${version}" env ''
$TMPDIR/create-darwin-volume.sh \ $TMPDIR/create-darwin-volume.sh \
$TMPDIR/install-darwin-multi-user.sh \ $TMPDIR/install-darwin-multi-user.sh \
$TMPDIR/install-systemd-multi-user.sh \ $TMPDIR/install-systemd-multi-user.sh \
$TMPDIR/install-freebsd-multi-user.sh \
$TMPDIR/install-multi-user \ $TMPDIR/install-multi-user \
$TMPDIR/reginfo \ $TMPDIR/reginfo \
$(cat ${installerClosureInfo}/store-paths) $(cat ${installerClosureInfo}/store-paths)

View file

@ -54,12 +54,12 @@ let
preConfigure = preConfigure =
prevAttrs.preConfigure or "" prevAttrs.preConfigure or ""
+ +
# Update the repo-global .version file. # Update the repo-global .version file.
# Symlink ./.version points there, but by default only workDir is writable. # Symlink ./.version points there, but by default only workDir is writable.
'' ''
chmod u+w ./.version chmod u+w ./.version
echo ${finalAttrs.version} > ./.version echo ${finalAttrs.version} > ./.version
''; '';
}; };
localSourceLayer = localSourceLayer =
@ -148,7 +148,8 @@ let
nativeBuildInputs = [ nativeBuildInputs = [
meson meson
ninja ninja
] ++ prevAttrs.nativeBuildInputs or [ ]; ]
++ prevAttrs.nativeBuildInputs or [ ];
mesonCheckFlags = prevAttrs.mesonCheckFlags or [ ] ++ [ mesonCheckFlags = prevAttrs.mesonCheckFlags or [ ] ++ [
"--print-errorlogs" "--print-errorlogs"
]; ];
@ -365,18 +366,33 @@ in
nix-cmd = callPackage ../src/libcmd/package.nix { }; nix-cmd = callPackage ../src/libcmd/package.nix { };
/**
The Nix command line interface. Note that this does not include its tests, whereas `nix-everything` does.
*/
nix-cli = callPackage ../src/nix/package.nix { version = fineVersion; }; nix-cli = callPackage ../src/nix/package.nix { version = fineVersion; };
nix-functional-tests = callPackage ../tests/functional/package.nix { nix-functional-tests = callPackage ../tests/functional/package.nix {
version = fineVersion; version = fineVersion;
}; };
/**
The manual as would be published on https://nix.dev/reference/nix-manual
*/
nix-manual = callPackage ../doc/manual/package.nix { version = fineVersion; }; nix-manual = callPackage ../doc/manual/package.nix { version = fineVersion; };
/**
Doxygen pages for C++ code
*/
nix-internal-api-docs = callPackage ../src/internal-api-docs/package.nix { version = fineVersion; }; nix-internal-api-docs = callPackage ../src/internal-api-docs/package.nix { version = fineVersion; };
/**
Doxygen pages for the public C API
*/
nix-external-api-docs = callPackage ../src/external-api-docs/package.nix { version = fineVersion; }; nix-external-api-docs = callPackage ../src/external-api-docs/package.nix { version = fineVersion; };
nix-perl-bindings = callPackage ../src/perl/package.nix { }; nix-perl-bindings = callPackage ../src/perl/package.nix { };
/**
Combined package that has the CLI, libraries, and (assuming non-cross, no overrides) it requires that all tests succeed.
*/
nix-everything = callPackage ../packaging/everything.nix { } // { nix-everything = callPackage ../packaging/everything.nix { } // {
# Note: no `passthru.overrideAllMesonComponents` etc # Note: no `passthru.overrideAllMesonComponents` etc
# This would propagate into `nix.overrideAttrs f`, but then discard # This would propagate into `nix.overrideAttrs f`, but then discard

View file

@ -10,27 +10,8 @@
stdenv, stdenv,
}: }:
let
prevStdenv = stdenv;
in
let let
inherit (pkgs) lib; inherit (pkgs) lib;
stdenv = if prevStdenv.isDarwin && prevStdenv.isx86_64 then darwinStdenv else prevStdenv;
# Fix the following error with the default x86_64-darwin SDK:
#
# error: aligned allocation function of type 'void *(std::size_t, std::align_val_t)' is only available on macOS 10.13 or newer
#
# Despite the use of the 10.13 deployment target here, the aligned
# allocation function Clang uses with this setting actually works
# all the way back to 10.6.
# NOTE: this is not just a version constraint, but a request to make Darwin
# provide this version level of support. Removing this minimum version
# request will regress the above error.
darwinStdenv = pkgs.overrideSDK prevStdenv { darwinMinVersion = "10.13"; };
in in
scope: { scope: {
inherit stdenv; inherit stdenv;
@ -50,8 +31,40 @@ scope: {
requiredSystemFeatures = [ ]; requiredSystemFeatures = [ ];
}; };
boehmgc = pkgs.boehmgc.override { boehmgc =
enableLargeConfig = true; (pkgs.boehmgc.override {
enableLargeConfig = true;
}).overrideAttrs
(attrs: {
# Increase the initial mark stack size to avoid stack
# overflows, since these inhibit parallel marking (see
# GC_mark_some()). To check whether the mark stack is too
# small, run Nix with GC_PRINT_STATS=1 and look for messages
# such as `Mark stack overflow`, `No room to copy back mark
# stack`, and `Grew mark stack to ... frames`.
NIX_CFLAGS_COMPILE = "-DINITIAL_MARK_STACK_SIZE=1048576";
});
lowdown = pkgs.lowdown.overrideAttrs (prevAttrs: rec {
version = "2.0.2";
src = pkgs.fetchurl {
url = "https://kristaps.bsd.lv/lowdown/snapshots/lowdown-${version}.tar.gz";
hash = "sha512-cfzhuF4EnGmLJf5EGSIbWqJItY3npbRSALm+GarZ7SMU7Hr1xw0gtBFMpOdi5PBar4TgtvbnG4oRPh+COINGlA==";
};
nativeBuildInputs = prevAttrs.nativeBuildInputs ++ [ pkgs.buildPackages.bmake ];
postInstall =
lib.replaceStrings [ "lowdown.so.1" "lowdown.1.dylib" ] [ "lowdown.so.2" "lowdown.2.dylib" ]
prevAttrs.postInstall;
});
toml11 = pkgs.toml11.overrideAttrs rec {
version = "4.4.0";
src = pkgs.fetchFromGitHub {
owner = "ToruNiina";
repo = "toml11";
tag = "v${version}";
hash = "sha256-sgWKYxNT22nw376ttGsTdg0AMzOwp8QH3E8mx0BZJTQ=";
};
}; };
# TODO Hack until https://github.com/NixOS/nixpkgs/issues/45462 is fixed. # TODO Hack until https://github.com/NixOS/nixpkgs/issues/45462 is fixed.
@ -62,6 +75,7 @@ scope: {
"--with-context" "--with-context"
"--with-coroutine" "--with-coroutine"
"--with-iostreams" "--with-iostreams"
"--with-url"
]; ];
enableIcu = false; enableIcu = false;
}).overrideAttrs }).overrideAttrs

View file

@ -71,17 +71,16 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
# We use this shell with the local checkout, not unpackPhase. # We use this shell with the local checkout, not unpackPhase.
src = null; src = null;
env = env = {
{ # For `make format`, to work without installing pre-commit
# For `make format`, to work without installing pre-commit _NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml"
_NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml" modular.pre-commit.settings.rawConfig
modular.pre-commit.settings.rawConfig }";
}"; }
} // lib.optionalAttrs stdenv.hostPlatform.isLinux {
// lib.optionalAttrs stdenv.hostPlatform.isLinux { CC_LD = "mold";
CC_LD = "mold"; CXX_LD = "mold";
CXX_LD = "mold"; };
};
mesonFlags = mesonFlags =
map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents2.nix-util.mesonFlags) map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents2.nix-util.mesonFlags)
@ -113,27 +112,31 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
) pkgs.buildPackages.mesonEmulatorHook ) pkgs.buildPackages.mesonEmulatorHook
++ [ ++ [
pkgs.buildPackages.cmake pkgs.buildPackages.cmake
pkgs.buildPackages.gnused
pkgs.buildPackages.shellcheck pkgs.buildPackages.shellcheck
pkgs.buildPackages.changelog-d pkgs.buildPackages.changelog-d
modular.pre-commit.settings.package modular.pre-commit.settings.package
(pkgs.writeScriptBin "pre-commit-hooks-install" modular.pre-commit.settings.installationScript) (pkgs.writeScriptBin "pre-commit-hooks-install" modular.pre-commit.settings.installationScript)
pkgs.buildPackages.nixfmt-rfc-style pkgs.buildPackages.nixfmt-rfc-style
pkgs.buildPackages.gdb
] ]
++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) ( ++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) (
lib.hiPrio pkgs.buildPackages.clang-tools lib.hiPrio pkgs.buildPackages.clang-tools
) )
++ lib.optional stdenv.hostPlatform.isLinux pkgs.buildPackages.mold-wrapped; ++ lib.optional stdenv.hostPlatform.isLinux pkgs.buildPackages.mold-wrapped;
buildInputs = buildInputs = [
attrs.buildInputs or [ ] pkgs.gbenchmark
++ pkgs.nixComponents2.nix-util.buildInputs ]
++ pkgs.nixComponents2.nix-store.buildInputs ++ attrs.buildInputs or [ ]
++ pkgs.nixComponents2.nix-store-tests.externalBuildInputs ++ pkgs.nixComponents2.nix-util.buildInputs
++ pkgs.nixComponents2.nix-fetchers.buildInputs ++ pkgs.nixComponents2.nix-store.buildInputs
++ pkgs.nixComponents2.nix-expr.buildInputs ++ pkgs.nixComponents2.nix-store-tests.externalBuildInputs
++ pkgs.nixComponents2.nix-expr.externalPropagatedBuildInputs ++ pkgs.nixComponents2.nix-fetchers.buildInputs
++ pkgs.nixComponents2.nix-cmd.buildInputs ++ pkgs.nixComponents2.nix-expr.buildInputs
++ lib.optionals havePerl pkgs.nixComponents2.nix-perl-bindings.externalBuildInputs ++ pkgs.nixComponents2.nix-expr.externalPropagatedBuildInputs
++ lib.optional havePerl pkgs.perl; ++ pkgs.nixComponents2.nix-cmd.buildInputs
++ lib.optionals havePerl pkgs.nixComponents2.nix-perl-bindings.externalBuildInputs
++ lib.optional havePerl pkgs.perl;
} }
) )

View file

@ -47,25 +47,25 @@
}: }:
let let
libs = libs = {
{ inherit
inherit nix-util
nix-util nix-util-c
nix-util-c nix-store
nix-store nix-store-c
nix-store-c nix-fetchers
nix-fetchers nix-fetchers-c
nix-fetchers-c nix-expr
nix-expr nix-expr-c
nix-expr-c nix-flake
nix-flake nix-flake-c
nix-flake-c nix-main
nix-main nix-main-c
nix-main-c nix-cmd
nix-cmd ;
; }
} //
// lib.optionalAttrs lib.optionalAttrs
(!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform) (!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
{ {
# Currently fails in static build # Currently fails in static build
@ -127,20 +127,19 @@ stdenv.mkDerivation (finalAttrs: {
*/ */
dontFixup = true; dontFixup = true;
checkInputs = checkInputs = [
[ # Make sure the unit tests have passed
# Make sure the unit tests have passed nix-util-tests.tests.run
nix-util-tests.tests.run nix-store-tests.tests.run
nix-store-tests.tests.run nix-expr-tests.tests.run
nix-expr-tests.tests.run nix-fetchers-tests.tests.run
nix-fetchers-tests.tests.run nix-flake-tests.tests.run
nix-flake-tests.tests.run
# Make sure the functional tests have passed # Make sure the functional tests have passed
nix-functional-tests nix-functional-tests
] ]
++ lib.optionals ++
(!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform) lib.optionals (!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
[ [
# Perl currently fails in static build # Perl currently fails in static build
# TODO: Split out tests into a separate derivation? # TODO: Split out tests into a separate derivation?

View file

@ -223,10 +223,17 @@ in
dockerImage = lib.genAttrs linux64BitSystems (system: self.packages.${system}.dockerImage); dockerImage = lib.genAttrs linux64BitSystems (system: self.packages.${system}.dockerImage);
# # Line coverage analysis. # # Line coverage analysis.
# coverage = nixpkgsFor.x86_64-linux.native.nix.override { coverage =
# pname = "nix-coverage"; (import ./../ci/gha/tests rec {
# withCoverageChecks = true; withCoverage = true;
# }; pkgs = nixpkgsFor.x86_64-linux.nativeForStdenv.clangStdenv;
nixComponents = pkgs.nixComponents2;
nixFlake = null;
getStdenv = p: p.clangStdenv;
}).codeCoverage.coverageReports.overrideAttrs
{
name = "nix-coverage"; # For historical consistency
};
# Nix's manual # Nix's manual
manual = nixpkgsFor.x86_64-linux.native.nixComponents2.nix-manual; manual = nixpkgsFor.x86_64-linux.native.nixComponents2.nix-manual;
@ -240,7 +247,9 @@ in
# System tests. # System tests.
tests = tests =
import ../tests/nixos { import ../tests/nixos {
inherit lib nixpkgs nixpkgsFor; inherit lib nixpkgs;
pkgs = nixpkgsFor.x86_64-linux.native;
nixComponents = nixpkgsFor.x86_64-linux.native.nixComponents2;
inherit (self.inputs) nixpkgs-23-11; inherit (self.inputs) nixpkgs-23-11;
} }
// { // {

View file

@ -0,0 +1,173 @@
#!/usr/bin/env bash
set -eu
set -o pipefail
# System specific settings
# FreeBSD typically uses UIDs from 1001+ for regular users,
# so we'll use a range that's unlikely to conflict
export NIX_FIRST_BUILD_UID="${NIX_FIRST_BUILD_UID:-30001}"
export NIX_BUILD_GROUP_ID="${NIX_BUILD_GROUP_ID:-30000}"
export NIX_BUILD_USER_NAME_TEMPLATE="nixbld%d"
# FreeBSD service paths
readonly SERVICE_SRC=/etc/rc.d/nix-daemon
readonly SERVICE_DEST=/usr/local/etc/rc.d/nix-daemon
poly_cure_artifacts() {
:
}
poly_service_installed_check() {
if [ -f "$SERVICE_DEST" ]; then
return 0
else
return 1
fi
}
poly_service_uninstall_directions() {
cat <<EOF
$1. Delete the rc.d service
sudo service nix-daemon stop
sudo rm -f $SERVICE_DEST
sudo sysrc -x nix_daemon_enable
EOF
}
poly_service_setup_note() {
cat <<EOF
- link the nix-daemon rc.d service to $SERVICE_DEST
EOF
}
poly_extra_try_me_commands() {
cat <<EOF
$ sudo service nix-daemon start
EOF
}
poly_configure_nix_daemon_service() {
task "Setting up the nix-daemon rc.d service"
# Ensure the rc.d directory exists
_sudo "to create the rc.d directory" \
mkdir -p /usr/local/etc/rc.d
# Link the pre-installed rc.d script
_sudo "to set up the nix-daemon service" \
ln -sfn "/nix/var/nix/profiles/default$SERVICE_SRC" "$SERVICE_DEST"
_sudo "to enable the nix-daemon service" \
sysrc nix_daemon_enable=YES
_sudo "to start the nix-daemon" \
service nix-daemon start
}
poly_group_exists() {
pw group show "$1" > /dev/null 2>&1
}
poly_group_id_get() {
pw group show "$1" | cut -d: -f3
}
poly_create_build_group() {
_sudo "Create the Nix build group, $NIX_BUILD_GROUP_NAME" \
pw groupadd -n "$NIX_BUILD_GROUP_NAME" -g "$NIX_BUILD_GROUP_ID" >&2
}
poly_user_exists() {
pw user show "$1" > /dev/null 2>&1
}
poly_user_id_get() {
pw user show "$1" | cut -d: -f3
}
poly_user_hidden_get() {
# FreeBSD doesn't have a concept of hidden users like macOS
echo "0"
}
poly_user_hidden_set() {
# No-op on FreeBSD
true
}
poly_user_home_get() {
pw user show "$1" | cut -d: -f9
}
poly_user_home_set() {
_sudo "in order to give $1 a safe home directory" \
pw usermod -n "$1" -d "$2"
}
poly_user_note_get() {
pw user show "$1" | cut -d: -f8
}
poly_user_note_set() {
_sudo "in order to give $1 a useful comment" \
pw usermod -n "$1" -c "$2"
}
poly_user_shell_get() {
pw user show "$1" | cut -d: -f10
}
poly_user_shell_set() {
_sudo "in order to prevent $1 from logging in" \
pw usermod -n "$1" -s "$2"
}
poly_user_in_group_check() {
groups "$1" 2>/dev/null | grep -q "\<$2\>"
}
poly_user_in_group_set() {
_sudo "Add $1 to the $2 group" \
pw groupmod -n "$2" -m "$1"
}
poly_user_primary_group_get() {
pw user show "$1" | cut -d: -f4
}
poly_user_primary_group_set() {
_sudo "to let the nix daemon use this user for builds" \
pw usermod -n "$1" -g "$2"
}
poly_create_build_user() {
username=$1
uid=$2
builder_num=$3
_sudo "Creating the Nix build user, $username" \
pw useradd \
-n "$username" \
-u "$uid" \
-g "$NIX_BUILD_GROUP_NAME" \
-G "$NIX_BUILD_GROUP_NAME" \
-d /var/empty \
-s /sbin/nologin \
-c "Nix build user $builder_num"
}
poly_prepare_to_install() {
# FreeBSD-specific preparation steps
:
}
poly_configure_default_profile_targets() {
# FreeBSD-specific profile locations
# FreeBSD uses /usr/local/etc for third-party shell configurations
# Include both profile (for login shells) and bashrc (for interactive shells)
echo "/usr/local/etc/profile /usr/local/etc/bashrc /usr/local/etc/profile.d/nix.sh /usr/local/etc/zshrc"
}

View file

@ -33,7 +33,8 @@ readonly NIX_BUILD_GROUP_NAME="nixbld"
readonly NIX_ROOT="/nix" readonly NIX_ROOT="/nix"
readonly NIX_EXTRA_CONF=${NIX_EXTRA_CONF:-} readonly NIX_EXTRA_CONF=${NIX_EXTRA_CONF:-}
readonly PROFILE_TARGETS=("/etc/bashrc" "/etc/profile.d/nix.sh" "/etc/zshrc" "/etc/bash.bashrc" "/etc/zsh/zshrc") # PROFILE_TARGETS will be set later after OS-specific scripts are loaded
PROFILE_TARGETS=()
readonly PROFILE_BACKUP_SUFFIX=".backup-before-nix" readonly PROFILE_BACKUP_SUFFIX=".backup-before-nix"
readonly PROFILE_NIX_FILE="$NIX_ROOT/var/nix/profiles/default/etc/profile.d/nix-daemon.sh" readonly PROFILE_NIX_FILE="$NIX_ROOT/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"
@ -99,6 +100,14 @@ is_os_darwin() {
fi fi
} }
is_os_freebsd() {
if [ "$(uname -s)" = "FreeBSD" ]; then
return 0
else
return 1
fi
}
contact_us() { contact_us() {
echo "You can open an issue at" echo "You can open an issue at"
echo "https://github.com/NixOS/nix/issues/new?labels=installer&template=installer.md" echo "https://github.com/NixOS/nix/issues/new?labels=installer&template=installer.md"
@ -498,6 +507,10 @@ You have aborted the installation.
EOF EOF
fi fi
fi fi
if is_os_freebsd; then
ok "Detected FreeBSD, will set up rc.d service for nix-daemon"
fi
} }
setup_report() { setup_report() {
@ -834,8 +847,13 @@ install_from_extracted_nix() {
( (
cd "$EXTRACTED_NIX_PATH" cd "$EXTRACTED_NIX_PATH"
_sudo "to copy the basic Nix files to the new store at $NIX_ROOT/store" \ if is_os_darwin || is_os_freebsd; then
cp -RPp ./store/* "$NIX_ROOT/store/" _sudo "to copy the basic Nix files to the new store at $NIX_ROOT/store" \
cp -RPp ./store/* "$NIX_ROOT/store/"
else
_sudo "to copy the basic Nix files to the new store at $NIX_ROOT/store" \
cp -RP --preserve=ownership,timestamps ./store/* "$NIX_ROOT/store/"
fi
_sudo "to make the new store non-writable at $NIX_ROOT/store" \ _sudo "to make the new store non-writable at $NIX_ROOT/store" \
chmod -R ugo-w "$NIX_ROOT/store/" chmod -R ugo-w "$NIX_ROOT/store/"
@ -984,11 +1002,22 @@ main() {
# shellcheck source=./install-systemd-multi-user.sh # shellcheck source=./install-systemd-multi-user.sh
. "$EXTRACTED_NIX_PATH/install-systemd-multi-user.sh" # most of this works on non-systemd distros also . "$EXTRACTED_NIX_PATH/install-systemd-multi-user.sh" # most of this works on non-systemd distros also
check_required_system_specific_settings "install-systemd-multi-user.sh" check_required_system_specific_settings "install-systemd-multi-user.sh"
elif is_os_freebsd; then
# shellcheck source=./install-freebsd-multi-user.sh
. "$EXTRACTED_NIX_PATH/install-freebsd-multi-user.sh"
check_required_system_specific_settings "install-freebsd-multi-user.sh"
else else
failure "Sorry, I don't know what to do on $(uname)" failure "Sorry, I don't know what to do on $(uname)"
fi fi
# Set profile targets after OS-specific scripts are loaded
if command -v poly_configure_default_profile_targets > /dev/null 2>&1; then
PROFILE_TARGETS=($(poly_configure_default_profile_targets))
else
PROFILE_TARGETS=("/etc/bashrc" "/etc/profile.d/nix.sh" "/etc/zshrc" "/etc/bash.bashrc" "/etc/zsh/zshrc")
fi
welcome_to_nix welcome_to_nix
if ! is_root; then if ! is_root; then

View file

@ -26,8 +26,10 @@ if [ -z "$HOME" ]; then
exit 1 exit 1
fi fi
OS="$(uname -s)"
# macOS support for 10.12.6 or higher # macOS support for 10.12.6 or higher
if [ "$(uname -s)" = "Darwin" ]; then if [ "$OS" = "Darwin" ]; then
IFS='.' read -r macos_major macos_minor macos_patch << EOF IFS='.' read -r macos_major macos_minor macos_patch << EOF
$(sw_vers -productVersion) $(sw_vers -productVersion)
EOF EOF
@ -39,11 +41,11 @@ EOF
fi fi
# Determine if we could use the multi-user installer or not # Determine if we could use the multi-user installer or not
if [ "$(uname -s)" = "Linux" ]; then if [ "$OS" = "Linux" ] || [ "$OS" = "FreeBSD" ]; then
echo "Note: a multi-user installation is possible. See https://nixos.org/manual/nix/stable/installation/installing-binary.html#multi-user-installation" >&2 echo "Note: a multi-user installation is possible. See https://nix.dev/manual/nix/stable/installation/installing-binary.html#multi-user-installation" >&2
fi fi
case "$(uname -s)" in case "$OS" in
"Darwin") "Darwin")
INSTALL_MODE=daemon;; INSTALL_MODE=daemon;;
*) *)
@ -60,7 +62,7 @@ while [ $# -gt 0 ]; do
ACTION=install ACTION=install
;; ;;
--no-daemon) --no-daemon)
if [ "$(uname -s)" = "Darwin" ]; then if [ "$OS" = "Darwin" ]; then
printf '\e[1;31mError: --no-daemon installs are no-longer supported on Darwin/macOS!\e[0m\n' >&2 printf '\e[1;31mError: --no-daemon installs are no-longer supported on Darwin/macOS!\e[0m\n' >&2
exit 1 exit 1
fi fi
@ -96,7 +98,7 @@ while [ $# -gt 0 ]; do
echo " providing multi-user support and better isolation for local builds." echo " providing multi-user support and better isolation for local builds."
echo " Both for security and reproducibility, this method is recommended if" echo " Both for security and reproducibility, this method is recommended if"
echo " supported on your platform." echo " supported on your platform."
echo " See https://nixos.org/manual/nix/stable/installation/installing-binary.html#multi-user-installation" echo " See https://nix.dev/manual/nix/stable/installation/installing-binary.html#multi-user-installation"
echo "" echo ""
echo " --no-daemon: Simple, single-user installation that does not require root and is" echo " --no-daemon: Simple, single-user installation that does not require root and is"
echo " trivial to uninstall." echo " trivial to uninstall."
@ -123,6 +125,13 @@ while [ $# -gt 0 ]; do
done done
if [ "$INSTALL_MODE" = "daemon" ]; then if [ "$INSTALL_MODE" = "daemon" ]; then
# Check for bash on systems that don't have it by default
if [ "$OS" = "FreeBSD" ] && ! command -v bash >/dev/null 2>&1; then
printf '\e[1;31mError: bash is required for multi-user installation but was not found.\e[0m\n' >&2
printf 'Please install bash first:\n' >&2
printf ' pkg install bash\n' >&2
exit 1
fi
printf '\e[1;31mSwitching to the Multi-user Installer\e[0m\n' printf '\e[1;31mSwitching to the Multi-user Installer\e[0m\n'
exec "$self/install-multi-user" $ACTION exec "$self/install-multi-user" $ACTION
exit 0 exit 0
@ -144,7 +153,7 @@ if ! [ -e "$dest" ]; then
fi fi
if ! [ -w "$dest" ]; then if ! [ -w "$dest" ]; then
echo "$0: directory $dest exists, but is not writable by you. This could indicate that another user has already performed a single-user installation of Nix on this system. If you wish to enable multi-user support see https://nixos.org/manual/nix/stable/installation/multi-user.html. If you wish to continue with a single-user install for $USER please run 'chown -R $USER $dest' as root." >&2 echo "$0: directory $dest exists, but is not writable by you. This could indicate that another user has already performed a single-user installation of Nix on this system. If you wish to enable multi-user support see https://nix.dev/manual/nix/stable/installation/multi-user.html. If you wish to continue with a single-user install for $USER please run 'chown -R $USER $dest' as root." >&2
exit 1 exit 1
fi fi
@ -167,7 +176,11 @@ for i in $(cd "$self/store" >/dev/null && echo ./*); do
rm -rf "$i_tmp" rm -rf "$i_tmp"
fi fi
if ! [ -e "$dest/store/$i" ]; then if ! [ -e "$dest/store/$i" ]; then
cp -RPp "$self/store/$i" "$i_tmp" if [ "$OS" = "Darwin" ] || [ "$OS" = "FreeBSD" ]; then
cp -RPp "$self/store/$i" "$i_tmp"
else
cp -RP --preserve=ownership,timestamps "$self/store/$i" "$i_tmp"
fi
chmod -R a-w "$i_tmp" chmod -R a-w "$i_tmp"
chmod +w "$i_tmp" chmod +w "$i_tmp"
mv "$i_tmp" "$dest/store/$i" mv "$i_tmp" "$dest/store/$i"

View file

@ -2,19 +2,19 @@ configure_file(
input : 'nix-profile.sh.in', input : 'nix-profile.sh.in',
output : 'nix-profile.sh', output : 'nix-profile.sh',
configuration : { configuration : {
'localstatedir': localstatedir, 'localstatedir' : localstatedir,
} },
) )
foreach rc : [ '.sh', '.fish', '-daemon.sh', '-daemon.fish' ] foreach rc : [ '.sh', '.fish', '-daemon.sh', '-daemon.fish' ]
configure_file( configure_file(
input : 'nix-profile' + rc + '.in', input : 'nix-profile' + rc + '.in',
output : 'nix' + rc, output : 'nix' + rc,
install : true, install : true,
install_dir : get_option('profile-dir'), install_dir : get_option('profile-dir'),
install_mode : 'rw-r--r--', install_mode : 'rw-r--r--',
configuration : { configuration : {
'localstatedir': localstatedir, 'localstatedir' : localstatedir,
}, },
) )
endforeach endforeach

View file

@ -1,22 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -d out ]]; then
echo "run prepare-installer-for-github-actions first"
exit 1
fi
cd out
PORT=${PORT:-8126}
nohup python -m http.server "$PORT" >/dev/null 2>&1 &
pid=$!
while ! curl -s "http://localhost:$PORT"; do
sleep 1
if ! kill -0 $pid; then
echo "Failed to start http server"
exit 1
fi
done
echo 'To install nix, run the following command:'
echo "sh <(curl http://localhost:$PORT/install) --tarball-url-prefix http://localhost:$PORT"

View file

@ -1,4 +1,5 @@
project('nix-external-api-docs', project(
'nix-external-api-docs',
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',
@ -10,7 +11,7 @@ doxygen_cfg = configure_file(
input : 'doxygen.cfg.in', input : 'doxygen.cfg.in',
output : 'doxygen.cfg', output : 'doxygen.cfg',
configuration : { configuration : {
'PROJECT_NUMBER': meson.project_version(), 'PROJECT_NUMBER' : meson.project_version(),
'OUTPUT_DIRECTORY' : meson.current_build_dir(), 'OUTPUT_DIRECTORY' : meson.current_build_dir(),
'src' : fs.parent(fs.parent(meson.project_source_root())), 'src' : fs.parent(fs.parent(meson.project_source_root())),
}, },
@ -20,7 +21,7 @@ doxygen = find_program('doxygen', native : true, required : true)
custom_target( custom_target(
'external-api-docs', 'external-api-docs',
command : [ doxygen , doxygen_cfg ], command : [ doxygen, doxygen_cfg ],
input : [ input : [
doxygen_cfg, doxygen_cfg,
], ],

View file

@ -57,9 +57,7 @@ INPUT = \
@src@/libutil/args \ @src@/libutil/args \
@src@/libutil-tests \ @src@/libutil-tests \
@src@/libutil-test-support/tests \ @src@/libutil-test-support/tests \
@src@/nix \ @src@/nix
@src@/nix-env \
@src@/nix-store
# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names # If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
# in the source code. If set to NO, only conditional compilation will be # in the source code. If set to NO, only conditional compilation will be

View file

@ -1,4 +1,5 @@
project('nix-internal-api-docs', project(
'nix-internal-api-docs',
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',
@ -10,7 +11,7 @@ doxygen_cfg = configure_file(
input : 'doxygen.cfg.in', input : 'doxygen.cfg.in',
output : 'doxygen.cfg', output : 'doxygen.cfg',
configuration : { configuration : {
'PROJECT_NUMBER': meson.project_version(), 'PROJECT_NUMBER' : meson.project_version(),
'OUTPUT_DIRECTORY' : meson.current_build_dir(), 'OUTPUT_DIRECTORY' : meson.current_build_dir(),
'BUILD_ROOT' : meson.build_root(), 'BUILD_ROOT' : meson.build_root(),
'src' : fs.parent(fs.parent(meson.project_source_root())) / 'src', 'src' : fs.parent(fs.parent(meson.project_source_root())) / 'src',
@ -21,7 +22,7 @@ doxygen = find_program('doxygen', native : true, required : true)
custom_target( custom_target(
'internal-api-docs', 'internal-api-docs',
command : [ doxygen , doxygen_cfg ], command : [ doxygen, doxygen_cfg ],
input : [ input : [
doxygen_cfg, doxygen_cfg,
], ],

View file

@ -10,23 +10,13 @@
namespace nix { namespace nix {
// Custom implementation to avoid `ref` ptr equality // Custom implementation to avoid `ref` ptr equality
GENERATE_CMP_EXT( GENERATE_CMP_EXT(, std::strong_ordering, SingleBuiltPathBuilt, *me->drvPath, me->output);
,
std::strong_ordering,
SingleBuiltPathBuilt,
*me->drvPath,
me->output);
// Custom implementation to avoid `ref` ptr equality // Custom implementation to avoid `ref` ptr equality
// TODO no `GENERATE_CMP_EXT` because no `std::set::operator<=>` on // TODO no `GENERATE_CMP_EXT` because no `std::set::operator<=>` on
// Darwin, per header. // Darwin, per header.
GENERATE_EQUAL( GENERATE_EQUAL(, BuiltPathBuilt ::, BuiltPathBuilt, *me->drvPath, me->outputs);
,
BuiltPathBuilt ::,
BuiltPathBuilt,
*me->drvPath,
me->outputs);
StorePath SingleBuiltPath::outPath() const StorePath SingleBuiltPath::outPath() const
{ {
@ -34,8 +24,8 @@ StorePath SingleBuiltPath::outPath() const
overloaded{ overloaded{
[](const SingleBuiltPath::Opaque & p) { return p.path; }, [](const SingleBuiltPath::Opaque & p) { return p.path; },
[](const SingleBuiltPath::Built & b) { return b.output.second; }, [](const SingleBuiltPath::Built & b) { return b.output.second; },
}, raw() },
); raw());
} }
StorePathSet BuiltPath::outPaths() const StorePathSet BuiltPath::outPaths() const
@ -49,13 +39,13 @@ StorePathSet BuiltPath::outPaths() const
res.insert(path); res.insert(path);
return res; return res;
}, },
}, raw() },
); raw());
} }
SingleDerivedPath::Built SingleBuiltPath::Built::discardOutputPath() const SingleDerivedPath::Built SingleBuiltPath::Built::discardOutputPath() const
{ {
return SingleDerivedPath::Built { return SingleDerivedPath::Built{
.drvPath = make_ref<SingleDerivedPath>(drvPath->discardOutputPath()), .drvPath = make_ref<SingleDerivedPath>(drvPath->discardOutputPath()),
.output = output.first, .output = output.first,
}; };
@ -65,14 +55,10 @@ SingleDerivedPath SingleBuiltPath::discardOutputPath() const
{ {
return std::visit( return std::visit(
overloaded{ overloaded{
[](const SingleBuiltPath::Opaque & p) -> SingleDerivedPath { [](const SingleBuiltPath::Opaque & p) -> SingleDerivedPath { return p; },
return p; [](const SingleBuiltPath::Built & b) -> SingleDerivedPath { return b.discardOutputPath(); },
}, },
[](const SingleBuiltPath::Built & b) -> SingleDerivedPath { raw());
return b.discardOutputPath();
},
}, raw()
);
} }
nlohmann::json BuiltPath::Built::toJSON(const StoreDirConfig & store) const nlohmann::json BuiltPath::Built::toJSON(const StoreDirConfig & store) const
@ -97,16 +83,12 @@ nlohmann::json SingleBuiltPath::Built::toJSON(const StoreDirConfig & store) cons
nlohmann::json SingleBuiltPath::toJSON(const StoreDirConfig & store) const nlohmann::json SingleBuiltPath::toJSON(const StoreDirConfig & store) const
{ {
return std::visit([&](const auto & buildable) { return std::visit([&](const auto & buildable) { return buildable.toJSON(store); }, raw());
return buildable.toJSON(store);
}, raw());
} }
nlohmann::json BuiltPath::toJSON(const StoreDirConfig & store) const nlohmann::json BuiltPath::toJSON(const StoreDirConfig & store) const
{ {
return std::visit([&](const auto & buildable) { return std::visit([&](const auto & buildable) { return buildable.toJSON(store); }, raw());
return buildable.toJSON(store);
}, raw());
} }
RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const
@ -116,20 +98,18 @@ RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const
overloaded{ overloaded{
[&](const BuiltPath::Opaque & p) { res.insert(p.path); }, [&](const BuiltPath::Opaque & p) { res.insert(p.path); },
[&](const BuiltPath::Built & p) { [&](const BuiltPath::Built & p) {
auto drvHashes = auto drvHashes = staticOutputHashes(store, store.readDerivation(p.drvPath->outPath()));
staticOutputHashes(store, store.readDerivation(p.drvPath->outPath())); for (auto & [outputName, outputPath] : p.outputs) {
for (auto& [outputName, outputPath] : p.outputs) { if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
if (experimentalFeatureSettings.isEnabled(
Xp::CaDerivations)) {
auto drvOutput = get(drvHashes, outputName); auto drvOutput = get(drvHashes, outputName);
if (!drvOutput) if (!drvOutput)
throw Error( throw Error(
"the derivation '%s' has unrealised output '%s' (derived-path.cc/toRealisedPaths)", "the derivation '%s' has unrealised output '%s' (derived-path.cc/toRealisedPaths)",
store.printStorePath(p.drvPath->outPath()), outputName); store.printStorePath(p.drvPath->outPath()),
auto thisRealisation = store.queryRealisation( outputName);
DrvOutput{*drvOutput, outputName}); auto thisRealisation = store.queryRealisation(DrvOutput{*drvOutput, outputName});
assert(thisRealisation); // Weve built it, so we must assert(thisRealisation); // Weve built it, so we must
// have the realisation // have the realisation
res.insert(*thisRealisation); res.insert(*thisRealisation);
} else { } else {
res.insert(outputPath); res.insert(outputPath);
@ -141,4 +121,4 @@ RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const
return res; return res;
} }
} } // namespace nix

View file

@ -8,4 +8,4 @@ void InstallableValueCommand::run(ref<Store> store, ref<Installable> installable
run(store, installableValue); run(store, installableValue);
} }
} } // namespace nix

View file

@ -402,4 +402,4 @@ void MixOutLinkBase::createOutLinksMaybe(const std::vector<BuiltPathWithResult>
createOutLinks(outLink, toBuiltPaths(buildables), *store2); createOutLinks(outLink, toBuiltPaths(buildables), *store2);
} }
} } // namespace nix

View file

@ -15,15 +15,15 @@
#include "nix/fetchers/fetch-to-store.hh" #include "nix/fetchers/fetch-to-store.hh"
#include "nix/cmd/compatibility-settings.hh" #include "nix/cmd/compatibility-settings.hh"
#include "nix/expr/eval-settings.hh" #include "nix/expr/eval-settings.hh"
#include "nix/store/globals.hh"
namespace nix { namespace nix {
fetchers::Settings fetchSettings; fetchers::Settings fetchSettings;
static GlobalConfig::Register rFetchSettings(&fetchSettings); static GlobalConfig::Register rFetchSettings(&fetchSettings);
EvalSettings evalSettings { EvalSettings evalSettings{
settings.readOnlyMode, settings.readOnlyMode,
{ {
{ {
@ -31,7 +31,7 @@ EvalSettings evalSettings {
[](EvalState & state, std::string_view rest) { [](EvalState & state, std::string_view rest) {
experimentalFeatureSettings.require(Xp::Flakes); experimentalFeatureSettings.require(Xp::Flakes);
// FIXME `parseFlakeRef` should take a `std::string_view`. // FIXME `parseFlakeRef` should take a `std::string_view`.
auto flakeRef = parseFlakeRef(fetchSettings, std::string { rest }, {}, true, false); auto flakeRef = parseFlakeRef(fetchSettings, std::string{rest}, {}, true, false);
debug("fetching flake search path element '%s''", rest); debug("fetching flake search path element '%s''", rest);
auto [accessor, lockedRef] = flakeRef.resolve(state.store).lazyFetch(state.store); auto [accessor, lockedRef] = flakeRef.resolve(state.store).lazyFetch(state.store);
auto storePath = nix::fetchToStore( auto storePath = nix::fetchToStore(
@ -49,17 +49,14 @@ EvalSettings evalSettings {
static GlobalConfig::Register rEvalSettings(&evalSettings); static GlobalConfig::Register rEvalSettings(&evalSettings);
flake::Settings flakeSettings; flake::Settings flakeSettings;
static GlobalConfig::Register rFlakeSettings(&flakeSettings); static GlobalConfig::Register rFlakeSettings(&flakeSettings);
CompatibilitySettings compatibilitySettings{};
CompatibilitySettings compatibilitySettings {};
static GlobalConfig::Register rCompatibilitySettings(&compatibilitySettings); static GlobalConfig::Register rCompatibilitySettings(&compatibilitySettings);
MixEvalArgs::MixEvalArgs() MixEvalArgs::MixEvalArgs()
{ {
addFlag({ addFlag({
@ -67,7 +64,9 @@ MixEvalArgs::MixEvalArgs()
.description = "Pass the value *expr* as the argument *name* to Nix functions.", .description = "Pass the value *expr* as the argument *name* to Nix functions.",
.category = category, .category = category,
.labels = {"name", "expr"}, .labels = {"name", "expr"},
.handler = {[&](std::string name, std::string expr) { autoArgs.insert_or_assign(name, AutoArg{AutoArgExpr{expr}}); }}, .handler = {[&](std::string name, std::string expr) {
autoArgs.insert_or_assign(name, AutoArg{AutoArgExpr{expr}});
}},
}); });
addFlag({ addFlag({
@ -75,7 +74,9 @@ MixEvalArgs::MixEvalArgs()
.description = "Pass the string *string* as the argument *name* to Nix functions.", .description = "Pass the string *string* as the argument *name* to Nix functions.",
.category = category, .category = category,
.labels = {"name", "string"}, .labels = {"name", "string"},
.handler = {[&](std::string name, std::string s) { autoArgs.insert_or_assign(name, AutoArg{AutoArgString{s}}); }}, .handler = {[&](std::string name, std::string s) {
autoArgs.insert_or_assign(name, AutoArg{AutoArgString{s}});
}},
}); });
addFlag({ addFlag({
@ -83,7 +84,9 @@ MixEvalArgs::MixEvalArgs()
.description = "Pass the contents of file *path* as the argument *name* to Nix functions.", .description = "Pass the contents of file *path* as the argument *name* to Nix functions.",
.category = category, .category = category,
.labels = {"name", "path"}, .labels = {"name", "path"},
.handler = {[&](std::string name, std::string path) { autoArgs.insert_or_assign(name, AutoArg{AutoArgFile{path}}); }}, .handler = {[&](std::string name, std::string path) {
autoArgs.insert_or_assign(name, AutoArg{AutoArgFile{path}});
}},
.completer = completePath, .completer = completePath,
}); });
@ -107,18 +110,14 @@ MixEvalArgs::MixEvalArgs()
)", )",
.category = category, .category = category,
.labels = {"path"}, .labels = {"path"},
.handler = {[&](std::string s) { .handler = {[&](std::string s) { lookupPath.elements.emplace_back(LookupPath::Elem::parse(s)); }},
lookupPath.elements.emplace_back(LookupPath::Elem::parse(s));
}},
}); });
addFlag({ addFlag({
.longName = "impure", .longName = "impure",
.description = "Allow access to mutable paths and repositories.", .description = "Allow access to mutable paths and repositories.",
.category = category, .category = category,
.handler = {[&]() { .handler = {[&]() { evalSettings.pureEval = false; }},
evalSettings.pureEval = false;
}},
}); });
addFlag({ addFlag({
@ -130,7 +129,8 @@ MixEvalArgs::MixEvalArgs()
auto from = parseFlakeRef(fetchSettings, _from, std::filesystem::current_path().string()); auto from = parseFlakeRef(fetchSettings, _from, std::filesystem::current_path().string());
auto to = parseFlakeRef(fetchSettings, _to, std::filesystem::current_path().string()); auto to = parseFlakeRef(fetchSettings, _to, std::filesystem::current_path().string());
fetchers::Attrs extraAttrs; fetchers::Attrs extraAttrs;
if (to.subdir != "") extraAttrs["dir"] = to.subdir; if (to.subdir != "")
extraAttrs["dir"] = to.subdir;
fetchers::overrideRegistry(from.input, to.input, extraAttrs); fetchers::overrideRegistry(from.input, to.input, extraAttrs);
}}, }},
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) { .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
@ -141,7 +141,7 @@ MixEvalArgs::MixEvalArgs()
addFlag({ addFlag({
.longName = "eval-store", .longName = "eval-store",
.description = .description =
R"( R"(
The [URL of the Nix store](@docroot@/store/types/index.md#store-url-format) The [URL of the Nix store](@docroot@/store/types/index.md#store-url-format)
to use for evaluation, i.e. to store derivations (`.drv` files) and inputs referenced by them. to use for evaluation, i.e. to store derivations (`.drv` files) and inputs referenced by them.
)", )",
@ -156,20 +156,21 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state)
auto res = state.buildBindings(autoArgs.size()); auto res = state.buildBindings(autoArgs.size());
for (auto & [name, arg] : autoArgs) { for (auto & [name, arg] : autoArgs) {
auto v = state.allocValue(); auto v = state.allocValue();
std::visit(overloaded { std::visit(
[&](const AutoArgExpr & arg) { overloaded{
state.mkThunk_(*v, state.parseExprFromString(arg.expr, compatibilitySettings.nixShellShebangArgumentsRelativeToScript ? state.rootPath(absPath(getCommandBaseDir())) : state.rootPath("."))); [&](const AutoArgExpr & arg) {
}, state.mkThunk_(
[&](const AutoArgString & arg) { *v,
v->mkString(arg.s); state.parseExprFromString(
}, arg.expr,
[&](const AutoArgFile & arg) { compatibilitySettings.nixShellShebangArgumentsRelativeToScript
v->mkString(readFile(arg.path.string())); ? state.rootPath(absPath(getCommandBaseDir()))
}, : state.rootPath(".")));
[&](const AutoArgStdin & arg) { },
v->mkString(readFile(STDIN_FILENO)); [&](const AutoArgString & arg) { v->mkString(arg.s); },
} [&](const AutoArgFile & arg) { v->mkString(readFile(arg.path.string())); },
}, arg); [&](const AutoArgStdin & arg) { v->mkString(readFile(STDIN_FILENO)); }},
arg);
res.insert(state.symbols.create(name), v); res.insert(state.symbols.create(name), v);
} }
return res.finish(); return res.finish();
@ -178,15 +179,8 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state)
SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * baseDir) SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * baseDir)
{ {
if (EvalSettings::isPseudoUrl(s)) { if (EvalSettings::isPseudoUrl(s)) {
auto accessor = fetchers::downloadTarball( auto accessor = fetchers::downloadTarball(state.store, state.fetchSettings, EvalSettings::resolvePseudoUrl(s));
state.store, auto storePath = fetchToStore(state.fetchSettings, *state.store, SourcePath(accessor), FetchMode::Copy);
state.fetchSettings,
EvalSettings::resolvePseudoUrl(s));
auto storePath = fetchToStore(
state.fetchSettings,
*state.store,
SourcePath(accessor),
FetchMode::Copy);
return state.storePath(storePath); return state.storePath(storePath);
} }
@ -195,11 +189,7 @@ SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * bas
auto flakeRef = parseFlakeRef(fetchSettings, std::string(s.substr(6)), {}, true, false); auto flakeRef = parseFlakeRef(fetchSettings, std::string(s.substr(6)), {}, true, false);
auto [accessor, lockedRef] = flakeRef.resolve(state.store).lazyFetch(state.store); auto [accessor, lockedRef] = flakeRef.resolve(state.store).lazyFetch(state.store);
auto storePath = nix::fetchToStore( auto storePath = nix::fetchToStore(
state.fetchSettings, state.fetchSettings, *state.store, SourcePath(accessor), FetchMode::Copy, lockedRef.input.getName());
*state.store,
SourcePath(accessor),
FetchMode::Copy,
lockedRef.input.getName());
state.allowPath(storePath); state.allowPath(storePath);
return state.storePath(storePath); return state.storePath(storePath);
} }
@ -213,4 +203,4 @@ SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * bas
return state.rootPath(baseDir ? absPath(s, *baseDir) : absPath(s)); return state.rootPath(baseDir ? absPath(s, *baseDir) : absPath(s));
} }
} } // namespace nix

View file

@ -11,14 +11,12 @@ Strings editorFor(const SourcePath & file, uint32_t line)
throw Error("cannot open '%s' in an editor because it has no physical path", file); throw Error("cannot open '%s' in an editor because it has no physical path", file);
auto editor = getEnv("EDITOR").value_or("cat"); auto editor = getEnv("EDITOR").value_or("cat");
auto args = tokenizeString<Strings>(editor); auto args = tokenizeString<Strings>(editor);
if (line > 0 && ( if (line > 0
editor.find("emacs") != std::string::npos || && (editor.find("emacs") != std::string::npos || editor.find("nano") != std::string::npos
editor.find("nano") != std::string::npos || || editor.find("vim") != std::string::npos || editor.find("kak") != std::string::npos))
editor.find("vim") != std::string::npos ||
editor.find("kak") != std::string::npos))
args.push_back(fmt("+%d", line)); args.push_back(fmt("+%d", line));
args.push_back(path->string()); args.push_back(path->string());
return args; return args;
} }
} } // namespace nix

View file

@ -8,7 +8,8 @@ namespace nix {
struct SingleBuiltPath; struct SingleBuiltPath;
struct SingleBuiltPathBuilt { struct SingleBuiltPathBuilt
{
ref<SingleBuiltPath> drvPath; ref<SingleBuiltPath> drvPath;
std::pair<std::string, StorePath> output; std::pair<std::string, StorePath> output;
@ -18,26 +19,25 @@ struct SingleBuiltPathBuilt {
static SingleBuiltPathBuilt parse(const StoreDirConfig & store, std::string_view, std::string_view); static SingleBuiltPathBuilt parse(const StoreDirConfig & store, std::string_view, std::string_view);
nlohmann::json toJSON(const StoreDirConfig & store) const; nlohmann::json toJSON(const StoreDirConfig & store) const;
bool operator ==(const SingleBuiltPathBuilt &) const noexcept; bool operator==(const SingleBuiltPathBuilt &) const noexcept;
std::strong_ordering operator <=>(const SingleBuiltPathBuilt &) const noexcept; std::strong_ordering operator<=>(const SingleBuiltPathBuilt &) const noexcept;
}; };
using _SingleBuiltPathRaw = std::variant< using _SingleBuiltPathRaw = std::variant<DerivedPathOpaque, SingleBuiltPathBuilt>;
DerivedPathOpaque,
SingleBuiltPathBuilt
>;
struct SingleBuiltPath : _SingleBuiltPathRaw { struct SingleBuiltPath : _SingleBuiltPathRaw
{
using Raw = _SingleBuiltPathRaw; using Raw = _SingleBuiltPathRaw;
using Raw::Raw; using Raw::Raw;
using Opaque = DerivedPathOpaque; using Opaque = DerivedPathOpaque;
using Built = SingleBuiltPathBuilt; using Built = SingleBuiltPathBuilt;
bool operator == (const SingleBuiltPath &) const = default; bool operator==(const SingleBuiltPath &) const = default;
auto operator <=> (const SingleBuiltPath &) const = default; auto operator<=>(const SingleBuiltPath &) const = default;
inline const Raw & raw() const { inline const Raw & raw() const
{
return static_cast<const Raw &>(*this); return static_cast<const Raw &>(*this);
} }
@ -51,7 +51,7 @@ struct SingleBuiltPath : _SingleBuiltPathRaw {
static inline ref<SingleBuiltPath> staticDrv(StorePath drvPath) static inline ref<SingleBuiltPath> staticDrv(StorePath drvPath)
{ {
return make_ref<SingleBuiltPath>(SingleBuiltPath::Opaque { drvPath }); return make_ref<SingleBuiltPath>(SingleBuiltPath::Opaque{drvPath});
} }
/** /**
@ -59,40 +59,41 @@ static inline ref<SingleBuiltPath> staticDrv(StorePath drvPath)
* *
* See 'BuiltPath' for more an explanation. * See 'BuiltPath' for more an explanation.
*/ */
struct BuiltPathBuilt { struct BuiltPathBuilt
{
ref<SingleBuiltPath> drvPath; ref<SingleBuiltPath> drvPath;
std::map<std::string, StorePath> outputs; std::map<std::string, StorePath> outputs;
bool operator == (const BuiltPathBuilt &) const noexcept; bool operator==(const BuiltPathBuilt &) const noexcept;
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet. // TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
//std::strong_ordering operator <=> (const BuiltPathBuilt &) const noexcept; // std::strong_ordering operator <=> (const BuiltPathBuilt &) const noexcept;
std::string to_string(const StoreDirConfig & store) const; std::string to_string(const StoreDirConfig & store) const;
static BuiltPathBuilt parse(const StoreDirConfig & store, std::string_view, std::string_view); static BuiltPathBuilt parse(const StoreDirConfig & store, std::string_view, std::string_view);
nlohmann::json toJSON(const StoreDirConfig & store) const; nlohmann::json toJSON(const StoreDirConfig & store) const;
}; };
using _BuiltPathRaw = std::variant< using _BuiltPathRaw = std::variant<DerivedPath::Opaque, BuiltPathBuilt>;
DerivedPath::Opaque,
BuiltPathBuilt
>;
/** /**
* A built path. Similar to a DerivedPath, but enriched with the corresponding * A built path. Similar to a DerivedPath, but enriched with the corresponding
* output path(s). * output path(s).
*/ */
struct BuiltPath : _BuiltPathRaw { struct BuiltPath : _BuiltPathRaw
{
using Raw = _BuiltPathRaw; using Raw = _BuiltPathRaw;
using Raw::Raw; using Raw::Raw;
using Opaque = DerivedPathOpaque; using Opaque = DerivedPathOpaque;
using Built = BuiltPathBuilt; using Built = BuiltPathBuilt;
bool operator == (const BuiltPath &) const = default; bool operator==(const BuiltPath &) const = default;
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
//auto operator <=> (const BuiltPath &) const = default;
inline const Raw & raw() const { // TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
// auto operator <=> (const BuiltPath &) const = default;
inline const Raw & raw() const
{
return static_cast<const Raw &>(*this); return static_cast<const Raw &>(*this);
} }
@ -104,4 +105,4 @@ struct BuiltPath : _BuiltPathRaw {
typedef std::vector<BuiltPath> BuiltPaths; typedef std::vector<BuiltPath> BuiltPaths;
} } // namespace nix

View file

@ -20,4 +20,4 @@ struct InstallableValueCommand : InstallableCommand
void run(ref<Store> store, ref<Installable> installable) override; void run(ref<Store> store, ref<Installable> installable) override;
}; };
} } // namespace nix

View file

@ -13,13 +13,17 @@ namespace nix {
class Store; class Store;
namespace fetchers { struct Settings; } namespace fetchers {
struct Settings;
}
class EvalState; class EvalState;
struct CompatibilitySettings; struct CompatibilitySettings;
class Bindings; class Bindings;
namespace flake { struct Settings; } namespace flake {
struct Settings;
}
/** /**
* @todo Get rid of global settings variables * @todo Get rid of global settings variables
@ -54,10 +58,23 @@ struct MixEvalArgs : virtual Args, virtual MixRepair
std::optional<std::string> evalStoreUrl; std::optional<std::string> evalStoreUrl;
private: private:
struct AutoArgExpr { std::string expr; }; struct AutoArgExpr
struct AutoArgString { std::string s; }; {
struct AutoArgFile { std::filesystem::path path; }; std::string expr;
struct AutoArgStdin { }; };
struct AutoArgString
{
std::string s;
};
struct AutoArgFile
{
std::filesystem::path path;
};
struct AutoArgStdin
{};
using AutoArg = std::variant<AutoArgExpr, AutoArgString, AutoArgFile, AutoArgStdin>; using AutoArg = std::variant<AutoArgExpr, AutoArgString, AutoArgFile, AutoArgStdin>;
@ -65,8 +82,8 @@ private:
}; };
/** /**
* @param baseDir Optional [base directory](https://nixos.org/manual/nix/unstable/glossary#gloss-base-directory) * @param baseDir Optional [base directory](https://nix.dev/manual/nix/development/glossary#gloss-base-directory)
*/ */
SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * baseDir = nullptr); SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * baseDir = nullptr);
} } // namespace nix

View file

@ -33,4 +33,4 @@ struct CompatibilitySettings : public Config
)"}; )"};
}; };
}; }; // namespace nix

View file

@ -12,4 +12,4 @@ namespace nix {
*/ */
Strings editorFor(const SourcePath & file, uint32_t line); Strings editorFor(const SourcePath & file, uint32_t line);
} } // namespace nix

View file

@ -39,7 +39,10 @@ class InstallableAttrPath : public InstallableValue
const std::string & attrPath, const std::string & attrPath,
ExtendedOutputsSpec extendedOutputsSpec); ExtendedOutputsSpec extendedOutputsSpec);
std::string what() const override { return attrPath; }; std::string what() const override
{
return attrPath;
};
std::pair<Value *, PosIdx> toValue(EvalState & state) override; std::pair<Value *, PosIdx> toValue(EvalState & state) override;
@ -55,4 +58,4 @@ public:
ExtendedOutputsSpec extendedOutputsSpec); ExtendedOutputsSpec extendedOutputsSpec);
}; };
} } // namespace nix

View file

@ -11,8 +11,10 @@ struct InstallableDerivedPath : Installable
DerivedPath derivedPath; DerivedPath derivedPath;
InstallableDerivedPath(ref<Store> store, DerivedPath && derivedPath) InstallableDerivedPath(ref<Store> store, DerivedPath && derivedPath)
: store(store), derivedPath(std::move(derivedPath)) : store(store)
{ } , derivedPath(std::move(derivedPath))
{
}
std::string what() const override; std::string what() const override;
@ -20,10 +22,8 @@ struct InstallableDerivedPath : Installable
std::optional<StorePath> getStorePath() override; std::optional<StorePath> getStorePath() override;
static InstallableDerivedPath parse( static InstallableDerivedPath
ref<Store> store, parse(ref<Store> store, std::string_view prefix, ExtendedOutputsSpec extendedOutputsSpec);
std::string_view prefix,
ExtendedOutputsSpec extendedOutputsSpec);
}; };
} } // namespace nix

View file

@ -18,7 +18,8 @@ struct ExtraPathInfoFlake : ExtraPathInfoValue
/** /**
* Extra struct to get around C++ designated initializer limitations * Extra struct to get around C++ designated initializer limitations
*/ */
struct Flake { struct Flake
{
FlakeRef originalRef; FlakeRef originalRef;
FlakeRef lockedRef; FlakeRef lockedRef;
}; };
@ -26,8 +27,10 @@ struct ExtraPathInfoFlake : ExtraPathInfoValue
Flake flake; Flake flake;
ExtraPathInfoFlake(Value && v, Flake && f) ExtraPathInfoFlake(Value && v, Flake && f)
: ExtraPathInfoValue(std::move(v)), flake(std::move(f)) : ExtraPathInfoValue(std::move(v))
{ } , flake(std::move(f))
{
}
}; };
struct InstallableFlake : InstallableValue struct InstallableFlake : InstallableValue
@ -49,7 +52,10 @@ struct InstallableFlake : InstallableValue
Strings prefixes, Strings prefixes,
const flake::LockFlags & lockFlags); const flake::LockFlags & lockFlags);
std::string what() const override { return flakeRef.to_string() + "#" + *attrPaths.begin(); } std::string what() const override
{
return flakeRef.to_string() + "#" + *attrPaths.begin();
}
std::vector<std::string> getActualAttrPaths(); std::vector<std::string> getActualAttrPaths();
@ -61,8 +67,7 @@ struct InstallableFlake : InstallableValue
* Get a cursor to every attrpath in getActualAttrPaths() that * Get a cursor to every attrpath in getActualAttrPaths() that
* exists. However if none exists, throw an exception. * exists. However if none exists, throw an exception.
*/ */
std::vector<ref<eval_cache::AttrCursor>> std::vector<ref<eval_cache::AttrCursor>> getCursors(EvalState & state) override;
getCursors(EvalState & state) override;
std::shared_ptr<flake::LockedFlake> getLockedFlake() const; std::shared_ptr<flake::LockedFlake> getLockedFlake() const;
@ -79,11 +84,9 @@ struct InstallableFlake : InstallableValue
*/ */
static inline FlakeRef defaultNixpkgsFlakeRef() static inline FlakeRef defaultNixpkgsFlakeRef()
{ {
return FlakeRef::fromAttrs(fetchSettings, {{"type","indirect"}, {"id", "nixpkgs"}}); return FlakeRef::fromAttrs(fetchSettings, {{"type", "indirect"}, {"id", "nixpkgs"}});
} }
ref<eval_cache::EvalCache> openEvalCache( ref<eval_cache::EvalCache> openEvalCache(EvalState & state, std::shared_ptr<flake::LockedFlake> lockedFlake);
EvalState & state,
std::shared_ptr<flake::LockedFlake> lockedFlake);
} } // namespace nix

View file

@ -9,7 +9,10 @@ namespace nix {
struct PackageInfo; struct PackageInfo;
struct SourceExprCommand; struct SourceExprCommand;
namespace eval_cache { class EvalCache; class AttrCursor; } namespace eval_cache {
class EvalCache;
class AttrCursor;
} // namespace eval_cache
struct App struct App
{ {
@ -37,7 +40,8 @@ struct ExtraPathInfoValue : ExtraPathInfo
/** /**
* Extra struct to get around C++ designated initializer limitations * Extra struct to get around C++ designated initializer limitations
*/ */
struct Value { struct Value
{
/** /**
* An optional priority for use with "build envs". See Package * An optional priority for use with "build envs". See Package
*/ */
@ -61,7 +65,8 @@ struct ExtraPathInfoValue : ExtraPathInfo
ExtraPathInfoValue(Value && v) ExtraPathInfoValue(Value && v)
: value(std::move(v)) : value(std::move(v))
{ } {
}
virtual ~ExtraPathInfoValue() = default; virtual ~ExtraPathInfoValue() = default;
}; };
@ -74,9 +79,12 @@ struct InstallableValue : Installable
{ {
ref<EvalState> state; ref<EvalState> state;
InstallableValue(ref<EvalState> state) : state(state) {} InstallableValue(ref<EvalState> state)
: state(state)
{
}
virtual ~InstallableValue() { } virtual ~InstallableValue() {}
virtual std::pair<Value *, PosIdx> toValue(EvalState & state) = 0; virtual std::pair<Value *, PosIdx> toValue(EvalState & state) = 0;
@ -85,15 +93,13 @@ struct InstallableValue : Installable
* However if none exists, throw exception instead of returning * However if none exists, throw exception instead of returning
* empty vector. * empty vector.
*/ */
virtual std::vector<ref<eval_cache::AttrCursor>> virtual std::vector<ref<eval_cache::AttrCursor>> getCursors(EvalState & state);
getCursors(EvalState & state);
/** /**
* Get the first and most preferred cursor this Installable could * Get the first and most preferred cursor this Installable could
* refer to, or throw an exception if none exists. * refer to, or throw an exception if none exists.
*/ */
virtual ref<eval_cache::AttrCursor> virtual ref<eval_cache::AttrCursor> getCursor(EvalState & state);
getCursor(EvalState & state);
UnresolvedApp toApp(EvalState & state); UnresolvedApp toApp(EvalState & state);
@ -116,7 +122,8 @@ protected:
* @result A derived path (with empty info, for now) if the value * @result A derived path (with empty info, for now) if the value
* matched the above criteria. * matched the above criteria.
*/ */
std::optional<DerivedPathWithInfo> trySinglePathToDerivedPaths(Value & v, const PosIdx pos, std::string_view errorCtx); std::optional<DerivedPathWithInfo>
trySinglePathToDerivedPaths(Value & v, const PosIdx pos, std::string_view errorCtx);
}; };
} } // namespace nix

View file

@ -112,7 +112,7 @@ typedef std::vector<ref<Installable>> Installables;
*/ */
struct Installable struct Installable
{ {
virtual ~Installable() { } virtual ~Installable() {}
/** /**
* What Installable is this? * What Installable is this?
@ -168,37 +168,19 @@ struct Installable
BuildMode bMode = bmNormal); BuildMode bMode = bmNormal);
static std::set<StorePath> toStorePathSet( static std::set<StorePath> toStorePathSet(
ref<Store> evalStore, ref<Store> evalStore, ref<Store> store, Realise mode, OperateOn operateOn, const Installables & installables);
ref<Store> store,
Realise mode,
OperateOn operateOn,
const Installables & installables);
static std::vector<StorePath> toStorePaths( static std::vector<StorePath> toStorePaths(
ref<Store> evalStore, ref<Store> evalStore, ref<Store> store, Realise mode, OperateOn operateOn, const Installables & installables);
ref<Store> store,
Realise mode,
OperateOn operateOn,
const Installables & installables);
static StorePath toStorePath( static StorePath toStorePath(
ref<Store> evalStore, ref<Store> evalStore, ref<Store> store, Realise mode, OperateOn operateOn, ref<Installable> installable);
ref<Store> store,
Realise mode,
OperateOn operateOn,
ref<Installable> installable);
static std::set<StorePath> toDerivations( static std::set<StorePath>
ref<Store> store, toDerivations(ref<Store> store, const Installables & installables, bool useDeriver = false);
const Installables & installables,
bool useDeriver = false);
static BuiltPaths toBuiltPaths( static BuiltPaths toBuiltPaths(
ref<Store> evalStore, ref<Store> evalStore, ref<Store> store, Realise mode, OperateOn operateOn, const Installables & installables);
ref<Store> store,
Realise mode,
OperateOn operateOn,
const Installables & installables);
}; };
} } // namespace nix

View file

@ -7,13 +7,14 @@
namespace nix { namespace nix {
typedef std::function<void(int, char * *)> MainFunction; typedef std::function<void(int, char **)> MainFunction;
struct RegisterLegacyCommand struct RegisterLegacyCommand
{ {
typedef std::map<std::string, MainFunction> Commands; typedef std::map<std::string, MainFunction> Commands;
static Commands & commands() { static Commands & commands()
{
static Commands commands; static Commands commands;
return commands; return commands;
} }
@ -24,4 +25,4 @@ struct RegisterLegacyCommand
} }
}; };
} } // namespace nix

View file

@ -14,4 +14,4 @@ namespace nix {
*/ */
std::string renderMarkdownToTerminal(std::string_view markdown); std::string renderMarkdownToTerminal(std::string_view markdown);
} } // namespace nix

View file

@ -1,6 +1,6 @@
# Public headers directory # Public headers directory
include_dirs = [include_directories('../..')] include_dirs = [ include_directories('../..') ]
headers = files( headers = files(
'built-path.hh', 'built-path.hh',

View file

@ -4,18 +4,22 @@
namespace nix::flag { namespace nix::flag {
Args::Flag hashAlgo(std::string && longName, HashAlgorithm * ha); Args::Flag hashAlgo(std::string && longName, HashAlgorithm * ha);
static inline Args::Flag hashAlgo(HashAlgorithm * ha) static inline Args::Flag hashAlgo(HashAlgorithm * ha)
{ {
return hashAlgo("hash-algo", ha); return hashAlgo("hash-algo", ha);
} }
Args::Flag hashAlgoOpt(std::string && longName, std::optional<HashAlgorithm> * oha); Args::Flag hashAlgoOpt(std::string && longName, std::optional<HashAlgorithm> * oha);
Args::Flag hashFormatWithDefault(std::string && longName, HashFormat * hf); Args::Flag hashFormatWithDefault(std::string && longName, HashFormat * hf);
Args::Flag hashFormatOpt(std::string && longName, std::optional<HashFormat> * ohf); Args::Flag hashFormatOpt(std::string && longName, std::optional<HashFormat> * ohf);
static inline Args::Flag hashAlgoOpt(std::optional<HashAlgorithm> * oha) static inline Args::Flag hashAlgoOpt(std::optional<HashAlgorithm> * oha)
{ {
return hashAlgoOpt("hash-algo", oha); return hashAlgoOpt("hash-algo", oha);
} }
Args::Flag fileIngestionMethod(FileIngestionMethod * method); Args::Flag fileIngestionMethod(FileIngestionMethod * method);
Args::Flag contentAddressMethod(ContentAddressMethod * method); Args::Flag contentAddressMethod(ContentAddressMethod * method);
} } // namespace nix::flag

View file

@ -19,4 +19,4 @@ extern const StringSet networkProxyVariables;
*/ */
bool haveNetworkProxyConnection(); bool haveNetworkProxyConnection();
} } // namespace nix

View file

@ -11,10 +11,11 @@ namespace nix {
namespace detail { namespace detail {
/** Provides the completion hooks for the repl, without exposing its complete /** Provides the completion hooks for the repl, without exposing its complete
* internals. */ * internals. */
struct ReplCompleterMixin { struct ReplCompleterMixin
{
virtual StringSet completePrefix(const std::string & prefix) = 0; virtual StringSet completePrefix(const std::string & prefix) = 0;
}; };
}; }; // namespace detail
enum class ReplPromptType { enum class ReplPromptType {
ReplPrompt, ReplPrompt,
@ -29,7 +30,7 @@ public:
virtual Guard init(detail::ReplCompleterMixin * repl) = 0; virtual Guard init(detail::ReplCompleterMixin * repl) = 0;
/** Returns a boolean of whether the interacter got EOF */ /** Returns a boolean of whether the interacter got EOF */
virtual bool getLine(std::string & input, ReplPromptType promptType) = 0; virtual bool getLine(std::string & input, ReplPromptType promptType) = 0;
virtual ~ReplInteracter(){}; virtual ~ReplInteracter() {};
}; };
class ReadlineLikeInteracter : public virtual ReplInteracter class ReadlineLikeInteracter : public virtual ReplInteracter
@ -40,9 +41,10 @@ public:
: historyFile(historyFile) : historyFile(historyFile)
{ {
} }
virtual Guard init(detail::ReplCompleterMixin * repl) override; virtual Guard init(detail::ReplCompleterMixin * repl) override;
virtual bool getLine(std::string & input, ReplPromptType promptType) override; virtual bool getLine(std::string & input, ReplPromptType promptType) override;
virtual ~ReadlineLikeInteracter() override; virtual ~ReadlineLikeInteracter() override;
}; };
}; }; // namespace nix

View file

@ -12,12 +12,12 @@ struct AbstractNixRepl
AbstractNixRepl(ref<EvalState> state) AbstractNixRepl(ref<EvalState> state)
: state(state) : state(state)
{ } {
}
virtual ~AbstractNixRepl() virtual ~AbstractNixRepl() {}
{ }
typedef std::vector<std::pair<Value*,std::string>> AnnotatedValues; typedef std::vector<std::pair<Value *, std::string>> AnnotatedValues;
using RunNix = void(Path program, const Strings & args, const std::optional<std::string> & input); using RunNix = void(Path program, const Strings & args, const std::optional<std::string> & input);
@ -33,13 +33,11 @@ struct AbstractNixRepl
std::function<AnnotatedValues()> getValues, std::function<AnnotatedValues()> getValues,
RunNix * runNix = nullptr); RunNix * runNix = nullptr);
static ReplExitStatus runSimple( static ReplExitStatus runSimple(ref<EvalState> evalState, const ValMap & extraEnv);
ref<EvalState> evalState,
const ValMap & extraEnv);
virtual void initEnv() = 0; virtual void initEnv() = 0;
virtual ReplExitStatus mainLoop() = 0; virtual ReplExitStatus mainLoop() = 0;
}; };
} } // namespace nix

Some files were not shown because too many files have changed in this diff Show more