diff --git a/.clang-format b/.clang-format
index 4f191fc18..1aadf2cad 100644
--- a/.clang-format
+++ b/.clang-format
@@ -8,7 +8,7 @@ BraceWrapping:
AfterUnion: true
SplitEmptyRecord: false
PointerAlignment: Middle
-FixNamespaceComments: false
+FixNamespaceComments: true
SortIncludes: Never
#IndentPPDirectives: BeforeHash
SpaceAfterCStyleCast: true
@@ -32,3 +32,4 @@ IndentPPDirectives: AfterHash
PPIndentWidth: 2
BinPackArguments: false
BreakBeforeTernaryOperators: true
+SeparateDefinitionBlocks: Always
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 000000000..2bea19741
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -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
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index a5005f8a0..af94c3e9e 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -45,7 +45,7 @@ assignees: ''
- [ ] checked [latest Nix manual] \([source])
- [ ] 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
[open bug issues and pull requests]: https://github.com/NixOS/nix/labels/bug
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index c75a46951..fe9f9dd20 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -30,7 +30,7 @@ assignees: ''
- [ ] checked [latest Nix manual] \([source])
- [ ] 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
[open feature issues and pull requests]: https://github.com/NixOS/nix/labels/feature
diff --git a/.github/ISSUE_TEMPLATE/installer.md b/.github/ISSUE_TEMPLATE/installer.md
index ed5e1ce87..070e0bd9b 100644
--- a/.github/ISSUE_TEMPLATE/installer.md
+++ b/.github/ISSUE_TEMPLATE/installer.md
@@ -38,7 +38,7 @@ assignees: ''
- [ ] checked [latest Nix manual] \([source])
- [ ] 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
[open installer issues and pull requests]: https://github.com/NixOS/nix/labels/installer
diff --git a/.github/ISSUE_TEMPLATE/missing_documentation.md b/.github/ISSUE_TEMPLATE/missing_documentation.md
index 6c334b722..4e05b626d 100644
--- a/.github/ISSUE_TEMPLATE/missing_documentation.md
+++ b/.github/ISSUE_TEMPLATE/missing_documentation.md
@@ -22,7 +22,7 @@ assignees: ''
- [ ] checked [latest Nix manual] \([source])
- [ ] 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
[open documentation issues and pull requests]: https://github.com/NixOS/nix/labels/documentation
diff --git a/.github/actions/install-nix-action/action.yaml b/.github/actions/install-nix-action/action.yaml
new file mode 100644
index 000000000..c299b3956
--- /dev/null
+++ b/.github/actions/install-nix-action/action.yaml
@@ -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 }}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 29cb33f56..e7e103b63 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -2,7 +2,15 @@ name: "CI"
on:
pull_request:
+ merge_group:
push:
+ workflow_dispatch:
+ inputs:
+ dogfood:
+ description: 'Use dogfood Nix build'
+ required: false
+ default: true
+ type: boolean
permissions: read-all
@@ -10,11 +18,16 @@ jobs:
eval:
runs-on: ubuntu-24.04
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
with:
fetch-depth: 0
- - uses: cachix/install-nix-action@v31
- - run: nix --experimental-features 'nix-command flakes' flake show --all-systems --json
+ - uses: ./.github/actions/install-nix-action
+ with:
+ dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
+ extra_nix_config:
+ experimental-features = nix-command flakes
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ - run: nix flake show --all-systems --json
tests:
strategy:
@@ -24,34 +37,69 @@ jobs:
- scenario: on ubuntu
runs-on: ubuntu-24.04
os: linux
+ instrumented: false
+ primary: true
+ stdenv: stdenv
- scenario: on macos
runs-on: macos-14
os: darwin
+ instrumented: false
+ primary: true
+ stdenv: stdenv
+ - scenario: on ubuntu (with sanitizers / coverage)
+ runs-on: ubuntu-24.04
+ os: linux
+ instrumented: true
+ primary: false
+ stdenv: clangStdenv
name: tests ${{ matrix.scenario }}
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 60
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
with:
fetch-depth: 0
- - uses: cachix/install-nix-action@v31
+ - 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' }}
# The sandbox would otherwise be disabled by default on Darwin
- extra_nix_config: |
- sandbox = true
- max-jobs = 1
+ extra_nix_config: "sandbox = true"
- uses: DeterminateSystems/magic-nix-cache-action@main
# Since ubuntu 22.30, unprivileged usernamespaces are no longer allowed to map to the root user:
# https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces
- run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
if: matrix.os == 'linux'
- - run: scripts/build-checks
- - run: scripts/prepare-installer-for-github-actions
+ - name: Run component tests
+ run: |
+ nix build --file ci/gha/tests/wrapper.nix componentTests -L \
+ --arg withInstrumentation ${{ matrix.instrumented }} \
+ --argstr stdenv "${{ matrix.stdenv }}"
+ - name: Run 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
uses: actions/upload-artifact@v4
with:
name: installer-${{matrix.os}}
path: out/*
+ if: ${{ matrix.primary }}
installer_test:
needs: [tests]
@@ -68,19 +116,19 @@ jobs:
name: installer test ${{ matrix.scenario }}
runs-on: ${{ matrix.runs-on }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
- name: Download installer tarball
- uses: actions/download-artifact@v4
+ uses: actions/download-artifact@v5
with:
name: installer-${{matrix.os}}
path: out
- - name: Serving installer
- id: serving_installer
- run: ./scripts/serve-installer-for-github-actions
+ - name: Looking up the installer tarball URL
+ id: installer-tarball-url
+ run: echo "installer-url=file://$GITHUB_WORKSPACE/out" >> "$GITHUB_OUTPUT"
- uses: cachix/install-nix-action@v31
with:
- install_url: 'http://localhost:8126/install'
- install_options: "--tarball-url-prefix http://localhost:8126/"
+ install_url: ${{ format('{0}/install', steps.installer-tarball-url.outputs.installer-url) }}
+ install_options: ${{ format('--tarball-url-prefix {0}', steps.installer-tarball-url.outputs.installer-url) }}
- run: sudo apt install fish zsh
if: matrix.os == 'linux'
- run: brew install fish
@@ -99,17 +147,17 @@ jobs:
check_secrets:
permissions:
contents: none
- name: Check Docker secrets present for installer tests
+ name: Check presence of secrets
runs-on: ubuntu-24.04
outputs:
docker: ${{ steps.secret.outputs.docker }}
steps:
- - name: Check for secrets
+ - name: Check for DockerHub secrets
id: secret
env:
_DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }}
run: |
- echo "::set-output name=docker::${{ env._DOCKER_SECRETS != '' }}"
+ echo "docker=${{ env._DOCKER_SECRETS != '' }}" >> $GITHUB_OUTPUT
docker_push_image:
needs: [tests, vm_tests, check_secrets]
@@ -122,13 +170,7 @@ jobs:
github.ref_name == 'master'
runs-on: ubuntu-24.04
steps:
- - name: Check for secrets
- id: secret
- env:
- _DOCKER_SECRETS: ${{ secrets.DOCKERHUB_USERNAME }}${{ secrets.DOCKERHUB_TOKEN }}
- run: |
- echo "::set-output name=docker::${{ env._DOCKER_SECRETS != '' }}"
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: cachix/install-nix-action@v31
@@ -174,8 +216,13 @@ jobs:
vm_tests:
runs-on: ubuntu-24.04
steps:
- - uses: actions/checkout@v4
- - uses: DeterminateSystems/nix-installer-action@main
+ - uses: actions/checkout@v5
+ - uses: ./.github/actions/install-nix-action
+ with:
+ dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
+ extra_nix_config:
+ experimental-features = nix-command flakes
+ github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: |
nix build -L \
@@ -190,17 +237,45 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: Checkout nix
- uses: actions/checkout@v4
+ uses: actions/checkout@v5
- name: Checkout flake-regressions
- uses: actions/checkout@v4
+ uses: actions/checkout@v5
with:
repository: NixOS/flake-regressions
path: flake-regressions
- name: Checkout flake-regressions-data
- uses: actions/checkout@v4
+ uses: actions/checkout@v5
with:
repository: NixOS/flake-regressions-data
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
- 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
diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml
index 23a5d9e51..16038cb21 100644
--- a/.github/workflows/labels.yml
+++ b/.github/workflows/labels.yml
@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-24.04
if: github.repository_owner == 'NixOS'
steps:
- - uses: actions/labeler@v5
+ - uses: actions/labeler@v6
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
sync-labels: false
diff --git a/.mergify.yml b/.mergify.yml
index 8941711a9..1c220045a 100644
--- a/.mergify.yml
+++ b/.mergify.yml
@@ -150,3 +150,25 @@ pull_request_rules:
labels:
- automatic backport
- merge-queue
+
+ - name: backport patches to 2.30
+ conditions:
+ - label=backport 2.30-maintenance
+ actions:
+ backport:
+ branches:
+ - "2.30-maintenance"
+ labels:
+ - automatic backport
+ - merge-queue
+
+ - name: backport patches to 2.31
+ conditions:
+ - label=backport 2.31-maintenance
+ actions:
+ backport:
+ branches:
+ - "2.31-maintenance"
+ labels:
+ - automatic backport
+ - merge-queue
diff --git a/.version b/.version
index 6a6900382..7cca401c7 100644
--- a/.version
+++ b/.version
@@ -1 +1 @@
-2.30.0
+2.32.0
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index ad8678962..7231730bb 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -89,7 +89,7 @@ Check out the [security policy](https://github.com/NixOS/nix/security/policy).
## Making changes to the Nix manual
-The Nix reference manual is hosted on https://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).
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).
diff --git a/ci/gha/profile-build/default.nix b/ci/gha/profile-build/default.nix
new file mode 100644
index 000000000..2b7261b71
--- /dev/null
+++ b/ci/gha/profile-build/default.nix
@@ -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 "$name
"
+ echo
+ echo '````'
+ ClangBuildAnalyzer --analyze "''\${componentBuildProfiles[$name]}"
+ echo '````'
+ echo
+ echo " "
+ } >> $out
+ done
+ '';
+in
+
+{
+ inherit buildTimeReport;
+ inherit componentDerivationsToProfile;
+}
diff --git a/scripts/build-checks b/ci/gha/tests/build-checks
similarity index 100%
rename from scripts/build-checks
rename to ci/gha/tests/build-checks
diff --git a/ci/gha/tests/default.nix b/ci/gha/tests/default.nix
new file mode 100644
index 000000000..74d0b8c7e
--- /dev/null
+++ b/ci/gha/tests/default.nix
@@ -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;
+ };
+}
diff --git a/scripts/prepare-installer-for-github-actions b/ci/gha/tests/prepare-installer-for-github-actions
similarity index 100%
rename from scripts/prepare-installer-for-github-actions
rename to ci/gha/tests/prepare-installer-for-github-actions
diff --git a/ci/gha/tests/wrapper.nix b/ci/gha/tests/wrapper.nix
new file mode 100644
index 000000000..dc280ebbb
--- /dev/null
+++ b/ci/gha/tests/wrapper.nix
@@ -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;
+ }
+)
diff --git a/doc/manual/meson.build b/doc/manual/meson.build
index 6fe2374a7..2e372dedd 100644
--- a/doc/manual/meson.build
+++ b/doc/manual/meson.build
@@ -1,4 +1,5 @@
-project('nix-manual',
+project(
+ 'nix-manual',
version : files('.version'),
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
@@ -8,43 +9,45 @@ nix = find_program('nix', native : true)
mdbook = find_program('mdbook', native : true)
bash = find_program('bash', native : true)
+rsync = find_program('rsync', required : true, native : true)
pymod = import('python')
python = pymod.find_installation('python3')
nix_env_for_docs = {
- 'HOME': '/dummy',
- 'NIX_CONF_DIR': '/dummy',
- 'NIX_SSL_CERT_FILE': '/dummy/no-ca-bundle.crt',
- 'NIX_STATE_DIR': '/dummy',
- 'NIX_CONFIG': 'cores = 0',
+ 'HOME' : '/dummy',
+ 'NIX_CONF_DIR' : '/dummy',
+ 'NIX_SSL_CERT_FILE' : '/dummy/no-ca-bundle.crt',
+ 'NIX_STATE_DIR' : '/dummy',
+ 'NIX_CONFIG' : 'cores = 0',
}
-nix_for_docs = [nix, '--experimental-features', 'nix-command']
+nix_for_docs = [ nix, '--experimental-features', 'nix-command' ]
nix_eval_for_docs_common = nix_for_docs + [
'eval',
- '-I', 'nix=' + meson.current_source_dir(),
+ '-I',
+ 'nix=' + meson.current_source_dir(),
'--store', 'dummy://',
'--impure',
]
nix_eval_for_docs = nix_eval_for_docs_common + '--raw'
conf_file_json = custom_target(
- command : nix_for_docs + ['config', 'show', '--json'],
+ command : nix_for_docs + [ 'config', 'show', '--json' ],
capture : true,
output : 'conf-file.json',
env : nix_env_for_docs,
)
language_json = custom_target(
- command: [nix, '__dump-language'],
+ command : [ nix, '__dump-language' ],
output : 'language.json',
capture : true,
env : nix_env_for_docs,
)
nix3_cli_json = custom_target(
- command : [nix, '__dump-cli'],
+ command : [ nix, '__dump-cli' ],
capture : true,
output : 'nix.json',
env : nix_env_for_docs,
@@ -78,13 +81,14 @@ manual = custom_target(
'manual',
command : [
bash,
- '-euo', 'pipefail',
+ '-euo',
+ 'pipefail',
'-c',
'''
@0@ @INPUT0@ @CURRENT_SOURCE_DIR@ > @DEPFILE@
@0@ @INPUT1@ summary @2@ < @CURRENT_SOURCE_DIR@/source/SUMMARY.md.in > @2@/source/SUMMARY.md
sed -e 's|@version@|@3@|g' < @INPUT2@ > @2@/book.toml
- 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
rm -rf @2@/manual
mv @2@/html @2@/manual
@@ -94,6 +98,7 @@ manual = custom_target(
mdbook.full_path(),
meson.current_build_dir(),
meson.project_version(),
+ rsync.full_path(),
),
],
input : [
@@ -118,8 +123,8 @@ manual = custom_target(
],
depfile : 'manual.d',
env : {
- 'RUST_LOG': 'info',
- 'MDBOOK_SUBSTITUTE_SEARCH': meson.current_build_dir() / 'source',
+ 'RUST_LOG' : 'info',
+ 'MDBOOK_SUBSTITUTE_SEARCH' : meson.current_build_dir() / 'source',
},
)
manual_html = manual[0]
@@ -131,7 +136,8 @@ install_subdir(
)
nix_nested_manpages = [
- [ 'nix-env',
+ [
+ 'nix-env',
[
'delete-generations',
'install',
@@ -146,7 +152,8 @@ nix_nested_manpages = [
'upgrade',
],
],
- [ 'nix-store',
+ [
+ 'nix-store',
[
'add-fixed',
'add',
diff --git a/doc/manual/package.nix b/doc/manual/package.nix
index af6d46a2a..69b7c0e49 100644
--- a/doc/manual/package.nix
+++ b/doc/manual/package.nix
@@ -46,24 +46,23 @@ mkMesonDerivation (finalAttrs: {
];
# Hack for sake of the dev shell
- passthru.externalNativeBuildInputs =
- [
- meson
- ninja
- (lib.getBin lowdown-unsandboxed)
- mdbook
- mdbook-linkcheck
- jq
- python3
- rsync
- changelog-d
- ]
- ++ lib.optionals (!officialRelease) [
- # When not an official release, we likely have changelog entries that have
- # yet to be rendered.
- # When released, these are rendered into a committed file to save a dependency.
- changelog-d
- ];
+ passthru.externalNativeBuildInputs = [
+ meson
+ ninja
+ (lib.getBin lowdown-unsandboxed)
+ mdbook
+ mdbook-linkcheck
+ jq
+ python3
+ rsync
+ changelog-d
+ ]
+ ++ lib.optionals (!officialRelease) [
+ # When not an official release, we likely have changelog entries that have
+ # yet to be rendered.
+ # When released, these are rendered into a committed file to save a dependency.
+ changelog-d
+ ];
nativeBuildInputs = finalAttrs.passthru.externalNativeBuildInputs ++ [
nix-cli
diff --git a/doc/manual/rl-next/dropped-compat.md b/doc/manual/rl-next/dropped-compat.md
new file mode 100644
index 000000000..d6cc7704a
--- /dev/null
+++ b/doc/manual/rl-next/dropped-compat.md
@@ -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.
diff --git a/doc/manual/rl-next/shorter-build-dir-names.md b/doc/manual/rl-next/shorter-build-dir-names.md
new file mode 100644
index 000000000..e87fa5d04
--- /dev/null
+++ b/doc/manual/rl-next/shorter-build-dir-names.md
@@ -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`.
\ No newline at end of file
diff --git a/doc/manual/source/SUMMARY.md.in b/doc/manual/source/SUMMARY.md.in
index bfb921567..8fed98c2c 100644
--- a/doc/manual/source/SUMMARY.md.in
+++ b/doc/manual/source/SUMMARY.md.in
@@ -128,6 +128,7 @@
- [Development](development/index.md)
- [Building](development/building.md)
- [Testing](development/testing.md)
+ - [Benchmarking](development/benchmarking.md)
- [Debugging](development/debugging.md)
- [Documentation](development/documentation.md)
- [CLI guideline](development/cli-guideline.md)
@@ -137,6 +138,7 @@
- [Contributing](development/contributing.md)
- [Releases](release-notes/index.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.29 (2025-05-14)](release-notes/rl-2.29.md)
- [Release 2.28 (2025-04-02)](release-notes/rl-2.28.md)
diff --git a/doc/manual/source/command-ref/env-common.md b/doc/manual/source/command-ref/env-common.md
index ee3995111..e0fd2b00e 100644
--- a/doc/manual/source/command-ref/env-common.md
+++ b/doc/manual/source/command-ref/env-common.md
@@ -75,7 +75,7 @@ Most Nix commands interpret the following environment variables:
- [`NIX_CONF_DIR`](#env-NIX_CONF_DIR)
Overrides the location of the system Nix configuration directory
- (default `prefix/etc/nix`).
+ (default `sysconfdir/nix`, i.e. `/etc/nix` on most systems).
- [`NIX_CONFIG`](#env-NIX_CONFIG)
diff --git a/doc/manual/source/command-ref/meson.build b/doc/manual/source/command-ref/meson.build
index 2976f69ff..92998dec1 100644
--- a/doc/manual/source/command-ref/meson.build
+++ b/doc/manual/source/command-ref/meson.build
@@ -1,13 +1,12 @@
xp_features_json = custom_target(
- command : [nix, '__dump-xp-features'],
+ command : [ nix, '__dump-xp-features' ],
capture : true,
output : 'xp-features.json',
)
experimental_features_shortlist_md = custom_target(
command : nix_eval_for_docs + [
- '--expr',
- 'import @INPUT0@ (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
+ '--expr', 'import @INPUT0@ (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
],
input : [
'../../generate-xp-features-shortlist.nix',
@@ -19,14 +18,8 @@ experimental_features_shortlist_md = custom_target(
)
nix3_cli_files = custom_target(
- command : [
- python.full_path(),
- '@INPUT0@',
- '@OUTPUT@',
- '--'
- ] + nix_eval_for_docs + [
- '--expr',
- 'import @INPUT1@ true (builtins.readFile ./@INPUT2@)',
+ command : [ python.full_path(), '@INPUT0@', '@OUTPUT@', '--' ] + nix_eval_for_docs + [
+ '--expr', 'import @INPUT1@ true (builtins.readFile ./@INPUT2@)',
],
input : [
'../../remove_before_wrapper.py',
@@ -40,8 +33,7 @@ nix3_cli_files = custom_target(
conf_file_md_body = custom_target(
command : [
nix_eval_for_docs,
- '--expr',
- 'import @INPUT0@ { prefix = "conf"; } (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
+ '--expr', 'import @INPUT0@ { prefix = "conf"; } (builtins.fromJSON (builtins.readFile ./@INPUT1@))',
],
capture : true,
input : [
diff --git a/doc/manual/source/development/benchmarking.md b/doc/manual/source/development/benchmarking.md
new file mode 100644
index 000000000..74eadd9c2
--- /dev/null
+++ b/doc/manual/source/development/benchmarking.md
@@ -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
+ ```
+
+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)
diff --git a/doc/manual/source/development/building.md b/doc/manual/source/development/building.md
index 167463837..a07232a5f 100644
--- a/doc/manual/source/development/building.md
+++ b/doc/manual/source/development/building.md
@@ -34,7 +34,7 @@ $ nix-shell --attr devShells.x86_64-linux.native-clangStdenvPackages
To build Nix itself in this shell:
```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]$ 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:
-| `config.guess` | Nix |
-|----------------------------|---------------------|
-| `amd64` | `x86_64` |
-| `i*86` | `i686` |
-| `arm6` | `arm6l` |
-| `arm7` | `arm7l` |
-| `linux-gnu*` | `linux` |
-| `linux-musl*` | `linux` |
+| `host_machine.cpu_family()` | `host_machine.endian()` | Nix |
+|-----------------------------|-------------------------|---------------------|
+| `x86` | | `i686` |
+| `arm` | | `host_machine.cpu()`|
+| `ppc` | `little` | `powerpcle` |
+| `ppc64` | `little` | `powerpc64le` |
+| `ppc` | `big` | `powerpc` |
+| `ppc64` | `big` | `powerpc64` |
+| `mips` | `little` | `mipsel` |
+| `mips64` | `little` | `mips64el` |
+| `mips` | `big` | `mips` |
+| `mips64` | `big` | `mips64` |
## Compilation environments
diff --git a/doc/manual/source/development/meson.build b/doc/manual/source/development/meson.build
index 5ffbfe394..4831cf8f0 100644
--- a/doc/manual/source/development/meson.build
+++ b/doc/manual/source/development/meson.build
@@ -1,7 +1,6 @@
experimental_feature_descriptions_md = custom_target(
command : nix_eval_for_docs + [
- '--expr',
- 'import @INPUT0@ (builtins.fromJSON (builtins.readFile @INPUT1@))',
+ '--expr', 'import @INPUT0@ (builtins.fromJSON (builtins.readFile @INPUT1@))',
],
input : [
'../../generate-xp-features.nix',
diff --git a/doc/manual/source/installation/prerequisites-source.md b/doc/manual/source/installation/prerequisites-source.md
index c346a0a4b..057fd4443 100644
--- a/doc/manual/source/installation/prerequisites-source.md
+++ b/doc/manual/source/installation/prerequisites-source.md
@@ -10,7 +10,7 @@
- Bash Shell. The `./configure` script relies on bashisms, so Bash is
required.
- - A version of GCC or Clang that supports C++20.
+ - A version of GCC or Clang that supports C++23.
- `pkg-config` to locate dependencies. If your distribution does not
provide it, you can get it from
diff --git a/doc/manual/source/installation/uninstall.md b/doc/manual/source/installation/uninstall.md
index 8d45da6bb..69d59847b 100644
--- a/doc/manual/source/installation/uninstall.md
+++ b/doc/manual/source/installation/uninstall.md
@@ -41,6 +41,38 @@ There may also be references to Nix in
which you may remove.
+### FreeBSD
+
+1. Stop and remove the Nix daemon service:
+
+ ```console
+ sudo service nix-daemon stop
+ sudo rm -f /usr/local/etc/rc.d/nix-daemon
+ sudo sysrc -x nix_daemon_enable
+ ```
+
+2. Remove files created by Nix:
+
+ ```console
+ sudo rm -rf /etc/nix /usr/local/etc/profile.d/nix.sh /nix ~root/.nix-channels ~root/.nix-defexpr ~root/.nix-profile ~root/.cache/nix
+ ```
+
+3. Remove build users and their group:
+
+ ```console
+ for i in $(seq 1 32); do
+ sudo pw userdel nixbld$i
+ done
+ sudo pw groupdel nixbld
+ ```
+
+4. There may also be references to Nix in:
+ - `/usr/local/etc/bashrc`
+ - `/usr/local/etc/zshrc`
+ - Shell configuration files in users' home directories
+
+ which you may remove.
+
### macOS
> **Updating to macOS 15 Sequoia**
diff --git a/doc/manual/source/language/advanced-attributes.md b/doc/manual/source/language/advanced-attributes.md
index 34c3b636b..c9d64f060 100644
--- a/doc/manual/source/language/advanced-attributes.md
+++ b/doc/manual/source/language/advanced-attributes.md
@@ -160,7 +160,6 @@ See the [corresponding section in the derivation output page](@docroot@/store/de
## Other output modifications
- [`unsafeDiscardReferences`]{#adv-attr-unsafeDiscardReferences}\
-
When using [structured attributes](#adv-attr-structuredAttrs), the
attribute `unsafeDiscardReferences` is an attribute set with a boolean value for each output name.
If set to `true`, it disables scanning the output for runtime dependencies.
@@ -195,7 +194,6 @@ See the [corresponding section in the derivation output page](@docroot@/store/de
[`builder`]: ./derivations.md#attr-builder
- [`requiredSystemFeatures`]{#adv-attr-requiredSystemFeatures}\
-
If a derivation has the `requiredSystemFeatures` attribute, then Nix will only build it on a machine that has the corresponding features set in its [`system-features` configuration](@docroot@/command-ref/conf-file.md#conf-system-features).
For example, setting
diff --git a/doc/manual/source/language/meson.build b/doc/manual/source/language/meson.build
index 97469e2f3..ed4995bfb 100644
--- a/doc/manual/source/language/meson.build
+++ b/doc/manual/source/language/meson.build
@@ -1,19 +1,13 @@
builtins_md = custom_target(
- command : [
- python.full_path(),
- '@INPUT0@',
- '@OUTPUT@',
- '--'
- ] + nix_eval_for_docs + [
- '--expr',
- '(builtins.readFile @INPUT3@) + import @INPUT1@ (builtins.fromJSON (builtins.readFile ./@INPUT2@)) + (builtins.readFile @INPUT4@)',
+ command : [ python.full_path(), '@INPUT0@', '@OUTPUT@', '--' ] + nix_eval_for_docs + [
+ '--expr', '(builtins.readFile @INPUT3@) + import @INPUT1@ (builtins.fromJSON (builtins.readFile ./@INPUT2@)) + (builtins.readFile @INPUT4@)',
],
input : [
'../../remove_before_wrapper.py',
'../../generate-builtins.nix',
language_json,
'builtins-prefix.md',
- 'builtins-suffix.md'
+ 'builtins-suffix.md',
],
output : 'builtins.md',
env : nix_env_for_docs,
diff --git a/doc/manual/source/meson.build b/doc/manual/source/meson.build
index 098a29897..949d26526 100644
--- a/doc/manual/source/meson.build
+++ b/doc/manual/source/meson.build
@@ -1,7 +1,8 @@
summary_rl_next = custom_target(
command : [
bash,
- '-euo', 'pipefail',
+ '-euo',
+ 'pipefail',
'-c',
'''
if [ -e "@INPUT@" ]; then
@@ -12,6 +13,6 @@ summary_rl_next = custom_target(
input : [
rl_next_generated,
],
- capture: true,
+ capture : true,
output : 'SUMMARY-rl-next.md',
)
diff --git a/doc/manual/source/package-management/garbage-collector-roots.md b/doc/manual/source/package-management/garbage-collector-roots.md
index 30c5b7f8d..925a33162 100644
--- a/doc/manual/source/package-management/garbage-collector-roots.md
+++ b/doc/manual/source/package-management/garbage-collector-roots.md
@@ -12,7 +12,7 @@ $ ln -s /nix/store/d718ef...-foo /nix/var/nix/gcroots/bar
That is, after this command, the garbage collector will not remove
`/nix/store/d718ef...-foo` or any of its dependencies.
-Subdirectories of `prefix/nix/var/nix/gcroots` are also searched for
-symlinks. Symlinks to non-store paths are followed and searched for
-roots, but symlinks to non-store paths *inside* the paths reached in
-that way are not followed to prevent infinite recursion.
+Subdirectories of `prefix/nix/var/nix/gcroots` are searched
+recursively. Symlinks to store paths count as roots. Symlinks to
+non-store paths are ignored, unless the non-store path is itself a
+symlink to a store path.
\ No newline at end of file
diff --git a/doc/manual/source/protocols/nix-archive.md b/doc/manual/source/protocols/nix-archive.md
index 640b527f1..02a8dd464 100644
--- a/doc/manual/source/protocols/nix-archive.md
+++ b/doc/manual/source/protocols/nix-archive.md
@@ -24,7 +24,7 @@ nar-obj-inner
| 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);
diff --git a/doc/manual/source/release-notes/rl-2.31.md b/doc/manual/source/release-notes/rl-2.31.md
new file mode 100644
index 000000000..8b9d44c83
--- /dev/null
+++ b/doc/manual/source/release-notes/rl-2.31.md
@@ -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
diff --git a/doc/manual/source/release-notes/rl-2.8.md b/doc/manual/source/release-notes/rl-2.8.md
index 9778e8c3a..686445208 100644
--- a/doc/manual/source/release-notes/rl-2.8.md
+++ b/doc/manual/source/release-notes/rl-2.8.md
@@ -48,6 +48,6 @@
* `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
- 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
(not apps).
diff --git a/doc/manual/source/store/derivation/index.md b/doc/manual/source/store/derivation/index.md
index 1687ad8c0..0e12b4d5e 100644
--- a/doc/manual/source/store/derivation/index.md
+++ b/doc/manual/source/store/derivation/index.md
@@ -9,7 +9,7 @@ This is where Nix distinguishes itself.
## 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*.
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.
diff --git a/doc/manual/source/store/meson.build b/doc/manual/source/store/meson.build
index e3006020d..ec4659ebc 100644
--- a/doc/manual/source/store/meson.build
+++ b/doc/manual/source/store/meson.build
@@ -1,12 +1,6 @@
types_dir = custom_target(
- command : [
- python.full_path(),
- '@INPUT0@',
- '@OUTPUT@',
- '--'
- ] + nix_eval_for_docs + [
- '--expr',
- 'import @INPUT1@ (builtins.fromJSON (builtins.readFile ./@INPUT2@)).stores',
+ command : [ python.full_path(), '@INPUT0@', '@OUTPUT@', '--' ] + nix_eval_for_docs + [
+ '--expr', 'import @INPUT1@ (builtins.fromJSON (builtins.readFile ./@INPUT2@)).stores',
],
input : [
'../../remove_before_wrapper.py',
diff --git a/doc/manual/source/store/store-object.md b/doc/manual/source/store/store-object.md
index 10c2384fa..71ec772fb 100644
--- a/doc/manual/source/store/store-object.md
+++ b/doc/manual/source/store/store-object.md
@@ -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
-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.
[transitive closure]: https://en.wikipedia.org/wiki/Transitive_closure
diff --git a/docker.nix b/docker.nix
index c6e8e478e..9dbc34d61 100644
--- a/docker.nix
+++ b/docker.nix
@@ -1,10 +1,10 @@
{
# Core dependencies
- pkgs,
- lib,
- dockerTools,
- runCommand,
- buildPackages,
+ pkgs ? import { },
+ lib ? pkgs.lib,
+ dockerTools ? pkgs.dockerTools,
+ runCommand ? pkgs.runCommand,
+ buildPackages ? pkgs.buildPackages,
# Image configuration
name ? "nix",
tag ? "latest",
@@ -28,24 +28,24 @@
},
Cmd ? [ (lib.getExe bashInteractive) ],
# Default Packages
- nix,
- bashInteractive,
- coreutils-full,
- gnutar,
- gzip,
- gnugrep,
- which,
- curl,
- less,
- wget,
- man,
- cacert,
- findutils,
- iana-etc,
- gitMinimal,
- openssh,
+ nix ? pkgs.nix,
+ bashInteractive ? pkgs.bashInteractive,
+ coreutils-full ? pkgs.coreutils-full,
+ gnutar ? pkgs.gnutar,
+ gzip ? pkgs.gzip,
+ gnugrep ? pkgs.gnugrep,
+ which ? pkgs.which,
+ curl ? pkgs.curl,
+ less ? pkgs.less,
+ wget ? pkgs.wget,
+ man ? pkgs.man,
+ cacert ? pkgs.cacert,
+ findutils ? pkgs.findutils,
+ iana-etc ? pkgs.iana-etc,
+ gitMinimal ? pkgs.gitMinimal,
+ openssh ? pkgs.openssh,
# Other dependencies
- shadow,
+ shadow ? pkgs.shadow,
}:
let
defaultPkgs = [
@@ -65,62 +65,61 @@ let
iana-etc
gitMinimal
openssh
- ] ++ extraPkgs;
+ ]
+ ++ extraPkgs;
- users =
- {
+ users = {
- root = {
- uid = 0;
- shell = lib.getExe bashInteractive;
- home = "/root";
- gid = 0;
- groups = [ "root" ];
- description = "System administrator";
- };
-
- nobody = {
- uid = 65534;
- shell = lib.getExe' shadow "nologin";
- home = "/var/empty";
- gid = 65534;
- groups = [ "nobody" ];
- description = "Unprivileged account (don't use!)";
- };
-
- }
- // lib.optionalAttrs (uid != 0) {
- "${uname}" = {
- uid = uid;
- shell = lib.getExe bashInteractive;
- home = "/home/${uname}";
- gid = gid;
- groups = [ "${gname}" ];
- description = "Nix user";
- };
- }
- // lib.listToAttrs (
- map (n: {
- name = "nixbld${toString n}";
- value = {
- uid = 30000 + n;
- gid = 30000;
- groups = [ "nixbld" ];
- description = "Nix build user ${toString n}";
- };
- }) (lib.lists.range 1 32)
- );
-
- groups =
- {
- root.gid = 0;
- nixbld.gid = 30000;
- nobody.gid = 65534;
- }
- // lib.optionalAttrs (gid != 0) {
- "${gname}".gid = gid;
+ root = {
+ uid = 0;
+ shell = lib.getExe bashInteractive;
+ home = "/root";
+ gid = 0;
+ groups = [ "root" ];
+ description = "System administrator";
};
+ nobody = {
+ uid = 65534;
+ shell = lib.getExe' shadow "nologin";
+ home = "/var/empty";
+ gid = 65534;
+ groups = [ "nobody" ];
+ description = "Unprivileged account (don't use!)";
+ };
+
+ }
+ // lib.optionalAttrs (uid != 0) {
+ "${uname}" = {
+ uid = uid;
+ shell = lib.getExe bashInteractive;
+ home = "/home/${uname}";
+ gid = gid;
+ groups = [ "${gname}" ];
+ description = "Nix user";
+ };
+ }
+ // lib.listToAttrs (
+ map (n: {
+ name = "nixbld${toString n}";
+ value = {
+ uid = 30000 + n;
+ gid = 30000;
+ groups = [ "nixbld" ];
+ description = "Nix build user ${toString n}";
+ };
+ }) (lib.lists.range 1 32)
+ );
+
+ groups = {
+ root.gid = 0;
+ nixbld.gid = 30000;
+ nobody.gid = 65534;
+ }
+ // lib.optionalAttrs (gid != 0) {
+ "${gname}".gid = gid;
+ };
+
userToPasswd = (
k:
{
@@ -184,11 +183,14 @@ let
} " = ";
};
- nixConfContents = toConf {
- sandbox = false;
- build-users-group = "nixbld";
- trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ];
- };
+ nixConfContents = toConf (
+ {
+ sandbox = false;
+ build-users-group = "nixbld";
+ trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ];
+ }
+ // nixConf
+ );
userHome = if uid == 0 then "/root" else "/home/${uname}";
@@ -279,7 +281,10 @@ let
# may get replaced by pkgs.dockerTools.caCertificates
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
+ # 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
echo "" >> $out/etc/passwd
@@ -308,6 +313,7 @@ let
# see doc/manual/source/command-ref/files/profiles.md
ln -s ${profile} $out/nix/var/nix/profiles/default-1-link
ln -s /nix/var/nix/profiles/default-1-link $out/nix/var/nix/profiles/default
+ ln -s /nix/var/nix/profiles/default $out${userHome}/.nix-profile
# see doc/manual/source/command-ref/files/channels.md
ln -s ${channel} $out/nix/var/nix/profiles/per-user/${uname}/channels-1-link
diff --git a/flake.lock b/flake.lock
index 3075eabc2..cc2b2f27e 100644
--- a/flake.lock
+++ b/flake.lock
@@ -63,16 +63,16 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1747179050,
- "narHash": "sha256-qhFMmDkeJX9KJwr5H32f1r7Prs7XbQWtO0h3V0a0rFY=",
+ "lastModified": 1756178832,
+ "narHash": "sha256-O2CIn7HjZwEGqBrwu9EU76zlmA5dbmna7jL1XUmAId8=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "adaa24fbf46737f3f1b5497bf64bae750f82942e",
+ "rev": "d98ce345cdab58477ca61855540999c86577d19d",
"type": "github"
},
"original": {
"owner": "NixOS",
- "ref": "nixos-unstable",
+ "ref": "nixos-25.05-small",
"repo": "nixpkgs",
"type": "github"
}
diff --git a/flake.nix b/flake.nix
index 69bd2a21a..fd623c807 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,7 +1,7 @@
{
description = "The purely functional package manager";
- inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05-small";
inputs.nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2";
inputs.nixpkgs-23-11.url = "github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446";
@@ -131,31 +131,107 @@
}
);
- overlayFor =
- getStdenv: final: prev:
+ /**
+ Produce the `nixComponents` and `nixDependencies` package sets (scopes) for
+ a given `pkgs` and `getStdenv`.
+ */
+ packageSetsFor =
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
- {
- nixStable = prev.nix;
+ args@{
+ 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
# without "polluting" the top level "`pkgs`" attrset.
# This also has the benefit of providing us with a distinct set of packages
# we can iterate over.
- # The `2` suffix is here because otherwise it interferes with `nixVersions.latest`, which is used in daemon compat tests.
- nixComponents2 =
+ nixComponents =
lib.makeScopeWithSplicing'
{
- inherit (final) splicePackages;
- inherit (final.nixDependencies2) newScope;
+ inherit (pkgs) splicePackages;
+ inherit (nixDependencies) newScope;
}
{
- otherSplices = final.generateSplicesForMkScope "nixComponents2";
+ otherSplices = renameSplicesTo "self" nixComponentsSplices;
f = import ./packaging/components.nix {
- inherit (final) lib;
+ inherit (pkgs) lib;
inherit officialRelease;
- pkgs = final;
+ inherit pkgs;
src = self;
maintainers = [ ];
};
@@ -163,29 +239,71 @@
# 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 =
+ nixDependencies =
lib.makeScopeWithSplicing'
{
- inherit (final) splicePackages;
- inherit (final) newScope; # layered directly on pkgs, unlike nixComponents2 above
+ inherit (pkgs) splicePackages;
+ inherit (pkgs) newScope; # layered directly on pkgs, unlike nixComponents2 above
}
{
- otherSplices = final.generateSplicesForMkScope "nixDependencies2";
+ otherSplices = renameSplicesTo "self" nixDependenciesSplices;
f = import ./packaging/dependencies.nix {
- inherit inputs stdenv;
- pkgs = final;
+ inherit inputs pkgs;
+ 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;
};
in
{
- # A Nixpkgs overlay that overrides the 'nix' and
- # 'nix-perl-bindings' packages.
- overlays.default = overlayFor (p: p.stdenv);
+ overlays.internal = overlayFor (p: p.stdenv);
+
+ /**
+ A Nixpkgs overlay that sets `nix` to something like `packages..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 {
inherit
@@ -202,43 +320,11 @@
checks = forAllSystems (
system:
- {
- installerScriptForGHA = self.hydraJobs.installerScriptForGHA.${system};
- installTests = self.hydraJobs.installTests.${system};
- nixpkgsLibTests = self.hydraJobs.tests.nixpkgsLibTests.${system};
- rl-next =
- 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;
- };
- }
+ (import ./ci/gha/tests {
+ inherit system;
+ pkgs = nixpkgsFor.${system}.native;
+ nixFlake = self;
+ }).topLevel
// (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
dockerImage = self.hydraJobs.dockerImage.${system};
}
@@ -251,58 +337,20 @@
# Add "passthru" tests
//
flatMapAttrs
+ {
+ "" = {
+ pkgs = nixpkgsFor.${system}.native;
+ };
+ }
(
- {
- # 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.
- "" = 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;
- }
+ nixpkgsPrefix: args:
+ (import ./ci/gha/tests (
+ args
+ // {
+ nixFlake = self;
+ componentTestsPrefix = nixpkgsPrefix;
+ }
+ )).componentTests
)
// devFlake.checks.${system} or { }
);
@@ -465,5 +513,53 @@
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;
+ };
};
}
diff --git a/maintainers/README.md b/maintainers/README.md
index 6553cd048..722a920b7 100644
--- a/maintainers/README.md
+++ b/maintainers/README.md
@@ -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
- 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).
2. Other chores and tasks.
diff --git a/maintainers/data/release-credits-email-to-handle.json b/maintainers/data/release-credits-email-to-handle.json
index 48e8685e6..ea37afb90 100644
--- a/maintainers/data/release-credits-email-to-handle.json
+++ b/maintainers/data/release-credits-email-to-handle.json
@@ -185,5 +185,23 @@
"gwenn.lebihan7@gmail.com": "gwennlbh",
"hey@ewen.works": "gwennlbh",
"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"
}
\ No newline at end of file
diff --git a/maintainers/data/release-credits-handle-to-name.json b/maintainers/data/release-credits-handle-to-name.json
index a6352c44b..e2510548d 100644
--- a/maintainers/data/release-credits-handle-to-name.json
+++ b/maintainers/data/release-credits-handle-to-name.json
@@ -162,5 +162,20 @@
"pbsds": "Peder Bergebakken Sundt",
"egorkonovalov": "Egor Konovalov",
"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"
}
\ No newline at end of file
diff --git a/maintainers/flake-module.nix b/maintainers/flake-module.nix
index 1058d6334..4815313dd 100644
--- a/maintainers/flake-module.nix
+++ b/maintainers/flake-module.nix
@@ -37,118 +37,29 @@
fi
''}";
};
- meson-format = {
- enable = true;
- files = "(meson.build|meson.options)$";
- entry = "${pkgs.writeScript "format-meson" ''
- #!${pkgs.runtimeShell}
- for file in "$@"; do
- ${lib.getExe pkgs.meson} format -ic ${../meson.format} "$file"
- done
- ''}";
- excludes = [
- # We haven't applied formatting to these files yet
- ''^doc/manual/meson.build$''
- ''^doc/manual/source/command-ref/meson.build$''
- ''^doc/manual/source/development/meson.build$''
- ''^doc/manual/source/language/meson.build$''
- ''^doc/manual/source/meson.build$''
- ''^doc/manual/source/release-notes/meson.build$''
- ''^doc/manual/source/store/meson.build$''
- ''^misc/bash/meson.build$''
- ''^misc/fish/meson.build$''
- ''^misc/launchd/meson.build$''
- ''^misc/meson.build$''
- ''^misc/systemd/meson.build$''
- ''^misc/zsh/meson.build$''
- ''^nix-meson-build-support/$''
- ''^nix-meson-build-support/big-objs/meson.build$''
- ''^nix-meson-build-support/common/meson.build$''
- ''^nix-meson-build-support/deps-lists/meson.build$''
- ''^nix-meson-build-support/export/meson.build$''
- ''^nix-meson-build-support/export-all-symbols/meson.build$''
- ''^nix-meson-build-support/generate-header/meson.build$''
- ''^nix-meson-build-support/libatomic/meson.build$''
- ''^nix-meson-build-support/subprojects/meson.build$''
- ''^scripts/meson.build$''
- ''^src/external-api-docs/meson.build$''
- ''^src/internal-api-docs/meson.build$''
- ''^src/libcmd/include/nix/cmd/meson.build$''
- ''^src/libcmd/meson.build$''
- ''^src/libcmd/nix-meson-build-support$''
- ''^src/libexpr/include/nix/expr/meson.build$''
- ''^src/libexpr/meson.build$''
- ''^src/libexpr/nix-meson-build-support$''
- ''^src/libexpr-c/meson.build$''
- ''^src/libexpr-c/nix-meson-build-support$''
- ''^src/libexpr-test-support/meson.build$''
- ''^src/libexpr-test-support/nix-meson-build-support$''
- ''^src/libexpr-tests/meson.build$''
- ''^src/libexpr-tests/nix-meson-build-support$''
- ''^src/libfetchers/include/nix/fetchers/meson.build$''
- ''^src/libfetchers/meson.build$''
- ''^src/libfetchers/nix-meson-build-support$''
- ''^src/libfetchers-c/meson.build$''
- ''^src/libfetchers-c/nix-meson-build-support$''
- ''^src/libfetchers-tests/meson.build$''
- ''^src/libfetchers-tests/nix-meson-build-support$''
- ''^src/libflake/include/nix/flake/meson.build$''
- ''^src/libflake/meson.build$''
- ''^src/libflake/nix-meson-build-support$''
- ''^src/libflake-c/meson.build$''
- ''^src/libflake-c/nix-meson-build-support$''
- ''^src/libflake-tests/meson.build$''
- ''^src/libflake-tests/nix-meson-build-support$''
- ''^src/libmain/include/nix/main/meson.build$''
- ''^src/libmain/meson.build$''
- ''^src/libmain/nix-meson-build-support$''
- ''^src/libmain-c/meson.build$''
- ''^src/libmain-c/nix-meson-build-support$''
- ''^src/libstore/include/nix/store/meson.build$''
- ''^src/libstore/meson.build$''
- ''^src/libstore/nix-meson-build-support$''
- ''^src/libstore/unix/include/nix/store/meson.build$''
- ''^src/libstore/unix/meson.build$''
- ''^src/libstore/windows/meson.build$''
- ''^src/libstore-c/meson.build$''
- ''^src/libstore-c/nix-meson-build-support$''
- ''^src/libstore-test-support/include/nix/store/tests/meson.build$''
- ''^src/libstore-test-support/meson.build$''
- ''^src/libstore-test-support/nix-meson-build-support$''
- ''^src/libstore-tests/meson.build$''
- ''^src/libstore-tests/nix-meson-build-support$''
- ''^src/libutil/meson.build$''
- ''^src/libutil/nix-meson-build-support$''
- ''^src/libutil/unix/include/nix/util/meson.build$''
- ''^src/libutil/unix/meson.build$''
- ''^src/libutil/windows/meson.build$''
- ''^src/libutil-c/meson.build$''
- ''^src/libutil-c/nix-meson-build-support$''
- ''^src/libutil-test-support/include/nix/util/tests/meson.build$''
- ''^src/libutil-test-support/meson.build$''
- ''^src/libutil-test-support/nix-meson-build-support$''
- ''^src/libutil-tests/meson.build$''
- ''^src/libutil-tests/nix-meson-build-support$''
- ''^src/nix/meson.build$''
- ''^src/nix/nix-meson-build-support$''
- ''^src/perl/lib/Nix/meson.build$''
- ''^src/perl/meson.build$''
- ''^tests/functional/ca/meson.build$''
- ''^tests/functional/common/meson.build$''
- ''^tests/functional/dyn-drv/meson.build$''
- ''^tests/functional/flakes/meson.build$''
- ''^tests/functional/git-hashing/meson.build$''
- ''^tests/functional/local-overlay-store/meson.build$''
- ''^tests/functional/meson.build$''
- ''^src/libcmd/meson.options$''
- ''^src/libexpr/meson.options$''
- ''^src/libstore/meson.options$''
- ''^src/libutil/meson.options$''
- ''^src/libutil-c/meson.options$''
- ''^src/nix/meson.options$''
- ''^src/perl/meson.options$''
- ];
- };
+ meson-format =
+ let
+ meson = pkgs.meson.overrideAttrs {
+ doCheck = false;
+ doInstallCheck = false;
+ patches = [
+ (pkgs.fetchpatch {
+ url = "https://github.com/mesonbuild/meson/commit/38d29b4dd19698d5cad7b599add2a69b243fd88a.patch";
+ hash = "sha256-PgPBvGtCISKn1qQQhzBW5XfknUe91i5XGGBcaUK4yeE=";
+ })
+ ];
+ };
+ in
+ {
+ enable = true;
+ files = "(meson.build|meson.options)$";
+ entry = "${pkgs.writeScript "format-meson" ''
+ #!${pkgs.runtimeShell}
+ for file in "$@"; do
+ ${lib.getExe meson} format -ic ${../meson.format} "$file"
+ done
+ ''}";
+ };
nixfmt-rfc-style = {
enable = true;
excludes = [
@@ -189,467 +100,6 @@
# Don't format vendored code
''^doc/manual/redirects\.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 = {
@@ -723,8 +173,6 @@
''^tests/functional/gc-concurrent\.sh$''
''^tests/functional/gc-concurrent2\.builder\.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/impure-derivations\.sh$''
''^tests/functional/impure-eval\.sh$''
@@ -800,7 +248,6 @@
''^tests/functional/user-envs\.builder\.sh$''
''^tests/functional/user-envs\.sh$''
''^tests/functional/why-depends\.sh$''
- ''^src/libutil-tests/data/git/check-data\.sh$''
];
};
};
diff --git a/maintainers/format.sh b/maintainers/format.sh
index a2a6d8b41..b2902e6dc 100755
--- a/maintainers/format.sh
+++ b/maintainers/format.sh
@@ -1,11 +1,16 @@
#!/usr/bin/env bash
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;
fi;
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;
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
diff --git a/maintainers/onboarding.md b/maintainers/onboarding.md
index d7491db16..311cc64e6 100644
--- a/maintainers/onboarding.md
+++ b/maintainers/onboarding.md
@@ -3,5 +3,9 @@
- https://github.com/NixOS/nixos-homepage/
- 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)
diff --git a/maintainers/release-notes-todo b/maintainers/release-notes-todo
new file mode 100755
index 000000000..7cadc2a79
--- /dev/null
+++ b/maintainers/release-notes-todo
@@ -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
diff --git a/maintainers/release-process.md b/maintainers/release-process.md
index f2c61302b..790618b7f 100644
--- a/maintainers/release-process.md
+++ b/maintainers/release-process.md
@@ -24,11 +24,18 @@ release:
* In a checkout of the Nix repo, make sure you're on `master` and run
`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
```console
$ export VERSION=X.YY
$ git checkout -b release-notes
+ $ export GITHUB_TOKEN=...
$ ./maintainers/release-notes
```
@@ -39,10 +46,6 @@ release:
* Proof-read / edit / rearrange the release notes if needed. Breaking changes
and highlights should go to the top.
-* Run `maintainers/release-credits` to make sure the credits script works
- and produces a sensible output. Some emails might not automatically map to
- a GitHub handle.
-
* Push.
```console
@@ -130,6 +133,8 @@ release:
Commit and push this to the maintenance branch.
+* Create a backport label.
+
* Bump the version of `master`:
```console
@@ -137,6 +142,7 @@ release:
$ git pull
$ NEW_VERSION=2.13.0
$ echo $NEW_VERSION > .version
+ $ ... edit .mergify.yml to add the previous version ...
$ git checkout -b bump-$NEW_VERSION
$ git commit -a -m 'Bump version'
$ git push --set-upstream origin bump-$NEW_VERSION
@@ -144,10 +150,6 @@ release:
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
`rl-$VERSION.md`.
diff --git a/meson.build b/meson.build
index 4a3a517fb..5dcf98717 100644
--- a/meson.build
+++ b/meson.build
@@ -8,7 +8,6 @@ project(
subproject_dir : 'src',
default_options : [
'localstatedir=/nix/var',
- # hack for trailing newline
],
meson_version : '>= 1.1',
)
@@ -29,7 +28,7 @@ subproject('nix')
if get_option('doc-gen')
subproject('internal-api-docs')
subproject('external-api-docs')
- if not meson.is_cross_build()
+ if meson.can_run_host_binaries()
subproject('nix-manual')
endif
endif
diff --git a/meson.options b/meson.options
index 30670902e..d2c9fa40c 100644
--- a/meson.options
+++ b/meson.options
@@ -20,3 +20,10 @@ option(
value : true,
description : 'Build language bindings (e.g. Perl)',
)
+
+option(
+ 'benchmarks',
+ type : 'boolean',
+ value : false,
+ description : 'Build benchmarks (requires gbenchmark)',
+)
diff --git a/misc/freebsd/meson.build b/misc/freebsd/meson.build
new file mode 100644
index 000000000..d94149883
--- /dev/null
+++ b/misc/freebsd/meson.build
@@ -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,
+ },
+)
diff --git a/misc/freebsd/nix-daemon.in b/misc/freebsd/nix-daemon.in
new file mode 100644
index 000000000..9eb269850
--- /dev/null
+++ b/misc/freebsd/nix-daemon.in
@@ -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"
\ No newline at end of file
diff --git a/misc/launchd/meson.build b/misc/launchd/meson.build
index 5168131d1..53a57b65b 100644
--- a/misc/launchd/meson.build
+++ b/misc/launchd/meson.build
@@ -9,5 +9,5 @@ configure_file(
# 'storedir' : store_dir,
# 'localstatedir' : localstatedir,
# 'bindir' : bindir,
- },
+},
)
diff --git a/misc/meson.build b/misc/meson.build
index 82f2b0c65..fc2bca07f 100644
--- a/misc/meson.build
+++ b/misc/meson.build
@@ -9,3 +9,7 @@ endif
if host_machine.system() == 'darwin'
subdir('launchd')
endif
+
+if host_machine.system() == 'freebsd'
+ subdir('freebsd')
+endif
diff --git a/nix-meson-build-support/big-objs/meson.build b/nix-meson-build-support/big-objs/meson.build
index 7e422abd8..f8dd8d1a3 100644
--- a/nix-meson-build-support/big-objs/meson.build
+++ b/nix-meson-build-support/big-objs/meson.build
@@ -2,5 +2,5 @@ if host_machine.system() == 'windows'
# libexpr's primops creates a large object
# 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'
- add_project_arguments([ '-Wa,-mbig-obj' ], language: 'cpp')
+ add_project_arguments([ '-Wa,-mbig-obj' ], language : 'cpp')
endif
diff --git a/nix-meson-build-support/common/meson.build b/nix-meson-build-support/common/meson.build
index b9140256a..fd686f140 100644
--- a/nix-meson-build-support/common/meson.build
+++ b/nix-meson-build-support/common/meson.build
@@ -18,3 +18,25 @@ add_project_arguments(
'-Wno-deprecated-declarations',
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
diff --git a/nix-meson-build-support/default-system-cpu/meson.build b/nix-meson-build-support/default-system-cpu/meson.build
new file mode 100644
index 000000000..f63b07975
--- /dev/null
+++ b/nix-meson-build-support/default-system-cpu/meson.build
@@ -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
diff --git a/nix-meson-build-support/deps-lists/meson.build b/nix-meson-build-support/deps-lists/meson.build
index 237eac545..b4609c176 100644
--- a/nix-meson-build-support/deps-lists/meson.build
+++ b/nix-meson-build-support/deps-lists/meson.build
@@ -6,7 +6,7 @@
# *interface*.
#
# See `man pkg-config` for some details.
-deps_private = [ ]
+deps_private = []
# These are public dependencies with pkg-config files. Public is the
# 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
# "API" stability, the private dependencies also matter as they can
# potentially affect the public ABI.
-deps_public = [ ]
+deps_public = []
# These are subproject deps (type == "internal"). They are other
# packages in `/src` in this repo. The private vs public distinction is
# the same as above.
-deps_private_subproject = [ ]
-deps_public_subproject = [ ]
+deps_private_subproject = []
+deps_public_subproject = []
# These are dependencencies without pkg-config files. Ideally they are
# just private, but they may also be public (e.g. boost).
-deps_other = [ ]
+deps_other = []
diff --git a/nix-meson-build-support/export-all-symbols/meson.build b/nix-meson-build-support/export-all-symbols/meson.build
index d7c086749..6a562e80d 100644
--- a/nix-meson-build-support/export-all-symbols/meson.build
+++ b/nix-meson-build-support/export-all-symbols/meson.build
@@ -5,7 +5,7 @@ if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
# and not detail with this yet.
#
# 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
linker_export_flags = []
endif
diff --git a/nix-meson-build-support/export/meson.build b/nix-meson-build-support/export/meson.build
index 950bd9544..62a27bd48 100644
--- a/nix-meson-build-support/export/meson.build
+++ b/nix-meson-build-support/export/meson.build
@@ -1,12 +1,12 @@
requires_private = []
foreach dep : deps_private_subproject
- requires_private += dep.name()
+ requires_private += dep.name()
endforeach
requires_private += deps_private
-requires_public = []
+requires_public = []
foreach dep : deps_public_subproject
- requires_public += dep.name()
+ requires_public += dep.name()
endforeach
requires_public += deps_public
@@ -14,7 +14,7 @@ extra_pkg_config_variables = get_variable('extra_pkg_config_variables', {})
extra_cflags = []
if not meson.project_name().endswith('-c')
- extra_cflags += ['-std=c++2a']
+ extra_cflags += [ '-std=c++23' ]
endif
import('pkgconfig').generate(
@@ -29,10 +29,13 @@ import('pkgconfig').generate(
variables : extra_pkg_config_variables,
)
-meson.override_dependency(meson.project_name(), declare_dependency(
- include_directories : include_dirs,
- link_with : this_library,
- compile_args : ['-std=c++2a'],
- dependencies : deps_public_subproject + deps_public,
- variables : extra_pkg_config_variables,
-))
+meson.override_dependency(
+ meson.project_name(),
+ declare_dependency(
+ include_directories : include_dirs,
+ link_with : this_library,
+ compile_args : [ '-std=c++23' ],
+ dependencies : deps_public_subproject + deps_public,
+ variables : extra_pkg_config_variables,
+ ),
+)
diff --git a/nix-meson-build-support/generate-header/meson.build b/nix-meson-build-support/generate-header/meson.build
index dfbe1375f..a6523bc9f 100644
--- a/nix-meson-build-support/generate-header/meson.build
+++ b/nix-meson-build-support/generate-header/meson.build
@@ -1,7 +1,12 @@
-bash = find_program('bash', native: true)
+bash = find_program('bash', native : true)
gen_header = generator(
bash,
- arguments : [ '-c', '{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"', '_ignored_argv0', '@OUTPUT@' ],
+ arguments : [
+ '-c',
+ '{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"',
+ '_ignored_argv0',
+ '@OUTPUT@',
+ ],
output : '@PLAINNAME@.gen.hh',
)
diff --git a/nix-meson-build-support/libatomic/meson.build b/nix-meson-build-support/libatomic/meson.build
index d16d23817..1c014bee7 100644
--- a/nix-meson-build-support/libatomic/meson.build
+++ b/nix-meson-build-support/libatomic/meson.build
@@ -3,6 +3,6 @@
# This is needed for std::atomic on some platforms
# We did not manage to test this reliably on all platforms, so we hardcode
# it for now.
-if host_machine.cpu_family() == 'arm'
+if host_machine.cpu_family() in [ 'arm', 'ppc' ]
deps_other += cxx.find_library('atomic')
endif
diff --git a/packaging/binary-tarball.nix b/packaging/binary-tarball.nix
index 2050384b0..86aae0ac5 100644
--- a/packaging/binary-tarball.nix
+++ b/packaging/binary-tarball.nix
@@ -37,6 +37,9 @@ runCommand "nix-binary-tarball-${version}" env ''
substitute ${../scripts/install-systemd-multi-user.sh} $TMPDIR/install-systemd-multi-user.sh \
--subst-var-by nix ${nix} \
--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 \
--subst-var-by nix ${nix} \
--subst-var-by cacert ${cacert}
@@ -48,6 +51,7 @@ runCommand "nix-binary-tarball-${version}" env ''
shellcheck $TMPDIR/create-darwin-volume.sh
shellcheck $TMPDIR/install-darwin-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
# /etc/profile
@@ -64,6 +68,7 @@ runCommand "nix-binary-tarball-${version}" env ''
chmod +x $TMPDIR/create-darwin-volume.sh
chmod +x $TMPDIR/install-darwin-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
dir=nix-${version}-${system}
fn=$out/$dir.tar.xz
@@ -82,6 +87,7 @@ runCommand "nix-binary-tarball-${version}" env ''
$TMPDIR/create-darwin-volume.sh \
$TMPDIR/install-darwin-multi-user.sh \
$TMPDIR/install-systemd-multi-user.sh \
+ $TMPDIR/install-freebsd-multi-user.sh \
$TMPDIR/install-multi-user \
$TMPDIR/reginfo \
$(cat ${installerClosureInfo}/store-paths)
diff --git a/packaging/components.nix b/packaging/components.nix
index b40bd45b0..b5fad4043 100644
--- a/packaging/components.nix
+++ b/packaging/components.nix
@@ -54,12 +54,12 @@ let
preConfigure =
prevAttrs.preConfigure or ""
+
- # Update the repo-global .version file.
- # Symlink ./.version points there, but by default only workDir is writable.
- ''
- chmod u+w ./.version
- echo ${finalAttrs.version} > ./.version
- '';
+ # Update the repo-global .version file.
+ # Symlink ./.version points there, but by default only workDir is writable.
+ ''
+ chmod u+w ./.version
+ echo ${finalAttrs.version} > ./.version
+ '';
};
localSourceLayer =
@@ -148,7 +148,8 @@ let
nativeBuildInputs = [
meson
ninja
- ] ++ prevAttrs.nativeBuildInputs or [ ];
+ ]
+ ++ prevAttrs.nativeBuildInputs or [ ];
mesonCheckFlags = prevAttrs.mesonCheckFlags or [ ] ++ [
"--print-errorlogs"
];
@@ -365,18 +366,33 @@ in
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-functional-tests = callPackage ../tests/functional/package.nix {
version = fineVersion;
};
+ /**
+ The manual as would be published on https://nix.dev/reference/nix-manual
+ */
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; };
+ /**
+ Doxygen pages for the public C API
+ */
nix-external-api-docs = callPackage ../src/external-api-docs/package.nix { version = fineVersion; };
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 { } // {
# Note: no `passthru.overrideAllMesonComponents` etc
# This would propagate into `nix.overrideAttrs f`, but then discard
diff --git a/packaging/dependencies.nix b/packaging/dependencies.nix
index 7ce3bf125..981c1aa48 100644
--- a/packaging/dependencies.nix
+++ b/packaging/dependencies.nix
@@ -10,27 +10,8 @@
stdenv,
}:
-let
- prevStdenv = stdenv;
-in
-
let
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
scope: {
inherit stdenv;
@@ -50,8 +31,40 @@ scope: {
requiredSystemFeatures = [ ];
};
- boehmgc = pkgs.boehmgc.override {
- enableLargeConfig = true;
+ boehmgc =
+ (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.
@@ -62,6 +75,7 @@ scope: {
"--with-context"
"--with-coroutine"
"--with-iostreams"
+ "--with-url"
];
enableIcu = false;
}).overrideAttrs
diff --git a/packaging/dev-shell.nix b/packaging/dev-shell.nix
index 8d3fa3852..949f79752 100644
--- a/packaging/dev-shell.nix
+++ b/packaging/dev-shell.nix
@@ -71,17 +71,16 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
# We use this shell with the local checkout, not unpackPhase.
src = null;
- env =
- {
- # For `make format`, to work without installing pre-commit
- _NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml"
- modular.pre-commit.settings.rawConfig
- }";
- }
- // lib.optionalAttrs stdenv.hostPlatform.isLinux {
- CC_LD = "mold";
- CXX_LD = "mold";
- };
+ env = {
+ # For `make format`, to work without installing pre-commit
+ _NIX_PRE_COMMIT_HOOKS_CONFIG = "${(pkgs.formats.yaml { }).generate "pre-commit-config.yaml"
+ modular.pre-commit.settings.rawConfig
+ }";
+ }
+ // lib.optionalAttrs stdenv.hostPlatform.isLinux {
+ CC_LD = "mold";
+ CXX_LD = "mold";
+ };
mesonFlags =
map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents2.nix-util.mesonFlags)
@@ -113,27 +112,31 @@ pkgs.nixComponents2.nix-util.overrideAttrs (
) pkgs.buildPackages.mesonEmulatorHook
++ [
pkgs.buildPackages.cmake
+ pkgs.buildPackages.gnused
pkgs.buildPackages.shellcheck
pkgs.buildPackages.changelog-d
modular.pre-commit.settings.package
(pkgs.writeScriptBin "pre-commit-hooks-install" modular.pre-commit.settings.installationScript)
pkgs.buildPackages.nixfmt-rfc-style
+ pkgs.buildPackages.gdb
]
++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) (
lib.hiPrio pkgs.buildPackages.clang-tools
)
++ lib.optional stdenv.hostPlatform.isLinux pkgs.buildPackages.mold-wrapped;
- buildInputs =
- attrs.buildInputs or [ ]
- ++ pkgs.nixComponents2.nix-util.buildInputs
- ++ pkgs.nixComponents2.nix-store.buildInputs
- ++ pkgs.nixComponents2.nix-store-tests.externalBuildInputs
- ++ pkgs.nixComponents2.nix-fetchers.buildInputs
- ++ pkgs.nixComponents2.nix-expr.buildInputs
- ++ pkgs.nixComponents2.nix-expr.externalPropagatedBuildInputs
- ++ pkgs.nixComponents2.nix-cmd.buildInputs
- ++ lib.optionals havePerl pkgs.nixComponents2.nix-perl-bindings.externalBuildInputs
- ++ lib.optional havePerl pkgs.perl;
+ buildInputs = [
+ pkgs.gbenchmark
+ ]
+ ++ attrs.buildInputs or [ ]
+ ++ pkgs.nixComponents2.nix-util.buildInputs
+ ++ pkgs.nixComponents2.nix-store.buildInputs
+ ++ pkgs.nixComponents2.nix-store-tests.externalBuildInputs
+ ++ pkgs.nixComponents2.nix-fetchers.buildInputs
+ ++ pkgs.nixComponents2.nix-expr.buildInputs
+ ++ pkgs.nixComponents2.nix-expr.externalPropagatedBuildInputs
+ ++ pkgs.nixComponents2.nix-cmd.buildInputs
+ ++ lib.optionals havePerl pkgs.nixComponents2.nix-perl-bindings.externalBuildInputs
+ ++ lib.optional havePerl pkgs.perl;
}
)
diff --git a/packaging/everything.nix b/packaging/everything.nix
index 5bf57f95a..f6bdad490 100644
--- a/packaging/everything.nix
+++ b/packaging/everything.nix
@@ -47,25 +47,25 @@
}:
let
- libs =
- {
- inherit
- nix-util
- nix-util-c
- nix-store
- nix-store-c
- nix-fetchers
- nix-fetchers-c
- nix-expr
- nix-expr-c
- nix-flake
- nix-flake-c
- nix-main
- nix-main-c
- nix-cmd
- ;
- }
- // lib.optionalAttrs
+ libs = {
+ inherit
+ nix-util
+ nix-util-c
+ nix-store
+ nix-store-c
+ nix-fetchers
+ nix-fetchers-c
+ nix-expr
+ nix-expr-c
+ nix-flake
+ nix-flake-c
+ nix-main
+ nix-main-c
+ nix-cmd
+ ;
+ }
+ //
+ lib.optionalAttrs
(!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
{
# Currently fails in static build
@@ -127,20 +127,19 @@ stdenv.mkDerivation (finalAttrs: {
*/
dontFixup = true;
- checkInputs =
- [
- # Make sure the unit tests have passed
- nix-util-tests.tests.run
- nix-store-tests.tests.run
- nix-expr-tests.tests.run
- nix-fetchers-tests.tests.run
- nix-flake-tests.tests.run
+ checkInputs = [
+ # Make sure the unit tests have passed
+ nix-util-tests.tests.run
+ nix-store-tests.tests.run
+ nix-expr-tests.tests.run
+ nix-fetchers-tests.tests.run
+ nix-flake-tests.tests.run
- # Make sure the functional tests have passed
- nix-functional-tests
- ]
- ++ lib.optionals
- (!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
+ # Make sure the functional tests have passed
+ nix-functional-tests
+ ]
+ ++
+ lib.optionals (!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
[
# Perl currently fails in static build
# TODO: Split out tests into a separate derivation?
diff --git a/packaging/hydra.nix b/packaging/hydra.nix
index 27c09d9c9..9f9749bde 100644
--- a/packaging/hydra.nix
+++ b/packaging/hydra.nix
@@ -223,10 +223,17 @@ in
dockerImage = lib.genAttrs linux64BitSystems (system: self.packages.${system}.dockerImage);
# # Line coverage analysis.
- # coverage = nixpkgsFor.x86_64-linux.native.nix.override {
- # pname = "nix-coverage";
- # withCoverageChecks = true;
- # };
+ coverage =
+ (import ./../ci/gha/tests rec {
+ 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
manual = nixpkgsFor.x86_64-linux.native.nixComponents2.nix-manual;
@@ -240,7 +247,9 @@ in
# System tests.
tests =
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;
}
// {
diff --git a/scripts/install-freebsd-multi-user.sh b/scripts/install-freebsd-multi-user.sh
new file mode 100644
index 000000000..0d8b85ec4
--- /dev/null
+++ b/scripts/install-freebsd-multi-user.sh
@@ -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 < /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"
+}
diff --git a/scripts/install-multi-user.sh b/scripts/install-multi-user.sh
index f051ccc46..477eb1fd6 100644
--- a/scripts/install-multi-user.sh
+++ b/scripts/install-multi-user.sh
@@ -33,7 +33,8 @@ readonly NIX_BUILD_GROUP_NAME="nixbld"
readonly NIX_ROOT="/nix"
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_NIX_FILE="$NIX_ROOT/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"
@@ -99,6 +100,14 @@ is_os_darwin() {
fi
}
+is_os_freebsd() {
+ if [ "$(uname -s)" = "FreeBSD" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
contact_us() {
echo "You can open an issue at"
echo "https://github.com/NixOS/nix/issues/new?labels=installer&template=installer.md"
@@ -498,6 +507,10 @@ You have aborted the installation.
EOF
fi
fi
+
+ if is_os_freebsd; then
+ ok "Detected FreeBSD, will set up rc.d service for nix-daemon"
+ fi
}
setup_report() {
@@ -834,8 +847,13 @@ install_from_extracted_nix() {
(
cd "$EXTRACTED_NIX_PATH"
- _sudo "to copy the basic Nix files to the new store at $NIX_ROOT/store" \
- cp -RPp ./store/* "$NIX_ROOT/store/"
+ if is_os_darwin || is_os_freebsd; then
+ _sudo "to copy the basic Nix files to the new store at $NIX_ROOT/store" \
+ cp -RPp ./store/* "$NIX_ROOT/store/"
+ else
+ _sudo "to copy the basic Nix files to the new store at $NIX_ROOT/store" \
+ cp -RP --preserve=ownership,timestamps ./store/* "$NIX_ROOT/store/"
+ fi
_sudo "to make the new store non-writable at $NIX_ROOT/store" \
chmod -R ugo-w "$NIX_ROOT/store/"
@@ -984,11 +1002,22 @@ main() {
# shellcheck source=./install-systemd-multi-user.sh
. "$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"
+ 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
failure "Sorry, I don't know what to do on $(uname)"
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
if ! is_root; then
diff --git a/scripts/install-nix-from-tarball.sh b/scripts/install-nix-from-tarball.sh
index 8d127a9c5..fd00460ec 100644
--- a/scripts/install-nix-from-tarball.sh
+++ b/scripts/install-nix-from-tarball.sh
@@ -26,8 +26,10 @@ if [ -z "$HOME" ]; then
exit 1
fi
+OS="$(uname -s)"
+
# 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
$(sw_vers -productVersion)
EOF
@@ -39,11 +41,11 @@ EOF
fi
# Determine if we could use the multi-user installer or not
-if [ "$(uname -s)" = "Linux" ]; then
- echo "Note: a multi-user installation is possible. See https://nixos.org/manual/nix/stable/installation/installing-binary.html#multi-user-installation" >&2
+if [ "$OS" = "Linux" ] || [ "$OS" = "FreeBSD" ]; then
+ echo "Note: a multi-user installation is possible. See https://nix.dev/manual/nix/stable/installation/installing-binary.html#multi-user-installation" >&2
fi
-case "$(uname -s)" in
+case "$OS" in
"Darwin")
INSTALL_MODE=daemon;;
*)
@@ -60,7 +62,7 @@ while [ $# -gt 0 ]; do
ACTION=install
;;
--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
exit 1
fi
@@ -96,7 +98,7 @@ while [ $# -gt 0 ]; do
echo " providing multi-user support and better isolation for local builds."
echo " Both for security and reproducibility, this method is recommended if"
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 " --no-daemon: Simple, single-user installation that does not require root and is"
echo " trivial to uninstall."
@@ -123,6 +125,13 @@ while [ $# -gt 0 ]; do
done
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'
exec "$self/install-multi-user" $ACTION
exit 0
@@ -144,7 +153,7 @@ if ! [ -e "$dest" ]; then
fi
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
fi
@@ -167,7 +176,11 @@ for i in $(cd "$self/store" >/dev/null && echo ./*); do
rm -rf "$i_tmp"
fi
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 +w "$i_tmp"
mv "$i_tmp" "$dest/store/$i"
diff --git a/scripts/meson.build b/scripts/meson.build
index 777da42b1..bbcf3ef56 100644
--- a/scripts/meson.build
+++ b/scripts/meson.build
@@ -2,19 +2,19 @@ configure_file(
input : 'nix-profile.sh.in',
output : 'nix-profile.sh',
configuration : {
- 'localstatedir': localstatedir,
- }
+ 'localstatedir' : localstatedir,
+ },
)
foreach rc : [ '.sh', '.fish', '-daemon.sh', '-daemon.fish' ]
configure_file(
- input : 'nix-profile' + rc + '.in',
+ input : 'nix-profile' + rc + '.in',
output : 'nix' + rc,
install : true,
install_dir : get_option('profile-dir'),
install_mode : 'rw-r--r--',
configuration : {
- 'localstatedir': localstatedir,
+ 'localstatedir' : localstatedir,
},
)
endforeach
diff --git a/scripts/serve-installer-for-github-actions b/scripts/serve-installer-for-github-actions
deleted file mode 100755
index 2efd2aa32..000000000
--- a/scripts/serve-installer-for-github-actions
+++ /dev/null
@@ -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"
diff --git a/src/external-api-docs/meson.build b/src/external-api-docs/meson.build
index 62474ffe4..cba6f646b 100644
--- a/src/external-api-docs/meson.build
+++ b/src/external-api-docs/meson.build
@@ -1,4 +1,5 @@
-project('nix-external-api-docs',
+project(
+ 'nix-external-api-docs',
version : files('.version'),
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
@@ -10,7 +11,7 @@ doxygen_cfg = configure_file(
input : 'doxygen.cfg.in',
output : 'doxygen.cfg',
configuration : {
- 'PROJECT_NUMBER': meson.project_version(),
+ 'PROJECT_NUMBER' : meson.project_version(),
'OUTPUT_DIRECTORY' : meson.current_build_dir(),
'src' : fs.parent(fs.parent(meson.project_source_root())),
},
@@ -20,7 +21,7 @@ doxygen = find_program('doxygen', native : true, required : true)
custom_target(
'external-api-docs',
- command : [ doxygen , doxygen_cfg ],
+ command : [ doxygen, doxygen_cfg ],
input : [
doxygen_cfg,
],
diff --git a/src/internal-api-docs/doxygen.cfg.in b/src/internal-api-docs/doxygen.cfg.in
index 950497ca3..2769edd9f 100644
--- a/src/internal-api-docs/doxygen.cfg.in
+++ b/src/internal-api-docs/doxygen.cfg.in
@@ -57,9 +57,7 @@ INPUT = \
@src@/libutil/args \
@src@/libutil-tests \
@src@/libutil-test-support/tests \
- @src@/nix \
- @src@/nix-env \
- @src@/nix-store
+ @src@/nix
# 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
diff --git a/src/internal-api-docs/meson.build b/src/internal-api-docs/meson.build
index c0426621e..daab4c93c 100644
--- a/src/internal-api-docs/meson.build
+++ b/src/internal-api-docs/meson.build
@@ -1,4 +1,5 @@
-project('nix-internal-api-docs',
+project(
+ 'nix-internal-api-docs',
version : files('.version'),
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
@@ -10,7 +11,7 @@ doxygen_cfg = configure_file(
input : 'doxygen.cfg.in',
output : 'doxygen.cfg',
configuration : {
- 'PROJECT_NUMBER': meson.project_version(),
+ 'PROJECT_NUMBER' : meson.project_version(),
'OUTPUT_DIRECTORY' : meson.current_build_dir(),
'BUILD_ROOT' : meson.build_root(),
'src' : fs.parent(fs.parent(meson.project_source_root())) / 'src',
@@ -21,7 +22,7 @@ doxygen = find_program('doxygen', native : true, required : true)
custom_target(
'internal-api-docs',
- command : [ doxygen , doxygen_cfg ],
+ command : [ doxygen, doxygen_cfg ],
input : [
doxygen_cfg,
],
diff --git a/src/libcmd/built-path.cc b/src/libcmd/built-path.cc
index 1238f9422..80d97dc3e 100644
--- a/src/libcmd/built-path.cc
+++ b/src/libcmd/built-path.cc
@@ -10,23 +10,13 @@
namespace nix {
// Custom implementation to avoid `ref` ptr equality
-GENERATE_CMP_EXT(
- ,
- std::strong_ordering,
- SingleBuiltPathBuilt,
- *me->drvPath,
- me->output);
+GENERATE_CMP_EXT(, std::strong_ordering, SingleBuiltPathBuilt, *me->drvPath, me->output);
// Custom implementation to avoid `ref` ptr equality
// TODO no `GENERATE_CMP_EXT` because no `std::set::operator<=>` on
// Darwin, per header.
-GENERATE_EQUAL(
- ,
- BuiltPathBuilt ::,
- BuiltPathBuilt,
- *me->drvPath,
- me->outputs);
+GENERATE_EQUAL(, BuiltPathBuilt ::, BuiltPathBuilt, *me->drvPath, me->outputs);
StorePath SingleBuiltPath::outPath() const
{
@@ -34,8 +24,8 @@ StorePath SingleBuiltPath::outPath() const
overloaded{
[](const SingleBuiltPath::Opaque & p) { return p.path; },
[](const SingleBuiltPath::Built & b) { return b.output.second; },
- }, raw()
- );
+ },
+ raw());
}
StorePathSet BuiltPath::outPaths() const
@@ -49,13 +39,13 @@ StorePathSet BuiltPath::outPaths() const
res.insert(path);
return res;
},
- }, raw()
- );
+ },
+ raw());
}
SingleDerivedPath::Built SingleBuiltPath::Built::discardOutputPath() const
{
- return SingleDerivedPath::Built {
+ return SingleDerivedPath::Built{
.drvPath = make_ref(drvPath->discardOutputPath()),
.output = output.first,
};
@@ -65,14 +55,10 @@ SingleDerivedPath SingleBuiltPath::discardOutputPath() const
{
return std::visit(
overloaded{
- [](const SingleBuiltPath::Opaque & p) -> SingleDerivedPath {
- return p;
- },
- [](const SingleBuiltPath::Built & b) -> SingleDerivedPath {
- return b.discardOutputPath();
- },
- }, raw()
- );
+ [](const SingleBuiltPath::Opaque & p) -> SingleDerivedPath { return p; },
+ [](const SingleBuiltPath::Built & b) -> SingleDerivedPath { return b.discardOutputPath(); },
+ },
+ raw());
}
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
{
- return std::visit([&](const auto & buildable) {
- return buildable.toJSON(store);
- }, raw());
+ return std::visit([&](const auto & buildable) { return buildable.toJSON(store); }, raw());
}
nlohmann::json BuiltPath::toJSON(const StoreDirConfig & store) const
{
- return std::visit([&](const auto & buildable) {
- return buildable.toJSON(store);
- }, raw());
+ return std::visit([&](const auto & buildable) { return buildable.toJSON(store); }, raw());
}
RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const
@@ -116,20 +98,18 @@ RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const
overloaded{
[&](const BuiltPath::Opaque & p) { res.insert(p.path); },
[&](const BuiltPath::Built & p) {
- auto drvHashes =
- staticOutputHashes(store, store.readDerivation(p.drvPath->outPath()));
- for (auto& [outputName, outputPath] : p.outputs) {
- if (experimentalFeatureSettings.isEnabled(
- Xp::CaDerivations)) {
+ auto drvHashes = staticOutputHashes(store, store.readDerivation(p.drvPath->outPath()));
+ for (auto & [outputName, outputPath] : p.outputs) {
+ if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
auto drvOutput = get(drvHashes, outputName);
if (!drvOutput)
throw Error(
"the derivation '%s' has unrealised output '%s' (derived-path.cc/toRealisedPaths)",
- store.printStorePath(p.drvPath->outPath()), outputName);
- auto thisRealisation = store.queryRealisation(
- DrvOutput{*drvOutput, outputName});
- assert(thisRealisation); // We’ve built it, so we must
- // have the realisation
+ store.printStorePath(p.drvPath->outPath()),
+ outputName);
+ auto thisRealisation = store.queryRealisation(DrvOutput{*drvOutput, outputName});
+ assert(thisRealisation); // We’ve built it, so we must
+ // have the realisation
res.insert(*thisRealisation);
} else {
res.insert(outputPath);
@@ -141,4 +121,4 @@ RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const
return res;
}
-}
+} // namespace nix
diff --git a/src/libcmd/command-installable-value.cc b/src/libcmd/command-installable-value.cc
index 0884f17e9..34e161b4b 100644
--- a/src/libcmd/command-installable-value.cc
+++ b/src/libcmd/command-installable-value.cc
@@ -8,4 +8,4 @@ void InstallableValueCommand::run(ref store, ref installable
run(store, installableValue);
}
-}
+} // namespace nix
diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc
index 31f64fd5a..6b6bbe345 100644
--- a/src/libcmd/command.cc
+++ b/src/libcmd/command.cc
@@ -402,4 +402,4 @@ void MixOutLinkBase::createOutLinksMaybe(const std::vector
createOutLinks(outLink, toBuiltPaths(buildables), *store2);
}
-}
+} // namespace nix
diff --git a/src/libcmd/common-eval-args.cc b/src/libcmd/common-eval-args.cc
index d275beb12..f7e086c16 100644
--- a/src/libcmd/common-eval-args.cc
+++ b/src/libcmd/common-eval-args.cc
@@ -15,15 +15,15 @@
#include "nix/fetchers/fetch-to-store.hh"
#include "nix/cmd/compatibility-settings.hh"
#include "nix/expr/eval-settings.hh"
+#include "nix/store/globals.hh"
namespace nix {
-
fetchers::Settings fetchSettings;
static GlobalConfig::Register rFetchSettings(&fetchSettings);
-EvalSettings evalSettings {
+EvalSettings evalSettings{
settings.readOnlyMode,
{
{
@@ -31,7 +31,7 @@ EvalSettings evalSettings {
[](EvalState & state, std::string_view rest) {
experimentalFeatureSettings.require(Xp::Flakes);
// 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);
auto [accessor, lockedRef] = flakeRef.resolve(state.store).lazyFetch(state.store);
auto storePath = nix::fetchToStore(
@@ -49,17 +49,14 @@ EvalSettings evalSettings {
static GlobalConfig::Register rEvalSettings(&evalSettings);
-
flake::Settings flakeSettings;
static GlobalConfig::Register rFlakeSettings(&flakeSettings);
-
-CompatibilitySettings compatibilitySettings {};
+CompatibilitySettings compatibilitySettings{};
static GlobalConfig::Register rCompatibilitySettings(&compatibilitySettings);
-
MixEvalArgs::MixEvalArgs()
{
addFlag({
@@ -67,7 +64,9 @@ MixEvalArgs::MixEvalArgs()
.description = "Pass the value *expr* as the argument *name* to Nix functions.",
.category = category,
.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({
@@ -75,7 +74,9 @@ MixEvalArgs::MixEvalArgs()
.description = "Pass the string *string* as the argument *name* to Nix functions.",
.category = category,
.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({
@@ -83,7 +84,9 @@ MixEvalArgs::MixEvalArgs()
.description = "Pass the contents of file *path* as the argument *name* to Nix functions.",
.category = category,
.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,
});
@@ -107,18 +110,14 @@ MixEvalArgs::MixEvalArgs()
)",
.category = category,
.labels = {"path"},
- .handler = {[&](std::string s) {
- lookupPath.elements.emplace_back(LookupPath::Elem::parse(s));
- }},
+ .handler = {[&](std::string s) { lookupPath.elements.emplace_back(LookupPath::Elem::parse(s)); }},
});
addFlag({
.longName = "impure",
.description = "Allow access to mutable paths and repositories.",
.category = category,
- .handler = {[&]() {
- evalSettings.pureEval = false;
- }},
+ .handler = {[&]() { evalSettings.pureEval = false; }},
});
addFlag({
@@ -130,7 +129,8 @@ MixEvalArgs::MixEvalArgs()
auto from = parseFlakeRef(fetchSettings, _from, std::filesystem::current_path().string());
auto to = parseFlakeRef(fetchSettings, _to, std::filesystem::current_path().string());
fetchers::Attrs extraAttrs;
- if (to.subdir != "") extraAttrs["dir"] = to.subdir;
+ if (to.subdir != "")
+ extraAttrs["dir"] = to.subdir;
fetchers::overrideRegistry(from.input, to.input, extraAttrs);
}},
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
@@ -141,7 +141,7 @@ MixEvalArgs::MixEvalArgs()
addFlag({
.longName = "eval-store",
.description =
- R"(
+ R"(
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.
)",
@@ -156,20 +156,21 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state)
auto res = state.buildBindings(autoArgs.size());
for (auto & [name, arg] : autoArgs) {
auto v = state.allocValue();
- std::visit(overloaded {
- [&](const AutoArgExpr & arg) {
- state.mkThunk_(*v, state.parseExprFromString(arg.expr, compatibilitySettings.nixShellShebangArgumentsRelativeToScript ? state.rootPath(absPath(getCommandBaseDir())) : state.rootPath(".")));
- },
- [&](const AutoArgString & arg) {
- v->mkString(arg.s);
- },
- [&](const AutoArgFile & arg) {
- v->mkString(readFile(arg.path.string()));
- },
- [&](const AutoArgStdin & arg) {
- v->mkString(readFile(STDIN_FILENO));
- }
- }, arg);
+ std::visit(
+ overloaded{
+ [&](const AutoArgExpr & arg) {
+ state.mkThunk_(
+ *v,
+ state.parseExprFromString(
+ arg.expr,
+ compatibilitySettings.nixShellShebangArgumentsRelativeToScript
+ ? state.rootPath(absPath(getCommandBaseDir()))
+ : state.rootPath(".")));
+ },
+ [&](const AutoArgString & arg) { v->mkString(arg.s); },
+ [&](const AutoArgFile & arg) { v->mkString(readFile(arg.path.string())); },
+ [&](const AutoArgStdin & arg) { v->mkString(readFile(STDIN_FILENO)); }},
+ arg);
res.insert(state.symbols.create(name), v);
}
return res.finish();
@@ -178,15 +179,8 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state)
SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * baseDir)
{
if (EvalSettings::isPseudoUrl(s)) {
- auto accessor = fetchers::downloadTarball(
- state.store,
- state.fetchSettings,
- EvalSettings::resolvePseudoUrl(s));
- auto storePath = fetchToStore(
- state.fetchSettings,
- *state.store,
- SourcePath(accessor),
- FetchMode::Copy);
+ auto accessor = fetchers::downloadTarball(state.store, state.fetchSettings, EvalSettings::resolvePseudoUrl(s));
+ auto storePath = fetchToStore(state.fetchSettings, *state.store, SourcePath(accessor), FetchMode::Copy);
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 [accessor, lockedRef] = flakeRef.resolve(state.store).lazyFetch(state.store);
auto storePath = nix::fetchToStore(
- state.fetchSettings,
- *state.store,
- SourcePath(accessor),
- FetchMode::Copy,
- lockedRef.input.getName());
+ state.fetchSettings, *state.store, SourcePath(accessor), FetchMode::Copy, lockedRef.input.getName());
state.allowPath(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));
}
-}
+} // namespace nix
diff --git a/src/libcmd/editor-for.cc b/src/libcmd/editor-for.cc
index a5d635859..95fdf95ad 100644
--- a/src/libcmd/editor-for.cc
+++ b/src/libcmd/editor-for.cc
@@ -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);
auto editor = getEnv("EDITOR").value_or("cat");
auto args = tokenizeString(editor);
- if (line > 0 && (
- editor.find("emacs") != std::string::npos ||
- editor.find("nano") != std::string::npos ||
- editor.find("vim") != std::string::npos ||
- editor.find("kak") != std::string::npos))
+ if (line > 0
+ && (editor.find("emacs") != std::string::npos || editor.find("nano") != std::string::npos
+ || editor.find("vim") != std::string::npos || editor.find("kak") != std::string::npos))
args.push_back(fmt("+%d", line));
args.push_back(path->string());
return args;
}
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/built-path.hh b/src/libcmd/include/nix/cmd/built-path.hh
index c885876a7..d41529e5a 100644
--- a/src/libcmd/include/nix/cmd/built-path.hh
+++ b/src/libcmd/include/nix/cmd/built-path.hh
@@ -8,7 +8,8 @@ namespace nix {
struct SingleBuiltPath;
-struct SingleBuiltPathBuilt {
+struct SingleBuiltPathBuilt
+{
ref drvPath;
std::pair output;
@@ -18,26 +19,25 @@ struct SingleBuiltPathBuilt {
static SingleBuiltPathBuilt parse(const StoreDirConfig & store, std::string_view, std::string_view);
nlohmann::json toJSON(const StoreDirConfig & store) const;
- bool operator ==(const SingleBuiltPathBuilt &) const noexcept;
- std::strong_ordering operator <=>(const SingleBuiltPathBuilt &) const noexcept;
+ bool operator==(const SingleBuiltPathBuilt &) const noexcept;
+ std::strong_ordering operator<=>(const SingleBuiltPathBuilt &) const noexcept;
};
-using _SingleBuiltPathRaw = std::variant<
- DerivedPathOpaque,
- SingleBuiltPathBuilt
->;
+using _SingleBuiltPathRaw = std::variant;
-struct SingleBuiltPath : _SingleBuiltPathRaw {
+struct SingleBuiltPath : _SingleBuiltPathRaw
+{
using Raw = _SingleBuiltPathRaw;
using Raw::Raw;
using Opaque = DerivedPathOpaque;
using Built = SingleBuiltPathBuilt;
- bool operator == (const SingleBuiltPath &) const = default;
- auto operator <=> (const SingleBuiltPath &) const = default;
+ bool operator==(const SingleBuiltPath &) const = default;
+ auto operator<=>(const SingleBuiltPath &) const = default;
- inline const Raw & raw() const {
+ inline const Raw & raw() const
+ {
return static_cast(*this);
}
@@ -51,7 +51,7 @@ struct SingleBuiltPath : _SingleBuiltPathRaw {
static inline ref staticDrv(StorePath drvPath)
{
- return make_ref(SingleBuiltPath::Opaque { drvPath });
+ return make_ref(SingleBuiltPath::Opaque{drvPath});
}
/**
@@ -59,40 +59,41 @@ static inline ref staticDrv(StorePath drvPath)
*
* See 'BuiltPath' for more an explanation.
*/
-struct BuiltPathBuilt {
+struct BuiltPathBuilt
+{
ref drvPath;
std::map 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.
- //std::strong_ordering operator <=> (const BuiltPathBuilt &) const noexcept;
+ // std::strong_ordering operator <=> (const BuiltPathBuilt &) const noexcept;
std::string to_string(const StoreDirConfig & store) const;
static BuiltPathBuilt parse(const StoreDirConfig & store, std::string_view, std::string_view);
nlohmann::json toJSON(const StoreDirConfig & store) const;
};
-using _BuiltPathRaw = std::variant<
- DerivedPath::Opaque,
- BuiltPathBuilt
->;
+using _BuiltPathRaw = std::variant;
/**
* A built path. Similar to a DerivedPath, but enriched with the corresponding
* output path(s).
*/
-struct BuiltPath : _BuiltPathRaw {
+struct BuiltPath : _BuiltPathRaw
+{
using Raw = _BuiltPathRaw;
using Raw::Raw;
using Opaque = DerivedPathOpaque;
using Built = BuiltPathBuilt;
- 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;
+ bool 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(*this);
}
@@ -104,4 +105,4 @@ struct BuiltPath : _BuiltPathRaw {
typedef std::vector BuiltPaths;
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/command-installable-value.hh b/src/libcmd/include/nix/cmd/command-installable-value.hh
index b171d9f73..beb77be64 100644
--- a/src/libcmd/include/nix/cmd/command-installable-value.hh
+++ b/src/libcmd/include/nix/cmd/command-installable-value.hh
@@ -20,4 +20,4 @@ struct InstallableValueCommand : InstallableCommand
void run(ref store, ref installable) override;
};
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/common-eval-args.hh b/src/libcmd/include/nix/cmd/common-eval-args.hh
index 88ede1ed7..62518ba0e 100644
--- a/src/libcmd/include/nix/cmd/common-eval-args.hh
+++ b/src/libcmd/include/nix/cmd/common-eval-args.hh
@@ -13,13 +13,17 @@ namespace nix {
class Store;
-namespace fetchers { struct Settings; }
+namespace fetchers {
+struct Settings;
+}
class EvalState;
struct CompatibilitySettings;
class Bindings;
-namespace flake { struct Settings; }
+namespace flake {
+struct Settings;
+}
/**
* @todo Get rid of global settings variables
@@ -54,10 +58,23 @@ struct MixEvalArgs : virtual Args, virtual MixRepair
std::optional evalStoreUrl;
private:
- struct AutoArgExpr { std::string expr; };
- struct AutoArgString { std::string s; };
- struct AutoArgFile { std::filesystem::path path; };
- struct AutoArgStdin { };
+ struct AutoArgExpr
+ {
+ std::string expr;
+ };
+
+ struct AutoArgString
+ {
+ std::string s;
+ };
+
+ struct AutoArgFile
+ {
+ std::filesystem::path path;
+ };
+
+ struct AutoArgStdin
+ {};
using AutoArg = std::variant;
@@ -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);
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/compatibility-settings.hh b/src/libcmd/include/nix/cmd/compatibility-settings.hh
index c7061a0a1..7c34ae17a 100644
--- a/src/libcmd/include/nix/cmd/compatibility-settings.hh
+++ b/src/libcmd/include/nix/cmd/compatibility-settings.hh
@@ -33,4 +33,4 @@ struct CompatibilitySettings : public Config
)"};
};
-};
+}; // namespace nix
diff --git a/src/libcmd/include/nix/cmd/editor-for.hh b/src/libcmd/include/nix/cmd/editor-for.hh
index 11414e823..3fb8a072e 100644
--- a/src/libcmd/include/nix/cmd/editor-for.hh
+++ b/src/libcmd/include/nix/cmd/editor-for.hh
@@ -12,4 +12,4 @@ namespace nix {
*/
Strings editorFor(const SourcePath & file, uint32_t line);
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/installable-attr-path.hh b/src/libcmd/include/nix/cmd/installable-attr-path.hh
index 5a0dc993c..474bb358e 100644
--- a/src/libcmd/include/nix/cmd/installable-attr-path.hh
+++ b/src/libcmd/include/nix/cmd/installable-attr-path.hh
@@ -39,7 +39,10 @@ class InstallableAttrPath : public InstallableValue
const std::string & attrPath,
ExtendedOutputsSpec extendedOutputsSpec);
- std::string what() const override { return attrPath; };
+ std::string what() const override
+ {
+ return attrPath;
+ };
std::pair toValue(EvalState & state) override;
@@ -55,4 +58,4 @@ public:
ExtendedOutputsSpec extendedOutputsSpec);
};
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/installable-derived-path.hh b/src/libcmd/include/nix/cmd/installable-derived-path.hh
index daa6ba868..f255f2bba 100644
--- a/src/libcmd/include/nix/cmd/installable-derived-path.hh
+++ b/src/libcmd/include/nix/cmd/installable-derived-path.hh
@@ -11,8 +11,10 @@ struct InstallableDerivedPath : Installable
DerivedPath derivedPath;
InstallableDerivedPath(ref store, DerivedPath && derivedPath)
- : store(store), derivedPath(std::move(derivedPath))
- { }
+ : store(store)
+ , derivedPath(std::move(derivedPath))
+ {
+ }
std::string what() const override;
@@ -20,10 +22,8 @@ struct InstallableDerivedPath : Installable
std::optional getStorePath() override;
- static InstallableDerivedPath parse(
- ref store,
- std::string_view prefix,
- ExtendedOutputsSpec extendedOutputsSpec);
+ static InstallableDerivedPath
+ parse(ref store, std::string_view prefix, ExtendedOutputsSpec extendedOutputsSpec);
};
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/installable-flake.hh b/src/libcmd/include/nix/cmd/installable-flake.hh
index 8699031b5..935ea8779 100644
--- a/src/libcmd/include/nix/cmd/installable-flake.hh
+++ b/src/libcmd/include/nix/cmd/installable-flake.hh
@@ -18,7 +18,8 @@ struct ExtraPathInfoFlake : ExtraPathInfoValue
/**
* Extra struct to get around C++ designated initializer limitations
*/
- struct Flake {
+ struct Flake
+ {
FlakeRef originalRef;
FlakeRef lockedRef;
};
@@ -26,8 +27,10 @@ struct ExtraPathInfoFlake : ExtraPathInfoValue
Flake flake;
ExtraPathInfoFlake(Value && v, Flake && f)
- : ExtraPathInfoValue(std::move(v)), flake(std::move(f))
- { }
+ : ExtraPathInfoValue(std::move(v))
+ , flake(std::move(f))
+ {
+ }
};
struct InstallableFlake : InstallableValue
@@ -49,7 +52,10 @@ struct InstallableFlake : InstallableValue
Strings prefixes,
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 getActualAttrPaths();
@@ -61,8 +67,7 @@ struct InstallableFlake : InstallableValue
* Get a cursor to every attrpath in getActualAttrPaths() that
* exists. However if none exists, throw an exception.
*/
- std::vector[>
- getCursors(EvalState & state) override;
+ std::vector][> getCursors(EvalState & state) override;
std::shared_ptr getLockedFlake() const;
@@ -79,11 +84,9 @@ struct InstallableFlake : InstallableValue
*/
static inline FlakeRef defaultNixpkgsFlakeRef()
{
- return FlakeRef::fromAttrs(fetchSettings, {{"type","indirect"}, {"id", "nixpkgs"}});
+ return FlakeRef::fromAttrs(fetchSettings, {{"type", "indirect"}, {"id", "nixpkgs"}});
}
-ref openEvalCache(
- EvalState & state,
- std::shared_ptr lockedFlake);
+ref openEvalCache(EvalState & state, std::shared_ptr lockedFlake);
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/installable-value.hh b/src/libcmd/include/nix/cmd/installable-value.hh
index e65c199a5..3521a4154 100644
--- a/src/libcmd/include/nix/cmd/installable-value.hh
+++ b/src/libcmd/include/nix/cmd/installable-value.hh
@@ -9,7 +9,10 @@ namespace nix {
struct PackageInfo;
struct SourceExprCommand;
-namespace eval_cache { class EvalCache; class AttrCursor; }
+namespace eval_cache {
+class EvalCache;
+class AttrCursor;
+} // namespace eval_cache
struct App
{
@@ -37,7 +40,8 @@ struct ExtraPathInfoValue : ExtraPathInfo
/**
* Extra struct to get around C++ designated initializer limitations
*/
- struct Value {
+ struct Value
+ {
/**
* An optional priority for use with "build envs". See Package
*/
@@ -61,7 +65,8 @@ struct ExtraPathInfoValue : ExtraPathInfo
ExtraPathInfoValue(Value && v)
: value(std::move(v))
- { }
+ {
+ }
virtual ~ExtraPathInfoValue() = default;
};
@@ -74,9 +79,12 @@ struct InstallableValue : Installable
{
ref state;
- InstallableValue(ref state) : state(state) {}
+ InstallableValue(ref state)
+ : state(state)
+ {
+ }
- virtual ~InstallableValue() { }
+ virtual ~InstallableValue() {}
virtual std::pair toValue(EvalState & state) = 0;
@@ -85,15 +93,13 @@ struct InstallableValue : Installable
* However if none exists, throw exception instead of returning
* empty vector.
*/
- virtual std::vector][>
- getCursors(EvalState & state);
+ virtual std::vector][> getCursors(EvalState & state);
/**
* Get the first and most preferred cursor this Installable could
* refer to, or throw an exception if none exists.
*/
- virtual ref
- getCursor(EvalState & state);
+ virtual ref getCursor(EvalState & state);
UnresolvedApp toApp(EvalState & state);
@@ -116,7 +122,8 @@ protected:
* @result A derived path (with empty info, for now) if the value
* matched the above criteria.
*/
- std::optional trySinglePathToDerivedPaths(Value & v, const PosIdx pos, std::string_view errorCtx);
+ std::optional
+ trySinglePathToDerivedPaths(Value & v, const PosIdx pos, std::string_view errorCtx);
};
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/installables.hh b/src/libcmd/include/nix/cmd/installables.hh
index 84941278a..530334e03 100644
--- a/src/libcmd/include/nix/cmd/installables.hh
+++ b/src/libcmd/include/nix/cmd/installables.hh
@@ -112,7 +112,7 @@ typedef std::vector][> Installables;
*/
struct Installable
{
- virtual ~Installable() { }
+ virtual ~Installable() {}
/**
* What Installable is this?
@@ -168,37 +168,19 @@ struct Installable
BuildMode bMode = bmNormal);
static std::set toStorePathSet(
- ref evalStore,
- ref store,
- Realise mode,
- OperateOn operateOn,
- const Installables & installables);
+ ref evalStore, ref store, Realise mode, OperateOn operateOn, const Installables & installables);
static std::vector toStorePaths(
- ref evalStore,
- ref store,
- Realise mode,
- OperateOn operateOn,
- const Installables & installables);
+ ref evalStore, ref store, Realise mode, OperateOn operateOn, const Installables & installables);
static StorePath toStorePath(
- ref evalStore,
- ref store,
- Realise mode,
- OperateOn operateOn,
- ref installable);
+ ref evalStore, ref store, Realise mode, OperateOn operateOn, ref installable);
- static std::set toDerivations(
- ref store,
- const Installables & installables,
- bool useDeriver = false);
+ static std::set
+ toDerivations(ref store, const Installables & installables, bool useDeriver = false);
static BuiltPaths toBuiltPaths(
- ref evalStore,
- ref store,
- Realise mode,
- OperateOn operateOn,
- const Installables & installables);
+ ref evalStore, ref store, Realise mode, OperateOn operateOn, const Installables & installables);
};
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/legacy.hh b/src/libcmd/include/nix/cmd/legacy.hh
index 0c375a7d2..546057184 100644
--- a/src/libcmd/include/nix/cmd/legacy.hh
+++ b/src/libcmd/include/nix/cmd/legacy.hh
@@ -7,13 +7,14 @@
namespace nix {
-typedef std::function MainFunction;
+typedef std::function MainFunction;
struct RegisterLegacyCommand
{
typedef std::map Commands;
- static Commands & commands() {
+ static Commands & commands()
+ {
static Commands commands;
return commands;
}
@@ -24,4 +25,4 @@ struct RegisterLegacyCommand
}
};
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/markdown.hh b/src/libcmd/include/nix/cmd/markdown.hh
index 66db1736c..95a59c2aa 100644
--- a/src/libcmd/include/nix/cmd/markdown.hh
+++ b/src/libcmd/include/nix/cmd/markdown.hh
@@ -14,4 +14,4 @@ namespace nix {
*/
std::string renderMarkdownToTerminal(std::string_view markdown);
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/meson.build b/src/libcmd/include/nix/cmd/meson.build
index 368edb28e..119d0814b 100644
--- a/src/libcmd/include/nix/cmd/meson.build
+++ b/src/libcmd/include/nix/cmd/meson.build
@@ -1,6 +1,6 @@
# Public headers directory
-include_dirs = [include_directories('../..')]
+include_dirs = [ include_directories('../..') ]
headers = files(
'built-path.hh',
diff --git a/src/libcmd/include/nix/cmd/misc-store-flags.hh b/src/libcmd/include/nix/cmd/misc-store-flags.hh
index c9467ad8e..27e139076 100644
--- a/src/libcmd/include/nix/cmd/misc-store-flags.hh
+++ b/src/libcmd/include/nix/cmd/misc-store-flags.hh
@@ -4,18 +4,22 @@
namespace nix::flag {
Args::Flag hashAlgo(std::string && longName, HashAlgorithm * ha);
+
static inline Args::Flag hashAlgo(HashAlgorithm * ha)
{
return hashAlgo("hash-algo", ha);
}
+
Args::Flag hashAlgoOpt(std::string && longName, std::optional * oha);
Args::Flag hashFormatWithDefault(std::string && longName, HashFormat * hf);
Args::Flag hashFormatOpt(std::string && longName, std::optional * ohf);
+
static inline Args::Flag hashAlgoOpt(std::optional * oha)
{
return hashAlgoOpt("hash-algo", oha);
}
+
Args::Flag fileIngestionMethod(FileIngestionMethod * method);
Args::Flag contentAddressMethod(ContentAddressMethod * method);
-}
+} // namespace nix::flag
diff --git a/src/libcmd/include/nix/cmd/network-proxy.hh b/src/libcmd/include/nix/cmd/network-proxy.hh
index 255597a61..f51b7dadb 100644
--- a/src/libcmd/include/nix/cmd/network-proxy.hh
+++ b/src/libcmd/include/nix/cmd/network-proxy.hh
@@ -19,4 +19,4 @@ extern const StringSet networkProxyVariables;
*/
bool haveNetworkProxyConnection();
-}
+} // namespace nix
diff --git a/src/libcmd/include/nix/cmd/repl-interacter.hh b/src/libcmd/include/nix/cmd/repl-interacter.hh
index eb58563b2..89e854ad9 100644
--- a/src/libcmd/include/nix/cmd/repl-interacter.hh
+++ b/src/libcmd/include/nix/cmd/repl-interacter.hh
@@ -11,10 +11,11 @@ namespace nix {
namespace detail {
/** Provides the completion hooks for the repl, without exposing its complete
* internals. */
-struct ReplCompleterMixin {
+struct ReplCompleterMixin
+{
virtual StringSet completePrefix(const std::string & prefix) = 0;
};
-};
+}; // namespace detail
enum class ReplPromptType {
ReplPrompt,
@@ -29,7 +30,7 @@ public:
virtual Guard init(detail::ReplCompleterMixin * repl) = 0;
/** Returns a boolean of whether the interacter got EOF */
virtual bool getLine(std::string & input, ReplPromptType promptType) = 0;
- virtual ~ReplInteracter(){};
+ virtual ~ReplInteracter() {};
};
class ReadlineLikeInteracter : public virtual ReplInteracter
@@ -40,9 +41,10 @@ public:
: historyFile(historyFile)
{
}
+
virtual Guard init(detail::ReplCompleterMixin * repl) override;
virtual bool getLine(std::string & input, ReplPromptType promptType) override;
virtual ~ReadlineLikeInteracter() override;
};
-};
+}; // namespace nix
diff --git a/src/libcmd/include/nix/cmd/repl.hh b/src/libcmd/include/nix/cmd/repl.hh
index 83e39727f..a2c905f86 100644
--- a/src/libcmd/include/nix/cmd/repl.hh
+++ b/src/libcmd/include/nix/cmd/repl.hh
@@ -12,12 +12,12 @@ struct AbstractNixRepl
AbstractNixRepl(ref state)
: state(state)
- { }
+ {
+ }
- virtual ~AbstractNixRepl()
- { }
+ virtual ~AbstractNixRepl() {}
- typedef std::vector> AnnotatedValues;
+ typedef std::vector> AnnotatedValues;
using RunNix = void(Path program, const Strings & args, const std::optional & input);
@@ -33,13 +33,11 @@ struct AbstractNixRepl
std::function getValues,
RunNix * runNix = nullptr);
- static ReplExitStatus runSimple(
- ref evalState,
- const ValMap & extraEnv);
+ static ReplExitStatus runSimple(ref evalState, const ValMap & extraEnv);
virtual void initEnv() = 0;
virtual ReplExitStatus mainLoop() = 0;
};
-}
+} // namespace nix
diff --git a/src/libcmd/installable-attr-path.cc b/src/libcmd/installable-attr-path.cc
index 7783b4f40..28c3db3fc 100644
--- a/src/libcmd/installable-attr-path.cc
+++ b/src/libcmd/installable-attr-path.cc
@@ -35,7 +35,8 @@ InstallableAttrPath::InstallableAttrPath(
, v(allocRootValue(v))
, attrPath(attrPath)
, extendedOutputsSpec(std::move(extendedOutputsSpec))
-{ }
+{
+}
std::pair InstallableAttrPath::toValue(EvalState & state)
{
@@ -48,12 +49,9 @@ DerivedPathsWithInfo InstallableAttrPath::toDerivedPaths()
{
auto [v, pos] = toValue(*state);
- if (std::optional derivedPathWithInfo = trySinglePathToDerivedPaths(
- *v,
- pos,
- fmt("while evaluating the attribute '%s'", attrPath)))
- {
- return { *derivedPathWithInfo };
+ if (std::optional derivedPathWithInfo =
+ trySinglePathToDerivedPaths(*v, pos, fmt("while evaluating the attribute '%s'", attrPath))) {
+ return {*derivedPathWithInfo};
}
Bindings & autoArgs = *cmd.getAutoArgs(*state);
@@ -70,19 +68,19 @@ DerivedPathsWithInfo InstallableAttrPath::toDerivedPaths()
if (!drvPath)
throw Error("'%s' is not a derivation", what());
- auto newOutputs = std::visit(overloaded {
- [&](const ExtendedOutputsSpec::Default & d) -> OutputsSpec {
- StringSet outputsToInstall;
- for (auto & output : packageInfo.queryOutputs(false, true))
- outputsToInstall.insert(output.first);
- if (outputsToInstall.empty())
- outputsToInstall.insert("out");
- return OutputsSpec::Names { std::move(outputsToInstall) };
+ auto newOutputs = std::visit(
+ overloaded{
+ [&](const ExtendedOutputsSpec::Default & d) -> OutputsSpec {
+ StringSet outputsToInstall;
+ for (auto & output : packageInfo.queryOutputs(false, true))
+ outputsToInstall.insert(output.first);
+ if (outputsToInstall.empty())
+ outputsToInstall.insert("out");
+ return OutputsSpec::Names{std::move(outputsToInstall)};
+ },
+ [&](const ExtendedOutputsSpec::Explicit & e) -> OutputsSpec { return e; },
},
- [&](const ExtendedOutputsSpec::Explicit & e) -> OutputsSpec {
- return e;
- },
- }, extendedOutputsSpec.raw);
+ extendedOutputsSpec.raw);
auto [iter, didInsert] = byDrvPath.emplace(*drvPath, newOutputs);
@@ -93,11 +91,12 @@ DerivedPathsWithInfo InstallableAttrPath::toDerivedPaths()
DerivedPathsWithInfo res;
for (auto & [drvPath, outputs] : byDrvPath)
res.push_back({
- .path = DerivedPath::Built {
- .drvPath = makeConstantStorePathRef(drvPath),
- .outputs = outputs,
- },
- .info = make_ref(ExtraPathInfoValue::Value {
+ .path =
+ DerivedPath::Built{
+ .drvPath = makeConstantStorePathRef(drvPath),
+ .outputs = outputs,
+ },
+ .info = make_ref(ExtraPathInfoValue::Value{
.extendedOutputsSpec = outputs,
/* FIXME: reconsider backwards compatibility above
so we can fill in this info. */
@@ -115,10 +114,12 @@ InstallableAttrPath InstallableAttrPath::parse(
ExtendedOutputsSpec extendedOutputsSpec)
{
return {
- state, cmd, v,
- prefix == "." ? "" : std::string { prefix },
+ state,
+ cmd,
+ v,
+ prefix == "." ? "" : std::string{prefix},
std::move(extendedOutputsSpec),
};
}
-}
+} // namespace nix
diff --git a/src/libcmd/installable-derived-path.cc b/src/libcmd/installable-derived-path.cc
index 5a92f81c7..929c663d1 100644
--- a/src/libcmd/installable-derived-path.cc
+++ b/src/libcmd/installable-derived-path.cc
@@ -21,35 +21,35 @@ std::optional InstallableDerivedPath::getStorePath()
return derivedPath.getBaseStorePath();
}
-InstallableDerivedPath InstallableDerivedPath::parse(
- ref store,
- std::string_view prefix,
- ExtendedOutputsSpec extendedOutputsSpec)
+InstallableDerivedPath
+InstallableDerivedPath::parse(ref store, std::string_view prefix, ExtendedOutputsSpec extendedOutputsSpec)
{
- auto derivedPath = std::visit(overloaded {
- // If the user did not use ^, we treat the output more
- // liberally: we accept a symlink chain or an actual
- // store path.
- [&](const ExtendedOutputsSpec::Default &) -> DerivedPath {
- auto storePath = store->followLinksToStorePath(prefix);
- return DerivedPath::Opaque {
- .path = std::move(storePath),
- };
+ auto derivedPath = std::visit(
+ overloaded{
+ // If the user did not use ^, we treat the output more
+ // liberally: we accept a symlink chain or an actual
+ // store path.
+ [&](const ExtendedOutputsSpec::Default &) -> DerivedPath {
+ auto storePath = store->followLinksToStorePath(prefix);
+ return DerivedPath::Opaque{
+ .path = std::move(storePath),
+ };
+ },
+ // If the user did use ^, we just do exactly what is written.
+ [&](const ExtendedOutputsSpec::Explicit & outputSpec) -> DerivedPath {
+ auto drv = make_ref(SingleDerivedPath::parse(*store, prefix));
+ drvRequireExperiment(*drv);
+ return DerivedPath::Built{
+ .drvPath = std::move(drv),
+ .outputs = outputSpec,
+ };
+ },
},
- // If the user did use ^, we just do exactly what is written.
- [&](const ExtendedOutputsSpec::Explicit & outputSpec) -> DerivedPath {
- auto drv = make_ref(SingleDerivedPath::parse(*store, prefix));
- drvRequireExperiment(*drv);
- return DerivedPath::Built {
- .drvPath = std::move(drv),
- .outputs = outputSpec,
- };
- },
- }, extendedOutputsSpec.raw);
- return InstallableDerivedPath {
+ extendedOutputsSpec.raw);
+ return InstallableDerivedPath{
store,
std::move(derivedPath),
};
}
-}
+} // namespace nix
diff --git a/src/libcmd/installable-flake.cc b/src/libcmd/installable-flake.cc
index 85a4188a7..5431100d3 100644
--- a/src/libcmd/installable-flake.cc
+++ b/src/libcmd/installable-flake.cc
@@ -28,8 +28,8 @@ namespace nix {
std::vector InstallableFlake::getActualAttrPaths()
{
std::vector res;
- if (attrPaths.size() == 1 && attrPaths.front().starts_with(".")){
- attrPaths.front().erase(0,1);
+ if (attrPaths.size() == 1 && attrPaths.front().starts_with(".")) {
+ attrPaths.front().erase(0, 1);
res.push_back(attrPaths.front());
return res;
}
@@ -47,8 +47,11 @@ static std::string showAttrPaths(const std::vector & paths)
{
std::string s;
for (const auto & [n, i] : enumerate(paths)) {
- if (n > 0) s += n + 1 == paths.size() ? " or " : ", ";
- s += '\''; s += i; s += '\'';
+ if (n > 0)
+ s += n + 1 == paths.size() ? " or " : ", ";
+ s += '\'';
+ s += i;
+ s += '\'';
}
return s;
}
@@ -62,12 +65,12 @@ InstallableFlake::InstallableFlake(
Strings attrPaths,
Strings prefixes,
const flake::LockFlags & lockFlags)
- : InstallableValue(state),
- flakeRef(flakeRef),
- attrPaths(fragment == "" ? attrPaths : Strings{(std::string) fragment}),
- prefixes(fragment == "" ? Strings{} : prefixes),
- extendedOutputsSpec(std::move(extendedOutputsSpec)),
- lockFlags(lockFlags)
+ : InstallableValue(state)
+ , flakeRef(flakeRef)
+ , attrPaths(fragment == "" ? attrPaths : Strings{(std::string) fragment})
+ , prefixes(fragment == "" ? Strings{} : prefixes)
+ , extendedOutputsSpec(std::move(extendedOutputsSpec))
+ , lockFlags(lockFlags)
{
if (cmd && cmd->getAutoArgs(*state)->size())
throw UsageError("'--arg' and '--argstr' are incompatible with flakes");
@@ -87,18 +90,14 @@ DerivedPathsWithInfo InstallableFlake::toDerivedPaths()
auto v = attr->forceValue();
if (std::optional derivedPathWithInfo = trySinglePathToDerivedPaths(
- v,
- noPos,
- fmt("while evaluating the flake output attribute '%s'", attrPath)))
- {
- return { *derivedPathWithInfo };
+ v, noPos, fmt("while evaluating the flake output attribute '%s'", attrPath))) {
+ return {*derivedPathWithInfo};
} else {
throw Error(
"expected flake output attribute '%s' to be a derivation or path but found %s: %s",
attrPath,
showType(v),
- ValuePrinter(*this->state, v, errorPrintOptions)
- );
+ ValuePrinter(*this->state, v, errorPrintOptions));
}
}
@@ -106,46 +105,47 @@ DerivedPathsWithInfo InstallableFlake::toDerivedPaths()
std::optional priority;
- if (attr->maybeGetAttr(state->sOutputSpecified)) {
- } else if (auto aMeta = attr->maybeGetAttr(state->sMeta)) {
+ if (attr->maybeGetAttr(state->s.outputSpecified)) {
+ } else if (auto aMeta = attr->maybeGetAttr(state->s.meta)) {
if (auto aPriority = aMeta->maybeGetAttr("priority"))
priority = aPriority->getInt().value;
}
return {{
- .path = DerivedPath::Built {
- .drvPath = makeConstantStorePathRef(std::move(drvPath)),
- .outputs = std::visit(overloaded {
- [&](const ExtendedOutputsSpec::Default & d) -> OutputsSpec {
- StringSet outputsToInstall;
- if (auto aOutputSpecified = attr->maybeGetAttr(state->sOutputSpecified)) {
- if (aOutputSpecified->getBool()) {
- if (auto aOutputName = attr->maybeGetAttr("outputName"))
- outputsToInstall = { aOutputName->getString() };
- }
- } else if (auto aMeta = attr->maybeGetAttr(state->sMeta)) {
- if (auto aOutputsToInstall = aMeta->maybeGetAttr("outputsToInstall"))
- for (auto & s : aOutputsToInstall->getListOfStrings())
- outputsToInstall.insert(s);
- }
+ .path =
+ DerivedPath::Built{
+ .drvPath = makeConstantStorePathRef(std::move(drvPath)),
+ .outputs = std::visit(
+ overloaded{
+ [&](const ExtendedOutputsSpec::Default & d) -> OutputsSpec {
+ StringSet outputsToInstall;
+ if (auto aOutputSpecified = attr->maybeGetAttr(state->s.outputSpecified)) {
+ if (aOutputSpecified->getBool()) {
+ if (auto aOutputName = attr->maybeGetAttr("outputName"))
+ outputsToInstall = {aOutputName->getString()};
+ }
+ } else if (auto aMeta = attr->maybeGetAttr(state->s.meta)) {
+ if (auto aOutputsToInstall = aMeta->maybeGetAttr("outputsToInstall"))
+ for (auto & s : aOutputsToInstall->getListOfStrings())
+ outputsToInstall.insert(s);
+ }
- if (outputsToInstall.empty())
- outputsToInstall.insert("out");
+ if (outputsToInstall.empty())
+ outputsToInstall.insert("out");
- return OutputsSpec::Names { std::move(outputsToInstall) };
- },
- [&](const ExtendedOutputsSpec::Explicit & e) -> OutputsSpec {
- return e;
- },
- }, extendedOutputsSpec.raw),
- },
+ return OutputsSpec::Names{std::move(outputsToInstall)};
+ },
+ [&](const ExtendedOutputsSpec::Explicit & e) -> OutputsSpec { return e; },
+ },
+ extendedOutputsSpec.raw),
+ },
.info = make_ref(
- ExtraPathInfoValue::Value {
+ ExtraPathInfoValue::Value{
.priority = priority,
.attrPath = attrPath,
.extendedOutputsSpec = extendedOutputsSpec,
},
- ExtraPathInfoFlake::Flake {
+ ExtraPathInfoFlake::Flake{
.originalRef = flakeRef,
.lockedRef = getLockedFlake()->flake.lockedRef,
}),
@@ -157,8 +157,7 @@ std::pair InstallableFlake::toValue(EvalState & state)
return {&getCursor(state)->forceValue(), noPos};
}
-std::vector][>
-InstallableFlake::getCursors(EvalState & state)
+std::vector][> InstallableFlake::getCursors(EvalState & state)
{
auto evalCache = openEvalCache(state, getLockedFlake());
@@ -181,11 +180,7 @@ InstallableFlake::getCursors(EvalState & state)
}
if (res.size() == 0)
- throw Error(
- suggestions,
- "flake '%s' does not provide attribute %s",
- flakeRef,
- showAttrPaths(attrPaths));
+ throw Error(suggestions, "flake '%s' does not provide attribute %s", flakeRef, showAttrPaths(attrPaths));
return res;
}
@@ -196,8 +191,8 @@ std::shared_ptr InstallableFlake::getLockedFlake() const
flake::LockFlags lockFlagsApplyConfig = lockFlags;
// FIXME why this side effect?
lockFlagsApplyConfig.applyNixConfig = true;
- _lockedFlake = std::make_shared(lockFlake(
- flakeSettings, *state, flakeRef, lockFlagsApplyConfig));
+ _lockedFlake =
+ std::make_shared(lockFlake(flakeSettings, *state, flakeRef, lockFlagsApplyConfig));
}
return _lockedFlake;
}
@@ -216,4 +211,4 @@ FlakeRef InstallableFlake::nixpkgsFlakeRef() const
return defaultNixpkgsFlakeRef();
}
-}
+} // namespace nix
diff --git a/src/libcmd/installable-value.cc b/src/libcmd/installable-value.cc
index e92496347..3a167af3d 100644
--- a/src/libcmd/installable-value.cc
+++ b/src/libcmd/installable-value.cc
@@ -4,17 +4,14 @@
namespace nix {
-std::vector][>
-InstallableValue::getCursors(EvalState & state)
+std::vector][> InstallableValue::getCursors(EvalState & state)
{
auto evalCache =
- std::make_shared(std::nullopt, state,
- [&]() { return toValue(state).first; });
+ std::make_shared(std::nullopt, state, [&]() { return toValue(state).first; });
return {evalCache->getRoot()};
}
-ref
-InstallableValue::getCursor(EvalState & state)
+ref InstallableValue::getCursor(EvalState & state)
{
/* Although getCursors should return at least one element, in case it doesn't,
bound check to avoid an undefined behavior for vector[0] */
@@ -39,30 +36,32 @@ ref InstallableValue::require(ref installable)
auto castedInstallable = installable.dynamic_pointer_cast();
if (!castedInstallable)
throw nonValueInstallable(*installable);
- return ref { castedInstallable };
+ return ref{castedInstallable};
}
-std::optional InstallableValue::trySinglePathToDerivedPaths(Value & v, const PosIdx pos, std::string_view errorCtx)
+std::optional
+InstallableValue::trySinglePathToDerivedPaths(Value & v, const PosIdx pos, std::string_view errorCtx)
{
if (v.type() == nPath) {
auto storePath = fetchToStore(state->fetchSettings, *state->store, v.path(), FetchMode::Copy);
return {{
- .path = DerivedPath::Opaque {
- .path = std::move(storePath),
- },
+ .path =
+ DerivedPath::Opaque{
+ .path = std::move(storePath),
+ },
.info = make_ref(),
}};
}
else if (v.type() == nString) {
return {{
- .path = DerivedPath::fromSingle(
- state->coerceToSingleDerivedPath(pos, v, errorCtx)),
+ .path = DerivedPath::fromSingle(state->coerceToSingleDerivedPath(pos, v, errorCtx)),
.info = make_ref(),
}};
}
- else return std::nullopt;
+ else
+ return std::nullopt;
}
-}
+} // namespace nix
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc
index 49ffd82e1..96ff06ad3 100644
--- a/src/libcmd/installables.cc
+++ b/src/libcmd/installables.cc
@@ -61,7 +61,8 @@ MixFlakeOptions::MixFlakeOptions()
.category = category,
.handler = {[&]() {
lockFlags.recreateLockFile = true;
- warn("'--recreate-lock-file' is deprecated and will be removed in a future version; use 'nix flake update' instead.");
+ warn(
+ "'--recreate-lock-file' is deprecated and will be removed in a future version; use 'nix flake update' instead.");
}},
});
@@ -158,9 +159,7 @@ MixFlakeOptions::MixFlakeOptions()
.description = "Write the given lock file instead of `flake.lock` within the top-level flake.",
.category = category,
.labels = {"flake-lock-path"},
- .handler = {[&](std::string lockFilePath) {
- lockFlags.outputLockFilePath = lockFilePath;
- }},
+ .handler = {[&](std::string lockFilePath) { lockFlags.outputLockFilePath = lockFilePath; }},
.completer = completePath,
});
@@ -175,14 +174,20 @@ MixFlakeOptions::MixFlakeOptions()
flakeSettings,
*evalState,
parseFlakeRef(fetchSettings, flakeRef, absPath(getCommandBaseDir())),
- { .writeLockFile = false });
+ {.writeLockFile = false});
for (auto & [inputName, input] : flake.lockFile.root->inputs) {
auto input2 = flake.lockFile.findInput({inputName}); // resolve 'follows' nodes
if (auto input3 = std::dynamic_pointer_cast(input2)) {
+ fetchers::Attrs extraAttrs;
+
+ if (!input3->lockedRef.subdir.empty()) {
+ extraAttrs["dir"] = input3->lockedRef.subdir;
+ }
+
overrideRegistry(
- fetchers::Input::fromAttrs(fetchSettings, {{"type","indirect"}, {"id", inputName}}),
+ fetchers::Input::fromAttrs(fetchSettings, {{"type", "indirect"}, {"id", inputName}}),
input3->lockedRef.input,
- {});
+ extraAttrs);
}
}
}},
@@ -209,7 +214,8 @@ SourceExprCommand::SourceExprCommand()
addFlag({
.longName = "expr",
- .description = "Interpret [*installables*](@docroot@/command-ref/new-cli/nix.md#installables) as attribute paths relative to the Nix expression *expr*.",
+ .description =
+ "Interpret [*installables*](@docroot@/command-ref/new-cli/nix.md#installables) as attribute paths relative to the Nix expression *expr*.",
.category = installablesCategory,
.labels = {"expr"},
.handler = {&expr},
@@ -220,32 +226,26 @@ MixReadOnlyOption::MixReadOnlyOption()
{
addFlag({
.longName = "read-only",
- .description =
- "Do not instantiate each evaluated derivation. "
- "This improves performance, but can cause errors when accessing "
- "store paths of derivations during evaluation.",
+ .description = "Do not instantiate each evaluated derivation. "
+ "This improves performance, but can cause errors when accessing "
+ "store paths of derivations during evaluation.",
.handler = {&settings.readOnlyMode, true},
});
}
Strings SourceExprCommand::getDefaultFlakeAttrPaths()
{
- return {
- "packages." + settings.thisSystem.get() + ".default",
- "defaultPackage." + settings.thisSystem.get()
- };
+ return {"packages." + settings.thisSystem.get() + ".default", "defaultPackage." + settings.thisSystem.get()};
}
Strings SourceExprCommand::getDefaultFlakeAttrPathPrefixes()
{
- return {
- // As a convenience, look for the attribute in
- // 'outputs.packages'.
- "packages." + settings.thisSystem.get() + ".",
- // As a temporary hack until Nixpkgs is properly converted
- // to provide a clean 'packages' set, look in 'legacyPackages'.
- "legacyPackages." + settings.thisSystem.get() + "."
- };
+ return {// As a convenience, look for the attribute in
+ // 'outputs.packages'.
+ "packages." + settings.thisSystem.get() + ".",
+ // As a temporary hack until Nixpkgs is properly converted
+ // to provide a clean 'packages' set, look in 'legacyPackages'.
+ "legacyPackages." + settings.thisSystem.get() + "."};
}
Args::CompleterClosure SourceExprCommand::getCompleteInstallable()
@@ -263,10 +263,7 @@ void SourceExprCommand::completeInstallable(AddCompletions & completions, std::s
evalSettings.pureEval = false;
auto state = getEvalState();
- auto e =
- state->parseExprFromFile(
- resolveExprPath(
- lookupFileArg(*state, *file)));
+ auto e = state->parseExprFromFile(resolveExprPath(lookupFileArg(*state, *file)));
Value root;
state->eval(e, root);
@@ -285,7 +282,7 @@ void SourceExprCommand::completeInstallable(AddCompletions & completions, std::s
}
auto [v, pos] = findAlongAttrPath(*state, prefix_, *autoArgs, root);
- Value &v1(*v);
+ Value & v1(*v);
state->forceValue(v1, pos);
Value v2;
state->autoCallFunction(*autoArgs, v1, v2);
@@ -310,7 +307,7 @@ void SourceExprCommand::completeInstallable(AddCompletions & completions, std::s
getDefaultFlakeAttrPaths(),
prefix);
}
- } catch (EvalError&) {
+ } catch (EvalError &) {
// Don't want eval errors to mess-up with the completion engine, so let's just swallow them
}
}
@@ -334,22 +331,23 @@ void completeFlakeRefWithFragment(
auto fragment = prefix.substr(hash + 1);
std::string prefixRoot = "";
- if (fragment.starts_with(".")){
+ if (fragment.starts_with(".")) {
fragment = fragment.substr(1);
prefixRoot = ".";
}
auto flakeRefS = std::string(prefix.substr(0, hash));
// TODO: ideally this would use the command base directory instead of assuming ".".
- auto flakeRef = parseFlakeRef(fetchSettings, expandTilde(flakeRefS), std::filesystem::current_path().string());
+ auto flakeRef =
+ parseFlakeRef(fetchSettings, expandTilde(flakeRefS), std::filesystem::current_path().string());
- auto evalCache = openEvalCache(*evalState,
- std::make_shared(lockFlake(
- flakeSettings, *evalState, flakeRef, lockFlags)));
+ auto evalCache = openEvalCache(
+ *evalState,
+ std::make_shared(lockFlake(flakeSettings, *evalState, flakeRef, lockFlags)));
auto root = evalCache->getRoot();
- if (prefixRoot == "."){
+ if (prefixRoot == ".") {
attrPathPrefixes.clear();
}
/* Complete 'fragment' relative to all the
@@ -369,7 +367,8 @@ void completeFlakeRefWithFragment(
}
auto attr = root->findAlongAttrPath(attrPath);
- if (!attr) continue;
+ if (!attr)
+ continue;
for (auto & attr2 : (*attr)->getAttrs()) {
if (hasPrefix(evalState->symbols[attr2], lastAttr)) {
@@ -377,7 +376,9 @@ void completeFlakeRefWithFragment(
/* Strip the attrpath prefix. */
attrPath2.erase(attrPath2.begin(), attrPath2.begin() + attrPathPrefix.size());
// FIXME: handle names with dots
- completions.add(flakeRefS + "#" + prefixRoot + concatStringsSep(".", evalState->symbols.resolve(attrPath2)));
+ completions.add(
+ flakeRefS + "#" + prefixRoot
+ + concatStringsSep(".", evalState->symbols.resolve(attrPath2)));
}
}
}
@@ -387,7 +388,8 @@ void completeFlakeRefWithFragment(
if (fragment.empty()) {
for (auto & attrPath : defaultFlakeAttrPaths) {
auto attr = root->findAlongAttrPath(parseAttrPath(*evalState, attrPath));
- if (!attr) continue;
+ if (!attr)
+ continue;
completions.add(flakeRefS + "#" + prefixRoot);
}
}
@@ -427,14 +429,12 @@ DerivedPathWithInfo Installable::toDerivedPath()
{
auto buildables = toDerivedPaths();
if (buildables.size() != 1)
- throw Error("installable '%s' evaluates to %d derivations, where only one is expected", what(), buildables.size());
+ throw Error(
+ "installable '%s' evaluates to %d derivations, where only one is expected", what(), buildables.size());
return std::move(buildables[0]);
}
-static StorePath getDeriver(
- ref store,
- const Installable & i,
- const StorePath & drvPath)
+static StorePath getDeriver(ref store, const Installable & i, const StorePath & drvPath)
{
auto derivers = store->queryValidDerivers(drvPath);
if (derivers.empty())
@@ -443,35 +443,35 @@ static StorePath getDeriver(
return *derivers.begin();
}
-ref openEvalCache(
- EvalState & state,
- std::shared_ptr lockedFlake)
+ref openEvalCache(EvalState & state, std::shared_ptr lockedFlake)
{
auto fingerprint = evalSettings.useEvalCache && evalSettings.pureEval
- ? lockedFlake->getFingerprint(state.store, state.fetchSettings)
- : std::nullopt;
- auto rootLoader = [&state, lockedFlake]()
- {
- /* For testing whether the evaluation cache is
- complete. */
- if (getEnv("NIX_ALLOW_EVAL").value_or("1") == "0")
- throw Error("not everything is cached, but evaluation is not allowed");
+ ? lockedFlake->getFingerprint(state.store, state.fetchSettings)
+ : std::nullopt;
+ auto rootLoader = [&state, lockedFlake]() {
+ /* For testing whether the evaluation cache is
+ complete. */
+ if (getEnv("NIX_ALLOW_EVAL").value_or("1") == "0")
+ throw Error("not everything is cached, but evaluation is not allowed");
- auto vFlake = state.allocValue();
- flake::callFlake(state, *lockedFlake, *vFlake);
+ auto vFlake = state.allocValue();
+ flake::callFlake(state, *lockedFlake, *vFlake);
- state.forceAttrs(*vFlake, noPos, "while parsing cached flake data");
+ state.forceAttrs(*vFlake, noPos, "while parsing cached flake data");
- auto aOutputs = vFlake->attrs()->get(state.symbols.create("outputs"));
- assert(aOutputs);
+ auto aOutputs = vFlake->attrs()->get(state.symbols.create("outputs"));
+ assert(aOutputs);
- return aOutputs->value;
- };
+ return aOutputs->value;
+ };
if (fingerprint) {
auto search = state.evalCaches.find(fingerprint.value());
if (search == state.evalCaches.end()) {
- search = state.evalCaches.emplace(fingerprint.value(), make_ref(fingerprint, state, rootLoader)).first;
+ search =
+ state.evalCaches
+ .emplace(fingerprint.value(), make_ref(fingerprint, state, rootLoader))
+ .first;
}
return search->second;
} else {
@@ -479,8 +479,7 @@ ref openEvalCache(
}
}
-Installables SourceExprCommand::parseInstallables(
- ref store, std::vector ss)
+Installables SourceExprCommand::parseInstallables(ref store, std::vector ss)
{
Installables result;
@@ -501,12 +500,10 @@ Installables SourceExprCommand::parseInstallables(
if (file == "-") {
auto e = state->parseStdin();
state->eval(e, *vFile);
- }
- else if (file) {
+ } else if (file) {
auto dir = absPath(getCommandBaseDir());
state->evalFile(lookupFileArg(*state, *file, &dir), *vFile);
- }
- else {
+ } else {
Path dir = absPath(getCommandBaseDir());
auto e = state->parseExprFromString(*expr, state->rootPath(dir));
state->eval(e, *vFile);
@@ -515,9 +512,8 @@ Installables SourceExprCommand::parseInstallables(
for (auto & s : ss) {
auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse(s);
result.push_back(
- make_ref(
- InstallableAttrPath::parse(
- state, *this, vFile, std::move(prefix), std::move(extendedOutputsSpec))));
+ make_ref(InstallableAttrPath::parse(
+ state, *this, vFile, std::move(prefix), std::move(extendedOutputsSpec))));
}
} else {
@@ -532,8 +528,9 @@ Installables SourceExprCommand::parseInstallables(
if (prefix.find('/') != std::string::npos) {
try {
- result.push_back(make_ref(
- InstallableDerivedPath::parse(store, prefix, extendedOutputsSpec.raw)));
+ result.push_back(
+ make_ref(
+ InstallableDerivedPath::parse(store, prefix, extendedOutputsSpec.raw)));
continue;
} catch (BadStorePath &) {
} catch (...) {
@@ -543,9 +540,10 @@ Installables SourceExprCommand::parseInstallables(
}
try {
- auto [flakeRef, fragment] = parseFlakeRefWithFragment(
- fetchSettings, std::string { prefix }, absPath(getCommandBaseDir()));
- result.push_back(make_ref(
+ auto [flakeRef, fragment] =
+ parseFlakeRefWithFragment(fetchSettings, std::string{prefix}, absPath(getCommandBaseDir()));
+ result.push_back(
+ make_ref(
this,
getEvalState(),
std::move(flakeRef),
@@ -566,8 +564,7 @@ Installables SourceExprCommand::parseInstallables(
return result;
}
-ref SourceExprCommand::parseInstallable(
- ref store, const std::string & installable)
+ref SourceExprCommand::parseInstallable(ref store, const std::string & installable)
{
auto installables = parseInstallables(store, {installable});
assert(installables.size() == 1);
@@ -578,20 +575,18 @@ static SingleBuiltPath getBuiltPath(ref evalStore, ref store, cons
{
return std::visit(
overloaded{
- [&](const SingleDerivedPath::Opaque & bo) -> SingleBuiltPath {
- return SingleBuiltPath::Opaque { bo.path };
- },
+ [&](const SingleDerivedPath::Opaque & bo) -> SingleBuiltPath { return SingleBuiltPath::Opaque{bo.path}; },
[&](const SingleDerivedPath::Built & bfd) -> SingleBuiltPath {
auto drvPath = getBuiltPath(evalStore, store, *bfd.drvPath);
// Resolving this instead of `bfd` will yield the same result, but avoid duplicative work.
- SingleDerivedPath::Built truncatedBfd {
+ SingleDerivedPath::Built truncatedBfd{
.drvPath = makeConstantStorePathRef(drvPath.outPath()),
.output = bfd.output,
};
auto outputPath = resolveDerivedPath(*store, truncatedBfd, &*evalStore);
- return SingleBuiltPath::Built {
+ return SingleBuiltPath::Built{
.drvPath = make_ref(std::move(drvPath)),
- .output = { bfd.output, outputPath },
+ .output = {bfd.output, outputPath},
};
},
},
@@ -599,11 +594,7 @@ static SingleBuiltPath getBuiltPath(ref evalStore, ref store, cons
}
std::vector Installable::build(
- ref evalStore,
- ref store,
- Realise mode,
- const Installables & installables,
- BuildMode bMode)
+ ref evalStore, ref store, Realise mode, const Installables & installables, BuildMode bMode)
{
std::vector res;
for (auto & [_, builtPathWithResult] : build2(evalStore, store, mode, installables, bMode))
@@ -611,9 +602,7 @@ std::vector Installable::build(
return res;
}
-static void throwBuildErrors(
- std::vector & buildResults,
- const Store & store)
+static void throwBuildErrors(std::vector & buildResults, const Store & store)
{
std::vector failed;
for (auto & buildResult : buildResults) {
@@ -630,10 +619,11 @@ static void throwBuildErrors(
StringSet failedPaths;
for (; failedResult != failed.end(); failedResult++) {
if (!failedResult->errorMsg.empty()) {
- logError(ErrorInfo{
- .level = lvlError,
- .msg = failedResult->errorMsg,
- });
+ logError(
+ ErrorInfo{
+ .level = lvlError,
+ .msg = failedResult->errorMsg,
+ });
}
failedPaths.insert(failedResult->path.to_string(store));
}
@@ -643,11 +633,7 @@ static void throwBuildErrors(
}
std::vector, BuiltPathWithResult>> Installable::build2(
- ref evalStore,
- ref store,
- Realise mode,
- const Installables & installables,
- BuildMode bMode)
+ ref evalStore, ref store, Realise mode, const Installables & installables, BuildMode bMode)
{
if (mode == Realise::Nothing)
settings.readOnlyMode = true;
@@ -678,22 +664,25 @@ std::vector, BuiltPathWithResult>> Installable::build
for (auto & path : pathsToBuild) {
for (auto & aux : backmap[path]) {
- std::visit(overloaded {
- [&](const DerivedPath::Built & bfd) {
- auto outputs = resolveDerivedPath(*store, bfd, &*evalStore);
- res.push_back({aux.installable, {
- .path = BuiltPath::Built {
- .drvPath = make_ref(getBuiltPath(evalStore, store, *bfd.drvPath)),
- .outputs = outputs,
- },
- .info = aux.info}});
+ std::visit(
+ overloaded{
+ [&](const DerivedPath::Built & bfd) {
+ auto outputs = resolveDerivedPath(*store, bfd, &*evalStore);
+ res.push_back(
+ {aux.installable,
+ {.path =
+ BuiltPath::Built{
+ .drvPath =
+ make_ref(getBuiltPath(evalStore, store, *bfd.drvPath)),
+ .outputs = outputs,
+ },
+ .info = aux.info}});
+ },
+ [&](const DerivedPath::Opaque & bo) {
+ res.push_back({aux.installable, {.path = BuiltPath::Opaque{bo.path}, .info = aux.info}});
+ },
},
- [&](const DerivedPath::Opaque & bo) {
- res.push_back({aux.installable, {
- .path = BuiltPath::Opaque { bo.path },
- .info = aux.info}});
- },
- }, path.raw());
+ path.raw());
}
}
@@ -707,26 +696,30 @@ std::vector, BuiltPathWithResult>> Installable::build
throwBuildErrors(buildResults, *store);
for (auto & buildResult : buildResults) {
for (auto & aux : backmap[buildResult.path]) {
- std::visit(overloaded {
- [&](const DerivedPath::Built & bfd) {
- std::map outputs;
- for (auto & [outputName, realisation] : buildResult.builtOutputs)
- outputs.emplace(outputName, realisation.outPath);
- res.push_back({aux.installable, {
- .path = BuiltPath::Built {
- .drvPath = make_ref(getBuiltPath(evalStore, store, *bfd.drvPath)),
- .outputs = outputs,
- },
- .info = aux.info,
- .result = buildResult}});
+ std::visit(
+ overloaded{
+ [&](const DerivedPath::Built & bfd) {
+ std::map outputs;
+ for (auto & [outputName, realisation] : buildResult.builtOutputs)
+ outputs.emplace(outputName, realisation.outPath);
+ res.push_back(
+ {aux.installable,
+ {.path =
+ BuiltPath::Built{
+ .drvPath =
+ make_ref(getBuiltPath(evalStore, store, *bfd.drvPath)),
+ .outputs = outputs,
+ },
+ .info = aux.info,
+ .result = buildResult}});
+ },
+ [&](const DerivedPath::Opaque & bo) {
+ res.push_back(
+ {aux.installable,
+ {.path = BuiltPath::Opaque{bo.path}, .info = aux.info, .result = buildResult}});
+ },
},
- [&](const DerivedPath::Opaque & bo) {
- res.push_back({aux.installable, {
- .path = BuiltPath::Opaque { bo.path },
- .info = aux.info,
- .result = buildResult}});
- },
- }, buildResult.path.raw());
+ buildResult.path.raw());
}
}
@@ -741,11 +734,7 @@ std::vector, BuiltPathWithResult>> Installable::build
}
BuiltPaths Installable::toBuiltPaths(
- ref evalStore,
- ref store,
- Realise mode,
- OperateOn operateOn,
- const Installables & installables)
+ ref evalStore, ref store, Realise mode, OperateOn operateOn, const Installables & installables)
{
if (operateOn == OperateOn::Output) {
BuiltPaths res;
@@ -764,10 +753,7 @@ BuiltPaths Installable::toBuiltPaths(
}
StorePathSet Installable::toStorePathSet(
- ref evalStore,
- ref store,
- Realise mode, OperateOn operateOn,
- const Installables & installables)
+ ref evalStore, ref store, Realise mode, OperateOn operateOn, const Installables & installables)
{
StorePathSet outPaths;
for (auto & path : toBuiltPaths(evalStore, store, mode, operateOn, installables)) {
@@ -778,10 +764,7 @@ StorePathSet Installable::toStorePathSet(
}
StorePaths Installable::toStorePaths(
- ref evalStore,
- ref store,
- Realise mode, OperateOn operateOn,
- const Installables & installables)
+ ref evalStore, ref store, Realise mode, OperateOn operateOn, const Installables & installables)
{
StorePaths outPaths;
for (auto & path : toBuiltPaths(evalStore, store, mode, operateOn, installables)) {
@@ -792,10 +775,7 @@ StorePaths Installable::toStorePaths(
}
StorePath Installable::toStorePath(
- ref evalStore,
- ref store,
- Realise mode, OperateOn operateOn,
- ref installable)
+ ref evalStore, ref store, Realise mode, OperateOn operateOn, ref installable)
{
auto paths = toStorePathSet(evalStore, store, mode, operateOn, {installable});
@@ -805,28 +785,23 @@ StorePath Installable::toStorePath(
return *paths.begin();
}
-StorePathSet Installable::toDerivations(
- ref store,
- const Installables & installables,
- bool useDeriver)
+StorePathSet Installable::toDerivations(ref store, const Installables & installables, bool useDeriver)
{
StorePathSet drvPaths;
for (const auto & i : installables)
for (const auto & b : i->toDerivedPaths())
- std::visit(overloaded {
- [&](const DerivedPath::Opaque & bo) {
- drvPaths.insert(
- bo.path.isDerivation()
- ? bo.path
- : useDeriver
- ? getDeriver(store, *i, bo.path)
- : throw Error("argument '%s' did not evaluate to a derivation", i->what()));
+ std::visit(
+ overloaded{
+ [&](const DerivedPath::Opaque & bo) {
+ drvPaths.insert(
+ bo.path.isDerivation() ? bo.path
+ : useDeriver ? getDeriver(store, *i, bo.path)
+ : throw Error("argument '%s' did not evaluate to a derivation", i->what()));
+ },
+ [&](const DerivedPath::Built & bfd) { drvPaths.insert(resolveDerivedPath(*store, *bfd.drvPath)); },
},
- [&](const DerivedPath::Built & bfd) {
- drvPaths.insert(resolveDerivedPath(*store, *bfd.drvPath));
- },
- }, b.path.raw());
+ b.path.raw());
return drvPaths;
}
@@ -861,10 +836,7 @@ std::vector RawInstallablesCommand::getFlakeRefsForCompletion()
std::vector res;
res.reserve(rawInstallables.size());
for (const auto & i : rawInstallables)
- res.push_back(parseFlakeRefWithFragment(
- fetchSettings,
- expandTilde(i),
- absPath(getCommandBaseDir())).first);
+ res.push_back(parseFlakeRefWithFragment(fetchSettings, expandTilde(i), absPath(getCommandBaseDir())).first);
return res;
}
@@ -883,12 +855,7 @@ void RawInstallablesCommand::run(ref store)
std::vector InstallableCommand::getFlakeRefsForCompletion()
{
- return {
- parseFlakeRefWithFragment(
- fetchSettings,
- expandTilde(_installable),
- absPath(getCommandBaseDir())).first
- };
+ return {parseFlakeRefWithFragment(fetchSettings, expandTilde(_installable), absPath(getCommandBaseDir())).first};
}
void InstallablesCommand::run(ref store, std::vector && rawInstallables)
@@ -928,4 +895,4 @@ BuiltPaths toBuiltPaths(const std::vector & builtPathsWithR
return res;
}
-}
+} // namespace nix
diff --git a/src/libcmd/markdown.cc b/src/libcmd/markdown.cc
index 41da73c7a..c3341da73 100644
--- a/src/libcmd/markdown.cc
+++ b/src/libcmd/markdown.cc
@@ -18,29 +18,36 @@ static std::string doRenderMarkdownToTerminal(std::string_view markdown)
{
int windowWidth = getWindowSize().second;
-#if HAVE_LOWDOWN_1_4
- struct lowdown_opts_term opts_term {
+# if HAVE_LOWDOWN_1_4
+ struct lowdown_opts_term opts_term{
.cols = (size_t) std::max(windowWidth - 5, 60),
.hmargin = 0,
.vmargin = 0,
};
-#endif
- struct lowdown_opts opts
- {
+# endif
+ struct lowdown_opts opts{
.type = LOWDOWN_TERM,
-#if HAVE_LOWDOWN_1_4
+# if HAVE_LOWDOWN_1_4
.term = opts_term,
-#endif
+# endif
.maxdepth = 20,
-#if !HAVE_LOWDOWN_1_4
+# if !HAVE_LOWDOWN_1_4
.cols = (size_t) std::max(windowWidth - 5, 60),
.hmargin = 0,
.vmargin = 0,
-#endif
+# endif
.feat = LOWDOWN_COMMONMARK | LOWDOWN_FENCED | LOWDOWN_DEFLIST | LOWDOWN_TABLES,
- .oflags = LOWDOWN_TERM_NOLINK,
+ .oflags =
+# if HAVE_LOWDOWN_1_4
+ LOWDOWN_TERM_NORELLINK // To render full links while skipping relative ones
+# else
+ LOWDOWN_TERM_NOLINK
+# endif
};
+ if (!isTTY())
+ opts.oflags |= LOWDOWN_TERM_NOANSI;
+
auto doc = lowdown_doc_new(&opts);
if (!doc)
throw Error("cannot allocate Markdown document");
@@ -66,7 +73,7 @@ static std::string doRenderMarkdownToTerminal(std::string_view markdown)
if (!rndr_res)
throw Error("allocation error while rendering Markdown");
- return filterANSIEscapes(std::string(buf->data, buf->size), !isTTY());
+ return std::string(buf->data, buf->size);
}
std::string renderMarkdownToTerminal(std::string_view markdown)
diff --git a/src/libcmd/meson.build b/src/libcmd/meson.build
index 216d4df9c..24e075246 100644
--- a/src/libcmd/meson.build
+++ b/src/libcmd/meson.build
@@ -1,7 +1,9 @@
-project('nix-cmd', 'cpp',
+project(
+ 'nix-cmd',
+ 'cpp',
version : files('.version'),
default_options : [
- 'cpp_std=c++2a',
+ 'cpp_std=c++23',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'errorlogs=true', # Please print logs for tests that fail
@@ -16,8 +18,7 @@ subdir('nix-meson-build-support/deps-lists')
configdata = configuration_data()
-deps_private_maybe_subproject = [
-]
+deps_private_maybe_subproject = []
deps_public_maybe_subproject = [
dependency('nix-util'),
dependency('nix-store'),
@@ -31,11 +32,18 @@ subdir('nix-meson-build-support/subprojects')
nlohmann_json = dependency('nlohmann_json', version : '>= 3.9')
deps_public += nlohmann_json
-lowdown = dependency('lowdown', version : '>= 0.9.0', required : get_option('markdown'))
+lowdown = dependency(
+ 'lowdown',
+ version : '>= 0.9.0',
+ required : get_option('markdown'),
+)
deps_private += lowdown
configdata.set('HAVE_LOWDOWN', lowdown.found().to_int())
# The API changed slightly around terminal initialization.
-configdata.set('HAVE_LOWDOWN_1_4', lowdown.version().version_compare('>= 1.4.0').to_int())
+configdata.set(
+ 'HAVE_LOWDOWN_1_4',
+ lowdown.version().version_compare('>= 1.4.0').to_int(),
+)
readline_flavor = get_option('readline-flavor')
if readline_flavor == 'editline'
@@ -50,7 +58,7 @@ endif
configdata.set(
'USE_READLINE',
(readline_flavor == 'readline').to_int(),
- description: 'Use readline instead of editline',
+ description : 'Use readline instead of editline',
)
config_priv_h = configure_file(
@@ -89,9 +97,10 @@ this_library = library(
config_priv_h,
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
- link_args: linker_export_flags,
+ link_args : linker_export_flags,
prelink : true, # For C++ static initializers
install : true,
+ cpp_pch : do_pch ? [ 'pch/precompiled-headers.hh' ] : [],
)
install_headers(headers, subdir : 'nix/cmd', preserve_path : true)
diff --git a/src/libcmd/meson.options b/src/libcmd/meson.options
index 79ae4fa55..31178d82f 100644
--- a/src/libcmd/meson.options
+++ b/src/libcmd/meson.options
@@ -2,14 +2,14 @@
option(
'markdown',
- type: 'feature',
- description: 'Enable Markdown rendering in the Nix binary (requires lowdown)',
+ type : 'feature',
+ description : 'Enable Markdown rendering in the Nix binary (requires lowdown)',
)
option(
'readline-flavor',
type : 'combo',
- choices : ['editline', 'readline'],
+ choices : [ 'editline', 'readline' ],
value : 'editline',
description : 'Which library to use for nice line editing with the Nix language REPL',
)
diff --git a/src/libcmd/misc-store-flags.cc b/src/libcmd/misc-store-flags.cc
index a57ad35ff..fd2211813 100644
--- a/src/libcmd/misc-store-flags.cc
+++ b/src/libcmd/misc-store-flags.cc
@@ -1,7 +1,6 @@
#include "nix/cmd/misc-store-flags.hh"
-namespace nix::flag
-{
+namespace nix::flag {
static void hashFormatCompleter(AddCompletions & completions, size_t index, std::string_view prefix)
{
@@ -15,27 +14,23 @@ static void hashFormatCompleter(AddCompletions & completions, size_t index, std:
Args::Flag hashFormatWithDefault(std::string && longName, HashFormat * hf)
{
assert(*hf == nix::HashFormat::SRI);
- return Args::Flag {
- .longName = std::move(longName),
- .description = "Hash format (`base16`, `nix32`, `base64`, `sri`). Default: `sri`.",
- .labels = {"hash-format"},
- .handler = {[hf](std::string s) {
- *hf = parseHashFormat(s);
- }},
- .completer = hashFormatCompleter,
+ return Args::Flag{
+ .longName = std::move(longName),
+ .description = "Hash format (`base16`, `nix32`, `base64`, `sri`). Default: `sri`.",
+ .labels = {"hash-format"},
+ .handler = {[hf](std::string s) { *hf = parseHashFormat(s); }},
+ .completer = hashFormatCompleter,
};
}
Args::Flag hashFormatOpt(std::string && longName, std::optional * ohf)
{
- return Args::Flag {
- .longName = std::move(longName),
- .description = "Hash format (`base16`, `nix32`, `base64`, `sri`).",
- .labels = {"hash-format"},
- .handler = {[ohf](std::string s) {
- *ohf = std::optional{parseHashFormat(s)};
- }},
- .completer = hashFormatCompleter,
+ return Args::Flag{
+ .longName = std::move(longName),
+ .description = "Hash format (`base16`, `nix32`, `base64`, `sri`).",
+ .labels = {"hash-format"},
+ .handler = {[ohf](std::string s) { *ohf = std::optional{parseHashFormat(s)}; }},
+ .completer = hashFormatCompleter,
};
}
@@ -48,34 +43,31 @@ static void hashAlgoCompleter(AddCompletions & completions, size_t index, std::s
Args::Flag hashAlgo(std::string && longName, HashAlgorithm * ha)
{
- return Args::Flag {
- .longName = std::move(longName),
- .description = "Hash algorithm (`blake3`, `md5`, `sha1`, `sha256`, or `sha512`).",
- .labels = {"hash-algo"},
- .handler = {[ha](std::string s) {
- *ha = parseHashAlgo(s);
- }},
- .completer = hashAlgoCompleter,
+ return Args::Flag{
+ .longName = std::move(longName),
+ .description = "Hash algorithm (`blake3`, `md5`, `sha1`, `sha256`, or `sha512`).",
+ .labels = {"hash-algo"},
+ .handler = {[ha](std::string s) { *ha = parseHashAlgo(s); }},
+ .completer = hashAlgoCompleter,
};
}
Args::Flag hashAlgoOpt(std::string && longName, std::optional * oha)
{
- return Args::Flag {
- .longName = std::move(longName),
- .description = "Hash algorithm (`blake3`, `md5`, `sha1`, `sha256`, or `sha512`). Can be omitted for SRI hashes.",
- .labels = {"hash-algo"},
- .handler = {[oha](std::string s) {
- *oha = std::optional{parseHashAlgo(s)};
- }},
- .completer = hashAlgoCompleter,
+ return Args::Flag{
+ .longName = std::move(longName),
+ .description =
+ "Hash algorithm (`blake3`, `md5`, `sha1`, `sha256`, or `sha512`). Can be omitted for SRI hashes.",
+ .labels = {"hash-algo"},
+ .handler = {[oha](std::string s) { *oha = std::optional{parseHashAlgo(s)}; }},
+ .completer = hashAlgoCompleter,
};
}
Args::Flag fileIngestionMethod(FileIngestionMethod * method)
{
- return Args::Flag {
- .longName = "mode",
+ return Args::Flag{
+ .longName = "mode",
// FIXME indentation carefully made for context, this is messed up.
.description = R"(
How to compute the hash of the input.
@@ -92,16 +84,14 @@ Args::Flag fileIngestionMethod(FileIngestionMethod * method)
it to the hash function.
)",
.labels = {"file-ingestion-method"},
- .handler = {[method](std::string s) {
- *method = parseFileIngestionMethod(s);
- }},
+ .handler = {[method](std::string s) { *method = parseFileIngestionMethod(s); }},
};
}
Args::Flag contentAddressMethod(ContentAddressMethod * method)
{
- return Args::Flag {
- .longName = "mode",
+ return Args::Flag{
+ .longName = "mode",
// FIXME indentation carefully made for context, this is messed up.
.description = R"(
How to compute the content-address of the store object.
@@ -126,10 +116,8 @@ Args::Flag contentAddressMethod(ContentAddressMethod * method)
for regular usage prefer `nar` and `flat`.
)",
.labels = {"content-address-method"},
- .handler = {[method](std::string s) {
- *method = ContentAddressMethod::parse(s);
- }},
+ .handler = {[method](std::string s) { *method = ContentAddressMethod::parse(s); }},
};
}
-}
+} // namespace nix::flag
diff --git a/src/libcmd/network-proxy.cc b/src/libcmd/network-proxy.cc
index a4a89685c..6c9f2b073 100644
--- a/src/libcmd/network-proxy.cc
+++ b/src/libcmd/network-proxy.cc
@@ -47,4 +47,4 @@ bool haveNetworkProxyConnection()
return false;
}
-}
+} // namespace nix
diff --git a/src/libcmd/package.nix b/src/libcmd/package.nix
index be5054f64..c382f0e57 100644
--- a/src/libcmd/package.nix
+++ b/src/libcmd/package.nix
@@ -53,7 +53,8 @@ mkMesonLibrary (finalAttrs: {
buildInputs = [
({ inherit editline readline; }.${readlineFlavor})
- ] ++ lib.optional enableMarkdown lowdown;
+ ]
+ ++ lib.optional enableMarkdown lowdown;
propagatedBuildInputs = [
nix-util
diff --git a/src/libcmd/pch/precompiled-headers.hh b/src/libcmd/pch/precompiled-headers.hh
new file mode 100644
index 000000000..6f9947e9b
--- /dev/null
+++ b/src/libcmd/pch/precompiled-headers.hh
@@ -0,0 +1,4 @@
+#include "nix/cmd/installables.hh"
+#include "nix/expr/eval.hh"
+#include "nix/util/util.hh"
+#include "nix/flake/flake.hh"
diff --git a/src/libcmd/repl-interacter.cc b/src/libcmd/repl-interacter.cc
index 4de335dd5..c9b435675 100644
--- a/src/libcmd/repl-interacter.cc
+++ b/src/libcmd/repl-interacter.cc
@@ -5,8 +5,8 @@
#include
#if USE_READLINE
-#include
-#include
+# include
+# include
#else
// editline < 1.15.2 don't wrap their API for C++ usage
// (added in https://github.com/troglobit/editline/commit/91398ceb3427b730995357e9d120539fb9bb7461).
@@ -14,7 +14,7 @@
// For compatibility with these versions, we wrap the API here
// (wrapping multiple times on newer versions is no problem).
extern "C" {
-#include
+# include
}
#endif
@@ -35,7 +35,7 @@ void sigintHandler(int signo)
{
g_signal_received = signo;
}
-};
+}; // namespace
static detail::ReplCompleterMixin * curRepl; // ugly
@@ -185,8 +185,7 @@ bool ReadlineLikeInteracter::getLine(std::string & input, ReplPromptType promptT
// editline doesn't echo the input to the output when non-interactive, unlike readline
// this results in a different behavior when running tests. The echoing is
// quite useful for reading the test output, so we add it here.
- if (auto e = getEnv("_NIX_TEST_REPL_ECHO"); s && e && *e == "1")
- {
+ if (auto e = getEnv("_NIX_TEST_REPL_ECHO"); s && e && *e == "1") {
#if !USE_READLINE
// This is probably not right for multi-line input, but we don't use that
// in the characterisation tests, so it's fine.
@@ -207,4 +206,4 @@ ReadlineLikeInteracter::~ReadlineLikeInteracter()
write_history(historyFile.c_str());
}
-};
+}; // namespace nix
diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc
index 8170bd579..01d786deb 100644
--- a/src/libcmd/repl.cc
+++ b/src/libcmd/repl.cc
@@ -54,10 +54,7 @@ enum class ProcessLineResult {
PromptAgain,
};
-struct NixRepl
- : AbstractNixRepl
- , detail::ReplCompleterMixin
- , gc
+struct NixRepl : AbstractNixRepl, detail::ReplCompleterMixin, gc
{
size_t debugTraceIndex;
@@ -80,8 +77,12 @@ struct NixRepl
std::unique_ptr interacter;
- NixRepl(const LookupPath & lookupPath, nix::ref store,ref state,
- std::function getValues, RunNix * runNix);
+ NixRepl(
+ const LookupPath & lookupPath,
+ nix::ref store,
+ ref state,
+ std::function getValues,
+ RunNix * runNix);
virtual ~NixRepl() = default;
ReplExitStatus mainLoop() override;
@@ -103,20 +104,22 @@ struct NixRepl
void evalString(std::string s, Value & v);
void loadDebugTraceEnv(DebugTrace & dt);
- void printValue(std::ostream & str,
- Value & v,
- unsigned int maxDepth = std::numeric_limits::max())
+ void printValue(std::ostream & str, Value & v, unsigned int maxDepth = std::numeric_limits::max())
{
// Hide the progress bar during printing because it might interfere
auto suspension = logger->suspend();
- ::nix::printValue(*state, str, v, PrintOptions {
- .ansiColors = true,
- .force = true,
- .derivationPaths = true,
- .maxDepth = maxDepth,
- .prettyIndent = 2,
- .errors = ErrorPrintBehavior::ThrowTopLevel,
- });
+ ::nix::printValue(
+ *state,
+ str,
+ v,
+ PrintOptions{
+ .ansiColors = true,
+ .force = true,
+ .derivationPaths = true,
+ .maxDepth = maxDepth,
+ .prettyIndent = 2,
+ .errors = ErrorPrintBehavior::ThrowTopLevel,
+ });
}
};
@@ -124,13 +127,17 @@ std::string removeWhitespace(std::string s)
{
s = chomp(s);
size_t n = s.find_first_not_of(" \n\r\t");
- if (n != std::string::npos) s = std::string(s, n);
+ if (n != std::string::npos)
+ s = std::string(s, n);
return s;
}
-
-NixRepl::NixRepl(const LookupPath & lookupPath, nix::ref store, ref state,
- std::function getValues, RunNix * runNix)
+NixRepl::NixRepl(
+ const LookupPath & lookupPath,
+ nix::ref store,
+ ref state,
+ std::function getValues,
+ RunNix * runNix)
: AbstractNixRepl(state)
, debugTraceIndex(0)
, getValues(getValues)
@@ -188,7 +195,8 @@ ReplExitStatus NixRepl::mainLoop()
auto suspension = logger->suspend();
// When continuing input from previous lines, don't print a prompt, just align to the same
// number of chars as the prompt.
- if (!interacter->getLine(input, input.empty() ? ReplPromptType::ReplPrompt : ReplPromptType::ContinuationPrompt)) {
+ if (!interacter->getLine(
+ input, input.empty() ? ReplPromptType::ReplPrompt : ReplPromptType::ContinuationPrompt)) {
// Ctrl-D should exit the debugger.
state->debugStop = false;
logger->cout("");
@@ -200,14 +208,14 @@ ReplExitStatus NixRepl::mainLoop()
}
try {
switch (processLine(input)) {
- case ProcessLineResult::Quit:
- return ReplExitStatus::QuitAll;
- case ProcessLineResult::Continue:
- return ReplExitStatus::Continue;
- case ProcessLineResult::PromptAgain:
- break;
- default:
- unreachable();
+ case ProcessLineResult::Quit:
+ return ReplExitStatus::QuitAll;
+ case ProcessLineResult::Continue:
+ return ReplExitStatus::Continue;
+ case ProcessLineResult::PromptAgain:
+ break;
+ default:
+ unreachable();
}
} catch (IncompleteReplExpr &) {
continue;
@@ -256,7 +264,8 @@ StringSet NixRepl::completePrefix(const std::string & prefix)
/* This is a variable name; look it up in the current scope. */
StringSet::iterator i = varNames.lower_bound(cur);
while (i != varNames.end()) {
- if (i->substr(0, cur.size()) != cur) break;
+ if (i->substr(0, cur.size()) != cur)
+ break;
completions.insert(prev + *i);
i++;
}
@@ -275,11 +284,15 @@ StringSet NixRepl::completePrefix(const std::string & prefix)
Expr * e = parseString(expr);
Value v;
e->eval(*state, *env, v);
- state->forceAttrs(v, noPos, "while evaluating an attrset for the purpose of completion (this error should not be displayed; file an issue?)");
+ state->forceAttrs(
+ v,
+ noPos,
+ "while evaluating an attrset for the purpose of completion (this error should not be displayed; file an issue?)");
for (auto & i : *v.attrs()) {
std::string_view name = state->symbols[i.name];
- if (name.substr(0, cur2.size()) != cur2) continue;
+ if (name.substr(0, cur2.size()) != cur2)
+ continue;
completions.insert(concatStrings(prev, expr, ".", name));
}
@@ -297,24 +310,23 @@ StringSet NixRepl::completePrefix(const std::string & prefix)
return completions;
}
-
// FIXME: DRY and match or use the parser
static bool isVarName(std::string_view s)
{
- if (s.size() == 0) return false;
+ if (s.size() == 0)
+ return false;
char c = s[0];
- if ((c >= '0' && c <= '9') || c == '-' || c == '\'') return false;
+ if ((c >= '0' && c <= '9') || c == '-' || c == '\'')
+ return false;
for (auto & i : s)
- if (!((i >= 'a' && i <= 'z') ||
- (i >= 'A' && i <= 'Z') ||
- (i >= '0' && i <= '9') ||
- i == '_' || i == '-' || i == '\''))
+ if (!((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z') || (i >= '0' && i <= '9') || i == '_' || i == '-'
+ || i == '\''))
return false;
return true;
}
-
-StorePath NixRepl::getDerivationPath(Value & v) {
+StorePath NixRepl::getDerivationPath(Value & v)
+{
auto packageInfo = getDerivation(*state, v, false);
if (!packageInfo)
throw Error("expression does not evaluate to a derivation, so I can't build it");
@@ -353,53 +365,50 @@ ProcessLineResult NixRepl::processLine(std::string line)
if (line[0] == ':') {
size_t p = line.find_first_of(" \n\r\t");
command = line.substr(0, p);
- if (p != std::string::npos) arg = removeWhitespace(line.substr(p));
+ if (p != std::string::npos)
+ arg = removeWhitespace(line.substr(p));
} else {
arg = line;
}
if (command == ":?" || command == ":help") {
// FIXME: convert to Markdown, include in the 'nix repl' manpage.
- std::cout
- << "The following commands are available:\n"
- << "\n"
- << " Evaluate and print expression\n"
- << " = Bind expression to variable\n"
- << " :a, :add Add attributes from resulting set to scope\n"
- << " :b Build a derivation\n"
- << " :bl Build a derivation, creating GC roots in the\n"
- << " working directory\n"
- << " :e, :edit Open package or function in $EDITOR\n"
- << " :i Build derivation, then install result into\n"
- << " current profile\n"
- << " :l, :load Load Nix expression and add it to scope\n"
- << " :lf, :load-flake ][ Load Nix flake and add it to scope\n"
- << " :ll, :last-loaded Show most recently loaded variables added to scope\n"
- << " :p, :print Evaluate and print expression recursively\n"
- << " Strings are printed directly, without escaping.\n"
- << " :q, :quit Exit nix-repl\n"
- << " :r, :reload Reload all files\n"
- << " :sh Build dependencies of derivation, then start\n"
- << " nix-shell\n"
- << " :t Describe result of evaluation\n"
- << " :u Build derivation, then start nix-shell\n"
- << " :doc Show documentation of a builtin function\n"
- << " :log Show logs for a derivation\n"
- << " :te, :trace-enable [bool] Enable, disable or toggle showing traces for\n"
- << " errors\n"
- << " :?, :help Brings up this help menu\n"
- ;
+ std::cout << "The following commands are available:\n"
+ << "\n"
+ << " Evaluate and print expression\n"
+ << " = Bind expression to variable\n"
+ << " :a, :add Add attributes from resulting set to scope\n"
+ << " :b Build a derivation\n"
+ << " :bl Build a derivation, creating GC roots in the\n"
+ << " working directory\n"
+ << " :e, :edit Open package or function in $EDITOR\n"
+ << " :i Build derivation, then install result into\n"
+ << " current profile\n"
+ << " :l, :load Load Nix expression and add it to scope\n"
+ << " :lf, :load-flake ]