diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index b7da3c84fc17..219efb6e2a54 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -102,3 +102,6 @@ fb0e5be84331188a69b3edd31679ca6576edb75a # systemd: break too long lines of Nix code 67643f8ec84bef1482204709073e417c9f07eb87 + +# {pkgs/development/cuda-modules,pkgs/test/cuda,pkgs/top-level/cuda-packages.nix}: reformat all CUDA files with nixfmt-rfc-style 2023-03-01 +802a1b4d3338f24cbc4efd704616654456d75a94 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 15e253be5b80..109b64d7392a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -13,7 +13,6 @@ # GitHub actions /.github/workflows @NixOS/Security @Mic92 @zowoq -/.github/workflows/merge-staging @FRidh # EditorConfig /.editorconfig @Mic92 @zowoq @@ -55,7 +54,7 @@ /pkgs/pkgs-lib/formats/hocon @h7x4 # pkgs/by-name -/pkgs/test/nixpkgs-check-by-name @infinisil +/pkgs/test/check-by-name @infinisil /pkgs/by-name/README.md @infinisil /pkgs/top-level/by-name-overlay.nix @infinisil /.github/workflows/check-by-name.yml @infinisil @@ -125,10 +124,8 @@ nixos/modules/installer/tools/nix-fallback-paths.nix @raitobezarius @ma27 /pkgs/common-updater/scripts/update-source-version @jtojnar # Python-related code and docs -/maintainers/scripts/update-python-libraries @FRidh -/pkgs/development/interpreters/python @FRidh -/doc/languages-frameworks/python.section.md @FRidh @mweinelt -/pkgs/development/interpreters/python/hooks @FRidh @jonringer +/doc/languages-frameworks/python.section.md @mweinelt +/pkgs/development/interpreters/python/hooks @jonringer # Haskell /doc/languages-frameworks/haskell.section.md @sternenseemann @maralorn @ncfavier @@ -148,10 +145,6 @@ nixos/modules/installer/tools/nix-fallback-paths.nix @raitobezarius @ma27 /pkgs/applications/science/math/R @jbedo /pkgs/development/r-modules @jbedo -# Ruby -/pkgs/development/interpreters/ruby @marsam -/pkgs/development/ruby-modules @marsam - # Rust /pkgs/development/compilers/rust @Mic92 @zowoq @winterqt @figsoda /pkgs/build-support/rust @zowoq @winterqt @figsoda @@ -159,7 +152,6 @@ nixos/modules/installer/tools/nix-fallback-paths.nix @raitobezarius @ma27 # C compilers /pkgs/development/compilers/gcc -/pkgs/development/compilers/llvm @RaitoBezarius /pkgs/development/compilers/emscripten @raitobezarius /doc/languages-frameworks/emscripten.section.md @raitobezarius @@ -186,28 +178,24 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt /lib/licenses.nix @alyssais # Qt -/pkgs/development/libraries/qt-5 @NixOS/qt-kde -/pkgs/development/libraries/qt-6 @NixOS/qt-kde +/pkgs/development/libraries/qt-5 @K900 @NickCao @SuperSandro2000 @ttuegel +/pkgs/development/libraries/qt-6 @K900 @NickCao @SuperSandro2000 @ttuegel # KDE / Plasma 5 -/pkgs/applications/kde @NixOS/qt-kde -/pkgs/desktops/plasma-5 @NixOS/qt-kde -/pkgs/development/libraries/kde-frameworks @NixOS/qt-kde +/pkgs/applications/kde @K900 @NickCao @SuperSandro2000 @ttuegel +/pkgs/desktops/plasma-5 @K900 @NickCao @SuperSandro2000 @ttuegel +/pkgs/development/libraries/kde-frameworks @K900 @NickCao @SuperSandro2000 @ttuegel # KDE / Plasma 6 -/pkgs/kde @NixOS/qt-kde -/maintainers/scripts/kde @NixOS/qt-kde +/pkgs/kde @K900 @NickCao @SuperSandro2000 @ttuegel +/maintainers/scripts/kde @K900 @NickCao @SuperSandro2000 @ttuegel # PostgreSQL and related stuff -/pkgs/servers/sql/postgresql @thoughtpolice @marsam +/pkgs/servers/sql/postgresql @thoughtpolice /nixos/modules/services/databases/postgresql.xml @thoughtpolice /nixos/modules/services/databases/postgresql.nix @thoughtpolice /nixos/tests/postgresql.nix @thoughtpolice -# Linux kernel -/pkgs/os-specific/linux/kernel @raitobezarius -/pkgs/top-level/linux-kernels.nix @raitobezarius - # Hardened profile & related modules /nixos/modules/profiles/hardened.nix @joachifm /nixos/modules/security/hidepid.nix @joachifm @@ -237,10 +225,12 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt /nixos/modules/services/networking/babeld.nix @mweinelt /nixos/modules/services/networking/kea.nix @mweinelt /nixos/modules/services/networking/knot.nix @mweinelt +nixos/modules/services/networking/networkmanager.nix @Janik-Haag /nixos/modules/services/monitoring/prometheus/exporters/kea.nix @mweinelt /nixos/tests/babeld.nix @mweinelt /nixos/tests/kea.nix @mweinelt /nixos/tests/knot.nix @mweinelt +/nixos/tests/networking/* @Janik-Haag # Web servers /doc/packages/nginx.section.md @raitobezarius @@ -301,7 +291,7 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt # GNOME /pkgs/desktops/gnome @jtojnar -/pkgs/desktops/gnome/extensions @piegamesde @jtojnar +/pkgs/desktops/gnome/extensions @jtojnar /pkgs/build-support/make-hardcode-gsettings-patch @jtojnar # Cinnamon @@ -364,3 +354,16 @@ pkgs/development/tools/continuous-integration/buildbot @Mic92 @zowoq pkgs/by-name/pr/pretix/ @mweinelt nixos/modules/services/web-apps/pretix.nix @mweinelt nixos/tests/web-apps/pretix.nix @mweinelt + +# incus/lxc/lxd +nixos/maintainers/scripts/lxd/ @adamcstephens +nixos/modules/virtualisation/incus.nix @adamcstephens +nixos/modules/virtualisation/lxc* @adamcstephens +nixos/modules/virtualisation/lxd* @adamcstephens +nixos/tests/incus/ @adamcstephens +nixos/tests/lxd/ @adamcstephens +pkgs/by-name/in/incus/ @adamcstephens +pkgs/by-name/lx/lxc* @adamcstephens +pkgs/by-name/lx/lxd* @adamcstephens +pkgs/os-specific/linux/lxc/ @adamcstephens + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 40ea13f131e8..7b68fbd77b74 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -19,7 +19,7 @@ For new packages please briefly describe the package or provide a link to its ho - [ ] `sandbox = true` - [ ] Tested, as applicable: - [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests)) - - and/or [package tests](https://nixos.org/manual/nixpkgs/unstable/#sec-package-tests) + - and/or [package tests](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests) - or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test) - made sure NixOS tests are [linked](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages - [ ] Tested compilation of all packages that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"`. Note: all changes have to be committed, also see [nixpkgs-review usage](https://github.com/Mic92/nixpkgs-review#usage) @@ -38,7 +38,7 @@ Reviewing helps to reduce the average time-to-merge for everyone. Thanks a lot if you do! List of open PRs: https://github.com/NixOS/nixpkgs/pulls -Reviewing guidelines: https://nixos.org/manual/nixpkgs/unstable/#chap-reviewing-contributions +Reviewing guidelines: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#reviewing-contributions --> --- diff --git a/.github/labeler.yml b/.github/labeler.yml index a6e8d734382e..b88f7f5179ec 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -95,6 +95,14 @@ - pkgs/top-level/haskell-packages.nix - pkgs/top-level/release-haskell.nix +"6.topic: julia": + - any: + - changed-files: + - any-glob-to-any-file: + - doc/languages-frameworks/julia.section.md + - pkgs/development/compilers/julia/**/* + - pkgs/development/julia-modules/**/* + "6.topic: jupyter": - any: - changed-files: @@ -122,6 +130,7 @@ - any: - changed-files: - any-glob-to-any-file: + - pkgs/development/tools/misc/luarocks/* - pkgs/development/interpreters/lua-5/**/* - pkgs/development/interpreters/luajit/**/* - pkgs/development/lua-modules/**/* @@ -360,3 +369,8 @@ - changed-files: - any-glob-to-any-file: - nixos/modules/**/* +"8.has: maintainer-list (update)": + - any: + - changed-files: + - any-glob-to-any-file: + - maintainers/maintainer-list.nix diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 3a93eb4fd624..7a168d14a479 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -20,11 +20,11 @@ jobs: if: github.repository_owner == 'NixOS' && github.event.pull_request.merged == true && (github.event_name != 'labeled' || startsWith('backport', github.event.label.name)) runs-on: ubuntu-latest steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: ref: ${{ github.event.pull_request.head.sha }} - name: Create backport PRs - uses: korthout/backport-action@e8161d6a0dbfa2651b7daa76cbb75bc7c925bbf3 # v2.4.1 + uses: korthout/backport-action@ef20d86abccbac3ee3a73cb2efbdc06344c390e5 # v2.5.0 with: # Config README: https://github.com/korthout/backport-action#backport-action copy_labels_pattern: 'severity:\ssecurity' diff --git a/.github/workflows/basic-eval.yml b/.github/workflows/basic-eval.yml index 9008ca208e17..6059ba784959 100644 --- a/.github/workflows/basic-eval.yml +++ b/.github/workflows/basic-eval.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest # we don't limit this action to only NixOS repo since the checks are cheap and useful developer feedback steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26 - uses: cachix/cachix-action@18cf96c7c98e048e10a83abd92116114cd8504be # v14 with: @@ -26,4 +26,4 @@ jobs: name: nixpkgs-ci signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' # explicit list of supportedSystems is needed until aarch64-darwin becomes part of the trunk jobset - - run: nix-build pkgs/top-level/release.nix -A tarball.nixpkgs-basic-release-checks --arg supportedSystems '[ "aarch64-darwin" "aarch64-linux" "x86_64-linux" "x86_64-darwin" ]' + - run: nix-build pkgs/top-level/release.nix -A release-checks --arg supportedSystems '[ "aarch64-darwin" "aarch64-linux" "x86_64-linux" "x86_64-darwin" ]' diff --git a/.github/workflows/check-by-name.yml b/.github/workflows/check-by-name.yml index bf6acf3701da..8e2011cb6d52 100644 --- a/.github/workflows/check-by-name.yml +++ b/.github/workflows/check-by-name.yml @@ -1,11 +1,9 @@ # Checks pkgs/by-name (see pkgs/by-name/README.md) -# using the nixpkgs-check-by-name tool (see pkgs/test/nixpkgs-check-by-name) +# using the nixpkgs-check-by-name tool (see https://github.com/NixOS/nixpkgs-check-by-name) # -# When you make changes to this workflow, also update pkgs/test/nixpkgs-check-by-name/scripts/run-local.sh adequately +# When you make changes to this workflow, also update pkgs/test/check-by-name/run-local.sh adequately name: Check pkgs/by-name -# The tool is pinned to a pre-built version on Hydra, -# see pkgs/test/nixpkgs-check-by-name/scripts/README.md on: # Using pull_request_target instead of pull_request avoids having to approve first time contributors pull_request_target: @@ -22,10 +20,16 @@ permissions: # We need this permission to cancel the workflow run if there's a merge conflict actions: write +# Create a check-by-name concurrency group based on the pull request number. if +# an event triggers a run on the same PR while a previous run is still in +# progress, the previous run will be canceled and the new one will start. +concurrency: + group: check-by-name-${{ github.event.pull_request.number }} + cancel-in-progress: true + jobs: check: - # This is x86_64-linux, for which the tool is always prebuilt on the nixos-* channels, - # as specified in nixos/release-combined.nix + # This needs to be x86_64-linux, because we depend on the tooling being pre-built in the GitHub releases runs-on: ubuntu-latest # This should take 1 minute at most, but let's be generous. # The default of 6 hours is definitely too long @@ -42,7 +46,7 @@ jobs: # https://docs.github.com/en/rest/guides/using-the-rest-api-to-interact-with-your-git-database?apiVersion=2022-11-28#checking-mergeability-of-pull-requests # Retry the API query this many times - retryCount=3 + retryCount=5 # Start with 5 seconds, but double every retry retryInterval=5 while true; do @@ -87,7 +91,7 @@ jobs: exit 1 fi echo "mergedSha=$mergedSha" >> "$GITHUB_ENV" - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: # pull_request_target checks out the base branch by default ref: ${{ env.mergedSha }} @@ -100,13 +104,20 @@ jobs: echo "base=$base" >> "$GITHUB_ENV" - uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26 - name: Fetching the pinned tool - # Update the pinned version using pkgs/test/nixpkgs-check-by-name/scripts/update-pinned-tool.sh + # Update the pinned version using pkgs/test/check-by-name/update-pinned-tool.sh run: | - # Get the direct /nix/store path from the pin to avoid having to evaluate Nixpkgs - toolPath=$(jq -r '."ci-path"' pkgs/test/nixpkgs-check-by-name/scripts/pinned-tool.json) - # This asks the substituter for the path, which should be there because Hydra will have pre-built and pushed it + # The pinned version of the tooling to use + toolVersion=$(' -iAP nixfmt-rfc-style" + - name: Check that Nix files are formatted according to the RFC style + # Each environment variable beginning with NIX_FMT_PATHS_ is a list of + # paths to check with nixfmt. + env: + # Format paths related to the Nixpkgs CUDA ecosystem. + NIX_FMT_PATHS_CUDA: | + pkgs/development/cuda-modules + pkgs/test/cuda + pkgs/top-level/cuda-packages.nix + # Iterate over all environment variables beginning with NIX_FMT_PATHS_. + run: | + for env_var in "${!NIX_FMT_PATHS_@}"; do + readarray -t paths <<< "${!env_var}" + if [[ "${paths[*]}" == "" ]]; then + echo "Error: $env_var is empty." + exit 1 + fi + echo "Checking paths: ${paths[@]}" + if ! nixfmt --check "${paths[@]}"; then + echo "Error: nixfmt failed." + exit 1 + fi + done diff --git a/.github/workflows/editorconfig.yml b/.github/workflows/editorconfig.yml index 168e5bccaea4..bb864ace316b 100644 --- a/.github/workflows/editorconfig.yml +++ b/.github/workflows/editorconfig.yml @@ -24,7 +24,7 @@ jobs: - name: print list of changed files run: | cat "$HOME/changed_files" - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: # pull_request_target checks out the base branch by default ref: refs/pull/${{ github.event.pull_request.number }}/merge diff --git a/.github/workflows/manual-nixos.yml b/.github/workflows/manual-nixos.yml index 545f0c95c47b..ac5532a25370 100644 --- a/.github/workflows/manual-nixos.yml +++ b/.github/workflows/manual-nixos.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest if: github.repository_owner == 'NixOS' steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: # pull_request_target checks out the base branch by default ref: refs/pull/${{ github.event.pull_request.number }}/merge @@ -26,6 +26,6 @@ jobs: with: # This cache is for the nixpkgs repo checks and should not be trusted or used elsewhere. name: nixpkgs-ci - signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - name: Building NixOS manual run: NIX_PATH=nixpkgs=$(pwd) nix-build --option restrict-eval true nixos/release.nix -A manual.x86_64-linux diff --git a/.github/workflows/manual-nixpkgs.yml b/.github/workflows/manual-nixpkgs.yml index 9d675c385feb..672ebf61ac77 100644 --- a/.github/workflows/manual-nixpkgs.yml +++ b/.github/workflows/manual-nixpkgs.yml @@ -9,13 +9,14 @@ on: paths: - 'doc/**' - 'lib/**' + - 'pkgs/tools/nix/nixdoc/**' jobs: nixpkgs: runs-on: ubuntu-latest if: github.repository_owner == 'NixOS' steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: # pull_request_target checks out the base branch by default ref: refs/pull/${{ github.event.pull_request.number }}/merge @@ -27,6 +28,6 @@ jobs: with: # This cache is for the nixpkgs repo checks and should not be trusted or used elsewhere. name: nixpkgs-ci - signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - name: Building Nixpkgs manual run: NIX_PATH=nixpkgs=$(pwd) nix-build --option restrict-eval true pkgs/top-level/release.nix -A manual -A manual.tests diff --git a/.github/workflows/nix-parse.yml b/.github/workflows/nix-parse.yml index da2e942414e2..b86594e0d53b 100644 --- a/.github/workflows/nix-parse.yml +++ b/.github/workflows/nix-parse.yml @@ -24,7 +24,7 @@ jobs: if [[ -s "$HOME/changed_files" ]]; then echo "CHANGED_FILES=$HOME/changed_files" > "$GITHUB_ENV" fi - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: # pull_request_target checks out the base branch by default ref: refs/pull/${{ github.event.pull_request.number }}/merge diff --git a/.github/workflows/periodic-merge-24h.yml b/.github/workflows/periodic-merge-24h.yml index 6adada59c5a5..d9ad593618ae 100644 --- a/.github/workflows/periodic-merge-24h.yml +++ b/.github/workflows/periodic-merge-24h.yml @@ -41,7 +41,7 @@ jobs: into: staging-23.11 name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }} steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }} uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f # 1.4.0 diff --git a/.github/workflows/periodic-merge-6h.yml b/.github/workflows/periodic-merge-6h.yml index 6f188ee28d17..a3131e802534 100644 --- a/.github/workflows/periodic-merge-6h.yml +++ b/.github/workflows/periodic-merge-6h.yml @@ -39,7 +39,7 @@ jobs: into: staging name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }} steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }} uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f # 1.4.0 diff --git a/.github/workflows/update-terraform-providers.yml b/.github/workflows/update-terraform-providers.yml index 9b7ec5cc59b0..36d84d617dc4 100644 --- a/.github/workflows/update-terraform-providers.yml +++ b/.github/workflows/update-terraform-providers.yml @@ -16,7 +16,7 @@ jobs: if: github.repository_owner == 'NixOS' && github.ref == 'refs/heads/master' # ensure workflow_dispatch only runs on master runs-on: ubuntu-latest steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26 with: nix_path: nixpkgs=channel:nixpkgs-unstable @@ -46,7 +46,7 @@ jobs: run: | git clean -f - name: create PR - uses: peter-evans/create-pull-request@70a41aba780001da0a30141984ae2a0c95d8704e # v6.0.2 + uses: peter-evans/create-pull-request@9153d834b60caba6d51c9b9510b087acf9f33f83 # v6.0.4 with: body: | Automatic update by [update-terraform-providers](https://github.com/NixOS/nixpkgs/blob/master/.github/workflows/update-terraform-providers.yml) action. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 115dd993ea62..8d54124acfd7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -512,6 +512,7 @@ To get a sense for what changes are considered mass rebuilds, see [previously me - Check for unnecessary whitespace with `git diff --check` before committing. - If you have commits `pkg-name: oh, forgot to insert whitespace`: squash commits in this case. Use `git rebase -i`. + See [Squashing Commits](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#_squashing) for additional information. - For consistency, there should not be a period at the end of the commit message's summary line (the first line of the commit message). @@ -557,7 +558,7 @@ Names of files and directories should be in lowercase, with dashes between words ```nix foo { - arg = ...; + arg = <...>; } ``` @@ -566,14 +567,14 @@ Names of files and directories should be in lowercase, with dashes between words ```nix foo { - arg = ...; + arg = <...>; } ``` Also fine is ```nix - foo { arg = ...; } + foo { arg = <...>; } ``` if it's a short call. @@ -581,41 +582,45 @@ Names of files and directories should be in lowercase, with dashes between words - In attribute sets or lists that span multiple lines, the attribute names or list elements should be aligned: ```nix - # A long list. - list = [ - elem1 - elem2 - elem3 - ]; + { + # A long list. + list = [ + elem1 + elem2 + elem3 + ]; - # A long attribute set. - attrs = { - attr1 = short_expr; - attr2 = - if true then big_expr else big_expr; - }; + # A long attribute set. + attrs = { + attr1 = short_expr; + attr2 = + if true then big_expr else big_expr; + }; - # Combined - listOfAttrs = [ - { - attr1 = 3; - attr2 = "fff"; - } - { - attr1 = 5; - attr2 = "ggg"; - } - ]; + # Combined + listOfAttrs = [ + { + attr1 = 3; + attr2 = "fff"; + } + { + attr1 = 5; + attr2 = "ggg"; + } + ]; + } ``` - Short lists or attribute sets can be written on one line: ```nix - # A short list. - list = [ elem1 elem2 elem3 ]; + { + # A short list. + list = [ elem1 elem2 elem3 ]; - # A short set. - attrs = { x = 1280; y = 1024; }; + # A short set. + attrs = { x = 1280; y = 1024; }; + } ``` - Breaking in the middle of a function argument can give hard-to-read code, like @@ -649,7 +654,7 @@ Names of files and directories should be in lowercase, with dashes between words ```nix { arg1, arg2 }: assert system == "i686-linux"; - stdenv.mkDerivation { ... + stdenv.mkDerivation { /* ... */ } ``` not @@ -657,41 +662,41 @@ Names of files and directories should be in lowercase, with dashes between words ```nix { arg1, arg2 }: assert system == "i686-linux"; - stdenv.mkDerivation { ... + stdenv.mkDerivation { /* ... */ } ``` - Function formal arguments are written as: ```nix - { arg1, arg2, arg3 }: + { arg1, arg2, arg3 }: { /* ... */ } ``` but if they don't fit on one line they're written as: ```nix { arg1, arg2, arg3 - , arg4, ... - , # Some comment... - argN - }: + , arg4 + # Some comment... + , argN + }: { } ``` - Functions should list their expected arguments as precisely as possible. That is, write ```nix - { stdenv, fetchurl, perl }: ... + { stdenv, fetchurl, perl }: <...> ``` instead of ```nix - args: with args; ... + args: with args; <...> ``` or ```nix - { stdenv, fetchurl, perl, ... }: ... + { stdenv, fetchurl, perl, ... }: <...> ``` For functions that are truly generic in the number of arguments (such as wrappers around `mkDerivation`) that have some required arguments, you should write them using an `@`-pattern: @@ -700,7 +705,7 @@ Names of files and directories should be in lowercase, with dashes between words { stdenv, doCoverageAnalysis ? false, ... } @ args: stdenv.mkDerivation (args // { - ... if doCoverageAnalysis then "bla" else "" ... + foo = if doCoverageAnalysis then "bla" else ""; }) ``` @@ -710,32 +715,40 @@ Names of files and directories should be in lowercase, with dashes between words args: args.stdenv.mkDerivation (args // { - ... if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "" ... + foo = if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else ""; }) ``` - Unnecessary string conversions should be avoided. Do ```nix - rev = version; + { + rev = version; + } ``` instead of ```nix - rev = "${version}"; + { + rev = "${version}"; + } ``` - Building lists conditionally _should_ be done with `lib.optional(s)` instead of using `if cond then [ ... ] else null` or `if cond then [ ... ] else [ ]`. ```nix - buildInputs = lib.optional stdenv.isDarwin iconv; + { + buildInputs = lib.optional stdenv.isDarwin iconv; + } ``` instead of ```nix - buildInputs = if stdenv.isDarwin then [ iconv ] else null; + { + buildInputs = if stdenv.isDarwin then [ iconv ] else null; + } ``` As an exception, an explicit conditional expression with null can be used when fixing a important bug without triggering a mass rebuild. diff --git a/README.md b/README.md index 481ada0565f8..5e6a8c54832b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@

- + - NixOS logo + NixOS logo

@@ -14,7 +14,7 @@

[Nixpkgs](https://github.com/nixos/nixpkgs) is a collection of over -80,000 software packages that can be installed with the +100,000 software packages that can be installed with the [Nix](https://nixos.org/nix/) package manager. It also implements [NixOS](https://nixos.org/nixos/), a purely-functional Linux distribution. @@ -29,8 +29,8 @@ * [Discourse Forum](https://discourse.nixos.org/) * [Matrix Chat](https://matrix.to/#/#community:nixos.org) * [NixOS Weekly](https://weekly.nixos.org/) -* [Community-maintained wiki](https://nixos.wiki/) -* [Community-maintained list of ways to get in touch](https://nixos.wiki/wiki/Get_In_Touch#Chat) (Discord, Telegram, IRC, etc.) +* [Official wiki](https://wiki.nixos.org/) +* [Community-maintained list of ways to get in touch](https://wiki.nixos.org/wiki/Get_In_Touch#Chat) (Discord, Telegram, IRC, etc.) # Other Project Repositories diff --git a/doc/README.md b/doc/README.md index 1e9305d040ba..41afc090b374 100644 --- a/doc/README.md +++ b/doc/README.md @@ -106,12 +106,12 @@ This is a warning The following are supported: -- [`caution`](https://tdg.docbook.org/tdg/5.0/caution.html) -- [`important`](https://tdg.docbook.org/tdg/5.0/important.html) -- [`note`](https://tdg.docbook.org/tdg/5.0/note.html) -- [`tip`](https://tdg.docbook.org/tdg/5.0/tip.html) -- [`warning`](https://tdg.docbook.org/tdg/5.0/warning.html) -- [`example`](https://tdg.docbook.org/tdg/5.0/example.html) +- `caution` +- `important` +- `note` +- `tip` +- `warning` +- `example` Example admonitions require a title to work. If you don't provide one, the manual won't be built. diff --git a/doc/build-helpers/fetchers.chapter.md b/doc/build-helpers/fetchers.chapter.md index b326f189d50e..cb37dca06d48 100644 --- a/doc/build-helpers/fetchers.chapter.md +++ b/doc/build-helpers/fetchers.chapter.md @@ -1,88 +1,681 @@ # Fetchers {#chap-pkgs-fetchers} Building software with Nix often requires downloading source code and other files from the internet. -To this end, Nixpkgs provides *fetchers*: functions to obtain remote sources via various protocols and services. +To this end, we use functions that we call _fetchers_, which obtain remote sources via various protocols and services. + +Nix provides built-in fetchers such as [`builtins.fetchTarball`](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fetchTarball). +Nixpkgs provides its own fetchers, which work differently: -Nixpkgs fetchers differ from built-in fetchers such as [`builtins.fetchTarball`](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fetchTarball): - A built-in fetcher will download and cache files at evaluation time and produce a [store path](https://nixos.org/manual/nix/stable/glossary#gloss-store-path). - A Nixpkgs fetcher will create a ([fixed-output](https://nixos.org/manual/nix/stable/glossary#gloss-fixed-output-derivation)) [derivation](https://nixos.org/manual/nix/stable/language/derivations), and files are downloaded at build time. + A Nixpkgs fetcher will create a ([fixed-output](https://nixos.org/manual/nix/stable/glossary#gloss-fixed-output-derivation)) [derivation](https://nixos.org/manual/nix/stable/glossary#gloss-derivation), and files are downloaded at build time. - Built-in fetchers will invalidate their cache after [`tarball-ttl`](https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-tarball-ttl) expires, and will require network activity to check if the cache entry is up to date. - Nixpkgs fetchers only re-download if the specified hash changes or the store object is not otherwise available. + Nixpkgs fetchers only re-download if the specified hash changes or the store object is not available. - Built-in fetchers do not use [substituters](https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-substituters). Derivations produced by Nixpkgs fetchers will use any configured binary cache transparently. -This significantly reduces the time needed to evaluate the entirety of Nixpkgs, and allows [Hydra](https://nixos.org/hydra) to retain and re-distribute sources used by Nixpkgs in the [public binary cache](https://cache.nixos.org). -For these reasons, built-in fetchers are not allowed in Nixpkgs source code. +This significantly reduces the time needed to evaluate Nixpkgs, and allows [Hydra](https://nixos.org/hydra) to retain and re-distribute sources used by Nixpkgs in the [public binary cache](https://cache.nixos.org). +For these reasons, Nix's built-in fetchers are not allowed in Nixpkgs. -The following table shows an overview of the differences: +The following table summarises the differences: | Fetchers | Download | Output | Cache | Re-download when | |-|-|-|-|-| | `builtins.fetch*` | evaluation time | store path | `/nix/store`, `~/.cache/nix` | `tarball-ttl` expires, cache miss in `~/.cache/nix`, output store object not in local store | | `pkgs.fetch*` | build time | derivation | `/nix/store`, substituters | output store object not available | +:::{.tip} +`pkgs.fetchFrom*` helpers retrieve _snapshots_ of version-controlled sources, as opposed to the entire version history, which is more efficient. +`pkgs.fetchgit` by default also has the same behaviour, but can be changed through specific attributes given to it. +::: + ## Caveats {#chap-pkgs-fetchers-caveats} -The fact that the hash belongs to the Nix derivation output and not the file itself can lead to confusion. -For example, consider the following fetcher: +Because Nixpkgs fetchers are fixed-output derivations, an [output hash](https://nixos.org/manual/nix/stable/language/advanced-attributes#adv-attr-outputHash) has to be specified, usually indirectly through a `hash` attribute. +This hash refers to the derivation output, which can be different from the remote source itself! + +This has the following implications that you should be aware of: + +- Use Nix (or Nix-aware) tooling to produce the output hash. + +- When changing any fetcher parameters, always update the output hash. + Use one of the methods from [](#sec-pkgs-fetchers-updating-source-hashes). + Otherwise, existing store objects that match the output hash will be re-used rather than fetching new content. + + :::{.note} + A similar problem arises while testing changes to a fetcher's implementation. + If the output of the derivation already exists in the Nix store, test failures can go undetected. + The [`invalidateFetcherByDrvHash`](#tester-invalidateFetcherByDrvHash) function helps prevent reusing cached derivations. + ::: + +## Updating source hashes {#sec-pkgs-fetchers-updating-source-hashes} + +There are several ways to obtain the hash corresponding to a remote source. +Unless you understand how the fetcher you're using calculates the hash from the downloaded contents, you should use [the fake hash method](#sec-pkgs-fetchers-updating-source-hashes-fakehash-method). + +1. []{#sec-pkgs-fetchers-updating-source-hashes-fakehash-method} The fake hash method: In your package recipe, set the hash to one of + + - `""` + - `lib.fakeHash` + - `lib.fakeSha256` + - `lib.fakeSha512` + + Attempt to build, extract the calculated hashes from error messages, and put them into the recipe. + + :::{.warning} + You must use one of these four fake hashes and not some arbitrarily-chosen hash. + See [](#sec-pkgs-fetchers-secure-hashes) for details. + ::: + + :::{.example #ex-fetchers-update-fod-hash} + # Update source hash with the fake hash method + + Consider the following recipe that produces a plain file: + + ```nix + { fetchurl }: + fetchurl { + url = "https://raw.githubusercontent.com/NixOS/nixpkgs/23.05/.version"; + hash = "sha256-ZHl1emidXVojm83LCVrwULpwIzKE/mYwfztVkvpruOM="; + } + ``` + + A common mistake is to update a fetcher parameter, such as `url`, without updating the hash: + + ```nix + { fetchurl }: + fetchurl { + url = "https://raw.githubusercontent.com/NixOS/nixpkgs/23.11/.version"; + hash = "sha256-ZHl1emidXVojm83LCVrwULpwIzKE/mYwfztVkvpruOM="; + } + ``` + + **This will produce the same output as before!** + Set the hash to an empty string: + + ```nix + { fetchurl }: + fetchurl { + url = "https://raw.githubusercontent.com/NixOS/nixpkgs/23.11/.version"; + hash = ""; + } + ``` + + When building the package, use the error message to determine the correct hash: + + ```shell + $ nix-build + (some output removed for clarity) + error: hash mismatch in fixed-output derivation '/nix/store/7yynn53jpc93l76z9zdjj4xdxgynawcw-version.drv': + specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + got: sha256-BZqI7r0MNP29yGH5+yW2tjU9OOpOCEvwWKrWCv5CQ0I= + error: build of '/nix/store/bqdjcw5ij5ymfbm41dq230chk9hdhqff-version.drv' failed + ``` + ::: + +2. Prefetch the source with [`nix-prefetch- `](https://search.nixos.org/packages?buckets={%22package_attr_set%22%3A[%22No%20package%20set%22]%2C%22package_license_set%22%3A[]%2C%22package_maintainers_set%22%3A[]%2C%22package_platforms%22%3A[]}&query=nix-prefetch), where `` is one of + + - `url` + - `git` + - `hg` + - `cvs` + - `bzr` + - `svn` + + The hash is printed to stdout. + +3. Prefetch by package source (with `nix-prefetch-url '' -A .src`, where `` is package attribute name). + The hash is printed to stdout. + + This works well when you've upgraded the existing package version and want to find out new hash, but is useless if the package can't be accessed by attribute or the package has multiple sources (`.srcs`, architecture-dependent sources, etc). + +4. Upstream hash: use it when upstream provides `sha256` or `sha512`. + Don't use it when upstream provides `md5`, compute `sha256` instead. + + A little nuance is that `nix-prefetch-*` tools produce hashes with the `nix32` encoding (a Nix-specific base32 adaptation), but upstream usually provides hexadecimal (`base16`) encoding. + Fetchers understand both formats. + Nixpkgs does not standardise on any one format. + + You can convert between hash formats with [`nix-hash`](https://nixos.org/manual/nix/stable/command-ref/nix-hash). + +5. Extract the hash from a local source archive with `sha256sum`. + Use `nix-prefetch-url file:///path/to/archive` if you want the custom Nix `base32` hash. + +## Obtaining hashes securely {#sec-pkgs-fetchers-secure-hashes} + +It's always a good idea to avoid Man-in-the-Middle (MITM) attacks when downloading source contents. +Otherwise, you could unknowingly download malware instead of the intended source, and instead of the actual source hash, you'll end up using the hash of malware. +Here are security considerations for this scenario: + +- `http://` URLs are not secure to prefetch hashes. + +- Upstream hashes should be obtained via a secure protocol. + +- `https://` URLs give you more protections when using `nix-prefetch-*` or for upstream hashes. + +- `https://` URLs are secure when using the [fake hash method](#sec-pkgs-fetchers-updating-source-hashes-fakehash-method) *only if* you use one of the listed fake hashes. + If you use any other hash, the download will be exposed to MITM attacks even if you use HTTPS URLs. + + In more concrete terms, if you use any other hash, the [`--insecure` flag](https://curl.se/docs/manpage.html#-k) will be passed to the underlying call to `curl` when downloading content. + +[]{#fetchurl} +## `fetchurl` {#sec-pkgs-fetchers-fetchurl} + +`fetchurl` returns a [fixed-output derivation](https://nixos.org/manual/nix/stable/glossary.html#gloss-fixed-output-derivation) which downloads content from a given URL and stores the unaltered contents within the Nix store. + +It uses {manpage}`curl(1)` internally, and allows its behaviour to be modified by specifying a few attributes in the argument to `fetchurl` (see the documentation for attributes `curlOpts`, `curlOptsList`, and `netrcPhase`). + +The resulting [store path](https://nixos.org/manual/nix/stable/store/store-path) is determined by the hash given to `fetchurl`, and also the `name` (or `pname` and `version`) values. + +If neither `name` nor `pname` and `version` are specified when calling `fetchurl`, it will default to using the [basename](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-baseNameOf) of `url` or the first element of `urls`. +If `pname` and `version` are specified, `fetchurl` will use those values and will ignore `name`, even if it is also specified. + +### Inputs {#sec-pkgs-fetchers-fetchurl-inputs} + +`fetchurl` requires an attribute set with the following attributes: + +`url` (String; _optional_) +: The URL to download from. + + :::{.note} + Either `url` or `urls` must be specified, but not both. + ::: + + All URLs of the format [specified here](https://curl.se/docs/url-syntax.html#rfc-3986-plus) are supported. + + _Default value:_ `""`. + +`urls` (List of String; _optional_) +: A list of URLs, specifying download locations for the same content. + Each URL will be tried in order until one of them succeeds with some content or all of them fail. + See [](#ex-fetchers-fetchurl-nixpkgs-version-multiple-urls) to understand how this attribute affects the behaviour of `fetchurl`. + + :::{.note} + Either `url` or `urls` must be specified, but not both. + ::: + + _Default value:_ `[]`. + +`hash` (String; _optional_) +: Hash of the derivation output of `fetchurl`, following the format for integrity metadata as defined by [SRI](https://www.w3.org/TR/SRI/). + For more information, see [](#chap-pkgs-fetchers-caveats). + + :::{.note} + It is recommended that you use the `hash` attribute instead of the other hash-specific attributes that exist for backwards compatibility. + + If `hash` is not specified, you must specify `outputHash` and `outputHashAlgo`, or one of `sha512`, `sha256`, or `sha1`. + ::: + + _Default value:_ `""`. + +`outputHash` (String; _optional_) +: Hash of the derivation output of `fetchurl` in the format expected by Nix. + See [the documentation on the Nix manual](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-outputHash) for more information about its format. + + :::{.note} + It is recommended that you use the `hash` attribute instead. + + If `outputHash` is specified, you must also specify `outputHashAlgo`. + ::: + + _Default value:_ `""`. + +`outputHashAlgo` (String; _optional_) +: Algorithm used to generate the value specified in `outputHash`. + See [the documentation on the Nix manual](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-outputHashAlgo) for more information about the values it supports. + + :::{.note} + It is recommended that you use the `hash` attribute instead. + + The value specified in `outputHashAlgo` will be ignored if `outputHash` isn't also specified. + ::: + + _Default value:_ `""`. + +`sha1` (String; _optional_) +: SHA-1 hash of the derivation output of `fetchurl` in the format expected by Nix. + See [the documentation on the Nix manual](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-outputHash) for more information about its format. + + :::{.note} + It is recommended that you use the `hash` attribute instead. + ::: + + _Default value:_ `""`. + +`sha256` (String; _optional_) +: SHA-256 hash of the derivation output of `fetchurl` in the format expected by Nix. + See [the documentation on the Nix manual](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-outputHash) for more information about its format. + + :::{.note} + It is recommended that you use the `hash` attribute instead. + ::: + + _Default value:_ `""`. + +`sha512` (String; _optional_) +: SHA-512 hash of the derivation output of `fetchurl` in the format expected by Nix. + See [the documentation on the Nix manual](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-outputHash) for more information about its format. + + :::{.note} + It is recommended that you use the `hash` attribute instead. + ::: + + _Default value:_ `""`. + +`name` (String; _optional_) +: The symbolic name of the downloaded file when saved in the Nix store. + See [the `fetchurl` overview](#sec-pkgs-fetchers-fetchurl) for details on how the name of the file is decided. + + _Default value:_ `""`. + +`pname` (String; _optional_) +: A base name, which will be combined with `version` to form the symbolic name of the downloaded file when saved in the Nix store. + See [the `fetchurl` overview](#sec-pkgs-fetchers-fetchurl) for details on how the name of the file is decided. + + :::{.note} + If `pname` is specified, you must also specify `version`, otherwise `fetchurl` will ignore the value of `pname`. + ::: + + _Default value:_ `""`. + +`version` (String; _optional_) +: A version, which will be combined with `pname` to form the symbolic name of the downloaded file when saved in the Nix store. + See [the `fetchurl` overview](#sec-pkgs-fetchers-fetchurl) for details on how the name of the file is decided. + + _Default value:_ `""`. + +`recursiveHash` (Boolean; _optional_) []{#sec-pkgs-fetchers-fetchurl-inputs-recursiveHash} +: If set to `true`, will signal to Nix that the hash given to `fetchurl` was calculated using the `"recursive"` mode. + See [the documentation on the Nix manual](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-outputHashMode) for more information about the existing modes. + + By default, `fetchurl` uses `"recursive"` mode when the `executable` attribute is set to `true`, so you don't need to specify `recursiveHash` in this case. + + _Default value:_ `false`. + +`executable` (Boolean; _optional_) +: If `true`, sets the executable bit on the downloaded file. + + _Default value_: `false`. + +`downloadToTemp` (Boolean; _optional_) []{#sec-pkgs-fetchers-fetchurl-inputs-downloadToTemp} +: If `true`, saves the downloaded file to a temporary location instead of the expected Nix store location. + This is useful when used in conjunction with `postFetch` attribute, otherwise `fetchurl` will not produce any meaningful output. + + The location of the downloaded file will be set in the `$downloadedFile` variable, which should be used by the script in the `postFetch` attribute. + See [](#ex-fetchers-fetchurl-nixpkgs-version-postfetch) to understand how to work with this attribute. + + _Default value:_ `false`. + +`postFetch` (String; _optional_) +: Script executed after the file has been downloaded successfully, and before `fetchurl` finishes running. + Useful for post-processing, to check or transform the file in some way. + See [](#ex-fetchers-fetchurl-nixpkgs-version-postfetch) to understand how to work with this attribute. + + _Default value:_ `""`. + +`netrcPhase` (String or Null; _optional_) +: Script executed to create a {manpage}`netrc(5)` file to be used with {manpage}`curl(1)`. + The script should create the `netrc` file (note that it does not begin with a ".") in the directory it's currently running in (`$PWD`). + + The script is executed during the setup done by `fetchurl` before it runs any of its code to download the specified content. + + :::{.note} + If specified, `fetchurl` will automatically alter its invocation of {manpage}`curl(1)` to use the `netrc` file, so you don't need to add anything to `curlOpts` or `curlOptsList`. + ::: + + :::{.caution} + Since `netrcPhase` needs to be specified in your source Nix code, any secrets that you put directly in it will be world-readable by design (both in your source code, and when the derivation gets created in the Nix store). + + If you want to avoid this behaviour, see the documentation of `netrcImpureEnvVars` for an alternative way of dealing with these secrets. + ::: + + _Default value_: `null`. + +`netrcImpureEnvVars` (List of String; _optional_) +: If specified, `fetchurl` will add these environment variable names to the list of [impure environment variables](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-impureEnvVars), which will be passed from the environment of the calling user to the builder running the `fetchurl` code. + + This is useful when used with `netrcPhase` to hide any secrets that are used in it, because the script in `netrcPhase` only needs to reference the environment variables with the secrets in them instead. + However, note that these are called _impure_ variables for a reason: + the environment that starts the build needs to have these variables declared for everything to work properly, which means that additional setup is required outside what Nix controls. + + _Default value:_ `[]`. + +`curlOpts` (String; _optional_) +: If specified, this value will be appended to the invocation of {manpage}`curl(1)` when downloading the URL(s) given to `fetchurl`. + Multiple arguments can be separated by spaces normally, but values with whitespaces will be interpreted as multiple arguments (instead of a single value), even if the value is escaped. + See `curlOptsList` for a way to pass values with whitespaces in them. + + _Default value:_ `""`. + +`curlOptsList` (List of String; _optional_) +: If specified, each element of this list will be passed as an argument to the invocation of {manpage}`curl(1)` when downloading the URL(s) given to `fetchurl`. + This allows passing values that contain spaces, with no escaping needed. + + _Default value:_ `[]`. + +`showURLs` (Boolean; _optional_) +: If set to `true`, this will stop `fetchurl` from downloading anything at all. + Instead, it will output a list of all the URLs it would've used to download the content (after resolving `mirror://` URLs, for example). + This is useful for debugging. + + _Default value:_ `false`. + +`meta` (Attribute Set; _optional_) +: Specifies any [meta-attributes](#chap-meta) for the derivation returned by `fetchurl`. + + _Default value:_ `{}`. + +`passthru` (Attribute Set; _optional_) +: Specifies any extra [passthru](#var-stdenv-passthru) attributes for the derivation returned by `fetchurl`. + Note that `fetchurl` defines [passthru attributes of its own](#ssec-pkgs-fetchers-fetchurl-passthru-outputs). + Attributes specified in `passthru` can override the default attributes returned by `fetchurl`. + + _Default value:_ `{}`. + +`preferLocalBuild` (Boolean; _optional_) +: This is the same attribute as [defined in the Nix manual](https://nixos.org/manual/nix/stable/language/advanced-attributes.html#adv-attr-preferLocalBuild). + It is `true` by default because making a remote machine download the content just duplicates network traffic (since the local machine might download the results from the derivation anyway), but this could be useful in cases where network access is restricted on local machines. + + _Default value:_ `true`. + +`nativeBuildInputs` (List of Attribute Set; _optional_) +: Additional packages needed to download the content. + This is useful if you need extra packages for `postFetch` or `netrcPhase`, for example. + Has the same semantics as in [](#var-stdenv-nativeBuildInputs). + See [](#ex-fetchers-fetchurl-nixpkgs-version-postfetch) to understand how this can be used with `postFetch`. + + _Default value:_ `[]`. + +### Passthru outputs {#ssec-pkgs-fetchers-fetchurl-passthru-outputs} + +`fetchurl` also defines its own [`passthru`](#var-stdenv-passthru) attributes: + +`url` (String) + +: The same `url` attribute passed in the argument to `fetchurl`. + +### Examples {#ssec-pkgs-fetchers-fetchurl-examples} + +:::{.example #ex-fetchers-fetchurl-nixpkgs-version} +# Using `fetchurl` to download a file + +The following package downloads a small file from a URL and shows the most common way to use `fetchurl`: ```nix +{ fetchurl }: fetchurl { - url = "http://www.example.org/hello-1.0.tar.gz"; - hash = "sha256-lTeyxzJNQeMdu1IVdovNMtgn77jRIhSybLdMbTkf2Ww="; -}; -``` - -A common mistake is to update a fetcher’s URL, or a version parameter, without updating the hash. - -```nix -fetchurl { - url = "http://www.example.org/hello-1.1.tar.gz"; - hash = "sha256-lTeyxzJNQeMdu1IVdovNMtgn77jRIhSybLdMbTkf2Ww="; -}; -``` - -**This will reuse the old contents**. -Remember to invalidate the hash argument, in this case by setting the `hash` attribute to an empty string. - -```nix -fetchurl { - url = "http://www.example.org/hello-1.1.tar.gz"; - hash = ""; -}; -``` - -Use the resulting error message to determine the correct hash. - -``` -error: hash mismatch in fixed-output derivation '/path/to/my.drv': - specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= - got: sha256-lTeyxzJNQeMdu1IVdovNMtgn77jRIhSybLdMbTkf2Ww= -``` - -A similar problem arises while testing changes to a fetcher's implementation. If the output of the derivation already exists in the Nix store, test failures can go undetected. The [`invalidateFetcherByDrvHash`](#tester-invalidateFetcherByDrvHash) function helps prevent reusing cached derivations. - -## `fetchurl` and `fetchzip` {#fetchurl} - -Two basic fetchers are `fetchurl` and `fetchzip`. Both of these have two required arguments, a URL and a hash. The hash is typically `hash`, although many more hash algorithms are supported. Nixpkgs contributors are currently recommended to use `hash`. This hash will be used by Nix to identify your source. A typical usage of `fetchurl` is provided below. - -```nix -{ stdenv, fetchurl }: - -stdenv.mkDerivation { - name = "hello"; - src = fetchurl { - url = "http://www.example.org/hello.tar.gz"; - hash = "sha256-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB="; - }; + url = "https://raw.githubusercontent.com/NixOS/nixpkgs/23.11/.version"; + hash = "sha256-BZqI7r0MNP29yGH5+yW2tjU9OOpOCEvwWKrWCv5CQ0I="; } ``` -The main difference between `fetchurl` and `fetchzip` is in how they store the contents. `fetchurl` will store the unaltered contents of the URL within the Nix store. `fetchzip` on the other hand, will decompress the archive for you, making files and directories directly accessible in the future. `fetchzip` can only be used with archives. Despite the name, `fetchzip` is not limited to .zip files and can also be used with any tarball. +After building the package, the file will be downloaded and place into the Nix store: -Additional parameters to `fetchurl`: -- `downloadToTemp`: Defaults to `false`. If `true`, saves the source to `$downloadedFile`, to be used in conjunction with `postFetch` -- `postFetch`: Shell code executed after the file has been fetched successfully. Use it for postprocessing, to check or transform the file. +```shell +$ nix-build +(output removed for clarity) +/nix/store/4g9y3x851wqrvim4zcz5x2v3zivmsq8n-version + +$ cat /nix/store/4g9y3x851wqrvim4zcz5x2v3zivmsq8n-version +23.11 +``` +::: + +:::{.example #ex-fetchers-fetchurl-nixpkgs-version-multiple-urls} +# Using `fetchurl` to download a file with multiple possible URLs + +The following package adapts [](#ex-fetchers-fetchurl-nixpkgs-version) to use multiple URLs. +The first URL was crafted to intentionally return an error to illustrate how `fetchurl` will try multiple URLs until it finds one that works (or all URLs fail). + +```nix +{ fetchurl }: +fetchurl { + urls = [ + "https://raw.githubusercontent.com/NixOS/nixpkgs/23.11/does-not-exist" + "https://raw.githubusercontent.com/NixOS/nixpkgs/23.11/.version" + ]; + hash = "sha256-BZqI7r0MNP29yGH5+yW2tjU9OOpOCEvwWKrWCv5CQ0I="; +} +``` + +After building the package, both URLs will be used to download the file: + +```shell +$ nix-build +(some output removed for clarity) +trying https://raw.githubusercontent.com/NixOS/nixpkgs/23.11/does-not-exist +(some output removed for clarity) +curl: (22) The requested URL returned error: 404 + +trying https://raw.githubusercontent.com/NixOS/nixpkgs/23.11/.version +(some output removed for clarity) +/nix/store/n9asny31z32q7sdw6a8r1gllrsfy53kl-does-not-exist + +$ cat /nix/store/n9asny31z32q7sdw6a8r1gllrsfy53kl-does-not-exist +23.11 +``` + +However, note that the name of the file was derived from the first URL (this is further explained in [the `fetchurl` overview](#sec-pkgs-fetchers-fetchurl)). +To ensure the result will have the same name regardless of which URLs are used, we can modify the package: + +```nix +{ fetchurl }: +fetchurl { + name = "nixpkgs-version"; + urls = [ + "https://raw.githubusercontent.com/NixOS/nixpkgs/23.11/does-not-exist" + "https://raw.githubusercontent.com/NixOS/nixpkgs/23.11/.version" + ]; + hash = "sha256-BZqI7r0MNP29yGH5+yW2tjU9OOpOCEvwWKrWCv5CQ0I="; +} +``` + +After building the package, the result will have the name we specified: + +```shell +$ nix-build +(output removed for clarity) +/nix/store/zczb6wl3al6jm9sm5h3pr6nqn0i5ji9z-nixpkgs-version +``` +::: + +:::{.example #ex-fetchers-fetchurl-nixpkgs-version-postfetch} +# Manipulating the content downloaded by `fetchurl` + +It might be useful to manipulate the content downloaded by `fetchurl` directly in its derivation. +In this example, we'll adapt [](#ex-fetchers-fetchurl-nixpkgs-version) to append the result of running the `hello` package to the contents we download, purely to illustrate how to manipulate the content. + +```nix +{ fetchurl, hello, lib }: +fetchurl { + url = "https://raw.githubusercontent.com/NixOS/nixpkgs/23.11/.version"; + + nativeBuildInputs = [ hello ]; + + downloadToTemp = true; + postFetch = '' + ${lib.getExe hello} >> $downloadedFile + mv $downloadedFile $out + ''; + + hash = "sha256-ceooQQYmDx5+0nfg40uU3NNI2yKrixP7HZ/xLZUNv+w="; +} +``` + +After building the package, the resulting file will have "Hello, world!" appended to it: + +```shell +$ nix-build +(output removed for clarity) +/nix/store/ifi6pp7q0ag5h7c5v9h1c1c7bhd10c7f-version + +$ cat /nix/store/ifi6pp7q0ag5h7c5v9h1c1c7bhd10c7f-version +23.11 +Hello, world! +``` + +Note that the `hash` specified in the package is different than the hash specified in [](#ex-fetchers-fetchurl-nixpkgs-version), because the contents of the output have changed (even though the actual file that was downloaded is the same). +See [](#chap-pkgs-fetchers-caveats) for more details on how to work with the `hash` attribute when the output changes. +::: + +## `fetchzip` {#sec-pkgs-fetchers-fetchzip} + +Returns a [fixed-output derivation](https://nixos.org/manual/nix/stable/glossary.html#gloss-fixed-output-derivation) which downloads an archive from a given URL and decompresses it. + +Despite its name, `fetchzip` is not limited to `.zip` files but can also be used with [various compressed tarball formats](#tar-files) by default. +This can extended by specifying additional attributes, see [](#ex-fetchers-fetchzip-rar-archive) to understand how to do that. + +### Inputs {#sec-pkgs-fetchers-fetchzip-inputs} + +`fetchzip` requires an attribute set, and most attributes are passed to the underlying call to [`fetchurl`](#sec-pkgs-fetchers-fetchurl). + +The attributes below are treated differently by `fetchzip` when compared to what `fetchurl` expects: + +`name` (String; _optional_) +: Works as defined in `fetchurl`, but has a different default value than `fetchurl`. + + _Default value:_ `"source"`. + +`nativeBuildInputs` (List of Attribute Set; _optional_) +: Works as defined in `fetchurl`, but it is also augmented by `fetchzip` to include packages to deal with additional archives (such as `.zip`). + + _Default value:_ `[]`. + +`postFetch` (String; _optional_) +: Works as defined in `fetchurl`, but it is also augmented with the code needed to make `fetchzip` work. + + :::{.caution} + It is only safe to modify files in `$out` in `postFetch`. + Consult the implementation of `fetchzip` for anything more involved. + ::: + + _Default value:_ `""`. + +`stripRoot` (Boolean; _optional_) +: If `true`, the decompressed contents are moved one level up the directory tree. + + This is useful for archives that decompress into a single directory which commonly includes some values that change with time, such as version numbers. + When this is the case (and `stripRoot` is `true`), `fetchzip` will remove this directory and make the decompressed contents available in the top-level directory. + + [](#ex-fetchers-fetchzip-simple-striproot) shows what this attribute does. + + This attribute is **not** passed through to `fetchurl`. + + _Default value:_ `true`. + +`extension` (String or Null; _optional_) +: If set, the archive downloaded by `fetchzip` will be renamed to a filename with the extension specified in this attribute. + + This is useful when making `fetchzip` support additional types of archives, because the implementation may use the extension of an archive to determine whether they can decompress it. + If the URL you're using to download the contents doesn't end with the extension associated with the archive, use this attribute to fix the filename of the archive. + + This attribute is **not** passed through to `fetchurl`. + + _Default value:_ `null`. + +`recursiveHash` (Boolean; _optional_) +: Works [as defined in `fetchurl`](#sec-pkgs-fetchers-fetchurl-inputs-recursiveHash), but its default value is different than for `fetchurl`. + + _Default value:_ `true`. + +`downloadToTemp` (Boolean; _optional_) +: Works [as defined in `fetchurl`](#sec-pkgs-fetchers-fetchurl-inputs-downloadToTemp), but its default value is different than for `fetchurl`. + + _Default value:_ `true`. + +`extraPostFetch` **DEPRECATED** +: This attribute is deprecated. + Please use `postFetch` instead. + + This attribute is **not** passed through to `fetchurl`. + +### Examples {#sec-pkgs-fetchers-fetchzip-examples} + +::::{.example #ex-fetchers-fetchzip-simple-striproot} +# Using `fetchzip` to output contents directly + +The following recipe shows how to use `fetchzip` to decompress a `.tar.gz` archive: + +```nix +{ fetchzip }: +fetchzip { + url = "https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.gz"; + hash = "sha256-3ABYlME9R8klcpJ7MQpyFEFwHmxDDEzIYBqu/CpDYmg="; +} +``` + +This archive has all its contents in a directory named `patchelf-0.18.0`. +This means that after decompressing, you'd have to enter this directory to see the contents of the archive. +However, `fetchzip` makes this easier through the attribute `stripRoot` (enabled by default). + +After building the recipe, the derivation output will show all the files in the archive at the top level: + +```shell +$ nix-build +(output removed for clarity) +/nix/store/1b7h3fvmgrcddvs0m299hnqxlgli1yjw-source + +$ ls /nix/store/1b7h3fvmgrcddvs0m299hnqxlgli1yjw-source +aclocal.m4 completions configure.ac m4 Makefile.in patchelf.spec README.md tests +build-aux configure COPYING Makefile.am patchelf.1 patchelf.spec.in src version +``` + +If `stripRoot` is set to `false`, the derivation output will be the decompressed archive as-is: + +```nix +{ fetchzip }: +fetchzip { + url = "https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.gz"; + hash = "sha256-uv3FuKE4DqpHT3yfE0qcnq0gYjDNQNKZEZt2+PUAneg="; + stripRoot = false; +} +``` + +:::{.caution} +The hash changed! +Whenever changing attributes of a Nixpkgs fetcher, [remember to invalidate the hash](#chap-pkgs-fetchers-caveats), otherwise you won't get the results you're expecting! +::: + +After building the recipe: + +```shell +$ nix-build +(output removed for clarity) +/nix/store/2hy5bxw7xgbgxkn0i4x6hjr8w3dbx16c-source + +$ ls /nix/store/2hy5bxw7xgbgxkn0i4x6hjr8w3dbx16c-source +patchelf-0.18.0 +``` +:::: + +::::{.example #ex-fetchers-fetchzip-rar-archive} +# Using `fetchzip` to decompress a `.rar` file + +The `unrar` package provides a [setup hook](#ssec-setup-hooks) to decompress `.rar` archives during the [unpack phase](#ssec-unpack-phase), which can be used with `fetchzip` to decompress those archives: + +```nix +{ fetchzip, unrar }: +fetchzip { + url = "https://archive.org/download/SpaceCadet_Plus95/Space_Cadet.rar"; + hash = "sha256-fC+zsR8BY6vXpUkVd6i1jF0IZZxVKVvNi6VWCKT+pA4="; + stripRoot = false; + nativeBuildInputs = [ unrar ]; +} +``` + +Since this particular `.rar` file doesn't put its contents in a directory inside the archive, `stripRoot` must be set to `false`. + +After building the recipe, the derivation output will show the decompressed files: + +```shell +$ nix-build +(output removed for clarity) +/nix/store/zpn7knxfva6rfjja2gbb4p3l9w1f0d36-source + +$ ls /nix/store/zpn7knxfva6rfjja2gbb4p3l9w1f0d36-source +FONT.DAT PINBALL.DAT PINBALL.EXE PINBALL2.MID TABLE.BMP WMCONFIG.EXE +MSCREATE.DIR PINBALL.DOC PINBALL.MID Sounds WAVEMIX.INF +``` +:::: ## `fetchpatch` {#fetchpatch} @@ -123,7 +716,7 @@ Here is an example of `fetchDebianPatch` in action: buildPythonPackage rec { pname = "pysimplesoap"; version = "1.16.2"; - src = ...; + src = <...>; patches = [ (fetchDebianPatch { @@ -134,7 +727,7 @@ buildPythonPackage rec { }) ]; - ... + # ... } ``` @@ -243,7 +836,7 @@ This is a useful last-resort workaround for license restrictions that prohibit r If the requested file is present in the Nix store, the resulting derivation will not be built, because its expected output is already available. Otherwise, the builder will run, but fail with a message explaining to the user how to provide the file. The following code, for example: -``` +```nix requireFile { name = "jdk-${version}_linux-x64_bin.tar.gz"; url = "https://www.oracle.com/java/technologies/javase-jdk11-downloads.html"; @@ -270,7 +863,7 @@ It produces packages that cannot be built automatically. `fetchtorrent` expects two arguments. `url` which can either be a Magnet URI (Magnet Link) such as `magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c` or an HTTP URL pointing to a `.torrent` file. It can also take a `config` argument which will craft a `settings.json` configuration file and give it to `transmission`, the underlying program that is performing the fetch. The available config options for `transmission` can be found [here](https://github.com/transmission/transmission/blob/main/docs/Editing-Configuration-Files.md#options) -``` +```nix { fetchtorrent }: fetchtorrent { diff --git a/doc/build-helpers/images/dockertools.section.md b/doc/build-helpers/images/dockertools.section.md index 001d5695290e..527e623e7898 100644 --- a/doc/build-helpers/images/dockertools.section.md +++ b/doc/build-helpers/images/dockertools.section.md @@ -1177,6 +1177,7 @@ dockerTools.buildImage { hello dockerTools.binSh ]; +} ``` After building the image and loading it in Docker, we can create a container based on it and enter a shell inside the container. diff --git a/doc/build-helpers/special/checkpoint-build.section.md b/doc/build-helpers/special/checkpoint-build.section.md index f60afe801ed4..a1ce5608f246 100644 --- a/doc/build-helpers/special/checkpoint-build.section.md +++ b/doc/build-helpers/special/checkpoint-build.section.md @@ -9,13 +9,17 @@ However, we can tell Nix explicitly what the previous build state was, by repres To change a normal derivation to a checkpoint based build, these steps must be taken: - apply `prepareCheckpointBuild` on the desired derivation, e.g. ```nix -checkpointArtifacts = (pkgs.checkpointBuildTools.prepareCheckpointBuild pkgs.virtualbox); +{ + checkpointArtifacts = (pkgs.checkpointBuildTools.prepareCheckpointBuild pkgs.virtualbox); +} ``` - change something you want in the sources of the package, e.g. use a source override: ```nix -changedVBox = pkgs.virtualbox.overrideAttrs (old: { - src = path/to/vbox/sources; -}); +{ + changedVBox = pkgs.virtualbox.overrideAttrs (old: { + src = path/to/vbox/sources; + }); +} ``` - use `mkCheckpointBuild changedVBox checkpointArtifacts` - enjoy shorter build times diff --git a/doc/build-helpers/special/fhs-environments.section.md b/doc/build-helpers/special/fhs-environments.section.md index 8145fbd730f7..918d1e8c2951 100644 --- a/doc/build-helpers/special/fhs-environments.section.md +++ b/doc/build-helpers/special/fhs-environments.section.md @@ -6,7 +6,11 @@ It uses Linux' namespaces feature to create temporary lightweight environments w Accepted arguments are: - `name` - The name of the environment and the wrapper executable. + The name of the environment, and the wrapper executable if `pname` is unset. +- `pname` + The pname of the environment and the wrapper executable. +- `version` + The version of the environment. - `targetPkgs` Packages to be installed for the main host's architecture (i.e. x86_64 on x86_64 installations). Along with libraries binaries are also installed. - `multiPkgs` diff --git a/doc/build-helpers/testers.chapter.md b/doc/build-helpers/testers.chapter.md index 35f9290ecbfb..b734cbbbd4e2 100644 --- a/doc/build-helpers/testers.chapter.md +++ b/doc/build-helpers/testers.chapter.md @@ -14,11 +14,13 @@ If the `moduleNames` argument is omitted, `hasPkgConfigModules` will use `meta.p # Check that `pkg-config` modules are exposed using default values ```nix -passthru.tests.pkg-config = testers.hasPkgConfigModules { - package = finalAttrs.finalPackage; -}; +{ + passthru.tests.pkg-config = testers.hasPkgConfigModules { + package = finalAttrs.finalPackage; + }; -meta.pkgConfigModules = [ "libfoo" ]; + meta.pkgConfigModules = [ "libfoo" ]; +} ``` ::: @@ -28,10 +30,12 @@ meta.pkgConfigModules = [ "libfoo" ]; # Check that `pkg-config` modules are exposed using explicit module names ```nix -passthru.tests.pkg-config = testers.hasPkgConfigModules { - package = finalAttrs.finalPackage; - moduleNames = [ "libfoo" ]; -}; +{ + passthru.tests.pkg-config = testers.hasPkgConfigModules { + package = finalAttrs.finalPackage; + moduleNames = [ "libfoo" ]; + }; +} ``` ::: @@ -55,7 +59,9 @@ The default argument to the command is `--version`, and the version to be checke This example will run the command `hello --version`, and then check that the version of the `hello` package is in the output of the command. ```nix -passthru.tests.version = testers.testVersion { package = hello; }; +{ + passthru.tests.version = testers.testVersion { package = hello; }; +} ``` ::: @@ -70,13 +76,15 @@ This means that an output like "leetcode 0.4.21" would fail the tests, and an ou A common usage of the `version` attribute is to specify `version = "v${version}"`. ```nix -version = "0.4.2"; +{ + version = "0.4.2"; -passthru.tests.version = testers.testVersion { - package = leetcode-cli; - command = "leetcode -V"; - version = "leetcode ${version}"; -}; + passthru.tests.version = testers.testVersion { + package = leetcode-cli; + command = "leetcode -V"; + version = "leetcode ${version}"; + }; +} ``` ::: @@ -116,7 +124,7 @@ runCommand "example" { grep -F 'failing though' $failed/testBuildFailure.log [[ 3 = $(cat $failed/testBuildFailure.exit) ]] touch $out -''; +'' ``` ::: @@ -193,12 +201,14 @@ once to get a derivation hash, and again to produce the final fixed output deriv # Prevent nix from reusing the output of a fetcher ```nix -tests.fetchgit = testers.invalidateFetcherByDrvHash fetchgit { - name = "nix-source"; - url = "https://github.com/NixOS/nix"; - rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a"; - hash = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY="; -}; +{ + tests.fetchgit = testers.invalidateFetcherByDrvHash fetchgit { + name = "nix-source"; + url = "https://github.com/NixOS/nix"; + rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a"; + hash = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY="; + }; +} ``` ::: diff --git a/doc/build-helpers/trivial-build-helpers.chapter.md b/doc/build-helpers/trivial-build-helpers.chapter.md index 6d14db639938..4f2754903f9b 100644 --- a/doc/build-helpers/trivial-build-helpers.chapter.md +++ b/doc/build-helpers/trivial-build-helpers.chapter.md @@ -76,12 +76,14 @@ If you need to refer to the resulting files somewhere else in a Nix expression, For example, if the file destination is a directory: ```nix -my-file = writeTextFile { - name = "my-file"; - text = '' - Contents of File - ''; - destination = "/share/my-file"; +{ + my-file = writeTextFile { + name = "my-file"; + text = '' + Contents of File + ''; + destination = "/share/my-file"; + }; } ``` @@ -90,7 +92,7 @@ Remember to append "/share/my-file" to the resulting store path when using it el ```nix writeShellScript "evaluate-my-file.sh" '' cat ${my-file}/share/my-file -''; +'' ``` :::: @@ -287,7 +289,7 @@ writeTextFile { }; allowSubstitutes = true; preferLocalBuild = false; -}; +} ``` ::: @@ -351,7 +353,7 @@ Write the string `Contents of File` to `/nix/store/`: writeText "my-file" '' Contents of File - ''; + '' ``` ::: @@ -391,7 +393,7 @@ Write the string `Contents of File` to `/nix/store//share/my-file`: writeTextDir "share/my-file" '' Contents of File - ''; + '' ``` ::: @@ -433,7 +435,7 @@ Write the string `Contents of File` to `/nix/store/` and make the fi writeScript "my-file" '' Contents of File - ''; + '' ``` ::: @@ -475,7 +477,7 @@ The store path will include the the name, and it will be a directory. writeScriptBin "my-script" '' echo "hi" - ''; + '' ``` ::: @@ -488,7 +490,7 @@ writeTextFile { echo "hi" ''; executable = true; - destination = "bin/my-script" + destination = "bin/my-script"; } ``` @@ -519,7 +521,7 @@ This function is almost exactly like [](#trivial-builder-writeScript), except th writeShellScript "my-script" '' echo "hi" - ''; + '' ``` ::: @@ -562,7 +564,7 @@ This function is a combination of [](#trivial-builder-writeShellScript) and [](# writeShellScriptBin "my-script" '' echo "hi" - ''; + '' ``` ::: @@ -576,7 +578,7 @@ writeTextFile { echo "hi" ''; executable = true; - destination = "bin/my-script" + destination = "bin/my-script"; } ``` @@ -674,7 +676,7 @@ writeClosure [ (writeScriptBin "hi" ''${hello}/bin/hello'') ] produces an output path `/nix/store/-runtime-deps` containing -```nix +``` /nix/store/-hello-2.10 /nix/store/-hi /nix/store/-libidn2-2.3.0 @@ -700,7 +702,7 @@ writeDirectReferencesToFile (writeScriptBin "hi" ''${hello}/bin/hello'') produces an output path `/nix/store/-runtime-references` containing -```nix +``` /nix/store/-hello-2.10 ``` diff --git a/doc/functions/nix-gitignore.section.md b/doc/functions/nix-gitignore.section.md index 8eb4081d2878..8532ab68ac04 100644 --- a/doc/functions/nix-gitignore.section.md +++ b/doc/functions/nix-gitignore.section.md @@ -7,27 +7,30 @@ `pkgs.nix-gitignore` exports a number of functions, but you'll most likely need either `gitignoreSource` or `gitignoreSourcePure`. As their first argument, they both accept either 1. a file with gitignore lines or 2. a string with gitignore lines, or 3. a list of either of the two. They will be concatenated into a single big string. ```nix -{ pkgs ? import {} }: +{ pkgs ? import {} }: { - nix-gitignore.gitignoreSource [] ./source + src = nix-gitignore.gitignoreSource [] ./source; # Simplest version - nix-gitignore.gitignoreSource "supplemental-ignores\n" ./source + src = nix-gitignore.gitignoreSource "supplemental-ignores\n" ./source; # This one reads the ./source/.gitignore and concats the auxiliary ignores - nix-gitignore.gitignoreSourcePure "ignore-this\nignore-that\n" ./source + src = nix-gitignore.gitignoreSourcePure "ignore-this\nignore-that\n" ./source; # Use this string as gitignore, don't read ./source/.gitignore. - nix-gitignore.gitignoreSourcePure ["ignore-this\nignore-that\n", ~/.gitignore] ./source + src = nix-gitignore.gitignoreSourcePure ["ignore-this\nignore-that\n" ~/.gitignore] ./source; # It also accepts a list (of strings and paths) that will be concatenated # once the paths are turned to strings via readFile. +} ``` These functions are derived from the `Filter` functions by setting the first filter argument to `(_: _: true)`: ```nix -gitignoreSourcePure = gitignoreFilterSourcePure (_: _: true); -gitignoreSource = gitignoreFilterSource (_: _: true); +{ + gitignoreSourcePure = gitignoreFilterSourcePure (_: _: true); + gitignoreSource = gitignoreFilterSource (_: _: true); +} ``` Those filter functions accept the same arguments the `builtins.filterSource` function would pass to its filters, thus `fn: gitignoreFilterSourcePure fn ""` should be extensionally equivalent to `filterSource`. The file is blacklisted if it's blacklisted by either your filter or the gitignoreFilter. @@ -35,7 +38,9 @@ Those filter functions accept the same arguments the `builtins.filterSource` fun If you want to make your own filter from scratch, you may use ```nix -gitignoreFilter = ign: root: filterPattern (gitignoreToPatterns ign) root; +{ + gitignoreFilter = ign: root: filterPattern (gitignoreToPatterns ign) root; +} ``` ## gitignore files in subdirectories {#sec-pkgs-nix-gitignore-usage-recursive} @@ -43,7 +48,9 @@ gitignoreFilter = ign: root: filterPattern (gitignoreToPatterns ign) root; If you wish to use a filter that would search for .gitignore files in subdirectories, just like git does by default, use this function: ```nix -gitignoreFilterRecursiveSource = filter: patterns: root: -# OR -gitignoreRecursiveSource = gitignoreFilterSourcePure (_: _: true); +{ + # gitignoreFilterRecursiveSource = filter: patterns: root: + # OR + gitignoreRecursiveSource = gitignoreFilterSourcePure (_: _: true); +} ``` diff --git a/doc/hooks/breakpoint.section.md b/doc/hooks/breakpoint.section.md index 424a9424b55e..b7f1979586de 100644 --- a/doc/hooks/breakpoint.section.md +++ b/doc/hooks/breakpoint.section.md @@ -3,7 +3,9 @@ This hook will make a build pause instead of stopping when a failure happens. It prevents nix from cleaning up the build environment immediately and allows the user to attach to a build environment using the `cntr` command. Upon build error it will print instructions on how to use `cntr`, which can be used to enter the environment for debugging. Installing cntr and running the command will provide shell access to the build sandbox of failed build. At `/var/lib/cntr` the sandboxed filesystem is mounted. All commands and files of the system are still accessible within the shell. To execute commands from the sandbox use the cntr exec subcommand. `cntr` is only supported on Linux-based platforms. To use it first add `cntr` to your `environment.systemPackages` on NixOS or alternatively to the root user on non-NixOS systems. Then in the package that is supposed to be inspected, add `breakpointHook` to `nativeBuildInputs`. ```nix -nativeBuildInputs = [ breakpointHook ]; +{ + nativeBuildInputs = [ breakpointHook ]; +} ``` When a build failure happens there will be an instruction printed that shows how to attach with `cntr` to the build sandbox. diff --git a/doc/hooks/installShellFiles.section.md b/doc/hooks/installShellFiles.section.md index 2567098116dd..834c6a37df15 100644 --- a/doc/hooks/installShellFiles.section.md +++ b/doc/hooks/installShellFiles.section.md @@ -7,19 +7,21 @@ The `installManPage` function takes one or more paths to manpages to install. Th The `installShellCompletion` function takes one or more paths to shell completion files. By default it will autodetect the shell type from the completion file extension, but you may also specify it by passing one of `--bash`, `--fish`, or `--zsh`. These flags apply to all paths listed after them (up until another shell flag is given). Each path may also have a custom installation name provided by providing a flag `--name NAME` before the path. If this flag is not provided, zsh completions will be renamed automatically such that `foobar.zsh` becomes `_foobar`. A root name may be provided for all paths using the flag `--cmd NAME`; this synthesizes the appropriate name depending on the shell (e.g. `--cmd foo` will synthesize the name `foo.bash` for bash and `_foo` for zsh). The path may also be a fifo or named fd (such as produced by `<(cmd)`), in which case the shell and name must be provided. ```nix -nativeBuildInputs = [ installShellFiles ]; -postInstall = '' - installManPage doc/foobar.1 doc/barfoo.3 - # explicit behavior - installShellCompletion --bash --name foobar.bash share/completions.bash - installShellCompletion --fish --name foobar.fish share/completions.fish - installShellCompletion --zsh --name _foobar share/completions.zsh - # implicit behavior - installShellCompletion share/completions/foobar.{bash,fish,zsh} - # using named fd - installShellCompletion --cmd foobar \ - --bash <($out/bin/foobar --bash-completion) \ - --fish <($out/bin/foobar --fish-completion) \ - --zsh <($out/bin/foobar --zsh-completion) -''; +{ + nativeBuildInputs = [ installShellFiles ]; + postInstall = '' + installManPage doc/foobar.1 doc/barfoo.3 + # explicit behavior + installShellCompletion --bash --name foobar.bash share/completions.bash + installShellCompletion --fish --name foobar.fish share/completions.fish + installShellCompletion --zsh --name _foobar share/completions.zsh + # implicit behavior + installShellCompletion share/completions/foobar.{bash,fish,zsh} + # using named fd + installShellCompletion --cmd foobar \ + --bash <($out/bin/foobar --bash-completion) \ + --fish <($out/bin/foobar --fish-completion) \ + --zsh <($out/bin/foobar --zsh-completion) + ''; +} ``` diff --git a/doc/hooks/mpi-check-hook.section.md b/doc/hooks/mpi-check-hook.section.md index 586ee2cc7c2d..c182c4cc6195 100644 --- a/doc/hooks/mpi-check-hook.section.md +++ b/doc/hooks/mpi-check-hook.section.md @@ -12,13 +12,14 @@ Example: ```nix { mpiCheckPhaseHook, mpi, ... }: + { + # ... - ... - - nativeCheckInputs = [ - openssh - mpiCheckPhaseHook - ]; + nativeCheckInputs = [ + openssh + mpiCheckPhaseHook + ]; + } ``` diff --git a/doc/languages-frameworks/agda.section.md b/doc/languages-frameworks/agda.section.md index cb1f12eec234..33fffc60c8db 100644 --- a/doc/languages-frameworks/agda.section.md +++ b/doc/languages-frameworks/agda.section.md @@ -114,7 +114,7 @@ This can be overridden by a different version of `ghc` as follows: ```nix agda.withPackages { - pkgs = [ ... ]; + pkgs = [ /* ... */ ]; ghc = haskell.compiler.ghcHEAD; } ``` @@ -180,6 +180,7 @@ To add an Agda package to `nixpkgs`, the derivation should be written to `pkgs/d ```nix { mkDerivation, standard-library, fetchFromGitHub }: +{} ``` Note that the derivation function is called with `mkDerivation` set to `agdaPackages.mkDerivation`, therefore you @@ -193,7 +194,7 @@ mkDerivation { version = "1.5.0"; pname = "iowa-stdlib"; - src = ... + src = <...>; libraryFile = ""; libraryName = "IAL-1.3"; diff --git a/doc/languages-frameworks/android.section.md b/doc/languages-frameworks/android.section.md index 6f9717ca09cc..1c5687f8ebf1 100644 --- a/doc/languages-frameworks/android.section.md +++ b/doc/languages-frameworks/android.section.md @@ -104,18 +104,20 @@ pull from: repo.json to the Nix store based on the given repository XMLs. ```nix -repoXmls = { - packages = [ ./xml/repository2-1.xml ]; - images = [ - ./xml/android-sys-img2-1.xml - ./xml/android-tv-sys-img2-1.xml - ./xml/android-wear-sys-img2-1.xml - ./xml/android-wear-cn-sys-img2-1.xml - ./xml/google_apis-sys-img2-1.xml - ./xml/google_apis_playstore-sys-img2-1.xml - ]; - addons = [ ./xml/addon2-1.xml ]; -}; +{ + repoXmls = { + packages = [ ./xml/repository2-1.xml ]; + images = [ + ./xml/android-sys-img2-1.xml + ./xml/android-tv-sys-img2-1.xml + ./xml/android-wear-sys-img2-1.xml + ./xml/android-wear-cn-sys-img2-1.xml + ./xml/google_apis-sys-img2-1.xml + ./xml/google_apis_playstore-sys-img2-1.xml + ]; + addons = [ ./xml/addon2-1.xml ]; + }; +} ``` When building the above expression with: diff --git a/doc/languages-frameworks/beam.section.md b/doc/languages-frameworks/beam.section.md index 992149090c63..3653cdb337d1 100644 --- a/doc/languages-frameworks/beam.section.md +++ b/doc/languages-frameworks/beam.section.md @@ -117,6 +117,7 @@ If there are git dependencies. - From the mix_deps.nix file, remove the dependencies that had git versions and pass them as an override to the import function. ```nix +{ mixNixDeps = import ./mix.nix { inherit beamPackages lib; overrides = (final: prev: { @@ -138,8 +139,9 @@ If there are git dependencies. # you can re-use the same beamDeps argument as generated beamDeps = with final; [ prometheus ]; }; - }); -}; + }); + }; +} ``` You will need to run the build process once to fix the hash to correspond to your new git src. @@ -153,11 +155,13 @@ Practical steps - start with the following argument to mixRelease ```nix +{ mixFodDeps = fetchMixDeps { pname = "mix-deps-${pname}"; inherit src version; hash = lib.fakeHash; }; +} ``` The first build will complain about the hash value, you can replace with the suggested value after that. diff --git a/doc/languages-frameworks/bower.section.md b/doc/languages-frameworks/bower.section.md index fceb6aaccb6d..20c142dad5b9 100644 --- a/doc/languages-frameworks/bower.section.md +++ b/doc/languages-frameworks/bower.section.md @@ -28,7 +28,7 @@ buildEnv { name = "bower-env"; ignoreCollisions = true; paths = [ (fetchbower "angular" "1.5.3" "~1.5.0" "1749xb0firxdra4rzadm4q9x90v6pzkbd7xmcyjk6qfza09ykk9y") (fetchbower "bootstrap" "3.3.6" "~3.3.6" "1vvqlpbfcy0k5pncfjaiskj3y6scwifxygfqnw393sjfxiviwmbv") (fetchbower "jquery" "2.2.2" "1.9.1 - 2" "10sp5h98sqwk90y4k6hbdviwqzvzwqf47r3r51pakch5ii2y7js1") -]; +]; } ``` Using the `bower2nix` command line arguments, the output can be redirected to a file. A name like `bower-packages.nix` would be fine. @@ -42,11 +42,13 @@ The function is implemented in [pkgs/development/bower-modules/generic/default.n ### Example buildBowerComponents {#ex-buildBowerComponents} ```nix -bowerComponents = buildBowerComponents { - name = "my-web-app"; - generated = ./bower-packages.nix; # note 1 - src = myWebApp; # note 2 -}; +{ + bowerComponents = buildBowerComponents { + name = "my-web-app"; + generated = ./bower-packages.nix; # note 1 + src = myWebApp; # note 2 + }; +} ``` In ["buildBowerComponents" example](#ex-buildBowerComponents) the following arguments are of special significance to the function: diff --git a/doc/languages-frameworks/chicken.section.md b/doc/languages-frameworks/chicken.section.md index 72c2642a6478..16b00b3f5b5d 100644 --- a/doc/languages-frameworks/chicken.section.md +++ b/doc/languages-frameworks/chicken.section.md @@ -13,10 +13,12 @@ done in the typical Nix fashion. For example, to include support for [SRFI might write: ```nix +{ buildInputs = [ chicken chickenPackages.chickenEggs.srfi-189 ]; +} ``` Both `chicken` and its eggs have a setup hook which configures the environment @@ -67,12 +69,12 @@ let chickenEggs = super.chickenEggs.overrideScope' (eggself: eggsuper: { srfi-180 = eggsuper.srfi-180.overrideAttrs { # path to a local copy of srfi-180 - src = ... + src = <...>; }; }); }); in # Here, `myChickenPackages.chickenEggs.json-rpc`, which depends on `srfi-180` will use # the local copy of `srfi-180`. -# ... +<...> ``` diff --git a/doc/languages-frameworks/coq.section.md b/doc/languages-frameworks/coq.section.md index db3724773345..fdc824781cd1 100644 --- a/doc/languages-frameworks/coq.section.md +++ b/doc/languages-frameworks/coq.section.md @@ -56,22 +56,17 @@ Here is a simple package example. It is a pure Coq library, thus it depends on C { lib, mkCoqDerivation, version ? null , coq, mathcomp, mathcomp-finmap, mathcomp-bigenough }: -let - inherit (lib) licenses maintainers switch; - inherit (lib.versions) range; -in - mkCoqDerivation { /* namePrefix leads to e.g. `name = coq8.11-mathcomp1.11-multinomials-1.5.2` */ namePrefix = [ "coq" "mathcomp" ]; pname = "multinomials"; owner = "math-comp"; inherit version; - defaultVersion = with versions; switch [ coq.version mathcomp.version ] [ - { cases = [ (range "8.7" "8.12") "1.11.0" ]; out = "1.5.2"; } - { cases = [ (range "8.7" "8.11") (range "1.8" "1.10") ]; out = "1.5.0"; } - { cases = [ (range "8.7" "8.10") (range "1.8" "1.10") ]; out = "1.4"; } - { cases = [ "8.6" (range "1.6" "1.7") ]; out = "1.1"; } + defaultVersion = with lib.versions; lib.switch [ coq.version mathcomp.version ] [ + { cases = [ (range "8.7" "8.12") (isEq "1.11") ]; out = "1.5.2"; } + { cases = [ (range "8.7" "8.11") (range "1.8" "1.10") ]; out = "1.5.0"; } + { cases = [ (range "8.7" "8.10") (range "1.8" "1.10") ]; out = "1.4"; } + { cases = [ (isEq "8.6") (range "1.6" "1.7") ]; out = "1.1"; } ] null; release = { "1.5.2".sha256 = "15aspf3jfykp1xgsxf8knqkxv8aav2p39c2fyirw7pwsfbsv2c4s"; @@ -90,7 +85,7 @@ mkCoqDerivation { meta = { description = "A Coq/SSReflect Library for Monoidal Rings and Multinomials"; - license = licenses.cecill-c; + license = lib.licenses.cecill-c; }; } ``` diff --git a/doc/languages-frameworks/crystal.section.md b/doc/languages-frameworks/crystal.section.md index b97e75a58da1..9953f357048a 100644 --- a/doc/languages-frameworks/crystal.section.md +++ b/doc/languages-frameworks/crystal.section.md @@ -33,22 +33,26 @@ crystal.buildCrystalPackage rec { # Insert the path to your shards.nix file here shardsFile = ./shards.nix; - ... + # ... } ``` This won't build anything yet, because we haven't told it what files build. We can specify a mapping from binary names to source files with the `crystalBinaries` attribute. The project's compilation instructions should show this. For Mint, the binary is called "mint", which is compiled from the source file `src/mint.cr`, so we'll specify this as follows: ```nix +{ crystalBinaries.mint.src = "src/mint.cr"; # ... +} ``` Additionally you can override the default `crystal build` options (which are currently `--release --progress --no-debug --verbose`) with ```nix +{ crystalBinaries.mint.options = [ "--release" "--verbose" ]; +} ``` Depending on the project, you might need additional steps to get it to compile successfully. In Mint's case, we need to link against openssl, so in the end the Nix file looks as follows: diff --git a/doc/languages-frameworks/cuda.section.md b/doc/languages-frameworks/cuda.section.md index 09af824531a2..1b2005bb1edd 100644 --- a/doc/languages-frameworks/cuda.section.md +++ b/doc/languages-frameworks/cuda.section.md @@ -16,24 +16,28 @@ To use one or more CUDA packages in an expression, give the expression a `cudaPa , cudaSupport ? config.cudaSupport , cudaPackages ? { } , ... -}: +}: {} ``` When using `callPackage`, you can choose to pass in a different variant, e.g. when a different version of the toolkit suffices ```nix -mypkg = callPackage { cudaPackages = cudaPackages_11_5; } +{ + mypkg = callPackage { cudaPackages = cudaPackages_11_5; }; +} ``` If another version of say `cudnn` or `cutensor` is needed, you can override the package set to make it the default. This guarantees you get a consistent package set. ```nix -mypkg = let - cudaPackages = cudaPackages_11_5.overrideScope (final: prev: { - cudnn = prev.cudnn_8_3; - }}); -in callPackage { inherit cudaPackages; }; +{ + mypkg = let + cudaPackages = cudaPackages_11_5.overrideScope (final: prev: { + cudnn = prev.cudnn_8_3; + }); + in callPackage { inherit cudaPackages; }; +} ``` The CUDA NVCC compiler requires flags to determine which hardware you @@ -144,4 +148,4 @@ All new projects should use the CUDA redistributables available in [`cudaPackage | Find libraries | `configurePhase` | Missing dependency on a `dev` output | Add the missing dependency | The `dev` output typically contain CMake configuration files | | Find libraries | `buildPhase` or `patchelf` | Missing dependency on a `lib` or `static` output | Add the missing dependency | The `lib` or `static` output typically contain the libraries | -In the scenario you are unable to run the resulting binary: this is arguably the most complicated as it could be any combination of the previous reasons. This type of failure typically occurs when a library attempts to load or open a library it depends on that it does not declare in its `DT_NEEDED` section. As a first step, ensure that dependencies are patched with [`cudaPackages.autoAddDriverRunpath`](https://search.nixos.org/packages?channel=unstable&type=packages&query=cudaPackages.autoAddDriverRunpath). Failing that, try running the application with [`nixGL`](https://github.com/guibou/nixGL) or a similar wrapper tool. If that works, it likely means that the application is attempting to load a library that is not in the `RPATH` or `RUNPATH` of the binary. +In the scenario you are unable to run the resulting binary: this is arguably the most complicated as it could be any combination of the previous reasons. This type of failure typically occurs when a library attempts to load or open a library it depends on that it does not declare in its `DT_NEEDED` section. As a first step, ensure that dependencies are patched with [`autoAddDriverRunpath`](https://search.nixos.org/packages?channel=unstable&type=packages&query=autoAddDriverRunpath). Failing that, try running the application with [`nixGL`](https://github.com/guibou/nixGL) or a similar wrapper tool. If that works, it likely means that the application is attempting to load a library that is not in the `RPATH` or `RUNPATH` of the binary. diff --git a/doc/languages-frameworks/cuelang.section.md b/doc/languages-frameworks/cuelang.section.md index 86304208aa20..70329b15fd7d 100644 --- a/doc/languages-frameworks/cuelang.section.md +++ b/doc/languages-frameworks/cuelang.section.md @@ -26,7 +26,7 @@ Cuelang schemas are similar to JSON, here is a quick cheatsheet: Nixpkgs provides a `pkgs.writeCueValidator` helper, which will write a validation script based on the provided Cuelang schema. Here is an example: -``` +```nix pkgs.writeCueValidator (pkgs.writeText "schema.cue" '' #Def1: { @@ -42,7 +42,7 @@ pkgs.writeCueValidator `document` : match your input data against this fragment of structure or definition, e.g. you may use the same schema file but different documents based on the data you are validating. Another example, given the following `validator.nix` : -``` +```nix { pkgs ? import {} }: let genericValidator = version: diff --git a/doc/languages-frameworks/dhall.section.md b/doc/languages-frameworks/dhall.section.md index 83567ab17ace..8d85c9f1daf7 100644 --- a/doc/languages-frameworks/dhall.section.md +++ b/doc/languages-frameworks/dhall.section.md @@ -187,6 +187,7 @@ wish to specify `source = true` for all Dhall packages, then you can amend the Dhall overlay like this: ```nix +{ dhallOverrides = self: super: { # Enable source for all Dhall packages buildDhallPackage = @@ -194,6 +195,7 @@ Dhall overlay like this: true = self.callPackage ./true.nix { }; }; +} ``` … and now the Prelude will contain the fully decoded result of interpreting @@ -429,22 +431,26 @@ $ dhall-to-nixpkgs github https://github.com/dhall-lang/dhall-lang.git \ the Prelude globally for all packages, like this: ```nix +{ dhallOverrides = self: super: { true = self.callPackage ./true.nix { }; Prelude = self.callPackage ./Prelude.nix { }; }; +} ``` … or selectively overriding the Prelude dependency for just the `true` package, like this: ```nix +{ dhallOverrides = self: super: { true = self.callPackage ./true.nix { Prelude = self.callPackage ./Prelude.nix { }; }; }; +} ``` ## Overrides {#ssec-dhall-overrides} @@ -454,11 +460,13 @@ You can override any of the arguments to `buildDhallGitHubPackage` or For example, suppose we wanted to selectively enable `source = true` just for the Prelude. We can do that like this: ```nix +{ dhallOverrides = self: super: { Prelude = super.Prelude.overridePackage { source = true; }; - … + # ... }; +} ``` [semantic-integrity-checks]: https://docs.dhall-lang.org/tutorials/Language-Tour.html#installing-packages diff --git a/doc/languages-frameworks/dlang.section.md b/doc/languages-frameworks/dlang.section.md new file mode 100644 index 000000000000..6e9edefc5e0f --- /dev/null +++ b/doc/languages-frameworks/dlang.section.md @@ -0,0 +1,69 @@ +# D (Dlang) {#dlang} + +Nixpkgs provides multiple D compilers such as `ldc`, `dmd` and `gdc`. +These can be used like any other package during build time. + +However, Nixpkgs provides a build helper for compiling packages using the `dub` package manager. + +Here's an example: +```nix +{ + lib, + buildDubPackage, + fetchFromGitHub, + ncurses, + zlib, +}: + +buildDubPackage rec { + pname = "btdu"; + version = "0.5.1"; + + src = fetchFromGitHub { + owner = "CyberShadow"; + repo = "btdu"; + rev = "v${version}"; + hash = "sha256-3sSZq+5UJH02IO0Y1yL3BLHDb4lk8k6awb5ZysBQciE="; + }; + + # generated by dub-to-nix, see below + dubLock = ./dub-lock.json; + + buildInputs = [ + ncurses + zlib + ]; + + installPhase = '' + runHook preInstall + install -Dm755 btdu -t $out/bin + runHook postInstall + ''; +} +``` + +Note that you need to define `installPhase` because `dub` doesn't know where files should go in `$out`. + +Also note that running `dub test` is disabled by default. You can enable it by setting `doCheck = true`. + +## Lockfiles {#dub-lockfiles} +Nixpkgs has its own lockfile format for `dub` dependencies, because `dub`'s official "lockfile" format (`dub.selections.json`) is not hash based. + +A lockfile can be generated using the `dub-to-nix` helper package. +* Firstly, install `dub-to-nix` into your shell session by running `nix-shell -p dub-to-nix` +* Then navigate to the root of the source of the program you want to package +* Finally, run `dub-to-nix` and it will print the lockfile to stdout. You could pipe stdout into a text file or just copy the output manually into a file. + +## `buildDubPackage` parameters {#builddubpackage-parameters} + +The `buildDubPackage` function takes an attrset of parameters that are passed on to `stdenv.mkDerivation`. + +The following parameters are specific to `buildDubPackage`: + +* `dubLock`: A lockfile generated by `dub-to-nix` from the source of the package. Can be either a path to the file, or an attrset already parsed with `lib.importJSON`. + The latter useful if the package uses `dub` dependencies not already in the lockfile. (e.g. if the package calls `dub run some-dub-package` manually) +* `dubBuildType ? "release"`: The build type to pass to `dub build` as a value for the `--build=` flag. +* `dubFlags ? []`: The flags to pass to `dub build` and `dub test`. +* `dubBuildFlags ? []`: The flags to pass to `dub build`. +* `dubTestFlags ? []`: The flags to pass to `dub test`. +* `compiler ? ldc`: The D compiler to be used by `dub`. diff --git a/doc/languages-frameworks/dotnet.section.md b/doc/languages-frameworks/dotnet.section.md index 7466c8cdc228..a4e9d6cf9a6c 100644 --- a/doc/languages-frameworks/dotnet.section.md +++ b/doc/languages-frameworks/dotnet.section.md @@ -134,7 +134,7 @@ Here is an example `default.nix`, using some of the previously discussed argumen { lib, buildDotnetModule, dotnetCorePackages, ffmpeg }: let - referencedProject = import ../../bar { ... }; + referencedProject = import ../../bar { /* ... */ }; in buildDotnetModule rec { pname = "someDotnetApplication"; version = "0.1"; @@ -236,7 +236,7 @@ the packages inside the `out` directory. $ nuget-to-nix out > deps.nix ``` Which `nuget-to-nix` will generate an output similar to below -``` +```nix { fetchNuGet }: [ (fetchNuGet { pname = "FosterFramework"; version = "0.1.15-alpha"; sha256 = "0pzsdfbsfx28xfqljcwy100xhbs6wyx0z1d5qxgmv3l60di9xkll"; }) (fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.linux-x64"; version = "8.0.1"; sha256 = "1gjz379y61ag9whi78qxx09bwkwcznkx2mzypgycibxk61g11da1"; }) diff --git a/doc/languages-frameworks/gnome.section.md b/doc/languages-frameworks/gnome.section.md index 5208f1013cbd..e158cea0e512 100644 --- a/doc/languages-frameworks/gnome.section.md +++ b/doc/languages-frameworks/gnome.section.md @@ -47,6 +47,7 @@ When an application uses icons, an icon theme should be available in `XDG_DATA_D In the rare case you need to use icons from dependencies (e.g. when an app forces an icon theme), you can use the following to pick them up: ```nix +{ buildInputs = [ pantheon.elementary-icon-theme ]; @@ -56,6 +57,7 @@ In the rare case you need to use icons from dependencies (e.g. when an app force --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS" ) ''; +} ``` To avoid costly file system access when locating icons, GTK, [as well as Qt](https://woboq.com/blog/qicon-reads-gtk-icon-cache-in-qt57.html), can rely on `icon-theme.cache` files from the themes' top-level directories. These files are generated using `gtk-update-icon-cache`, which is expected to be run whenever an icon is added or removed to an icon theme (typically an application icon into `hicolor` theme) and some programs do indeed run this after icon installation. However, since packages are installed into their own prefix by Nix, this would lead to conflicts. For that reason, `gtk3` provides a [setup hook](#ssec-gnome-hooks-gtk-drop-icon-theme-cache) that will clean the file from installation. Since most applications only ship their own icon that will be loaded on start-up, it should not affect them too much. On the other hand, icon themes are much larger and more widely used so we need to cache them. Because we recommend installing icon themes globally, we will generate the cache files from all packages in a profile using a NixOS module. You can enable the cache generation using `gtk.iconCache.enable` option if your desktop environment does not already do that. @@ -85,22 +87,26 @@ If your application uses [GStreamer](https://gstreamer.freedesktop.org/) or [Gri Given the requirements above, the package expression would become messy quickly: ```nix -preFixup = '' - for f in $(find $out/bin/ $out/libexec/ -type f -executable); do - wrapProgram "$f" \ - --prefix GIO_EXTRA_MODULES : "${getLib dconf}/lib/gio/modules" \ - --prefix XDG_DATA_DIRS : "$out/share" \ - --prefix XDG_DATA_DIRS : "$out/share/gsettings-schemas/${name}" \ - --prefix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}" \ - --prefix XDG_DATA_DIRS : "${hicolor-icon-theme}/share" \ - --prefix GI_TYPELIB_PATH : "${lib.makeSearchPath "lib/girepository-1.0" [ pango json-glib ]}" - done -''; +{ + preFixup = '' + for f in $(find $out/bin/ $out/libexec/ -type f -executable); do + wrapProgram "$f" \ + --prefix GIO_EXTRA_MODULES : "${getLib dconf}/lib/gio/modules" \ + --prefix XDG_DATA_DIRS : "$out/share" \ + --prefix XDG_DATA_DIRS : "$out/share/gsettings-schemas/${name}" \ + --prefix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}" \ + --prefix XDG_DATA_DIRS : "${hicolor-icon-theme}/share" \ + --prefix GI_TYPELIB_PATH : "${lib.makeSearchPath "lib/girepository-1.0" [ pango json-glib ]}" + done + ''; +} ``` -Fortunately, there is [`wrapGAppsHook`]{#ssec-gnome-hooks-wrapgappshook}. It works in conjunction with other setup hooks that populate environment variables, and it will then wrap all executables in `bin` and `libexec` directories using said variables. +Fortunately, there is [`wrapGAppsHook`]{#ssec-gnome-hooks-wrapgappshook}. It works in conjunction with other setup hooks that populate environment variables, and it will then wrap all executables in `bin` and `libexec` directories using said variables. For convenience, it also adds `dconf.lib` for a GIO module implementing a GSettings backend using `dconf`, `gtk3` for GSettings schemas, and `librsvg` for GdkPixbuf loader to the closure. -For convenience, it also adds `dconf.lib` for a GIO module implementing a GSettings backend using `dconf`, `gtk3` for GSettings schemas, and `librsvg` for GdkPixbuf loader to the closure. There is also [`wrapGAppsHook4`]{#ssec-gnome-hooks-wrapgappshook4}, which replaces GTK 3 with GTK 4. And in case you are packaging a program without a graphical interface, you might want to use [`wrapGAppsNoGuiHook`]{#ssec-gnome-hooks-wrapgappsnoguihook}, which runs the same script as `wrapGAppsHook` but does not bring `gtk3` and `librsvg` into the closure. +There is also [`wrapGAppsHook4`]{#ssec-gnome-hooks-wrapgappshook4}, which replaces GTK 3 with GTK 4. Instead of `wrapGAppsHook`, this should be used for all GTK4 applications. + +In case you are packaging a program without a graphical interface, you might want to use [`wrapGAppsNoGuiHook`]{#ssec-gnome-hooks-wrapgappsnoguihook}, which runs the same script as `wrapGAppsHook` but does not bring `gtk3` and `librsvg` into the closure. - `wrapGAppsHook` itself will add the package’s `share` directory to `XDG_DATA_DIRS`. @@ -121,14 +127,16 @@ For convenience, it also adds `dconf.lib` for a GIO module implementing a GSetti You can also pass additional arguments to `makeWrapper` using `gappsWrapperArgs` in `preFixup` hook: ```nix -preFixup = '' - gappsWrapperArgs+=( - # Thumbnailers - --prefix XDG_DATA_DIRS : "${gdk-pixbuf}/share" - --prefix XDG_DATA_DIRS : "${librsvg}/share" - --prefix XDG_DATA_DIRS : "${shared-mime-info}/share" - ) -''; +{ + preFixup = '' + gappsWrapperArgs+=( + # Thumbnailers + --prefix XDG_DATA_DIRS : "${gdk-pixbuf}/share" + --prefix XDG_DATA_DIRS : "${librsvg}/share" + --prefix XDG_DATA_DIRS : "${shared-mime-info}/share" + ) + ''; +} ``` ## Updating GNOME packages {#ssec-gnome-updating} @@ -159,7 +167,7 @@ python3.pkgs.buildPythonApplication { nativeBuildInputs = [ wrapGAppsHook gobject-introspection - ... + # ... ]; dontWrapGApps = true; @@ -181,7 +189,7 @@ mkDerivation { nativeBuildInputs = [ wrapGAppsHook qmake - ... + # ... ]; dontWrapGApps = true; diff --git a/doc/languages-frameworks/go.section.md b/doc/languages-frameworks/go.section.md index 369eb88d331f..2f4cb0326a8a 100644 --- a/doc/languages-frameworks/go.section.md +++ b/doc/languages-frameworks/go.section.md @@ -38,24 +38,26 @@ The `buildGoModule` function accepts the following parameters in addition to the The following is an example expression using `buildGoModule`: ```nix -pet = buildGoModule rec { - pname = "pet"; - version = "0.3.4"; +{ + pet = buildGoModule rec { + pname = "pet"; + version = "0.3.4"; - src = fetchFromGitHub { - owner = "knqyf263"; - repo = "pet"; - rev = "v${version}"; - hash = "sha256-Gjw1dRrgM8D3G7v6WIM2+50r4HmTXvx0Xxme2fH9TlQ="; - }; + src = fetchFromGitHub { + owner = "knqyf263"; + repo = "pet"; + rev = "v${version}"; + hash = "sha256-Gjw1dRrgM8D3G7v6WIM2+50r4HmTXvx0Xxme2fH9TlQ="; + }; - vendorHash = "sha256-ciBIR+a1oaYH+H1PcC8cD8ncfJczk1IiJ8iYNM+R6aA="; + vendorHash = "sha256-ciBIR+a1oaYH+H1PcC8cD8ncfJczk1IiJ8iYNM+R6aA="; - meta = { - description = "Simple command-line snippet manager, written in Go"; - homepage = "https://github.com/knqyf263/pet"; - license = lib.licenses.mit; - maintainers = with lib.maintainers; [ kalbasit ]; + meta = { + description = "Simple command-line snippet manager, written in Go"; + homepage = "https://github.com/knqyf263/pet"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ kalbasit ]; + }; }; } ``` @@ -72,20 +74,22 @@ In the following is an example expression using `buildGoPackage`, the following - `goDeps` is where the Go dependencies of a Go program are listed as a list of package source identified by Go import path. It could be imported as a separate `deps.nix` file for readability. The dependency data structure is described below. ```nix -deis = buildGoPackage rec { - pname = "deis"; - version = "1.13.0"; +{ + deis = buildGoPackage rec { + pname = "deis"; + version = "1.13.0"; - goPackagePath = "github.com/deis/deis"; + goPackagePath = "github.com/deis/deis"; - src = fetchFromGitHub { - owner = "deis"; - repo = "deis"; - rev = "v${version}"; - hash = "sha256-XCPD4LNWtAd8uz7zyCLRfT8rzxycIUmTACjU03GnaeM="; + src = fetchFromGitHub { + owner = "deis"; + repo = "deis"; + rev = "v${version}"; + hash = "sha256-XCPD4LNWtAd8uz7zyCLRfT8rzxycIUmTACjU03GnaeM="; + }; + + goDeps = ./deps.nix; }; - - goDeps = ./deps.nix; } ``` @@ -138,6 +142,7 @@ Many attributes [controlling the build phase](#variables-controlling-the-build-p - [`patchFlags`](#var-stdenv-patchFlags) - [`postPatch`](#var-stdenv-postPatch) - [`preBuild`](#var-stdenv-preBuild) +- `env`: useful for passing down variables such as `GOWORK`. To control test execution of the build derivation, the following attributes are of interest: @@ -153,10 +158,12 @@ A string list of flags to pass to the Go linker tool via the `-ldflags` argument The most common use case for this argument is to make the resulting executable aware of its own version by injecting the value of string variable using the `-X` flag. For example: ```nix +{ ldflags = [ "-X main.Version=${version}" "-X main.Commit=${version}" ]; +} ``` ### `tags` {#var-go-tags} @@ -164,16 +171,20 @@ The most common use case for this argument is to make the resulting executable a A string list of [Go build tags (also called build constraints)](https://pkg.go.dev/cmd/go#hdr-Build_constraints) that are passed via the `-tags` argument of `go build`. These constraints control whether Go files from the source should be included in the build. For example: ```nix +{ tags = [ "production" "sqlite" ]; +} ``` Tags can also be set conditionally: ```nix +{ tags = [ "production" ] ++ lib.optionals withSqlite [ "sqlite" ]; +} ``` ### `deleteVendor` {#var-go-deleteVendor} @@ -188,10 +199,12 @@ Many Go projects keep the main package in a `cmd` directory. Following example could be used to only build the example-cli and example-server binaries: ```nix -subPackages = [ - "cmd/example-cli" - "cmd/example-server" -]; +{ + subPackages = [ + "cmd/example-cli" + "cmd/example-server" + ]; +} ``` ### `excludedPackages` {#var-go-excludedPackages} @@ -213,10 +226,12 @@ on a per package level using build tags (`tags`). In case CGO is disabled, these When a Go program depends on C libraries, place those dependencies in `buildInputs`: ```nix +{ buildInputs = [ libvirt libxml2 ]; +} ``` `CGO_ENABLED` defaults to `1`. @@ -245,15 +260,18 @@ This is done with the [`-skip` or `-run`](https://pkg.go.dev/cmd/go#hdr-Testing_ For example, only a selection of tests could be run with: ```nix +{ # -run and -skip accept regular expressions checkFlags = [ "-run=^Test(Simple|Fast)$" ]; +} ``` If a larger amount of tests should be skipped, the following pattern can be used: ```nix +{ checkFlags = let # Skip tests that require network access @@ -264,6 +282,7 @@ If a larger amount of tests should be skipped, the following pattern can be used ]; in [ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ]; +} ``` To disable tests altogether, set `doCheck = false;`. diff --git a/doc/languages-frameworks/idris.section.md b/doc/languages-frameworks/idris.section.md index e30a849dd456..0fa828825749 100644 --- a/doc/languages-frameworks/idris.section.md +++ b/doc/languages-frameworks/idris.section.md @@ -134,9 +134,9 @@ For example you could set ```nix build-idris-package { - idrisBuildOptions = [ "--log" "1" "--verbose" ] + idrisBuildOptions = [ "--log" "1" "--verbose" ]; - ... + # ... } ``` diff --git a/doc/languages-frameworks/index.md b/doc/languages-frameworks/index.md index 67107fb5b687..920e5e7bd431 100644 --- a/doc/languages-frameworks/index.md +++ b/doc/languages-frameworks/index.md @@ -14,6 +14,7 @@ cuda.section.md cuelang.section.md dart.section.md dhall.section.md +dlang.section.md dotnet.section.md emscripten.section.md gnome.section.md diff --git a/doc/languages-frameworks/java.section.md b/doc/languages-frameworks/java.section.md index 0ce1442cca68..6d56ffcd4503 100644 --- a/doc/languages-frameworks/java.section.md +++ b/doc/languages-frameworks/java.section.md @@ -7,7 +7,7 @@ stdenv.mkDerivation { pname = "..."; version = "..."; - src = fetchurl { ... }; + src = fetchurl { /* ... */ }; nativeBuildInputs = [ ant @@ -48,8 +48,10 @@ installs a JAR named `foo.jar` in its `share/java` directory, and another package declares the attribute ```nix -buildInputs = [ libfoo ]; -nativeBuildInputs = [ jdk ]; +{ + buildInputs = [ libfoo ]; + nativeBuildInputs = [ jdk ]; +} ``` then `CLASSPATH` will be set to @@ -62,13 +64,15 @@ If your Java package provides a program, you need to generate a wrapper script to run it using a JRE. You can use `makeWrapper` for this: ```nix -nativeBuildInputs = [ makeWrapper ]; +{ + nativeBuildInputs = [ makeWrapper ]; -installPhase = '' - mkdir -p $out/bin - makeWrapper ${jre}/bin/java $out/bin/foo \ - --add-flags "-cp $out/share/java/foo.jar org.foo.Main" -''; + installPhase = '' + mkdir -p $out/bin + makeWrapper ${jre}/bin/java $out/bin/foo \ + --add-flags "-cp $out/share/java/foo.jar org.foo.Main" + ''; +} ``` Since the introduction of the Java Platform Module System in Java 9, @@ -92,16 +96,18 @@ let something = (pkgs.something.override { jre = my_jre; }); other = (pkgs.other.override { jre = my_jre; }); in - ... + <...> ``` You can also specify what JDK your JRE should be based on, for example selecting a 'headless' build to avoid including a link to GTK+: ```nix -my_jre = pkgs.jre_minimal.override { - jdk = jdk11_headless; -}; +{ + my_jre = pkgs.jre_minimal.override { + jdk = jdk11_headless; + }; +} ``` Note all JDKs passthru `home`, so if your application requires @@ -116,7 +122,9 @@ It is possible to use a different Java compiler than `javac` from the OpenJDK. For instance, to use the GNU Java Compiler: ```nix -nativeBuildInputs = [ gcj ant ]; +{ + nativeBuildInputs = [ gcj ant ]; +} ``` Here, Ant will automatically use `gij` (the GNU Java Runtime) instead of diff --git a/doc/languages-frameworks/javascript.section.md b/doc/languages-frameworks/javascript.section.md index d553444d53b0..f706f92c6691 100644 --- a/doc/languages-frameworks/javascript.section.md +++ b/doc/languages-frameworks/javascript.section.md @@ -46,7 +46,7 @@ If a particular lock file is present, it is a strong indication of which package It's better to try to use a Nix tool that understand the lock file. Using a different tool might give you hard to understand error because different packages have been installed. An example of problems that could arise can be found [here](https://github.com/NixOS/nixpkgs/pull/126629). -Upstream use NPM, but this is an attempt to package it with `yarn2nix` (that uses yarn.lock). +Upstream use npm, but this is an attempt to package it with `yarn2nix` (that uses yarn.lock). Using a different tool forces to commit a lock file to the repository. Those files are fairly large, so when packaging for nixpkgs, this approach does not scale well. @@ -54,8 +54,8 @@ Those files are fairly large, so when packaging for nixpkgs, this approach does Exceptions to this rule are: - When you encounter one of the bugs from a Nix tool. In each of the tool specific instructions, known problems will be detailed. If you have a problem with a particular tool, then it's best to try another tool, even if this means you will have to recreate a lock file and commit it to nixpkgs. In general `yarn2nix` has less known problems and so a simple search in nixpkgs will reveal many yarn.lock files committed. -- Some lock files contain particular version of a package that has been pulled off NPM for some reason. In that case, you can recreate upstream lock (by removing the original and `npm install`, `yarn`, ...) and commit this to nixpkgs. -- The only tool that supports workspaces (a feature of NPM that helps manage sub-directories with different package.json from a single top level package.json) is `yarn2nix`. If upstream has workspaces you should try `yarn2nix`. +- Some lock files contain particular version of a package that has been pulled off npm for some reason. In that case, you can recreate upstream lock (by removing the original and `npm install`, `yarn`, ...) and commit this to nixpkgs. +- The only tool that supports workspaces (a feature of npm that helps manage sub-directories with different package.json from a single top level package.json) is `yarn2nix`. If upstream has workspaces you should try `yarn2nix`. ### Try to use upstream package.json {#javascript-upstream-package-json} @@ -76,11 +76,13 @@ Exceptions to this rule are: when you need to override a package.json. It's nice to use the one from the upstream source and do some explicit override. Here is an example: ```nix - patchedPackageJSON = final.runCommand "package.json" { } '' - ${jq}/bin/jq '.version = "0.4.0" | - .devDependencies."@jsdoc/cli" = "^0.2.5" - ${sonar-src}/package.json > $out - ''; + { + patchedPackageJSON = final.runCommand "package.json" { } '' + ${jq}/bin/jq '.version = "0.4.0" | + .devDependencies."@jsdoc/cli" = "^0.2.5" + ${sonar-src}/package.json > $out + ''; + } ``` You will still need to commit the modified version of the lock files, but at least the overrides are explicit for everyone to see. @@ -95,12 +97,12 @@ Then when building the frontend you can just symlink the node_modules directory. ## Javascript packages inside nixpkgs {#javascript-packages-nixpkgs} -The [pkgs/development/node-packages](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages) folder contains a generated collection of [NPM packages](https://npmjs.com/) that can be installed with the Nix package manager. +The [pkgs/development/node-packages](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages) folder contains a generated collection of [npm packages](https://npmjs.com/) that can be installed with the Nix package manager. As a rule of thumb, the package set should only provide _end user_ software packages, such as command-line utilities. -Libraries should only be added to the package set if there is a non-NPM package that requires it. +Libraries should only be added to the package set if there is a non-npm package that requires it. -When it is desired to use NPM libraries in a development project, use the `node2nix` generator directly on the `package.json` configuration file of the project. +When it is desired to use npm libraries in a development project, use the `node2nix` generator directly on the `package.json` configuration file of the project. The package set provides support for the official stable Node.js versions. The latest stable LTS release in `nodePackages`, as well as the latest stable current release in `nodePackages_latest`. @@ -115,15 +117,17 @@ After you have identified the correct system, you need to override your package For example, `dat` requires `node-gyp-build`, so we override its expression in [pkgs/development/node-packages/overrides.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages/overrides.nix): ```nix + { dat = prev.dat.override (oldAttrs: { buildInputs = [ final.node-gyp-build pkgs.libtool pkgs.autoconf pkgs.automake ]; meta = oldAttrs.meta // { broken = since "12"; }; }); + } ``` ### Adding and Updating Javascript packages in nixpkgs {#javascript-adding-or-updating-packages} -To add a package from NPM to nixpkgs: +To add a package from npm to nixpkgs: 1. Modify [pkgs/development/node-packages/node-packages.json](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages/node-packages.json) to add, update or remove package entries to have it included in `nodePackages` and `nodePackages_latest`. 2. Run the script: @@ -150,7 +154,7 @@ To add a package from NPM to nixpkgs: For more information about the generation process, consult the [README.md](https://github.com/svanderburg/node2nix) file of the `node2nix` tool. -To update NPM packages in nixpkgs, run the same `generate.sh` script: +To update npm packages in nixpkgs, run the same `generate.sh` script: ```sh ./pkgs/development/node-packages/generate.sh @@ -303,8 +307,8 @@ See `node2nix` [docs](https://github.com/svanderburg/node2nix) for more info. #### Pitfalls {#javascript-node2nix-pitfalls} - If upstream package.json does not have a "version" attribute, `node2nix` will crash. You will need to add it like shown in [the package.json section](#javascript-upstream-package-json). -- `node2nix` has some [bugs](https://github.com/svanderburg/node2nix/issues/238) related to working with lock files from NPM distributed with `nodejs_16`. -- `node2nix` does not like missing packages from NPM. If you see something like `Cannot resolve version: vue-loader-v16@undefined` then you might want to try another tool. The package might have been pulled off of NPM. +- `node2nix` has some [bugs](https://github.com/svanderburg/node2nix/issues/238) related to working with lock files from npm distributed with `nodejs_16`. +- `node2nix` does not like missing packages from npm. If you see something like `Cannot resolve version: vue-loader-v16@undefined` then you might want to try another tool. The package might have been pulled off of npm. ### yarn2nix {#javascript-yarn2nix} @@ -315,10 +319,12 @@ You will need at least a `yarn.lock` file. If upstream does not have one you nee If the downloaded files contain the `package.json` and `yarn.lock` files they can be used like this: ```nix -offlineCache = fetchYarnDeps { - yarnLock = src + "/yarn.lock"; - hash = "...."; -}; +{ + offlineCache = fetchYarnDeps { + yarnLock = src + "/yarn.lock"; + hash = "...."; + }; +} ``` #### mkYarnPackage {#javascript-yarn2nix-mkYarnPackage} @@ -328,33 +334,41 @@ offlineCache = fetchYarnDeps { It's important to use the `--offline` flag. For example if you script is `"build": "something"` in `package.json` use: ```nix -buildPhase = '' - export HOME=$(mktemp -d) - yarn --offline build -''; +{ + buildPhase = '' + export HOME=$(mktemp -d) + yarn --offline build + ''; +} ``` The `distPhase` is packing the package's dependencies in a tarball using `yarn pack`. You can disable it using: ```nix -doDist = false; +{ + doDist = false; +} ``` The configure phase can sometimes fail because it makes many assumptions which may not always apply. One common override is: ```nix -configurePhase = '' - ln -s $node_modules node_modules -''; +{ + configurePhase = '' + ln -s $node_modules node_modules + ''; +} ``` or if you need a writeable node_modules directory: ```nix -configurePhase = '' - cp -r $node_modules node_modules - chmod +w node_modules -''; +{ + configurePhase = '' + cp -r $node_modules node_modules + chmod +w node_modules + ''; +} ``` #### mkYarnModules {#javascript-yarn2nix-mkYarnModules} @@ -394,12 +408,14 @@ mkYarnPackage rec { - Having trouble with `node-gyp`? Try adding these lines to the `yarnPreBuild` steps: ```nix - yarnPreBuild = '' - mkdir -p $HOME/.node-gyp/${nodejs.version} - echo 9 > $HOME/.node-gyp/${nodejs.version}/installVersion - ln -sfv ${nodejs}/include $HOME/.node-gyp/${nodejs.version} - export npm_config_nodedir=${nodejs} - ''; + { + yarnPreBuild = '' + mkdir -p $HOME/.node-gyp/${nodejs.version} + echo 9 > $HOME/.node-gyp/${nodejs.version}/installVersion + ln -sfv ${nodejs}/include $HOME/.node-gyp/${nodejs.version} + export npm_config_nodedir=${nodejs} + ''; + } ``` - The `echo 9` steps comes from this answer: diff --git a/doc/languages-frameworks/lisp.section.md b/doc/languages-frameworks/lisp.section.md index 09193093b08f..73f20436c76f 100644 --- a/doc/languages-frameworks/lisp.section.md +++ b/doc/languages-frameworks/lisp.section.md @@ -45,7 +45,7 @@ $ sbcl Also one can create a `pkgs.mkShell` environment in `shell.nix`/`flake.nix`: -``` +```nix let sbcl' = sbcl.withPackages (ps: [ ps.alexandria ]); in mkShell { @@ -55,10 +55,12 @@ in mkShell { Such a Lisp can be now used e.g. to compile your sources: -``` -buildPhase = '' - ${sbcl'}/bin/sbcl --load my-build-file.lisp -'' +```nix +{ + buildPhase = '' + ${sbcl'}/bin/sbcl --load my-build-file.lisp + ''; +} ``` ## Importing packages from Quicklisp {#lisp-importing-packages-from-quicklisp} @@ -173,7 +175,7 @@ into the package scope with `withOverrides`. A package defined outside Nixpkgs using `buildASDFSystem` can be woven into the Nixpkgs-provided scope like this: -``` +```nix let alexandria = sbcl.buildASDFSystem rec { pname = "alexandria"; @@ -199,7 +201,7 @@ new package with different parameters. Example of overriding `alexandria`: -``` +```nix sbcl.pkgs.alexandria.overrideLispAttrs (oldAttrs: rec { version = "1.4"; src = fetchFromGitLab { @@ -225,7 +227,7 @@ vice versa. To package slashy systems, use `overrideLispAttrs`, like so: -``` +```nix ecl.pkgs.alexandria.overrideLispAttrs (oldAttrs: { systems = oldAttrs.systems ++ [ "alexandria/tests" ]; lispLibs = oldAttrs.lispLibs ++ [ ecl.pkgs.rt ]; @@ -290,7 +292,7 @@ derivation. This example wraps CLISP: -``` +```nix wrapLisp { pkg = clisp; faslExt = "fas"; diff --git a/doc/languages-frameworks/lua.section.md b/doc/languages-frameworks/lua.section.md index a6577a56a436..87bf7ce885bc 100644 --- a/doc/languages-frameworks/lua.section.md +++ b/doc/languages-frameworks/lua.section.md @@ -17,6 +17,9 @@ The main package set contains aliases to these package sets, e.g. `luaPackages` refers to `lua5_1.pkgs` and `lua52Packages` to `lua5_2.pkgs`. +Note that nixpkgs patches the non-luajit interpreters to avoid referring to +`/usr` and have `;;` (a [placeholder](https://www.lua.org/manual/5.1/manual.html#pdf-package.path) replaced with the default LUA_PATH) work correctly. + ### Installing Lua and packages {#installing-lua-and-packages} #### Lua environment defined in separate `.nix` file {#lua-environment-defined-in-separate-.nix-file} @@ -87,6 +90,7 @@ final: prev: pname = "luarocks-nix"; src = /home/my_luarocks/repository; }); + }; }; luaPackages = lua.pkgs; @@ -154,7 +158,9 @@ You can develop your package as you usually would, just don't forget to wrap it within a `toLuaModule` call, for instance ```nix -mynewlib = toLuaModule ( stdenv.mkDerivation { ... }); +{ + mynewlib = toLuaModule ( stdenv.mkDerivation { /* ... */ }); +} ``` There is also the `buildLuaPackage` function that can be used when lua modules @@ -182,24 +188,26 @@ Each interpreter has the following attributes: The `buildLuarocksPackage` function is implemented in `pkgs/development/interpreters/lua-5/build-luarocks-package.nix` The following is an example: ```nix -luaposix = buildLuarocksPackage { - pname = "luaposix"; - version = "34.0.4-1"; +{ + luaposix = buildLuarocksPackage { + pname = "luaposix"; + version = "34.0.4-1"; - src = fetchurl { - url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/luaposix-34.0.4-1.src.rock"; - hash = "sha256-4mLJG8n4m6y4Fqd0meUDfsOb9RHSR0qa/KD5KCwrNXs="; - }; - disabled = (luaOlder "5.1") || (luaAtLeast "5.4"); - propagatedBuildInputs = [ bit32 lua std_normalize ]; + src = fetchurl { + url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/luaposix-34.0.4-1.src.rock"; + hash = "sha256-4mLJG8n4m6y4Fqd0meUDfsOb9RHSR0qa/KD5KCwrNXs="; + }; + disabled = (luaOlder "5.1") || (luaAtLeast "5.4"); + propagatedBuildInputs = [ bit32 lua std_normalize ]; - meta = { - homepage = "https://github.com/luaposix/luaposix/"; - description = "Lua bindings for POSIX"; - maintainers = with lib.maintainers; [ vyp lblasc ]; - license.fullName = "MIT/X11"; + meta = { + homepage = "https://github.com/luaposix/luaposix/"; + description = "Lua bindings for POSIX"; + maintainers = with lib.maintainers; [ vyp lblasc ]; + license.fullName = "MIT/X11"; + }; }; -}; +} ``` The `buildLuarocksPackage` delegates most tasks to luarocks: diff --git a/doc/languages-frameworks/maven.section.md b/doc/languages-frameworks/maven.section.md index 2ec419e010eb..e56beb102570 100644 --- a/doc/languages-frameworks/maven.section.md +++ b/doc/languages-frameworks/maven.section.md @@ -40,7 +40,7 @@ maven.buildMavenPackage rec { license = lib.licenses.gpl3Plus; maintainers = with lib.maintainers; [ majiir ]; }; -}: +} ``` This package calls `maven.buildMavenPackage` to do its work. The primary difference from `stdenv.mkDerivation` is the `mvnHash` variable, which is a hash of all of the Maven dependencies. diff --git a/doc/languages-frameworks/ocaml.section.md b/doc/languages-frameworks/ocaml.section.md index 4f3b6e0264f7..44f514e90a1b 100644 --- a/doc/languages-frameworks/ocaml.section.md +++ b/doc/languages-frameworks/ocaml.section.md @@ -92,6 +92,7 @@ buildDunePackage rec { license = lib.licenses.bsd3; maintainers = with lib.maintainers; [ sternenseemann ]; }; +} ``` Here is a second example, this time using a source archive generated with `dune-release`. It is a good idea to use this archive when it is available as it will usually contain substituted variables such as a `%%VERSION%%` field. This library does not depend on any other OCaml library and no tests are run after building it. diff --git a/doc/languages-frameworks/perl.section.md b/doc/languages-frameworks/perl.section.md index c188e228112c..4ef6d173a178 100644 --- a/doc/languages-frameworks/perl.section.md +++ b/doc/languages-frameworks/perl.section.md @@ -34,23 +34,27 @@ Nixpkgs provides a function `buildPerlPackage`, a generic package builder functi Perl packages from CPAN are defined in [pkgs/top-level/perl-packages.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/perl-packages.nix) rather than `pkgs/all-packages.nix`. Most Perl packages are so straight-forward to build that they are defined here directly, rather than having a separate function for each package called from `perl-packages.nix`. However, more complicated packages should be put in a separate file, typically in `pkgs/development/perl-modules`. Here is an example of the former: ```nix -ClassC3 = buildPerlPackage rec { - pname = "Class-C3"; - version = "0.21"; - src = fetchurl { - url = "mirror://cpan/authors/id/F/FL/FLORA/${pname}-${version}.tar.gz"; - hash = "sha256-/5GE5xHT0uYGOQxroqj6LMU7CtKn2s6vMVoSXxL4iK4="; +{ + ClassC3 = buildPerlPackage rec { + pname = "Class-C3"; + version = "0.21"; + src = fetchurl { + url = "mirror://cpan/authors/id/F/FL/FLORA/${pname}-${version}.tar.gz"; + hash = "sha256-/5GE5xHT0uYGOQxroqj6LMU7CtKn2s6vMVoSXxL4iK4="; + }; }; -}; +} ``` Note the use of `mirror://cpan/`, and the `pname` and `version` in the URL definition to ensure that the `pname` attribute is consistent with the source that we’re actually downloading. Perl packages are made available in `all-packages.nix` through the variable `perlPackages`. For instance, if you have a package that needs `ClassC3`, you would typically write ```nix -foo = import ../path/to/foo.nix { - inherit stdenv fetchurl ...; - inherit (perlPackages) ClassC3; -}; +{ + foo = import ../path/to/foo.nix { + inherit stdenv fetchurl /* ... */; + inherit (perlPackages) ClassC3; + }; +} ``` in `all-packages.nix`. You can test building a Perl package as follows: @@ -91,17 +95,19 @@ buildPerlPackage rec { Dependencies on other Perl packages can be specified in the `buildInputs` and `propagatedBuildInputs` attributes. If something is exclusively a build-time dependency, use `buildInputs`; if it’s (also) a runtime dependency, use `propagatedBuildInputs`. For instance, this builds a Perl module that has runtime dependencies on a bunch of other modules: ```nix -ClassC3Componentised = buildPerlPackage rec { - pname = "Class-C3-Componentised"; - version = "1.0004"; - src = fetchurl { - url = "mirror://cpan/authors/id/A/AS/ASH/${pname}-${version}.tar.gz"; - hash = "sha256-ASO9rV/FzJYZ0BH572Fxm2ZrFLMZLFATJng1NuU4FHc="; +{ + ClassC3Componentised = buildPerlPackage rec { + pname = "Class-C3-Componentised"; + version = "1.0004"; + src = fetchurl { + url = "mirror://cpan/authors/id/A/AS/ASH/${pname}-${version}.tar.gz"; + hash = "sha256-ASO9rV/FzJYZ0BH572Fxm2ZrFLMZLFATJng1NuU4FHc="; + }; + propagatedBuildInputs = [ + ClassC3 ClassInspector TestException MROCompat + ]; }; - propagatedBuildInputs = [ - ClassC3 ClassInspector TestException MROCompat - ]; -}; +} ``` On Darwin, if a script has too many `-Idir` flags in its first line (its “shebang line”), it will not run. This can be worked around by calling the `shortenPerlShebang` function from the `postInstall` phase: @@ -109,20 +115,22 @@ On Darwin, if a script has too many `-Idir` flags in its first line (its “sheb ```nix { lib, stdenv, buildPerlPackage, fetchurl, shortenPerlShebang }: -ImageExifTool = buildPerlPackage { - pname = "Image-ExifTool"; - version = "12.50"; +{ + ImageExifTool = buildPerlPackage { + pname = "Image-ExifTool"; + version = "12.50"; - src = fetchurl { - url = "https://exiftool.org/${pname}-${version}.tar.gz"; - hash = "sha256-vOhB/FwQMC8PPvdnjDvxRpU6jAZcC6GMQfc0AH4uwKg="; + src = fetchurl { + url = "https://exiftool.org/${pname}-${version}.tar.gz"; + hash = "sha256-vOhB/FwQMC8PPvdnjDvxRpU6jAZcC6GMQfc0AH4uwKg="; + }; + + nativeBuildInputs = lib.optional stdenv.isDarwin shortenPerlShebang; + postInstall = lib.optionalString stdenv.isDarwin '' + shortenPerlShebang $out/bin/exiftool + ''; }; - - nativeBuildInputs = lib.optional stdenv.isDarwin shortenPerlShebang; - postInstall = lib.optionalString stdenv.isDarwin '' - shortenPerlShebang $out/bin/exiftool - ''; -}; +} ``` This will remove the `-I` flags from the shebang line, rewrite them in the `use lib` form, and put them on the next line instead. This function can be given any number of Perl scripts as arguments; it will modify them in-place. diff --git a/doc/languages-frameworks/php.section.md b/doc/languages-frameworks/php.section.md index 154d8174f9aa..c1493588a606 100644 --- a/doc/languages-frameworks/php.section.md +++ b/doc/languages-frameworks/php.section.md @@ -97,7 +97,7 @@ let myPhp = php.withExtensions ({ all, ... }: with all; [ imagick opcache ]); in { services.phpfpm.pools."foo".phpPackage = myPhp; -}; +} ``` ```nix @@ -108,7 +108,7 @@ let }; in { services.phpfpm.pools."foo".phpPackage = myPhp; -}; +} ``` #### Example usage with `nix-shell` {#ssec-php-user-guide-installing-with-extensions-nix-shell} @@ -149,7 +149,7 @@ php.override { extensions = prev.extensions // { mysqlnd = prev.extensions.mysqlnd.overrideAttrs (attrs: { patches = attrs.patches or [] ++ [ - … + # ... ]; }); }; diff --git a/doc/languages-frameworks/pkg-config.section.md b/doc/languages-frameworks/pkg-config.section.md index 75cbdaeb6fe8..e5a2b85b6576 100644 --- a/doc/languages-frameworks/pkg-config.section.md +++ b/doc/languages-frameworks/pkg-config.section.md @@ -12,18 +12,18 @@ Additionally, the [`validatePkgConfig` setup hook](https://nixos.org/manual/nixp A good example of all these things is zlib: -``` +```nix { pkg-config, testers, ... }: stdenv.mkDerivation (finalAttrs: { - ... + /* ... */ nativeBuildInputs = [ pkg-config validatePkgConfig ]; passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; meta = { - ... + /* ... */ pkgConfigModules = [ "zlib" ]; }; }) diff --git a/doc/languages-frameworks/python.section.md b/doc/languages-frameworks/python.section.md index 049b395dcc25..6fcae4b6520d 100644 --- a/doc/languages-frameworks/python.section.md +++ b/doc/languages-frameworks/python.section.md @@ -254,17 +254,19 @@ The next example shows a non trivial overriding of the `blas` implementation to be used through out all of the Python package set: ```nix -python3MyBlas = pkgs.python3.override { - packageOverrides = self: super: { - # We need toPythonModule for the package set to evaluate this - blas = super.toPythonModule(super.pkgs.blas.override { - blasProvider = super.pkgs.mkl; - }); - lapack = super.toPythonModule(super.pkgs.lapack.override { - lapackProvider = super.pkgs.mkl; - }); +{ + python3MyBlas = pkgs.python3.override { + packageOverrides = self: super: { + # We need toPythonModule for the package set to evaluate this + blas = super.toPythonModule(super.pkgs.blas.override { + blasProvider = super.pkgs.mkl; + }); + lapack = super.toPythonModule(super.pkgs.lapack.override { + lapackProvider = super.pkgs.mkl; + }); + }; }; -}; +} ``` This is particularly useful for numpy and scipy users who want to gain speed with other blas implementations. @@ -322,7 +324,9 @@ python3Packages.buildPythonApplication rec { This is then added to `all-packages.nix` just as any other application would be. ```nix -luigi = callPackage ../applications/networking/cluster/luigi { }; +{ + luigi = callPackage ../applications/networking/cluster/luigi { }; +} ``` Since the package is an application, a consumer doesn't need to care about @@ -342,7 +346,9 @@ the attribute in `python-packages.nix`, and the `toPythonApplication` shall be applied to the reference: ```nix -youtube-dl = with python3Packages; toPythonApplication youtube-dl; +{ + youtube-dl = with python3Packages; toPythonApplication youtube-dl; +} ``` #### `toPythonModule` function {#topythonmodule-function} @@ -354,10 +360,12 @@ bindings should be made available from `python-packages.nix`. The modifications. ```nix -opencv = toPythonModule (pkgs.opencv.override { - enablePython = true; - pythonPackages = self; -}); +{ + opencv = toPythonModule (pkgs.opencv.override { + enablePython = true; + pythonPackages = self; + }); +} ``` Do pay attention to passing in the right Python version! @@ -489,40 +497,6 @@ are used in [`buildPythonPackage`](#buildpythonpackage-function). with the `pipInstallHook`. - `unittestCheckHook` will run tests with `python -m unittest discover`. See [example usage](#using-unittestcheckhook). -### Development mode {#development-mode} - -Development or editable mode is supported. To develop Python packages -[`buildPythonPackage`](#buildpythonpackage-function) has additional logic inside `shellPhase` to run `pip -install -e . --prefix $TMPDIR/`for the package. - -Warning: `shellPhase` is executed only if `setup.py` exists. - -Given a `default.nix`: - -```nix -with import {}; - -python3Packages.buildPythonPackage { - name = "myproject"; - buildInputs = with python3Packages; [ pyramid ]; - - src = ./.; -} -``` - -Running `nix-shell` with no arguments should give you the environment in which -the package would be built with `nix-build`. - -Shortcut to setup environments with C headers/libraries and Python packages: - -```shell -nix-shell -p python3Packages.pyramid zlib libjpeg git -``` - -::: {.note} -There is a boolean value `lib.inNixShell` set to `true` if nix-shell is invoked. -::: - ## User Guide {#user-guide} ### Using Python {#using-python} @@ -859,8 +833,7 @@ Above, we were mostly just focused on use cases and what to do to get started creating working Python environments in nix. Now that you know the basics to be up and running, it is time to take a step -back and take a deeper look at how Python packages are packaged on Nix. Then, -we will look at how you can use development mode with your code. +back and take a deeper look at how Python packages are packaged on Nix. #### Python library packages in Nixpkgs {#python-library-packages-in-nixpkgs} @@ -905,7 +878,6 @@ buildPythonPackage rec { homepage = "https://github.com/pytoolz/toolz"; description = "List processing tools and functional utilities"; license = lib.licenses.bsd3; - maintainers = with lib.maintainers; [ fridh ]; }; } ``` @@ -1040,7 +1012,6 @@ buildPythonPackage rec { homepage = "https://github.com/ContinuumIO/datashape"; description = "A data description language"; license = lib.licenses.bsd2; - maintainers = with lib.maintainers; [ fridh ]; }; } ``` @@ -1161,7 +1132,6 @@ buildPythonPackage rec { description = "A pythonic wrapper around FFTW, the FFT library, presenting a unified interface for all the supported transforms"; homepage = "http://hgomersall.github.com/pyFFTW"; license = with lib.licenses; [ bsd2 bsd3 ]; - maintainers = with lib.maintainers; [ fridh ]; }; } ``` @@ -1197,7 +1167,8 @@ a good indication that the package is not in a valid state. Pytest is the most common test runner for python repositories. A trivial test run would be: -``` +```nix +{ nativeCheckInputs = [ pytest ]; checkPhase = '' runHook preCheck @@ -1206,6 +1177,7 @@ test run would be: runHook postCheck ''; +} ``` However, many repositories' test suites do not translate well to nix's build @@ -1213,7 +1185,8 @@ sandbox, and will generally need many tests to be disabled. To filter tests using pytest, one can do the following: -``` +```nix +{ nativeCheckInputs = [ pytest ]; # avoid tests which need additional data or touch network checkPhase = '' @@ -1223,6 +1196,7 @@ To filter tests using pytest, one can do the following: runHook postCheck ''; +} ``` `--ignore` will tell pytest to ignore that file or directory from being @@ -1248,7 +1222,8 @@ when a package may need many items disabled to run the test suite. Using the example above, the analogous `pytestCheckHook` usage would be: -``` +```nix +{ nativeCheckInputs = [ pytestCheckHook ]; @@ -1268,12 +1243,14 @@ Using the example above, the analogous `pytestCheckHook` usage would be: disabledTestPaths = [ "tests/test_failing.py" ]; +} ``` This is especially useful when tests need to be conditionally disabled, for example: -``` +```nix +{ disabledTests = [ # touches network "download" @@ -1285,6 +1262,7 @@ for example: # can fail when building with other packages "socket" ]; +} ``` Trying to concatenate the related strings to disable tests in a regular @@ -1298,20 +1276,24 @@ all packages have test suites that can be run easily, and some have none at all. To help ensure the package still works, [`pythonImportsCheck`](#using-pythonimportscheck) can attempt to import the listed modules. -``` +```nix +{ pythonImportsCheck = [ "requests" "urllib" ]; +} ``` roughly translates to: -``` +```nix +{ postCheck = '' PYTHONPATH=$out/${python.sitePackages}:$PYTHONPATH python -c "import requests; import urllib" ''; +} ``` However, this is done in its own phase, and not dependent on whether [`doCheck = true;`](#var-stdenv-doCheck). @@ -1342,7 +1324,8 @@ pkg3>=1.0,<=2.0 we can do: -``` +```nix +{ nativeBuildInputs = [ pythonRelaxDepsHook ]; @@ -1353,6 +1336,7 @@ we can do: pythonRemoveDeps = [ "pkg2" ]; +} ``` which would result in the following `requirements.txt` file: @@ -1365,9 +1349,11 @@ pkg3 Another option is to pass `true`, that will relax/remove all dependencies, for example: -``` +```nix +{ nativeBuildInputs = [ pythonRelaxDepsHook ]; pythonRelaxDeps = true; +} ``` which would result in the following `requirements.txt` file: @@ -1392,7 +1378,8 @@ work with any of the [existing hooks](#setup-hooks). `unittestCheckHook` is a hook which will substitute the setuptools `test` command for a [`checkPhase`](#ssec-check-phase) which runs `python -m unittest discover`: -``` +```nix +{ nativeCheckInputs = [ unittestCheckHook ]; @@ -1400,6 +1387,7 @@ work with any of the [existing hooks](#setup-hooks). unittestFlagsArray = [ "-s" "tests" "-v" ]; +} ``` #### Using sphinxHook {#using-sphinxhook} @@ -1409,7 +1397,8 @@ using the popular Sphinx documentation generator. It is setup to automatically find common documentation source paths and render them using the default `html` style. -``` +```nix +{ outputs = [ "out" "doc" @@ -1418,13 +1407,15 @@ render them using the default `html` style. nativeBuildInputs = [ sphinxHook ]; +} ``` The hook will automatically build and install the artifact into the `doc` output, if it exists. It also provides an automatic diversion for the artifacts of the `man` builder into the `man` target. -``` +```nix +{ outputs = [ "out" "doc" @@ -1436,58 +1427,22 @@ for the artifacts of the `man` builder into the `man` target. "singlehtml" "man" ]; +} ``` Overwrite `sphinxRoot` when the hook is unable to find your documentation source root. -``` +```nix +{ # Configure sphinxRoot for uncommon paths sphinxRoot = "weird/docs/path"; +} ``` The hook is also available to packages outside the python ecosystem by referencing it using `sphinxHook` from top-level. -### Develop local package {#develop-local-package} - -As a Python developer you're likely aware of [development mode](http://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode) -(`python setup.py develop`); instead of installing the package this command -creates a special link to the project code. That way, you can run updated code -without having to reinstall after each and every change you make. Development -mode is also available. Let's see how you can use it. - -In the previous Nix expression the source was fetched from a url. We can also -refer to a local source instead using `src = ./path/to/source/tree;` - -If we create a `shell.nix` file which calls [`buildPythonPackage`](#buildpythonpackage-function), and if `src` -is a local source, and if the local source has a `setup.py`, then development -mode is activated. - -In the following example, we create a simple environment that has a Python 3.11 -version of our package in it, as well as its dependencies and other packages we -like to have in the environment, all specified with `dependencies`. - -```nix -with import {}; -with python311Packages; - -buildPythonPackage rec { - name = "mypackage"; - src = ./path/to/package/source; - dependencies = [ - pytest - numpy - ]; - propagatedBuildInputs = [ - pkgs.libsndfile - ]; -} -``` - -It is important to note that due to how development mode is implemented on Nix -it is not possible to have multiple packages simultaneously in development mode. - ### Organising your packages {#organising-your-packages} So far we discussed how you can use Python on Nix, and how you can develop with @@ -1536,7 +1491,6 @@ buildPythonPackage rec { homepage = "https://github.com/pytoolz/toolz/"; description = "List processing tools and functional utilities"; license = lib.licenses.bsd3; - maintainers = with lib.maintainers; [ fridh ]; }; } ``` @@ -1827,6 +1781,7 @@ folder and not downloaded again. If you need to change a package's attribute(s) from `configuration.nix` you could do: ```nix +{ nixpkgs.config.packageOverrides = super: { python3 = super.python3.override { packageOverrides = python-self: python-super: { @@ -1841,6 +1796,7 @@ If you need to change a package's attribute(s) from `configuration.nix` you coul }; }; }; +} ``` `python3Packages.twisted` is now globally overridden. @@ -1853,11 +1809,13 @@ To modify only a Python package set instead of a whole Python derivation, use this snippet: ```nix +{ myPythonPackages = python3Packages.override { overrides = self: super: { - twisted = ...; + twisted = <...>; }; - } + }; +} ``` ### How to override a Python package using overlays? {#how-to-override-a-python-package-using-overlays} @@ -1893,7 +1851,7 @@ final: prev: { ( python-final: python-prev: { foo = python-prev.foo.overridePythonAttrs (oldAttrs: { - ... + # ... }); } ) @@ -1920,7 +1878,7 @@ The Python interpreters are by default not built with optimizations enabled, bec the builds are in that case not reproducible. To enable optimizations, override the interpreter of interest, e.g using -``` +```nix let pkgs = import ./. {}; mypython = pkgs.python3.override { @@ -1938,17 +1896,21 @@ Some packages define optional dependencies for additional features. With `extras-require`, while PEP 621 calls these `optional-dependencies`. ```nix -optional-dependencies = { - complete = [ distributed ]; -}; +{ + optional-dependencies = { + complete = [ distributed ]; + }; +} ``` and letting the package requiring the extra add the list to its dependencies ```nix -dependencies = [ - ... -] ++ dask.optional-dependencies.complete; +{ + dependencies = [ + # ... + ] ++ dask.optional-dependencies.complete; +} ``` This method is using `passthru`, meaning that changing `optional-dependencies` of a package won't cause it to rebuild. diff --git a/doc/languages-frameworks/ruby.section.md b/doc/languages-frameworks/ruby.section.md index 9527395de58f..7dede6944a3d 100644 --- a/doc/languages-frameworks/ruby.section.md +++ b/doc/languages-frameworks/ruby.section.md @@ -124,11 +124,13 @@ mkShell { buildInputs = [ gems (lowPrio gems.wrappedRuby) ]; } Sometimes a Gemfile references other files. Such as `.ruby-version` or vendored gems. When copying the Gemfile to the nix store we need to copy those files alongside. This can be done using `extraConfigPaths`. For example: ```nix +{ gems = bundlerEnv { name = "gems-for-some-project"; gemdir = ./.; extraConfigPaths = [ "${./.}/.ruby-version" ]; }; +} ``` ### Gem-specific configurations and workarounds {#gem-specific-configurations-and-workarounds} diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md index 75e57a8bb574..8a1007b7bb8a 100644 --- a/doc/languages-frameworks/rust.section.md +++ b/doc/languages-frameworks/rust.section.md @@ -3,10 +3,12 @@ To install the rust compiler and cargo put ```nix -environment.systemPackages = [ - rustc - cargo -]; +{ + environment.systemPackages = [ + rustc + cargo + ]; +} ``` into your `configuration.nix` or bring them into scope with `nix-shell -p rustc cargo`. @@ -51,7 +53,9 @@ preferred over `cargoSha256` which was used for traditional Nix SHA-256 hashes. For example: ```nix +{ cargoHash = "sha256-l1vL2ZdtDRxSGvP0X/l3nMw8+6WF67KPutJEzUROjg8="; +} ``` Exception: If the application has cargo `git` dependencies, the `cargoHash`/`cargoSha256` @@ -67,13 +71,17 @@ then be taken from the failed build. A fake hash can be used for `cargoHash` as follows: ```nix +{ cargoHash = lib.fakeHash; +} ``` For `cargoSha256` you can use: ```nix +{ cargoSha256 = lib.fakeSha256; +} ``` Per the instructions in the [Cargo Book](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html) @@ -162,9 +170,11 @@ doesn't add a `Cargo.lock` to your `src`, and a `Cargo.lock` is still required to build a rust package. A simple fix is to use: ```nix -postPatch = '' - ln -s ${./Cargo.lock} Cargo.lock -''; +{ + postPatch = '' + ln -s ${./Cargo.lock} Cargo.lock + ''; +} ``` The output hash of each dependency that uses a git source must be @@ -409,7 +419,7 @@ the `cargoPatches` attribute to update or add it. ```nix rustPlatform.buildRustPackage rec { - (...) + # ... cargoPatches = [ # a patch file to add/update Cargo.lock in the source code ./add-Cargo.lock.patch @@ -433,10 +443,12 @@ containing `Cargo.toml` and `Cargo.lock`, `fetchCargoTarball` can be used as follows: ```nix -cargoDeps = rustPlatform.fetchCargoTarball { - inherit src; - hash = "sha256-BoHIN/519Top1NUBjpB/oEMqi86Omt3zTQcXFWqrek0="; -}; +{ + cargoDeps = rustPlatform.fetchCargoTarball { + inherit src; + hash = "sha256-BoHIN/519Top1NUBjpB/oEMqi86Omt3zTQcXFWqrek0="; + }; +} ``` The `src` attribute is required, as well as a hash specified through @@ -458,23 +470,27 @@ function does not require a hash (unless git dependencies are used) and fetches every dependency as a separate fixed-output derivation. `importCargoLock` can be used as follows: -``` -cargoDeps = rustPlatform.importCargoLock { - lockFile = ./Cargo.lock; -}; +```nix +{ + cargoDeps = rustPlatform.importCargoLock { + lockFile = ./Cargo.lock; + }; +} ``` If the `Cargo.lock` file includes git dependencies, then their output hashes need to be specified since they are not available through the lock file. For example: -``` -cargoDeps = rustPlatform.importCargoLock { - lockFile = ./Cargo.lock; - outputHashes = { - "rand-0.8.3" = "0ya2hia3cn31qa8894s3av2s8j5bjwb6yq92k0jsnlx7jid0jwqa"; +```nix +{ + cargoDeps = rustPlatform.importCargoLock { + lockFile = ./Cargo.lock; + outputHashes = { + "rand-0.8.3" = "0ya2hia3cn31qa8894s3av2s8j5bjwb6yq92k0jsnlx7jid0jwqa"; + }; }; -}; +} ``` If you do not specify an output hash for a git dependency, building @@ -651,6 +667,66 @@ buildPythonPackage rec { } ``` +#### Rust package built with `meson` {#rust-package-built-with-meson} + +Some projects, especially GNOME applications, are built with the Meson Build System instead of calling Cargo directly. Using `rustPlatform.buildRustPackage` may successfully build the main program, but related files will be missing. Instead, you need to set up Cargo dependencies with `fetchCargoTarball` and `cargoSetupHook` and leave the rest to Meson. `rust` and `cargo` are still needed in `nativeBuildInputs` for Meson to use. + +```nix +{ lib +, stdenv +, fetchFromGitLab +, meson +, ninja +, pkg-config +, rustPlatform +, rustc +, cargo +, wrapGAppsHook4 +, blueprint-compiler +, libadwaita +, libsecret +, tracker +}: + +stdenv.mkDerivation rec { + pname = "health"; + version = "0.95.0"; + + src = fetchFromGitLab { + domain = "gitlab.gnome.org"; + owner = "World"; + repo = "health"; + rev = version; + hash = "sha256-PrNPprSS98yN8b8yw2G6hzTSaoE65VbsM3q7FVB4mds="; + }; + + cargoDeps = rustPlatform.fetchCargoTarball { + inherit src; + name = "${pname}-${version}"; + hash = "sha256-8fa3fa+sFi5H+49B5sr2vYPkp9C9s6CcE0zv4xB8gww="; + }; + + nativeBuildInputs = [ + meson + ninja + pkg-config + rustPlatform.cargoSetupHook + rustc + cargo + wrapGAppsHook4 + blueprint-compiler + ]; + + buildInputs = [ + libadwaita + libsecret + tracker + ]; + + # ... +} +``` + ## `buildRustCrate`: Compiling Rust crates using Nix instead of Cargo {#compiling-rust-crates-using-nix-instead-of-cargo} ### Simple operation {#simple-operation} @@ -732,27 +808,27 @@ general. A number of other parameters can be overridden: - The version of `rustc` used to compile the crate: ```nix - (hello {}).override { rust = pkgs.rust; }; + (hello {}).override { rust = pkgs.rust; } ``` - Whether to build in release mode or debug mode (release mode by default): ```nix - (hello {}).override { release = false; }; + (hello {}).override { release = false; } ``` - Whether to print the commands sent to `rustc` when building (equivalent to `--verbose` in cargo: ```nix - (hello {}).override { verbose = false; }; + (hello {}).override { verbose = false; } ``` - Extra arguments to be passed to `rustc`: ```nix - (hello {}).override { extraRustcOpts = "-Z debuginfo=2"; }; + (hello {}).override { extraRustcOpts = "-Z debuginfo=2"; } ``` - Phases, just like in any other derivation, can be specified using @@ -768,7 +844,7 @@ general. A number of other parameters can be overridden: preConfigure = '' echo "pub const PATH=\"${hi.out}\";" >> src/path.rs" ''; - }; + } ``` ### Setting Up `nix-shell` {#setting-up-nix-shell} diff --git a/doc/languages-frameworks/swift.section.md b/doc/languages-frameworks/swift.section.md index 213d444f499f..88d98deeb2dd 100644 --- a/doc/languages-frameworks/swift.section.md +++ b/doc/languages-frameworks/swift.section.md @@ -112,13 +112,17 @@ stdenv.mkDerivation rec { If you'd like to build a different configuration than `release`: ```nix -swiftpmBuildConfig = "debug"; +{ + swiftpmBuildConfig = "debug"; +} ``` It is also possible to provide additional flags to `swift build`: ```nix -swiftpmFlags = [ "--disable-dead-strip" ]; +{ + swiftpmFlags = [ "--disable-dead-strip" ]; +} ``` The default `buildPhase` already passes `-j` for parallel building. @@ -132,7 +136,9 @@ Including `swiftpm` in your `nativeBuildInputs` also provides a default `checkPhase`, but it must be enabled with: ```nix -doCheck = true; +{ + doCheck = true; +} ``` This essentially runs: `swift test -c release` @@ -147,13 +153,15 @@ them, we need to make them writable. A special function `swiftpmMakeMutable` is available to replace the symlink with a writable copy: -``` -configurePhase = generated.configure ++ '' - # Replace the dependency symlink with a writable copy. - swiftpmMakeMutable swift-crypto - # Now apply a patch. - patch -p1 -d .build/checkouts/swift-crypto -i ${./some-fix.patch} -''; +```nix +{ + configurePhase = generated.configure ++ '' + # Replace the dependency symlink with a writable copy. + swiftpmMakeMutable swift-crypto + # Now apply a patch. + patch -p1 -d .build/checkouts/swift-crypto -i ${./some-fix.patch} + ''; +} ``` ## Considerations for custom build tools {#ssec-swift-considerations-for-custom-build-tools} diff --git a/doc/languages-frameworks/vim.section.md b/doc/languages-frameworks/vim.section.md index 1f3727f552c8..69031ccbd340 100644 --- a/doc/languages-frameworks/vim.section.md +++ b/doc/languages-frameworks/vim.section.md @@ -219,9 +219,11 @@ After running the updater, if nvim-treesitter received an update, also run [`nvi Some plugins require overrides in order to function properly. Overrides are placed in [overrides.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/overrides.nix). Overrides are most often required when a plugin requires some dependencies, or extra steps are required during the build process. For example `deoplete-fish` requires both `deoplete-nvim` and `vim-fish`, and so the following override was added: ```nix -deoplete-fish = super.deoplete-fish.overrideAttrs(old: { - dependencies = with super; [ deoplete-nvim vim-fish ]; -}); +{ + deoplete-fish = super.deoplete-fish.overrideAttrs(old: { + dependencies = with super; [ deoplete-nvim vim-fish ]; + }); +} ``` Sometimes plugins require an override that must be changed when the plugin is updated. This can cause issues when Vim plugins are auto-updated but the associated override isn't updated. For these plugins, the override should be written so that it specifies all information required to install the plugin, and running `./update.py` doesn't change the derivation for the plugin. Manually updating the override is required to update these types of plugins. An example of such a plugin is `LanguageClient-neovim`. @@ -264,8 +266,10 @@ pwntester/octo.nvim,, You can then reference the generated vim plugins via: ```nix -myVimPlugins = pkgs.vimPlugins.extend ( - (pkgs.callPackage ./generated.nix {}) -); +{ + myVimPlugins = pkgs.vimPlugins.extend ( + (pkgs.callPackage ./generated.nix {}) + ); +} ``` diff --git a/doc/manpage-urls.json b/doc/manpage-urls.json index 2cc03af4360f..e878caf042a4 100644 --- a/doc/manpage-urls.json +++ b/doc/manpage-urls.json @@ -320,5 +320,7 @@ "login.defs(5)": "https://man.archlinux.org/man/login.defs.5", "unshare(1)": "https://man.archlinux.org/man/unshare.1.en", "nix-shell(1)": "https://nixos.org/manual/nix/stable/command-ref/nix-shell.html", - "mksquashfs(1)": "https://man.archlinux.org/man/extra/squashfs-tools/mksquashfs.1.en" + "mksquashfs(1)": "https://man.archlinux.org/man/extra/squashfs-tools/mksquashfs.1.en", + "curl(1)": "https://curl.se/docs/manpage.html", + "netrc(5)": "https://man.cx/netrc" } diff --git a/doc/packages/darwin-builder.section.md b/doc/packages/darwin-builder.section.md index 3a547de53705..ca8519c5bf5f 100644 --- a/doc/packages/darwin-builder.section.md +++ b/doc/packages/darwin-builder.section.md @@ -81,7 +81,7 @@ $ sudo launchctl kickstart -k system/org.nixos.nix-daemon ## Example flake usage {#sec-darwin-builder-example-flake} -``` +```nix { inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-22.11-darwin"; @@ -153,7 +153,8 @@ you may use it to build a modified remote builder with additional storage or mem To do this, you just need to set the `virtualisation.darwin-builder.*` parameters as in the example below and rebuild. -``` +```nix + { darwin-builder = nixpkgs.lib.nixosSystem { system = linuxSystem; modules = [ @@ -166,6 +167,8 @@ in the example below and rebuild. virtualisation.darwin-builder.workingDirectory = "/var/lib/darwin-builder"; } ]; + }; + } ``` You may make any other changes to your VM in this attribute set. For example, diff --git a/doc/packages/eclipse.section.md b/doc/packages/eclipse.section.md index e19510e131a0..acf34b57571a 100644 --- a/doc/packages/eclipse.section.md +++ b/doc/packages/eclipse.section.md @@ -13,11 +13,13 @@ Once an Eclipse variant is installed, it can be run using the `eclipse` command, If you prefer to install plugins in a more declarative manner, then Nixpkgs also offer a number of Eclipse plugins that can be installed in an _Eclipse environment_. This type of environment is created using the function `eclipseWithPlugins` found inside the `nixpkgs.eclipses` attribute set. This function takes as argument `{ eclipse, plugins ? [], jvmArgs ? [] }` where `eclipse` is a one of the Eclipse packages described above, `plugins` is a list of plugin derivations, and `jvmArgs` is a list of arguments given to the JVM running the Eclipse. For example, say you wish to install the latest Eclipse Platform with the popular Eclipse Color Theme plugin and also allow Eclipse to use more RAM. You could then add: ```nix -packageOverrides = pkgs: { - myEclipse = with pkgs.eclipses; eclipseWithPlugins { - eclipse = eclipse-platform; - jvmArgs = [ "-Xmx2048m" ]; - plugins = [ plugins.color-theme ]; +{ + packageOverrides = pkgs: { + myEclipse = with pkgs.eclipses; eclipseWithPlugins { + eclipse = eclipse-platform; + jvmArgs = [ "-Xmx2048m" ]; + plugins = [ plugins.color-theme ]; + }; }; } ``` @@ -33,32 +35,34 @@ If there is a need to install plugins that are not available in Nixpkgs then it Expanding the previous example with two plugins using the above functions, we have: ```nix -packageOverrides = pkgs: { - myEclipse = with pkgs.eclipses; eclipseWithPlugins { - eclipse = eclipse-platform; - jvmArgs = [ "-Xmx2048m" ]; - plugins = [ - plugins.color-theme - (plugins.buildEclipsePlugin { - name = "myplugin1-1.0"; - srcFeature = fetchurl { - url = "http://…/features/myplugin1.jar"; - hash = "sha256-123…"; - }; - srcPlugin = fetchurl { - url = "http://…/plugins/myplugin1.jar"; - hash = "sha256-123…"; - }; - }); - (plugins.buildEclipseUpdateSite { - name = "myplugin2-1.0"; - src = fetchurl { - stripRoot = false; - url = "http://…/myplugin2.zip"; - hash = "sha256-123…"; - }; - }); - ]; +{ + packageOverrides = pkgs: { + myEclipse = with pkgs.eclipses; eclipseWithPlugins { + eclipse = eclipse-platform; + jvmArgs = [ "-Xmx2048m" ]; + plugins = [ + plugins.color-theme + (plugins.buildEclipsePlugin { + name = "myplugin1-1.0"; + srcFeature = fetchurl { + url = "http://…/features/myplugin1.jar"; + hash = "sha256-123…"; + }; + srcPlugin = fetchurl { + url = "http://…/plugins/myplugin1.jar"; + hash = "sha256-123…"; + }; + }) + (plugins.buildEclipseUpdateSite { + name = "myplugin2-1.0"; + src = fetchurl { + stripRoot = false; + url = "http://…/myplugin2.zip"; + hash = "sha256-123…"; + }; + }) + ]; + }; }; } ``` diff --git a/doc/packages/emacs.section.md b/doc/packages/emacs.section.md index c50c7815537d..2ced251f3e46 100644 --- a/doc/packages/emacs.section.md +++ b/doc/packages/emacs.section.md @@ -16,7 +16,7 @@ The Emacs package comes with some extra helpers to make it easier to configure. projectile use-package ])); - } + }; } ``` @@ -102,10 +102,12 @@ This provides a fairly full Emacs start file. It will load in addition to the us Sometimes `emacs.pkgs.withPackages` is not enough, as this package set has some priorities imposed on packages (with the lowest priority assigned to GNU-devel ELPA, and the highest for packages manually defined in `pkgs/applications/editors/emacs/elisp-packages/manual-packages`). But you can't control these priorities when some package is installed as a dependency. You can override it on a per-package-basis, providing all the required dependencies manually, but it's tedious and there is always a possibility that an unwanted dependency will sneak in through some other package. To completely override such a package, you can use `overrideScope`. ```nix -overrides = self: super: rec { - haskell-mode = self.melpaPackages.haskell-mode; - ... -}; +let + overrides = self: super: rec { + haskell-mode = self.melpaPackages.haskell-mode; + # ... + }; +in ((emacsPackagesFor emacs).overrideScope overrides).withPackages (p: with p; [ # here both these package will use haskell-mode of our own choice @@ -113,3 +115,4 @@ overrides = self: super: rec { dante ]) ``` +} diff --git a/doc/packages/index.md b/doc/packages/index.md index 1f45018ffc4a..38dba5b3498f 100644 --- a/doc/packages/index.md +++ b/doc/packages/index.md @@ -14,6 +14,7 @@ fish.section.md fuse.section.md ibus.section.md kakoune.section.md +krita.section.md linux.section.md locales.section.md etc-files.section.md diff --git a/doc/packages/krita.section.md b/doc/packages/krita.section.md new file mode 100644 index 000000000000..ba427bd62ba1 --- /dev/null +++ b/doc/packages/krita.section.md @@ -0,0 +1,37 @@ +# Krita {#sec-krita} + +## Python plugins {#krita-python-plugins} + +"pykrita" plugins should be installed following +[Krita's manual](https://docs.krita.org/en/user_manual/python_scripting/install_custom_python_plugin.html). +This generally involves extracting the extension to `~/.local/share/krita/pykrita/`. + +## Binary plugins {#krita-binary-plugins} + +Binary plugins are Dynamically Linked Libraries to be loaded by Krita. + +_Note: You most likely won't need to deal with binary plugins, +all known plugins are bundled and enabled by default._ + +### Installing binary plugins {#krita-install-binary-plugins} + +You can choose what plugins are added to Krita by overriding the +`binaryPlugins` attribute. + +If you want to add plugins instead of replacing, you can read the +list of previous plugins via `pkgs.krita.binaryPlugins`: + +```nix +(pkgs.krita.override (old: { + binaryPlugins = old.binaryPlugins ++ [ your-plugin ]; +})) +``` + +### Example structure of a binary plugin {#krita-binary-plugin-structure} + +``` +/nix/store/00000000000000000000000000000000-krita-plugin-example-1.2.3 +└── lib + └── kritaplugins + └── krita_example.so +``` diff --git a/doc/packages/steam.section.md b/doc/packages/steam.section.md index a1e88b0d9710..c9a09962f62d 100644 --- a/doc/packages/steam.section.md +++ b/doc/packages/steam.section.md @@ -51,7 +51,7 @@ Use `programs.steam.enable = true;` if you want to add steam to `systemPackages` you need to add: ```nix - steam.override { withJava = true; }; + steam.override { withJava = true; } ``` ## steam-run {#sec-steam-run} diff --git a/doc/packages/urxvt.section.md b/doc/packages/urxvt.section.md index 7aff0997dd2b..1d40c92ed73f 100644 --- a/doc/packages/urxvt.section.md +++ b/doc/packages/urxvt.section.md @@ -65,7 +65,9 @@ A plugin can be any kind of derivation, the only requirement is that it should a If the plugin is itself a Perl package that needs to be imported from other plugins or scripts, add the following passthrough: ```nix -passthru.perlPackages = [ "self" ]; +{ + passthru.perlPackages = [ "self" ]; +} ``` This will make the urxvt wrapper pick up the dependency and set up the Perl path accordingly. diff --git a/doc/packages/weechat.section.md b/doc/packages/weechat.section.md index 755b6e6ad1ea..295397f476b0 100644 --- a/doc/packages/weechat.section.md +++ b/doc/packages/weechat.section.md @@ -3,9 +3,9 @@ WeeChat can be configured to include your choice of plugins, reducing its closure size from the default configuration which includes all available plugins. To make use of this functionality, install an expression that overrides its configuration, such as: ```nix -weechat.override {configure = {availablePlugins, ...}: { +weechat.override {configure = ({availablePlugins, ...}: { plugins = with availablePlugins; [ python perl ]; - } + }); } ``` @@ -59,7 +59,7 @@ weechat.override { ]; init = '' /set plugins.var.python.jabber.key "val" - '': + ''; }; } ``` diff --git a/doc/stdenv/cross-compilation.chapter.md b/doc/stdenv/cross-compilation.chapter.md index e659e1803807..76c931ba047a 100644 --- a/doc/stdenv/cross-compilation.chapter.md +++ b/doc/stdenv/cross-compilation.chapter.md @@ -15,7 +15,9 @@ Nixpkgs follows the [conventions of GNU autoconf](https://gcc.gnu.org/onlinedocs In Nixpkgs, these three platforms are defined as attribute sets under the names `buildPlatform`, `hostPlatform`, and `targetPlatform`. They are always defined as attributes in the standard environment. That means one can access them like: ```nix -{ stdenv, fooDep, barDep, ... }: ...stdenv.buildPlatform... +{ stdenv, fooDep, barDep, ... }: { + # ...stdenv.buildPlatform... +} ``` `buildPlatform` @@ -127,7 +129,9 @@ Some frequently encountered problems when packaging for cross-compilation should Many packages assume that an unprefixed binutils (`cc`/`ar`/`ld` etc.) is available, but Nix doesn't provide one. It only provides a prefixed one, just as it only does for all the other binutils programs. It may be necessary to patch the package to fix the build system to use a prefix. For instance, instead of `cc`, use `${stdenv.cc.targetPrefix}cc`. ```nix -makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; +{ + makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; +} ``` #### How do I avoid compiling a GCC cross-compiler from source? {#cross-qa-avoid-compiling-gcc-cross-compiler} @@ -142,7 +146,9 @@ $ nix-build '' -A pkgsCross.raspberryPi.hello Add the following to your `mkDerivation` invocation. ```nix -depsBuildBuild = [ buildPackages.stdenv.cc ]; +{ + depsBuildBuild = [ buildPackages.stdenv.cc ]; +} ``` #### My package’s testsuite needs to run host platform code. {#cross-testsuite-runs-host-code} @@ -150,7 +156,9 @@ depsBuildBuild = [ buildPackages.stdenv.cc ]; Add the following to your `mkDerivation` invocation. ```nix -doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; +{ + doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; +} ``` #### Package using Meson needs to run binaries for the host platform during build. {#cross-meson-runs-host-code} @@ -159,12 +167,14 @@ Add `mesonEmulatorHook` to `nativeBuildInputs` conditionally on if the target bi e.g. -``` -nativeBuildInputs = [ - meson -] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ - mesonEmulatorHook -]; +```nix +{ + nativeBuildInputs = [ + meson + ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ + mesonEmulatorHook + ]; +} ``` Example of an error which this fixes. diff --git a/doc/stdenv/meta.chapter.md b/doc/stdenv/meta.chapter.md index 4a3b04b8f6e4..7f57eda791ea 100644 --- a/doc/stdenv/meta.chapter.md +++ b/doc/stdenv/meta.chapter.md @@ -3,17 +3,19 @@ Nix packages can declare *meta-attributes* that contain information about a package such as a description, its homepage, its license, and so on. For instance, the GNU Hello package has a `meta` declaration like this: ```nix -meta = { - description = "A program that produces a familiar, friendly greeting"; - longDescription = '' - GNU Hello is a program that prints "Hello, world!" when you run it. - It is fully customizable. - ''; - homepage = "https://www.gnu.org/software/hello/manual/"; - license = lib.licenses.gpl3Plus; - maintainers = with lib.maintainers; [ eelco ]; - platforms = lib.platforms.all; -}; +{ + meta = { + description = "A program that produces a familiar, friendly greeting"; + longDescription = '' + GNU Hello is a program that prints "Hello, world!" when you run it. + It is fully customizable. + ''; + homepage = "https://www.gnu.org/software/hello/manual/"; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ eelco ]; + platforms = lib.platforms.all; + }; +} ``` Meta-attributes are not passed to the builder of the package. Thus, a change to a meta-attribute doesn’t trigger a recompilation of the package. @@ -82,7 +84,9 @@ The *priority* of the package, used by `nix-env` to resolve file name conflicts The list of Nix platform types on which the package is supported. Hydra builds packages according to the platform specified. If no platform is specified, the package does not have prebuilt binaries. An example is: ```nix -meta.platforms = lib.platforms.linux; +{ + meta.platforms = lib.platforms.linux; +} ``` Attribute Set `lib.platforms` defines [various common lists](https://github.com/NixOS/nixpkgs/blob/master/lib/systems/doubles.nix) of platforms types. @@ -95,8 +99,10 @@ In general it is preferable to set `meta.platforms = lib.platforms.all` and then For example, a package which requires dynamic linking and cannot be linked statically could use this: ```nix -meta.platforms = lib.platforms.all; -meta.badPlatforms = [ lib.systems.inspect.patterns.isStatic ]; +{ + meta.platforms = lib.platforms.all; + meta.badPlatforms = [ lib.systems.inspect.patterns.isStatic ]; +} ``` The [`lib.meta.availableOn`](https://github.com/NixOS/nixpkgs/blob/b03ac42b0734da3e7be9bf8d94433a5195734b19/lib/meta.nix#L95-L106) function can be used to test whether or not a package is available (i.e. buildable) on a given platform. @@ -136,7 +142,7 @@ For more on how to write and run package tests, see [](#sec-package-tests). The NixOS tests are available as `nixosTests` in parameters of derivations. For instance, the OpenSMTPD derivation includes lines similar to: ```nix -{ /* ... */, nixosTests }: +{ /* ... , */ nixosTests }: { # ... passthru.tests = { @@ -194,8 +200,10 @@ To be effective, it must be presented directly to an evaluation process that han The list of Nix platform types for which the [Hydra](https://github.com/nixos/hydra) [instance at `hydra.nixos.org`](https://nixos.org/hydra) will build the package. (Hydra is the Nix-based continuous build system.) It defaults to the value of `meta.platforms`. Thus, the only reason to set `meta.hydraPlatforms` is if you want `hydra.nixos.org` to build the package on a subset of `meta.platforms`, or not at all, e.g. ```nix -meta.platforms = lib.platforms.linux; -meta.hydraPlatforms = []; +{ + meta.platforms = lib.platforms.linux; + meta.hydraPlatforms = []; +} ``` ### `broken` {#var-meta-broken} @@ -209,13 +217,17 @@ This means that `broken` can be used to express constraints, for example: - Does not cross compile ```nix - meta.broken = !(stdenv.buildPlatform.canExecute stdenv.hostPlatform) + { + meta.broken = !(stdenv.buildPlatform.canExecute stdenv.hostPlatform); + } ``` - Broken if all of a certain set of its dependencies are broken ```nix - meta.broken = lib.all (map (p: p.meta.broken) [ glibc musl ]) + { + meta.broken = lib.all (map (p: p.meta.broken) [ glibc musl ]); + } ``` This makes `broken` strictly more powerful than `meta.badPlatforms`. diff --git a/doc/stdenv/multiple-output.chapter.md b/doc/stdenv/multiple-output.chapter.md index 1ee063c0c2f4..5e86d2aa3d56 100644 --- a/doc/stdenv/multiple-output.chapter.md +++ b/doc/stdenv/multiple-output.chapter.md @@ -30,7 +30,9 @@ Here you find how to write a derivation that produces multiple outputs. In nixpkgs there is a framework supporting multiple-output derivations. It tries to cover most cases by default behavior. You can find the source separated in ``; it’s relatively well-readable. The whole machinery is triggered by defining the `outputs` attribute to contain the list of desired output names (strings). ```nix -outputs = [ "bin" "dev" "out" "doc" ]; +{ + outputs = [ "bin" "dev" "out" "doc" ]; +} ``` Often such a single line is enough. For each output an equally named environment variable is passed to the builder and contains the path in nix store for that output. Typically you also want to have the main `out` output, as it catches any files that didn’t get elsewhere. diff --git a/doc/stdenv/stdenv.chapter.md b/doc/stdenv/stdenv.chapter.md index a948c6757c4a..f3cdb1f2dc0c 100644 --- a/doc/stdenv/stdenv.chapter.md +++ b/doc/stdenv/stdenv.chapter.md @@ -36,7 +36,7 @@ Many packages have dependencies that are not provided in the standard environmen stdenv.mkDerivation { pname = "libfoo"; version = "1.2.3"; - ... + # ... buildInputs = [libbar perl ncurses]; } ``` @@ -49,7 +49,7 @@ Often it is necessary to override or modify some aspect of the build. To make th stdenv.mkDerivation { pname = "fnord"; version = "4.5"; - ... + # ... buildPhase = '' gcc foo.c -o foo ''; @@ -70,7 +70,7 @@ While the standard environment provides a generic builder, you can still supply stdenv.mkDerivation { pname = "libfoo"; version = "1.2.3"; - ... + # ... builder = ./builder.sh; } ``` @@ -449,11 +449,13 @@ Unless set to `false`, some build systems with good support for parallel buildin This is an attribute set which can be filled with arbitrary values. For example: ```nix -passthru = { - foo = "bar"; - baz = { - value1 = 4; - value2 = 5; +{ + passthru = { + foo = "bar"; + baz = { + value1 = 4; + value2 = 5; + }; }; } ``` @@ -467,27 +469,33 @@ A script to be run by `maintainers/scripts/update.nix` when the package is match - []{#var-passthru-updateScript-command} an executable file, either on the file system: ```nix - passthru.updateScript = ./update.sh; + { + passthru.updateScript = ./update.sh; + } ``` or inside the expression itself: ```nix - passthru.updateScript = writeScript "update-zoom-us" '' - #!/usr/bin/env nix-shell - #!nix-shell -i bash -p curl pcre2 common-updater-scripts + { + passthru.updateScript = writeScript "update-zoom-us" '' + #!/usr/bin/env nix-shell + #!nix-shell -i bash -p curl pcre2 common-updater-scripts - set -eu -o pipefail + set -eu -o pipefail - version="$(curl -sI https://zoom.us/client/latest/zoom_x86_64.tar.xz | grep -Fi 'Location:' | pcre2grep -o1 '/(([0-9]\.?)+)/')" - update-source-version zoom-us "$version" - ''; + version="$(curl -sI https://zoom.us/client/latest/zoom_x86_64.tar.xz | grep -Fi 'Location:' | pcre2grep -o1 '/(([0-9]\.?)+)/')" + update-source-version zoom-us "$version" + ''; + } ``` - a list, a script followed by arguments to be passed to it: ```nix - passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]; + { + passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ]; + } ``` - an attribute set containing: @@ -496,18 +504,22 @@ A script to be run by `maintainers/scripts/update.nix` when the package is match - [`supportedFeatures`]{#var-passthru-updateScript-set-supportedFeatures} (optional) – a list of the [extra features](#var-passthru-updateScript-supported-features) the script supports. ```nix - passthru.updateScript = { - command = [ ../../update.sh pname ]; - attrPath = pname; - supportedFeatures = [ … ]; - }; + { + passthru.updateScript = { + command = [ ../../update.sh pname ]; + attrPath = pname; + supportedFeatures = [ /* ... */ ]; + }; + } ``` ::: {.tip} A common pattern is to use the [`nix-update-script`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/common-updater/nix-update.nix) attribute provided in Nixpkgs, which runs [`nix-update`](https://github.com/Mic92/nix-update): ```nix -passthru.updateScript = nix-update-script { }; +{ + passthru.updateScript = nix-update-script { }; +} ``` For simple packages, this is often enough, and will ensure that the package is updated automatically by [`nixpkgs-update`](https://ryantm.github.io/nixpkgs-update) when a new version is released. The [update bot](https://nix-community.org/update-bot) runs periodically to attempt to automatically update packages, and will run `passthru.updateScript` if set. While not strictly necessary if the project is listed on [Repology](https://repology.org), using `nix-update-script` allows the package to update via many more sources (e.g. GitHub releases). @@ -785,7 +797,7 @@ A shell array containing additional arguments passed to the configure script. Yo ##### `dontAddPrefix` {#var-stdenv-dontAddPrefix} -By default, the flag `--prefix=$prefix` is added to the configure flags. If this is undesirable, set this variable to true. +By default, `./configure` is passed the concatenation of [`prefixKey`](#var-stdenv-prefixKey) and [`prefix`](#var-stdenv-prefix) on the command line. Disable this by setting `dontAddPrefix` to `true`. ##### `prefix` {#var-stdenv-prefix} @@ -793,7 +805,7 @@ The prefix under which the package must be installed, passed via the `--prefix` ##### `prefixKey` {#var-stdenv-prefixKey} -The key to use when specifying the prefix. By default, this is set to `--prefix=` as that is used by the majority of packages. +The key to use when specifying the installation [`prefix`](#var-stdenv-prefix). By default, this is set to `--prefix=` as that is used by the majority of packages. Other packages may need `--prefix ` (with a trailing space) or `PREFIX=`. ##### `dontAddStaticConfigureFlags` {#var-stdenv-dontAddStaticConfigureFlags} @@ -846,7 +858,9 @@ The file name of the Makefile. A list of strings passed as additional flags to `make`. These flags are also used by the default install and check phase. For setting make flags specific to the build phase, use `buildFlags` (see below). ```nix -makeFlags = [ "PREFIX=$(out)" ]; +{ + makeFlags = [ "PREFIX=$(out)" ]; +} ``` ::: {.note} @@ -858,9 +872,11 @@ The flags are quoted in bash, but environment variables can be specified by usin A shell array containing additional arguments passed to `make`. You must use this instead of `makeFlags` if the arguments contain spaces, e.g. ```nix -preBuild = '' - makeFlagsArray+=(CFLAGS="-O0 -g" LDFLAGS="-lfoo -lbar") -''; +{ + preBuild = '' + makeFlagsArray+=(CFLAGS="-O0 -g" LDFLAGS="-lfoo -lbar") + ''; +} ``` Note that shell arrays cannot be passed through environment variables, so you cannot set `makeFlagsArray` in a derivation attribute (because those are passed through environment variables): you have to define them in shell code. @@ -892,7 +908,9 @@ The check phase checks whether the package was built correctly by running its te Controls whether the check phase is executed. By default it is skipped, but if `doCheck` is set to true, the check phase is usually executed. Thus you should set ```nix -doCheck = true; +{ + doCheck = true; +} ``` in the derivation to enable checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how `doCheck` is set, as the newly-built program won’t run on the platform used to build it. @@ -945,7 +963,9 @@ See the [build phase](#var-stdenv-makeFlags) for details. The make targets that perform the installation. Defaults to `install`. Example: ```nix -installTargets = "install-bin install-doc"; +{ + installTargets = "install-bin install-doc"; +} ``` ##### `installFlags` / `installFlagsArray` {#var-stdenv-installFlags} @@ -1024,7 +1044,7 @@ This example prevents all `*.rlib` files from being stripped: ```nix stdenv.mkDerivation { # ... - stripExclude = [ "*.rlib" ] + stripExclude = [ "*.rlib" ]; } ``` @@ -1033,7 +1053,7 @@ This example prevents files within certain paths from being stripped: ```nix stdenv.mkDerivation { # ... - stripExclude = [ "lib/modules/*/build/* ] + stripExclude = [ "lib/modules/*/build/*" ]; } ``` @@ -1134,7 +1154,9 @@ It is often better to add tests that are not part of the source distribution to Controls whether the installCheck phase is executed. By default it is skipped, but if `doInstallCheck` is set to true, the installCheck phase is usually executed. Thus you should set ```nix -doInstallCheck = true; +{ + doInstallCheck = true; +} ``` in the derivation to enable install checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how `doInstallCheck` is set, as the newly-built program won’t run on the platform used to build it. @@ -1244,9 +1266,11 @@ To use this, add `removeReferencesTo` to `nativeBuildInputs`. As `remove-references-to` is an actual executable and not a shell function, it can be used with `find`. Example removing all references to the compiler in the output: ```nix -postInstall = '' - find "$out" -type f -exec remove-references-to -t ${stdenv.cc} '{}' + -''; +{ + postInstall = '' + find "$out" -type f -exec remove-references-to -t ${stdenv.cc} '{}' + + ''; +} ``` ### `substitute` \ \ \ {#fun-substitute} diff --git a/doc/style.css b/doc/style.css index fddf4f4823c7..5bc587a6ee30 100644 --- a/doc/style.css +++ b/doc/style.css @@ -347,6 +347,22 @@ div.appendix div.example { margin-top: 1.5em; } +div.book div.example details, +div.appendix div.example details { + padding: 5px; +} + +div.book div.example details[open], +div.appendix div.example details[open] { + border: 1px solid #aaa; + border-radius: 4px; +} + +div.book div.example details>summary, +div.appendix div.example details>summary { + cursor: pointer; +} + div.book br.example-break, div.appendix br.example-break { display: none; @@ -414,3 +430,12 @@ div.appendix .informaltable th, div.appendix .informaltable td { padding: 0.5rem; } + +/* + This relies on highlight.js applying certain classes on the prompts. + For more details, see https://highlightjs.readthedocs.io/en/latest/css-classes-reference.html#stylable-scopes +*/ +.hljs-meta.prompt_ { + user-select: none; + -webkit-user-select: none; +} diff --git a/doc/using/configuration.chapter.md b/doc/using/configuration.chapter.md index 8d246b117b05..05a8fa5517cc 100644 --- a/doc/using/configuration.chapter.md +++ b/doc/using/configuration.chapter.md @@ -1,6 +1,7 @@ # Global configuration {#chap-packageconfig} -Nix comes with certain defaults about what packages can and cannot be installed, based on a package's metadata. By default, Nix will prevent installation if any of the following criteria are true: +Nix comes with certain defaults about which packages can and cannot be installed, based on a package's metadata. +By default, Nix will prevent installation if any of the following criteria are true: - The package is thought to be broken, and has had its `meta.broken` set to `true`. @@ -10,23 +11,14 @@ Nix comes with certain defaults about what packages can and cannot be installed, - The package has known security vulnerabilities but has not or can not be updated for some reason, and a list of issues has been entered in to the package's `meta.knownVulnerabilities`. -Note that all this is checked during evaluation already, and the check includes any package that is evaluated. In particular, all build-time dependencies are checked. `nix-env -qa` will (attempt to) hide any packages that would be refused. +Each of these criteria can be altered in the Nixpkgs configuration. -Each of these criteria can be altered in the nixpkgs configuration. +:::{.note} +All this is checked during evaluation already, and the check includes any package that is evaluated. +In particular, all build-time dependencies are checked. +::: -The nixpkgs configuration for a NixOS system is set in the `configuration.nix`, as in the following example: - -```nix -{ - nixpkgs.config = { - allowUnfree = true; - }; -} -``` - -However, this does not allow unfree software for individual users. Their configurations are managed separately. - -A user's nixpkgs configuration is stored in a user-specific configuration file located at `~/.config/nixpkgs/config.nix`. For example: +A user's Nixpkgs configuration is stored in a user-specific configuration file located at `~/.config/nixpkgs/config.nix`. For example: ```nix { @@ -34,7 +26,10 @@ A user's nixpkgs configuration is stored in a user-specific configuration file l } ``` -Note that we are not able to test or build unfree software on Hydra due to policy. Most unfree licenses prohibit us from either executing or distributing the software. +:::{.caution} +Unfree software is not tested or built in Nixpkgs continuous integration, and therefore not cached. +Most unfree licenses prohibit either executing or distributing the software. +::: ## Installing broken packages {#sec-allow-broken} @@ -176,7 +171,7 @@ You can define a function called `packageOverrides` in your local `~/.config/nix ```nix { packageOverrides = pkgs: rec { - foo = pkgs.foo.override { ... }; + foo = pkgs.foo.override { /* ... */ }; }; } ``` diff --git a/doc/using/overlays.chapter.md b/doc/using/overlays.chapter.md index 1bec6586f28e..46200730f0b2 100644 --- a/doc/using/overlays.chapter.md +++ b/doc/using/overlays.chapter.md @@ -141,7 +141,7 @@ For BLAS/LAPACK switching to work correctly, all packages must depend on `blas` assert (!blas.isILP64) && (!lapack.isILP64); stdenv.mkDerivation { - ... + # ... } ``` diff --git a/doc/using/overrides.chapter.md b/doc/using/overrides.chapter.md index a1ef9afb0b69..8c6ed79076c2 100644 --- a/doc/using/overrides.chapter.md +++ b/doc/using/overrides.chapter.md @@ -13,13 +13,13 @@ It is used to override the arguments passed to a function. Example usages: ```nix -pkgs.foo.override { arg1 = val1; arg2 = val2; ... } +pkgs.foo.override { arg1 = val1; arg2 = val2; /* ... */ } ``` It's also possible to access the previous arguments. ```nix -pkgs.foo.override (previous: { arg1 = previous.arg1; ... }) +pkgs.foo.override (previous: { arg1 = previous.arg1; /* ... */ }) ``` @@ -27,13 +27,15 @@ pkgs.foo.override (previous: { arg1 = previous.arg1; ... }) ```nix import pkgs.path { overlays = [ (self: super: { foo = super.foo.override { barSupport = true ; }; - })]}; + })];} ``` ```nix -mypkg = pkgs.callPackage ./mypkg.nix { - mydep = pkgs.mydep.override { ... }; - } +{ + mypkg = pkgs.callPackage ./mypkg.nix { + mydep = pkgs.mydep.override { /* ... */ }; + }; +} ``` In the first example, `pkgs.foo` is the result of a function call with some default arguments, usually a derivation. Using `pkgs.foo.override` will call the same function with the given new arguments. @@ -45,9 +47,11 @@ The function `overrideAttrs` allows overriding the attribute set passed to a `st Example usages: ```nix -helloBar = pkgs.hello.overrideAttrs (finalAttrs: previousAttrs: { - pname = previousAttrs.pname + "-bar"; -}); +{ + helloBar = pkgs.hello.overrideAttrs (finalAttrs: previousAttrs: { + pname = previousAttrs.pname + "-bar"; + }); +} ``` In the above example, "-bar" is appended to the pname attribute, while all other attributes will be retained from the original `hello` package. @@ -61,9 +65,11 @@ If only a one-argument function is written, the argument has the meaning of `pre Function arguments can be omitted entirely if there is no need to access `previousAttrs` or `finalAttrs`. ```nix -helloWithDebug = pkgs.hello.overrideAttrs { - separateDebugInfo = true; -}; +{ + helloWithDebug = pkgs.hello.overrideAttrs { + separateDebugInfo = true; + }; +} ``` In the above example, the `separateDebugInfo` attribute is overridden to be true, thus building debug info for `helloWithDebug`. @@ -87,14 +93,16 @@ The function `overrideDerivation` creates a new derivation based on an existing Example usage: ```nix -mySed = pkgs.gnused.overrideDerivation (oldAttrs: { - name = "sed-4.2.2-pre"; - src = fetchurl { - url = "ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2"; - hash = "sha256-MxBJRcM2rYzQYwJ5XKxhXTQByvSg5jZc5cSHEZoB2IY="; - }; - patches = []; -}); +{ + mySed = pkgs.gnused.overrideDerivation (oldAttrs: { + name = "sed-4.2.2-pre"; + src = fetchurl { + url = "ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2"; + hash = "sha256-MxBJRcM2rYzQYwJ5XKxhXTQByvSg5jZc5cSHEZoB2IY="; + }; + patches = []; + }); +} ``` In the above example, the `name`, `src`, and `patches` of the derivation will be overridden, while all other attributes will be retained from the original derivation. @@ -112,8 +120,10 @@ The function `lib.makeOverridable` is used to make the result of a function easi Example usage: ```nix -f = { a, b }: { result = a+b; }; -c = lib.makeOverridable f { a = 1; b = 2; }; +{ + f = { a, b }: { result = a+b; }; + c = lib.makeOverridable f { a = 1; b = 2; }; +} ``` The variable `c` is the value of the `f` function applied with some default arguments. Hence the value of `c.result` is `3`, in this example. diff --git a/lib/attrsets.nix b/lib/attrsets.nix index de5968b95348..83f8d0f34186 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -5,7 +5,7 @@ let inherit (builtins) head length; - inherit (lib.trivial) mergeAttrs warn; + inherit (lib.trivial) isInOldestRelease mergeAttrs warn warnIf; inherit (lib.strings) concatStringsSep concatMapStringsSep escapeNixIdentifier sanitizeDerivationName; inherit (lib.lists) foldr foldl' concatMap elemAt all partition groupBy take foldl; in @@ -87,9 +87,9 @@ rec { Nix has a [has attribute operator `?`](https://nixos.org/manual/nix/stable/language/operators#has-attribute), which is sufficient for such queries, as long as the number of attributes is static. For example: ```nix - (x?a.b) == hasAttryByPath ["a" "b"] x + (x?a.b) == hasAttrByPath ["a" "b"] x # and - (x?${f p}."example.com") == hasAttryByPath [ (f p) "example.com" ] x + (x?${f p}."example.com") == hasAttrByPath [ (f p) "example.com" ] x ``` **Laws**: @@ -885,15 +885,15 @@ rec { # Type ``` - cartesianProductOfSets :: AttrSet -> [AttrSet] + cartesianProduct :: AttrSet -> [AttrSet] ``` # Examples :::{.example} - ## `lib.attrsets.cartesianProductOfSets` usage example + ## `lib.attrsets.cartesianProduct` usage example ```nix - cartesianProductOfSets { a = [ 1 2 ]; b = [ 10 20 ]; } + cartesianProduct { a = [ 1 2 ]; b = [ 10 20 ]; } => [ { a = 1; b = 10; } { a = 1; b = 20; } @@ -904,7 +904,7 @@ rec { ::: */ - cartesianProductOfSets = + cartesianProduct = attrsOfLists: foldl' (listOfAttrs: attrName: concatMap (attrs: @@ -913,6 +913,40 @@ rec { ) [{}] (attrNames attrsOfLists); + /** + Return the result of function f applied to the cartesian product of attribute set value combinations. + Equivalent to using cartesianProduct followed by map. + + # Inputs + + `f` + + : A function, given an attribute set, it returns a new value. + + `attrsOfLists` + + : Attribute set with attributes that are lists of values + + # Type + + ``` + mapCartesianProduct :: (AttrSet -> a) -> AttrSet -> [a] + ``` + + # Examples + :::{.example} + ## `lib.attrsets.mapCartesianProduct` usage example + + ```nix + mapCartesianProduct ({a, b}: "${a}-${b}") { a = [ "1" "2" ]; b = [ "3" "4" ]; } + => [ "1-3" "1-4" "2-3" "2-4" ] + ``` + + ::: + + */ + mapCartesianProduct = f: attrsOfLists: map f (cartesianProduct attrsOfLists); + /** Utility function that creates a `{name, value}` pair as expected by `builtins.listToAttrs`. @@ -1999,4 +2033,8 @@ rec { # DEPRECATED zip = warn "lib.zip is a deprecated alias of lib.zipAttrsWith." zipAttrsWith; + + # DEPRECATED + cartesianProductOfSets = warnIf (isInOldestRelease 2405) + "lib.cartesianProductOfSets is a deprecated alias of lib.cartesianProduct." cartesianProduct; } diff --git a/lib/cli.nix b/lib/cli.nix index c96d4dbb0432..fcffacb5ea99 100644 --- a/lib/cli.nix +++ b/lib/cli.nix @@ -1,43 +1,64 @@ { lib }: rec { - /* Automatically convert an attribute set to command-line options. + /** + Automatically convert an attribute set to command-line options. - This helps protect against malformed command lines and also to reduce - boilerplate related to command-line construction for simple use cases. + This helps protect against malformed command lines and also to reduce + boilerplate related to command-line construction for simple use cases. - `toGNUCommandLine` returns a list of nix strings. - `toGNUCommandLineShell` returns an escaped shell string. + `toGNUCommandLine` returns a list of nix strings. - Example: - cli.toGNUCommandLine {} { - data = builtins.toJSON { id = 0; }; - X = "PUT"; - retry = 3; - retry-delay = null; - url = [ "https://example.com/foo" "https://example.com/bar" ]; - silent = false; - verbose = true; - } - => [ - "-X" "PUT" - "--data" "{\"id\":0}" - "--retry" "3" - "--url" "https://example.com/foo" - "--url" "https://example.com/bar" - "--verbose" - ] + `toGNUCommandLineShell` returns an escaped shell string. - cli.toGNUCommandLineShell {} { - data = builtins.toJSON { id = 0; }; - X = "PUT"; - retry = 3; - retry-delay = null; - url = [ "https://example.com/foo" "https://example.com/bar" ]; - silent = false; - verbose = true; - } - => "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'"; + + # Inputs + + `options` + + : 1\. Function argument + + `attrs` + + : 2\. Function argument + + + # Examples + :::{.example} + ## `lib.cli.toGNUCommandLineShell` usage example + + ```nix + cli.toGNUCommandLine {} { + data = builtins.toJSON { id = 0; }; + X = "PUT"; + retry = 3; + retry-delay = null; + url = [ "https://example.com/foo" "https://example.com/bar" ]; + silent = false; + verbose = true; + } + => [ + "-X" "PUT" + "--data" "{\"id\":0}" + "--retry" "3" + "--url" "https://example.com/foo" + "--url" "https://example.com/bar" + "--verbose" + ] + + cli.toGNUCommandLineShell {} { + data = builtins.toJSON { id = 0; }; + X = "PUT"; + retry = 3; + retry-delay = null; + url = [ "https://example.com/foo" "https://example.com/bar" ]; + silent = false; + verbose = true; + } + => "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'"; + ``` + + ::: */ toGNUCommandLineShell = options: attrs: lib.escapeShellArgs (toGNUCommandLine options attrs); diff --git a/lib/customisation.nix b/lib/customisation.nix index 66638b63342a..0e0d79120296 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -15,42 +15,64 @@ in rec { - /* `overrideDerivation drv f` takes a derivation (i.e., the result - of a call to the builtin function `derivation`) and returns a new - derivation in which the attributes of the original are overridden - according to the function `f`. The function `f` is called with - the original derivation attributes. + /** + `overrideDerivation drv f` takes a derivation (i.e., the result + of a call to the builtin function `derivation`) and returns a new + derivation in which the attributes of the original are overridden + according to the function `f`. The function `f` is called with + the original derivation attributes. - `overrideDerivation` allows certain "ad-hoc" customisation - scenarios (e.g. in ~/.config/nixpkgs/config.nix). For instance, - if you want to "patch" the derivation returned by a package - function in Nixpkgs to build another version than what the - function itself provides. + `overrideDerivation` allows certain "ad-hoc" customisation + scenarios (e.g. in ~/.config/nixpkgs/config.nix). For instance, + if you want to "patch" the derivation returned by a package + function in Nixpkgs to build another version than what the + function itself provides. - For another application, see build-support/vm, where this - function is used to build arbitrary derivations inside a QEMU - virtual machine. + For another application, see build-support/vm, where this + function is used to build arbitrary derivations inside a QEMU + virtual machine. - Note that in order to preserve evaluation errors, the new derivation's - outPath depends on the old one's, which means that this function cannot - be used in circular situations when the old derivation also depends on the - new one. + Note that in order to preserve evaluation errors, the new derivation's + outPath depends on the old one's, which means that this function cannot + be used in circular situations when the old derivation also depends on the + new one. - You should in general prefer `drv.overrideAttrs` over this function; - see the nixpkgs manual for more information on overriding. + You should in general prefer `drv.overrideAttrs` over this function; + see the nixpkgs manual for more information on overriding. - Example: - mySed = overrideDerivation pkgs.gnused (oldAttrs: { - name = "sed-4.2.2-pre"; - src = fetchurl { - url = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2; - hash = "sha256-MxBJRcM2rYzQYwJ5XKxhXTQByvSg5jZc5cSHEZoB2IY="; - }; - patches = []; - }); - Type: - overrideDerivation :: Derivation -> ( Derivation -> AttrSet ) -> Derivation + # Inputs + + `drv` + + : 1\. Function argument + + `f` + + : 2\. Function argument + + # Type + + ``` + overrideDerivation :: Derivation -> ( Derivation -> AttrSet ) -> Derivation + ``` + + # Examples + :::{.example} + ## `lib.customisation.overrideDerivation` usage example + + ```nix + mySed = overrideDerivation pkgs.gnused (oldAttrs: { + name = "sed-4.2.2-pre"; + src = fetchurl { + url = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2; + hash = "sha256-MxBJRcM2rYzQYwJ5XKxhXTQByvSg5jZc5cSHEZoB2IY="; + }; + patches = []; + }); + ``` + + ::: */ overrideDerivation = drv: f: let @@ -67,26 +89,44 @@ rec { }); - /* `makeOverridable` takes a function from attribute set to attribute set and - injects `override` attribute which can be used to override arguments of - the function. + /** + `makeOverridable` takes a function from attribute set to attribute set and + injects `override` attribute which can be used to override arguments of + the function. - Please refer to documentation on [`.overrideDerivation`](#sec-pkg-overrideDerivation) to learn about `overrideDerivation` and caveats - related to its use. + Please refer to documentation on [`.overrideDerivation`](#sec-pkg-overrideDerivation) to learn about `overrideDerivation` and caveats + related to its use. - Example: - nix-repl> x = {a, b}: { result = a + b; } - nix-repl> y = lib.makeOverridable x { a = 1; b = 2; } + # Inputs - nix-repl> y - { override = «lambda»; overrideDerivation = «lambda»; result = 3; } + `f` - nix-repl> y.override { a = 10; } - { override = «lambda»; overrideDerivation = «lambda»; result = 12; } + : 1\. Function argument - Type: - makeOverridable :: (AttrSet -> a) -> AttrSet -> a + # Type + + ``` + makeOverridable :: (AttrSet -> a) -> AttrSet -> a + ``` + + # Examples + :::{.example} + ## `lib.customisation.makeOverridable` usage example + + ```nix + nix-repl> x = {a, b}: { result = a + b; } + + nix-repl> y = lib.makeOverridable x { a = 1; b = 2; } + + nix-repl> y + { override = «lambda»; overrideDerivation = «lambda»; result = 3; } + + nix-repl> y.override { a = 10; } + { override = «lambda»; overrideDerivation = «lambda»; result = 12; } + ``` + + ::: */ makeOverridable = f: let @@ -120,7 +160,8 @@ rec { else result); - /* Call the package function in the file `fn` with the required + /** + Call the package function in the file `fn` with the required arguments automatically. The function is called with the arguments `args`, but any missing arguments are obtained from `autoArgs`. This function is intended to be partially @@ -147,8 +188,26 @@ rec { - Type: - callPackageWith :: AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a + + # Inputs + + `autoArgs` + + : 1\. Function argument + + `fn` + + : 2\. Function argument + + `args` + + : 3\. Function argument + + # Type + + ``` + callPackageWith :: AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a + ``` */ callPackageWith = autoArgs: fn: args: let @@ -210,12 +269,31 @@ rec { else abort "lib.customisation.callPackageWith: ${error}"; - /* Like callPackage, but for a function that returns an attribute - set of derivations. The override function is added to the - individual attributes. + /** + Like callPackage, but for a function that returns an attribute + set of derivations. The override function is added to the + individual attributes. - Type: - callPackagesWith :: AttrSet -> ((AttrSet -> AttrSet) | Path) -> AttrSet -> AttrSet + + # Inputs + + `autoArgs` + + : 1\. Function argument + + `fn` + + : 2\. Function argument + + `args` + + : 3\. Function argument + + # Type + + ``` + callPackagesWith :: AttrSet -> ((AttrSet -> AttrSet) | Path) -> AttrSet -> AttrSet + ``` */ callPackagesWith = autoArgs: fn: args: let @@ -233,11 +311,30 @@ rec { else mapAttrs mkAttrOverridable pkgs; - /* Add attributes to each output of a derivation without changing - the derivation itself and check a given condition when evaluating. + /** + Add attributes to each output of a derivation without changing + the derivation itself and check a given condition when evaluating. - Type: - extendDerivation :: Bool -> Any -> Derivation -> Derivation + + # Inputs + + `condition` + + : 1\. Function argument + + `passthru` + + : 2\. Function argument + + `drv` + + : 3\. Function argument + + # Type + + ``` + extendDerivation :: Bool -> Any -> Derivation -> Derivation + ``` */ extendDerivation = condition: passthru: drv: let @@ -269,13 +366,24 @@ rec { outPath = assert condition; drv.outPath; }; - /* Strip a derivation of all non-essential attributes, returning - only those needed by hydra-eval-jobs. Also strictly evaluate the - result to ensure that there are no thunks kept alive to prevent - garbage collection. + /** + Strip a derivation of all non-essential attributes, returning + only those needed by hydra-eval-jobs. Also strictly evaluate the + result to ensure that there are no thunks kept alive to prevent + garbage collection. - Type: - hydraJob :: (Derivation | Null) -> (Derivation | Null) + + # Inputs + + `drv` + + : 1\. Function argument + + # Type + + ``` + hydraJob :: (Derivation | Null) -> (Derivation | Null) + ``` */ hydraJob = drv: let @@ -443,32 +551,65 @@ rec { }; in self; - /* backward compatibility with old uncurried form; deprecated */ + /** + backward compatibility with old uncurried form; deprecated + + + # Inputs + + `splicePackages` + + : 1\. Function argument + + `newScope` + + : 2\. Function argument + + `otherSplices` + + : 3\. Function argument + + `keep` + + : 4\. Function argument + + `extra` + + : 5\. Function argument + + `f` + + : 6\. Function argument + */ makeScopeWithSplicing = splicePackages: newScope: otherSplices: keep: extra: f: makeScopeWithSplicing' { inherit splicePackages newScope; } { inherit otherSplices keep extra f; }; - /* Like makeScope, but aims to support cross compilation. It's still ugly, but - hopefully it helps a little bit. + /** + Like makeScope, but aims to support cross compilation. It's still ugly, but + hopefully it helps a little bit. - Type: - makeScopeWithSplicing' :: - { splicePackages :: Splice -> AttrSet - , newScope :: AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a - } - -> { otherSplices :: Splice, keep :: AttrSet -> AttrSet, extra :: AttrSet -> AttrSet } - -> AttrSet + # Type - Splice :: - { pkgsBuildBuild :: AttrSet - , pkgsBuildHost :: AttrSet - , pkgsBuildTarget :: AttrSet - , pkgsHostHost :: AttrSet - , pkgsHostTarget :: AttrSet - , pkgsTargetTarget :: AttrSet - } + ``` + makeScopeWithSplicing' :: + { splicePackages :: Splice -> AttrSet + , newScope :: AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a + } + -> { otherSplices :: Splice, keep :: AttrSet -> AttrSet, extra :: AttrSet -> AttrSet } + -> AttrSet + + Splice :: + { pkgsBuildBuild :: AttrSet + , pkgsBuildHost :: AttrSet + , pkgsBuildTarget :: AttrSet + , pkgsHostHost :: AttrSet + , pkgsHostTarget :: AttrSet + , pkgsTargetTarget :: AttrSet + } + ``` */ makeScopeWithSplicing' = { splicePackages diff --git a/lib/default.nix b/lib/default.nix index 668c29640f9f..d5d47defb8e6 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -47,7 +47,7 @@ let # misc asserts = callLibs ./asserts.nix; debug = callLibs ./debug.nix; - misc = callLibs ./deprecated.nix; + misc = callLibs ./deprecated/misc.nix; # domain-specific fetchers = callLibs ./fetchers.nix; @@ -69,7 +69,7 @@ let hasAttr head isAttrs isBool isInt isList isPath isString length lessThan listToAttrs pathExists readFile replaceStrings seq stringLength sub substring tail trace; - inherit (self.trivial) id const pipe concat or and bitAnd bitOr bitXor + inherit (self.trivial) id const pipe concat or and xor bitAnd bitOr bitXor bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max importJSON importTOML warn warnIf warnIfNot throwIf throwIfNot checkListOfEnum info showWarnings nixpkgsVersion version isInOldestRelease @@ -86,10 +86,10 @@ let zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil recursiveUpdate matchAttrs mergeAttrsList overrideExisting showAttrPath getOutput getBin getLib getDev getMan chooseDevOutputs zipWithNames zip - recurseIntoAttrs dontRecurseIntoAttrs cartesianProductOfSets - updateManyAttrsByPath; + recurseIntoAttrs dontRecurseIntoAttrs cartesianProduct cartesianProductOfSets + mapCartesianProduct updateManyAttrsByPath; inherit (self.lists) singleton forEach foldr fold foldl foldl' imap0 imap1 - concatMap flatten remove findSingle findFirst any all count + ifilter0 concatMap flatten remove findSingle findFirst any all count optional optionals toList range replicate partition zipListsWith zipLists reverseList listDfs toposort sort sortOn naturalSort compareLists take drop sublist last init crossLists unique allUnique intersectLists @@ -97,7 +97,7 @@ let inherit (self.strings) concatStrings concatMapStrings concatImapStrings intersperse concatStringsSep concatMapStringsSep concatImapStringsSep concatLines makeSearchPath makeSearchPathOutput - makeLibraryPath makeBinPath optionalString + makeLibraryPath makeIncludePath makeBinPath optionalString hasInfix hasPrefix hasSuffix stringToCharacters stringAsChars escape escapeShellArg escapeShellArgs isStorePath isStringLike @@ -128,7 +128,7 @@ let canCleanSource pathIsGitRepo; inherit (self.modules) evalModules setDefaultModuleLocation unifyModuleSyntax applyModuleArgsIfFunction mergeModules - mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions + mergeModules' mergeOptionDecls mergeDefinitions pushDownProperties dischargeProperties filterOverrides sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride mkOptionDefault mkDefault mkImageMediaOverride mkForce mkVMOverride @@ -138,6 +138,7 @@ let mkMergedOptionModule mkChangedOptionModule mkAliasOptionModule mkDerivedConfig doRename mkAliasOptionModuleMD; + evalOptionValue = lib.warn "External use of `lib.evalOptionValue` is deprecated. If your use case isn't covered by non-deprecated functions, we'd like to know more and perhaps support your use case well, instead of providing access to these low level functions. In this case please open an issue in https://github.com/nixos/nixpkgs/issues/." self.modules.evalOptionValue; inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption getValues getFiles diff --git a/lib/deprecated/README.md b/lib/deprecated/README.md new file mode 100644 index 000000000000..afeb34d449f5 --- /dev/null +++ b/lib/deprecated/README.md @@ -0,0 +1,11 @@ + +# lib/deprecated + +Do not add any new functions to this directory. + +This directory contains the `lib.misc` sublibrary, which - as a location - is deprecated. +Furthermore, some of the functions inside are of *dubious* utility, and should perhaps be avoided, +while some functions *may still be needed*. + +This directory does not play a role in the deprecation process for library functions. +They should be deprecated in place, by putting a `lib.warn` or `lib.warnIf` call around the function. diff --git a/lib/deprecated.nix b/lib/deprecated/misc.nix similarity index 98% rename from lib/deprecated.nix rename to lib/deprecated/misc.nix index b76622b5d842..d556bccbec0b 100644 --- a/lib/deprecated.nix +++ b/lib/deprecated/misc.nix @@ -314,12 +314,13 @@ let else if isInt x then "int" else "string"; - /* deprecated: + /** + # Deprecated - For historical reasons, imap has an index starting at 1. + For historical reasons, imap has an index starting at 1. - But for consistency with the rest of the library we want an index - starting at zero. + But for consistency with the rest of the library we want an index + starting at zero. */ imap = imap1; diff --git a/lib/fileset/default.nix b/lib/fileset/default.nix index ce9afc796a3f..e29f30251c69 100644 --- a/lib/fileset/default.nix +++ b/lib/fileset/default.nix @@ -1,5 +1,5 @@ /* - + []{#sec-fileset} The [`lib.fileset`](#sec-functions-library-fileset) library allows you to work with _file sets_. diff --git a/lib/kernel.nix b/lib/kernel.nix index 7391f9e5d079..d03d0103a678 100644 --- a/lib/kernel.nix +++ b/lib/kernel.nix @@ -16,9 +16,8 @@ in unset = { tristate = null; optional = false; }; freeform = x: { freeform = x; optional = false; }; - /* - Common patterns/legacy used in common-config/hardened/config.nix - */ + + # Common patterns/legacy used in common-config/hardened/config.nix whenHelpers = version: { whenAtLeast = ver: mkIf (versionAtLeast version ver); whenOlder = ver: mkIf (versionOlder version ver); diff --git a/lib/licenses.nix b/lib/licenses.nix index 4cda7e5c01a3..49c7a4a353ec 100644 --- a/lib/licenses.nix +++ b/lib/licenses.nix @@ -93,12 +93,12 @@ in mkLicense lset) ({ url = "https://aomedia.org/license/patent-license/"; }; - apsl10 = { + apple-psl10 = { spdxId = "APSL-1.0"; fullName = "Apple Public Source License 1.0"; }; - apsl20 = { + apple-psl20 = { spdxId = "APSL-2.0"; fullName = "Apple Public Source License 2.0"; }; @@ -392,6 +392,12 @@ in mkLicense lset) ({ fullName = "Common Public Attribution License 1.0"; }; + commons-clause = { + fullName = "Commons Clause License"; + url = "https://commonsclause.com/"; + free = false; + }; + cpl10 = { spdxId = "CPL-1.0"; fullName = "Common Public License 1.0"; @@ -1162,6 +1168,11 @@ in mkLicense lset) ({ # channel and NixOS images. }; + unicode-30 = { + spdxId = "Unicode-3.0"; + fullName = "Unicode License v3"; + }; + unicode-dfs-2015 = { spdxId = "Unicode-DFS-2015"; fullName = "Unicode License Agreement - Data Files and Software (2015)"; @@ -1266,6 +1277,18 @@ in mkLicense lset) ({ }; } // { # TODO: remove legacy aliases + apsl10 = { + # deprecated for consistency with `apple-psl20`; use `apple-psl10` + spdxId = "APSL-1.0"; + fullName = "Apple Public Source License 1.0"; + deprecated = true; + }; + apsl20 = { + # deprecated due to confusion with Apache-2.0; use `apple-psl20` + spdxId = "APSL-2.0"; + fullName = "Apple Public Source License 2.0"; + deprecated = true; + }; gpl2 = { spdxId = "GPL-2.0"; fullName = "GNU General Public License v2.0"; diff --git a/lib/lists.nix b/lib/lists.nix index c162f921280d..ca436d7a9c94 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -4,7 +4,7 @@ { lib }: let inherit (lib.strings) toInt; - inherit (lib.trivial) compare min id warn; + inherit (lib.trivial) compare min id warn pipe; inherit (lib.attrsets) mapAttrs; in rec { @@ -333,6 +333,54 @@ rec { */ imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list); + /** + Filter a list for elements that satisfy a predicate function. + The predicate function is called with both the index and value for each element. + It must return `true`/`false` to include/exclude a given element in the result. + This function is strict in the result of the predicate function for each element. + This function has O(n) complexity. + + Also see [`builtins.filter`](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-filter) (available as `lib.lists.filter`), + which can be used instead when the index isn't needed. + + # Inputs + + `ipred` + + : The predicate function, it takes two arguments: + - 1. (int): the index of the element. + - 2. (a): the value of the element. + + It must return `true`/`false` to include/exclude a given element from the result. + + `list` + + : The list to filter using the predicate. + + # Type + ``` + ifilter0 :: (int -> a -> bool) -> [a] -> [a] + ``` + + # Examples + :::{.example} + ## `lib.lists.ifilter0` usage example + + ```nix + ifilter0 (i: v: i == 0 || v > 2) [ 1 2 3 ] + => [ 1 3 ] + ``` + ::: + */ + ifilter0 = + ipred: + input: + map (idx: elemAt input idx) ( + filter (idx: ipred idx (elemAt input idx)) ( + genList (x: x) (length input) + ) + ); + /** Map and concatenate the result. @@ -1688,16 +1736,32 @@ rec { ## `lib.lists.crossLists` usage example ```nix - crossLists (x:y: "${toString x}${toString y}") [[1 2] [3 4]] + crossLists (x: y: "${toString x}${toString y}") [[1 2] [3 4]] => [ "13" "14" "23" "24" ] ``` + The following function call is equivalent to the one deprecated above: + + ```nix + mapCartesianProduct (x: "${toString x.a}${toString x.b}") { a = [1 2]; b = [3 4]; } + => [ "13" "14" "23" "24" ] + ``` ::: */ crossLists = warn - "lib.crossLists is deprecated, use lib.cartesianProductOfSets instead." - (f: foldl (fs: args: concatMap (f: map f args) fs) [f]); + ''lib.crossLists is deprecated, use lib.mapCartesianProduct instead. + For example, the following function call: + + nix-repl> lib.crossLists (x: y: x+y) [[1 2] [3 4]] + [ 4 5 5 6 ] + + Can now be replaced by the following one: + + nix-repl> lib.mapCartesianProduct ({x,y}: x+y) { x = [1 2]; y = [3 4]; } + [ 4 5 5 6 ] + '' + (f: foldl (fs: args: concatMap (f: map f args) fs) [f]); /** Remove duplicate elements from the `list`. O(n^2) complexity. diff --git a/lib/modules.nix b/lib/modules.nix index 61964d466781..79892f50c4fe 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -136,7 +136,7 @@ let # TODO: Change the type of this option to a submodule with a # freeformType, so that individual arguments can be documented # separately - description = lib.mdDoc '' + description = '' Additional arguments passed to each module in addition to ones like `lib`, `config`, and `pkgs`, `modulesPath`. @@ -187,14 +187,14 @@ let type = types.bool; internal = true; default = true; - description = lib.mdDoc "Whether to check whether all option definitions have matching declarations."; + description = "Whether to check whether all option definitions have matching declarations."; }; _module.freeformType = mkOption { type = types.nullOr types.optionType; internal = true; default = null; - description = lib.mdDoc '' + description = '' If set, merge all definitions that don't have an associated option together using this type. The result then gets combined with the values of all declared options to produce the final ` @@ -209,7 +209,7 @@ let _module.specialArgs = mkOption { readOnly = true; internal = true; - description = lib.mdDoc '' + description = '' Externally provided module arguments that can't be modified from within a configuration, but can be used in module imports. ''; @@ -1378,7 +1378,6 @@ let inherit applyModuleArgsIfFunction dischargeProperties - evalOptionValue mergeModules mergeModules' pushDownProperties @@ -1399,6 +1398,7 @@ private // defaultPriority doRename evalModules + evalOptionValue # for use by lib.types filterOverrides filterOverrides' fixMergeModules diff --git a/lib/options.nix b/lib/options.nix index 0d1d90efe217..7e64e6e510fb 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -400,9 +400,11 @@ rec { literalExample = lib.warn "lib.literalExample is deprecated, use lib.literalExpression instead, or use lib.literalMD for a non-Nix description." literalExpression; /* Transition marker for documentation that's already migrated to markdown - syntax. This is a no-op and no longer needed. + syntax. Has been a no-op for some while and been removed from nixpkgs. + Kept here to alert downstream users who may not be aware of the migration's + completion that it should be removed from modules. */ - mdDoc = lib.id; + mdDoc = lib.warn "lib.mdDoc will be removed from nixpkgs in 24.11. Option descriptions are now in Markdown by default; you can remove any remaining uses of lib.mdDoc."; /* For use in the `defaultText` and `example` option attributes. Causes the given MD text to be inserted verbatim in the documentation, for when diff --git a/lib/strings.nix b/lib/strings.nix index 32efc9bdb70e..67bb669d04e0 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -206,6 +206,18 @@ rec { */ makeLibraryPath = makeSearchPathOutput "lib" "lib"; + /* Construct an include search path (such as C_INCLUDE_PATH) containing the + header files for a set of packages or paths. + + Example: + makeIncludePath [ "/usr" "/usr/local" ] + => "/usr/include:/usr/local/include" + pkgs = import { } + makeIncludePath [ pkgs.openssl pkgs.zlib ] + => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-dev/include:/nix/store/wwh7mhwh269sfjkm6k5665b5kgp7jrk2-zlib-1.2.8-dev/include" + */ + makeIncludePath = makeSearchPathOutput "dev" "include"; + /* Construct a binary search path (such as $PATH) containing the binaries for a set of packages. diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 6137d47e91a2..7e9aadeef72e 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -1,7 +1,25 @@ { lib }: - let inherit (lib.attrsets) mapAttrs; in -rec { +let + inherit (lib) + any + filterAttrs + foldl + hasInfix + isFunction + isList + isString + mapAttrs + optional + optionalAttrs + optionalString + removeSuffix + replaceStrings + toUpper + ; + + inherit (lib.strings) toJSON; + doubles = import ./doubles.nix { inherit lib; }; parse = import ./parse.nix { inherit lib; }; inspect = import ./inspect.nix { inherit lib; }; @@ -9,7 +27,7 @@ rec { examples = import ./examples.nix { inherit lib; }; architectures = import ./architectures.nix { inherit lib; }; - /* + /** Elaborated systems contain functions, which means that they don't satisfy `==` for a lack of reflexivity. @@ -24,13 +42,16 @@ rec { both arguments have been `elaborate`-d. */ equals = - let removeFunctions = a: lib.filterAttrs (_: v: !builtins.isFunction v) a; + let removeFunctions = a: filterAttrs (_: v: !isFunction v) a; in a: b: removeFunctions a == removeFunctions b; - /* List of all Nix system doubles the nixpkgs flake will expose the package set - for. All systems listed here must be supported by nixpkgs as `localSystem`. + /** + List of all Nix system doubles the nixpkgs flake will expose the package set + for. All systems listed here must be supported by nixpkgs as `localSystem`. - **Warning**: This attribute is considered experimental and is subject to change. + :::{.warning} + This attribute is considered experimental and is subject to change. + ::: */ flakeExposed = import ./flake-systems.nix { }; @@ -41,7 +62,7 @@ rec { # clearly preferred, and to prevent cycles. A simpler fixed point where the RHS # always just used `final.*` would fail on both counts. elaborate = args': let - args = if lib.isString args' then { system = args'; } + args = if isString args' then { system = args'; } else args'; # TODO: deprecate args.rustc in favour of args.rust after 23.05 is EOL. @@ -96,7 +117,7 @@ rec { then "lib64" else "lib" else null; - extensions = lib.optionalAttrs final.hasSharedLibraries { + extensions = optionalAttrs final.hasSharedLibraries { sharedLibrary = if final.isDarwin then ".dylib" else if final.isWindows then ".dll" @@ -134,9 +155,9 @@ rec { # uname -m processor = if final.isPower64 - then "ppc64${lib.optionalString final.isLittleEndian "le"}" + then "ppc64${optionalString final.isLittleEndian "le"}" else if final.isPower - then "ppc${lib.optionalString final.isLittleEndian "le"}" + then "ppc${optionalString final.isLittleEndian "le"}" else if final.isMips64 then "mips64" # endianness is *not* included on mips64 else final.parsed.cpu.name; @@ -202,8 +223,8 @@ rec { else if final.isS390 && !final.isS390x then null else if final.isx86_64 then "x86_64" else if final.isx86 then "i386" - else if final.isMips64n32 then "mipsn32${lib.optionalString final.isLittleEndian "el"}" - else if final.isMips64 then "mips64${lib.optionalString final.isLittleEndian "el"}" + else if final.isMips64n32 then "mipsn32${optionalString final.isLittleEndian "el"}" + else if final.isMips64 then "mips64${optionalString final.isLittleEndian "el"}" else final.uname.processor; # Name used by UEFI for architectures. @@ -243,10 +264,14 @@ rec { vncSupport = false; gtkSupport = false; sdlSupport = false; + alsaSupport = false; pulseSupport = false; pipewireSupport = false; + jackSupport = false; smbdSupport = false; seccompSupport = false; + tpmSupport = false; + capstoneSupport = false; enableDocs = false; hostCpuTargets = [ "${final.qemuArch}-linux-user" ]; }; @@ -255,7 +280,7 @@ rec { if pkgs.stdenv.hostPlatform.canExecute final then "${pkgs.runtimeShell} -c '\"$@\"' --" else if final.isWindows - then "${wine}/bin/wine${lib.optionalString (final.parsed.cpu.bits == 64) "64"}" + then "${wine}/bin/wine${optionalString (final.parsed.cpu.bits == 64) "64"}" else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux && final.qemuArch != null then "${qemu-user}/bin/qemu-${final.qemuArch}" else if final.isWasi @@ -306,10 +331,10 @@ rec { let f = args.rustc.platform.target-family; in - if builtins.isList f then f else [ f ] + if isList f then f else [ f ] ) - else lib.optional final.isUnix "unix" - ++ lib.optional final.isWindows "windows"; + else optional final.isUnix "unix" + ++ optional final.isWindows "windows"; # https://doc.rust-lang.org/reference/conditional-compilation.html#target_vendor vendor = let @@ -333,13 +358,13 @@ rec { vendor_ = final.rust.platform.vendor; # TODO: deprecate args.rustc in favour of args.rust after 23.05 is EOL. in args.rust.rustcTarget or args.rustc.config - or "${cpu_}-${vendor_}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}"; + or "${cpu_}-${vendor_}-${kernel.name}${optionalString (abi.name != "unknown") "-${abi.name}"}"; # The name of the rust target if it is standard, or the json file # containing the custom target spec. rustcTargetSpec = rust.rustcTargetSpec or ( /**/ if rust ? platform - then builtins.toFile (final.rust.rustcTarget + ".json") (builtins.toJSON rust.platform) + then builtins.toFile (final.rust.rustcTarget + ".json") (toJSON rust.platform) else final.rust.rustcTarget); # The name of the rust target if it is standard, or the @@ -348,7 +373,7 @@ rec { # # This is the name used by Cargo for target subdirectories. cargoShortTarget = - lib.removeSuffix ".json" (baseNameOf "${final.rust.rustcTargetSpec}"); + removeSuffix ".json" (baseNameOf "${final.rust.rustcTargetSpec}"); # When used as part of an environment variable name, triples are # uppercased and have all hyphens replaced by underscores: @@ -356,17 +381,17 @@ rec { # https://github.com/rust-lang/cargo/pull/9169 # https://github.com/rust-lang/cargo/issues/8285#issuecomment-634202431 cargoEnvVarTarget = - lib.strings.replaceStrings ["-"] ["_"] - (lib.strings.toUpper final.rust.cargoShortTarget); + replaceStrings ["-"] ["_"] + (toUpper final.rust.cargoShortTarget); # True if the target is no_std # https://github.com/rust-lang/rust/blob/2e44c17c12cec45b6a682b1e53a04ac5b5fcc9d2/src/bootstrap/config.rs#L415-L421 isNoStdTarget = - builtins.any (t: lib.hasInfix t final.rust.rustcTarget) ["-none" "nvptx" "switch" "-uefi"]; + any (t: hasInfix t final.rust.rustcTarget) ["-none" "nvptx" "switch" "-uefi"]; }; }; in assert final.useAndroidPrebuilt -> final.isAndroid; - assert lib.foldl + assert foldl (pass: { assertion, message }: if assertion final then pass @@ -374,4 +399,20 @@ rec { true (final.parsed.abi.assertions or []); final; + +in + +# Everything in this attrset is the public interface of the file. +{ + inherit + architectures + doubles + elaborate + equals + examples + flakeExposed + inspect + parse + platforms + ; } diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 75578b974945..b16445eadfea 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -235,6 +235,11 @@ rec { libc = "newlib"; }; + microblaze-embedded = { + config = "microblazeel-none-elf"; + libc = "newlib"; + }; + # # Redox # diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index c6a33781ae28..ebc7ab366876 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -1,10 +1,31 @@ { lib }: -with import ./parse.nix { inherit lib; }; -with lib.attrsets; -with lib.lists; -let abis_ = abis; in -let abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) abis_; in +let + inherit (lib) + any + attrValues + concatMap + filter + hasPrefix + isList + mapAttrs + matchAttrs + recursiveUpdateUntil + toList + ; + + inherit (lib.strings) toJSON; + + inherit (lib.systems.parse) + kernels + kernelFamilies + significantBytes + cpuTypes + execFormats + ; + + abis = mapAttrs (_: abi: removeAttrs abi [ "assertions" ]) lib.systems.parse.abis; +in rec { # these patterns are to be matched against {host,build,target}Platform.parsed @@ -32,8 +53,8 @@ rec { isx86 = { cpu = { family = "x86"; }; }; isAarch32 = { cpu = { family = "arm"; bits = 32; }; }; isArmv7 = map ({ arch, ... }: { cpu = { inherit arch; }; }) - (lib.filter (cpu: lib.hasPrefix "armv7" cpu.arch or "") - (lib.attrValues cpuTypes)); + (filter (cpu: hasPrefix "armv7" cpu.arch or "") + (attrValues cpuTypes)); isAarch64 = { cpu = { family = "arm"; bits = 64; }; }; isAarch = { cpu = { family = "arm"; }; }; isMicroBlaze = { cpu = { family = "microblaze"; }; }; @@ -111,19 +132,19 @@ rec { let # patterns can be either a list or a (bare) singleton; turn # them into singletons for uniform handling - pat1 = lib.toList pat1_; - pat2 = lib.toList pat2_; + pat1 = toList pat1_; + pat2 = toList pat2_; in - lib.concatMap (attr1: + concatMap (attr1: map (attr2: - lib.recursiveUpdateUntil + recursiveUpdateUntil (path: subattr1: subattr2: if (builtins.intersectAttrs subattr1 subattr2) == {} || subattr1 == subattr2 then true else throw '' pattern conflict at path ${toString path}: - ${builtins.toJSON subattr1} - ${builtins.toJSON subattr2} + ${toJSON subattr1} + ${toJSON subattr2} '') attr1 attr2 @@ -132,7 +153,7 @@ rec { pat1; matchAnyAttrs = patterns: - if builtins.isList patterns then attrs: any (pattern: matchAttrs pattern attrs) patterns + if isList patterns then attrs: any (pattern: matchAttrs pattern attrs) patterns else matchAttrs patterns; predicates = mapAttrs (_: matchAnyAttrs) patterns; diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index b69ad669e187..191e9734b879 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -15,14 +15,45 @@ # systems that overlap with existing ones and won't notice something amiss. # { lib }: -with lib.lists; -with lib.types; -with lib.attrsets; -with lib.strings; -with (import ./inspect.nix { inherit lib; }).predicates; let - inherit (lib.options) mergeOneOption; + inherit (lib) + all + any + attrValues + elem + elemAt + hasPrefix + id + length + mapAttrs + mergeOneOption + optionalString + splitString + versionAtLeast + ; + + inherit (lib.strings) match; + + inherit (lib.systems.inspect.predicates) + isAarch32 + isBigEndian + isDarwin + isLinux + isPower64 + isWindows + ; + + inherit (lib.types) + enum + float + isType + mkOptionType + number + setType + string + types + ; setTypes = type: mapAttrs (name: value: @@ -33,10 +64,10 @@ let # regex `e?abi.*$` when determining the validity of a triple. In # other words, `i386-linuxabichickenlips` is a valid triple. removeAbiSuffix = x: - let match = builtins.match "(.*)e?abi.*" x; - in if match==null + let found = match "(.*)e?abi.*" x; + in if found == null then x - else lib.elemAt match 0; + else elemAt found 0; in @@ -76,7 +107,7 @@ rec { types.cpuType = enum (attrValues cpuTypes); - cpuTypes = with significantBytes; setTypes types.openCpuType { + cpuTypes = let inherit (significantBytes) bigEndian littleEndian; in setTypes types.openCpuType { arm = { bits = 32; significantByte = littleEndian; family = "arm"; }; armv5tel = { bits = 32; significantByte = littleEndian; family = "arm"; version = "5"; arch = "armv5t"; }; armv6m = { bits = 32; significantByte = littleEndian; family = "arm"; version = "6"; arch = "armv6-m"; }; @@ -166,7 +197,7 @@ rec { # Note: Since 22.11 the archs of a mode switching CPU are no longer considered # pairwise compatible. Mode switching implies that binaries built for A # and B respectively can't be executed at the same time. - isCompatible = a: b: with cpuTypes; lib.any lib.id [ + isCompatible = with cpuTypes; a: b: any id [ # x86 (b == i386 && isCompatible a i486) (b == i486 && isCompatible a i586) @@ -287,7 +318,10 @@ rec { types.kernel = enum (attrValues kernels); - kernels = with execFormats; with kernelFamilies; setTypes types.openKernel { + kernels = let + inherit (execFormats) elf pe wasm unknown macho; + inherit (kernelFamilies) bsd darwin; + in setTypes types.openKernel { # TODO(@Ericson2314): Don't want to mass-rebuild yet to keeping 'darwin' as # the normalized name for macOS. macos = { execFormat = macho; families = { inherit darwin; }; name = "darwin"; }; @@ -359,7 +393,7 @@ rec { The "gnu" ABI is ambiguous on 32-bit ARM. Use "gnueabi" or "gnueabihf" instead. ''; } - { assertion = platform: with platform; !(isPower64 && isBigEndian); + { assertion = platform: !(platform.isPower64 && platform.isBigEndian); message = '' The "gnu" ABI is ambiguous on big-endian 64-bit PowerPC. Use "gnuabielfv2" or "gnuabielfv1" instead. ''; @@ -480,7 +514,7 @@ rec { /**/ if args ? abi then getAbi args.abi else if isLinux parsed || isWindows parsed then if isAarch32 parsed then - if lib.versionAtLeast (parsed.cpu.version or "0") "6" + if versionAtLeast (parsed.cpu.version or "0") "6" then abis.gnueabihf else abis.gnueabi # Default ppc64 BE to ELFv2 @@ -491,7 +525,7 @@ rec { in mkSystem parsed; - mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s)); + mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (splitString "-" s)); kernelName = kernel: kernel.name + toString (kernel.version or ""); @@ -503,10 +537,10 @@ rec { tripleFromSystem = { cpu, vendor, kernel, abi, ... } @ sys: assert isSystem sys; let optExecFormat = - lib.optionalString (kernel.name == "netbsd" && + optionalString (kernel.name == "netbsd" && gnuNetBSDDefaultExecFormat cpu != kernel.execFormat) kernel.execFormat.name; - optAbi = lib.optionalString (abi != abis.unknown) "-${abi.name}"; + optAbi = optionalString (abi != abis.unknown) "-${abi.name}"; in "${cpu.name}-${vendor.name}-${kernelName kernel}${optExecFormat}${optAbi}"; ################################################################################ diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 6f1d9039db80..6774939023d2 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -1,17 +1,21 @@ -/* -Nix evaluation tests for various lib functions. +/** + Nix evaluation tests for various lib functions. -Since these tests are implemented with Nix evaluation, error checking is limited to what `builtins.tryEval` can detect, which is `throw`'s and `abort`'s, without error messages. -If you need to test error messages or more complex evaluations, see ./modules.sh, ./sources.sh or ./filesystem.sh as examples. + Since these tests are implemented with Nix evaluation, + error checking is limited to what `builtins.tryEval` can detect, + which is `throw`'s and `abort`'s, without error messages. -To run these tests: + If you need to test error messages or more complex evaluations, see + `lib/tests/modules.sh`, `lib/tests/sources.sh` or `lib/tests/filesystem.sh` as examples. - [nixpkgs]$ nix-instantiate --eval --strict lib/tests/misc.nix + To run these tests: -If the resulting list is empty, all tests passed. -Alternatively, to run all `lib` tests: + [nixpkgs]$ nix-instantiate --eval --strict lib/tests/misc.nix - [nixpkgs]$ nix-build lib/tests/release.nix + If the resulting list is empty, all tests passed. + Alternatively, to run all `lib` tests: + + [nixpkgs]$ nix-build lib/tests/release.nix */ let @@ -29,7 +33,7 @@ let boolToString callPackagesWith callPackageWith - cartesianProductOfSets + cartesianProduct cli composeExtensions composeManyExtensions @@ -59,17 +63,20 @@ let hasAttrByPath hasInfix id + ifilter0 isStorePath lazyDerivation + length lists listToAttrs makeExtensible + makeIncludePath makeOverridable mapAttrs + mapCartesianProduct matchAttrs mergeAttrs meta - mkOption mod nameValuePair optionalDrvAttr @@ -101,6 +108,7 @@ let types updateManyAttrsByPath versions + xor ; testingThrow = expr: { @@ -111,7 +119,6 @@ let expr = (builtins.tryEval expr).success; expected = true; }; - testingDeepThrow = expr: testingThrow (builtins.deepSeq expr expr); testSanitizeDerivationName = { name, expected }: let @@ -198,10 +205,10 @@ runTests { }; /* - testOr = { - expr = or true false; - expected = true; - }; + testOr = { + expr = or true false; + expected = true; + }; */ testAnd = { @@ -209,6 +216,21 @@ runTests { expected = false; }; + testXor = { + expr = [ + (xor true false) + (xor true true) + (xor false false) + (xor false true) + ]; + expected = [ + true + false + false + true + ]; + }; + testFix = { expr = fix (x: {a = if x ? a then "a" else "b";}); expected = {a = "a";}; @@ -296,6 +318,35 @@ runTests { expected = "a\nb\nc\n"; }; + testMakeIncludePathWithPkgs = { + expr = (makeIncludePath [ + # makeIncludePath preferably selects the "dev" output + { dev.outPath = "/dev"; out.outPath = "/out"; outPath = "/default"; } + # "out" is used if "dev" is not found + { out.outPath = "/out"; outPath = "/default"; } + # And it returns the derivation directly if there's no "out" either + { outPath = "/default"; } + # Same if the output is specified explicitly, even if there's a "dev" + { dev.outPath = "/dev"; outPath = "/default"; outputSpecified = true; } + ]); + expected = "/dev/include:/out/include:/default/include:/default/include"; + }; + + testMakeIncludePathWithEmptyList = { + expr = (makeIncludePath [ ]); + expected = ""; + }; + + testMakeIncludePathWithOneString = { + expr = (makeIncludePath [ "/usr" ]); + expected = "/usr/include"; + }; + + testMakeIncludePathWithManyString = { + expr = (makeIncludePath [ "/usr" "/usr/local" ]); + expected = "/usr/include:/usr/local/include"; + }; + testReplicateString = { expr = strings.replicate 5 "hello"; expected = "hellohellohellohellohello"; @@ -602,6 +653,31 @@ runTests { expected = ["b" "c"]; }; + testIfilter0Example = { + expr = ifilter0 (i: v: i == 0 || v > 2) [ 1 2 3 ]; + expected = [ 1 3 ]; + }; + testIfilter0Empty = { + expr = ifilter0 (i: v: abort "shouldn't be evaluated!") [ ]; + expected = [ ]; + }; + testIfilter0IndexOnly = { + expr = length (ifilter0 (i: v: mod i 2 == 0) [ (throw "0") (throw "1") (throw "2") (throw "3")]); + expected = 2; + }; + testIfilter0All = { + expr = ifilter0 (i: v: true) [ 10 11 12 13 14 15 ]; + expected = [ 10 11 12 13 14 15 ]; + }; + testIfilter0First = { + expr = ifilter0 (i: v: i == 0) [ 10 11 12 13 14 15 ]; + expected = [ 10 ]; + }; + testIfilter0Last = { + expr = ifilter0 (i: v: i == 5) [ 10 11 12 13 14 15 ]; + expected = [ 15 ]; + }; + testFold = let f = op: fold: fold op 0 (range 0 100); @@ -1267,7 +1343,7 @@ runTests { ''; }; - /* right now only invocation check */ + # right now only invocation check testToJSONSimple = let val = { foobar = [ "baz" 1 2 3 ]; @@ -1278,7 +1354,7 @@ runTests { expected = builtins.toJSON val; }; - /* right now only invocation check */ + # right now only invocation check testToYAMLSimple = let val = { list = [ { one = 1; } { two = 2; } ]; @@ -1365,7 +1441,7 @@ runTests { }; testToPrettyMultiline = { - expr = mapAttrs (const (generators.toPretty { })) rec { + expr = mapAttrs (const (generators.toPretty { })) { list = [ 3 4 [ false ] ]; attrs = { foo = null; bar.foo = "baz"; }; newlinestring = "\n"; @@ -1379,7 +1455,7 @@ runTests { there test''; }; - expected = rec { + expected = { list = '' [ 3 @@ -1417,13 +1493,10 @@ runTests { expected = "«foo»"; }; - testToPlist = - let - deriv = derivation { name = "test"; builder = "/bin/sh"; system = "aarch64-linux"; }; - in { + testToPlist = { expr = mapAttrs (const (generators.toPlist { })) { value = { - nested.values = rec { + nested.values = { int = 42; float = 0.1337; bool = true; @@ -1636,17 +1709,17 @@ runTests { }; testCartesianProductOfEmptySet = { - expr = cartesianProductOfSets {}; + expr = cartesianProduct {}; expected = [ {} ]; }; testCartesianProductOfOneSet = { - expr = cartesianProductOfSets { a = [ 1 2 3 ]; }; + expr = cartesianProduct { a = [ 1 2 3 ]; }; expected = [ { a = 1; } { a = 2; } { a = 3; } ]; }; testCartesianProductOfTwoSets = { - expr = cartesianProductOfSets { a = [ 1 ]; b = [ 10 20 ]; }; + expr = cartesianProduct { a = [ 1 ]; b = [ 10 20 ]; }; expected = [ { a = 1; b = 10; } { a = 1; b = 20; } @@ -1654,12 +1727,12 @@ runTests { }; testCartesianProductOfTwoSetsWithOneEmpty = { - expr = cartesianProductOfSets { a = [ ]; b = [ 10 20 ]; }; + expr = cartesianProduct { a = [ ]; b = [ 10 20 ]; }; expected = [ ]; }; testCartesianProductOfThreeSets = { - expr = cartesianProductOfSets { + expr = cartesianProduct { a = [ 1 2 3 ]; b = [ 10 20 30 ]; c = [ 100 200 300 ]; @@ -1703,6 +1776,30 @@ runTests { ]; }; + testMapCartesianProductOfOneSet = { + expr = mapCartesianProduct ({a}: a * 2) { a = [ 1 2 3 ]; }; + expected = [ 2 4 6 ]; + }; + + testMapCartesianProductOfTwoSets = { + expr = mapCartesianProduct ({a,b}: a + b) { a = [ 1 ]; b = [ 10 20 ]; }; + expected = [ 11 21 ]; + }; + + testMapCartesianProcutOfTwoSetsWithOneEmpty = { + expr = mapCartesianProduct (x: x.a + x.b) { a = [ ]; b = [ 10 20 ]; }; + expected = [ ]; + }; + + testMapCartesianProductOfThreeSets = { + expr = mapCartesianProduct ({a,b,c}: a + b + c) { + a = [ 1 2 3 ]; + b = [ 10 20 30 ]; + c = [ 100 200 300 ]; + }; + expected = [ 111 211 311 121 221 321 131 231 331 112 212 312 122 222 322 132 232 332 113 213 313 123 223 323 133 233 333 ]; + }; + # The example from the showAttrPath documentation testShowAttrPathExample = { expr = showAttrPath [ "foo" "10" "bar" ]; diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index b3bbdf9485ac..750b1d025e02 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -103,6 +103,18 @@ checkConfigError 'The option .sub.wrong2. does not exist. Definition values:' co checkConfigError '.*This can happen if you e.g. declared your options in .types.submodule.' config.sub ./error-mkOption-in-submodule-config.nix checkConfigError '.*A definition for option .bad. is not of type .non-empty .list of .submodule...\.' config.bad ./error-nonEmptyListOf-submodule.nix +# types.attrTag +checkConfigOutput '^true$' config.okChecks ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.syntaxError. is not of type .attribute-tagged union' config.intStrings.syntaxError ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.syntaxError2. is not of type .attribute-tagged union' config.intStrings.syntaxError2 ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.syntaxError3. is not of type .attribute-tagged union' config.intStrings.syntaxError3 ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.syntaxError4. is not of type .attribute-tagged union' config.intStrings.syntaxError4 ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.mergeError. is not of type .attribute-tagged union' config.intStrings.mergeError ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.badTagError. is not of type .attribute-tagged union' config.intStrings.badTagError ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.badTagTypeError\.left. is not of type .signed integer.' config.intStrings.badTagTypeError.left ./types-attrTag.nix +checkConfigError 'A definition for option .nested\.right\.left. is not of type .signed integer.' config.nested.right.left ./types-attrTag.nix +checkConfigError 'In attrTag, each tag value must be an option, but tag int was a bare type, not wrapped in mkOption.' config.opt.int ./types-attrTag-wrong-decl.nix + # types.pathInStore checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix checkConfigOutput '".*/store/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15"' config.pathInStore.ok2 ./types.nix diff --git a/lib/tests/modules/doRename-condition.nix b/lib/tests/modules/doRename-condition.nix index c08b3035be6f..176c21a01a17 100644 --- a/lib/tests/modules/doRename-condition.nix +++ b/lib/tests/modules/doRename-condition.nix @@ -1,4 +1,4 @@ -/* +/** Simulate a migration from a single-instance `services.foo` to a multi instance `services.foos.` module, where `name = ""` serves as the legacy / compatibility instance. @@ -10,7 +10,7 @@ The relevant scenarios are tested in separate files: - ./doRename-condition-enable.nix - ./doRename-condition-no-enable.nix - */ +*/ { config, lib, ... }: let inherit (lib) mkOption mkEnableOption types doRename; diff --git a/lib/tests/modules/docs.nix b/lib/tests/modules/docs.nix new file mode 100644 index 000000000000..225aa7eac1de --- /dev/null +++ b/lib/tests/modules/docs.nix @@ -0,0 +1,41 @@ +/* + A basic documentation generating module. + Declares and defines a `docs` option, suitable for making assertions about + the extraction "phase" of documentation generation. + */ +{ lib, options, ... }: + +let + inherit (lib) + head + length + mkOption + types + ; + + traceListSeq = l: v: lib.foldl' (a: b: lib.traceSeq b a) v l; + +in + +{ + options.docs = mkOption { + type = types.lazyAttrsOf types.raw; + description = '' + All options to be rendered, without any visibility filtering applied. + ''; + }; + config.docs = + lib.zipAttrsWith + (name: values: + if length values > 1 then + traceListSeq values + abort "Multiple options with the same name: ${name}" + else + assert length values == 1; + head values + ) + (map + (opt: { ${opt.name} = opt; }) + (lib.optionAttrSetToDocList options) + ); +} diff --git a/lib/tests/modules/types-attrTag-wrong-decl.nix b/lib/tests/modules/types-attrTag-wrong-decl.nix new file mode 100644 index 000000000000..d03370bc10da --- /dev/null +++ b/lib/tests/modules/types-attrTag-wrong-decl.nix @@ -0,0 +1,14 @@ +{ lib, ... }: +let + inherit (lib) types mkOption; +in +{ + options = { + opt = mkOption { + type = types.attrTag { + int = types.int; + }; + default = { int = 1; }; + }; + }; +} diff --git a/lib/tests/modules/types-attrTag.nix b/lib/tests/modules/types-attrTag.nix new file mode 100644 index 000000000000..b2e5158bb44b --- /dev/null +++ b/lib/tests/modules/types-attrTag.nix @@ -0,0 +1,135 @@ +{ lib, config, options, ... }: +let + inherit (lib) mkOption types; + forceDeep = x: builtins.deepSeq x x; + mergedSubOption = (options.merged.type.getSubOptions options.merged.loc).extensible."merged."; +in +{ + options = { + intStrings = mkOption { + type = types.attrsOf + (types.attrTag { + left = mkOption { + type = types.int; + }; + right = mkOption { + type = types.str; + }; + }); + }; + nested = mkOption { + type = types.attrTag { + left = mkOption { + type = types.int; + }; + right = mkOption { + type = types.attrTag { + left = mkOption { + type = types.int; + }; + right = mkOption { + type = types.str; + }; + }; + }; + }; + }; + merged = mkOption { + type = types.attrsOf ( + types.attrTag { + yay = mkOption { + type = types.int; + }; + extensible = mkOption { + type = types.enum [ "foo" ]; + }; + } + ); + }; + submodules = mkOption { + type = types.attrsOf ( + types.attrTag { + foo = mkOption { + type = types.submodule { + options = { + bar = mkOption { + type = types.int; + }; + }; + }; + }; + qux = mkOption { + type = types.str; + description = "A qux for when you don't want a foo"; + }; + } + ); + }; + okChecks = mkOption {}; + }; + imports = [ + ./docs.nix + { + options.merged = mkOption { + type = types.attrsOf ( + types.attrTag { + nay = mkOption { + type = types.bool; + }; + extensible = mkOption { + type = types.enum [ "bar" ]; + }; + } + ); + }; + } + ]; + config = { + intStrings.syntaxError = 1; + intStrings.syntaxError2 = {}; + intStrings.syntaxError3 = { a = true; b = true; }; + intStrings.syntaxError4 = lib.mkMerge [ { a = true; } { b = true; } ]; + intStrings.mergeError = lib.mkMerge [ { int = throw "do not eval"; } { string = throw "do not eval"; } ]; + intStrings.badTagError.rite = throw "do not eval"; + intStrings.badTagTypeError.left = "bad"; + intStrings.numberOne.left = 1; + intStrings.hello.right = "hello world"; + nested.right.left = "not a number"; + merged.negative.nay = false; + merged.positive.yay = 100; + merged.extensi-foo.extensible = "foo"; + merged.extensi-bar.extensible = "bar"; + okChecks = builtins.addErrorContext "while evaluating the assertions" ( + assert config.intStrings.hello == { right = "hello world"; }; + assert config.intStrings.numberOne == { left = 1; }; + assert config.merged.negative == { nay = false; }; + assert config.merged.positive == { yay = 100; }; + assert config.merged.extensi-foo == { extensible = "foo"; }; + assert config.merged.extensi-bar == { extensible = "bar"; }; + assert config.docs."submodules..foo.bar".type == "signed integer"; + assert config.docs."submodules..qux".type == "string"; + assert config.docs."submodules..qux".declarations == [ __curPos.file ]; + assert config.docs."submodules..qux".loc == [ "submodules" "" "qux" ]; + assert config.docs."submodules..qux".name == "submodules..qux"; + assert config.docs."submodules..qux".description == "A qux for when you don't want a foo"; + assert config.docs."submodules..qux".readOnly == false; + assert config.docs."submodules..qux".visible == true; + # Not available (yet?) + # assert config.docs."submodules..qux".declarationsWithPositions == [ ... ]; + assert options.submodules.declarations == [ __curPos.file ]; + assert lib.length options.submodules.declarationPositions == 1; + assert (lib.head options.submodules.declarationPositions).file == __curPos.file; + assert options.merged.declarations == [ __curPos.file __curPos.file ]; + assert lib.length options.merged.declarationPositions == 2; + assert (lib.elemAt options.merged.declarationPositions 0).file == __curPos.file; + assert (lib.elemAt options.merged.declarationPositions 1).file == __curPos.file; + assert (lib.elemAt options.merged.declarationPositions 0).line != (lib.elemAt options.merged.declarationPositions 1).line; + assert mergedSubOption.declarations == [ __curPos.file __curPos.file ]; + assert lib.length mergedSubOption.declarationPositions == 2; + assert (lib.elemAt mergedSubOption.declarationPositions 0).file == __curPos.file; + assert (lib.elemAt mergedSubOption.declarationPositions 1).file == __curPos.file; + assert (lib.elemAt mergedSubOption.declarationPositions 0).line != (lib.elemAt mergedSubOption.declarationPositions 1).line; + assert lib.length config.docs."merged..extensible".declarations == 2; + true); + }; +} diff --git a/lib/trivial.nix b/lib/trivial.nix index 936ad207c03d..5b7a1ee30f7a 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -199,6 +199,24 @@ in { */ and = x: y: x && y; + /** + boolean “exclusive or” + + + # Inputs + + `x` + + : 1\. Function argument + + `y` + + : 2\. Function argument + */ + # We explicitly invert the arguments purely as a type assertion. + # This is invariant under XOR, so it does not affect the result. + xor = x: y: (!x) != (!y); + /** bitwise “not” */ diff --git a/lib/types.nix b/lib/types.nix index 12bf18633e3a..518b987dcd92 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -15,6 +15,7 @@ let isList isString isStorePath + throwIf toDerivation toList ; @@ -65,6 +66,11 @@ let fixupOptionType mergeOptionDecls ; + + inAttrPosSuffix = v: name: + let pos = builtins.unsafeGetAttrPos name v; in + if pos == null then "" else " at ${pos.file}:${toString pos.line}:${toString pos.column}"; + outer_types = rec { __attrsFailEvaluation = true; @@ -152,7 +158,7 @@ rec { # If it doesn't, this should be {} # This may be used when a value is required for `mkIf false`. This allows the extra laziness in e.g. `lazyAttrsOf`. emptyValue ? {} - , # Return a flat list of sub-options. Used to generate + , # Return a flat attrset of sub-options. Used to generate # documentation. getSubOptions ? prefix: {} , # List of modules if any, or null if none. @@ -328,15 +334,24 @@ rec { "signedInt${toString bit}" "${toString bit} bit signed integer"; in { - /* An int with a fixed range. - * - * Example: - * (ints.between 0 100).check (-1) - * => false - * (ints.between 0 100).check (101) - * => false - * (ints.between 0 0).check 0 - * => true + # TODO: Deduplicate with docs in nixos/doc/manual/development/option-types.section.md + /** + An int with a fixed range. + + # Example + :::{.example} + ## `lib.types.ints.between` usage example + + ```nix + (ints.between 0 100).check (-1) + => false + (ints.between 0 100).check (101) + => false + (ints.between 0 0).check 0 + => true + ``` + + ::: */ inherit between; @@ -614,6 +629,100 @@ rec { nestedTypes.elemType = elemType; }; + attrTag = tags: + let tags_ = tags; in + let + tags = + mapAttrs + (n: opt: + builtins.addErrorContext "while checking that attrTag tag ${lib.strings.escapeNixIdentifier n} is an option with a type${inAttrPosSuffix tags_ n}" ( + throwIf (opt._type or null != "option") + "In attrTag, each tag value must be an option, but tag ${lib.strings.escapeNixIdentifier n} ${ + if opt?_type then + if opt._type == "option-type" + then "was a bare type, not wrapped in mkOption." + else "was of type ${lib.strings.escapeNixString opt._type}." + else "was not."}" + opt // { + declarations = opt.declarations or ( + let pos = builtins.unsafeGetAttrPos n tags_; + in if pos == null then [] else [ pos.file ] + ); + declarationPositions = opt.declarationPositions or ( + let pos = builtins.unsafeGetAttrPos n tags_; + in if pos == null then [] else [ pos ] + ); + } + )) + tags_; + choicesStr = concatMapStringsSep ", " lib.strings.escapeNixIdentifier (attrNames tags); + in + mkOptionType { + name = "attrTag"; + description = "attribute-tagged union"; + descriptionClass = "noun"; + getSubOptions = prefix: + mapAttrs + (tagName: tagOption: { + "${lib.showOption prefix}" = + tagOption // { + loc = prefix ++ [ tagName ]; + }; + }) + tags; + check = v: isAttrs v && length (attrNames v) == 1 && tags?${head (attrNames v)}; + merge = loc: defs: + let + choice = head (attrNames (head defs).value); + checkedValueDefs = map + (def: + assert (length (attrNames def.value)) == 1; + if (head (attrNames def.value)) != choice + then throw "The option `${showOption loc}` is defined both as `${choice}` and `${head (attrNames def.value)}`, in ${showFiles (getFiles defs)}." + else { inherit (def) file; value = def.value.${choice}; }) + defs; + in + if tags?${choice} + then + { ${choice} = + (lib.modules.evalOptionValue + (loc ++ [choice]) + tags.${choice} + checkedValueDefs + ).value; + } + else throw "The option `${showOption loc}` is defined as ${lib.strings.escapeNixIdentifier choice}, but ${lib.strings.escapeNixIdentifier choice} is not among the valid choices (${choicesStr}). Value ${choice} was defined in ${showFiles (getFiles defs)}."; + nestedTypes = tags; + functor = defaultFunctor "attrTag" // { + type = { tags, ... }: types.attrTag tags; + payload = { inherit tags; }; + binOp = + let + # Add metadata in the format that submodules work with + wrapOptionDecl = + option: { options = option; _file = ""; pos = null; }; + in + a: b: { + tags = a.tags // b.tags // + mapAttrs + (tagName: bOpt: + lib.mergeOptionDecls + # FIXME: loc is not accurate; should include prefix + # Fortunately, it's only used for error messages, where a "relative" location is kinda ok. + # It is also returned though, but use of the attribute seems rare? + [tagName] + [ (wrapOptionDecl a.tags.${tagName}) (wrapOptionDecl bOpt) ] + // { + # mergeOptionDecls is not idempotent in these attrs: + declarations = a.tags.${tagName}.declarations ++ bOpt.declarations; + declarationPositions = a.tags.${tagName}.declarationPositions ++ bOpt.declarationPositions; + } + ) + (builtins.intersectAttrs a.tags b.tags); + }; + }; + }; + uniq = unique { message = ""; }; unique = { message }: type: mkOptionType rec { diff --git a/maintainers/README.md b/maintainers/README.md index f121ec756413..848cb9fed9b5 100644 --- a/maintainers/README.md +++ b/maintainers/README.md @@ -87,8 +87,8 @@ checks should be performed: keys = [{ fingerprint = "0000 0000 2A70 6423 0AED 3C11 F04F 7A19 AAA6 3AFE"; }]; - } - }; + }; + } ``` First receive their key from a keyserver: @@ -133,8 +133,8 @@ checks should be performed: name = "Example User"; github = "ghost"; githubId = 10137; - } - }; + }; + } ``` First, make sure that the listed GitHub handle matches the author of diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 307c33318bc9..7edf4202b1e3 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -58,6 +58,10 @@ nix-build lib/tests/maintainers.nix See `./scripts/check-maintainer-github-handles.sh` for an example on how to work with this data. + + When adding a new maintainer, be aware of the current commit conventions + documented at [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#commit-conventions) + file located in the root of the Nixpkgs repo. */ { _0b11stan = { @@ -203,6 +207,12 @@ fingerprint = "D292 365E 3C46 A5AA 75EE B30B 78DB 7EDE 3540 794B"; }]; }; + _48cf = { + name = "czapek"; + email = "czapek1337@gmail.com"; + github = "48cf"; + githubId = 32851089; + }; _6543 = { email = "6543@obermui.de"; github = "6543"; @@ -218,6 +228,12 @@ githubId = 12578560; name = "Quinn Bohner"; }; + _8aed = { + email = "8aed@riseup.net"; + github = "8aed"; + githubId = 140662578; + name = "Huit Aed"; + }; _8-bit-fox = { email = "sebastian@markwaerter.de"; github = "8-bit-fox"; @@ -256,6 +272,12 @@ githubId = 381298; name = "9R"; }; + A1ca7raz = { + email = "aya@wtm.moe"; + github = "A1ca7raz"; + githubId = 7345998; + name = "A1ca7raz"; + }; a1russell = { email = "adamlr6+pub@gmail.com"; github = "a1russell"; @@ -649,6 +671,12 @@ fingerprint = "B0D7 2955 235F 6AB5 ACFA 1619 8C7F F5BB 1ADE F191"; }]; }; + aimpizza = { + email = "rickomo.us@gmail.com"; + name = "Rick Omonsky"; + github = "AimPizza"; + githubId = 64905268; + }; aiotter = { email = "git@aiotter.com"; github = "aiotter"; @@ -772,6 +800,12 @@ githubId = 20405311; name = "Aksh Gupta"; }; + aktaboot = { + email = "akhtaboo@protonmail.com"; + github = "aktaboot"; + githubId = 120214979; + name = "aktaboot"; + }; al3xtjames = { email = "nix@alextjam.es"; github = "al3xtjames"; @@ -1052,12 +1086,6 @@ githubId = 153175; name = "Andrew Marshall"; }; - amaxine = { - email = "max@ine.dev"; - github = "amaxine"; - githubId = 35892750; - name = "Maxine Aubrey"; - }; ambroisie = { email = "bruno.nixpkgs@belanyi.fr"; github = "ambroisie"; @@ -1213,12 +1241,6 @@ githubId = 962885; name = "Andrew Chambers"; }; - andrew-d = { - email = "andrew@du.nham.ca"; - github = "andrew-d"; - githubId = 1079173; - name = "Andrew Dunham"; - }; andrewrk = { email = "superjoe30@gmail.com"; github = "andrewrk"; @@ -1231,12 +1253,6 @@ githubId = 29887; name = "Andrew Smith"; }; - andsild = { - email = "andsild@gmail.com"; - github = "andsild"; - githubId = 3808928; - name = "Anders Sildnes"; - }; andys8 = { github = "andys8"; githubId = 13085980; @@ -1330,12 +1346,6 @@ githubId = 81317317; name = "Anna Aurora"; }; - a-n-n-a-l-e-e = { - github = "a-n-n-a-l-e-e"; - githubId = 150648636; - matrix = "@a-n-n-a-l-e-e:matrix.org"; - name = "annalee"; - }; anoa = { matrix = "@andrewm:amorgan.xyz"; email = "andrew@amorgan.xyz"; @@ -1382,6 +1392,7 @@ github = "anthonyroussel"; githubId = 220084; name = "Anthony Roussel"; + matrix = "@anthonyrsl:matrix.org"; keys = [{ fingerprint = "472D 368A F107 F443 F3A5 C712 9DC4 987B 1A55 E75E"; }]; @@ -1425,6 +1436,18 @@ githubId = 4194320; name = "Anton Schirg"; }; + anytimetraveler = { + email = "simon@simonscode.org"; + github = "AnyTimeTraveler"; + githubId = 19378309; + name = "Simon Struck"; + }; + aorith = { + email = "aomanu+nixpkgs@gmail.com"; + github = "aorith"; + githubId = 5411704; + name = "Manuel Sanchez Pinar"; + }; apeschar = { email = "albert@peschar.net"; github = "apeschar"; @@ -1546,6 +1569,12 @@ githubId = 160646; name = "Patrick Jackson"; }; + arduano = { + email = "leonid.shchurov@gmail.com"; + github = "arduano"; + githubId = 13347712; + name = "Leo Shchurov"; + }; ardumont = { email = "eniotna.t@gmail.com"; github = "ardumont"; @@ -1752,10 +1781,15 @@ githubId = 11037075; name = "Ashley Hooper"; }; - ashvith-shetty = { - github = "Ashvith10"; - githubId = 113123021; - name = "Ashvith Shetty"; + ashuramaruzxc = { + email = "ashuramaru@tenjin-dk.com"; + matrix = "@tenjin:mozilla.org"; + github = "ashuramaruzxc"; + githubId = 72100551; + name = "Mariia Holovata"; + keys = [{ + fingerprint = "409D 201E 9450 8732 A49E D0FC 6BDA F874 0068 08DF"; + }]; }; asininemonkey = { email = "nixpkgs@asininemonkey.com"; @@ -1784,12 +1818,25 @@ fingerprint = "C919 E69E A7C0 E147 9E0F C26E 1EDA D0C6 70BD 062D"; }]; }; + assistant = { + email = "assistant.moetron@gmail.com"; + github = "Assistant"; + githubId = 2748721; + matrix = "@assistant:pygmalion.chat"; + name = "Assistant Moetron"; + }; astavie = { email = "astavie@pm.me"; github = "astavie"; githubId = 7745457; name = "Astavie"; }; + astindev = { + email = "astindev@pm.me"; + github = "astindev"; + githubId = 52360869; + name = "Astin"; + }; astro = { email = "astro@spaceboyz.net"; github = "astro"; @@ -1971,10 +2018,10 @@ name = "averelld"; }; avery = { - email = "averyl+nixos@protonmail.com"; - github = "AveryLychee"; - githubId = 9147625; - name = "Avery Lychee"; + email = "nixpkgs@avery.cafe"; + github = "coolavery"; + githubId = 76545554; + name = "Avery"; }; avh4 = { email = "gruen0aermel@gmail.com"; @@ -2544,6 +2591,12 @@ githubId = 34919100; name = "Brendan Hall"; }; + bhankas = { + email = "payas@relekar.org"; + github = "bhankas"; + githubId = 24254289; + name = "Payas Relekar"; + }; bhipple = { email = "bhipple@protonmail.com"; github = "bhipple"; @@ -2586,6 +2639,12 @@ githubId = 30630233; name = "Timo Triebensky"; }; + birkb = { + email = "birk@batchworks.de"; + github = "birkb"; + githubId = 10164833; + name = "Birk Bohne"; + }; bjornfor = { email = "bjorn.forsman@gmail.com"; github = "bjornfor"; @@ -2674,6 +2733,12 @@ github = "bmwalters"; githubId = 4380777; }; + bnlrnz = { + github = "bnlrnz"; + githubId = 11310385; + name = "Ben Lorenz"; + email = "bnlrnz@gmail.com"; + }; bobakker = { email = "bobakk3r@gmail.com"; github = "bobakker"; @@ -2711,6 +2776,12 @@ githubId = 150560585; name = "Dmitry Ivankov"; }; + bonsairobo = { + email = "duncanfairbanks6@gmail.com"; + github = "bonsairobo"; + githubId = 3229981; + name = "Duncan Fairbanks"; + }; booklearner = { name = "booklearner"; email = "booklearner@proton.me"; @@ -2958,6 +3029,12 @@ github = "bycEEE"; githubId = 8891115; name = "Brian Choy"; + }; + ByteSudoer = { + email = "bytesudoer@gmail.com"; + github = "bytesudoer"; + githubId = 88513682; + name = "ByteSudoer"; }; bzizou = { email = "Bruno@bzizou.net"; @@ -3217,6 +3294,12 @@ matrix = "@cawilliamson:nixos.dev"; name = "Christopher A. Williamson"; }; + cbarrete = { + github = "cbarrete"; + githubId = 62146989; + matrix = "@cedric:cbarrete.com"; + name = "Cédric Barreteau"; + }; cbleslie = { email = "cameronleslie@gmail.com"; github = "cbleslie"; @@ -3463,12 +3546,6 @@ githubId = 1118859; name = "Scott Worley"; }; - ChlorideCull = { - email = "nixrelated@chcl.se"; - github = "ChlorideCull"; - githubId = 4977063; - name = "Sebastian Johansson"; - }; choochootrain = { email = "hurshal@imap.cc"; github = "choochootrain"; @@ -3674,6 +3751,13 @@ githubId = 46303707; name = "Christian Lütke-Stetzkamp"; }; + clot27 = { + name = "Clot"; + email = "adityayadav11082@protonmail.com"; + github = "clot27"; + githubId = 69784758; + matrix = "@clot27:matrix.org"; + }; clr-cera = { email = "clrcera05@gmail.com"; github = "clr-cera"; @@ -4118,6 +4202,17 @@ githubId = 16950437; name = "cwyc"; }; + cybershadow = { + name = "Vladimir Panteleev"; + email = "nixpkgs@cy.md"; + matrix = "@cybershadow:cy.md"; + github = "CyberShadow"; + githubId = 160894; + + keys = [{ + fingerprint = "BBED 1B08 8CED 7F95 8917 FBE8 5004 F0FA D051 576D"; + }]; + }; cynerd = { name = "Karel Kočí"; email = "cynerd@email.cz"; @@ -4246,12 +4341,6 @@ githubId = 990767; name = "Daniel Olsen"; }; - danderson = { - email = "dave@natulte.net"; - github = "danderson"; - githubId = 1918; - name = "David Anderson"; - }; daneads = { email = "me@daneads.com"; github = "daneads"; @@ -4322,6 +4411,13 @@ fingerprint = "4779 D1D5 3C97 2EAE 34A5 ED3D D8AF C4BF 0567 0F9D"; }]; }; + dan-theriault = { + email = "nix@theriault.codes"; + github = "Dan-Theriault"; + githubId = 13945563; + matrix = "@dan:matrix.org"; + name = "Daniel Theriault"; + }; dariof4 = { name = "dariof4"; email = "dazedtank@gmail.com"; @@ -4335,6 +4431,12 @@ github = "DarkOnion0"; githubId = 68606322; }; + daru-san = { + name = "Daru"; + email = "zadarumaka@proton.me"; + github = "Daru-san"; + githubId = 135046711; + }; das-g = { email = "nixpkgs@raphael.dasgupta.ch"; github = "das-g"; @@ -4468,6 +4570,12 @@ githubId = 11422515; name = "David Sánchez"; }; + dav-wolff = { + email = "dav-wolff@outlook.com"; + github = "dav-wolff"; + githubId = 130931508; + name = "David Wolff"; + }; dawidd6 = { email = "dawidd0811@gmail.com"; github = "dawidd6"; @@ -4649,12 +4757,6 @@ githubId = 150736012; email = "me+git@delliott.xyz"; }; - delroth = { - email = "delroth@gmail.com"; - github = "delroth"; - githubId = 202798; - name = "Pierre Bourdon"; - }; delta = { email = "d4delta@outlook.fr"; github = "D4Delta"; @@ -4739,6 +4841,12 @@ githubId = 4956158; name = "Robin Stumm"; }; + DerRockWolf = { + email = "git@rockwolf.eu"; + github = "DerRockWolf"; + githubId = 50499906; + name = "DerRockWolf"; + }; DerTim1 = { email = "tim.digel@active-group.de"; github = "DerTim1"; @@ -4820,6 +4928,12 @@ github = "dfithian"; githubId = 8409320; }; + dflores = { + email = "dflores.country455@passinbox.com"; + name = "David Flores"; + github = "dflores1"; + githubId = 8538265; + }; dfordivam = { email = "dfordivam+nixpkgs@gmail.com"; github = "dfordivam"; @@ -4832,6 +4946,12 @@ githubId = 4708206; name = "Daniel Fox Franke"; }; + dghubble = { + email = "dghubble@gmail.com"; + github = "dghubble"; + githubId = 2253428; + name = "Dalton Hubble"; + }; dgliwka = { email = "dawid.gliwka@gmail.com"; github = "dgliwka"; @@ -4911,6 +5031,12 @@ github = "DimitarNestorov"; githubId = 8790386; }; + diniamo = { + name = "diniamo"; + email = "diniamo53@gmail.com"; + github = "diniamo"; + githubId = 55629891; + }; diogotcorreia = { name = "Diogo Correia"; email = "me@diogotc.com"; @@ -5199,6 +5325,12 @@ fingerprint = "D245 D484 F357 8CB1 7FD6 DA6B 67DB 29BF F3C9 6757"; }]; }; + dragonginger = { + email = "dragonginger10@gmail.com"; + github = "dragonginger10"; + githubId = 20759788; + name = "JP Lippold"; + }; dramaturg = { email = "seb@ds.ag"; github = "dramaturg"; @@ -5293,6 +5425,12 @@ fingerprint = "389A 78CB CD88 5E0C 4701 DEB9 FD42 C7D0 D414 94C8"; }]; }; + dudymas = { + email = "jeremy.white@cloudposse.com"; + github = "dudymas"; + githubId = 928448; + name = "Jeremy White"; + }; dukc = { email = "ajieskola@gmail.com"; github = "dukc"; @@ -5336,6 +5474,12 @@ githubId = 6689924; name = "David Terry"; }; + dylan-gonzalez = { + email = "dylcg10@gmail.com"; + github = "dylan-gonzalez"; + githubId = 45161987; + name = "Dylan Gonzalez"; + }; dylanmtaylor = { email = "dylan@dylanmtaylor.com"; github = "dylanmtaylor"; @@ -5423,6 +5567,7 @@ name = "Florentin Eckl"; }; eclairevoyant = { + email = "contactmeongithubinstead@proton.me"; github = "eclairevoyant"; githubId = 848000; name = "éclairevoyant"; @@ -5695,6 +5840,12 @@ githubId = 122112154; name = "Edgar Lee"; }; + elrohirgt = { + email = "elrohirgt@gmail.com"; + github = "ElrohirGT"; + githubId = 45268815; + name = "Flavio Galán"; + }; elvishjerricco = { email = "elvishjerricco@gmail.com"; matrix = "@elvishjerricco:matrix.org"; @@ -5783,12 +5934,6 @@ name = "Zhenbo Li"; matrix = "@zhenbo:matrix.org"; }; - endocrimes = { - email = "dani@builds.terrible.systems"; - github = "endocrimes"; - githubId = 1330683; - name = "Danielle Lancashire"; - }; enorris = { name = "Eric Norris"; email = "erictnorris@gmail.com"; @@ -5812,6 +5957,13 @@ githubId = 418227; name = "Jean-Philippe Braun"; }; + eopb = { + email = "ethanboxx@gmail.com"; + github = "eopb"; + githubId = 8074468; + matrix = "@efun:matrix.org"; + name = "Ethan Brierley"; + }; eownerdead = { name = "EOWNERDEAD"; email = "eownerdead@disroot.org"; @@ -6186,7 +6338,7 @@ }; eymeric = { name = "Eymeric Dechelette"; - email = "hatchchcien@protonmail.com"; + email = "hatchchien@protonmail.com"; github = "hatch01"; githubId = 42416805; }; @@ -6293,6 +6445,12 @@ githubId = 4246921; name = "Florian Beeres"; }; + fccapria = { + email = "francesco@capria.eu"; + github = "fccapria"; + githubId = 62179193; + name = "Francesco Carmelo Capria"; + }; fd = { email = "simon.menke@gmail.com"; github = "fd"; @@ -6305,16 +6463,6 @@ githubId = 541748; name = "Felipe Espinoza"; }; - federicoschonborn = { - name = "Federico Damián Schonborn"; - email = "federicoschonborn@disroot.org"; - github = "FedericoSchonborn"; - githubId = 62166915; - matrix = "@FedericoDSchonborn:matrix.org"; - keys = [ - { fingerprint = "C43F 4052 D289 3B73 33F8 0259 E4F6 F544 DE9E 29E8"; } - ]; - }; fedx-sudo = { email = "fedx-sudo@pm.me"; github = "FedX-sudo"; @@ -6384,6 +6532,12 @@ githubId = 5198058; name = "Udo Sauer"; }; + ferrine = { + email = "justferres@yandex.ru"; + github = "ferrine"; + githubId = 11705326; + name = "Max Kochurov"; + }; ffinkdevs = { email = "fink@h0st.space"; github = "ffinkdevs"; @@ -6547,12 +6701,6 @@ githubId = 5918766; name = "Franz Thoma"; }; - fogti = { - name = "Alain Fogtia Zscheile"; - email = "fogti+devel@ytrizja.de"; - github = "fogti"; - githubId = 1618343; - }; foo-dogsquared = { email = "foodogsquared@foodogsquared.one"; github = "foo-dogsquared"; @@ -6782,6 +6930,15 @@ githubId = 21362942; name = "Fugi"; }; + funkeleinhorn = { + email = "git@funkeleinhorn.com"; + github = "funkeleinhorn"; + githubId = 103313934; + name = "Funkeleinhorn"; + keys = [{ + fingerprint = "689D 1C81 DA0D 1EB2 F029 D24E C7BE A25A 0A33 5A72"; + }]; + }; fusion809 = { email = "brentonhorne77@gmail.com"; github = "fusion809"; @@ -6866,6 +7023,15 @@ githubId = 1313787; name = "Gabriella Gonzalez"; }; + gabyx = { + email = "gnuetzi@gmail.com"; + github = "gabyx"; + githubId = 647437; + name = "Gabriel Nützi"; + keys = [{ + fingerprint = "90AE CCB9 7AD3 4CE4 3AED 9402 E969 172A B075 7EB8"; + }]; + }; gador = { email = "florian.brandes@posteo.de"; github = "gador"; @@ -6996,6 +7162,12 @@ githubId = 40209356; name = "Gabriel Doriath Döhler"; }; + gdifolco = { + email = "gautier.difolco@gmail.com"; + github = "blackheaven"; + githubId = 1362807; + name = "Gautier Di Folco"; + }; gdinh = { email = "nix@contact.dinh.ai"; github = "gdinh"; @@ -7176,18 +7348,18 @@ githubId = 104317939; name = "gilice"; }; - gilligan = { - email = "tobias.pflug@gmail.com"; - github = "gilligan"; - githubId = 27668; - name = "Tobias Pflug"; - }; gin66 = { email = "jochen@kiemes.de"; github = "gin66"; githubId = 5549373; name = "Jochen Kiemes"; }; + giodamelio = { + name = "Giovanni d'Amelio"; + email = "gio@damelio.net"; + github = "giodamelio"; + githubId = 441646; + }; giogadi = { email = "lgtorres42@gmail.com"; github = "giogadi"; @@ -7446,6 +7618,13 @@ githubId = 201997; name = "Eric Seidel"; }; + grimmauld = { + name = "Sören Bender"; + email = "soeren@benjos.de"; + github = "LordGrimmauld"; + githubId = 49513131; + matrix = "@grimmauld:grimmauld.de"; + }; grindhold = { name = "grindhold"; email = "grindhold+nix@skarphed.org"; @@ -7600,6 +7779,12 @@ githubId = 22756350; name = "Emile Hansmaennel"; }; + HannahMR = { + name = "Hannah Rosenberg"; + email = "hannah@velascommerce.com"; + github = "HannahMR"; + githubId = 9088467; + }; hansjoergschurr = { email = "commits@schurr.at"; github = "hansjoergschurr"; @@ -7775,6 +7960,12 @@ matrix = "@chris:netsoj.nl"; name = "Chris Josten"; }; + hennk = { + email = "henning.kiel@gmail.com"; + github = "hennk"; + githubId = 328259; + name = "Henning Kiel"; + }; henrikolsson = { email = "henrik@fixme.se"; github = "henrikolsson"; @@ -8226,6 +8417,12 @@ github = "Icy-Thought"; githubId = 53710398; }; + id3v1669 = { + name = "id3v1669"; + email = "id3v1669@gmail.com"; + github = "id3v1669"; + githubId = 57532211; + }; idlip = { name = "Dilip"; email = "igoldlip@gmail.com"; @@ -8384,6 +8581,12 @@ fingerprint = "F5B2 BE1B 9AAD 98FE 2916 5597 3665 FFF7 9D38 7BAA"; }]; }; + imrying = { + email = "philiprying@gmail.com"; + github = "imrying"; + githubId = 36996706; + name = "Philip Rying"; + }; imuli = { email = "i@imu.li"; github = "imuli"; @@ -8500,6 +8703,12 @@ githubId = 137306; name = "Michele Catalano"; }; + isabelroses = { + email = "isabel@isabelroses.com"; + github = "isabelroses"; + githubId = 71222764; + name = "Isabel Roses"; + }; isaozler = { email = "isaozler@gmail.com"; github = "isaozler"; @@ -8641,12 +8850,33 @@ github = "j0xaf"; githubId = 932697; }; + j1nxie = { + email = "rylie@rylie.moe"; + name = "Nguyen Pham Quoc An"; + github = "j1nxie"; + githubId = 52886388; + }; j4m3s = { name = "James Landrein"; email = "github@j4m3s.eu"; github = "j4m3s-s"; githubId = 9413812; }; + ja1den = { + name = "Jaiden Douglas"; + email = "contact@ja1den.me"; + github = "ja1den"; + githubId = 49811314; + keys = [{ + fingerprint = "CC36 4CF4 32DD 443F 27FC 033C 3475 AA20 D72F 6A93"; + }]; + }; + jab = { + name = "Joshua Bronson"; + email = "jabronson@gmail.com"; + github = "jab"; + githubId = 64992; + }; jacbart = { name = "Jack Bartlett"; email = "jacbart@gmail.com"; @@ -8864,6 +9094,12 @@ github = "joshua-cooper"; githubId = 35612334; }; + jcaesar = { + name = "Julius Michaelis"; + matrix = "@julius:mtx.liftm.de"; + github = "jcaesar"; + githubId = 1753388; + }; jceb = { name = "Jan Christoph Ebersbach"; email = "jceb@e-jc.de"; @@ -9033,6 +9269,12 @@ githubId = 1667473; name = "Jethro Kuan"; }; + jetpackjackson = { + email = "baileyannew@tutanota.com"; + github = "JetpackJackson"; + githubId = 88674707; + name = "Bailey Watkins"; + }; jevy = { email = "jevin@quickjack.ca"; github = "jevy"; @@ -9451,6 +9693,12 @@ githubId = 51028009; name = "John Rodewald"; }; + johnrtitor = { + email = "masumrezarock100@gmail.com"; + github = "johnrtitor"; + githubId = 50095635; + name = "Masum Reza"; + }; john-shaffer = { email = "jdsha@proton.me"; github = "john-shaffer"; @@ -9524,6 +9772,12 @@ githubId = 1843676; name = "Jonathan Reeve"; }; + jonboh = { + email = "jon.bosque.hernando@gmail.com"; + github = "jonboh"; + githubId = 31407988; + name = "Jon Bosque"; + }; jonnybolton = { email = "jonnybolton@gmail.com"; github = "jonnynightingale"; @@ -9604,6 +9858,11 @@ github = "jpagex"; githubId = 635768; }; + jpaju = { + name = "Jaakko Paju"; + github = "jpaju"; + githubId = 36770267; + }; jpas = { name = "Jarrod Pas"; email = "jarrod@jarrodpas.com"; @@ -9950,6 +10209,11 @@ githubId = 6544084; name = "Kai Harries"; }; + kai-tub = { + name = "Kai Norman Clasen"; + github = "kai-tub"; + githubId = 46302524; + }; kalbasit = { email = "wael.nasreddine@gmail.com"; matrix = "@kalbasit:matrix.org"; @@ -10030,6 +10294,11 @@ githubId = 15855440; name = "Keanu Ashwell"; }; + katanallama = { + github = "katanallama"; + githubId = 70604257; + name = "katanallama"; + }; katexochen = { github = "katexochen"; githubId = 49727155; @@ -10078,15 +10347,6 @@ github = "keenanweaver"; githubId = 37268985; }; - keksbg = { - email = "keksbg@riseup.net"; - name = "Stella"; - github = "keksbg"; - githubId = 10682187; - keys = [{ - fingerprint = "AB42 1F18 5A19 A160 AD77 9885 3D6D CA5B 6F2C 2A7A"; - }]; - }; keldu = { email = "mail@keldu.de"; github = "keldu"; @@ -10244,6 +10504,12 @@ githubId = 845652; name = "Kier Davis"; }; + kiike = { + email = "me@enric.me"; + github = "kiike"; + githubId = 464625; + name = "Enric Morales"; + }; kilianar = { email = "mail@kilianar.de"; github = "kilianar"; @@ -10298,6 +10564,12 @@ githubId = 691290; name = "Keshav Kini"; }; + kintrix = { + email = "kintrix007@proton.me"; + github = "kintrix007"; + githubId = 60898798; + name = "kintrix"; + }; kinzoku = { email = "kinzokudev4869@gmail.com"; github = "kinzoku-dev"; @@ -10521,6 +10793,12 @@ githubId = 2037002; name = "Konstantinos"; }; + kotatsuyaki = { + email = "kotatsuyaki@mail.kotatsu.dev"; + github = "kotatsuyaki"; + githubId = 17219127; + name = "kotatsuyaki"; + }; kouyk = { email = "skykinetic@stevenkou.xyz"; github = "kouyk"; @@ -10752,6 +11030,12 @@ }]; name = "Yaroslav Bolyukin"; }; + lachrymal = { + email = "lachrymalfutura@gmail.com"; + name = "lachrymaL"; + github = "lachrymaLF"; + githubId = 13716477; + }; lafrenierejm = { email = "joseph@lafreniere.xyz"; github = "lafrenierejm"; @@ -10790,6 +11074,12 @@ githubId = 695526; name = "Benjamin Kober"; }; + lampros = { + email = "hauahx@gmail.com"; + github = "LamprosPitsillos"; + githubId = 61395246; + name = "Lampros Pitsillos"; + }; larsr = { email = "Lars.Rasmusson@gmail.com"; github = "larsr"; @@ -11148,6 +11438,12 @@ fingerprint = "92D8 A09D 03DD B774 AABD 53B9 E136 2F07 D750 DB5C"; }]; }; + lilacious = { + email = "yuchenhe126@gmail.com"; + github = "Lilacious"; + githubId = 101508537; + name = "Yuchen He"; + }; lillycham = { email = "lillycat332@gmail.com"; github = "lillycat332"; @@ -11189,6 +11485,13 @@ fingerprint = "80EE AAD8 43F9 3097 24B5 3D7E 27E9 7B91 E63A 7FF8"; }]; }; + link2xt = { + email = "link2xt@testrun.org"; + githubId = 18373967; + github = "link2xt"; + matrix = "@link2xt:matrix.org"; + name = "link2xt"; + }; linquize = { email = "linquize@yahoo.com.hk"; github = "linquize"; @@ -11293,12 +11596,6 @@ githubId = 918448; name = "Anthony Lodi"; }; - loewenheim = { - email = "loewenheim@mailbox.org"; - github = "loewenheim"; - githubId = 7622248; - name = "Sebastian Zivota"; - }; logo = { email = "logo4poop@protonmail.com"; matrix = "@logo4poop:matrix.org"; @@ -11328,6 +11625,12 @@ github = "LongerHV"; githubId = 46924944; }; + lonyelon = { + email = "sergio@lony.xyz"; + name = "Sergio Miguéns Iglesias"; + github = "lonyelon"; + githubId = 18664655; + }; lopsided98 = { email = "benwolsieffer@gmail.com"; github = "lopsided98"; @@ -11466,6 +11769,15 @@ githubId = 3717454; name = "Lucas Bergman"; }; + lucas-deangelis = { + email = "deangelis.lucas@outlook.com"; + github = "lucas-deangelis"; + githubId = 55180995; + name = "Lucas De Angelis"; + keys = [{ + fingerprint = "3C8B D3AD 93BB 1F36 B8FF 30BD 8627 E5ED F74B 5BF4"; + }]; + }; lucasew = { email = "lucas59356@gmail.com"; github = "lucasew"; @@ -11532,12 +11844,6 @@ githubId = 5767106; name = "Lukas Schmidt"; }; - luis = { - email = "luis.nixos@gmail.com"; - github = "Luis-Hebendanz"; - githubId = 22085373; - name = "Luis Hebendanz"; - }; luisdaranda = { email = "luisdomingoaranda@gmail.com"; github = "propet"; @@ -11582,6 +11888,12 @@ githubId = 30468956; name = "Lukas Heiligenbrunner"; }; + lukaslihotzki = { + email = "lukas@lihotzki.de"; + github = "lukaslihotzki"; + githubId = 10326063; + name = "Lukas Lihotzki"; + }; lukaswrz = { email = "lukas@wrz.one"; github = "lukaswrz"; @@ -12022,10 +12334,11 @@ githubId = 26470037; name = "Markus Kowalewski"; }; - marsam = { - github = "marsam"; - githubId = 65531; - name = "Mario Rodas"; + marmolak = { + email = "hack.robin@gmail.com"; + github = "marmolak"; + githubId = 1709273; + name = "Robin Hack"; }; marsupialgutz = { email = "mars@possums.xyz"; @@ -12464,6 +12777,12 @@ fingerprint = "D709 03C8 0BE9 ACDC 14F0 3BFB 77BF E531 397E DE94"; }]; }; + mdorman = { + email = "mdorman@jaunder.io"; + github = "mdorman"; + githubId = 333344; + name = "Michael Alan Dorman"; + }; mdr = { email = "MattRussellUK@gmail.com"; github = "mdr"; @@ -12495,6 +12814,12 @@ githubId = 1631737; name = "Mikhail Medvedev"; }; + meebey = { + email = "meebey@meebey.net"; + github = "meebey"; + githubId = 318066; + name = "Mirco Bauer"; + }; megheaiulian = { email = "iulian.meghea@gmail.com"; github = "megheaiulian"; @@ -12537,6 +12862,15 @@ githubId = 15093162; name = "Melanie B. Sigl"; }; + melvyn2 = { + email = "melvyn2@dnsense.pub"; + github = "melvyn2"; + githubId = 9157412; + name = "melvyn"; + keys = [{ + fingerprint = "232B 9F00 2153 CA86 849C 9224 25A2 B728 0CE3 AFF6"; + }]; + }; mephistophiles = { email = "mussitantesmortem@gmail.com"; name = "Maxim Zhukov"; @@ -13033,6 +13367,12 @@ fingerprint = "E90C BA34 55B3 6236 740C 038F 0D94 8CE1 9CF4 9C5F"; }]; }; + mksafavi = { + name = "MK Safavi"; + email = "mksafavi@gmail.com"; + github = "mksafavi"; + githubId = 50653293; + }; mktip = { email = "mo.issa.ok+nix@gmail.com"; github = "mktip"; @@ -13042,6 +13382,12 @@ fingerprint = "64BE BF11 96C3 DD7A 443E 8314 1DC0 82FA DE5B A863"; }]; }; + mlaradji = { + name = "Mohamed Laradji"; + email = "mlaradji@pm.me"; + github = "mlaradji"; + githubId = 33703663; + }; mlatus = { email = "wqseleven@gmail.com"; github = "Ninlives"; @@ -13181,6 +13527,12 @@ githubId = 830082; name = "Nathan Moos"; }; + moraxyc = { + name = "Moraxyc Xu"; + email = "nix@qaq.li"; + github = "Moraxyc"; + githubId = 69713071; + }; moredread = { email = "code@apb.name"; github = "Moredread"; @@ -13230,12 +13582,6 @@ githubId = 20026143; name = "Katona László"; }; - MP2E = { - email = "MP2E@archlinux.us"; - github = "MP2E"; - githubId = 167708; - name = "Cray Elliott"; - }; mpcsh = { email = "m@mpc.sh"; github = "mpcsh"; @@ -13351,15 +13697,6 @@ githubId = 3856390; email = "mschwaig+nixpkgs@eml.cc"; }; - msfjarvis = { - github = "msfjarvis"; - githubId = 13348378; - name = "Harsh Shandilya"; - email = "nixos@msfjarvis.dev"; - keys = [{ - fingerprint = "8F87 050B 0F9C B841 1515 7399 B784 3F82 3355 E9B9"; - }]; - }; msiedlarek = { email = "mikolaj@siedlarek.pl"; github = "msiedlarek"; @@ -13569,6 +13906,14 @@ fingerprint = "9E6A 25F2 C1F2 9D76 ED00 1932 1261 173A 01E1 0298"; }]; }; + n8henrie = { + name = "Nathan Henrie"; + github = "n8henrie"; + githubId = 1234956; + "keys" = [{ + "fingerprint" = "F21A 6194 C9DB 9899 CD09 E24E 434B 2C14 B8C3 3422"; + }]; + }; nadir-ishiguro = { github = "nadir-ishiguro"; githubId = 23151917; @@ -13680,6 +14025,10 @@ githubId = 56316606; name = "Amneesh Singh"; }; + nayala = { + name = "Nia"; + matrix = "@fly:asra.gr"; + }; nazarewk = { name = "Krzysztof Nazarewski"; matrix = "@nazarewk:matrix.org"; @@ -14159,6 +14508,12 @@ githubId = 6930756; name = "Nicolas Mattia"; }; + noaccos = { + name = "Francesco Noacco"; + email = "francesco.noacco2000@gmail.com"; + github = "noaccOS"; + githubId = 24324352; + }; nobbz = { name = "Norbert Melzer"; email = "timmelzer+nixpkgs@gmail.com"; @@ -14177,6 +14532,12 @@ githubId = 42322511; name = "Patryk Kwiatek"; }; + nokazn = { + email = "me@nokazn.me"; + github = "nokazn"; + githubId = 41154684; + name = "nokazn"; + }; nomeata = { email = "mail@joachim-breitner.de"; github = "nomeata"; @@ -14255,12 +14616,6 @@ githubId = 126072875; name = "nova madeline"; }; - novenary = { - email = "streetwalkermc@gmail.com"; - github = "9ary"; - githubId = 1155030; - name = "novenary"; - }; novoxd = { email = "radnovox@gmail.com"; github = "novoxd"; @@ -14385,6 +14740,12 @@ githubId = 16027994; name = "Nathan Viets"; }; + nyadiia = { + email = "nyadiia@pm.me"; + github = "nyadiia"; + githubId = 43252360; + name = "Nadia"; + }; nyanbinary = { email = "nyanbinary@keemail.me"; matrix = "@niko:conduit.rs"; @@ -14410,6 +14771,12 @@ githubId = 127548; name = "Judson Lester"; }; + nyawox = { + name = "nyawox"; + email = "nyawox.git@gmail.com"; + github = "nyawox"; + githubId = 93813719; + }; nzbr = { email = "nixos@nzbr.de"; github = "nzbr"; @@ -14514,6 +14881,12 @@ githubId = 7249506; name = "oida"; }; + ok-nick = { + email = "nick.libraries@gmail.com"; + github = "ok-nick"; + githubId = 25470747; + name = "Nick"; + }; olcai = { email = "dev@timan.info"; github = "olcai"; @@ -14623,6 +14996,12 @@ github = "ony"; githubId = 11265; }; + oo-infty = { + name = "Justin Chen"; + email = "oo-infty@outlook.com"; + github = "oo-infty"; + githubId = 42143810; + }; ooliver1 = { name = "Oliver Wilkes"; email = "oliverwilkes2006@icloud.com"; @@ -14927,12 +15306,6 @@ githubId = 72527881; name = "PassiveLemon"; }; - patka = { - email = "patka@patka.dev"; - github = "patka-123"; - githubId = 69802930; - name = "patka"; - }; patricksjackson = { email = "patrick@jackson.dev"; github = "patricksjackson"; @@ -14989,12 +15362,6 @@ githubId = 116740; name = "Paweł Pacana"; }; - payas = { - email = "relekarpayas@gmail.com"; - github = "bhankas"; - githubId = 24254289; - name = "Payas Relekar"; - }; pb- = { email = "pbaecher@gmail.com"; github = "pb-"; @@ -15017,6 +15384,12 @@ fingerprint = "E005 48D5 D6AC 812C AAD2 AFFA 9C42 B05E 5913 60DC"; }]; }; + pbeucher = { + email = "pierre@crafteo.io"; + github = "PierreBeucher"; + githubId = 5041481; + name = "Pierre Beucher"; + }; pblkt = { email = "pebblekite@gmail.com"; github = "pblkt"; @@ -15066,6 +15439,12 @@ githubId = 1368952; name = "Pedro Lara Campos"; }; + peefy = { + email = "xpf6677@gmail.com"; + github = "Peefy"; + githubId = 22744597; + name = "Peefy"; + }; peelz = { email = "peelz.dev+nixpkgs@gmail.com"; github = "notpeelz"; @@ -15198,6 +15577,12 @@ fingerprint = "7756 E88F 3C6A 47A5 C5F0 CDFB AB54 6777 F93E 20BF"; }]; }; + phdyellow = { + name = "Phil Dyer"; + email = "phildyer@protonmail.com"; + github = "PhDyellow"; + githubId = 7740661; + }; phfroidmont = { name = "Paul-Henri Froidmont"; email = "nix.contact-j9dw4d@froidmont.org"; @@ -15623,6 +16008,12 @@ githubId = 4201956; name = "pongo1231"; }; + poptart = { + email = "poptart@hosakacorp.net"; + github = "terrorbyte"; + githubId = 1601039; + name = "Cale Black"; + }; portothree = { name = "Gustavo Porto"; email = "gus@p8s.co"; @@ -15916,6 +16307,12 @@ githubId = 5636; name = "Steve Purcell"; }; + purrpurrn = { + email = "scrcpynovideoaudiocodecraw+nixpkgs@gmail.com"; + github = "purrpurrn"; + githubId = 142632643; + name = "purrpurrn"; + }; putchar = { email = "slim.cadoux@gmail.com"; matrix = "@putch4r:matrix.org"; @@ -15941,6 +16338,16 @@ githubId = 4579165; name = "Danny Bautista"; }; + pyrox0 = { + name = "Pyrox"; + email = "pyrox@pyrox.dev"; + matrix = "@pyrox:pyrox.dev"; + github = "pyrox0"; + githubId = 35778371; + keys = [{ + fingerprint = "4CA9 72FB ADC8 1416 0F10 3138 FE1D 8A7D 620C 611F"; + }]; + }; pyxels = { email = "pyxels.dev@gmail.com"; github = "Pyxels"; @@ -16006,6 +16413,12 @@ matrix = "@quantenzitrone:matrix.org"; name = "quantenzitrone"; }; + qubasa = { + email = "consulting@qube.email"; + github = "Qubasa"; + githubId = 22085373; + name = "Luis Hebendanz"; + }; queezle = { email = "git@queezle.net"; github = "queezle42"; @@ -16039,6 +16452,12 @@ githubId = 39039420; name = "Quinn Dougherty"; }; + qusic = { + email = "qusicx@gmail.com"; + github = "Qusic"; + githubId = 2141853; + name = "Bang Lee"; + }; qyliss = { email = "hi@alyssa.is"; github = "alyssais"; @@ -16049,6 +16468,13 @@ fingerprint = "7573 56D7 79BB B888 773E 415E 736C CDF9 EF51 BD97"; }]; }; + qyriad = { + email = "qyriad@qyriad.me"; + github = "Qyriad"; + githubId = 1542224; + matrix = "@qyriad:katesiria.org"; + name = "Qyriad"; + }; r3dl3g = { email = "redleg@rothfuss-web.de"; github = "r3dl3g"; @@ -16148,6 +16574,15 @@ githubId = 104558; name = "Benjamin Saunders"; }; + ramblurr = { + name = "Casey Link"; + email = "nix@caseylink.com"; + github = "Ramblurr"; + githubId = 14830; + keys = [{ + fingerprint = "978C 4D08 058B A26E B97C B518 2078 2DBC ACFA ACDA"; + }]; + }; ramkromberg = { email = "ramkromberg@mail.com"; github = "RamKromberg"; @@ -16232,12 +16667,24 @@ githubId = 25647735; name = "Victor Freire"; }; + ravenz46 = { + email = "goldraven0406@gmail.com"; + github = "RAVENz46"; + githubId = 86608952; + name = "RAVENz46"; + }; rawkode = { email = "david.andrew.mckay@gmail.com"; github = "rawkode"; githubId = 145816; name = "David McKay"; }; + raylas = { + email = "r@raymond.sh"; + github = "raylas"; + githubId = 8099415; + name = "Raymond Douglas"; + }; rayslash = { email = "stevemathewjoy@tutanota.com"; github = "rayslash"; @@ -16480,6 +16927,13 @@ githubId = 12279531; name = "Ricardo Guevara"; }; + rhelmot = { + name = "Audrey Dutcher"; + github = "rhelmot"; + githubId = 2498805; + email = "audrey@rhelmot.io"; + matrix = "@rhelmot:matrix.org"; + }; rhendric = { name = "Ryan Hendrickson"; github = "rhendric"; @@ -16516,6 +16970,11 @@ githubId = 61013287; name = "Ricardo Steijn"; }; + richar = { + github = "ri-char"; + githubId = 17962023; + name = "richar"; + }; richardipsum = { email = "richardipsum@fastmail.co.uk"; github = "richardipsum"; @@ -16565,6 +17024,12 @@ githubId = 37246692; name = "Riley Inman"; }; + rinx = { + email = "rintaro.okamura@gmail.com"; + github = "rinx"; + githubId = 1588935; + name = "Rintaro Okamura"; + }; riotbib = { email = "lennart@cope.cool"; github = "riotbib"; @@ -16898,6 +17363,17 @@ github = "rski"; githubId = 2960312; }; + rsniezek = { + email = "radoslaw.sniezek@protonmail.com"; + github = "rsniezek"; + githubId = 19433256; + name = "Radoslaw Sniezek"; + }; + rster2002 = { + name = "Bjørn"; + github = "rster2002"; + githubId = 26026518; + }; rsynnest = { email = "contact@rsynnest.com"; github = "rsynnest"; @@ -16990,6 +17466,12 @@ githubId = 2660; name = "Russell Sim"; }; + rutherther = { + name = "Rutherther"; + email = "rutherther@proton.me"; + github = "rutherther"; + githubId = 12197024; + }; ruuda = { email = "dev+nix@veniogames.com"; github = "ruuda"; @@ -17281,6 +17763,12 @@ githubId = 92817635; name = "Sanskar Gurdasani"; }; + sarahec = { + email = "seclark@nextquestion.net"; + github = "sarahec"; + githubId = 11277967; + name = "Sarah Clark"; + }; sarcasticadmin = { email = "rob@sarcasticadmin.com"; github = "sarcasticadmin"; @@ -17521,6 +18009,17 @@ fingerprint = "0AF6 4C3B 1F12 14B3 8C8C 5786 1FA2 DBE6 7438 7CC3"; }]; }; + sebrut = { + email = "kontakt@sebastian-rutofski.de"; + github = "sebrut"; + githubId = 3962409; + name = "Sebastian Rutofski"; + keys = [ + { + fingerprint = "F1D4 8061 2830 3AF6 42DC 3867 C37F 3374 2A95 C547"; + } + ]; + }; sebtm = { email = "mail@sebastian-sellmeier.de"; github = "SebTM"; @@ -17636,6 +18135,11 @@ githubId = 863807; name = "Serge Guelton"; }; + sergioribera = { + github = "SergioRibera"; + githubId = 56278796; + name = "Sergio Ribera"; + }; sersorrel = { email = "ash@sorrel.sh"; github = "sersorrel"; @@ -17951,6 +18455,16 @@ github = "silky"; githubId = 129525; }; + sils = { + name = "Silas Schöffel"; + email = "sils@sils.li"; + matrix = "@sils:vhack.eu"; + github = "s1ls"; + githubId = 91412114; + keys = [{ + fingerprint = "C1DA A551 B422 7A6F 3FD9 6B3A 467B 7D12 9EA7 3AC9"; + }]; + }; Silver-Golden = { name = "Brendan Golden"; email = "github+nixpkgs@brendan.ie"; @@ -18369,6 +18883,12 @@ githubId = 20756843; name = "Sofi"; }; + soyouzpanda = { + name = "soyouzpanda"; + email = "soyouzpanda@soyouzpanda.fr"; + github = "soyouzpanda"; + githubId = 23421201; + }; soywod = { name = "Clément DOUIN"; email = "clement.douin@posteo.net"; @@ -18433,6 +18953,21 @@ githubId = 950799; name = "Tomasz Czyż"; }; + spitulax = { + name = "Bintang Adiputra Pratama"; + email = "bintangadiputrapratama@gmail.com"; + github = "spitulax"; + githubId = 96517350; + keys = [{ + fingerprint = "652F FAAD 5CB8 AF1D 3F96 9521 929E D6C4 0414 D3F5"; + }]; + }; + spk = { + email = "laurent@spkdev.net"; + github = "spk"; + githubId = 98590; + name = "Laurent Arnoud"; + }; spoonbaker = { github = "Spoonbaker"; githubId = 47164123; @@ -18462,12 +18997,6 @@ githubId = 16364318; name = "Jeffrey Harmon"; }; - srapenne = { - email = "solene@perso.pw"; - github = "rapenne-s"; - githubId = 248016; - name = "Solène Rapenne"; - }; srghma = { email = "srghma@gmail.com"; github = "srghma"; @@ -18538,11 +19067,17 @@ githubId = 6362238; name = "Christoph Honal"; }; - star-szr = { - email = "nixpkgs@szr.fastmail.com"; - github = "star-szr"; - githubId = 327943; - name = "Scott Zhu Reeves"; + starkca90 = { + email = "starkca90@gmail.com"; + github = "starkca90"; + githubId = 2060836; + name = "Casey Stark"; + }; + starsep = { + email = "nix@starsep.com"; + github = "starsep"; + githubId = 2798728; + name = "Filip Czaplicki"; }; starzation = { email = "nixpkgs@starzation.net"; @@ -18612,6 +19147,15 @@ githubId = 89950; name = "Stéphan Kochen"; }; + stephen-huan = { + name = "Stephen Huan"; + email = "stephen.huan@cgdct.moe"; + github = "stephen-huan"; + githubId = 20411956; + keys = [{ + fingerprint = "EA6E 2794 8C7D BF5D 0DF0 85A1 0FBC 2E3B A99D D60E"; + }]; + }; stephenmw = { email = "stephen@q5comm.com"; github = "stephenmw"; @@ -18748,6 +19292,16 @@ githubId = 39732259; name = "Justus K"; }; + stv0g = { + name = "Steffen Vogel"; + email = "post@steffenvogel.de"; + matrix = "@stv0ge:matrix.org"; + github = "stv0g"; + githubId = 285829; + keys = [{ + fingerprint = "09BE 3BAE 8D55 D4CD 8579 285A 9675 EAC3 4897 E6E2"; + }]; + }; SubhrajyotiSen = { email = "subhrajyoti12@gmail.com"; github = "SubhrajyotiSen"; @@ -18784,6 +19338,12 @@ githubId = 1939855; name = "Kimmo Suominen"; }; + supa = { + email = "supa.codes@gmail.com"; + github = "0Supa"; + githubId = 36031171; + name = "Supa"; + }; superbo = { email = "supernbo@gmail.com"; github = "SuperBo"; @@ -18882,6 +19442,12 @@ github = "sweenu"; githubId = 7051978; }; + swendel = { + name = "Sebastian Wendel"; + email = "nixpkgs.aiX5ph@srx.digital"; + github = "SebastianWendel"; + githubId = 919570; + }; swesterfeld = { email = "stefan@space.twc.de"; github = "swesterfeld"; @@ -18965,6 +19531,12 @@ fingerprint = "6866 981C 4992 4D64 D154 E1AC 19E5 A2D8 B1E4 3F19"; }]; }; + t4sm5n = { + email = "t4sm5n@gmail.com"; + github = "t4sm5n"; + githubId = 28858039; + name = "Tuomas Mäkinen"; + }; tadeokondrak = { email = "me@tadeo.ca"; github = "tadeokondrak"; @@ -19007,6 +19579,12 @@ githubId = 321799; name = "Paul Colomiets"; }; + takac = { + email = "cammann.tom@gmail.com"; + github = "takac"; + githubId = 1015381; + name = "Tom Cammann"; + }; takagiy = { email = "takagiy.4dev@gmail.com"; github = "takagiy"; @@ -19150,6 +19728,12 @@ githubId = 2389333; name = "Andy Tockman"; }; + tcmal = { + email = "me@aria.rip"; + github = "tcmal"; + githubId = 4183876; + name = "Aria Shrimpton"; + }; teatwig = { email = "nix@teatwig.net"; name = "tea"; @@ -19375,16 +19959,6 @@ github = "thefossguy"; githubId = 44400303; }; - thehedgeh0g = { - name = "The Hedgehog"; - email = "hedgehog@mrhedgehog.xyz"; - matrix = "@mrhedgehog:jupiterbroadcasting.com"; - github = "pyrox0"; - githubId = 35778371; - keys = [{ - fingerprint = "38A0 29B0 4A7E 4C13 A4BB 86C8 7D51 0786 6B1C 6752"; - }]; - }; thekostins = { name = "Konstantin"; email = "anisimovkosta19@gmail.com"; @@ -19659,12 +20233,6 @@ github = "tirimia"; githubId = 11174371; }; - titanous = { - email = "jonathan@titanous.com"; - github = "titanous"; - githubId = 13026; - name = "Jonathan Rudenberg"; - }; tjni = { email = "43ngvg@masqt.com"; matrix = "@tni:matrix.org"; @@ -19727,6 +20295,11 @@ githubId = 9853194; name = "Philipp Bartsch"; }; + toast = { + name = "Toast"; + github = "toast003"; + githubId = 39011842; + }; toastal = { email = "toastal+nix@posteo.net"; matrix = "@toastal:mozilla.org"; @@ -19755,12 +20328,6 @@ githubId = 74688871; name = "Tochukwu Ahanonu"; }; - tokudan = { - email = "git@danielfrank.net"; - github = "tokudan"; - githubId = 692610; - name = "Daniel Frank"; - }; tomahna = { email = "kevin.rauscher@tomahna.fr"; github = "Tomahna"; @@ -20080,12 +20647,6 @@ githubId = 131159000; name = "Nitin Passa"; }; - twitchyliquid64 = { - name = "Tom"; - email = "twitchyliquid64@ciphersink.net"; - github = "twitchyliquid64"; - githubId = 6328589; - }; twz123 = { name = "Tom Wieczorek"; email = "tom@bibbu.net"; @@ -20161,6 +20722,12 @@ githubId = 20206121; name = "umlx5h"; }; + uncenter = { + name = "uncenter"; + email = "uncenter@uncenter.dev"; + github = "uncenter"; + githubId = 47499684; + }; unclamped = { name = "Maru"; email = "clear6860@tutanota.com"; @@ -20699,6 +21266,12 @@ githubId = 357664; name = "Viktor Petersson"; }; + vpochapuis = { + email = "vincent.professional@chapuis.ovh"; + github = "vpochapuis"; + githubId = 75721408; + name = "Vincent Chapuis"; + }; vq = { email = "vq@erq.se"; github = "vq"; @@ -20951,6 +21524,16 @@ fingerprint = "DA03 D6C6 3F58 E796 AD26 E99B 366A 2940 479A 06FC"; }]; }; + willbush = { + email = "git@willbush.dev"; + matrix = "@willbush:matrix.org"; + github = "willbush"; + githubId = 2023546; + name = "Will Bush"; + keys = [{ + fingerprint = "4441 422E 61E4 C8F3 EBFE 5E33 3823 864B 54B1 3BDA"; + }]; + }; willcohen = { github = "willcohen"; githubId = 5185341; @@ -21087,6 +21670,15 @@ githubId = 8378365; name = "P. R. d. O."; }; + wolfgangwalther = { + name = "Wolfgang Walther"; + email = "walther@technowledgy.de"; + github = "wolfgangwalther"; + githubId = 9132420; + keys = [{ + fingerprint = "F943 A0BC 720C 5BEF 73CD E02D B398 93FA 5F65 CAE1"; + }]; + }; womfoo = { email = "kranium@gikos.net"; github = "womfoo"; @@ -21244,12 +21836,6 @@ githubId = 36407913; name = "Uli Baum"; }; - xfix = { - email = "kamila@borowska.pw"; - github = "KamilaBorowska"; - githubId = 1297598; - name = "Kamila Borowska"; - }; xfnw = { email = "xfnw+nixos@riseup.net"; github = "xfnw"; @@ -21264,7 +21850,8 @@ }; xgwq = { name = "XGWQ"; - email = "nixos@xnee.de"; + email = "nixos.xgwq@xnee.net"; + keys = [{ fingerprint = "6489 9EF2 A256 5C04 7426 686C 8337 A748 74EB E129"; }]; matrix = "@xgwq:nerdberg.de"; github = "peterablehmann"; githubId = 36541313; @@ -21293,6 +21880,12 @@ githubId = 3028542; name = "Guillermo NWDD"; }; + xokdvium = { + email = "xokdvium@proton.me"; + github = "xokdvium"; + githubId = 145775305; + name = "Sergei Zimmerman"; + }; xrelkd = { github = "xrelkd"; githubId = 46590321; @@ -21644,6 +22237,12 @@ githubId = 179548; name = "Yves Fischer"; }; + YvesStraten = { + email = "yves.straten@gmail.com"; + github = "YvesStraten"; + githubId = 65394961; + name = "Yves Straten"; + }; yvt = { email = "i@yvt.jp"; github = "yvt"; @@ -21826,6 +22425,12 @@ githubId = 1108325; name = "Théo Zimmermann"; }; + zlepper = { + name = "Rasmus Hansen"; + github = "zlepper"; + githubId = 1499810; + email = "hansen13579@gmail.com"; + }; zmitchell = { name = "Zach Mitchell"; email = "zmitchell@fastmail.com"; @@ -21866,12 +22471,6 @@ githubId = 51886259; name = "Zokre Zyl"; }; - zombiezen = { - name = "Ross Light"; - email = "ross@zombiezen.com"; - github = "zombiezen"; - githubId = 181535; - }; zookatron = { email = "tim@zookatron.com"; github = "zookatron"; @@ -21913,12 +22512,6 @@ githubId = 393108; name = "Damien Diederen"; }; - zumorica = { - name = "Vera Aguilera Puerto"; - email = "gradientvera+nix@outlook.com"; - github = "Zumorica"; - githubId = 6766154; - }; zupo = { name = "Nejc Zupan"; email = "nejczupan+nix@gmail.com"; diff --git a/maintainers/scripts/README.md b/maintainers/scripts/README.md index f8fc7aff955d..1af4715b05be 100644 --- a/maintainers/scripts/README.md +++ b/maintainers/scripts/README.md @@ -11,7 +11,7 @@ What follows is a (very incomplete) overview of available scripts. ### `check-by-name.sh` -An alias for `pkgs/test/nixpkgs-check-by-name/scripts/run-local.sh`, see [documentation](../../pkgs/test/nixpkgs-check-by-name/scripts/README.md). +An alias for `pkgs/test/check-by-name/run-local.sh`, see [documentation](../../pkgs/test/check-by-name/README.md). ### `get-maintainer.sh` diff --git a/maintainers/scripts/check-by-name.sh b/maintainers/scripts/check-by-name.sh index 545dbedf0a31..d267ed9352a0 120000 --- a/maintainers/scripts/check-by-name.sh +++ b/maintainers/scripts/check-by-name.sh @@ -1 +1 @@ -../../pkgs/test/nixpkgs-check-by-name/scripts/run-local.sh \ No newline at end of file +../../pkgs/test/check-by-name/run-local.sh \ No newline at end of file diff --git a/maintainers/scripts/check-cherry-picks.sh b/maintainers/scripts/check-cherry-picks.sh new file mode 100755 index 000000000000..e7ffe2bf4c73 --- /dev/null +++ b/maintainers/scripts/check-cherry-picks.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env bash +# Find alleged cherry-picks + +set -e + +if [ $# != "2" ] ; then + echo "usage: check-cherry-picks.sh base_rev head_rev" + exit 2 +fi + +PICKABLE_BRANCHES=${PICKABLE_BRANCHES:-master staging release-??.?? staging-??.??} +problem=0 + +while read new_commit_sha ; do + if [ -z "$new_commit_sha" ] ; then + continue # skip empty lines + fi + if [ "$GITHUB_ACTIONS" = 'true' ] ; then + echo "::group::Commit $new_commit_sha" + else + echo "=================================================" + fi + git rev-list --max-count=1 --format=medium "$new_commit_sha" + echo "-------------------------------------------------" + + original_commit_sha=$( + git rev-list --max-count=1 --format=format:%B "$new_commit_sha" \ + | grep -Ei -m1 "cherry.*[0-9a-f]{40}" \ + | grep -Eoi -m1 '[0-9a-f]{40}' + ) + if [ "$?" != "0" ] ; then + echo " ? Couldn't locate original commit hash in message" + [ "$GITHUB_ACTIONS" = 'true' ] && echo ::endgroup:: + continue + fi + + set -f # prevent pathname expansion of patterns + for branch_pattern in $PICKABLE_BRANCHES ; do + set +f # re-enable pathname expansion + + while read -r picked_branch ; do + if git merge-base --is-ancestor "$original_commit_sha" "$picked_branch" ; then + echo " ✔ $original_commit_sha present in branch $picked_branch" + + range_diff_common='git range-diff + --no-notes + --creation-factor=100 + '"$original_commit_sha~..$original_commit_sha"' + '"$new_commit_sha~..$new_commit_sha"' + ' + + if $range_diff_common --no-color | grep -E '^ {4}[+-]{2}' > /dev/null ; then + if [ "$GITHUB_ACTIONS" = 'true' ] ; then + echo ::endgroup:: + echo -n "::warning ::" + else + echo -n " ⚠ " + fi + echo "Difference between $new_commit_sha and original $original_commit_sha may warrant inspection:" + + $range_diff_common --color + + echo "Note this should not necessarily be treated as a hard fail, but a reviewer's attention should" \ + "be drawn to it and github actions have no way of doing that but to raise a 'failure'" + problem=1 + else + echo " ✔ $original_commit_sha highly similar to $new_commit_sha" + $range_diff_common --color + [ "$GITHUB_ACTIONS" = 'true' ] && echo ::endgroup:: + fi + + # move on to next commit + continue 3 + fi + done <<< "$( + git for-each-ref \ + --format="%(refname)" \ + "refs/remotes/origin/$branch_pattern" + )" + done + + if [ "$GITHUB_ACTIONS" = 'true' ] ; then + echo ::endgroup:: + echo -n "::error ::" + else + echo -n " ✘ " + fi + echo "$original_commit_sha not found in any pickable branch" + + problem=1 +done <<< "$( + git rev-list \ + -E -i --grep="cherry.*[0-9a-f]{40}" --reverse \ + "$1..$2" +)" + +exit $problem diff --git a/maintainers/scripts/eval-release.nix b/maintainers/scripts/eval-release.nix index 10acfe328447..fb830981683f 100644 --- a/maintainers/scripts/eval-release.nix +++ b/maintainers/scripts/eval-release.nix @@ -5,7 +5,7 @@ let trace = if builtins.getEnv "VERBOSE" == "1" then builtins.trace else (x: y: y); - rel = removeAttrs (import ../../pkgs/top-level/release.nix { }) [ "tarball" "unstable" "xbursttools" ]; + rel = removeAttrs (import ../../pkgs/top-level/release.nix { }) [ "tarball" "unstable" ]; # Add the ‘recurseForDerivations’ attribute to ensure that # nix-instantiate recurses into nested attribute sets. diff --git a/maintainers/scripts/haskell/hydra-report.hs b/maintainers/scripts/haskell/hydra-report.hs index e911830e8b3e..debf684abf50 100755 --- a/maintainers/scripts/haskell/hydra-report.hs +++ b/maintainers/scripts/haskell/hydra-report.hs @@ -78,6 +78,7 @@ import Network.HTTP.Req ( ) import System.Directory (XdgDirectory (XdgCache), getXdgDirectory) import System.Environment (getArgs) +import System.Exit (die) import System.Process (readProcess) import Prelude hiding (id) import Data.List (sortOn) @@ -155,17 +156,20 @@ data Build = Build data HydraSlownessWorkaroundFlag = HydraSlownessWorkaround | NoHydraSlownessWorkaround data RequestLogsFlag = RequestLogs | NoRequestLogs +usage :: IO a +usage = die "Usage: get-report [--slow] [EVAL-ID] | ping-maintainers | mark-broken-list [--no-request-logs] | eval-info" + main :: IO () main = do args <- getArgs case args of - ["get-report", "--slow"] -> getBuildReports HydraSlownessWorkaround - ["get-report"] -> getBuildReports NoHydraSlownessWorkaround + "get-report":"--slow":id -> getBuildReports HydraSlownessWorkaround id + "get-report":id -> getBuildReports NoHydraSlownessWorkaround id ["ping-maintainers"] -> printMaintainerPing ["mark-broken-list", "--no-request-logs"] -> printMarkBrokenList NoRequestLogs ["mark-broken-list"] -> printMarkBrokenList RequestLogs ["eval-info"] -> printEvalInfo - _ -> putStrLn "Usage: get-report [--slow] | ping-maintainers | mark-broken-list [--no-request-logs] | eval-info" + _ -> usage reportFileName :: IO FilePath reportFileName = getXdgDirectory XdgCache "haskell-updates-build-report.json" @@ -173,23 +177,26 @@ reportFileName = getXdgDirectory XdgCache "haskell-updates-build-report.json" showT :: Show a => a -> Text showT = Text.pack . show -getBuildReports :: HydraSlownessWorkaroundFlag -> IO () -getBuildReports opt = runReq defaultHttpConfig do - evalMay <- Seq.lookup 0 . evals <$> hydraJSONQuery mempty ["jobset", "nixpkgs", "haskell-updates", "evals"] - eval@Eval{id} <- maybe (liftIO $ fail "No Evaluation found") pure evalMay +getBuildReports :: HydraSlownessWorkaroundFlag -> [String] -> IO () +getBuildReports opt args = runReq defaultHttpConfig do + eval@Eval{id} <- case args of + [id] -> hydraJSONQuery mempty ["eval", Text.pack id] + [] -> do + evalMay <- Seq.lookup 0 . evals <$> hydraJSONQuery mempty ["jobset", "nixpkgs", "haskell-updates", "evals"] + maybe (liftIO $ fail "No Evaluation found") pure evalMay + _ -> liftIO usage liftIO . putStrLn $ "Fetching evaluation " <> show id <> " from Hydra. This might take a few minutes..." - buildReports <- getEvalBuilds opt id + buildReports <- getEvalBuilds opt eval liftIO do fileName <- reportFileName putStrLn $ "Finished fetching all builds from Hydra, saving report as " <> fileName now <- getCurrentTime encodeFile fileName (eval, now, buildReports) -getEvalBuilds :: HydraSlownessWorkaroundFlag -> Int -> Req (Seq Build) -getEvalBuilds NoHydraSlownessWorkaround id = +getEvalBuilds :: HydraSlownessWorkaroundFlag -> Eval -> Req (Seq Build) +getEvalBuilds NoHydraSlownessWorkaround Eval{id} = hydraJSONQuery mempty ["eval", showT id, "builds"] -getEvalBuilds HydraSlownessWorkaround id = do - Eval{builds} <- hydraJSONQuery mempty [ "eval", showT id ] +getEvalBuilds HydraSlownessWorkaround Eval{builds} = do forM builds $ \buildId -> do liftIO $ putStrLn $ "Querying build " <> show buildId hydraJSONQuery mempty [ "build", showT buildId ] diff --git a/maintainers/scripts/kde/generate-sources.py b/maintainers/scripts/kde/generate-sources.py index 7b3b2ac35d26..4f43710997f4 100755 --- a/maintainers/scripts/kde/generate-sources.py +++ b/maintainers/scripts/kde/generate-sources.py @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i python3 -p "python3.withPackages(ps: [ ps.beautifulsoup4 ps.click ps.httpx ps.jinja2 ps.pyyaml ]) +#!nix-shell -i python3 -p "python3.withPackages(ps: [ ps.beautifulsoup4 ps.click ps.httpx ps.jinja2 ps.pyyaml ])" import base64 import binascii import json diff --git a/maintainers/scripts/kde/utils.py b/maintainers/scripts/kde/utils.py index 7a82c4955c6b..b3a00093d703 100644 --- a/maintainers/scripts/kde/utils.py +++ b/maintainers/scripts/kde/utils.py @@ -122,10 +122,7 @@ class KDERepoMetadata: dep_graph={}, ) - dep_specs = [ - "dependency-data-common", - "dependency-data-kf6-qt6" - ] + dep_specs = ["dependency-data-stable-kf6-qt6"] dep_graph = collections.defaultdict(set) for spec in dep_specs: diff --git a/maintainers/scripts/luarocks-packages.csv b/maintainers/scripts/luarocks-packages.csv index fd6c59c0b46f..4b41b7887512 100644 --- a/maintainers/scripts/luarocks-packages.csv +++ b/maintainers/scripts/luarocks-packages.csv @@ -5,10 +5,11 @@ argparse,,,,,, basexx,,,,,, binaryheap,,,,,,vcunat busted,,,,,, -cassowary,,,,,,marsam alerque +cassowary,,,,,,alerque cldr,,,,,,alerque compat53,,,,,,vcunat -cosmo,,,,,,marsam +commons.nvim,,,,,,mrcjkb +cosmo,,,,,, coxpcall,,,,1.17.0-1,, cqueues,,,,,,vcunat cyan,,,,,, @@ -18,6 +19,8 @@ fennel,,,,,,misterio77 fidget.nvim,,,,,,mrcjkb fifo,,,,,, fluent,,,,,,alerque +funnyfiles.nvim,,,,,,mrcjkb +fzf-lua,,,,,,mrcjkb fzy,,,,,,mrcjkb gitsigns.nvim,https://github.com/lewis6991/gitsigns.nvim.git,,,,5.1, haskell-tools.nvim,,,,,, @@ -85,6 +88,7 @@ luaunbound,,,,,, luaunit,,,,,,lockejan luautf8,,,,,,pstn luazip,,,,,, +lua-utils.nvim,,,,,,mrcjkb lua-yajl,,,,,,pstn lua-iconv,,,,7.0.0,, luuid,,,,20120509-2,, @@ -98,15 +102,21 @@ middleclass,,,,,, mimetypes,,,,,, mpack,,,,,, moonscript,https://github.com/leafo/moonscript.git,dev-1,,,,arobyn +neotest,,,,,,mrcjkb nlua,,,,,,teto nui.nvim,,,,,,mrcjkb nvim-cmp,https://github.com/hrsh7th/nvim-cmp,,,,, nvim-nio,,,,,,mrcjkb +pathlib.nvim,,,,,, penlight,https://github.com/lunarmodules/Penlight.git,,,,,alerque plenary.nvim,https://github.com/nvim-lua/plenary.nvim.git,,,,5.1, rapidjson,https://github.com/xpol/lua-rapidjson.git,,,,, rocks.nvim,,,,,5.1,teto mrcjkb rest.nvim,,,,,5.1,teto +rocks.nvim,,,,,,mrcjkb +rocks-git.nvim,,,,,,mrcjkb +rocks-config.nvim,,,,,,mrcjkb +rocks-dev.nvim,,,,,,mrcjkb rustaceanvim,,,,,,mrcjkb say,https://github.com/Olivine-Labs/say.git,,,,, serpent,,,,,,lockejan diff --git a/maintainers/scripts/mdize-module.sh b/maintainers/scripts/mdize-module.sh deleted file mode 100755 index e2d2e5467aa9..000000000000 --- a/maintainers/scripts/mdize-module.sh +++ /dev/null @@ -1,83 +0,0 @@ -#! /usr/bin/env nix-shell -#! nix-shell -I nixpkgs=. -i bash -p delta jq perl - -set -euo pipefail -shopt -s inherit_errexit - -cat <<'EOF' -This script attempts to automatically convert option descriptions from -DocBook syntax to markdown. Naturally this process is incomplete and -imperfect, so any changes generated by this script MUST be reviewed. - -Possible problems include: incorrectly replaced tags, badly formatted -markdown, DocBook tags this script doesn't recognize remaining in the -output and crashing the docs build, incorrect escaping of markdown -metacharacters, incorrect unescaping of XML entities—and the list goes on. - -Always review the generated changes! - -Some known limitations: - - Does not transform literalDocBook items - - Replacements can occur in non-option code, such as string literals - - -EOF - - - -build-options-json() { - nix-build --no-out-link --expr ' - let - sys = import ./nixos/default.nix { - configuration = {}; - }; - in - [ - sys.config.system.build.manual.optionsJSON - ] - ' -} - - - -git diff --quiet || { - echo "Worktree is dirty. Please stash or commit first." - exit 1 -} - -echo "Building options.json ..." -old_options=$(build-options-json) - -echo "Applying replacements ..." -perl -pi -e ' - BEGIN { - undef $/; - } - - s,([^`]*?),`$1`,smg; - s,([^»]*?),«$1»,smg; - s,([^`]*?),{file}`$1`,smg; - s,,{option}`$1`,smg; - s,([^`]*?),`$1`,smg; - s,([^`]*?),{command}`$1`,smg; - s,,<$1>,smg; - s,(.*?),[$2]($1),smg; - s,([^`]*?),`$1`,smg; - s,([^*]*?),*$1*,smg; - s,\s* - \s*(.*?)\s*\s* - \s*(.*?)\s*\s* - ,{manpage}`$1($2)`,smgx; - s,^( +description =),\1 lib.mdDoc,smg; -' "$@" - -echo "Building options.json again ..." -new_options=$(build-options-json) - - -! cmp -s {$old_options,$new_options}/share/doc/nixos/options.json && { - diff -U10 \ - <(jq . <$old_options/share/doc/nixos/options.json) \ - <(jq . <$new_options/share/doc/nixos/options.json) \ - | delta -} diff --git a/maintainers/scripts/pluginupdate.py b/maintainers/scripts/pluginupdate.py index 056abda85bfd..239f529f9eaa 100644 --- a/maintainers/scripts/pluginupdate.py +++ b/maintainers/scripts/pluginupdate.py @@ -1,7 +1,7 @@ # python library used to update plugins: # - pkgs/applications/editors/vim/plugins/update.py # - pkgs/applications/editors/kakoune/plugins/update.py -# - maintainers/scripts/update-luarocks-packages +# - pkgs/development/lua-modules/updater/updater.py # format: # $ nix run nixpkgs#black maintainers/scripts/pluginupdate.py diff --git a/maintainers/team-list.nix b/maintainers/team-list.nix index 0f481ed3eb9d..08aa297a7c10 100644 --- a/maintainers/team-list.nix +++ b/maintainers/team-list.nix @@ -32,7 +32,6 @@ with lib.maintainers; { acme = { members = [ aanderse - andrew-d arianvp emily flokli @@ -46,7 +45,6 @@ with lib.maintainers; { bazel = { members = [ mboes - marsam uri-canva cbley olebedev @@ -99,7 +97,6 @@ with lib.maintainers; { budgie = { members = [ bobby285271 - federicoschonborn ]; scope = "Maintain Budgie desktop environment"; shortName = "Budgie"; @@ -146,6 +143,15 @@ with lib.maintainers; { enableFeatureFreezePing = true; }; + cloudposse = { + members = [ + dudymas + ]; + scope = "Maintain atmos and applications made by the Cloud Posse team."; + shortName = "CloudPosse"; + enableFeatureFreezePing = true; + }; + coq = { members = [ cohencyril @@ -256,10 +262,7 @@ with lib.maintainers; { }; docs = { - members = [ - asymmetric - ryantm - ]; + members = [ ]; scope = "Maintain nixpkgs/NixOS documentation and tools for building it."; shortName = "Docs"; enableFeatureFreezePing = true; @@ -352,6 +355,7 @@ with lib.maintainers; { geospatial = { members = [ imincik + l0b0 nh2 nialov sikmir @@ -371,7 +375,6 @@ with lib.maintainers; { krav talyz yayayayaka - yuka ]; scope = "Maintain gitlab packages."; shortName = "gitlab"; @@ -399,7 +402,6 @@ with lib.maintainers; { hedning jtojnar dasj19 - amaxine ]; githubTeams = [ "gnome" @@ -442,6 +444,7 @@ with lib.maintainers; { # Verify additions to this team with at least one already existing member of the team. members = [ das_j + conni2461 ]; scope = "Group registration for packages maintained by Helsinki Systems"; shortName = "Helsinki Systems employees"; @@ -475,6 +478,7 @@ with lib.maintainers; { ryantm lassulus yayayayaka + asymmetric ]; scope = "Maintain Jitsi."; shortName = "Jitsi"; @@ -507,6 +511,7 @@ with lib.maintainers; { cpages dschrempf edwtjo + kazenyuk minijackson peterhoeg sephalon @@ -519,7 +524,6 @@ with lib.maintainers; { members = [ aanderse edwtjo - MP2E thiagokokada ]; scope = "Maintain Libretro, RetroArch and related packages."; @@ -559,10 +563,13 @@ with lib.maintainers; { ericson2314 lovek323 qyliss - raitobezarius + RossComputerGuy rrbutani sternenseemann ]; + githubTeams = [ + "llvm" + ]; scope = "Maintain LLVM package sets and related packages"; shortName = "LLVM"; enableFeatureFreezePing = true; @@ -721,7 +728,6 @@ with lib.maintainers; { node = { members = [ lilyinstarlight - marsam winter ]; scope = "Maintain Node.js runtimes and build tooling."; @@ -819,7 +825,6 @@ with lib.maintainers; { python = { members = [ - fridh hexa jonringer tjni @@ -891,7 +896,6 @@ with lib.maintainers; { ruby = { members = [ - marsam ]; scope = "Maintain the Ruby interpreter and related packages."; shortName = "Ruby"; diff --git a/nixos/doc/manual/administration/cleaning-store.chapter.md b/nixos/doc/manual/administration/cleaning-store.chapter.md index c9140d0869c7..4f404882055a 100644 --- a/nixos/doc/manual/administration/cleaning-store.chapter.md +++ b/nixos/doc/manual/administration/cleaning-store.chapter.md @@ -21,8 +21,10 @@ You can tell NixOS in `configuration.nix` to run this unit automatically at certain points in time, for instance, every night at 03:15: ```nix -nix.gc.automatic = true; -nix.gc.dates = "03:15"; +{ + nix.gc.automatic = true; + nix.gc.dates = "03:15"; +} ``` The commands above do not remove garbage collector roots, such as old diff --git a/nixos/doc/manual/administration/container-networking.section.md b/nixos/doc/manual/administration/container-networking.section.md index 0873768376cc..723cf211d872 100644 --- a/nixos/doc/manual/administration/container-networking.section.md +++ b/nixos/doc/manual/administration/container-networking.section.md @@ -26,9 +26,11 @@ host to rewrite container traffic to use your external IP address. This can be accomplished using the following configuration on the host: ```nix -networking.nat.enable = true; -networking.nat.internalInterfaces = ["ve-+"]; -networking.nat.externalInterface = "eth0"; +{ + networking.nat.enable = true; + networking.nat.internalInterfaces = ["ve-+"]; + networking.nat.externalInterface = "eth0"; +} ``` where `eth0` should be replaced with the desired external interface. @@ -38,7 +40,9 @@ If you are using Network Manager, you need to explicitly prevent it from managing container interfaces: ```nix -networking.networkmanager.unmanaged = [ "interface-name:ve-*" ]; +{ + networking.networkmanager.unmanaged = [ "interface-name:ve-*" ]; +} ``` You may need to restart your system for the changes to take effect. diff --git a/nixos/doc/manual/administration/control-groups.chapter.md b/nixos/doc/manual/administration/control-groups.chapter.md index abe8dd80b5ab..8682236ca1a9 100644 --- a/nixos/doc/manual/administration/control-groups.chapter.md +++ b/nixos/doc/manual/administration/control-groups.chapter.md @@ -39,7 +39,9 @@ they were in the same cgroup, then the PostgreSQL process would get `configuration.nix`: ```nix -systemd.services.httpd.serviceConfig.CPUShares = 512; +{ + systemd.services.httpd.serviceConfig.CPUShares = 512; +} ``` By default, every cgroup has 1024 CPU shares, so this will halve the CPU @@ -52,7 +54,9 @@ limits can be specified in `configuration.nix`; for instance, to limit `httpd.service` to 512 MiB of RAM (excluding swap): ```nix -systemd.services.httpd.serviceConfig.MemoryLimit = "512M"; +{ + systemd.services.httpd.serviceConfig.MemoryLimit = "512M"; +} ``` The command `systemd-cgtop` shows a continuously updated list of all diff --git a/nixos/doc/manual/administration/declarative-containers.section.md b/nixos/doc/manual/administration/declarative-containers.section.md index eaa50d3c663d..f16fa8332b51 100644 --- a/nixos/doc/manual/administration/declarative-containers.section.md +++ b/nixos/doc/manual/administration/declarative-containers.section.md @@ -5,13 +5,15 @@ You can also specify containers and their configuration in the host's shall be a container named `database` running PostgreSQL: ```nix -containers.database = - { config = - { config, pkgs, ... }: - { services.postgresql.enable = true; - services.postgresql.package = pkgs.postgresql_14; - }; - }; +{ + containers.database = + { config = + { config, pkgs, ... }: + { services.postgresql.enable = true; + services.postgresql.package = pkgs.postgresql_14; + }; + }; +} ``` If you run `nixos-rebuild switch`, the container will be built. If the @@ -25,11 +27,13 @@ cannot change the network configuration. You can give a container its own network as follows: ```nix -containers.database = { - privateNetwork = true; - hostAddress = "192.168.100.10"; - localAddress = "192.168.100.11"; -}; +{ + containers.database = { + privateNetwork = true; + hostAddress = "192.168.100.10"; + localAddress = "192.168.100.11"; + }; +} ``` This gives the container a private virtual Ethernet interface with IP diff --git a/nixos/doc/manual/administration/service-mgmt.chapter.md b/nixos/doc/manual/administration/service-mgmt.chapter.md index bc9bdbe3708b..49e8d801fb80 100644 --- a/nixos/doc/manual/administration/service-mgmt.chapter.md +++ b/nixos/doc/manual/administration/service-mgmt.chapter.md @@ -82,7 +82,9 @@ In order to enable a systemd *system* service with provided upstream package, use (e.g): ```nix -systemd.packages = [ pkgs.packagekit ]; +{ + systemd.packages = [ pkgs.packagekit ]; +} ``` Usually NixOS modules written by the community do the above, plus take diff --git a/nixos/doc/manual/administration/system-state.chapter.md b/nixos/doc/manual/administration/system-state.chapter.md index 6840cc390257..89013933cda5 100644 --- a/nixos/doc/manual/administration/system-state.chapter.md +++ b/nixos/doc/manual/administration/system-state.chapter.md @@ -7,7 +7,7 @@ However, it is possible and not-uncommon to create [impermanent systems], whose `rootfs` is either a `tmpfs` or reset during boot. While NixOS itself supports this kind of configuration, special care needs to be taken. -[impermanent systems]: https://nixos.wiki/wiki/Impermanence +[impermanent systems]: https://wiki.nixos.org/wiki/Impermanence ```{=include=} sections diff --git a/nixos/doc/manual/configuration/abstractions.section.md b/nixos/doc/manual/configuration/abstractions.section.md index bf26e4c51ed3..06356c472ba9 100644 --- a/nixos/doc/manual/configuration/abstractions.section.md +++ b/nixos/doc/manual/configuration/abstractions.section.md @@ -35,7 +35,7 @@ in { services.httpd.virtualHosts = { "blog.example.org" = (commonConfig // { documentRoot = "/webroot/blog.example.org"; }); - "wiki.example.org" = (commonConfig // { documentRoot = "/webroot/wiki.example.com"; }); + "wiki.example.org" = (commonConfig // { documentRoot = "/webroot/wiki.example.org"; }); }; } ``` @@ -47,9 +47,9 @@ You can write a `let` wherever an expression is allowed. Thus, you also could ha ```nix { services.httpd.virtualHosts = - let commonConfig = ...; in - { "blog.example.org" = (commonConfig // { ... }) - "wiki.example.org" = (commonConfig // { ... }) + let commonConfig = { /* ... */ }; in + { "blog.example.org" = (commonConfig // { /* ... */ }); + "wiki.example.org" = (commonConfig // { /* ... */ }); }; } ``` diff --git a/nixos/doc/manual/configuration/ad-hoc-network-config.section.md b/nixos/doc/manual/configuration/ad-hoc-network-config.section.md index 4478d77f361d..ecb06ad984a3 100644 --- a/nixos/doc/manual/configuration/ad-hoc-network-config.section.md +++ b/nixos/doc/manual/configuration/ad-hoc-network-config.section.md @@ -6,8 +6,10 @@ is useful for doing network configuration not covered by the existing NixOS modules. For instance, to statically configure an IPv6 address: ```nix -networking.localCommands = - '' - ip -6 addr add 2001:610:685:1::1/64 dev eth0 - ''; +{ + networking.localCommands = + '' + ip -6 addr add 2001:610:685:1::1/64 dev eth0 + ''; +} ``` diff --git a/nixos/doc/manual/configuration/adding-custom-packages.section.md b/nixos/doc/manual/configuration/adding-custom-packages.section.md index 2340723e07c6..f9a5221d6c93 100644 --- a/nixos/doc/manual/configuration/adding-custom-packages.section.md +++ b/nixos/doc/manual/configuration/adding-custom-packages.section.md @@ -23,7 +23,9 @@ Then you write and test the package as described in the Nixpkgs manual. Finally, you add it to [](#opt-environment.systemPackages), e.g. ```nix -environment.systemPackages = [ pkgs.my-package ]; +{ + environment.systemPackages = [ pkgs.my-package ]; +} ``` and you run `nixos-rebuild`, specifying your own Nixpkgs tree: @@ -38,24 +40,28 @@ tree. For instance, here is how you specify a build of the `configuration.nix`: ```nix -environment.systemPackages = - let - my-hello = with pkgs; stdenv.mkDerivation rec { - name = "hello-2.8"; - src = fetchurl { - url = "mirror://gnu/hello/${name}.tar.gz"; - hash = "sha256-5rd/gffPfa761Kn1tl3myunD8TuM+66oy1O7XqVGDXM="; +{ + environment.systemPackages = + let + my-hello = with pkgs; stdenv.mkDerivation rec { + name = "hello-2.8"; + src = fetchurl { + url = "mirror://gnu/hello/${name}.tar.gz"; + hash = "sha256-5rd/gffPfa761Kn1tl3myunD8TuM+66oy1O7XqVGDXM="; + }; }; - }; - in - [ my-hello ]; + in + [ my-hello ]; +} ``` Of course, you can also move the definition of `my-hello` into a separate Nix expression, e.g. ```nix -environment.systemPackages = [ (import ./my-hello.nix) ]; +{ + environment.systemPackages = [ (import ./my-hello.nix) ]; +} ``` where `my-hello.nix` contains: @@ -88,7 +94,9 @@ section](#module-services-flatpak). AppImages will not run "as-is" on NixOS. First you need to install `appimage-run`: add to `/etc/nixos/configuration.nix` ```nix -environment.systemPackages = [ pkgs.appimage-run ]; +{ + environment.systemPackages = [ pkgs.appimage-run ]; +} ``` Then instead of running the AppImage "as-is", run `appimage-run foo.appimage`. diff --git a/nixos/doc/manual/configuration/config-file.section.md b/nixos/doc/manual/configuration/config-file.section.md index b010026c5828..e213aae29ae3 100644 --- a/nixos/doc/manual/configuration/config-file.section.md +++ b/nixos/doc/manual/configuration/config-file.section.md @@ -5,7 +5,7 @@ The NixOS configuration file generally looks like this: ```nix { config, pkgs, ... }: -{ option definitions +{ /* option definitions */ } ``` @@ -80,7 +80,9 @@ Strings : Strings are enclosed in double quotes, e.g. ```nix - networking.hostName = "dexter"; + { + networking.hostName = "dexter"; + } ``` Special characters can be escaped by prefixing them with a backslash @@ -89,11 +91,13 @@ Strings Multi-line strings can be enclosed in *double single quotes*, e.g. ```nix - networking.extraHosts = - '' - 127.0.0.2 other-localhost - 10.0.0.1 server - ''; + { + networking.extraHosts = + '' + 127.0.0.2 other-localhost + 10.0.0.1 server + ''; + } ``` The main difference is that it strips from each line a number of @@ -108,8 +112,10 @@ Booleans : These can be `true` or `false`, e.g. ```nix - networking.firewall.enable = true; - networking.firewall.allowPing = false; + { + networking.firewall.enable = true; + networking.firewall.allowPing = false; + } ``` Integers @@ -117,7 +123,9 @@ Integers : For example, ```nix - boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 60; + { + boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 60; + } ``` (Note that here the attribute name `net.ipv4.tcp_keepalive_time` is @@ -132,11 +140,13 @@ Sets braces, as in the option definition ```nix - fileSystems."/boot" = - { device = "/dev/sda1"; - fsType = "ext4"; - options = [ "rw" "data=ordered" "relatime" ]; - }; + { + fileSystems."/boot" = + { device = "/dev/sda1"; + fsType = "ext4"; + options = [ "rw" "data=ordered" "relatime" ]; + }; + } ``` Lists @@ -145,13 +155,17 @@ Lists separated by whitespace, like this: ```nix - boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ]; + { + boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ]; + } ``` List elements can be any other type, e.g. sets: ```nix - swapDevices = [ { device = "/dev/disk/by-label/swap"; } ]; + { + swapDevices = [ { device = "/dev/disk/by-label/swap"; } ]; + } ``` Packages @@ -161,12 +175,14 @@ Packages argument `pkgs`. Typical uses: ```nix - environment.systemPackages = - [ pkgs.thunderbird - pkgs.emacs - ]; + { + environment.systemPackages = + [ pkgs.thunderbird + pkgs.emacs + ]; - services.postgresql.package = pkgs.postgresql_14; + services.postgresql.package = pkgs.postgresql_14; + } ``` The latter option definition changes the default PostgreSQL package diff --git a/nixos/doc/manual/configuration/customizing-packages.section.md b/nixos/doc/manual/configuration/customizing-packages.section.md index 76413b7d84fb..074932b3f110 100644 --- a/nixos/doc/manual/configuration/customizing-packages.section.md +++ b/nixos/doc/manual/configuration/customizing-packages.section.md @@ -1,11 +1,33 @@ # Customising Packages {#sec-customising-packages} -Some packages in Nixpkgs have options to enable or disable optional -functionality or change other aspects of the package. +The Nixpkgs configuration for a NixOS system is set by the {option}`nixpkgs.config` option. + +::::{.example} +# Globally allow unfree packages + +```nix +{ + nixpkgs.config = { + allowUnfree = true; + }; +} +``` + +:::{.note} +This only allows unfree software in the given NixOS configuration. +For users invoking Nix commands such as [`nix-build`](https://nixos.org/manual/nix/stable/command-ref/nix-build), Nixpkgs is configured independently. +See the [Nixpkgs manual section on global configuration](https://nixos.org/manual/nixpkgs/unstable/#chap-packageconfig) for details. +::: +:::: + + + +Some packages in Nixpkgs have options to enable or disable optional functionality, or change other aspects of the package. ::: {.warning} -Unfortunately, Nixpkgs currently lacks a way to query available -configuration options. +Unfortunately, Nixpkgs currently lacks a way to query available package configuration options. ::: ::: {.note} @@ -16,18 +38,20 @@ Examples include: You can use them like this: ```nix -environment.systemPackages = with pkgs; [ - sl - (pass.withExtensions (subpkgs: with subpkgs; [ - pass-audit - pass-otp - pass-genphrase - ])) - (python3.withPackages (subpkgs: with subpkgs; [ - requests - ])) - cowsay -]; +{ + environment.systemPackages = with pkgs; [ + sl + (pass.withExtensions (subpkgs: with subpkgs; [ + pass-audit + pass-otp + pass-genphrase + ])) + (python3.withPackages (subpkgs: with subpkgs; [ + requests + ])) + cowsay + ]; +} ``` ::: @@ -38,7 +62,9 @@ dependency on GTK 2. If you want to build it against GTK 3, you can specify that as follows: ```nix -environment.systemPackages = [ (pkgs.emacs.override { gtk = pkgs.gtk3; }) ]; +{ + environment.systemPackages = [ (pkgs.emacs.override { gtk = pkgs.gtk3; }) ]; +} ``` The function `override` performs the call to the Nix function that @@ -58,12 +84,14 @@ of the package, such as the source code. For instance, if you want to override the source code of Emacs, you can say: ```nix -environment.systemPackages = [ - (pkgs.emacs.overrideAttrs (oldAttrs: { - name = "emacs-25.0-pre"; - src = /path/to/my/emacs/tree; - })) -]; +{ + environment.systemPackages = [ + (pkgs.emacs.overrideAttrs (oldAttrs: { + name = "emacs-25.0-pre"; + src = /path/to/my/emacs/tree; + })) + ]; +} ``` Here, `overrideAttrs` takes the Nix derivation specified by `pkgs.emacs` @@ -80,9 +108,11 @@ two instances of the package. If you want to have everything depend on your customised instance, you can apply a *global* override as follows: ```nix -nixpkgs.config.packageOverrides = pkgs: - { emacs = pkgs.emacs.override { gtk = pkgs.gtk3; }; - }; +{ + nixpkgs.config.packageOverrides = pkgs: + { emacs = pkgs.emacs.override { gtk = pkgs.gtk3; }; + }; +} ``` The effect of this definition is essentially equivalent to modifying the diff --git a/nixos/doc/manual/configuration/declarative-packages.section.md b/nixos/doc/manual/configuration/declarative-packages.section.md index 480e250da8c7..6cdd520dcf15 100644 --- a/nixos/doc/manual/configuration/declarative-packages.section.md +++ b/nixos/doc/manual/configuration/declarative-packages.section.md @@ -7,7 +7,9 @@ following line to `configuration.nix` enables the Mozilla Thunderbird email application: ```nix -environment.systemPackages = [ pkgs.thunderbird ]; +{ + environment.systemPackages = [ pkgs.thunderbird ]; +} ``` The effect of this specification is that the Thunderbird package from diff --git a/nixos/doc/manual/configuration/file-systems.chapter.md b/nixos/doc/manual/configuration/file-systems.chapter.md index 3dfdd20ac33e..4bdd9c60e327 100644 --- a/nixos/doc/manual/configuration/file-systems.chapter.md +++ b/nixos/doc/manual/configuration/file-systems.chapter.md @@ -6,10 +6,12 @@ Ext4 file system on device `/dev/disk/by-label/data` onto the mount point `/data`: ```nix -fileSystems."/data" = - { device = "/dev/disk/by-label/data"; - fsType = "ext4"; - }; +{ + fileSystems."/data" = + { device = "/dev/disk/by-label/data"; + fsType = "ext4"; + }; +} ``` This will create an entry in `/etc/fstab`, which will generate a diff --git a/nixos/doc/manual/configuration/firewall.section.md b/nixos/doc/manual/configuration/firewall.section.md index dbf0ffb9273e..9a71217944ee 100644 --- a/nixos/doc/manual/configuration/firewall.section.md +++ b/nixos/doc/manual/configuration/firewall.section.md @@ -5,14 +5,18 @@ and other unexpected packets. The firewall applies to both IPv4 and IPv6 traffic. It is enabled by default. It can be disabled as follows: ```nix -networking.firewall.enable = false; +{ + networking.firewall.enable = false; +} ``` If the firewall is enabled, you can open specific TCP ports to the outside world: ```nix -networking.firewall.allowedTCPPorts = [ 80 443 ]; +{ + networking.firewall.allowedTCPPorts = [ 80 443 ]; +} ``` Note that TCP port 22 (ssh) is opened automatically if the SSH daemon is @@ -22,10 +26,12 @@ enabled (`services.openssh.enable = true`). UDP ports can be opened through To open ranges of TCP ports: ```nix -networking.firewall.allowedTCPPortRanges = [ - { from = 4000; to = 4007; } - { from = 8000; to = 8010; } -]; +{ + networking.firewall.allowedTCPPortRanges = [ + { from = 4000; to = 4007; } + { from = 8000; to = 8010; } + ]; +} ``` Similarly, UDP port ranges can be opened through diff --git a/nixos/doc/manual/configuration/gpu-accel.chapter.md b/nixos/doc/manual/configuration/gpu-accel.chapter.md index aa63aec61669..3b98bdd97c68 100644 --- a/nixos/doc/manual/configuration/gpu-accel.chapter.md +++ b/nixos/doc/manual/configuration/gpu-accel.chapter.md @@ -55,9 +55,11 @@ supported through the rocmPackages.clr.icd package. Adding this package to enables OpenCL support: ```nix -hardware.opengl.extraPackages = [ - rocmPackages.clr.icd -]; +{ + hardware.opengl.extraPackages = [ + rocmPackages.clr.icd + ]; +} ``` ### Intel {#sec-gpu-accel-opencl-intel} @@ -74,9 +76,11 @@ to enable OpenCL support. For example, for Gen8 and later GPUs, the following configuration can be used: ```nix -hardware.opengl.extraPackages = [ - intel-compute-runtime -]; +{ + hardware.opengl.extraPackages = [ + intel-compute-runtime + ]; +} ``` ## Vulkan {#sec-gpu-accel-vulkan} @@ -141,20 +145,22 @@ makes amdvlk the default driver and hides radv and lavapipe from the device list A specific driver can be forced as follows: ```nix -hardware.opengl.extraPackages = [ - pkgs.amdvlk -]; +{ + hardware.opengl.extraPackages = [ + pkgs.amdvlk + ]; -# To enable Vulkan support for 32-bit applications, also add: -hardware.opengl.extraPackages32 = [ - pkgs.driversi686Linux.amdvlk -]; + # To enable Vulkan support for 32-bit applications, also add: + hardware.opengl.extraPackages32 = [ + pkgs.driversi686Linux.amdvlk + ]; -# Force radv -environment.variables.AMD_VULKAN_ICD = "RADV"; -# Or -environment.variables.VK_ICD_FILENAMES = - "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json"; + # Force radv + environment.variables.AMD_VULKAN_ICD = "RADV"; + # Or + environment.variables.VK_ICD_FILENAMES = + "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json"; +} ``` ## VA-API {#sec-gpu-accel-va-api} @@ -178,17 +184,21 @@ $ nix-shell -p libva-utils --run vainfo Modern Intel GPUs use the iHD driver, which can be installed with: ```nix -hardware.opengl.extraPackages = [ - intel-media-driver -]; +{ + hardware.opengl.extraPackages = [ + intel-media-driver + ]; +} ``` Older Intel GPUs use the i965 driver, which can be installed with: ```nix -hardware.opengl.extraPackages = [ - intel-vaapi-driver -]; +{ + hardware.opengl.extraPackages = [ + intel-vaapi-driver + ]; +} ``` ## Common issues {#sec-gpu-accel-common-issues} diff --git a/nixos/doc/manual/configuration/ipv4-config.section.md b/nixos/doc/manual/configuration/ipv4-config.section.md index c73024b856d7..0464f5389855 100644 --- a/nixos/doc/manual/configuration/ipv4-config.section.md +++ b/nixos/doc/manual/configuration/ipv4-config.section.md @@ -5,18 +5,22 @@ configure network interfaces. However, you can configure an interface manually as follows: ```nix -networking.interfaces.eth0.ipv4.addresses = [ { - address = "192.168.1.2"; - prefixLength = 24; -} ]; +{ + networking.interfaces.eth0.ipv4.addresses = [ { + address = "192.168.1.2"; + prefixLength = 24; + } ]; +} ``` Typically you'll also want to set a default gateway and set of name servers: ```nix -networking.defaultGateway = "192.168.1.1"; -networking.nameservers = [ "8.8.8.8" ]; +{ + networking.defaultGateway = "192.168.1.1"; + networking.nameservers = [ "8.8.8.8" ]; +} ``` ::: {.note} @@ -28,7 +32,9 @@ configuration is performed by `network-setup.service`. The host name is set using [](#opt-networking.hostName): ```nix -networking.hostName = "cartman"; +{ + networking.hostName = "cartman"; +} ``` The default host name is `nixos`. Set it to the empty string (`""`) to diff --git a/nixos/doc/manual/configuration/ipv6-config.section.md b/nixos/doc/manual/configuration/ipv6-config.section.md index ce66f53ed472..b4fe0d759b8a 100644 --- a/nixos/doc/manual/configuration/ipv6-config.section.md +++ b/nixos/doc/manual/configuration/ipv6-config.section.md @@ -9,34 +9,42 @@ may be overridden on a per-interface basis by IPv6 support globally by setting: ```nix -networking.enableIPv6 = false; +{ + networking.enableIPv6 = false; +} ``` You can disable IPv6 on a single interface using a normal sysctl (in this example, we use interface `eth0`): ```nix -boot.kernel.sysctl."net.ipv6.conf.eth0.disable_ipv6" = true; +{ + boot.kernel.sysctl."net.ipv6.conf.eth0.disable_ipv6" = true; +} ``` As with IPv4 networking interfaces are automatically configured via DHCPv6. You can configure an interface manually: ```nix -networking.interfaces.eth0.ipv6.addresses = [ { - address = "fe00:aa:bb:cc::2"; - prefixLength = 64; -} ]; +{ + networking.interfaces.eth0.ipv6.addresses = [ { + address = "fe00:aa:bb:cc::2"; + prefixLength = 64; + } ]; +} ``` For configuring a gateway, optionally with explicitly specified interface: ```nix -networking.defaultGateway6 = { - address = "fe00::1"; - interface = "enp0s3"; -}; +{ + networking.defaultGateway6 = { + address = "fe00::1"; + interface = "enp0s3"; + }; +} ``` See [](#sec-ipv4) for similar examples and additional information. diff --git a/nixos/doc/manual/configuration/kubernetes.chapter.md b/nixos/doc/manual/configuration/kubernetes.chapter.md index f39726090e43..fba40b648752 100644 --- a/nixos/doc/manual/configuration/kubernetes.chapter.md +++ b/nixos/doc/manual/configuration/kubernetes.chapter.md @@ -7,14 +7,16 @@ There are generally two ways of enabling Kubernetes on NixOS. One way is to enable and configure cluster components appropriately by hand: ```nix -services.kubernetes = { - apiserver.enable = true; - controllerManager.enable = true; - scheduler.enable = true; - addonManager.enable = true; - proxy.enable = true; - flannel.enable = true; -}; +{ + services.kubernetes = { + apiserver.enable = true; + controllerManager.enable = true; + scheduler.enable = true; + addonManager.enable = true; + proxy.enable = true; + flannel.enable = true; + }; +} ``` Another way is to assign cluster roles ("master" and/or "node") to @@ -22,20 +24,26 @@ the host. This enables apiserver, controllerManager, scheduler, addonManager, kube-proxy and etcd: ```nix -services.kubernetes.roles = [ "master" ]; +{ + services.kubernetes.roles = [ "master" ]; +} ``` While this will enable the kubelet and kube-proxy only: ```nix -services.kubernetes.roles = [ "node" ]; +{ + services.kubernetes.roles = [ "node" ]; +} ``` Assigning both the master and node roles is usable if you want a single node Kubernetes cluster for dev or testing purposes: ```nix -services.kubernetes.roles = [ "master" "node" ]; +{ + services.kubernetes.roles = [ "master" "node" ]; +} ``` Note: Assigning either role will also default both diff --git a/nixos/doc/manual/configuration/linux-kernel.chapter.md b/nixos/doc/manual/configuration/linux-kernel.chapter.md index 31d8d1a7d0cf..3bc97446f452 100644 --- a/nixos/doc/manual/configuration/linux-kernel.chapter.md +++ b/nixos/doc/manual/configuration/linux-kernel.chapter.md @@ -5,7 +5,9 @@ option `boot.kernelPackages`. For instance, this selects the Linux 3.10 kernel: ```nix -boot.kernelPackages = pkgs.linuxKernel.packages.linux_3_10; +{ + boot.kernelPackages = pkgs.linuxKernel.packages.linux_3_10; +} ``` Note that this not only replaces the kernel, but also packages that are @@ -40,13 +42,15 @@ If you want to change the kernel configuration, you can use the instance, to enable support for the kernel debugger KGDB: ```nix -nixpkgs.config.packageOverrides = pkgs: pkgs.lib.recursiveUpdate pkgs { - linuxKernel.kernels.linux_5_10 = pkgs.linuxKernel.kernels.linux_5_10.override { - extraConfig = '' - KGDB y - ''; +{ + nixpkgs.config.packageOverrides = pkgs: pkgs.lib.recursiveUpdate pkgs { + linuxKernel.kernels.linux_5_10 = pkgs.linuxKernel.kernels.linux_5_10.override { + extraConfig = '' + KGDB y + ''; + }; }; -}; +} ``` `extraConfig` takes a list of Linux kernel configuration options, one @@ -59,14 +63,18 @@ by `udev`. You can force a module to be loaded via [](#opt-boot.kernelModules), e.g. ```nix -boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ]; +{ + boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ]; +} ``` If the module is required early during the boot (e.g. to mount the root file system), you can use [](#opt-boot.initrd.kernelModules): ```nix -boot.initrd.kernelModules = [ "cifs" ]; +{ + boot.initrd.kernelModules = [ "cifs" ]; +} ``` This causes the specified modules and their dependencies to be added to @@ -76,7 +84,9 @@ Kernel runtime parameters can be set through [](#opt-boot.kernel.sysctl), e.g. ```nix -boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 120; +{ + boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 120; +} ``` sets the kernel's TCP keepalive time to 120 seconds. To see the @@ -89,7 +99,9 @@ Please refer to the Nixpkgs manual for the various ways of [building a custom ke To use your custom kernel package in your NixOS configuration, set ```nix -boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel; +{ + boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel; +} ``` ## Rust {#sec-linux-rust} @@ -99,15 +111,17 @@ default. For kernel versions 6.7 or newer, experimental Rust support can be enabled. In a NixOS configuration, set: ```nix -boot.kernelPatches = [ - { - name = "Rust Support"; - patch = null; - features = { - rust = true; - }; - } -]; +{ + boot.kernelPatches = [ + { + name = "Rust Support"; + patch = null; + features = { + rust = true; + }; + } + ]; +} ``` ## Developing kernel modules {#sec-linux-config-developing-modules} diff --git a/nixos/doc/manual/configuration/luks-file-systems.section.md b/nixos/doc/manual/configuration/luks-file-systems.section.md index 7615b95aef42..4d2f625073d4 100644 --- a/nixos/doc/manual/configuration/luks-file-systems.section.md +++ b/nixos/doc/manual/configuration/luks-file-systems.section.md @@ -29,15 +29,19 @@ system is automatically mounted at boot time as `/`, add the following to `configuration.nix`: ```nix -boot.initrd.luks.devices.crypted.device = "/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d"; -fileSystems."/".device = "/dev/mapper/crypted"; +{ + boot.initrd.luks.devices.crypted.device = "/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d"; + fileSystems."/".device = "/dev/mapper/crypted"; +} ``` Should grub be used as bootloader, and `/boot` is located on an encrypted partition, it is necessary to add the following grub option: ```nix -boot.loader.grub.enableCryptodisk = true; +{ + boot.loader.grub.enableCryptodisk = true; +} ``` ## FIDO2 {#sec-luks-file-systems-fido2} @@ -68,8 +72,10 @@ To ensure that this file system is decrypted using the FIDO2 compatible key, add the following to `configuration.nix`: ```nix -boot.initrd.luks.fido2Support = true; -boot.initrd.luks.devices."/dev/sda2".fido2.credential = "f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7"; +{ + boot.initrd.luks.fido2Support = true; + boot.initrd.luks.devices."/dev/sda2".fido2.credential = "f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7"; +} ``` You can also use the FIDO2 passwordless setup, but for security reasons, @@ -77,7 +83,9 @@ you might want to enable it only when your device is PIN protected, such as [Trezor](https://trezor.io/). ```nix -boot.initrd.luks.devices."/dev/sda2".fido2.passwordLess = true; +{ + boot.initrd.luks.devices."/dev/sda2".fido2.passwordLess = true; +} ``` ### systemd Stage 1 {#sec-luks-file-systems-fido2-systemd} @@ -88,13 +96,15 @@ unlocking the existing LUKS2 volume `root` using any enrolled FIDO2 compatible tokens. ```nix -boot.initrd = { - luks.devices.root = { - crypttabExtraOpts = [ "fido2-device=auto" ]; - device = "/dev/sda2"; +{ + boot.initrd = { + luks.devices.root = { + crypttabExtraOpts = [ "fido2-device=auto" ]; + device = "/dev/sda2"; + }; + systemd.enable = true; }; - systemd.enable = true; -}; +} ``` All tokens that should be used for unlocking the LUKS2-encrypted volume must diff --git a/nixos/doc/manual/configuration/modularity.section.md b/nixos/doc/manual/configuration/modularity.section.md index f4a566d66973..ba3bc79a3631 100644 --- a/nixos/doc/manual/configuration/modularity.section.md +++ b/nixos/doc/manual/configuration/modularity.section.md @@ -16,7 +16,7 @@ including them from `configuration.nix`, e.g.: { imports = [ ./vpn.nix ./kde.nix ]; services.httpd.enable = true; environment.systemPackages = [ pkgs.emacs ]; - ... + # ... } ``` @@ -27,7 +27,7 @@ Here, we include two modules from the same directory, `vpn.nix` and { config, pkgs, ... }: { services.xserver.enable = true; - services.xserver.displayManager.sddm.enable = true; + services.displayManager.sddm.enable = true; services.xserver.desktopManager.plasma5.enable = true; environment.systemPackages = [ pkgs.vim ]; } @@ -42,7 +42,9 @@ merged last, so for list-type options, it will appear at the end of the merged list. If you want it to appear first, you can use `mkBefore`: ```nix -boot.kernelModules = mkBefore [ "kvm-intel" ]; +{ + boot.kernelModules = mkBefore [ "kvm-intel" ]; +} ``` This causes the `kvm-intel` kernel module to be loaded before any other @@ -60,7 +62,9 @@ When that happens, it's possible to force one definition take precedence over the others: ```nix -services.httpd.adminAddr = pkgs.lib.mkForce "bob@example.org"; +{ + services.httpd.adminAddr = pkgs.lib.mkForce "bob@example.org"; +} ``` When using multiple modules, you may need to access configuration values diff --git a/nixos/doc/manual/configuration/network-manager.section.md b/nixos/doc/manual/configuration/network-manager.section.md index 4bda21d34a10..8e8dfabbf3cd 100644 --- a/nixos/doc/manual/configuration/network-manager.section.md +++ b/nixos/doc/manual/configuration/network-manager.section.md @@ -4,7 +4,9 @@ To facilitate network configuration, some desktop environments use NetworkManager. You can enable NetworkManager by setting: ```nix -networking.networkmanager.enable = true; +{ + networking.networkmanager.enable = true; +} ``` some desktop managers (e.g., GNOME) enable NetworkManager automatically @@ -14,7 +16,9 @@ All users that should have permission to change network settings must belong to the `networkmanager` group: ```nix -users.users.alice.extraGroups = [ "networkmanager" ]; +{ + users.users.alice.extraGroups = [ "networkmanager" ]; +} ``` NetworkManager is controlled using either `nmcli` or `nmtui` @@ -32,9 +36,11 @@ can be used together if desired. To do this you need to instruct NetworkManager to ignore those interfaces like: ```nix -networking.networkmanager.unmanaged = [ - "*" "except:type:wwan" "except:type:gsm" -]; +{ + networking.networkmanager.unmanaged = [ + "*" "except:type:wwan" "except:type:gsm" + ]; +} ``` Refer to the option description for the exact syntax and references to diff --git a/nixos/doc/manual/configuration/overlayfs.section.md b/nixos/doc/manual/configuration/overlayfs.section.md index 592fb7c2e6f7..7027a6f426d4 100644 --- a/nixos/doc/manual/configuration/overlayfs.section.md +++ b/nixos/doc/manual/configuration/overlayfs.section.md @@ -4,21 +4,23 @@ NixOS offers a convenient abstraction to create both read-only as well writable overlays. ```nix -fileSystems = { - "/writable-overlay" = { - overlay = { - lowerdir = [ writableOverlayLowerdir ]; - upperdir = "/.rw-writable-overlay/upper"; - workdir = "/.rw-writable-overlay/work"; +{ + fileSystems = { + "/writable-overlay" = { + overlay = { + lowerdir = [ writableOverlayLowerdir ]; + upperdir = "/.rw-writable-overlay/upper"; + workdir = "/.rw-writable-overlay/work"; + }; + # Mount the writable overlay in the initrd. + neededForBoot = true; }; - # Mount the writable overlay in the initrd. - neededForBoot = true; + "/readonly-overlay".overlay.lowerdir = [ + writableOverlayLowerdir + writableOverlayLowerdir2 + ]; }; - "/readonly-overlay".overlay.lowerdir = [ - writableOverlayLowerdir - writableOverlayLowerdir2 - ]; -}; +} ``` If `upperdir` and `workdir` are not null, they will be created before the diff --git a/nixos/doc/manual/configuration/profiles.chapter.md b/nixos/doc/manual/configuration/profiles.chapter.md index 9f6c11b0d59d..6161d48e353f 100644 --- a/nixos/doc/manual/configuration/profiles.chapter.md +++ b/nixos/doc/manual/configuration/profiles.chapter.md @@ -8,9 +8,11 @@ is to say, expected usage is to add them to the imports list of your `/etc/configuration.nix` as such: ```nix -imports = [ - -]; +{ + imports = [ + + ]; +} ``` Even if some of these profiles seem only useful in the context of diff --git a/nixos/doc/manual/configuration/profiles/demo.section.md b/nixos/doc/manual/configuration/profiles/demo.section.md index 0a0df483c123..720fc101dc18 100644 --- a/nixos/doc/manual/configuration/profiles/demo.section.md +++ b/nixos/doc/manual/configuration/profiles/demo.section.md @@ -1,4 +1,4 @@ # Demo {#sec-profile-demo} This profile just enables a `demo` user, with password `demo`, uid `1000`, `wheel` group and -[autologin in the SDDM display manager](#opt-services.xserver.displayManager.autoLogin). +[autologin in the SDDM display manager](#opt-services.displayManager.autoLogin). diff --git a/nixos/doc/manual/configuration/profiles/graphical.section.md b/nixos/doc/manual/configuration/profiles/graphical.section.md index aaea5c8c0288..84fad5c0a612 100644 --- a/nixos/doc/manual/configuration/profiles/graphical.section.md +++ b/nixos/doc/manual/configuration/profiles/graphical.section.md @@ -4,7 +4,7 @@ Defines a NixOS configuration with the Plasma 5 desktop. It's used by the graphical installation CD. It sets [](#opt-services.xserver.enable), -[](#opt-services.xserver.displayManager.sddm.enable), +[](#opt-services.displayManager.sddm.enable), [](#opt-services.xserver.desktopManager.plasma5.enable), -and [](#opt-services.xserver.libinput.enable) to true. It also +and [](#opt-services.libinput.enable) to true. It also includes glxinfo and firefox in the system packages list. diff --git a/nixos/doc/manual/configuration/renaming-interfaces.section.md b/nixos/doc/manual/configuration/renaming-interfaces.section.md index 5b515e9f82a0..4804e35f8a24 100644 --- a/nixos/doc/manual/configuration/renaming-interfaces.section.md +++ b/nixos/doc/manual/configuration/renaming-interfaces.section.md @@ -25,10 +25,12 @@ we assign the name `wan` to the interface with MAC address `52:54:00:12:01:01` using a netword link unit: ```nix -systemd.network.links."10-wan" = { - matchConfig.PermanentMACAddress = "52:54:00:12:01:01"; - linkConfig.Name = "wan"; -}; +{ + systemd.network.links."10-wan" = { + matchConfig.PermanentMACAddress = "52:54:00:12:01:01"; + linkConfig.Name = "wan"; + }; +} ``` Note that links are directly read by udev, *not networkd*, and will work @@ -37,10 +39,12 @@ even if networkd is disabled. Alternatively, we can use a plain old udev rule: ```nix -boot.initrd.services.udev.rules = '' - SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", \ - ATTR{address}=="52:54:00:12:01:01", KERNEL=="eth*", NAME="wan" -''; +{ + boot.initrd.services.udev.rules = '' + SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", \ + ATTR{address}=="52:54:00:12:01:01", KERNEL=="eth*", NAME="wan" + ''; +} ``` ::: {.warning} diff --git a/nixos/doc/manual/configuration/ssh.section.md b/nixos/doc/manual/configuration/ssh.section.md index 9e239a848178..8754e3d9ccaf 100644 --- a/nixos/doc/manual/configuration/ssh.section.md +++ b/nixos/doc/manual/configuration/ssh.section.md @@ -3,7 +3,9 @@ Secure shell (SSH) access to your machine can be enabled by setting: ```nix -services.openssh.enable = true; +{ + services.openssh.enable = true; +} ``` By default, root logins using a password are disallowed. They can be @@ -14,6 +16,8 @@ You can declaratively specify authorised RSA/DSA public keys for a user as follows: ```nix -users.users.alice.openssh.authorizedKeys.keys = - [ "ssh-dss AAAAB3NzaC1kc3MAAACBAPIkGWVEt4..." ]; +{ + users.users.alice.openssh.authorizedKeys.keys = + [ "ssh-dss AAAAB3NzaC1kc3MAAACBAPIkGWVEt4..." ]; +} ``` diff --git a/nixos/doc/manual/configuration/sshfs-file-systems.section.md b/nixos/doc/manual/configuration/sshfs-file-systems.section.md index e2e37454b7ea..32b4aac78304 100644 --- a/nixos/doc/manual/configuration/sshfs-file-systems.section.md +++ b/nixos/doc/manual/configuration/sshfs-file-systems.section.md @@ -26,8 +26,8 @@ To create a new key without a passphrase you can do: ```ShellSession $ ssh-keygen -t ed25519 -P '' -f example-key Generating public/private ed25519 key pair. -Your identification has been saved in test-key -Your public key has been saved in test-key.pub +Your identification has been saved in example-key +Your public key has been saved in example-key.pub The key fingerprint is: SHA256:yjxl3UbTn31fLWeyLYTAKYJPRmzknjQZoyG8gSNEoIE my-user@workstation ``` diff --git a/nixos/doc/manual/configuration/subversion.chapter.md b/nixos/doc/manual/configuration/subversion.chapter.md index ff870f5c40b9..2436138669fe 100644 --- a/nixos/doc/manual/configuration/subversion.chapter.md +++ b/nixos/doc/manual/configuration/subversion.chapter.md @@ -21,9 +21,11 @@ Apache HTTP, setting [](#opt-services.httpd.adminAddr) appropriately: ```nix -services.httpd.enable = true; -services.httpd.adminAddr = ...; -networking.firewall.allowedTCPPorts = [ 80 443 ]; +{ + services.httpd.enable = true; + services.httpd.adminAddr = "..."; + networking.firewall.allowedTCPPorts = [ 80 443 ]; +} ``` For a simple Subversion server with basic authentication, configure the @@ -34,25 +36,28 @@ the `.authz` file describing access permission, and `AuthUserFile` to the password file. ```nix -services.httpd.extraModules = [ - # note that order is *super* important here - { name = "dav_svn"; path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_dav_svn.so"; } - { name = "authz_svn"; path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_authz_svn.so"; } - ]; - services.httpd.virtualHosts = { - "svn" = { - hostName = HOSTNAME; - documentRoot = DOCUMENTROOT; - locations."/svn".extraConfig = '' - DAV svn - SVNParentPath REPO_PARENT - AuthzSVNAccessFile ACCESS_FILE - AuthName "SVN Repositories" - AuthType Basic - AuthUserFile PASSWORD_FILE - Require valid-user - ''; - } +{ + services.httpd.extraModules = [ + # note that order is *super* important here + { name = "dav_svn"; path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_dav_svn.so"; } + { name = "authz_svn"; path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_authz_svn.so"; } + ]; + services.httpd.virtualHosts = { + "svn" = { + hostName = HOSTNAME; + documentRoot = DOCUMENTROOT; + locations."/svn".extraConfig = '' + DAV svn + SVNParentPath REPO_PARENT + AuthzSVNAccessFile ACCESS_FILE + AuthName "SVN Repositories" + AuthType Basic + AuthUserFile PASSWORD_FILE + Require valid-user + ''; + }; + }; +} ``` The key `"svn"` is just a symbolic name identifying the virtual host. @@ -90,7 +95,7 @@ $ htpasswd -s PASSWORD_FILE USER_NAME The file describing access permissions `ACCESS_FILE` will look something like the following: -```nix +``` [/] * = r diff --git a/nixos/doc/manual/configuration/user-mgmt.chapter.md b/nixos/doc/manual/configuration/user-mgmt.chapter.md index 71d61ce4c641..7d83121d41e0 100644 --- a/nixos/doc/manual/configuration/user-mgmt.chapter.md +++ b/nixos/doc/manual/configuration/user-mgmt.chapter.md @@ -6,13 +6,15 @@ management. In the declarative style, users are specified in account named `alice` shall exist: ```nix -users.users.alice = { - isNormalUser = true; - home = "/home/alice"; - description = "Alice Foobar"; - extraGroups = [ "wheel" "networkmanager" ]; - openssh.authorizedKeys.keys = [ "ssh-dss AAAAB3Nza... alice@foobar" ]; -}; +{ + users.users.alice = { + isNormalUser = true; + home = "/home/alice"; + description = "Alice Foobar"; + extraGroups = [ "wheel" "networkmanager" ]; + openssh.authorizedKeys.keys = [ "ssh-dss AAAAB3Nza... alice@foobar" ]; + }; +} ``` Note that `alice` is a member of the `wheel` and `networkmanager` @@ -38,7 +40,9 @@ A user ID (uid) is assigned automatically. You can also specify a uid manually by adding ```nix -uid = 1000; +{ + uid = 1000; +} ``` to the user specification. @@ -47,7 +51,9 @@ Groups can be specified similarly. The following states that a group named `students` shall exist: ```nix -users.groups.students.gid = 1000; +{ + users.groups.students.gid = 1000; +} ``` As with users, the group ID (gid) is optional and will be assigned @@ -100,7 +106,9 @@ Instead of using a custom perl script to create users and groups, you can use systemd-sysusers: ```nix -systemd.sysusers.enable = true; +{ + systemd.sysusers.enable = true; +} ``` The primary benefit of this is to remove a dependency on perl. diff --git a/nixos/doc/manual/configuration/wayland.chapter.md b/nixos/doc/manual/configuration/wayland.chapter.md index 0f195bd66567..27c027d38514 100644 --- a/nixos/doc/manual/configuration/wayland.chapter.md +++ b/nixos/doc/manual/configuration/wayland.chapter.md @@ -9,7 +9,9 @@ a Wayland Compositor such as sway without separately enabling a Wayland server: ```nix +{ programs.sway.enable = true; +} ``` This installs the sway compositor along with some essential utilities. @@ -19,7 +21,9 @@ If you are using a wlroots-based compositor, like sway, and want to be able to share your screen, you might want to activate this option: ```nix -xdg.portal.wlr.enable = true; +{ + xdg.portal.wlr.enable = true; +} ``` and configure Pipewire using diff --git a/nixos/doc/manual/configuration/wireless.section.md b/nixos/doc/manual/configuration/wireless.section.md index 3299d2d7ecb8..df828698cf03 100644 --- a/nixos/doc/manual/configuration/wireless.section.md +++ b/nixos/doc/manual/configuration/wireless.section.md @@ -7,25 +7,29 @@ skip the rest of this section on wireless networks. NixOS will start wpa_supplicant for you if you enable this setting: ```nix -networking.wireless.enable = true; +{ + networking.wireless.enable = true; +} ``` NixOS lets you specify networks for wpa_supplicant declaratively: ```nix -networking.wireless.networks = { - echelon = { # SSID with no spaces or special characters - psk = "abcdefgh"; +{ + networking.wireless.networks = { + echelon = { # SSID with no spaces or special characters + psk = "abcdefgh"; + }; + "echelon's AP" = { # SSID with spaces and/or special characters + psk = "ijklmnop"; + }; + echelon = { # Hidden SSID + hidden = true; + psk = "qrstuvwx"; + }; + free.wifi = {}; # Public wireless network }; - "echelon's AP" = { # SSID with spaces and/or special characters - psk = "ijklmnop"; - }; - echelon = { # Hidden SSID - hidden = true; - psk = "qrstuvwx"; - }; - free.wifi = {}; # Public wireless network -}; +} ``` Be aware that keys will be written to the nix store in plaintext! When @@ -46,11 +50,13 @@ network={ ``` ```nix -networking.wireless.networks = { - echelon = { - pskRaw = "dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435"; +{ + networking.wireless.networks = { + echelon = { + pskRaw = "dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435"; + }; }; -}; +} ``` or you can use it to directly generate the `wpa_supplicant.conf`: diff --git a/nixos/doc/manual/configuration/x-windows.chapter.md b/nixos/doc/manual/configuration/x-windows.chapter.md index bf1872ae01ac..31752330dd9a 100644 --- a/nixos/doc/manual/configuration/x-windows.chapter.md +++ b/nixos/doc/manual/configuration/x-windows.chapter.md @@ -4,7 +4,9 @@ The X Window System (X11) provides the basis of NixOS' graphical user interface. It can be enabled as follows: ```nix -services.xserver.enable = true; +{ + services.xserver.enable = true; +} ``` The X server will automatically detect and use the appropriate video @@ -12,7 +14,9 @@ driver from a set of X.org drivers (such as `vesa` and `intel`). You can also specify a driver manually, e.g. ```nix -services.xserver.videoDrivers = [ "r128" ]; +{ + services.xserver.videoDrivers = [ "r128" ]; +} ``` to enable X.org's `xf86-video-r128` driver. @@ -22,15 +26,17 @@ Otherwise, you can only log into a plain undecorated `xterm` window. Thus you should pick one or more of the following lines: ```nix -services.xserver.desktopManager.plasma5.enable = true; -services.xserver.desktopManager.xfce.enable = true; -services.xserver.desktopManager.gnome.enable = true; -services.xserver.desktopManager.mate.enable = true; -services.xserver.windowManager.xmonad.enable = true; -services.xserver.windowManager.twm.enable = true; -services.xserver.windowManager.icewm.enable = true; -services.xserver.windowManager.i3.enable = true; -services.xserver.windowManager.herbstluftwm.enable = true; +{ + services.xserver.desktopManager.plasma5.enable = true; + services.xserver.desktopManager.xfce.enable = true; + services.xserver.desktopManager.gnome.enable = true; + services.xserver.desktopManager.mate.enable = true; + services.xserver.windowManager.xmonad.enable = true; + services.xserver.windowManager.twm.enable = true; + services.xserver.windowManager.icewm.enable = true; + services.xserver.windowManager.i3.enable = true; + services.xserver.windowManager.herbstluftwm.enable = true; +} ``` NixOS's default *display manager* (the program that provides a graphical @@ -38,22 +44,28 @@ login prompt and manages the X server) is LightDM. You can select an alternative one by picking one of the following lines: ```nix -services.xserver.displayManager.sddm.enable = true; -services.xserver.displayManager.gdm.enable = true; +{ + services.displayManager.sddm.enable = true; + services.xserver.displayManager.gdm.enable = true; +} ``` You can set the keyboard layout (and optionally the layout variant): ```nix -services.xserver.xkb.layout = "de"; -services.xserver.xkb.variant = "neo"; +{ + services.xserver.xkb.layout = "de"; + services.xserver.xkb.variant = "neo"; +} ``` The X server is started automatically at boot time. If you don't want this to happen, you can set: ```nix -services.xserver.autorun = false; +{ + services.xserver.autorun = false; +} ``` The X server can then be started manually: @@ -66,7 +78,9 @@ On 64-bit systems, if you want OpenGL for 32-bit programs such as in Wine, you should also set the following: ```nix -hardware.opengl.driSupport32Bit = true; +{ + hardware.opengl.driSupport32Bit = true; +} ``` ## Auto-login {#sec-x11-auto-login} @@ -84,16 +98,20 @@ desktop environment. If you wanted no desktop environment and i3 as your your window manager, you'd define: ```nix -services.xserver.displayManager.defaultSession = "none+i3"; +{ + services.displayManager.defaultSession = "none+i3"; +} ``` Every display manager in NixOS supports auto-login, here is an example using lightdm for a user `alice`: ```nix -services.xserver.displayManager.lightdm.enable = true; -services.xserver.displayManager.autoLogin.enable = true; -services.xserver.displayManager.autoLogin.user = "alice"; +{ + services.xserver.displayManager.lightdm.enable = true; + services.displayManager.autoLogin.enable = true; + services.displayManager.autoLogin.user = "alice"; +} ``` ## Intel Graphics drivers {#sec-x11--graphics-cards-intel} @@ -119,18 +137,22 @@ drivers. Use the option to set one. The recommended configuration for modern systems is: ```nix -services.xserver.videoDrivers = [ "modesetting" ]; +{ + services.xserver.videoDrivers = [ "modesetting" ]; +} ``` If you experience screen tearing no matter what, this configuration was reported to resolve the issue: ```nix -services.xserver.videoDrivers = [ "intel" ]; -services.xserver.deviceSection = '' - Option "DRI" "2" - Option "TearFree" "true" -''; +{ + services.xserver.videoDrivers = [ "intel" ]; + services.xserver.deviceSection = '' + Option "DRI" "2" + Option "TearFree" "true" + ''; +} ``` Note that this will likely downgrade the performance compared to @@ -143,17 +165,19 @@ better 3D performance than the X.org drivers. It is not enabled by default because it's not free software. You can enable it as follows: ```nix -services.xserver.videoDrivers = [ "nvidia" ]; +{ + services.xserver.videoDrivers = [ "nvidia" ]; +} ``` -Or if you have an older card, you may have to use one of the legacy -drivers: +If you have an older card, you may have to use one of the legacy drivers: ```nix -services.xserver.videoDrivers = [ "nvidiaLegacy470" ]; -services.xserver.videoDrivers = [ "nvidiaLegacy390" ]; -services.xserver.videoDrivers = [ "nvidiaLegacy340" ]; -services.xserver.videoDrivers = [ "nvidiaLegacy304" ]; +{ + hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_470; + hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_390; + hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_340; +} ``` You may need to reboot after enabling this driver to prevent a clash @@ -168,7 +192,9 @@ performance. If you still want to use it anyway, you need to explicitly set: ```nix -services.xserver.videoDrivers = [ "amdgpu-pro" ]; +{ + services.xserver.videoDrivers = [ "amdgpu-pro" ]; +} ``` You will need to reboot after enabling this driver to prevent a clash @@ -180,14 +206,18 @@ Support for Synaptics touchpads (found in many laptops such as the Dell Latitude series) can be enabled as follows: ```nix -services.xserver.libinput.enable = true; +{ + services.libinput.enable = true; +} ``` The driver has many options (see [](#ch-options)). For instance, the following disables tap-to-click behavior: ```nix -services.xserver.libinput.touchpad.tapping = false; +{ + services.libinput.touchpad.tapping = false; +} ``` Note: the use of `services.xserver.synaptics` is deprecated since NixOS @@ -200,9 +230,11 @@ GTK themes can be installed either to user profile or system-wide (via GTK ones, you can use the following configuration: ```nix -qt.enable = true; -qt.platformTheme = "gtk2"; -qt.style = "gtk2"; +{ + qt.enable = true; + qt.platformTheme = "gtk2"; + qt.style = "gtk2"; +} ``` ## Custom XKB layouts {#custom-xkb-layouts} @@ -219,7 +251,7 @@ Create a file called `us-greek` with the following content (under a directory called `symbols`; it's an XKB peculiarity that will help with testing): -```nix +``` xkb_symbols "us-greek" { include "us(basic)" // includes the base US keys @@ -236,11 +268,13 @@ xkb_symbols "us-greek" A minimal layout specification must include the following: ```nix -services.xserver.xkb.extraLayouts.us-greek = { - description = "US layout with alt-gr greek"; - languages = [ "eng" ]; - symbolsFile = /yourpath/symbols/us-greek; -}; +{ + services.xserver.xkb.extraLayouts.us-greek = { + description = "US layout with alt-gr greek"; + languages = [ "eng" ]; + symbolsFile = /yourpath/symbols/us-greek; + }; +} ``` ::: {.note} @@ -277,7 +311,7 @@ Use the *xev* utility from `pkgs.xorg.xev` to find the codes of the keys of interest, then create a `media-key` file to hold the keycodes definitions -```nix +``` xkb_keycodes "media" { = 123; @@ -287,7 +321,7 @@ xkb_keycodes "media" Now use the newly define keycodes in `media-sym`: -```nix +``` xkb_symbols "media" { key.type = "ONE_LEVEL"; @@ -299,12 +333,14 @@ xkb_symbols "media" As before, to install the layout do ```nix -services.xserver.xkb.extraLayouts.media = { - description = "Multimedia keys remapping"; - languages = [ "eng" ]; - symbolsFile = /path/to/media-key; - keycodesFile = /path/to/media-sym; -}; +{ + services.xserver.xkb.extraLayouts.media = { + description = "Multimedia keys remapping"; + languages = [ "eng" ]; + symbolsFile = /path/to/media-key; + keycodesFile = /path/to/media-sym; + }; +} ``` ::: {.note} @@ -320,7 +356,9 @@ workaround, you can set the keymap using `setxkbmap` at the start of the session with: ```nix -services.xserver.displayManager.sessionCommands = "setxkbmap -keycodes media"; +{ + services.xserver.displayManager.sessionCommands = "setxkbmap -keycodes media"; +} ``` If you are manually starting the X server, you should set the argument diff --git a/nixos/doc/manual/configuration/xfce.chapter.md b/nixos/doc/manual/configuration/xfce.chapter.md index 9ec4a51d6e35..302cf9fa093d 100644 --- a/nixos/doc/manual/configuration/xfce.chapter.md +++ b/nixos/doc/manual/configuration/xfce.chapter.md @@ -3,21 +3,25 @@ To enable the Xfce Desktop Environment, set ```nix -services.xserver.desktopManager.xfce.enable = true; -services.xserver.displayManager.defaultSession = "xfce"; +{ + services.xserver.desktopManager.xfce.enable = true; + services.displayManager.defaultSession = "xfce"; +} ``` Optionally, *picom* can be enabled for nice graphical effects, some example settings: ```nix -services.picom = { - enable = true; - fade = true; - inactiveOpacity = 0.9; - shadow = true; - fadeDelta = 4; -}; +{ + services.picom = { + enable = true; + fade = true; + inactiveOpacity = 0.9; + shadow = true; + fadeDelta = 4; + }; +} ``` Some Xfce programs are not installed automatically. To install them diff --git a/nixos/doc/manual/default.nix b/nixos/doc/manual/default.nix index 5f51bb53ad7f..558fec4cab92 100644 --- a/nixos/doc/manual/default.nix +++ b/nixos/doc/manual/default.nix @@ -9,12 +9,20 @@ , prefix ? ../../.. }: -with pkgs; - let - inherit (lib) hasPrefix removePrefix; + inherit (pkgs) buildPackages runCommand docbook_xsl_ns; - lib = pkgs.lib; + inherit (pkgs.lib) + hasPrefix + removePrefix + flip + foldr + types + mkOption + escapeShellArg + concatMapStringsSep + sourceFilesBySuffices + ; common = import ./common.nix; @@ -27,7 +35,7 @@ let # E.g. if some `options` came from modules in ${pkgs.customModules}/nix, # you'd need to include `extraSources = [ pkgs.customModules ]` prefixesToStrip = map (p: "${toString p}/") ([ prefix ] ++ extraSources); - stripAnyPrefixes = lib.flip (lib.foldr lib.removePrefix) prefixesToStrip; + stripAnyPrefixes = flip (foldr removePrefix) prefixesToStrip; optionsDoc = buildPackages.nixosOptionsDoc { inherit options revision baseOptionsJSON warningsAreErrors; @@ -42,8 +50,8 @@ let testOptionsDoc = let eval = nixos-lib.evalTest { # Avoid evaluating a NixOS config prototype. - config.node.type = lib.types.deferredModule; - options._module.args = lib.mkOption { internal = true; }; + config.node.type = types.deferredModule; + options._module.args = mkOption { internal = true; }; }; in buildPackages.nixosOptionsDoc { inherit (eval) options; @@ -76,7 +84,7 @@ let substituteInPlace ./configuration/configuration.md \ --replace \ '@MODULE_CHAPTERS@' \ - ${lib.escapeShellArg (lib.concatMapStringsSep "\n" (p: "${p.value}") config.meta.doc)} + ${escapeShellArg (concatMapStringsSep "\n" (p: "${p.value}") config.meta.doc)} substituteInPlace ./nixos-options.md \ --replace \ '@NIXOS_OPTIONS_JSON@' \ @@ -95,7 +103,7 @@ in rec { # Generate the NixOS manual. manualHTML = runCommand "nixos-manual-html" { nativeBuildInputs = [ buildPackages.nixos-render-docs ]; - inputs = lib.sourceFilesBySuffices ./. [ ".md" ]; + inputs = sourceFilesBySuffices ./. [ ".md" ]; meta.description = "The NixOS manual in HTML format"; allowedReferences = ["out"]; } @@ -114,8 +122,8 @@ in rec { nixos-render-docs -j $NIX_BUILD_CORES manual html \ --manpage-urls ${manpageUrls} \ - --revision ${lib.escapeShellArg revision} \ - --generator "nixos-render-docs ${lib.version}" \ + --revision ${escapeShellArg revision} \ + --generator "nixos-render-docs ${pkgs.lib.version}" \ --stylesheet style.css \ --stylesheet highlightjs/mono-blue.css \ --script ./highlightjs/highlight.pack.js \ @@ -147,7 +155,7 @@ in rec { xml:id="book-nixos-manual"> NixOS Manual - Version ${lib.version} + Version ${pkgs.lib.version} Temporarily unavailable @@ -199,7 +207,7 @@ in rec { # Generate manpages. mkdir -p $out/share/man/man5 nixos-render-docs -j $NIX_BUILD_CORES options manpage \ - --revision ${lib.escapeShellArg revision} \ + --revision ${escapeShellArg revision} \ ${optionsJSON}/${common.outputPath}/options.json \ $out/share/man/man5/configuration.nix.5 ''; diff --git a/nixos/doc/manual/development/activation-script.section.md b/nixos/doc/manual/development/activation-script.section.md index cc317a6a01aa..f771c3524b79 100644 --- a/nixos/doc/manual/development/activation-script.section.md +++ b/nixos/doc/manual/development/activation-script.section.md @@ -17,13 +17,15 @@ activation script will take these dependencies into account and order the snippets accordingly. As a simple example: ```nix -system.activationScripts.my-activation-script = { - deps = [ "etc" ]; - # supportsDryActivation = true; - text = '' - echo "Hallo i bims" - ''; -}; +{ + system.activationScripts.my-activation-script = { + deps = [ "etc" ]; + # supportsDryActivation = true; + text = '' + echo "Hallo i bims" + ''; + }; +} ``` This example creates an activation script snippet that is run after the `etc` diff --git a/nixos/doc/manual/development/assertions.section.md b/nixos/doc/manual/development/assertions.section.md index cc6d81e56990..eb5158c90f98 100644 --- a/nixos/doc/manual/development/assertions.section.md +++ b/nixos/doc/manual/development/assertions.section.md @@ -18,7 +18,7 @@ This is an example of using `warnings`. This is known to cause some specific problems in certain situations. '' ] else []; - } + }; } ``` @@ -35,6 +35,6 @@ This example, extracted from the [`syslogd` module](https://github.com/NixOS/nix message = "rsyslogd conflicts with syslogd"; } ]; - } + }; } ``` diff --git a/nixos/doc/manual/development/etc-overlay.section.md b/nixos/doc/manual/development/etc-overlay.section.md index e6f6d8d4ca1e..d8588f508a26 100644 --- a/nixos/doc/manual/development/etc-overlay.section.md +++ b/nixos/doc/manual/development/etc-overlay.section.md @@ -9,7 +9,9 @@ Instead of using a custom perl script to activate `/etc`, you activate it via an overlay filesystem: ```nix -system.etc.overlay.enable = true; +{ + system.etc.overlay.enable = true; +} ``` Using an overlay has two benefits: @@ -22,7 +24,9 @@ upper layer). However, you can also mount `/etc` immutably (i.e. read-only) by setting: ```nix -system.etc.overlay.mutable = false; +{ + system.etc.overlay.mutable = false; +} ``` The overlay is atomically replaced during system switch. However, files that diff --git a/nixos/doc/manual/development/meta-attributes.section.md b/nixos/doc/manual/development/meta-attributes.section.md index 33b41fe74d29..b2ad23e58b94 100644 --- a/nixos/doc/manual/development/meta-attributes.section.md +++ b/nixos/doc/manual/development/meta-attributes.section.md @@ -14,11 +14,11 @@ file. { config, lib, pkgs, ... }: { options = { - ... + # ... }; config = { - ... + # ... }; meta = { diff --git a/nixos/doc/manual/development/non-switchable-systems.section.md b/nixos/doc/manual/development/non-switchable-systems.section.md index 87bb46c78909..a51e8233f30b 100644 --- a/nixos/doc/manual/development/non-switchable-systems.section.md +++ b/nixos/doc/manual/development/non-switchable-systems.section.md @@ -9,7 +9,7 @@ profile: ```nix { modulesPath, ... }: { - imports = [ "${modulesPath}/profiles/image-based-appliance.nix" ] + imports = [ "${modulesPath}/profiles/image-based-appliance.nix" ]; } ``` diff --git a/nixos/doc/manual/development/option-declarations.section.md b/nixos/doc/manual/development/option-declarations.section.md index 762070416187..325f4d11cb08 100644 --- a/nixos/doc/manual/development/option-declarations.section.md +++ b/nixos/doc/manual/development/option-declarations.section.md @@ -6,14 +6,16 @@ hasn't been declared in any module. An option declaration generally looks like this: ```nix -options = { - name = mkOption { - type = type specification; - default = default value; - example = example value; - description = lib.mdDoc "Description for use in the NixOS manual."; +{ + options = { + name = mkOption { + type = type specification; + default = default value; + example = example value; + description = "Description for use in the NixOS manual."; + }; }; -}; +} ``` The attribute names within the `name` attribute path must be camel @@ -56,12 +58,9 @@ The function `mkOption` accepts the following arguments. `description` -: A textual description of the option, in [Nixpkgs-flavored Markdown]( - https://nixos.org/nixpkgs/manual/#sec-contributing-markup) format, that will be - included in the NixOS manual. During the migration process from DocBook - it is necessary to mark descriptions written in CommonMark with `lib.mdDoc`. - The description may still be written in DocBook (without any marker), but this - is discouraged and will be deprecated in the future. +: A textual description of the option in [Nixpkgs-flavored Markdown]( + https://nixos.org/nixpkgs/manual/#sec-contributing-markup) format that will be + included in the NixOS manual. ## Utility functions for common option patterns {#sec-option-declarations-util} @@ -79,13 +78,13 @@ For example: ::: {#ex-options-declarations-util-mkEnableOption-magic .example} ### `mkEnableOption` usage ```nix -lib.mkEnableOption (lib.mdDoc "magic") +lib.mkEnableOption "magic" # is like lib.mkOption { type = lib.types.bool; default = false; example = true; - description = lib.mdDoc "Whether to enable magic."; + description = "Whether to enable magic."; } ``` ::: @@ -133,7 +132,7 @@ lib.mkOption { type = lib.types.package; default = pkgs.hello; defaultText = lib.literalExpression "pkgs.hello"; - description = lib.mdDoc "The hello package to use."; + description = "The hello package to use."; } ``` ::: @@ -151,7 +150,7 @@ lib.mkOption { default = pkgs.ghc; defaultText = lib.literalExpression "pkgs.ghc"; example = lib.literalExpression "pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])"; - description = lib.mdDoc "The GHC package to use."; + description = "The GHC package to use."; } ``` ::: @@ -221,28 +220,34 @@ enforces that there can only be a single display manager enabled. ::: {#ex-option-declaration-eot-service .example} ### Extensible type placeholder in the service module ```nix -services.xserver.displayManager.enable = mkOption { - description = "Display manager to use"; - type = with types; nullOr (enum [ ]); -}; +{ + services.xserver.displayManager.enable = mkOption { + description = "Display manager to use"; + type = with types; nullOr (enum [ ]); + }; +} ``` ::: ::: {#ex-option-declaration-eot-backend-gdm .example} ### Extending `services.xserver.displayManager.enable` in the `gdm` module ```nix -services.xserver.displayManager.enable = mkOption { - type = with types; nullOr (enum [ "gdm" ]); -}; +{ + services.xserver.displayManager.enable = mkOption { + type = with types; nullOr (enum [ "gdm" ]); + }; +} ``` ::: ::: {#ex-option-declaration-eot-backend-sddm .example} ### Extending `services.xserver.displayManager.enable` in the `sddm` module ```nix -services.xserver.displayManager.enable = mkOption { - type = with types; nullOr (enum [ "sddm" ]); -}; +{ + services.xserver.displayManager.enable = mkOption { + type = with types; nullOr (enum [ "sddm" ]); + }; +} ``` ::: diff --git a/nixos/doc/manual/development/option-def.section.md b/nixos/doc/manual/development/option-def.section.md index 6a3dc26b99be..227f41d812ff 100644 --- a/nixos/doc/manual/development/option-def.section.md +++ b/nixos/doc/manual/development/option-def.section.md @@ -4,9 +4,11 @@ Option definitions are generally straight-forward bindings of values to option names, like ```nix -config = { - services.httpd.enable = true; -}; +{ + config = { + services.httpd.enable = true; + }; +} ``` However, sometimes you need to wrap an option definition or set of @@ -18,10 +20,12 @@ If a set of option definitions is conditional on the value of another option, you may need to use `mkIf`. Consider, for instance: ```nix -config = if config.services.httpd.enable then { - environment.systemPackages = [ ... ]; - ... -} else {}; +{ + config = if config.services.httpd.enable then { + environment.systemPackages = [ /* ... */ ]; + # ... + } else {}; +} ``` This definition will cause Nix to fail with an "infinite recursion" @@ -30,30 +34,36 @@ on the value being constructed here. After all, you could also write the clearly circular and contradictory: ```nix -config = if config.services.httpd.enable then { - services.httpd.enable = false; -} else { - services.httpd.enable = true; -}; +{ + config = if config.services.httpd.enable then { + services.httpd.enable = false; + } else { + services.httpd.enable = true; + }; +} ``` The solution is to write: ```nix -config = mkIf config.services.httpd.enable { - environment.systemPackages = [ ... ]; - ... -}; +{ + config = mkIf config.services.httpd.enable { + environment.systemPackages = [ /* ... */ ]; + # ... + }; +} ``` The special function `mkIf` causes the evaluation of the conditional to be "pushed down" into the individual definitions, as if you had written: ```nix -config = { - environment.systemPackages = if config.services.httpd.enable then [ ... ] else []; - ... -}; +{ + config = { + environment.systemPackages = if config.services.httpd.enable then [ /* ... */ ] else []; + # ... + }; +} ``` ## Setting Priorities {#sec-option-definitions-setting-priorities} @@ -65,7 +75,9 @@ priority 100 and option defaults have priority 1500. You can specify an explicit priority by using `mkOverride`, e.g. ```nix -services.openssh.enable = mkOverride 10 false; +{ + services.openssh.enable = mkOverride 10 false; +} ``` This definition causes all other definitions with priorities above 10 to @@ -80,7 +92,9 @@ The functions `mkBefore` and `mkAfter` are equal to `mkOrder 500` and `mkOrder 1 As an example, ```nix -hardware.firmware = mkBefore [ myFirmware ]; +{ + hardware.firmware = mkBefore [ myFirmware ]; +} ``` This definition ensures that `myFirmware` comes before other unordered @@ -97,13 +111,15 @@ they were declared in separate modules. This can be done using `mkMerge`: ```nix -config = mkMerge - [ # Unconditional stuff. - { environment.systemPackages = [ ... ]; - } - # Conditional stuff. - (mkIf config.services.bla.enable { - environment.systemPackages = [ ... ]; - }) - ]; +{ + config = mkMerge + [ # Unconditional stuff. + { environment.systemPackages = [ /* ... */ ]; + } + # Conditional stuff. + (mkIf config.services.bla.enable { + environment.systemPackages = [ /* ... */ ]; + }) + ]; +} ``` diff --git a/nixos/doc/manual/development/option-types.section.md b/nixos/doc/manual/development/option-types.section.md index 04edf99e70b0..b44a84553b37 100644 --- a/nixos/doc/manual/development/option-types.section.md +++ b/nixos/doc/manual/development/option-types.section.md @@ -42,6 +42,9 @@ merging is handled. : One element of the list *`l`*, e.g. `types.enum [ "left" "right" ]`. Multiple definitions cannot be merged. + If you want to pair these values with more information, possibly of + distinct types, consider using a [sum type](#sec-option-types-sums). + `types.anything` : A type that accepts any value and recursively merges attribute sets @@ -279,6 +282,84 @@ Submodules are detailed in [Submodule](#section-option-types-submodule). more convenient and discoverable than expecting the module user to type-merge with the `attrsOf submodule` option. +## Union types {#sec-option-types-unions} + +A union of types is a type such that a value is valid when it is valid for at least one of those types. + +If some values are instances of more than one of the types, it is not possible to distinguish which type they are meant to be instances of. If that's needed, consider using a [sum type](#sec-option-types-sums). + +`types.either` *`t1 t2`* + +: Type *`t1`* or type *`t2`*, e.g. `with types; either int str`. + Multiple definitions cannot be merged. + +`types.oneOf` \[ *`t1 t2`* ... \] + +: Type *`t1`* or type *`t2`* and so forth, e.g. + `with types; oneOf [ int str bool ]`. Multiple definitions cannot be + merged. + +`types.nullOr` *`t`* + +: `null` or type *`t`*. Multiple definitions are merged according to + type *`t`*. + + +## Sum types {#sec-option-types-sums} + +A sum type can be thought of, conceptually, as a *`types.enum`* where each valid item is paired with at least a type, through some value syntax. +Nix does not have a built-in syntax for this pairing of a label and a type or value, so sum types may be represented in multiple ways. + +If the you're interested in can be distinguished without a label, you may simplify your value syntax with a [union type](#sec-option-types-unions) instead. + +`types.attrTag` *`{ attr1 = option1; attr2 = option2; ... }`* + +: An attribute set containing one attribute, whose name must be picked from + the attribute set (`attr1`, etc) and whose value consists of definitions that are valid for the corresponding option (`option1`, etc). + + This type appears in the documentation as _attribute-tagged union_. + + Example: + + ```nix + { lib, ... }: + let inherit (lib) type mkOption; + in { + options.toyRouter.rules = mkOption { + description = '' + Rules for a fictional packet routing service. + ''; + type = types.attrsOf ( + types.attrTag { + bounce = mkOption { + description = "Send back a packet explaining why it wasn't forwarded."; + type = types.submodule { + options.errorMessage = mkOption { … }; + }; + }; + forward = mkOption { + description = "Forward the packet."; + type = types.submodule { + options.destination = mkOption { … }; + }; + }; + ignore = types.mkOption { + description = "Drop the packet without sending anything back."; + type = types.submodule {}; + }; + }); + }; + config.toyRouter.rules = { + http = { + bounce = { + errorMessage = "Unencrypted HTTP is banned. You must always use https://."; + }; + }; + ssh = { drop = {}; }; + }; + } + ``` + ## Composed types {#sec-option-types-composed} Composed types are types that take a type as parameter. `listOf @@ -318,11 +399,6 @@ Composed types are types that take a type as parameter. `listOf returned instead for the same `mkIf false` definition. ::: -`types.nullOr` *`t`* - -: `null` or type *`t`*. Multiple definitions are merged according to - type *`t`*. - `types.uniq` *`t`* : Ensures that type *`t`* cannot be merged. It is used to ensure option @@ -334,17 +410,6 @@ Composed types are types that take a type as parameter. `listOf the line `The option