mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-06 13:23:41 +00:00
Compare commits
1 Commits
24.05-pre
...
netboot-sy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eea01712af |
@@ -39,60 +39,3 @@ d1c1a0c656ccd8bd3b25d3c4287f2d075faf3cf3
|
||||
|
||||
# fix indentation in meteor default.nix
|
||||
a37a6de881ec4c6708e6b88fd16256bbc7f26bbd
|
||||
|
||||
# treewide: automatically md-convert option descriptions
|
||||
2e751c0772b9d48ff6923569adfa661b030ab6a2
|
||||
|
||||
# nixos/*: automatically convert option docs
|
||||
087472b1e5230ffc8ba642b1e4f9218adf4634a2
|
||||
|
||||
# nixos/*: automatically convert option descriptions
|
||||
ef176dcf7e76c3639571d7c6051246c8fbadf12a
|
||||
|
||||
# nixos/*: automatically convert option docs to MD
|
||||
61e93df1891972bae3e0c97a477bd44e8a477aa0
|
||||
|
||||
# nixos/*: convert options with admonitions to MD
|
||||
722b99bc0eb57711c0498a86a3f55e6c69cdb05f
|
||||
|
||||
# nixos/*: automatically convert option docs
|
||||
6039648c50c7c0858b5e506c6298773a98e0f066
|
||||
|
||||
# nixos/*: md-convert options with unordered lists
|
||||
c915b915b5e466a0b0b2af2906cd4d2380b8a1de
|
||||
|
||||
# nixos/*: convert options with listings
|
||||
f2ea09ecbe1fa1da32eaa6e036d64ac324a2986f
|
||||
|
||||
# nixos/*: convert straggler options to MD
|
||||
1d41cff3dc4c8f37bb5841f51fcbff705e169178
|
||||
|
||||
# nixos/*: normalize manpage references to single-line form
|
||||
423545fe4865d126e86721ba30da116e29c65004
|
||||
|
||||
# nixos/documentation: split options doc build
|
||||
fc614c37c653637e5475a0b0a987489b4d1f351d
|
||||
|
||||
# nixos/*: convert options with admonitions to MD
|
||||
722b99bc0eb57711c0498a86a3f55e6c69cdb05f
|
||||
|
||||
# nixos/*: convert internal option descriptions to MD
|
||||
9547123258f69efd92b54763051d6dc7f3bfcaca
|
||||
|
||||
# nixos/*: replace </para><para> with double linebreaks
|
||||
694d5b19d30bf66687b42fb77f43ea7cd1002a62
|
||||
|
||||
# treewide: add defaultText for options with simple interpolation defaults
|
||||
fb0e5be84331188a69b3edd31679ca6576edb75a
|
||||
|
||||
# nixos/*: mark pre-existing markdown descriptions as mdDoc
|
||||
7e7d68a250f75678451cd44f8c3d585bf750461e
|
||||
|
||||
# nixos/*: normalize link format
|
||||
3aebb4a2be8821a6d8a695f0908d8567dc00de31
|
||||
|
||||
# nixos/*: replace <code> in option docs with <literal>
|
||||
16102dce2fbad670bd47dd75c860a8daa5fe47ad
|
||||
|
||||
# nixos/*: add trivial defaultText for options with simple defaults
|
||||
25124556397ba17bfd70297000270de1e6523b0a
|
||||
|
||||
160
.github/CODEOWNERS
vendored
160
.github/CODEOWNERS
vendored
@@ -11,6 +11,9 @@
|
||||
# This also holds true for GitHub teams. Since almost none of our teams have write
|
||||
# permissions, you need to list all members of the team with commit access individually.
|
||||
|
||||
# This file
|
||||
/.github/CODEOWNERS @edolstra
|
||||
|
||||
# GitHub actions
|
||||
/.github/workflows @NixOS/Security @Mic92 @zowoq
|
||||
/.github/workflows/merge-staging @FRidh
|
||||
@@ -19,65 +22,49 @@
|
||||
/.editorconfig @Mic92 @zowoq
|
||||
|
||||
# Libraries
|
||||
/lib @infinisil
|
||||
/lib/systems @alyssais @ericson2314 @amjoseph-nixpkgs
|
||||
/lib/generators.nix @infinisil @Profpatsch
|
||||
/lib/cli.nix @infinisil @Profpatsch
|
||||
/lib/debug.nix @infinisil @Profpatsch
|
||||
/lib/asserts.nix @infinisil @Profpatsch
|
||||
/lib @edolstra @infinisil
|
||||
/lib/systems @alyssais @ericson2314 @matthewbauer
|
||||
/lib/generators.nix @edolstra @Profpatsch
|
||||
/lib/cli.nix @edolstra @Profpatsch
|
||||
/lib/debug.nix @edolstra @Profpatsch
|
||||
/lib/asserts.nix @edolstra @Profpatsch
|
||||
/lib/path.* @infinisil @fricklerhandwerk
|
||||
/lib/fileset @infinisil
|
||||
|
||||
# Nixpkgs Internals
|
||||
/default.nix @Ericson2314
|
||||
/pkgs/top-level/default.nix @Ericson2314
|
||||
/pkgs/top-level/impure.nix @Ericson2314
|
||||
/pkgs/top-level/stage.nix @Ericson2314
|
||||
/pkgs/top-level/splice.nix @Ericson2314
|
||||
/pkgs/top-level/release-cross.nix @Ericson2314
|
||||
/pkgs/stdenv/generic @Ericson2314 @amjoseph-nixpkgs
|
||||
/pkgs/stdenv/generic/check-meta.nix @Ericson2314 @piegamesde
|
||||
/pkgs/stdenv/cross @Ericson2314 @amjoseph-nixpkgs
|
||||
/pkgs/build-support/cc-wrapper @Ericson2314 @amjoseph-nixpkgs
|
||||
/pkgs/top-level/stage.nix @Ericson2314 @matthewbauer
|
||||
/pkgs/top-level/splice.nix @Ericson2314 @matthewbauer
|
||||
/pkgs/top-level/release-cross.nix @Ericson2314 @matthewbauer
|
||||
/pkgs/stdenv/generic @Ericson2314 @matthewbauer
|
||||
/pkgs/stdenv/generic/check-meta.nix @Ericson2314 @matthewbauer @piegamesde
|
||||
/pkgs/stdenv/cross @Ericson2314 @matthewbauer
|
||||
/pkgs/build-support/cc-wrapper @Ericson2314
|
||||
/pkgs/build-support/bintools-wrapper @Ericson2314
|
||||
/pkgs/build-support/setup-hooks @Ericson2314
|
||||
/pkgs/build-support/setup-hooks/auto-patchelf.sh @layus
|
||||
/pkgs/build-support/setup-hooks/auto-patchelf.py @layus
|
||||
/pkgs/pkgs-lib @infinisil
|
||||
## Format generators/serializers
|
||||
/pkgs/pkgs-lib/formats/libconfig @ckiee
|
||||
|
||||
# pkgs/by-name
|
||||
/pkgs/test/nixpkgs-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
|
||||
|
||||
# Nixpkgs build-support
|
||||
/pkgs/build-support/writers @lassulus @Profpatsch
|
||||
|
||||
# Nixpkgs make-disk-image
|
||||
/doc/build-helpers/images/makediskimage.section.md @raitobezarius
|
||||
/doc/builders/images/makediskimage.section.md @raitobezarius
|
||||
/nixos/lib/make-disk-image.nix @raitobezarius
|
||||
|
||||
# Nixpkgs documentation
|
||||
/maintainers/scripts/db-to-md.sh @jtojnar @ryantm
|
||||
/maintainers/scripts/doc @jtojnar @ryantm
|
||||
|
||||
# Contributor documentation
|
||||
/CONTRIBUTING.md @infinisil
|
||||
/.github/PULL_REQUEST_TEMPLATE.md @infinisil
|
||||
/doc/contributing/ @fricklerhandwerk @infinisil
|
||||
/doc/contributing/contributing-to-documentation.chapter.md @jtojnar @fricklerhandwerk @infinisil
|
||||
/lib/README.md @infinisil
|
||||
/doc/README.md @infinisil
|
||||
/nixos/README.md @infinisil
|
||||
/pkgs/README.md @infinisil
|
||||
/maintainers/README.md @infinisil
|
||||
|
||||
# User-facing development documentation
|
||||
/doc/development.md @infinisil
|
||||
/doc/development @infinisil
|
||||
/doc/* @fricklerhandwerk
|
||||
/doc/build-aux/pandoc-filters @jtojnar
|
||||
/doc/builders/trivial-builders.chapter.md @fricklerhandwerk
|
||||
/doc/contributing/ @fricklerhandwerk
|
||||
/doc/contributing/contributing-to-documentation.chapter.md @jtojnar @fricklerhandwerk
|
||||
/doc/stdenv @fricklerhandwerk
|
||||
/doc/using @fricklerhandwerk
|
||||
|
||||
# NixOS Internals
|
||||
/nixos/default.nix @infinisil
|
||||
@@ -99,10 +86,6 @@
|
||||
/nixos/lib/systemd-*.nix @NixOS/systemd
|
||||
/pkgs/os-specific/linux/systemd @NixOS/systemd
|
||||
|
||||
# Images and installer media
|
||||
/nixos/modules/installer/cd-dvd/ @samueldr
|
||||
/nixos/modules/installer/sd-card/ @samueldr
|
||||
|
||||
# Updaters
|
||||
## update.nix
|
||||
/maintainers/scripts/update.nix @jtojnar
|
||||
@@ -114,16 +97,17 @@
|
||||
/maintainers/scripts/update-python-libraries @FRidh
|
||||
/pkgs/development/interpreters/python @FRidh
|
||||
/doc/languages-frameworks/python.section.md @FRidh @mweinelt
|
||||
/pkgs/development/tools/poetry2nix @adisbladis
|
||||
/pkgs/development/interpreters/python/hooks @FRidh @jonringer
|
||||
|
||||
# Haskell
|
||||
/doc/languages-frameworks/haskell.section.md @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/maintainers/scripts/haskell @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/development/compilers/ghc @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/development/haskell-modules @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/test/haskell @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/top-level/release-haskell.nix @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/top-level/haskell-packages.nix @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/doc/languages-frameworks/haskell.section.md @cdepillabout @sternenseemann @maralorn
|
||||
/maintainers/scripts/haskell @cdepillabout @sternenseemann @maralorn
|
||||
/pkgs/development/compilers/ghc @cdepillabout @sternenseemann @maralorn
|
||||
/pkgs/development/haskell-modules @cdepillabout @sternenseemann @maralorn
|
||||
/pkgs/test/haskell @cdepillabout @sternenseemann @maralorn
|
||||
/pkgs/top-level/release-haskell.nix @cdepillabout @sternenseemann @maralorn
|
||||
/pkgs/top-level/haskell-packages.nix @cdepillabout @sternenseemann @maralorn
|
||||
|
||||
# Perl
|
||||
/pkgs/development/interpreters/perl @stigtsp @zakame @dasJ
|
||||
@@ -144,10 +128,12 @@
|
||||
/doc/languages-frameworks/rust.section.md @zowoq @winterqt @figsoda
|
||||
|
||||
# C compilers
|
||||
/pkgs/development/compilers/gcc @amjoseph-nixpkgs
|
||||
/pkgs/development/compilers/llvm @RaitoBezarius
|
||||
/pkgs/development/compilers/emscripten @raitobezarius
|
||||
/doc/languages-frameworks/emscripten.section.md @raitobezarius
|
||||
/pkgs/development/compilers/gcc @matthewbauer
|
||||
/pkgs/development/compilers/llvm @matthewbauer @RaitoBezarius
|
||||
|
||||
# Compatibility stuff
|
||||
/pkgs/top-level/unix-tools.nix @matthewbauer
|
||||
/pkgs/development/tools/xcbuild @matthewbauer
|
||||
|
||||
# Audio
|
||||
/nixos/modules/services/audio/botamusique.nix @mweinelt
|
||||
@@ -214,11 +200,6 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt
|
||||
/nixos/tests/kea.nix @mweinelt
|
||||
/nixos/tests/knot.nix @mweinelt
|
||||
|
||||
# Web servers
|
||||
/doc/packages/nginx.section.md @raitobezarius
|
||||
/pkgs/servers/http/nginx/ @raitobezarius
|
||||
/nixos/modules/services/web-servers/nginx/ @raitobezarius
|
||||
|
||||
# Dhall
|
||||
/pkgs/development/dhall-modules @Gabriella439 @Profpatsch @ehmry
|
||||
/pkgs/development/interpreters/dhall @Gabriella439 @Profpatsch @ehmry
|
||||
@@ -249,26 +230,30 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt
|
||||
# VsCode Extensions
|
||||
/pkgs/applications/editors/vscode/extensions @jonringer
|
||||
|
||||
# Prometheus exporter modules and tests
|
||||
/nixos/modules/services/monitoring/prometheus/exporters.nix @WilliButz
|
||||
/nixos/modules/services/monitoring/prometheus/exporters.xml @WilliButz
|
||||
/nixos/tests/prometheus-exporters.nix @WilliButz
|
||||
|
||||
# PHP interpreter, packages, extensions, tests and documentation
|
||||
/doc/languages-frameworks/php.section.md @aanderse @drupol @etu @globin @ma27 @talyz
|
||||
/nixos/tests/php @aanderse @drupol @etu @globin @ma27 @talyz
|
||||
/pkgs/build-support/php/build-pecl.nix @aanderse @drupol @etu @globin @ma27 @talyz
|
||||
/pkgs/build-support/php @drupol @etu
|
||||
/pkgs/development/interpreters/php @jtojnar @aanderse @drupol @etu @globin @ma27 @talyz
|
||||
/pkgs/development/php-packages @aanderse @drupol @etu @globin @ma27 @talyz
|
||||
/pkgs/top-level/php-packages.nix @jtojnar @aanderse @drupol @etu @globin @ma27 @talyz
|
||||
/doc/languages-frameworks/php.section.md @aanderse @etu @globin @ma27 @talyz
|
||||
/nixos/tests/php @aanderse @etu @globin @ma27 @talyz
|
||||
/pkgs/build-support/build-pecl.nix @aanderse @etu @globin @ma27 @talyz
|
||||
/pkgs/development/interpreters/php @jtojnar @aanderse @etu @globin @ma27 @talyz
|
||||
/pkgs/development/php-packages @aanderse @etu @globin @ma27 @talyz
|
||||
/pkgs/top-level/php-packages.nix @jtojnar @aanderse @etu @globin @ma27 @talyz
|
||||
|
||||
# Podman, CRI-O modules and related
|
||||
/nixos/modules/virtualisation/containers.nix @adisbladis
|
||||
/nixos/modules/virtualisation/cri-o.nix @adisbladis
|
||||
/nixos/modules/virtualisation/podman @adisbladis
|
||||
/nixos/tests/cri-o.nix @adisbladis
|
||||
/nixos/tests/podman @adisbladis
|
||||
/nixos/modules/virtualisation/containers.nix @zowoq @adisbladis
|
||||
/nixos/modules/virtualisation/cri-o.nix @zowoq @adisbladis
|
||||
/nixos/modules/virtualisation/podman @zowoq @adisbladis
|
||||
/nixos/tests/cri-o.nix @zowoq @adisbladis
|
||||
/nixos/tests/podman @zowoq @adisbladis
|
||||
|
||||
# Docker tools
|
||||
/pkgs/build-support/docker @roberth
|
||||
/nixos/tests/docker-tools* @roberth
|
||||
/doc/build-helpers/images/dockertools.section.md @roberth
|
||||
/doc/builders/images/dockertools.section.md @roberth
|
||||
|
||||
# Blockchains
|
||||
/pkgs/applications/blockchains @mmahut @RaghavSood
|
||||
@@ -294,6 +279,12 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt
|
||||
# terraform providers
|
||||
/pkgs/applications/networking/cluster/terraform-providers @zowoq
|
||||
|
||||
# kubernetes
|
||||
/nixos/doc/manual/configuration/kubernetes.chapter.md @zowoq
|
||||
/nixos/modules/services/cluster/kubernetes @zowoq
|
||||
/nixos/tests/kubernetes @zowoq
|
||||
/pkgs/applications/networking/cluster/kubernetes @zowoq
|
||||
|
||||
# Matrix
|
||||
/pkgs/servers/heisenbridge @piegamesde
|
||||
/pkgs/servers/matrix-conduit @piegamesde
|
||||
@@ -301,25 +292,19 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt
|
||||
/nixos/modules/services/misc/matrix-conduit.nix @piegamesde
|
||||
/nixos/tests/matrix-conduit.nix @piegamesde
|
||||
|
||||
# Forgejo
|
||||
nixos/modules/services/misc/forgejo.nix @bendlas @emilylange
|
||||
pkgs/applications/version-management/forgejo @bendlas @emilylange
|
||||
|
||||
# Dotnet
|
||||
/pkgs/build-support/dotnet @IvarWithoutBones
|
||||
/pkgs/development/compilers/dotnet @IvarWithoutBones
|
||||
/pkgs/test/dotnet @IvarWithoutBones
|
||||
/doc/languages-frameworks/dotnet.section.md @IvarWithoutBones
|
||||
/pkgs/build-support/dotnet @IvarWithoutBones
|
||||
/pkgs/development/compilers/dotnet @IvarWithoutBones
|
||||
|
||||
# Node.js
|
||||
/pkgs/build-support/node/build-npm-package @lilyinstarlight @winterqt
|
||||
/pkgs/build-support/node/fetch-npm-deps @lilyinstarlight @winterqt
|
||||
/doc/languages-frameworks/javascript.section.md @lilyinstarlight @winterqt
|
||||
/pkgs/build-support/node/build-npm-package @winterqt
|
||||
/pkgs/build-support/node/fetch-npm-deps @winterqt
|
||||
/doc/languages-frameworks/javascript.section.md @winterqt
|
||||
|
||||
# OCaml
|
||||
/pkgs/build-support/ocaml @ulrikstrid
|
||||
/pkgs/development/compilers/ocaml @ulrikstrid
|
||||
/pkgs/development/ocaml-modules @ulrikstrid
|
||||
/pkgs/build-support/ocaml @romildo @ulrikstrid
|
||||
/pkgs/development/compilers/ocaml @romildo @ulrikstrid
|
||||
/pkgs/development/ocaml-modules @romildo @ulrikstrid
|
||||
|
||||
# ZFS
|
||||
pkgs/os-specific/linux/zfs @raitobezarius
|
||||
@@ -327,10 +312,3 @@ nixos/lib/make-single-disk-zfs-image.nix @raitobezarius
|
||||
nixos/lib/make-multi-disk-zfs-image.nix @raitobezarius
|
||||
nixos/modules/tasks/filesystems/zfs.nix @raitobezarius
|
||||
nixos/tests/zfs.nix @raitobezarius
|
||||
|
||||
# Zig
|
||||
/pkgs/development/compilers/zig @AndersonTorres @figsoda
|
||||
/doc/hooks/zig.section.md @AndersonTorres @figsoda
|
||||
|
||||
# Linux Kernel
|
||||
pkgs/os-specific/linux/kernel/manual-config.nix @amjoseph-nixpkgs
|
||||
|
||||
7
.github/ISSUE_TEMPLATE/bug_report.md
vendored
7
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -39,10 +39,3 @@ Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.
|
||||
[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
|
||||
output here
|
||||
```
|
||||
|
||||
### Priorities
|
||||
|
||||
Add a :+1: [reaction] to [issues you find important].
|
||||
|
||||
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
|
||||
[issues you find important]: https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc
|
||||
|
||||
7
.github/ISSUE_TEMPLATE/build_failure.md
vendored
7
.github/ISSUE_TEMPLATE/build_failure.md
vendored
@@ -37,10 +37,3 @@ Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.
|
||||
[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
|
||||
output here
|
||||
```
|
||||
|
||||
### Priorities
|
||||
|
||||
Add a :+1: [reaction] to [issues you find important].
|
||||
|
||||
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
|
||||
[issues you find important]: https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc
|
||||
|
||||
@@ -30,9 +30,3 @@ assignees: ''
|
||||
[open documentation issues]: https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue+is%3Aopen+label%3A%229.needs%3A+documentation%22
|
||||
[open documentation pull requests]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+is%3Apr+label%3A%228.has%3A+documentation%22%2C%226.topic%3A+documentation%22
|
||||
|
||||
### Priorities
|
||||
|
||||
Add a :+1: [reaction] to [issues you find important].
|
||||
|
||||
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
|
||||
[issues you find important]: https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc
|
||||
|
||||
@@ -26,10 +26,3 @@ There's a high chance that you'll have the new version right away while helping
|
||||
-----
|
||||
|
||||
Note for maintainers: Please tag this issue in your PR.
|
||||
|
||||
**Priorities**
|
||||
|
||||
Add a :+1: [reaction] to [issues you find important].
|
||||
|
||||
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
|
||||
[issues you find important]: https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc
|
||||
|
||||
7
.github/ISSUE_TEMPLATE/packaging_request.md
vendored
7
.github/ISSUE_TEMPLATE/packaging_request.md
vendored
@@ -17,10 +17,3 @@ assignees: ''
|
||||
* source URL:
|
||||
* license: mit, bsd, gpl2+ , ...
|
||||
* platforms: unix, linux, darwin, ...
|
||||
|
||||
**Priorities**
|
||||
|
||||
Add a :+1: [reaction] to [issues you find important].
|
||||
|
||||
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
|
||||
[issues you find important]: https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc
|
||||
|
||||
81
.github/ISSUE_TEMPLATE/unreproducible_package.md
vendored
81
.github/ISSUE_TEMPLATE/unreproducible_package.md
vendored
@@ -7,88 +7,25 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
Hello dear reporter,
|
||||
Building this package twice does not produce the bit-by-bit identical result each time, making it harder to detect CI breaches. You can read more about this at https://reproducible-builds.org/ .
|
||||
|
||||
Thank you for bringing attention to this issue. Your insights are valuable to
|
||||
us, and we appreciate the time you took to document the problem.
|
||||
|
||||
I wanted to kindly point out that in this issue template, it would be beneficial
|
||||
to replace the placeholder `<package>` with the actual, canonical name of the
|
||||
package you're reporting the issue for. Doing so will provide better context and
|
||||
facilitate quicker troubleshooting for anyone who reads this issue in the
|
||||
future.
|
||||
|
||||
Best regards
|
||||
-->
|
||||
|
||||
Building this package multiple times does not yield bit-by-bit identical
|
||||
results, complicating the detection of Continuous Integration (CI) breaches. For
|
||||
more information on this issue, visit
|
||||
[reproducible-builds.org](https://reproducible-builds.org/).
|
||||
|
||||
Fixing bit-by-bit reproducibility also has additional advantages, such as
|
||||
avoiding hard-to-reproduce bugs, making content-addressed storage more effective
|
||||
and reducing rebuilds in such systems.
|
||||
Fixing bit-by-bit reproducibility also has additional advantages, such as avoiding hard-to-reproduce bugs, making content-addressed storage more effective and reducing rebuilds in such systems.
|
||||
|
||||
### Steps To Reproduce
|
||||
|
||||
In the following steps, replace `<package>` with the canonical name of the
|
||||
package.
|
||||
|
||||
#### 1. Build the package
|
||||
|
||||
This step will build the package. Specific arguments are passed to the command
|
||||
to keep the build artifacts so we can compare them in case of differences.
|
||||
|
||||
Execute the following command:
|
||||
|
||||
```
|
||||
nix-build '<nixpkgs>' -A <package> && nix-build '<nixpkgs>' -A <package> --check --keep-failed
|
||||
nix-build '<nixpkgs>' -A ... --check --keep-failed
|
||||
```
|
||||
|
||||
Or using the new command line style:
|
||||
You can use `diffoscope` to analyze the differences in the output of the two builds.
|
||||
|
||||
To view the build log of the build that produced the artifact in the binary cache:
|
||||
|
||||
```
|
||||
nix build nixpkgs#<package> && nix build nixpkgs#<package> --rebuild --keep-failed
|
||||
```
|
||||
|
||||
#### 2. Compare the build artifacts
|
||||
|
||||
If the previous command completes successfully, no differences were found and
|
||||
there's nothing to do, builds are reproducible.
|
||||
If it terminates with the error message `error: derivation '<X>' may not be
|
||||
deterministic: output '<Y>' differs from '<Z>'`, use `diffoscope` to investigate
|
||||
the discrepancies between the two build outputs. You may need to add the
|
||||
`--exclude-directory-metadata recursive` option to ignore files and directories
|
||||
metadata (*e.g. timestamp*) differences.
|
||||
|
||||
```
|
||||
nix run nixpkgs#diffoscopeMinimal -- --exclude-directory-metadata recursive <Y> <Z>
|
||||
```
|
||||
|
||||
#### 3. Examine the build log
|
||||
|
||||
To examine the build log, use:
|
||||
|
||||
```
|
||||
nix-store --read-log $(nix-instantiate '<nixpkgs>' -A <package>)
|
||||
```
|
||||
|
||||
Or with the new command line style:
|
||||
|
||||
```
|
||||
nix log $(nix path-info --derivation nixpkgs#<package>)
|
||||
nix-store --read-log $(nix-instantiate '<nixpkgs>' -A ...)
|
||||
```
|
||||
|
||||
### Additional context
|
||||
|
||||
(please share the relevant fragment of the diffoscope output here, and any
|
||||
additional analysis you may have done)
|
||||
|
||||
### Priorities
|
||||
|
||||
Add a :+1: [reaction] to [issues you find important].
|
||||
|
||||
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
|
||||
[issues you find important]: https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc
|
||||
(please share the relevant fragment of the diffoscope output here,
|
||||
and any additional analysis you may have done)
|
||||
|
||||
17
.github/PULL_REQUEST_TEMPLATE.md
vendored
17
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,11 +1,11 @@
|
||||
## Description of changes
|
||||
###### Description of changes
|
||||
|
||||
<!--
|
||||
For package updates please link to a changelog or describe changes, this helps your fellow maintainers discover breaking updates.
|
||||
For new packages please briefly describe the package or provide a link to its homepage.
|
||||
-->
|
||||
|
||||
## Things done
|
||||
###### Things done
|
||||
|
||||
<!-- Please check what applies. Note that these are not hard requirements but merely serve as information for reviewers. -->
|
||||
|
||||
@@ -14,9 +14,7 @@ For new packages please briefly describe the package or provide a link to its ho
|
||||
- [ ] aarch64-linux
|
||||
- [ ] x86_64-darwin
|
||||
- [ ] aarch64-darwin
|
||||
- For non-Linux: Is sandboxing enabled in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
|
||||
- [ ] `sandbox = relaxed`
|
||||
- [ ] `sandbox = true`
|
||||
- [ ] For non-Linux: Is `sandbox = true` set in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
|
||||
- [ ] 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)
|
||||
@@ -24,7 +22,7 @@ For new packages please briefly describe the package or provide a link to its ho
|
||||
- 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)
|
||||
- [ ] Tested basic functionality of all binary files (usually in `./result/bin/`)
|
||||
- [23.11 Release Notes](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2311.section.md) (or backporting [23.05 Release notes](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2305.section.md))
|
||||
- [23.11 Release Notes (or backporting 23.05 Release notes)](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#generating-2305-release-notes)
|
||||
- [ ] (Package updates) Added a release notes entry if the change is major or breaking
|
||||
- [ ] (Module updates) Added a release notes entry if the change is significant
|
||||
- [ ] (Module addition) Added a release notes entry if adding a new NixOS module
|
||||
@@ -40,10 +38,3 @@ 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
|
||||
-->
|
||||
|
||||
### Priorities
|
||||
|
||||
Add a :+1: [reaction] to [pull requests you find important].
|
||||
|
||||
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
|
||||
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
|
||||
|
||||
28
.github/labeler.yml
vendored
28
.github/labeler.yml
vendored
@@ -37,11 +37,6 @@
|
||||
"6.topic: fetch":
|
||||
- pkgs/build-support/fetch*/**/*
|
||||
|
||||
"6.topic: flakes":
|
||||
- '**/flake.nix'
|
||||
- lib/systems/flake-systems.nix
|
||||
- nixos/modules/config/nix-flakes.nix
|
||||
|
||||
"6.topic: GNOME":
|
||||
- doc/languages-frameworks/gnome.section.md
|
||||
- nixos/modules/services/desktops/gnome/**/*
|
||||
@@ -69,9 +64,6 @@
|
||||
- pkgs/build-support/kernel/**/*
|
||||
- pkgs/os-specific/linux/kernel/**/*
|
||||
|
||||
"6.topic: lib":
|
||||
- lib/**
|
||||
|
||||
"6.topic: lua":
|
||||
- pkgs/development/interpreters/lua-5/**/*
|
||||
- pkgs/development/interpreters/luajit/**/*
|
||||
@@ -91,13 +83,6 @@
|
||||
- nixos/tests/mate.nix
|
||||
- pkgs/desktops/mate/**/*
|
||||
|
||||
"6.topic: module system":
|
||||
- lib/modules.nix
|
||||
- lib/types.nix
|
||||
- lib/options.nix
|
||||
- lib/tests/modules.sh
|
||||
- lib/tests/modules/**
|
||||
|
||||
"6.topic: nixos":
|
||||
- nixos/**/*
|
||||
- pkgs/os-specific/linux/nixos-rebuild/**/*
|
||||
@@ -108,14 +93,6 @@
|
||||
- pkgs/development/nim-packages/**/*
|
||||
- pkgs/top-level/nim-packages.nix
|
||||
|
||||
"6.topic: nodejs":
|
||||
- doc/languages-frameworks/javascript.section.md
|
||||
- pkgs/build-support/node/**/*
|
||||
- pkgs/development/node-packages/**/*
|
||||
- pkgs/development/tools/yarn/*
|
||||
- pkgs/development/tools/yarn2nix-moretea/**/*
|
||||
- pkgs/development/web/nodejs/*
|
||||
|
||||
"6.topic: ocaml":
|
||||
- doc/languages-frameworks/ocaml.section.md
|
||||
- pkgs/development/compilers/ocaml/**/*
|
||||
@@ -175,7 +152,6 @@
|
||||
|
||||
"6.topic: TeX":
|
||||
- doc/languages-frameworks/texlive.section.md
|
||||
- pkgs/test/texlive/**
|
||||
- pkgs/tools/typesetting/tex/**/*
|
||||
|
||||
"6.topic: vim":
|
||||
@@ -194,10 +170,6 @@
|
||||
- nixos/tests/xfce.nix
|
||||
- pkgs/desktops/xfce/**/*
|
||||
|
||||
"6.topic: zig":
|
||||
- pkgs/development/compilers/zig/**/*
|
||||
- doc/hooks/zig.section.md
|
||||
|
||||
"8.has: changelog":
|
||||
- nixos/doc/manual/release-notes/**/*
|
||||
|
||||
|
||||
8
.github/workflows/backport.yml
vendored
8
.github/workflows/backport.yml
vendored
@@ -20,16 +20,16 @@ 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@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Create backport PRs
|
||||
uses: korthout/backport-action@v2.1.1
|
||||
uses: korthout/backport-action@v1.2.0
|
||||
with:
|
||||
# Config README: https://github.com/korthout/backport-action#backport-action
|
||||
copy_labels_pattern: 'severity:\ssecurity'
|
||||
pull_description: |-
|
||||
Bot-based backport to `${target_branch}`, triggered by a label in #${pull_number}.
|
||||
|
||||
* [ ] Before merging, ensure that this backport is [acceptable for the release](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#changes-acceptable-for-releases).
|
||||
* Even as a non-commiter, if you find that it is not acceptable, leave a comment.
|
||||
* [ ] Before merging, ensure that this backport complies with the [Criteria for Backporting](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#criteria-for-backporting-changes).
|
||||
* Even as a non-commiter, if you find that it does not comply, leave a comment.
|
||||
|
||||
4
.github/workflows/basic-eval.yml
vendored
4
.github/workflows/basic-eval.yml
vendored
@@ -18,8 +18,8 @@ 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@v4
|
||||
- uses: cachix/install-nix-action@v23
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v21
|
||||
- uses: cachix/cachix-action@v12
|
||||
with:
|
||||
# This cache is for the nixpkgs repo checks and should not be trusted or used elsewhere.
|
||||
|
||||
173
.github/workflows/check-by-name.yml
vendored
173
.github/workflows/check-by-name.yml
vendored
@@ -1,173 +0,0 @@
|
||||
# Checks pkgs/by-name (see pkgs/by-name/README.md)
|
||||
# using the nixpkgs-check-by-name tool (see pkgs/test/nixpkgs-check-by-name)
|
||||
name: Check pkgs/by-name
|
||||
|
||||
# The pre-built tool is fetched from a channel,
|
||||
# making it work predictable on all PRs.
|
||||
on:
|
||||
# Using pull_request_target instead of pull_request avoids having to approve first time contributors
|
||||
pull_request_target
|
||||
|
||||
# The tool doesn't need any permissions, it only outputs success or not based on the checkout
|
||||
permissions: {}
|
||||
|
||||
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
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Resolving the merge commit
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
# This checks for mergeability of a pull request as recommended in
|
||||
# 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
|
||||
while true; do
|
||||
echo "Checking whether the pull request can be merged"
|
||||
prInfo=$(gh api \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||
/repos/"$GITHUB_REPOSITORY"/pulls/${{ github.event.pull_request.number }})
|
||||
mergeable=$(jq -r .mergeable <<< "$prInfo")
|
||||
mergedSha=$(jq -r .merge_commit_sha <<< "$prInfo")
|
||||
|
||||
if [[ "$mergeable" == "null" ]]; then
|
||||
# null indicates that GitHub is still computing whether it's mergeable
|
||||
# Wait a couple seconds before trying again
|
||||
echo "GitHub is still computing whether this PR can be merged, waiting 5 seconds before trying again"
|
||||
sleep 5
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$mergeable" == "true" ]]; then
|
||||
echo "The PR can be merged, checking the merge commit $mergedSha"
|
||||
else
|
||||
echo "The PR cannot be merged, it has a merge conflict"
|
||||
exit 1
|
||||
fi
|
||||
echo "mergedSha=$mergedSha" >> "$GITHUB_ENV"
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
# pull_request_target checks out the base branch by default
|
||||
ref: ${{ env.mergedSha }}
|
||||
# Fetches the merge commit and its parents
|
||||
fetch-depth: 2
|
||||
- name: Determining PR git hashes
|
||||
run: |
|
||||
# For pull_request_target this is the same as $GITHUB_SHA
|
||||
echo "baseSha=$(git rev-parse HEAD^1)" >> "$GITHUB_ENV"
|
||||
|
||||
echo "headSha=$(git rev-parse HEAD^2)" >> "$GITHUB_ENV"
|
||||
- uses: cachix/install-nix-action@v23
|
||||
- name: Determining channel to use for dependencies
|
||||
run: |
|
||||
echo "Determining which channel to use for PR base branch $GITHUB_BASE_REF"
|
||||
if [[ "$GITHUB_BASE_REF" =~ ^(release|staging|staging-next)-([0-9][0-9]\.[0-9][0-9])$ ]]; then
|
||||
# Use the release channel for all PRs to release-XX.YY, staging-XX.YY and staging-next-XX.YY
|
||||
channel=nixos-${BASH_REMATCH[2]}
|
||||
echo "PR is for a release branch, using release channel $channel"
|
||||
else
|
||||
# Use the nixos-unstable channel for all other PRs
|
||||
channel=nixos-unstable
|
||||
echo "PR is for a non-release branch, using unstable channel $channel"
|
||||
fi
|
||||
echo "channel=$channel" >> "$GITHUB_ENV"
|
||||
- name: Fetching latest version of channel
|
||||
run: |
|
||||
echo "Fetching latest version of channel $channel"
|
||||
# This is probably the easiest way to get Nix to output the path to a downloaded channel!
|
||||
nixpkgs=$(nix-instantiate --find-file nixpkgs -I nixpkgs=channel:"$channel")
|
||||
# This file only exists in channels
|
||||
rev=$(<"$nixpkgs"/.git-revision)
|
||||
echo "Channel $channel is at revision $rev"
|
||||
echo "nixpkgs=$nixpkgs" >> "$GITHUB_ENV"
|
||||
echo "rev=$rev" >> "$GITHUB_ENV"
|
||||
- name: Fetching pre-built nixpkgs-check-by-name from the channel
|
||||
run: |
|
||||
echo "Fetching pre-built nixpkgs-check-by-name from channel $channel at revision $rev"
|
||||
# Passing --max-jobs 0 makes sure that we won't build anything
|
||||
nix-build "$nixpkgs" -A tests.nixpkgs-check-by-name --max-jobs 0
|
||||
- name: Running nixpkgs-check-by-name
|
||||
run: |
|
||||
echo "Checking whether the check succeeds on the base branch $GITHUB_BASE_REF"
|
||||
git checkout -q "$baseSha"
|
||||
if baseOutput=$(result/bin/nixpkgs-check-by-name . 2>&1); then
|
||||
baseSuccess=1
|
||||
else
|
||||
baseSuccess=
|
||||
fi
|
||||
printf "%s\n" "$baseOutput"
|
||||
|
||||
echo "Checking whether the check would succeed after merging this pull request"
|
||||
git checkout -q "$mergedSha"
|
||||
if mergedOutput=$(result/bin/nixpkgs-check-by-name . 2>&1); then
|
||||
mergedSuccess=1
|
||||
exitCode=0
|
||||
else
|
||||
mergedSuccess=
|
||||
exitCode=1
|
||||
fi
|
||||
printf "%s\n" "$mergedOutput"
|
||||
|
||||
resultToEmoji() {
|
||||
if [[ -n "$1" ]]; then
|
||||
echo ":heavy_check_mark:"
|
||||
else
|
||||
echo ":x:"
|
||||
fi
|
||||
}
|
||||
|
||||
# Print a markdown summary in GitHub actions
|
||||
{
|
||||
echo "| Nixpkgs version | Check result |"
|
||||
echo "| --- | --- |"
|
||||
echo "| Latest base commit | $(resultToEmoji "$baseSuccess") |"
|
||||
echo "| After merging this PR | $(resultToEmoji "$mergedSuccess") |"
|
||||
echo ""
|
||||
|
||||
if [[ -n "$baseSuccess" ]]; then
|
||||
if [[ -n "$mergedSuccess" ]]; then
|
||||
echo "The check succeeds on both the base branch and after merging this PR"
|
||||
else
|
||||
echo "The check succeeds on the base branch, but would fail after merging this PR:"
|
||||
echo "\`\`\`"
|
||||
echo "$mergedOutput"
|
||||
echo "\`\`\`"
|
||||
echo ""
|
||||
fi
|
||||
else
|
||||
if [[ -n "$mergedSuccess" ]]; then
|
||||
echo "The check fails on the base branch, but this PR fixes it, nicely done!"
|
||||
else
|
||||
echo "The check fails on both the base branch and after merging this PR, unknown if only this PRs changes would satisfy the check, the base branch needs to be fixed first."
|
||||
echo ""
|
||||
echo "Failure on the base branch:"
|
||||
echo "\`\`\`"
|
||||
echo "$baseOutput"
|
||||
echo "\`\`\`"
|
||||
echo ""
|
||||
echo "Failure after merging this PR:"
|
||||
echo "\`\`\`"
|
||||
echo "$mergedOutput"
|
||||
echo "\`\`\`"
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "### Details"
|
||||
echo "- nixpkgs-check-by-name tool:"
|
||||
echo " - Channel: $channel"
|
||||
echo " - Nixpkgs commit: [$rev](https://github.com/${GITHUB_REPOSITORY}/commit/$rev)"
|
||||
echo " - Store path: \`$(realpath result)\`"
|
||||
echo "- Tested Nixpkgs:"
|
||||
echo " - Base branch: $GITHUB_BASE_REF"
|
||||
echo " - Latest base branch commit: [$baseSha](https://github.com/${GITHUB_REPOSITORY}/commit/$baseSha)"
|
||||
echo " - Latest PR commit: [$headSha](https://github.com/${GITHUB_REPOSITORY}/commit/$headSha)"
|
||||
echo " - Merge commit: [$mergedSha](https://github.com/${GITHUB_REPOSITORY}/commit/$mergedSha)"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
exit "$exitCode"
|
||||
|
||||
@@ -12,11 +12,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'NixOS'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
# pull_request_target checks out the base branch by default
|
||||
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
- uses: cachix/install-nix-action@v23
|
||||
- uses: cachix/install-nix-action@v21
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
|
||||
21
.github/workflows/compare-manuals.sh
vendored
Executable file
21
.github/workflows/compare-manuals.sh
vendored
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash -p html-tidy
|
||||
|
||||
set -euo pipefail
|
||||
shopt -s inherit_errexit
|
||||
|
||||
normalize() {
|
||||
tidy \
|
||||
--anchor-as-name no \
|
||||
--coerce-endtags no \
|
||||
--escape-scripts no \
|
||||
--fix-backslash no \
|
||||
--fix-style-tags no \
|
||||
--fix-uri no \
|
||||
--indent yes \
|
||||
--wrap 0 \
|
||||
< "$1" \
|
||||
2> /dev/null
|
||||
}
|
||||
|
||||
diff -U3 <(normalize "$1") <(normalize "$2")
|
||||
37
.github/workflows/direct-push.yml
vendored
Normal file
37
.github/workflows/direct-push.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
name: "Direct Push Warning"
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- release-**
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
permissions:
|
||||
contents: write # for peter-evans/commit-comment to comment on commit
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'NixOS'
|
||||
env:
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
||||
steps:
|
||||
- name: Check if commit is a merge commit
|
||||
id: ismerge
|
||||
run: |
|
||||
ISMERGE=$(curl -H 'Accept: application/vnd.github.groot-preview+json' -H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ env.GITHUB_REPOSITORY }}/commits/${{ env.GITHUB_SHA }}/pulls | jq -r '.[] | select(.merge_commit_sha == "${{ env.GITHUB_SHA }}") | any')
|
||||
echo "ismerge=$ISMERGE" >> $GITHUB_OUTPUT
|
||||
# github events are eventually consistent, so wait until changes propagate to thier DB
|
||||
- run: sleep 60
|
||||
if: steps.ismerge.outputs.ismerge != 'true'
|
||||
- name: Warn if the commit was a direct push
|
||||
if: steps.ismerge.outputs.ismerge != 'true'
|
||||
uses: peter-evans/commit-comment@v2
|
||||
with:
|
||||
body: |
|
||||
@${{ github.actor }}, you pushed a commit directly to master/release branch
|
||||
instead of going through a Pull Request.
|
||||
|
||||
That's highly discouraged beyond the few exceptions listed
|
||||
on https://github.com/NixOS/nixpkgs/issues/118661
|
||||
4
.github/workflows/editorconfig.yml
vendored
4
.github/workflows/editorconfig.yml
vendored
@@ -24,11 +24,11 @@ jobs:
|
||||
- name: print list of changed files
|
||||
run: |
|
||||
cat "$HOME/changed_files"
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
# pull_request_target checks out the base branch by default
|
||||
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
- uses: cachix/install-nix-action@v23
|
||||
- uses: cachix/install-nix-action@v21
|
||||
with:
|
||||
# nixpkgs commit is pinned so that it doesn't break
|
||||
# editorconfig-checker 2.4.0
|
||||
|
||||
14
.github/workflows/manual-nixos.yml
vendored
14
.github/workflows/manual-nixos.yml
vendored
@@ -14,11 +14,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'NixOS'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
# pull_request_target checks out the base branch by default
|
||||
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
- uses: cachix/install-nix-action@v23
|
||||
- uses: cachix/install-nix-action@v21
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
@@ -27,5 +27,13 @@ jobs:
|
||||
# This cache is for the nixpkgs repo checks and should not be trusted or used elsewhere.
|
||||
name: nixpkgs-ci
|
||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||
- name: Building NixOS manual
|
||||
- name: Building NixOS manual with DocBook options
|
||||
run: NIX_PATH=nixpkgs=$(pwd) nix-build --option restrict-eval true nixos/release.nix -A manual.x86_64-linux
|
||||
- name: Building NixOS manual with Markdown options
|
||||
run: |
|
||||
export NIX_PATH=nixpkgs=$(pwd)
|
||||
nix-build \
|
||||
--option restrict-eval true \
|
||||
--arg configuration '{ documentation.nixos.options.allowDocBook = false; }' \
|
||||
nixos/release.nix \
|
||||
-A manual.x86_64-linux
|
||||
|
||||
4
.github/workflows/manual-nixpkgs.yml
vendored
4
.github/workflows/manual-nixpkgs.yml
vendored
@@ -15,11 +15,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'NixOS'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
# pull_request_target checks out the base branch by default
|
||||
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
- uses: cachix/install-nix-action@v23
|
||||
- uses: cachix/install-nix-action@v21
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
|
||||
64
.github/workflows/manual-rendering.yml
vendored
Normal file
64
.github/workflows/manual-rendering.yml
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
name: "Check NixOS Manual DocBook rendering against MD rendering"
|
||||
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# * is a special character in YAML so you have to quote this string
|
||||
# Check every 24 hours
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check-rendering-equivalence:
|
||||
permissions:
|
||||
pull-requests: write # for peter-evans/create-or-update-comment to create or update comment
|
||||
if: github.repository_owner == 'NixOS'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v21
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
- uses: cachix/cachix-action@v12
|
||||
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 }}'
|
||||
|
||||
- name: Build DocBook and MD manuals
|
||||
run: |
|
||||
export NIX_PATH=nixpkgs=$(pwd)
|
||||
nix-build \
|
||||
--option restrict-eval true \
|
||||
-o docbook nixos/release.nix \
|
||||
-A manual.x86_64-linux
|
||||
nix-build \
|
||||
--option restrict-eval true \
|
||||
--arg configuration '{ documentation.nixos.options.allowDocBook = false; }' \
|
||||
-o md nixos/release.nix \
|
||||
-A manual.x86_64-linux
|
||||
|
||||
- name: Compare DocBook and MD manuals
|
||||
id: check
|
||||
run: |
|
||||
export NIX_PATH=nixpkgs=$(pwd)
|
||||
.github/workflows/compare-manuals.sh \
|
||||
docbook/share/doc/nixos/options.html \
|
||||
md/share/doc/nixos/options.html
|
||||
|
||||
# if the manual can't be built we don't want to notify anyone.
|
||||
# while this may temporarily hide rendering failures it will be a lot
|
||||
# less noisy until all nixpkgs pull requests have stopped using
|
||||
# docbook for option docs.
|
||||
- name: Comment on failure
|
||||
uses: peter-evans/create-or-update-comment@v3
|
||||
if: ${{ failure() && steps.check.conclusion == 'failure' }}
|
||||
with:
|
||||
issue-number: 189318
|
||||
body: |
|
||||
Markdown and DocBook manuals do not agree.
|
||||
|
||||
Check https://github.com/NixOS/nixpkgs/actions/runs/${{ github.run_id }} for details.
|
||||
10
.github/workflows/periodic-merge-24h.yml
vendored
10
.github/workflows/periodic-merge-24h.yml
vendored
@@ -34,17 +34,17 @@ jobs:
|
||||
pairs:
|
||||
- from: master
|
||||
into: haskell-updates
|
||||
- from: release-22.11
|
||||
into: staging-next-22.11
|
||||
- from: staging-next-22.11
|
||||
into: staging-22.11
|
||||
- from: release-23.05
|
||||
into: staging-next-23.05
|
||||
- from: staging-next-23.05
|
||||
into: staging-23.05
|
||||
- from: release-23.11
|
||||
into: staging-next-23.11
|
||||
- from: staging-next-23.11
|
||||
into: staging-23.11
|
||||
name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
|
||||
uses: devmasx/merge-branch@1.4.0
|
||||
|
||||
2
.github/workflows/periodic-merge-6h.yml
vendored
2
.github/workflows/periodic-merge-6h.yml
vendored
@@ -38,7 +38,7 @@ jobs:
|
||||
into: staging
|
||||
name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
|
||||
uses: devmasx/merge-branch@1.4.0
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
name: "Update terraform-providers"
|
||||
|
||||
on:
|
||||
#schedule:
|
||||
# - cron: "0 3 * * *"
|
||||
schedule:
|
||||
- cron: "0 3 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
@@ -16,8 +16,8 @@ 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@v4
|
||||
- uses: cachix/install-nix-action@v23
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v21
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixpkgs-unstable
|
||||
- name: setup
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -5,12 +5,10 @@
|
||||
.\#*
|
||||
\#*\#
|
||||
.idea/
|
||||
.nixos-test-history
|
||||
.vscode/
|
||||
outputs/
|
||||
result-*
|
||||
result
|
||||
repl-result-*
|
||||
!pkgs/development/python-modules/result
|
||||
/doc/NEWS.html
|
||||
/doc/NEWS.txt
|
||||
|
||||
741
CONTRIBUTING.md
741
CONTRIBUTING.md
@@ -1,208 +1,74 @@
|
||||
# Contributing to Nixpkgs
|
||||
# How to contribute
|
||||
|
||||
This document is for people wanting to contribute to the implementation of Nixpkgs.
|
||||
This involves interacting with implementation changes that are proposed using [GitHub](https://github.com/) [pull requests](https://docs.github.com/pull-requests) to the [Nixpkgs](https://github.com/nixos/nixpkgs/) repository (which you're in right now).
|
||||
Note: contributing implies licensing those contributions
|
||||
under the terms of [COPYING](COPYING), which is an MIT-like license.
|
||||
|
||||
As such, a GitHub account is recommended, which you can sign up for [here](https://github.com/signup).
|
||||
See [here](https://discourse.nixos.org/t/about-the-patches-category/477) for how to contribute without a GitHub account.
|
||||
## Opening issues
|
||||
|
||||
Additionally this document assumes that you already know how to use GitHub and Git.
|
||||
If that's not the case, we recommend learning about it first [here](https://docs.github.com/en/get-started/quickstart/hello-world).
|
||||
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
||||
* Make sure there is no open issue on the topic
|
||||
* [Submit a new issue](https://github.com/NixOS/nixpkgs/issues/new/choose) by choosing the kind of topic and fill out the template
|
||||
|
||||
## Overview
|
||||
[overview]: #overview
|
||||
## Submitting changes
|
||||
|
||||
This file contains general contributing information, but individual parts also have more specific information to them in their respective `README.md` files, linked here:
|
||||
- [`lib`](./lib/README.md): Sources and documentation of the [library functions](https://nixos.org/manual/nixpkgs/stable/#chap-functions)
|
||||
- [`maintainers`](./maintainers/README.md): Nixpkgs maintainer and team listings, maintainer scripts
|
||||
- [`pkgs`](./pkgs/README.md): Package and [builder](https://nixos.org/manual/nixpkgs/stable/#part-builders) definitions
|
||||
- [`doc`](./doc/README.md): Sources and infrastructure for the [Nixpkgs manual](https://nixos.org/manual/nixpkgs/stable/)
|
||||
- [`nixos`](./nixos/README.md): Implementation of [NixOS](https://nixos.org/manual/nixos/stable/)
|
||||
Read the ["Submitting changes"](https://nixos.org/nixpkgs/manual/#chap-submitting-changes) section of the nixpkgs manual. It explains how to write, test, and iterate on your change, and which branch to base your pull request against.
|
||||
|
||||
# How to's
|
||||
Below is a short excerpt of some points in there:
|
||||
|
||||
## How to create pull requests
|
||||
[pr-create]: #how-to-create-pull-requests
|
||||
* Format the commit messages in the following way:
|
||||
|
||||
This section describes in some detail how changes can be made and proposed with pull requests.
|
||||
```
|
||||
(pkg-name | nixos/<module>): (from -> to | init at version | refactor | etc)
|
||||
|
||||
> **Note**
|
||||
> Be aware that contributing implies licensing those contributions under the terms of [COPYING](./COPYING), an MIT-like license.
|
||||
|
||||
0. Set up a local version of Nixpkgs to work with using GitHub and Git
|
||||
1. [Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository) the [Nixpkgs repository](https://github.com/nixos/nixpkgs/).
|
||||
1. [Clone the forked repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#cloning-your-forked-repository) into a local `nixpkgs` directory.
|
||||
1. [Configure the upstream Nixpkgs repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#configuring-git-to-sync-your-fork-with-the-upstream-repository).
|
||||
|
||||
1. Figure out the branch that should be used for this change by going through [this section][branch].
|
||||
If in doubt use `master`, that's where most changes should go.
|
||||
This can be changed later by [rebasing][rebase].
|
||||
|
||||
2. Create and switch to a new Git branch, ideally such that:
|
||||
- The name of the branch hints at the change you'd like to implement, e.g. `update-hello`.
|
||||
- The base of the branch includes the most recent changes on the base branch from step 1, we'll assume `master` here.
|
||||
|
||||
```bash
|
||||
# Make sure you have the latest changes from upstream Nixpkgs
|
||||
git fetch upstream
|
||||
|
||||
# Create and switch to a new branch based off the master branch in Nixpkgs
|
||||
git switch --create update-hello upstream/master
|
||||
```
|
||||
|
||||
To avoid having to download and build potentially many derivations, at the expense of using a potentially outdated version, you can base the branch off a specific [Git commit](https://www.git-scm.com/docs/gitglossary#def_commit) instead:
|
||||
- The commit of the latest `nixpkgs-unstable` channel, available [here](https://channels.nixos.org/nixpkgs-unstable/git-revision).
|
||||
- The commit of a local Nixpkgs downloaded using [nix-channel](https://nixos.org/manual/nix/stable/command-ref/nix-channel), available using `nix-instantiate --eval --expr '(import <nixpkgs/lib>).trivial.revisionWithDefault null'`
|
||||
- If you're using NixOS, the commit of your NixOS installation, available with `nixos-version --revision`.
|
||||
|
||||
Once you have an appropriate commit you can use it instead of `upstream/master` in the above command:
|
||||
```bash
|
||||
git switch --create update-hello <the desired base commit>
|
||||
```
|
||||
|
||||
3. Make the desired changes in the local Nixpkgs repository using an editor of your choice.
|
||||
Make sure to:
|
||||
- Adhere to both the [general code conventions][code-conventions], and the code conventions specific to the part you're making changes to.
|
||||
See the [overview section][overview] for more specific information.
|
||||
- Test the changes.
|
||||
See the [overview section][overview] for more specific information.
|
||||
- If necessary, document the change.
|
||||
See the [overview section][overview] for more specific information.
|
||||
|
||||
4. Commit your changes using `git commit`.
|
||||
Make sure to adhere to the [commit conventions](#commit-conventions).
|
||||
|
||||
Repeat the steps 3-4 as many times as necessary.
|
||||
Advance to the next step if all the commits (viewable with `git log`) make sense together.
|
||||
|
||||
5. Push your commits to your fork of Nixpkgs.
|
||||
```
|
||||
git push --set-upstream origin HEAD
|
||||
```
|
||||
|
||||
The above command will output a link that allows you to directly quickly do the next step:
|
||||
```
|
||||
remote: Create a pull request for 'update-hello' on GitHub by visiting:
|
||||
remote: https://github.com/myUser/nixpkgs/pull/new/update-hello
|
||||
```
|
||||
|
||||
6. [Create a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request#creating-the-pull-request) from the new branch in your Nixpkgs fork to the upstream Nixpkgs repository.
|
||||
Use the branch from step 2 as the pull requests base branch.
|
||||
Go through the [pull request template](#pull-request-template) in the pre-filled default description.
|
||||
|
||||
7. Respond to review comments, potential CI failures and potential merge conflicts by updating the pull request.
|
||||
Always keep the pull request in a mergeable state.
|
||||
|
||||
The custom [OfBorg](https://github.com/NixOS/ofborg) CI system will perform various checks to help ensure code quality, whose results you can see at the bottom of the pull request.
|
||||
See [the OfBorg Readme](https://github.com/NixOS/ofborg#readme) for more details.
|
||||
|
||||
- To add new commits, repeat steps 3-4 and push the result using
|
||||
```
|
||||
git push
|
||||
```
|
||||
|
||||
- To change existing commits you will have to [rewrite Git history](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History).
|
||||
Useful Git commands that can help a lot with this are `git commit --patch --amend` and `git rebase --interactive`.
|
||||
With a rewritten history you need to force-push the commits using
|
||||
```
|
||||
git push --force-with-lease
|
||||
```
|
||||
|
||||
- In case of merge conflicts you will also have to [rebase the branch](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) on top of current `master`.
|
||||
Sometimes this can be done [on GitHub directly](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/keeping-your-pull-request-in-sync-with-the-base-branch#updating-your-pull-request-branch), but if not you will have to rebase locally using
|
||||
```
|
||||
git fetch upstream
|
||||
git rebase upstream/master
|
||||
git push --force-with-lease
|
||||
```
|
||||
|
||||
- If you need to change the base branch of the pull request, you can do so by [rebasing][rebase].
|
||||
|
||||
8. If your pull request is merged and [acceptable for releases][release-acceptable] you may [backport][pr-backport] the pull request.
|
||||
|
||||
### Pull request template
|
||||
[pr-template]: #pull-request-template
|
||||
|
||||
The pull request template helps determine what steps have been made for a contribution so far, and will help guide maintainers on the status of a change. The motivation section of the PR should include any extra details the title does not address and link any existing issues related to the pull request.
|
||||
|
||||
When a PR is created, it will be pre-populated with some checkboxes detailed below:
|
||||
|
||||
#### Tested using sandboxing
|
||||
|
||||
When sandbox builds are enabled, Nix will setup an isolated environment for each build process. It is used to remove further hidden dependencies set by the build environment to improve reproducibility. This includes access to the network during the build outside of `fetch*` functions and files outside the Nix store. Depending on the operating system access to other resources are blocked as well (ex. inter process communication is isolated on Linux); see [sandbox](https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-sandbox) in the Nix manual for details.
|
||||
|
||||
Sandboxing is not enabled by default in Nix due to a small performance hit on each build. In pull requests for [nixpkgs](https://github.com/NixOS/nixpkgs/) people are asked to test builds with sandboxing enabled (see `Tested using sandboxing` in the pull request template) because in [Hydra](https://nixos.org/hydra/) sandboxing is also used.
|
||||
|
||||
Depending if you use NixOS or other platforms you can use one of the following methods to enable sandboxing **before** building the package:
|
||||
|
||||
- **Globally enable sandboxing on NixOS**: add the following to `configuration.nix`
|
||||
|
||||
```nix
|
||||
nix.settings.sandbox = true;
|
||||
(Motivation for change. Link to release notes. Additional information.)
|
||||
```
|
||||
|
||||
- **Globally enable sandboxing on non-NixOS platforms**: add the following to: `/etc/nix/nix.conf`
|
||||
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).
|
||||
|
||||
```ini
|
||||
sandbox = true
|
||||
```
|
||||
Examples:
|
||||
|
||||
#### Built on platform(s)
|
||||
* nginx: init at 2.0.1
|
||||
* firefox: 54.0.1 -> 55.0
|
||||
https://www.mozilla.org/en-US/firefox/55.0/releasenotes/
|
||||
* nixos/hydra: add bazBaz option
|
||||
|
||||
Many Nix packages are designed to run on multiple platforms. As such, it’s important to let the maintainer know which platforms your changes have been tested on. It’s not always practical to test a change on all platforms, and is not required for a pull request to be merged. Only check the systems you tested the build on in this section.
|
||||
Dual baz behavior is needed to do foo.
|
||||
* nixos/nginx: refactor config generation
|
||||
|
||||
#### Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
|
||||
The old config generation system used impure shell scripts and could break in specific circumstances (see #1234).
|
||||
|
||||
Packages with automated tests are much more likely to be merged in a timely fashion because it doesn’t require as much manual testing by the maintainer to verify the functionality of the package. If there are existing tests for the package, they should be run to verify your changes do not break the tests. Tests can only be run on Linux. For more details on writing and running tests, see the [section in the NixOS manual](https://nixos.org/nixos/manual/index.html#sec-nixos-tests).
|
||||
* `meta.description` should:
|
||||
* Be short, just one sentence.
|
||||
* Be capitalized.
|
||||
* Not start with the package name.
|
||||
* More generally, it should not refer to the package name.
|
||||
* Not end with a period (or any punctuation for that matter).
|
||||
* Aim to inform while avoiding subjective language.
|
||||
* `meta.license` must be set and fit the upstream license.
|
||||
* If there is no upstream license, `meta.license` should default to `lib.licenses.unfree`.
|
||||
* If in doubt, try to contact the upstream developers for clarification.
|
||||
* `meta.maintainers` must be set.
|
||||
|
||||
#### Tested compilation of all pkgs that depend on this change using `nixpkgs-review`
|
||||
See the nixpkgs manual for more details on [standard meta-attributes](https://nixos.org/nixpkgs/manual/#sec-standard-meta-attributes).
|
||||
|
||||
If you are modifying a package, you can use `nixpkgs-review` to make sure all packages that depend on the updated package still compile correctly. The `nixpkgs-review` utility can look for and build all dependencies either based on uncommitted changes with the `wip` option or specifying a GitHub pull request number.
|
||||
## Writing good commit messages
|
||||
|
||||
Review changes from pull request number 12345:
|
||||
In addition to writing properly formatted commit messages, it's important to include relevant information so other developers can later understand *why* a change was made. While this information usually can be found by digging code, mailing list/Discourse archives, pull request discussions or upstream changes, it may require a lot of work.
|
||||
|
||||
```ShellSession
|
||||
nix-shell -p nixpkgs-review --run "nixpkgs-review pr 12345"
|
||||
```
|
||||
Package version upgrades usually allow for simpler commit messages, including attribute name, old and new version, as well as a reference to the relevant release notes/changelog. Every once in a while a package upgrade requires more extensive changes, and that subsequently warrants a more verbose message.
|
||||
|
||||
Alternatively, with flakes (and analogously for the other commands below):
|
||||
Pull requests should not be squash merged in order to keep complete commit messages and GPG signatures intact and must not be when the change doesn't make sense as a single commit.
|
||||
This means that, when addressing review comments in order to keep the pull request in an always mergeable status, you will sometimes need to rewrite your branch's history and then force-push it with `git push --force-with-lease`.
|
||||
Useful git commands that can help a lot with this are `git commit --patch --amend` and `git rebase --interactive`. For more details consult the git man pages or online resources like [git-rebase.io](https://git-rebase.io/) or [The Pro Git Book](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History).
|
||||
|
||||
```ShellSession
|
||||
nix run nixpkgs#nixpkgs-review -- pr 12345
|
||||
```
|
||||
|
||||
Review uncommitted changes:
|
||||
|
||||
```ShellSession
|
||||
nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
|
||||
```
|
||||
|
||||
Review changes from last commit:
|
||||
|
||||
```ShellSession
|
||||
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
|
||||
```
|
||||
|
||||
#### Tested execution of all binary files (usually in `./result/bin/`)
|
||||
|
||||
It’s important to test any executables generated by a build when you change or create a package in nixpkgs. This can be done by looking in `./result/bin` and running any files in there, or at a minimum, the main executable for the package. For example, if you make a change to texlive, you probably would only check the binaries associated with the change you made rather than testing all of them.
|
||||
|
||||
#### Meets Nixpkgs contribution standards
|
||||
|
||||
The last checkbox is about whether it fits the guidelines in this `CONTRIBUTING.md` file. This document has detailed information on standards the Nix community has for commit messages, reviews, licensing of contributions you make to the project, etc... Everyone should read and understand the standards the community has for contributing before submitting a pull request.
|
||||
|
||||
### Rebasing between branches (i.e. from master to staging)
|
||||
[rebase]: #rebasing-between-branches-ie-from-master-to-staging
|
||||
## Rebasing between branches (i.e. from master to staging)
|
||||
|
||||
From time to time, changes between branches must be rebased, for example, if the
|
||||
number of new rebuilds they would cause is too large for the target branch. When
|
||||
rebasing, care must be taken to include only the intended changes, otherwise
|
||||
many CODEOWNERS will be inadvertently requested for review. To achieve this,
|
||||
many CODEOWNERS will be inadvertently requested for review. To achieve this,
|
||||
rebasing should not be performed directly on the target branch, but on the merge
|
||||
base between the current and target branch. As an additional precautionary measure,
|
||||
you should temporarily mark the PR as draft for the duration of the operation.
|
||||
This reduces the probability of mass-pinging people. (OfBorg might still
|
||||
request a couple of persons for reviews though.)
|
||||
base between the current and target branch.
|
||||
|
||||
In the following example, we assume that the current branch, called `feature`,
|
||||
is based on `master`, and we rebase it onto the merge base between
|
||||
@@ -236,508 +102,45 @@ git status
|
||||
git push origin feature --force-with-lease
|
||||
```
|
||||
|
||||
#### Something went wrong and a lot of people were pinged
|
||||
## Backporting changes
|
||||
|
||||
It happens. Remember to be kind, especially to new contributors.
|
||||
There is no way back, so the pull request should be closed and locked
|
||||
(if possible). The changes should be re-submitted in a new PR, in which the people
|
||||
originally involved in the conversation need to manually be pinged again.
|
||||
No further discussion should happen on the original PR, as a lot of people
|
||||
are now subscribed to it.
|
||||
Follow these steps to backport a change into a release branch in compliance with the [commit policy](https://nixos.org/nixpkgs/manual/#submitting-changes-stable-release-branches).
|
||||
|
||||
The following message (or a version thereof) might be left when closing to
|
||||
describe the situation, since closing and locking without any explanation
|
||||
is kind of rude:
|
||||
You can add a label such as `backport release-23.05` to a PR, so that merging it will
|
||||
automatically create a backport (via [a GitHub Action](.github/workflows/backport.yml)).
|
||||
This also works for pull requests that have already been merged, and might take a couple of minutes to trigger.
|
||||
|
||||
```markdown
|
||||
It looks like you accidentally mass-pinged a bunch of people, which are now subscribed
|
||||
and getting notifications for everything in this pull request. Unfortunately, they
|
||||
cannot be automatically unsubscribed from the issue (removing review request does not
|
||||
unsubscribe), therefore development cannot continue in this pull request anymore.
|
||||
You can also create the backport manually:
|
||||
|
||||
Please open a new pull request with your changes, link back to this one and ping the
|
||||
people actually involved in here over there.
|
||||
1. Take note of the commits in which the change was introduced into `master` branch.
|
||||
2. Check out the target _release branch_, e.g. `release-23.05`. Do not use a _channel branch_ like `nixos-23.05` or `nixpkgs-23.05-darwin`.
|
||||
3. Create a branch for your change, e.g. `git checkout -b backport`.
|
||||
4. When the reason to backport is not obvious from the original commit message, use `git cherry-pick -xe <original commit>` and add a reason. Otherwise use `git cherry-pick -x <original commit>`. That's fine for minor version updates that only include security and bug fixes, commits that fixes an otherwise broken package or similar. Please also ensure the commits exists on the master branch; in the case of squashed or rebased merges, the commit hash will change and the new commits can be found in the merge message at the bottom of the master pull request.
|
||||
5. Push to GitHub and open a backport pull request. Make sure to select the release branch (e.g. `release-23.05`) as the target branch of the pull request, and link to the pull request in which the original change was committed to `master`. The pull request title should be the commit title with the release version as prefix, e.g. `[23.05]`.
|
||||
6. When the backport pull request is merged and you have the necessary privileges you can also replace the label `9.needs: port to stable` with `8.has: port to stable` on the original pull request. This way maintainers can keep track of missing backports easier.
|
||||
|
||||
In order to avoid this in the future, there are instructions for how to properly
|
||||
rebase between branches in our [contribution guidelines](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#rebasing-between-branches-ie-from-master-to-staging).
|
||||
Setting your pull request to draft prior to rebasing is strongly recommended.
|
||||
In draft status, you can preview the list of people that are about to be requested
|
||||
for review, which allows you to sidestep this issue.
|
||||
This is not a bulletproof method though, as OfBorg still does review requests even on draft PRs.
|
||||
```
|
||||
## Criteria for Backporting changes
|
||||
|
||||
## How to backport pull requests
|
||||
[pr-backport]: #how-to-backport-pull-requests
|
||||
|
||||
Once a pull request has been merged into `master`, a backport pull request to the corresponding `release-YY.MM` branch can be created either automatically or manually.
|
||||
|
||||
### Automatically backporting changes
|
||||
|
||||
> **Note**
|
||||
> You have to be a [Nixpkgs maintainer](./maintainers) to automatically create a backport pull request.
|
||||
|
||||
Add the [`backport release-YY.MM` label](https://github.com/NixOS/nixpkgs/labels?q=backport) to the pull request on the `master` branch.
|
||||
This will cause [a GitHub Action](.github/workflows/backport.yml) to open a pull request to the `release-YY.MM` branch a few minutes later.
|
||||
This can be done on both open or already merged pull requests.
|
||||
|
||||
### Manually backporting changes
|
||||
|
||||
To manually create a backport pull request, follow [the standard pull request process][pr-create], with these notable differences:
|
||||
|
||||
- Use `release-YY.MM` for the base branch, both for the local branch and the pull request.
|
||||
> **Warning**
|
||||
> Do not use the `nixos-YY.MM` branch, that is a branch pointing to the tested release channel commit
|
||||
|
||||
- Instead of manually making and committing the changes, use [`git cherry-pick -x`](https://git-scm.com/docs/git-cherry-pick) for each commit from the pull request you'd like to backport.
|
||||
Either `git cherry-pick -x <commit>` when the reason for the backport is obvious (such as minor versions, fixes, etc.), otherwise use `git cherry-pick -xe <commit>` to add a reason for the backport to the commit message.
|
||||
Here is [an example](https://github.com/nixos/nixpkgs/commit/5688c39af5a6c5f3d646343443683da880eaefb8) of this.
|
||||
|
||||
> **Warning**
|
||||
> Ensure the commits exists on the master branch.
|
||||
> In the case of squashed or rebased merges, the commit hash will change and the new commits can be found in the merge message at the bottom of the master pull request.
|
||||
|
||||
- In the pull request description, link to the original pull request to `master`.
|
||||
The pull request title should include `[YY.MM]` matching the release you're backporting to.
|
||||
|
||||
- When the backport pull request is merged and you have the necessary privileges you can also replace the label `9.needs: port to stable` with `8.has: port to stable` on the original pull request.
|
||||
This way maintainers can keep track of missing backports easier.
|
||||
|
||||
## How to review pull requests
|
||||
[pr-review]: #how-to-review-pull-requests
|
||||
|
||||
> **Warning**
|
||||
> The following section is a draft, and the policy for reviewing is still being discussed in issues such as [#11166](https://github.com/NixOS/nixpkgs/issues/11166) and [#20836](https://github.com/NixOS/nixpkgs/issues/20836).
|
||||
|
||||
The Nixpkgs project receives a fairly high number of contributions via GitHub pull requests. Reviewing and approving these is an important task and a way to contribute to the project.
|
||||
|
||||
The high change rate of Nixpkgs makes any pull request that remains open for too long subject to conflicts that will require extra work from the submitter or the merger. Reviewing pull requests in a timely manner and being responsive to the comments is the key to avoid this issue. GitHub provides sort filters that can be used to see the [most recently](https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc) and the [least recently](https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-asc) updated pull requests. We highly encourage looking at [this list of ready to merge, unreviewed pull requests](https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+review%3Anone+status%3Asuccess+-label%3A%222.status%3A+work-in-progress%22+no%3Aproject+no%3Aassignee+no%3Amilestone).
|
||||
|
||||
When reviewing a pull request, please always be nice and polite. Controversial changes can lead to controversial opinions, but it is important to respect every community member and their work.
|
||||
|
||||
GitHub provides reactions as a simple and quick way to provide feedback to pull requests or any comments. The thumb-down reaction should be used with care and if possible accompanied with some explanation so the submitter has directions to improve their contribution.
|
||||
|
||||
Pull request reviews should include a list of what has been reviewed in a comment, so other reviewers and mergers can know the state of the review.
|
||||
|
||||
All the review template samples provided in this section are generic and meant as examples. Their usage is optional and the reviewer is free to adapt them to their liking.
|
||||
|
||||
To get more information about how to review specific parts of Nixpkgs, refer to the documents linked to in the [overview section][overview].
|
||||
|
||||
If a pull request contains documentation changes that might require feedback from the documentation team, ping @NixOS/documentation-team on the pull request.
|
||||
|
||||
If you consider having enough knowledge and experience in a topic and would like to be a long-term reviewer for related submissions, please contact the current reviewers for that topic. They will give you information about the reviewing process. The main reviewers for a topic can be hard to find as there is no list, but checking past pull requests to see who reviewed or git-blaming the code to see who committed to that topic can give some hints.
|
||||
|
||||
Container system, boot system and library changes are some examples of the pull requests fitting this category.
|
||||
|
||||
## How to merge pull requests
|
||||
[pr-merge]: #how-to-merge-pull-requests
|
||||
|
||||
The *Nixpkgs committers* are people who have been given
|
||||
permission to merge.
|
||||
|
||||
It is possible for community members that have enough knowledge and experience on a special topic to contribute by merging pull requests.
|
||||
|
||||
In case the PR is stuck waiting for the original author to apply a trivial
|
||||
change (a typo, capitalisation change, etc.) and the author allowed the members
|
||||
to modify the PR, consider applying it yourself (or commit the existing review
|
||||
suggestion). You should pay extra attention to make sure the addition doesn't go
|
||||
against the idea of the original PR and would not be opposed by the author.
|
||||
Anything that does not cause user or downstream dependency regressions can be backported. This includes:
|
||||
- New Packages / Modules
|
||||
- Security / Patch updates
|
||||
- Version updates which include new functionality (but no breaking changes)
|
||||
- Services which require a client to be up-to-date regardless. (E.g. `spotify`, `steam`, or `discord`)
|
||||
- Security critical applications (E.g. `firefox`)
|
||||
|
||||
## Generating 23.11 Release Notes
|
||||
<!--
|
||||
The following paragraphs about how to deal with unactive contributors is just a proposition and should be modified to what the community agrees to be the right policy.
|
||||
|
||||
Please note that contributors with commit rights unactive for more than three months will have their commit rights revoked.
|
||||
note: title unchanged even though we don't need regeneration because extant
|
||||
PRs will link here. definitely change the title for 23.11 though.
|
||||
-->
|
||||
|
||||
Please see the discussion in [GitHub nixpkgs issue #50105](https://github.com/NixOS/nixpkgs/issues/50105) for information on how to proceed to be granted this level of access.
|
||||
Documentation in nixpkgs is transitioning to a markdown-centric workflow. In the past release notes required a translation step to convert from markdown to a compatible docbook document, but this is no longer necessary.
|
||||
|
||||
In a case a contributor definitively leaves the Nix community, they should create an issue or post on [Discourse](https://discourse.nixos.org) with references of packages and modules they maintain so the maintainership can be taken over by other contributors.
|
||||
Steps for updating 23.11 Release notes:
|
||||
|
||||
# Flow of merged pull requests
|
||||
1. Edit `nixos/doc/manual/release-notes/rl-2311.section.md` with the desired changes
|
||||
2. Commit changes to `rl-2311.section.md`.
|
||||
|
||||
After a pull request is merged, it eventually makes it to the [official Hydra CI](https://hydra.nixos.org/).
|
||||
Hydra regularly evaluates and builds Nixpkgs, updating [the official channels](https://channels.nixos.org/) when specific Hydra jobs succeeded.
|
||||
See [Nix Channel Status](https://status.nixos.org/) for the current channels and their state.
|
||||
Here's a brief overview of the main Git branches and what channels they're used for:
|
||||
## Reviewing contributions
|
||||
|
||||
- `master`: The main branch, used for the unstable channels such as `nixpkgs-unstable`, `nixos-unstable` and `nixos-unstable-small`.
|
||||
- `release-YY.MM` (e.g. `release-23.05`): The NixOS release branches, used for the stable channels such as `nixos-23.05`, `nixos-23.05-small` and `nixpkgs-23.05-darwin`.
|
||||
|
||||
When a channel is updated, a corresponding Git branch is also updated to point to the corresponding commit.
|
||||
So e.g. the [`nixpkgs-unstable` branch](https://github.com/nixos/nixpkgs/tree/nixpkgs-unstable) corresponds to the Git commit from the [`nixpkgs-unstable` channel](https://channels.nixos.org/nixpkgs-unstable).
|
||||
|
||||
Nixpkgs in its entirety is tied to the NixOS release process, which is documented in the [NixOS Release Wiki](https://nixos.github.io/release-wiki/).
|
||||
|
||||
See [this section][branch] to know when to use the release branches.
|
||||
|
||||
## Staging
|
||||
[staging]: #staging
|
||||
|
||||
The staging workflow exists to batch Hydra builds of many packages together.
|
||||
|
||||
It works by directing commits that cause [mass rebuilds][mass-rebuild] to a separate `staging` branch that isn't directly built by Hydra.
|
||||
Regularly, the `staging` branch is _manually_ merged into a `staging-next` branch to be built by Hydra using the [`nixpkgs:staging-next` jobset](https://hydra.nixos.org/jobset/nixpkgs/staging-next).
|
||||
The `staging-next` branch should then only receive direct commits in order to fix Hydra builds.
|
||||
Once it is verified that there are no major regressions, it is merged into `master` using [a pull requests](https://github.com/NixOS/nixpkgs/pulls?q=head%3Astaging-next).
|
||||
This is done manually in order to ensure it's a good use of Hydra's computing resources.
|
||||
By keeping the `staging-next` branch separate from `staging`, this batching does not block developers from merging changes into `staging`.
|
||||
|
||||
In order for the `staging` and `staging-next` branches to be up-to-date with the latest commits on `master`, there are regular _automated_ merges from `master` into `staging-next` and `staging`.
|
||||
This is implemented using GitHub workflows [here](.github/workflows/periodic-merge-6h.yml) and [here](.github/workflows/periodic-merge-24h.yml).
|
||||
|
||||
> **Note**
|
||||
> Changes must be sufficiently tested before being merged into any branch.
|
||||
> Hydra builds should not be used as testing platform.
|
||||
|
||||
Here is a Git history diagram showing the flow of commits between the three branches:
|
||||
```mermaid
|
||||
%%{init: {
|
||||
'theme': 'base',
|
||||
'themeVariables': {
|
||||
'gitInv0': '#ff0000',
|
||||
'gitInv1': '#ff0000',
|
||||
'git2': '#ff4444',
|
||||
'commitLabelFontSize': '15px'
|
||||
},
|
||||
'gitGraph': {
|
||||
'showCommitLabel':true,
|
||||
'mainBranchName': 'master',
|
||||
'rotateCommitLabel': true
|
||||
}
|
||||
} }%%
|
||||
gitGraph
|
||||
commit id:" "
|
||||
branch staging-next
|
||||
branch staging
|
||||
|
||||
checkout master
|
||||
checkout staging
|
||||
checkout master
|
||||
commit id:" "
|
||||
checkout staging-next
|
||||
merge master id:"automatic"
|
||||
checkout staging
|
||||
merge staging-next id:"automatic "
|
||||
|
||||
checkout staging-next
|
||||
merge staging type:HIGHLIGHT id:"manual"
|
||||
commit id:"fixup"
|
||||
|
||||
checkout master
|
||||
checkout staging
|
||||
checkout master
|
||||
commit id:" "
|
||||
checkout staging-next
|
||||
merge master id:"automatic "
|
||||
checkout staging
|
||||
merge staging-next id:"automatic "
|
||||
|
||||
checkout staging-next
|
||||
commit id:"fixup "
|
||||
checkout master
|
||||
merge staging-next type:HIGHLIGHT id:"manual (PR)"
|
||||
```
|
||||
|
||||
|
||||
Here's an overview of the different branches:
|
||||
|
||||
| branch | `master` | `staging` | `staging-next` |
|
||||
| --- | --- | --- | --- |
|
||||
| Used for development | ✔️ | ✔️ | ❌ |
|
||||
| Built by Hydra | ✔️ | ❌ | ✔️ |
|
||||
| [Mass rebuilds][mass-rebuild] | ❌ | ✔️ | ⚠️ Only to fix Hydra builds |
|
||||
| Critical security fixes | ✔️ for non-mass-rebuilds | ❌ | ✔️ for mass-rebuilds |
|
||||
| Automatically merged into | `staging-next` | - | `staging` |
|
||||
| Manually merged into | - | `staging-next` | `master` |
|
||||
|
||||
The staging workflow is used for all main branches, `master` and `release-YY.MM`, with corresponding names:
|
||||
- `master`/`release-YY.MM`
|
||||
- `staging`/`staging-YY.MM`
|
||||
- `staging-next`/`staging-next-YY.MM`
|
||||
|
||||
# Conventions
|
||||
|
||||
## Branch conventions
|
||||
<!-- This section is relevant to both contributors and reviewers -->
|
||||
[branch]: #branch-conventions
|
||||
|
||||
Most changes should go to the `master` branch, but sometimes other branches should be used instead.
|
||||
Use the following decision process to figure out which one it should be:
|
||||
|
||||
Is the change [acceptable for releases][release-acceptable] and do you wish to have the change in the release?
|
||||
- No: Use the `master` branch, do not backport the pull request.
|
||||
- Yes: Can the change be implemented the same way on the `master` and release branches?
|
||||
For example, a packages major version might differ between the `master` and release branches, such that separate security patches are required.
|
||||
- Yes: Use the `master` branch and [backport the pull request](#how-to-backport-pull-requests).
|
||||
- No: Create separate pull requests to the `master` and `release-XX.YY` branches.
|
||||
|
||||
Furthermore, if the change causes a [mass rebuild][mass-rebuild], use the appropriate staging branch instead:
|
||||
- Mass rebuilds to `master` should go to `staging` instead.
|
||||
- Mass rebuilds to `release-XX.YY` should go to `staging-XX.YY` instead.
|
||||
|
||||
See [this section][staging] for more details about such changes propagate between the branches.
|
||||
|
||||
### Changes acceptable for releases
|
||||
[release-acceptable]: #changes-acceptable-for-releases
|
||||
|
||||
Only changes to supported releases may be accepted.
|
||||
The oldest supported release (`YYMM`) can be found using
|
||||
```
|
||||
nix-instantiate --eval -A lib.trivial.oldestSupportedRelease
|
||||
```
|
||||
|
||||
The release branches should generally only receive backwards-compatible changes, both for the Nix expressions and derivations.
|
||||
Here are some examples of backwards-compatible changes that are okay to backport:
|
||||
- ✔️ New packages, modules and functions
|
||||
- ✔️ Security fixes
|
||||
- ✔️ Package version updates
|
||||
- ✔️ Patch versions with fixes
|
||||
- ✔️ Minor versions with new functionality, but no breaking changes
|
||||
|
||||
In addition, major package version updates with breaking changes are also acceptable for:
|
||||
- ✔️ Services that would fail without up-to-date client software, such as `spotify`, `steam`, and `discord`
|
||||
- ✔️ Security critical applications, such as `firefox` and `chromium`
|
||||
|
||||
### Changes causing mass rebuilds
|
||||
[mass-rebuild]: #changes-causing-mass-rebuilds
|
||||
|
||||
Which changes cause mass rebuilds is not formally defined.
|
||||
In order to help the decision, CI automatically assigns [`rebuild` labels](https://github.com/NixOS/nixpkgs/labels?q=rebuild) to pull requests based on the number of packages they cause rebuilds for.
|
||||
As a rule of thumb, if the number of rebuilds is **over 500**, it can be considered a mass rebuild.
|
||||
To get a sense for what changes are considered mass rebuilds, see [previously merged pull requests to the staging branches](https://github.com/NixOS/nixpkgs/issues?q=base%3Astaging+-base%3Astaging-next+is%3Amerged).
|
||||
|
||||
## Commit conventions
|
||||
[commit-conventions]: #commit-conventions
|
||||
|
||||
- Create a commit for each logical unit.
|
||||
|
||||
- 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`.
|
||||
|
||||
- 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).
|
||||
|
||||
- When adding yourself as maintainer in the same pull request, make a separate
|
||||
commit with the message `maintainers: add <handle>`.
|
||||
Add the commit before those making changes to the package or module.
|
||||
See [Nixpkgs Maintainers](./maintainers/README.md) for details.
|
||||
|
||||
- Make sure you read about any commit conventions specific to the area you're touching. See:
|
||||
- [Commit conventions](./pkgs/README.md#commit-conventions) for changes to `pkgs`.
|
||||
- [Commit conventions](./lib/README.md#commit-conventions) for changes to `lib`.
|
||||
- [Commit conventions](./nixos/README.md#commit-conventions) for changes to `nixos`.
|
||||
- [Commit conventions](./doc/README.md#commit-conventions) for changes to `doc`, the Nixpkgs manual.
|
||||
|
||||
### Writing good commit messages
|
||||
|
||||
In addition to writing properly formatted commit messages, it's important to include relevant information so other developers can later understand *why* a change was made. While this information usually can be found by digging code, mailing list/Discourse archives, pull request discussions or upstream changes, it may require a lot of work.
|
||||
|
||||
Package version upgrades usually allow for simpler commit messages, including attribute name, old and new version, as well as a reference to the relevant release notes/changelog. Every once in a while a package upgrade requires more extensive changes, and that subsequently warrants a more verbose message.
|
||||
|
||||
Pull requests should not be squash merged in order to keep complete commit messages and GPG signatures intact and must not be when the change doesn't make sense as a single commit.
|
||||
|
||||
## Code conventions
|
||||
[code-conventions]: #code-conventions
|
||||
|
||||
### Release notes
|
||||
|
||||
If you removed packages or made some major NixOS changes, write about it in the release notes for the next stable release in [`nixos/doc/manual/release-notes`](./nixos/doc/manual/release-notes).
|
||||
|
||||
### File naming and organisation
|
||||
|
||||
Names of files and directories should be in lowercase, with dashes between words — not in camel case. For instance, it should be `all-packages.nix`, not `allPackages.nix` or `AllPackages.nix`.
|
||||
|
||||
### Syntax
|
||||
|
||||
- Use 2 spaces of indentation per indentation level in Nix expressions, 4 spaces in shell scripts.
|
||||
|
||||
- Do not use tab characters, i.e. configure your editor to use soft tabs. For instance, use `(setq-default indent-tabs-mode nil)` in Emacs. Everybody has different tab settings so it’s asking for trouble.
|
||||
|
||||
- Use `lowerCamelCase` for variable names, not `UpperCamelCase`. Note, this rule does not apply to package attribute names, which instead follow the rules in [package naming](./pkgs/README.md#package-naming).
|
||||
|
||||
- Function calls with attribute set arguments are written as
|
||||
|
||||
```nix
|
||||
foo {
|
||||
arg = ...;
|
||||
}
|
||||
```
|
||||
|
||||
not
|
||||
|
||||
```nix
|
||||
foo
|
||||
{
|
||||
arg = ...;
|
||||
}
|
||||
```
|
||||
|
||||
Also fine is
|
||||
|
||||
```nix
|
||||
foo { arg = ...; }
|
||||
```
|
||||
|
||||
if it's a short call.
|
||||
|
||||
- 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 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";
|
||||
}
|
||||
];
|
||||
```
|
||||
|
||||
- Short lists or attribute sets can be written on one line:
|
||||
|
||||
```nix
|
||||
# A short list.
|
||||
list = [ elem1 elem2 elem3 ];
|
||||
|
||||
# A short set.
|
||||
attrs = { x = 1280; y = 1024; };
|
||||
```
|
||||
|
||||
- Breaking in the middle of a function argument can give hard-to-read code, like
|
||||
|
||||
```nix
|
||||
someFunction { x = 1280;
|
||||
y = 1024; } otherArg
|
||||
yetAnotherArg
|
||||
```
|
||||
|
||||
(especially if the argument is very large, spanning multiple lines).
|
||||
|
||||
Better:
|
||||
|
||||
```nix
|
||||
someFunction
|
||||
{ x = 1280; y = 1024; }
|
||||
otherArg
|
||||
yetAnotherArg
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```nix
|
||||
let res = { x = 1280; y = 1024; };
|
||||
in someFunction res otherArg yetAnotherArg
|
||||
```
|
||||
|
||||
- The bodies of functions, asserts, and withs are not indented to prevent a lot of superfluous indentation levels, i.e.
|
||||
|
||||
```nix
|
||||
{ arg1, arg2 }:
|
||||
assert system == "i686-linux";
|
||||
stdenv.mkDerivation { ...
|
||||
```
|
||||
|
||||
not
|
||||
|
||||
```nix
|
||||
{ arg1, arg2 }:
|
||||
assert system == "i686-linux";
|
||||
stdenv.mkDerivation { ...
|
||||
```
|
||||
|
||||
- Function formal arguments are written as:
|
||||
|
||||
```nix
|
||||
{ arg1, arg2, arg3 }:
|
||||
```
|
||||
|
||||
but if they don't fit on one line they're written as:
|
||||
|
||||
```nix
|
||||
{ arg1, arg2, arg3
|
||||
, arg4, ...
|
||||
, # Some comment...
|
||||
argN
|
||||
}:
|
||||
```
|
||||
|
||||
- Functions should list their expected arguments as precisely as possible. That is, write
|
||||
|
||||
```nix
|
||||
{ stdenv, fetchurl, perl }: ...
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```nix
|
||||
args: with args; ...
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```nix
|
||||
{ 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:
|
||||
|
||||
```nix
|
||||
{ stdenv, doCoverageAnalysis ? false, ... } @ args:
|
||||
|
||||
stdenv.mkDerivation (args // {
|
||||
... if doCoverageAnalysis then "bla" else "" ...
|
||||
})
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```nix
|
||||
args:
|
||||
|
||||
args.stdenv.mkDerivation (args // {
|
||||
... if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "" ...
|
||||
})
|
||||
```
|
||||
|
||||
- Unnecessary string conversions should be avoided. Do
|
||||
|
||||
```nix
|
||||
rev = version;
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```nix
|
||||
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;
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```nix
|
||||
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.
|
||||
If this is done a follow up pull request _should_ be created to change the code to `lib.optional(s)`.
|
||||
See the nixpkgs manual for more details on how to [Review contributions](https://nixos.org/nixpkgs/manual/#chap-reviewing-contributions).
|
||||
|
||||
21
README.md
21
README.md
@@ -70,7 +70,26 @@ Linux distribution. The [GitHub Insights](https://github.com/NixOS/nixpkgs/pulse
|
||||
page gives a sense of the project activity.
|
||||
|
||||
Community contributions are always welcome through GitHub Issues and
|
||||
Pull Requests.
|
||||
Pull Requests. When pull requests are made, our tooling automation bot,
|
||||
[OfBorg](https://github.com/NixOS/ofborg) will perform various checks
|
||||
to help ensure expression quality.
|
||||
|
||||
The *Nixpkgs maintainers* are people who have assigned themselves to
|
||||
maintain specific individual packages. We encourage people who care
|
||||
about a package to assign themselves as a maintainer. When a pull
|
||||
request is made against a package, OfBorg will notify the appropriate
|
||||
maintainer(s). The *Nixpkgs committers* are people who have been given
|
||||
permission to merge.
|
||||
|
||||
Most contributions are based on and merged into these branches:
|
||||
|
||||
* `master` is the main branch where all small contributions go
|
||||
* `staging` is branched from master, changes that have a big impact on
|
||||
Hydra builds go to this branch
|
||||
* `staging-next` is branched from staging and only fixes to stabilize
|
||||
and security fixes with a big impact on Hydra builds should be
|
||||
contributed to this branch. This branch is merged into master when
|
||||
deemed of sufficiently high quality
|
||||
|
||||
For more information about contributing to the project, please visit
|
||||
the [contributing page](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
|
||||
11
doc/.gitignore
vendored
Normal file
11
doc/.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
*.chapter.xml
|
||||
*.section.xml
|
||||
.version
|
||||
functions/library/generated
|
||||
functions/library/locations.xml
|
||||
highlightjs
|
||||
manual-full.xml
|
||||
out
|
||||
result
|
||||
result-*
|
||||
media
|
||||
119
doc/Makefile
Normal file
119
doc/Makefile
Normal file
@@ -0,0 +1,119 @@
|
||||
MD_TARGETS=$(addsuffix .xml, $(basename $(shell find . -type f -regex '.*\.md$$' -not -name README.md)))
|
||||
|
||||
PANDOC ?= pandoc
|
||||
|
||||
pandoc_media_dir = media
|
||||
# NOTE: Keep in sync with conversion script (/maintainers/scripts/db-to-md.sh).
|
||||
# TODO: Remove raw-attribute when we can get rid of DocBook altogether.
|
||||
pandoc_commonmark_enabled_extensions = +attributes+fenced_divs+footnotes+bracketed_spans+definition_lists+pipe_tables+raw_attribute
|
||||
# Not needed:
|
||||
# - docbook-reader/citerefentry-to-rst-role.lua (only relevant for DocBook → MarkDown/rST/MyST)
|
||||
pandoc_flags = --extract-media=$(pandoc_media_dir) \
|
||||
--lua-filter=$(PANDOC_LUA_FILTERS_DIR)/diagram-generator.lua \
|
||||
--lua-filter=build-aux/pandoc-filters/myst-reader/roles.lua \
|
||||
--lua-filter=$(PANDOC_LINK_MANPAGES_FILTER) \
|
||||
--lua-filter=build-aux/pandoc-filters/docbook-writer/rst-roles.lua \
|
||||
--lua-filter=build-aux/pandoc-filters/docbook-writer/labelless-link-is-xref.lua \
|
||||
-f commonmark$(pandoc_commonmark_enabled_extensions)+smart
|
||||
|
||||
.PHONY: all
|
||||
all: validate format out/html/index.html out/epub/manual.epub
|
||||
|
||||
.PHONY: render-md
|
||||
render-md: ${MD_TARGETS}
|
||||
|
||||
.PHONY: debug
|
||||
debug:
|
||||
nix-shell --run "xmloscopy --docbook5 ./manual.xml ./manual-full.xml"
|
||||
|
||||
.PHONY: format
|
||||
format: doc-support/result
|
||||
find . -iname '*.xml' -type f | while read f; do \
|
||||
echo $$f ;\
|
||||
xmlformat --config-file "doc-support/result/xmlformat.conf" -i $$f ;\
|
||||
done
|
||||
|
||||
.PHONY: fix-misc-xml
|
||||
fix-misc-xml:
|
||||
find . -iname '*.xml' -type f \
|
||||
-exec ../nixos/doc/varlistentry-fixer.rb {} ';'
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f ${MD_TARGETS} doc-support/result .version manual-full.xml functions/library/locations.xml functions/library/generated
|
||||
rm -rf ./out/ ./highlightjs ./media
|
||||
|
||||
.PHONY: validate
|
||||
validate: manual-full.xml doc-support/result
|
||||
jing doc-support/result/docbook.rng manual-full.xml
|
||||
|
||||
out/html/index.html: doc-support/result manual-full.xml style.css highlightjs
|
||||
mkdir -p out/html
|
||||
xsltproc \
|
||||
--nonet --xinclude \
|
||||
--output $@ \
|
||||
doc-support/result/xhtml.xsl \
|
||||
./manual-full.xml
|
||||
|
||||
mkdir -p out/html/highlightjs/
|
||||
cp -r highlightjs out/html/
|
||||
|
||||
cp -r $(pandoc_media_dir) out/html/
|
||||
cp ./overrides.css out/html/
|
||||
cp ./style.css out/html/style.css
|
||||
|
||||
mkdir -p out/html/images/callouts
|
||||
cp doc-support/result/xsl/docbook/images/callouts/*.svg out/html/images/callouts/
|
||||
chmod u+w -R out/html/
|
||||
|
||||
out/epub/manual.epub: manual-full.xml
|
||||
mkdir -p out/epub/scratch
|
||||
xsltproc --nonet \
|
||||
--output out/epub/scratch/ \
|
||||
doc-support/result/epub.xsl \
|
||||
./manual-full.xml
|
||||
|
||||
cp -r $(pandoc_media_dir) out/epub/scratch/OEBPS
|
||||
cp ./overrides.css out/epub/scratch/OEBPS
|
||||
cp ./style.css out/epub/scratch/OEBPS
|
||||
mkdir -p out/epub/scratch/OEBPS/images/callouts/
|
||||
cp doc-support/result/xsl/docbook/images/callouts/*.svg out/epub/scratch/OEBPS/images/callouts/
|
||||
echo "application/epub+zip" > mimetype
|
||||
zip -0Xq "out/epub/manual.epub" mimetype
|
||||
rm mimetype
|
||||
cd "out/epub/scratch/" && zip -Xr9D "../manual.epub" *
|
||||
rm -rf "out/epub/scratch/"
|
||||
|
||||
highlightjs: doc-support/result
|
||||
mkdir -p highlightjs
|
||||
cp -r doc-support/result/highlightjs/highlight.pack.js highlightjs/
|
||||
cp -r doc-support/result/highlightjs/LICENSE highlightjs/
|
||||
cp -r doc-support/result/highlightjs/mono-blue.css highlightjs/
|
||||
cp -r doc-support/result/highlightjs/loader.js highlightjs/
|
||||
|
||||
|
||||
manual-full.xml: ${MD_TARGETS} .version functions/library/locations.xml functions/library/generated *.xml **/*.xml **/**/*.xml
|
||||
xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml
|
||||
|
||||
.version: doc-support/result
|
||||
ln -rfs ./doc-support/result/version .version
|
||||
|
||||
doc-support/result: doc-support/default.nix
|
||||
(cd doc-support; nix-build)
|
||||
|
||||
functions/library/locations.xml: doc-support/result
|
||||
ln -rfs ./doc-support/result/function-locations.xml functions/library/locations.xml
|
||||
|
||||
functions/library/generated: doc-support/result
|
||||
ln -rfs ./doc-support/result/function-docs functions/library/generated
|
||||
|
||||
%.section.xml: %.section.md
|
||||
$(PANDOC) $^ -t docbook \
|
||||
$(pandoc_flags) \
|
||||
-o $@
|
||||
|
||||
%.chapter.xml: %.chapter.md
|
||||
$(PANDOC) $^ -t docbook \
|
||||
--top-level-division=chapter \
|
||||
$(pandoc_flags) \
|
||||
-o $@
|
||||
133
doc/README.md
133
doc/README.md
@@ -1,137 +1,12 @@
|
||||
# Contributing to the Nixpkgs manual
|
||||
|
||||
# Nixpkgs/doc
|
||||
|
||||
This directory houses the sources files for the Nixpkgs manual.
|
||||
|
||||
You can find the [rendered documentation for Nixpkgs `unstable` on nixos.org](https://nixos.org/manual/nixpkgs/unstable/).
|
||||
The rendering tool is [nixos-render-docs](../pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs), sometimes abbreviated `nrd`.
|
||||
|
||||
[Docs for Nixpkgs stable](https://nixos.org/manual/nixpkgs/stable/) are also available.
|
||||
|
||||
If you want to contribute to the documentation, [here's how to do it](https://nixos.org/manual/nixpkgs/unstable/#chap-contributing).
|
||||
|
||||
If you're only getting started with Nix, go to [nixos.org/learn](https://nixos.org/learn).
|
||||
|
||||
## Contributing to this documentation
|
||||
|
||||
You can quickly check your edits with `nix-build`:
|
||||
|
||||
```ShellSession
|
||||
$ cd /path/to/nixpkgs
|
||||
$ nix-build doc
|
||||
```
|
||||
|
||||
If the build succeeds, the manual will be in `./result/share/doc/nixpkgs/manual.html`.
|
||||
|
||||
### devmode
|
||||
|
||||
The shell in the manual source directory makes available a command, `devmode`.
|
||||
It is a daemon, that:
|
||||
1. watches the manual's source for changes and when they occur — rebuilds
|
||||
2. HTTP serves the manual, injecting a script that triggers reload on changes
|
||||
3. opens the manual in the default browser
|
||||
|
||||
## Syntax
|
||||
|
||||
As per [RFC 0072](https://github.com/NixOS/rfcs/pull/72), all new documentation content should be written in [CommonMark](https://commonmark.org/) Markdown dialect.
|
||||
|
||||
Additional syntax extensions are available, all of which can be used in NixOS option documentation. The following extensions are currently used:
|
||||
|
||||
#### Tables
|
||||
|
||||
Tables, using the [GitHub-flavored Markdown syntax](https://github.github.com/gfm/#tables-extension-).
|
||||
|
||||
#### Anchors
|
||||
|
||||
Explicitly defined **anchors** on headings, to allow linking to sections. These should be always used, to ensure the anchors can be linked even when the heading text changes, and to prevent conflicts between [automatically assigned identifiers](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/auto_identifiers.md).
|
||||
|
||||
It uses the widely compatible [header attributes](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/attributes.md) syntax:
|
||||
|
||||
```markdown
|
||||
## Syntax {#sec-contributing-markup}
|
||||
```
|
||||
|
||||
> **Note**
|
||||
> NixOS option documentation does not support headings in general.
|
||||
|
||||
#### Inline Anchors
|
||||
|
||||
Allow linking arbitrary place in the text (e.g. individual list items, sentences…).
|
||||
|
||||
They are defined using a hybrid of the link syntax with the attributes syntax known from headings, called [bracketed spans](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/bracketed_spans.md):
|
||||
|
||||
```markdown
|
||||
- []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`.
|
||||
```
|
||||
|
||||
#### Automatic links
|
||||
|
||||
If you **omit a link text** for a link pointing to a section, the text will be substituted automatically. For example `[](#chap-contributing)`.
|
||||
|
||||
This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing).
|
||||
|
||||
#### Roles
|
||||
|
||||
If you want to link to a man page, you can use `` {manpage}`nix.conf(5)` ``. The references will turn into links when a mapping exists in [`doc/manpage-urls.json`](./manpage-urls.json).
|
||||
|
||||
A few markups for other kinds of literals are also available:
|
||||
|
||||
- `` {command}`rm -rfi` ``
|
||||
- `` {env}`XDG_DATA_DIRS` ``
|
||||
- `` {file}`/etc/passwd` ``
|
||||
- `` {option}`networking.useDHCP` ``
|
||||
- `` {var}`/etc/passwd` ``
|
||||
|
||||
These literal kinds are used mostly in NixOS option documentation.
|
||||
|
||||
This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/syntax/syntax.html#roles-an-in-line-extension-point). Though, the feature originates from [reStructuredText](https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-manpage) with slightly different syntax.
|
||||
|
||||
#### Admonitions
|
||||
|
||||
Set off from the text to bring attention to something.
|
||||
|
||||
It uses pandoc’s [fenced `div`s syntax](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/fenced_divs.md):
|
||||
|
||||
```markdown
|
||||
::: {.warning}
|
||||
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)
|
||||
|
||||
#### [Definition lists](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/definition_lists.md)
|
||||
|
||||
For defining a group of terms:
|
||||
|
||||
```markdown
|
||||
pear
|
||||
: green or yellow bulbous fruit
|
||||
|
||||
watermelon
|
||||
: green fruit with red flesh
|
||||
```
|
||||
|
||||
## Commit conventions
|
||||
|
||||
- Make sure you read about the [commit conventions](../CONTRIBUTING.md#commit-conventions) common to Nixpkgs as a whole.
|
||||
|
||||
- If creating a commit purely for documentation changes, format the commit message in the following way:
|
||||
|
||||
```
|
||||
doc: (documentation summary)
|
||||
|
||||
(Motivation for change, relevant links, additional information.)
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
* doc: update the kernel config documentation to use `nix-shell`
|
||||
* doc: add information about `nix-update-script`
|
||||
|
||||
Closes #216321.
|
||||
|
||||
- If the commit contains more than just documentation changes, follow the commit message format relevant for the rest of the changes.
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
--[[
|
||||
Converts Code AST nodes produced by pandoc’s DocBook reader
|
||||
from citerefentry elements into AST for corresponding role
|
||||
for reStructuredText.
|
||||
|
||||
We use subset of MyST syntax (CommonMark with features from rST)
|
||||
so let’s use the rST AST for rST features.
|
||||
|
||||
Reference: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-manpage
|
||||
]]
|
||||
|
||||
function Code(elem)
|
||||
elem.classes = elem.classes:map(function (x)
|
||||
if x == 'citerefentry' then
|
||||
elem.attributes['role'] = 'manpage'
|
||||
return 'interpreted-text'
|
||||
else
|
||||
return x
|
||||
end
|
||||
end)
|
||||
|
||||
return elem
|
||||
end
|
||||
@@ -0,0 +1,34 @@
|
||||
--[[
|
||||
Converts Link AST nodes with empty label to DocBook xref elements.
|
||||
|
||||
This is a temporary script to be able use cross-references conveniently
|
||||
using syntax taken from MyST, while we still use docbook-xsl
|
||||
for generating the documentation.
|
||||
|
||||
Reference: https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing
|
||||
]]
|
||||
|
||||
local function starts_with(start, str)
|
||||
return str:sub(1, #start) == start
|
||||
end
|
||||
|
||||
local function escape_xml_arg(arg)
|
||||
amps = arg:gsub('&', '&')
|
||||
amps_quotes = amps:gsub('"', '"')
|
||||
amps_quotes_lt = amps_quotes:gsub('<', '<')
|
||||
|
||||
return amps_quotes_lt
|
||||
end
|
||||
|
||||
function Link(elem)
|
||||
has_no_content = #elem.content == 0
|
||||
targets_anchor = starts_with('#', elem.target)
|
||||
has_no_attributes = elem.title == '' and elem.identifier == '' and #elem.classes == 0 and #elem.attributes == 0
|
||||
|
||||
if has_no_content and targets_anchor and has_no_attributes then
|
||||
-- xref expects idref without the pound-sign
|
||||
target_without_hash = elem.target:sub(2, #elem.target)
|
||||
|
||||
return pandoc.RawInline('docbook', '<xref linkend="' .. escape_xml_arg(target_without_hash) .. '" />')
|
||||
end
|
||||
end
|
||||
44
doc/build-aux/pandoc-filters/docbook-writer/rst-roles.lua
Normal file
44
doc/build-aux/pandoc-filters/docbook-writer/rst-roles.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
--[[
|
||||
Converts AST for reStructuredText roles into corresponding
|
||||
DocBook elements.
|
||||
|
||||
Currently, only a subset of roles is supported.
|
||||
|
||||
Reference:
|
||||
List of roles:
|
||||
https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html
|
||||
manpage:
|
||||
https://tdg.docbook.org/tdg/5.1/citerefentry.html
|
||||
file:
|
||||
https://tdg.docbook.org/tdg/5.1/filename.html
|
||||
]]
|
||||
|
||||
function Code(elem)
|
||||
if elem.classes:includes('interpreted-text') then
|
||||
local tag = nil
|
||||
local content = elem.text
|
||||
if elem.attributes['role'] == 'manpage' then
|
||||
tag = 'citerefentry'
|
||||
local title, volnum = content:match('^(.+)%((%w+)%)$')
|
||||
if title == nil then
|
||||
-- No volnum in parentheses.
|
||||
title = content
|
||||
end
|
||||
content = '<refentrytitle>' .. title .. '</refentrytitle>' .. (volnum ~= nil and ('<manvolnum>' .. volnum .. '</manvolnum>') or '')
|
||||
elseif elem.attributes['role'] == 'file' then
|
||||
tag = 'filename'
|
||||
elseif elem.attributes['role'] == 'command' then
|
||||
tag = 'command'
|
||||
elseif elem.attributes['role'] == 'option' then
|
||||
tag = 'option'
|
||||
elseif elem.attributes['role'] == 'var' then
|
||||
tag = 'varname'
|
||||
elseif elem.attributes['role'] == 'env' then
|
||||
tag = 'envar'
|
||||
end
|
||||
|
||||
if tag ~= nil then
|
||||
return pandoc.RawInline('docbook', '<' .. tag .. '>' .. content .. '</' .. tag .. '>')
|
||||
end
|
||||
end
|
||||
end
|
||||
28
doc/build-aux/pandoc-filters/link-manpages.nix
Normal file
28
doc/build-aux/pandoc-filters/link-manpages.nix
Normal file
@@ -0,0 +1,28 @@
|
||||
{ pkgs ? import ../../.. {} }:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
manpageURLs = lib.importJSON (pkgs.path + "/doc/manpage-urls.json");
|
||||
in pkgs.writeText "link-manpages.lua" ''
|
||||
--[[
|
||||
Adds links to known man pages that aren't already in a link.
|
||||
]]
|
||||
|
||||
local manpage_urls = {
|
||||
${lib.concatStringsSep "\n" (lib.mapAttrsToList (man: url:
|
||||
" [${builtins.toJSON man}] = ${builtins.toJSON url},") manpageURLs)}
|
||||
}
|
||||
|
||||
traverse = 'topdown'
|
||||
|
||||
-- Returning false as the second value aborts processing of child elements.
|
||||
function Link(elem)
|
||||
return elem, false
|
||||
end
|
||||
|
||||
function Code(elem)
|
||||
local is_man_role = elem.classes:includes('interpreted-text') and elem.attributes['role'] == 'manpage'
|
||||
if is_man_role and manpage_urls[elem.text] ~= nil then
|
||||
return pandoc.Link(elem, manpage_urls[elem.text]), false
|
||||
end
|
||||
end
|
||||
''
|
||||
36
doc/build-aux/pandoc-filters/myst-reader/roles.lua
Normal file
36
doc/build-aux/pandoc-filters/myst-reader/roles.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
--[[
|
||||
Replaces Str AST nodes containing {role}, followed by a Code node
|
||||
by a Code node with attrs that would be produced by rST reader
|
||||
from the role syntax.
|
||||
|
||||
This is to emulate MyST syntax in Pandoc.
|
||||
(MyST is a CommonMark flavour with rST features mixed in.)
|
||||
|
||||
Reference: https://myst-parser.readthedocs.io/en/latest/syntax/syntax.html#roles-an-in-line-extension-point
|
||||
]]
|
||||
|
||||
function Inlines(inlines)
|
||||
for i = #inlines-1,1,-1 do
|
||||
local first = inlines[i]
|
||||
local second = inlines[i+1]
|
||||
local correct_tags = first.tag == 'Str' and second.tag == 'Code'
|
||||
if correct_tags then
|
||||
-- docutils supports alphanumeric strings separated by [-._:]
|
||||
-- We are slightly more liberal for simplicity.
|
||||
-- Allow preceding punctuation (eg '('), otherwise '({file}`...`)'
|
||||
-- does not match. Also allow anything followed by a non-breaking space
|
||||
-- since pandoc emits those after certain abbreviations (e.g. e.g.).
|
||||
local prefix, role = first.text:match('^(.*){([-._+:%w]+)}$')
|
||||
if role ~= nil and (prefix == '' or prefix:match("^.*[%p ]$") ~= nil) then
|
||||
if prefix == '' then
|
||||
inlines:remove(i)
|
||||
else
|
||||
first.text = prefix
|
||||
end
|
||||
second.attributes['role'] = role
|
||||
second.classes:insert('interpreted-text')
|
||||
end
|
||||
end
|
||||
end
|
||||
return inlines
|
||||
end
|
||||
25
doc/build-aux/pandoc-filters/myst-writer/roles.lua
Normal file
25
doc/build-aux/pandoc-filters/myst-writer/roles.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
--[[
|
||||
Replaces Code nodes with attrs that would be produced by rST reader
|
||||
from the role syntax by a Str AST node containing {role}, followed by a Code node.
|
||||
|
||||
This is to emulate MyST syntax in Pandoc.
|
||||
(MyST is a CommonMark flavour with rST features mixed in.)
|
||||
|
||||
Reference: https://myst-parser.readthedocs.io/en/latest/syntax/syntax.html#roles-an-in-line-extension-point
|
||||
]]
|
||||
|
||||
function Code(elem)
|
||||
local role = elem.attributes['role']
|
||||
|
||||
if elem.classes:includes('interpreted-text') and role ~= nil then
|
||||
elem.classes = elem.classes:filter(function (c)
|
||||
return c ~= 'interpreted-text'
|
||||
end)
|
||||
elem.attributes['role'] = nil
|
||||
|
||||
return {
|
||||
pandoc.Str('{' .. role .. '}'),
|
||||
elem,
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -1,28 +0,0 @@
|
||||
# Build helpers {#part-builders}
|
||||
|
||||
A build helper is a function that produces derivations.
|
||||
|
||||
:::{.warning}
|
||||
This is not to be confused with the [`builder` argument of the Nix `derivation` primitive](https://nixos.org/manual/nix/unstable/language/derivations.html), which refers to the executable that produces the build result, or [remote builder](https://nixos.org/manual/nix/stable/advanced-topics/distributed-builds.html), which refers to a remote machine that could run such an executable.
|
||||
:::
|
||||
|
||||
Such a function is usually designed to abstract over a typical workflow for a given programming language or framework.
|
||||
This allows declaring a build recipe by setting a limited number of options relevant to the particular use case instead of using the `derivation` function directly.
|
||||
|
||||
[`stdenv.mkDerivation`](#part-stdenv) is the most widely used build helper, and serves as a basis for many others.
|
||||
In addition, it offers various options to customize parts of the builds.
|
||||
|
||||
There is no uniform interface for build helpers.
|
||||
[Trivial build helpers](#chap-trivial-builders) and [fetchers](#chap-pkgs-fetchers) have various input types for convenience.
|
||||
[Language- or framework-specific build helpers](#chap-language-support) usually follow the style of `stdenv.mkDerivation`, which accepts an attribute set or a fixed-point function taking an attribute set.
|
||||
|
||||
```{=include=} chapters
|
||||
build-helpers/fetchers.chapter.md
|
||||
build-helpers/trivial-build-helpers.chapter.md
|
||||
build-helpers/testers.chapter.md
|
||||
build-helpers/special.md
|
||||
build-helpers/images.md
|
||||
hooks/index.md
|
||||
languages-frameworks/index.md
|
||||
packages/index.md
|
||||
```
|
||||
@@ -1,283 +0,0 @@
|
||||
# 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.
|
||||
|
||||
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.
|
||||
- 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.
|
||||
- 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.
|
||||
|
||||
The following table shows an overview of 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 |
|
||||
|
||||
## 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:
|
||||
|
||||
```nix
|
||||
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=";
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
## `fetchpatch` {#fetchpatch}
|
||||
|
||||
`fetchpatch` works very similarly to `fetchurl` with the same arguments expected. It expects patch files as a source and performs normalization on them before computing the checksum. For example, it will remove comments or other unstable parts that are sometimes added by version control systems and can change over time.
|
||||
|
||||
- `relative`: Similar to using `git-diff`'s `--relative` flag, only keep changes inside the specified directory, making paths relative to it.
|
||||
- `stripLen`: Remove the first `stripLen` components of pathnames in the patch.
|
||||
- `decode`: Pipe the downloaded data through this command before processing it as a patch.
|
||||
- `extraPrefix`: Prefix pathnames by this string.
|
||||
- `excludes`: Exclude files matching these patterns (applies after the above arguments).
|
||||
- `includes`: Include only files matching these patterns (applies after the above arguments).
|
||||
- `revert`: Revert the patch.
|
||||
|
||||
Note that because the checksum is computed after applying these effects, using or modifying these arguments will have no effect unless the `hash` argument is changed as well.
|
||||
|
||||
|
||||
Most other fetchers return a directory rather than a single file.
|
||||
|
||||
|
||||
## `fetchDebianPatch` {#fetchdebianpatch}
|
||||
|
||||
A wrapper around `fetchpatch`, which takes:
|
||||
- `patch` and `hash`: the patch's filename,
|
||||
and its hash after normalization by `fetchpatch` ;
|
||||
- `pname`: the Debian source package's name ;
|
||||
- `version`: the upstream version number ;
|
||||
- `debianRevision`: the [Debian revision number] if applicable ;
|
||||
- the `area` of the Debian archive: `main` (default), `contrib`, or `non-free`.
|
||||
|
||||
Here is an example of `fetchDebianPatch` in action:
|
||||
|
||||
```nix
|
||||
{ lib
|
||||
, fetchDebianPatch
|
||||
, buildPythonPackage
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "pysimplesoap";
|
||||
version = "1.16.2";
|
||||
src = ...;
|
||||
|
||||
patches = [
|
||||
(fetchDebianPatch {
|
||||
inherit pname version;
|
||||
debianRevision = "5";
|
||||
name = "Add-quotes-to-SOAPAction-header-in-SoapClient.patch";
|
||||
hash = "sha256-xA8Wnrpr31H8wy3zHSNfezFNjUJt1HbSXn3qUMzeKc0=";
|
||||
})
|
||||
];
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Patches are fetched from `sources.debian.org`, and so must come from a
|
||||
package version that was uploaded to the Debian archive. Packages may
|
||||
be removed from there once that specific version isn't in any suite
|
||||
anymore (stable, testing, unstable, etc.), so maintainers should use
|
||||
`copy-tarballs.pl` to archive the patch if it needs to be available
|
||||
longer-term.
|
||||
|
||||
[Debian revision number]: https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
|
||||
|
||||
|
||||
## `fetchsvn` {#fetchsvn}
|
||||
|
||||
Used with Subversion. Expects `url` to a Subversion directory, `rev`, and `hash`.
|
||||
|
||||
## `fetchgit` {#fetchgit}
|
||||
|
||||
Used with Git. Expects `url` to a Git repo, `rev`, and `hash`. `rev` in this case can be full the git commit id (SHA1 hash) or a tag name like `refs/tags/v1.0`.
|
||||
|
||||
Additionally, the following optional arguments can be given: `fetchSubmodules = true` makes `fetchgit` also fetch the submodules of a repository. If `deepClone` is set to true, the entire repository is cloned as opposing to just creating a shallow clone. `deepClone = true` also implies `leaveDotGit = true` which means that the `.git` directory of the clone won't be removed after checkout.
|
||||
|
||||
If only parts of the repository are needed, `sparseCheckout` can be used. This will prevent git from fetching unnecessary blobs from server, see [git sparse-checkout](https://git-scm.com/docs/git-sparse-checkout) for more information:
|
||||
|
||||
```nix
|
||||
{ stdenv, fetchgit }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "hello";
|
||||
src = fetchgit {
|
||||
url = "https://...";
|
||||
sparseCheckout = [
|
||||
"directory/to/be/included"
|
||||
"another/directory"
|
||||
];
|
||||
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## `fetchfossil` {#fetchfossil}
|
||||
|
||||
Used with Fossil. Expects `url` to a Fossil archive, `rev`, and `hash`.
|
||||
|
||||
## `fetchcvs` {#fetchcvs}
|
||||
|
||||
Used with CVS. Expects `cvsRoot`, `tag`, and `hash`.
|
||||
|
||||
## `fetchhg` {#fetchhg}
|
||||
|
||||
Used with Mercurial. Expects `url`, `rev`, and `hash`.
|
||||
|
||||
A number of fetcher functions wrap part of `fetchurl` and `fetchzip`. They are mainly convenience functions intended for commonly used destinations of source code in Nixpkgs. These wrapper fetchers are listed below.
|
||||
|
||||
## `fetchFromGitea` {#fetchfromgitea}
|
||||
|
||||
`fetchFromGitea` expects five arguments. `domain` is the gitea server name. `owner` is a string corresponding to the Gitea user or organization that controls this repository. `repo` corresponds to the name of the software repository. These are located at the top of every Gitea HTML page as `owner`/`repo`. `rev` corresponds to the Git commit hash or tag (e.g `v1.0`) that will be downloaded from Git. Finally, `hash` corresponds to the hash of the extracted directory. Again, other hash algorithms are also available but `hash` is currently preferred.
|
||||
|
||||
## `fetchFromGitHub` {#fetchfromgithub}
|
||||
|
||||
`fetchFromGitHub` expects four arguments. `owner` is a string corresponding to the GitHub user or organization that controls this repository. `repo` corresponds to the name of the software repository. These are located at the top of every GitHub HTML page as `owner`/`repo`. `rev` corresponds to the Git commit hash or tag (e.g `v1.0`) that will be downloaded from Git. Finally, `hash` corresponds to the hash of the extracted directory. Again, other hash algorithms are also available, but `hash` is currently preferred.
|
||||
|
||||
To use a different GitHub instance, use `githubBase` (defaults to `"github.com"`).
|
||||
|
||||
`fetchFromGitHub` uses `fetchzip` to download the source archive generated by GitHub for the specified revision. If `leaveDotGit`, `deepClone` or `fetchSubmodules` are set to `true`, `fetchFromGitHub` will use `fetchgit` instead. Refer to its section for documentation of these options.
|
||||
|
||||
## `fetchFromGitLab` {#fetchfromgitlab}
|
||||
|
||||
This is used with GitLab repositories. It behaves similarly to `fetchFromGitHub`, and expects `owner`, `repo`, `rev`, and `hash`.
|
||||
|
||||
To use a specific GitLab instance, use `domain` (defaults to `"gitlab.com"`).
|
||||
|
||||
|
||||
## `fetchFromGitiles` {#fetchfromgitiles}
|
||||
|
||||
This is used with Gitiles repositories. The arguments expected are similar to `fetchgit`.
|
||||
|
||||
## `fetchFromBitbucket` {#fetchfrombitbucket}
|
||||
|
||||
This is used with BitBucket repositories. The arguments expected are very similar to `fetchFromGitHub` above.
|
||||
|
||||
## `fetchFromSavannah` {#fetchfromsavannah}
|
||||
|
||||
This is used with Savannah repositories. The arguments expected are very similar to `fetchFromGitHub` above.
|
||||
|
||||
## `fetchFromRepoOrCz` {#fetchfromrepoorcz}
|
||||
|
||||
This is used with repo.or.cz repositories. The arguments expected are very similar to `fetchFromGitHub` above.
|
||||
|
||||
## `fetchFromSourcehut` {#fetchfromsourcehut}
|
||||
|
||||
This is used with sourcehut repositories. Similar to `fetchFromGitHub` above,
|
||||
it expects `owner`, `repo`, `rev` and `hash`, but don't forget the tilde (~)
|
||||
in front of the username! Expected arguments also include `vc` ("git" (default)
|
||||
or "hg"), `domain` and `fetchSubmodules`.
|
||||
|
||||
If `fetchSubmodules` is `true`, `fetchFromSourcehut` uses `fetchgit`
|
||||
or `fetchhg` with `fetchSubmodules` or `fetchSubrepos` set to `true`,
|
||||
respectively. Otherwise, the fetcher uses `fetchzip`.
|
||||
|
||||
## `requireFile` {#requirefile}
|
||||
|
||||
`requireFile` allows requesting files that cannot be fetched automatically, but whose content is known.
|
||||
This is a useful last-resort workaround for license restrictions that prohibit redistribution, or for downloads that are only accessible after authenticating interactively in a browser.
|
||||
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:
|
||||
|
||||
```
|
||||
requireFile {
|
||||
name = "jdk-${version}_linux-x64_bin.tar.gz";
|
||||
url = "https://www.oracle.com/java/technologies/javase-jdk11-downloads.html";
|
||||
hash = "sha256-lL00+F7jjT71nlKJ7HRQuUQ7kkxVYlZh//5msD8sjeI=";
|
||||
}
|
||||
```
|
||||
results in this error message:
|
||||
```
|
||||
***
|
||||
Unfortunately, we cannot download file jdk-11.0.10_linux-x64_bin.tar.gz automatically.
|
||||
Please go to https://www.oracle.com/java/technologies/javase-jdk11-downloads.html to download it yourself, and add it to the Nix store
|
||||
using either
|
||||
nix-store --add-fixed sha256 jdk-11.0.10_linux-x64_bin.tar.gz
|
||||
or
|
||||
nix-prefetch-url --type sha256 file:///path/to/jdk-11.0.10_linux-x64_bin.tar.gz
|
||||
|
||||
***
|
||||
```
|
||||
## `fetchtorrent` {#fetchtorrent}
|
||||
|
||||
`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)
|
||||
|
||||
```
|
||||
{ fetchtorrent }:
|
||||
|
||||
fetchtorrent {
|
||||
config = { peer-limit-global = 100; };
|
||||
url = "magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c";
|
||||
sha256 = "";
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters {#fetchtorrent-parameters}
|
||||
|
||||
- `url`: Magnet URI (Magnet Link) such as `magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c` or an HTTP URL pointing to a `.torrent` file.
|
||||
|
||||
- `backend`: Which bittorrent program to use. Default: `"transmission"`. Valid values are `"rqbit"` or `"transmission"`. These are the two most suitable torrent clients for fetching in a fixed-output derivation at the time of writing, as they can be easily exited after usage. `rqbit` is written in Rust and has a smaller closure size than `transmission`, and the performance and peer discovery properties differs between these clients, requiring experimentation to decide upon which is the best.
|
||||
|
||||
- `config`: When using `transmission` as the `backend`, a json configuration can
|
||||
be supplied to transmission. Refer to the [upstream documentation](https://github.com/transmission/transmission/blob/main/docs/Editing-Configuration-Files.md) for information on how to configure.
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
# Images {#chap-images}
|
||||
|
||||
This chapter describes tools for creating various types of images.
|
||||
|
||||
```{=include=} sections
|
||||
images/appimagetools.section.md
|
||||
images/dockertools.section.md
|
||||
images/ocitools.section.md
|
||||
images/snaptools.section.md
|
||||
images/portableservice.section.md
|
||||
images/makediskimage.section.md
|
||||
images/binarycache.section.md
|
||||
```
|
||||
@@ -1,10 +0,0 @@
|
||||
# Special build helpers {#chap-special}
|
||||
|
||||
This chapter describes several special build helpers.
|
||||
|
||||
```{=include=} sections
|
||||
special/fhs-environments.section.md
|
||||
special/makesetuphook.section.md
|
||||
special/mkshell.section.md
|
||||
special/vm-tools.section.md
|
||||
```
|
||||
@@ -1,240 +0,0 @@
|
||||
# Trivial build helpers {#chap-trivial-builders}
|
||||
|
||||
Nixpkgs provides a couple of functions that help with building derivations. The most important one, `stdenv.mkDerivation`, has already been documented above. The following functions wrap `stdenv.mkDerivation`, making it easier to use in certain cases.
|
||||
|
||||
## `runCommand` {#trivial-builder-runCommand}
|
||||
|
||||
`runCommand :: String -> AttrSet -> String -> Derivation`
|
||||
|
||||
`runCommand name drvAttrs buildCommand` returns a derivation that is built by running the specified shell commands.
|
||||
|
||||
`name :: String`
|
||||
: The name that Nix will append to the store path in the same way that `stdenv.mkDerivation` uses its `name` attribute.
|
||||
|
||||
`drvAttr :: AttrSet`
|
||||
: Attributes to pass to the underlying call to [`stdenv.mkDerivation`](#chap-stdenv).
|
||||
|
||||
`buildCommand :: String`
|
||||
: Shell commands to run in the derivation builder.
|
||||
|
||||
::: {.note}
|
||||
You have to create a file or directory `$out` for Nix to be able to run the builder successfully.
|
||||
:::
|
||||
|
||||
::: {.example #ex-runcommand-simple}
|
||||
# Invocation of `runCommand`
|
||||
|
||||
```nix
|
||||
(import <nixpkgs> {}).runCommand "my-example" {} ''
|
||||
echo My example command is running
|
||||
|
||||
mkdir $out
|
||||
|
||||
echo I can write data to the Nix store > $out/message
|
||||
|
||||
echo I can also run basic commands like:
|
||||
|
||||
echo ls
|
||||
ls
|
||||
|
||||
echo whoami
|
||||
whoami
|
||||
|
||||
echo date
|
||||
date
|
||||
''
|
||||
```
|
||||
:::
|
||||
|
||||
## `runCommandCC` {#trivial-builder-runCommandCC}
|
||||
|
||||
This works just like `runCommand`. The only difference is that it also provides a C compiler in `buildCommand`'s environment. To minimize your dependencies, you should only use this if you are sure you will need a C compiler as part of running your command.
|
||||
|
||||
## `runCommandLocal` {#trivial-builder-runCommandLocal}
|
||||
|
||||
Variant of `runCommand` that forces the derivation to be built locally, it is not substituted. This is intended for very cheap commands (<1s execution time). It saves on the network round-trip and can speed up a build.
|
||||
|
||||
::: {.note}
|
||||
This sets [`allowSubstitutes` to `false`](https://nixos.org/nix/manual/#adv-attr-allowSubstitutes), so only use `runCommandLocal` if you are certain the user will always have a builder for the `system` of the derivation. This should be true for most trivial use cases (e.g., just copying some files to a different location or adding symlinks) because there the `system` is usually the same as `builtins.currentSystem`.
|
||||
:::
|
||||
|
||||
## `writeTextFile`, `writeText`, `writeTextDir`, `writeScript`, `writeScriptBin` {#trivial-builder-writeText}
|
||||
|
||||
These functions write `text` to the Nix store. This is useful for creating scripts from Nix expressions. `writeTextFile` takes an attribute set and expects two arguments, `name` and `text`. `name` corresponds to the name used in the Nix store path. `text` will be the contents of the file. You can also set `executable` to true to make this file have the executable bit set.
|
||||
|
||||
Many more commands wrap `writeTextFile` including `writeText`, `writeTextDir`, `writeScript`, and `writeScriptBin`. These are convenience functions over `writeTextFile`.
|
||||
|
||||
Here are a few examples:
|
||||
```nix
|
||||
# Writes my-file to /nix/store/<store path>
|
||||
writeTextFile {
|
||||
name = "my-file";
|
||||
text = ''
|
||||
Contents of File
|
||||
'';
|
||||
}
|
||||
# See also the `writeText` helper function below.
|
||||
|
||||
# Writes executable my-file to /nix/store/<store path>/bin/my-file
|
||||
writeTextFile {
|
||||
name = "my-file";
|
||||
text = ''
|
||||
Contents of File
|
||||
'';
|
||||
executable = true;
|
||||
destination = "/bin/my-file";
|
||||
}
|
||||
# Writes contents of file to /nix/store/<store path>
|
||||
writeText "my-file"
|
||||
''
|
||||
Contents of File
|
||||
'';
|
||||
# Writes contents of file to /nix/store/<store path>/share/my-file
|
||||
writeTextDir "share/my-file"
|
||||
''
|
||||
Contents of File
|
||||
'';
|
||||
# Writes my-file to /nix/store/<store path> and makes executable
|
||||
writeScript "my-file"
|
||||
''
|
||||
Contents of File
|
||||
'';
|
||||
# Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
|
||||
writeScriptBin "my-file"
|
||||
''
|
||||
Contents of File
|
||||
'';
|
||||
# Writes my-file to /nix/store/<store path> and makes executable.
|
||||
writeShellScript "my-file"
|
||||
''
|
||||
Contents of File
|
||||
'';
|
||||
# Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
|
||||
writeShellScriptBin "my-file"
|
||||
''
|
||||
Contents of File
|
||||
'';
|
||||
|
||||
```
|
||||
|
||||
## `concatTextFile`, `concatText`, `concatScript` {#trivial-builder-concatText}
|
||||
|
||||
These functions concatenate `files` to the Nix store in a single file. This is useful for configuration files structured in lines of text. `concatTextFile` takes an attribute set and expects two arguments, `name` and `files`. `name` corresponds to the name used in the Nix store path. `files` will be the files to be concatenated. You can also set `executable` to true to make this file have the executable bit set.
|
||||
`concatText` and`concatScript` are simple wrappers over `concatTextFile`.
|
||||
|
||||
Here are a few examples:
|
||||
```nix
|
||||
|
||||
# Writes my-file to /nix/store/<store path>
|
||||
concatTextFile {
|
||||
name = "my-file";
|
||||
files = [ drv1 "${drv2}/path/to/file" ];
|
||||
}
|
||||
# See also the `concatText` helper function below.
|
||||
|
||||
# Writes executable my-file to /nix/store/<store path>/bin/my-file
|
||||
concatTextFile {
|
||||
name = "my-file";
|
||||
files = [ drv1 "${drv2}/path/to/file" ];
|
||||
executable = true;
|
||||
destination = "/bin/my-file";
|
||||
}
|
||||
# Writes contents of files to /nix/store/<store path>
|
||||
concatText "my-file" [ file1 file2 ]
|
||||
|
||||
# Writes contents of files to /nix/store/<store path>
|
||||
concatScript "my-file" [ file1 file2 ]
|
||||
```
|
||||
|
||||
## `writeShellApplication` {#trivial-builder-writeShellApplication}
|
||||
|
||||
This can be used to easily produce a shell script that has some dependencies (`runtimeInputs`). It automatically sets the `PATH` of the script to contain all of the listed inputs, sets some sanity shellopts (`errexit`, `nounset`, `pipefail`), and checks the resulting script with [`shellcheck`](https://github.com/koalaman/shellcheck).
|
||||
|
||||
For example, look at the following code:
|
||||
|
||||
```nix
|
||||
writeShellApplication {
|
||||
name = "show-nixos-org";
|
||||
|
||||
runtimeInputs = [ curl w3m ];
|
||||
|
||||
text = ''
|
||||
curl -s 'https://nixos.org' | w3m -dump -T text/html
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
Unlike with normal `writeShellScriptBin`, there is no need to manually write out `${curl}/bin/curl`, setting the PATH
|
||||
was handled by `writeShellApplication`. Moreover, the script is being checked with `shellcheck` for more strict
|
||||
validation.
|
||||
|
||||
## `symlinkJoin` {#trivial-builder-symlinkJoin}
|
||||
|
||||
This can be used to put many derivations into the same directory structure. It works by creating a new derivation and adding symlinks to each of the paths listed. It expects two arguments, `name`, and `paths`. `name` is the name used in the Nix store path for the created derivation. `paths` is a list of paths that will be symlinked. These paths can be to Nix store derivations or any other subdirectory contained within.
|
||||
Here is an example:
|
||||
```nix
|
||||
# adds symlinks of hello and stack to current build and prints "links added"
|
||||
symlinkJoin { name = "myexample"; paths = [ pkgs.hello pkgs.stack ]; postBuild = "echo links added"; }
|
||||
```
|
||||
This creates a derivation with a directory structure like the following:
|
||||
```
|
||||
/nix/store/sglsr5g079a5235hy29da3mq3hv8sjmm-myexample
|
||||
|-- bin
|
||||
| |-- hello -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10/bin/hello
|
||||
| `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/bin/stack
|
||||
`-- share
|
||||
|-- bash-completion
|
||||
| `-- completions
|
||||
| `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/bash-completion/completions/stack
|
||||
|-- fish
|
||||
| `-- vendor_completions.d
|
||||
| `-- stack.fish -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/fish/vendor_completions.d/stack.fish
|
||||
...
|
||||
```
|
||||
|
||||
## `writeReferencesToFile` {#trivial-builder-writeReferencesToFile}
|
||||
|
||||
Writes the closure of transitive dependencies to a file.
|
||||
|
||||
This produces the equivalent of `nix-store -q --requisites`.
|
||||
|
||||
For example,
|
||||
|
||||
```nix
|
||||
writeReferencesToFile (writeScriptBin "hi" ''${hello}/bin/hello'')
|
||||
```
|
||||
|
||||
produces an output path `/nix/store/<hash>-runtime-deps` containing
|
||||
|
||||
```nix
|
||||
/nix/store/<hash>-hello-2.10
|
||||
/nix/store/<hash>-hi
|
||||
/nix/store/<hash>-libidn2-2.3.0
|
||||
/nix/store/<hash>-libunistring-0.9.10
|
||||
/nix/store/<hash>-glibc-2.32-40
|
||||
```
|
||||
|
||||
You can see that this includes `hi`, the original input path,
|
||||
`hello`, which is a direct reference, but also
|
||||
the other paths that are indirectly required to run `hello`.
|
||||
|
||||
## `writeDirectReferencesToFile` {#trivial-builder-writeDirectReferencesToFile}
|
||||
|
||||
Writes the set of references to the output file, that is, their immediate dependencies.
|
||||
|
||||
This produces the equivalent of `nix-store -q --references`.
|
||||
|
||||
For example,
|
||||
|
||||
```nix
|
||||
writeDirectReferencesToFile (writeScriptBin "hi" ''${hello}/bin/hello'')
|
||||
```
|
||||
|
||||
produces an output path `/nix/store/<hash>-runtime-references` containing
|
||||
|
||||
```nix
|
||||
/nix/store/<hash>-hello-2.10
|
||||
```
|
||||
|
||||
but none of `hello`'s dependencies because those are not referenced directly
|
||||
by `hi`'s output.
|
||||
193
doc/builders/fetchers.chapter.md
Normal file
193
doc/builders/fetchers.chapter.md
Normal file
@@ -0,0 +1,193 @@
|
||||
# Fetchers {#chap-pkgs-fetchers}
|
||||
|
||||
Building software with Nix often requires downloading source code and other files from the internet.
|
||||
`nixpkgs` provides *fetchers* for different protocols and services. Fetchers are functions that simplify downloading files.
|
||||
|
||||
## Caveats {#chap-pkgs-fetchers-caveats}
|
||||
|
||||
Fetchers create [fixed output derivations](https://nixos.org/manual/nix/stable/#fixed-output-drvs) from downloaded files.
|
||||
Nix can reuse the downloaded files via the hash of the resulting derivation.
|
||||
|
||||
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:
|
||||
|
||||
```nix
|
||||
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=";
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
## `fetchpatch` {#fetchpatch}
|
||||
|
||||
`fetchpatch` works very similarly to `fetchurl` with the same arguments expected. It expects patch files as a source and performs normalization on them before computing the checksum. For example, it will remove comments or other unstable parts that are sometimes added by version control systems and can change over time.
|
||||
|
||||
- `relative`: Similar to using `git-diff`'s `--relative` flag, only keep changes inside the specified directory, making paths relative to it.
|
||||
- `stripLen`: Remove the first `stripLen` components of pathnames in the patch.
|
||||
- `decode`: Pipe the downloaded data through this command before processing it as a patch.
|
||||
- `extraPrefix`: Prefix pathnames by this string.
|
||||
- `excludes`: Exclude files matching these patterns (applies after the above arguments).
|
||||
- `includes`: Include only files matching these patterns (applies after the above arguments).
|
||||
- `revert`: Revert the patch.
|
||||
|
||||
Note that because the checksum is computed after applying these effects, using or modifying these arguments will have no effect unless the `hash` argument is changed as well.
|
||||
|
||||
|
||||
Most other fetchers return a directory rather than a single file.
|
||||
|
||||
## `fetchsvn` {#fetchsvn}
|
||||
|
||||
Used with Subversion. Expects `url` to a Subversion directory, `rev`, and `hash`.
|
||||
|
||||
## `fetchgit` {#fetchgit}
|
||||
|
||||
Used with Git. Expects `url` to a Git repo, `rev`, and `hash`. `rev` in this case can be full the git commit id (SHA1 hash) or a tag name like `refs/tags/v1.0`.
|
||||
|
||||
Additionally, the following optional arguments can be given: `fetchSubmodules = true` makes `fetchgit` also fetch the submodules of a repository. If `deepClone` is set to true, the entire repository is cloned as opposing to just creating a shallow clone. `deepClone = true` also implies `leaveDotGit = true` which means that the `.git` directory of the clone won't be removed after checkout.
|
||||
|
||||
If only parts of the repository are needed, `sparseCheckout` can be used. This will prevent git from fetching unnecessary blobs from server, see [git sparse-checkout](https://git-scm.com/docs/git-sparse-checkout) for more information:
|
||||
|
||||
```nix
|
||||
{ stdenv, fetchgit }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "hello";
|
||||
src = fetchgit {
|
||||
url = "https://...";
|
||||
sparseCheckout = [
|
||||
"directory/to/be/included"
|
||||
"another/directory"
|
||||
];
|
||||
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## `fetchfossil` {#fetchfossil}
|
||||
|
||||
Used with Fossil. Expects `url` to a Fossil archive, `rev`, and `hash`.
|
||||
|
||||
## `fetchcvs` {#fetchcvs}
|
||||
|
||||
Used with CVS. Expects `cvsRoot`, `tag`, and `hash`.
|
||||
|
||||
## `fetchhg` {#fetchhg}
|
||||
|
||||
Used with Mercurial. Expects `url`, `rev`, and `hash`.
|
||||
|
||||
A number of fetcher functions wrap part of `fetchurl` and `fetchzip`. They are mainly convenience functions intended for commonly used destinations of source code in Nixpkgs. These wrapper fetchers are listed below.
|
||||
|
||||
## `fetchFromGitea` {#fetchfromgitea}
|
||||
|
||||
`fetchFromGitea` expects five arguments. `domain` is the gitea server name. `owner` is a string corresponding to the Gitea user or organization that controls this repository. `repo` corresponds to the name of the software repository. These are located at the top of every Gitea HTML page as `owner`/`repo`. `rev` corresponds to the Git commit hash or tag (e.g `v1.0`) that will be downloaded from Git. Finally, `hash` corresponds to the hash of the extracted directory. Again, other hash algorithms are also available but `hash` is currently preferred.
|
||||
|
||||
## `fetchFromGitHub` {#fetchfromgithub}
|
||||
|
||||
`fetchFromGitHub` expects four arguments. `owner` is a string corresponding to the GitHub user or organization that controls this repository. `repo` corresponds to the name of the software repository. These are located at the top of every GitHub HTML page as `owner`/`repo`. `rev` corresponds to the Git commit hash or tag (e.g `v1.0`) that will be downloaded from Git. Finally, `hash` corresponds to the hash of the extracted directory. Again, other hash algorithms are also available, but `hash` is currently preferred.
|
||||
|
||||
`fetchFromGitHub` uses `fetchzip` to download the source archive generated by GitHub for the specified revision. If `leaveDotGit`, `deepClone` or `fetchSubmodules` are set to `true`, `fetchFromGitHub` will use `fetchgit` instead. Refer to its section for documentation of these options.
|
||||
|
||||
## `fetchFromGitLab` {#fetchfromgitlab}
|
||||
|
||||
This is used with GitLab repositories. The arguments expected are very similar to `fetchFromGitHub` above.
|
||||
|
||||
## `fetchFromGitiles` {#fetchfromgitiles}
|
||||
|
||||
This is used with Gitiles repositories. The arguments expected are similar to `fetchgit`.
|
||||
|
||||
## `fetchFromBitbucket` {#fetchfrombitbucket}
|
||||
|
||||
This is used with BitBucket repositories. The arguments expected are very similar to fetchFromGitHub above.
|
||||
|
||||
## `fetchFromSavannah` {#fetchfromsavannah}
|
||||
|
||||
This is used with Savannah repositories. The arguments expected are very similar to `fetchFromGitHub` above.
|
||||
|
||||
## `fetchFromRepoOrCz` {#fetchfromrepoorcz}
|
||||
|
||||
This is used with repo.or.cz repositories. The arguments expected are very similar to `fetchFromGitHub` above.
|
||||
|
||||
## `fetchFromSourcehut` {#fetchfromsourcehut}
|
||||
|
||||
This is used with sourcehut repositories. Similar to `fetchFromGitHub` above,
|
||||
it expects `owner`, `repo`, `rev` and `hash`, but don't forget the tilde (~)
|
||||
in front of the username! Expected arguments also include `vc` ("git" (default)
|
||||
or "hg"), `domain` and `fetchSubmodules`.
|
||||
|
||||
If `fetchSubmodules` is `true`, `fetchFromSourcehut` uses `fetchgit`
|
||||
or `fetchhg` with `fetchSubmodules` or `fetchSubrepos` set to `true`,
|
||||
respectively. Otherwise, the fetcher uses `fetchzip`.
|
||||
|
||||
## `requireFile` {#requirefile}
|
||||
|
||||
`requireFile` allows requesting files that cannot be fetched automatically, but whose content is known.
|
||||
This is a useful last-resort workaround for license restrictions that prohibit redistribution, or for downloads that are only accessible after authenticating interactively in a browser.
|
||||
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:
|
||||
|
||||
```
|
||||
requireFile {
|
||||
name = "jdk-${version}_linux-x64_bin.tar.gz";
|
||||
url = "https://www.oracle.com/java/technologies/javase-jdk11-downloads.html";
|
||||
sha256 = "94bd34f85ee38d3ef59e5289ec7450b9443b924c55625661fffe66b03f2c8de2";
|
||||
}
|
||||
```
|
||||
results in this error message:
|
||||
```
|
||||
***
|
||||
Unfortunately, we cannot download file jdk-11.0.10_linux-x64_bin.tar.gz automatically.
|
||||
Please go to https://www.oracle.com/java/technologies/javase-jdk11-downloads.html to download it yourself, and add it to the Nix store
|
||||
using either
|
||||
nix-store --add-fixed sha256 jdk-11.0.10_linux-x64_bin.tar.gz
|
||||
or
|
||||
nix-prefetch-url --type sha256 file:///path/to/jdk-11.0.10_linux-x64_bin.tar.gz
|
||||
|
||||
***
|
||||
```
|
||||
15
doc/builders/images.xml
Normal file
15
doc/builders/images.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<chapter xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
xml:id="chap-images">
|
||||
<title>Images</title>
|
||||
<para>
|
||||
This chapter describes tools for creating various types of images.
|
||||
</para>
|
||||
<xi:include href="images/appimagetools.section.xml" />
|
||||
<xi:include href="images/dockertools.section.xml" />
|
||||
<xi:include href="images/ocitools.section.xml" />
|
||||
<xi:include href="images/snaptools.section.xml" />
|
||||
<xi:include href="images/portableservice.section.xml" />
|
||||
<xi:include href="images/makediskimage.section.xml" />
|
||||
<xi:include href="images/binarycache.section.xml" />
|
||||
</chapter>
|
||||
@@ -275,7 +275,7 @@ pullImage {
|
||||
`nix-prefetch-docker` command can be used to get required image parameters:
|
||||
|
||||
```ShellSession
|
||||
$ nix run nixpkgs#nix-prefetch-docker -- --image-name mysql --image-tag 5
|
||||
$ nix run nixpkgs.nix-prefetch-docker -c nix-prefetch-docker --image-name mysql --image-tag 5
|
||||
```
|
||||
|
||||
Since a given `imageName` may transparently refer to a manifest list of images which support multiple architectures and/or operating systems, you can supply the `--os` and `--arch` arguments to specify exactly which image you want. By default it will match the OS and architecture of the host the command is run on.
|
||||
@@ -1,6 +1,6 @@
|
||||
# DLib {#dlib}
|
||||
|
||||
[DLib](http://dlib.net/) is a modern, C++\-based toolkit which provides several machine learning algorithms.
|
||||
[DLib](http://dlib.net/) is a modern, C++-based toolkit which provides several machine learning algorithms.
|
||||
|
||||
## Compiling without AVX support {#compiling-without-avx-support}
|
||||
|
||||
@@ -26,6 +26,10 @@ You can install it like any other packages via `nix-env -iA myEmacs`. However, t
|
||||
{
|
||||
packageOverrides = pkgs: with pkgs; rec {
|
||||
myEmacsConfig = writeText "default.el" ''
|
||||
;; initialize package
|
||||
|
||||
(require 'package)
|
||||
(package-initialize 'noactivate)
|
||||
(eval-when-compile
|
||||
(require 'use-package))
|
||||
|
||||
@@ -99,14 +103,14 @@ You can install it like any other packages via `nix-env -iA myEmacs`. However, t
|
||||
|
||||
This provides a fairly full Emacs start file. It will load in addition to the user's personal config. You can always disable it by passing `-q` to the Emacs command.
|
||||
|
||||
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`.
|
||||
Sometimes `emacs.pkgs.withPackages` is not enough, as this package set has some priorities imposed on packages (with the lowest priority assigned to Melpa Unstable, and the highest for packages manually defined in `pkgs/top-level/emacs-packages.nix`). 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;
|
||||
...
|
||||
};
|
||||
((emacsPackagesFor emacs).overrideScope overrides).withPackages
|
||||
((emacsPackagesFor emacs).overrideScope' overrides).withPackages
|
||||
(p: with p; [
|
||||
# here both these package will use haskell-mode of our own choice
|
||||
ghc-mod
|
||||
@@ -29,12 +29,10 @@ _Note: each language passed to `langs` must be an attribute name in `pkgs.hunspe
|
||||
|
||||
## Built-in emoji picker {#sec-ibus-typing-booster-emoji-picker}
|
||||
|
||||
The `ibus-engines.typing-booster` package contains a program named `emoji-picker`. To display all emojis correctly, a special font such as `noto-fonts-color-emoji` is needed:
|
||||
The `ibus-engines.typing-booster` package contains a program named `emoji-picker`. To display all emojis correctly, a special font such as `noto-fonts-emoji` is needed:
|
||||
|
||||
On NixOS, it can be installed using the following expression:
|
||||
|
||||
```nix
|
||||
{ pkgs, ... }: {
|
||||
fonts.packages = with pkgs; [ noto-fonts-color-emoji ];
|
||||
}
|
||||
{ pkgs, ... }: { fonts.fonts = with pkgs; [ noto-fonts-emoji ]; }
|
||||
```
|
||||
29
doc/builders/packages/index.xml
Normal file
29
doc/builders/packages/index.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<chapter xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
xml:id="chap-packages">
|
||||
<title>Packages</title>
|
||||
<para>
|
||||
This chapter contains information about how to use and maintain the Nix expressions for a number of specific packages, such as the Linux kernel or X.org.
|
||||
</para>
|
||||
<xi:include href="citrix.section.xml" />
|
||||
<xi:include href="dlib.section.xml" />
|
||||
<xi:include href="eclipse.section.xml" />
|
||||
<xi:include href="elm.section.xml" />
|
||||
<xi:include href="emacs.section.xml" />
|
||||
<xi:include href="firefox.section.xml" />
|
||||
<xi:include href="fish.section.xml" />
|
||||
<xi:include href="fuse.section.xml" />
|
||||
<xi:include href="ibus.section.xml" />
|
||||
<xi:include href="kakoune.section.xml" />
|
||||
<xi:include href="linux.section.xml" />
|
||||
<xi:include href="locales.section.xml" />
|
||||
<xi:include href="etc-files.section.xml" />
|
||||
<xi:include href="nginx.section.xml" />
|
||||
<xi:include href="opengl.section.xml" />
|
||||
<xi:include href="shell-helpers.section.xml" />
|
||||
<xi:include href="steam.section.xml" />
|
||||
<xi:include href="cataclysm-dda.section.xml" />
|
||||
<xi:include href="urxvt.section.xml" />
|
||||
<xi:include href="weechat.section.xml" />
|
||||
<xi:include href="xorg.section.xml" />
|
||||
</chapter>
|
||||
@@ -11,7 +11,7 @@ Nix problems and constraints:
|
||||
- The `steam.sh` script in `$HOME` cannot be patched, as it is checked and rewritten by steam.
|
||||
- The steam binary cannot be patched, it's also checked.
|
||||
|
||||
The current approach to deploy Steam in NixOS is composing a FHS-compatible chroot environment, as documented [here](https://sandervanderburg.blogspot.com/2013/09/composing-fhs-compatible-chroot.html). This allows us to have binaries in the expected paths without disrupting the system, and to avoid patching them to work in a non FHS environment.
|
||||
The current approach to deploy Steam in NixOS is composing a FHS-compatible chroot environment, as documented [here](http://sandervanderburg.blogspot.nl/2013/09/composing-fhs-compatible-chroot.html). This allows us to have binaries in the expected paths without disrupting the system, and to avoid patching them to work in a non FHS environment.
|
||||
|
||||
## How to play {#sec-steam-play}
|
||||
|
||||
@@ -34,7 +34,7 @@ $ nix repl
|
||||
map (p: p.name) pkgs.rxvt-unicode.plugins
|
||||
```
|
||||
|
||||
Alternatively, if your shell is bash or zsh and have completion enabled, type `nixpkgs.rxvt-unicode.plugins.<tab>`.
|
||||
Alternatively, if your shell is bash or zsh and have completion enabled, simply type `nixpkgs.rxvt-unicode.plugins.<tab>`.
|
||||
|
||||
In addition to `plugins` the options `extraDeps` and `perlDeps` can be used to install extra packages. `extraDeps` can be used, for example, to provide `xsel` (a clipboard manager) to the clipboard plugin, without installing it globally:
|
||||
|
||||
13
doc/builders/special.xml
Normal file
13
doc/builders/special.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<chapter xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
xml:id="chap-special">
|
||||
<title>Special builders</title>
|
||||
<para>
|
||||
This chapter describes several special builders.
|
||||
</para>
|
||||
<xi:include href="special/fhs-environments.section.xml" />
|
||||
<xi:include href="special/makesetuphook.section.xml" />
|
||||
<xi:include href="special/mkshell.section.xml" />
|
||||
<xi:include href="special/darwin-builder.section.xml" />
|
||||
<xi:include href="special/vm-tools.section.xml" />
|
||||
</chapter>
|
||||
149
doc/builders/special/darwin-builder.section.md
Normal file
149
doc/builders/special/darwin-builder.section.md
Normal file
@@ -0,0 +1,149 @@
|
||||
# darwin.builder {#sec-darwin-builder}
|
||||
|
||||
`darwin.builder` provides a way to bootstrap a Linux builder on a macOS machine.
|
||||
|
||||
This requires macOS version 12.4 or later.
|
||||
|
||||
This also requires that port 22 on your machine is free (since Nix does not
|
||||
permit specifying a non-default SSH port for builders).
|
||||
|
||||
You will also need to be a trusted user for your Nix installation. In other
|
||||
words, your `/etc/nix/nix.conf` should have something like:
|
||||
|
||||
```
|
||||
extra-trusted-users = <your username goes here>
|
||||
```
|
||||
|
||||
To launch the builder, run the following flake:
|
||||
|
||||
```ShellSession
|
||||
$ nix run nixpkgs#darwin.builder
|
||||
```
|
||||
|
||||
That will prompt you to enter your `sudo` password:
|
||||
|
||||
```
|
||||
+ sudo --reset-timestamp /nix/store/…-install-credentials.sh ./keys
|
||||
Password:
|
||||
```
|
||||
|
||||
… so that it can install a private key used to `ssh` into the build server.
|
||||
After that the script will launch the virtual machine and automatically log you
|
||||
in as the `builder` user:
|
||||
|
||||
```
|
||||
<<< Welcome to NixOS 22.11.20220901.1bd8d11 (aarch64) - ttyAMA0 >>>
|
||||
|
||||
Run 'nixos-help' for the NixOS manual.
|
||||
|
||||
nixos login: builder (automatic login)
|
||||
|
||||
|
||||
[builder@nixos:~]$
|
||||
```
|
||||
|
||||
> Note: When you need to stop the VM, run `shutdown now` as the `builder` user.
|
||||
|
||||
To delegate builds to the remote builder, add the following options to your
|
||||
`nix.conf` file:
|
||||
|
||||
```
|
||||
# - Replace ${ARCH} with either aarch64 or x86_64 to match your host machine
|
||||
# - Replace ${MAX_JOBS} with the maximum number of builds (pick 4 if you're not sure)
|
||||
builders = ssh-ng://builder@localhost ${ARCH}-linux /etc/nix/builder_ed25519 ${MAX_JOBS} - - - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo=
|
||||
|
||||
# Not strictly necessary, but this will reduce your disk utilization
|
||||
builders-use-substitutes = true
|
||||
```
|
||||
|
||||
… and then restart your Nix daemon to apply the change:
|
||||
|
||||
```ShellSession
|
||||
$ sudo launchctl kickstart -k system/org.nixos.nix-daemon
|
||||
```
|
||||
|
||||
## Example flake usage
|
||||
|
||||
```
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-22.11-darwin";
|
||||
darwin.url = "github:lnl7/nix-darwin/master";
|
||||
darwin.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, darwin, nixpkgs, ... }@inputs:
|
||||
let
|
||||
|
||||
inherit (darwin.lib) darwinSystem;
|
||||
system = "aarch64-darwin";
|
||||
pkgs = nixpkgs.legacyPackages."${system}";
|
||||
linuxSystem = builtins.replaceStrings [ "darwin" ] [ "linux" ] system;
|
||||
|
||||
darwin-builder = nixpkgs.lib.nixosSystem {
|
||||
system = linuxSystem;
|
||||
modules = [
|
||||
"${nixpkgs}/nixos/modules/profiles/macos-builder.nix"
|
||||
{ virtualisation.host.pkgs = pkgs; }
|
||||
];
|
||||
};
|
||||
in {
|
||||
|
||||
darwinConfigurations = {
|
||||
machine1 = darwinSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
{
|
||||
nix.distributedBuilds = true;
|
||||
nix.buildMachines = [{
|
||||
hostName = "ssh://builder@localhost";
|
||||
system = linuxSystem;
|
||||
maxJobs = 4;
|
||||
supportedFeatures = [ "kvm" "benchmark" "big-parallel" ];
|
||||
}];
|
||||
|
||||
launchd.daemons.darwin-builder = {
|
||||
command = "${darwin-builder.config.system.build.macos-builder-installer}/bin/create-builder";
|
||||
serviceConfig = {
|
||||
KeepAlive = true;
|
||||
RunAtLoad = true;
|
||||
StandardOutPath = "/var/log/darwin-builder.log";
|
||||
StandardErrorPath = "/var/log/darwin-builder.log";
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## Reconfiguring the builder
|
||||
|
||||
Initially you should not change the builder configuration else you will not be
|
||||
able to use the binary cache. However, after you have the builder running locally
|
||||
you may use it to build a modified builder with additional storage or memory.
|
||||
|
||||
To do this, you just need to set the `virtualisation.darwin-builder.*` parameters as
|
||||
in the example below and rebuild.
|
||||
|
||||
```
|
||||
darwin-builder = nixpkgs.lib.nixosSystem {
|
||||
system = linuxSystem;
|
||||
modules = [
|
||||
"${nixpkgs}/nixos/modules/profiles/macos-builder.nix"
|
||||
{
|
||||
virtualisation.host.pkgs = pkgs;
|
||||
virtualisation.darwin-builder.diskSize = 5120;
|
||||
virtualisation.darwin-builder.memorySize = 1024;
|
||||
virtualisation.darwin-builder.hostPort = 33022;
|
||||
virtualisation.darwin-builder.workingDirectory = "/var/lib/darwin-builder";
|
||||
}
|
||||
];
|
||||
```
|
||||
|
||||
You may make any other changes to your VM in this attribute set. For example,
|
||||
you could enable Docker or X11 forwarding to your Darwin host.
|
||||
|
||||
@@ -11,8 +11,6 @@ Accepted arguments are:
|
||||
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`
|
||||
Packages to be installed for all architectures supported by a host (i.e. i686 and x86_64 on x86_64 installations). Only libraries are installed by default.
|
||||
- `multiArch`
|
||||
Whether to install 32bit multiPkgs into the FHSEnv in 64bit environments
|
||||
- `extraBuildCommands`
|
||||
Additional commands to be executed for finalizing the directory structure.
|
||||
- `extraBuildCommandsMulti`
|
||||
@@ -1,6 +1,6 @@
|
||||
# pkgs.makeSetupHook {#sec-pkgs.makeSetupHook}
|
||||
|
||||
`pkgs.makeSetupHook` is a build helper that produces hooks that go in to `nativeBuildInputs`
|
||||
`pkgs.makeSetupHook` is a builder that produces hooks that go in to `nativeBuildInputs`
|
||||
|
||||
## Usage {#sec-pkgs.makeSetupHook-usage}
|
||||
|
||||
@@ -12,7 +12,7 @@ pkgs.makeSetupHook {
|
||||
} ./script.sh
|
||||
```
|
||||
|
||||
### setup hook that depends on the hello package and runs hello and @shell@ is substituted with path to bash {#sec-pkgs.makeSetupHook-usage-example}
|
||||
#### setup hook that depends on the hello package and runs hello and @shell@ is substituted with path to bash {#sec-pkgs.makeSetupHook-usage-example}
|
||||
|
||||
```nix
|
||||
pkgs.makeSetupHook {
|
||||
@@ -6,7 +6,7 @@ A set of VM related utilities, that help in building some packages in more advan
|
||||
|
||||
A bash script fragment that produces a disk image at `destination`.
|
||||
|
||||
### Attributes {#vm-tools-createEmptyImage-attributes}
|
||||
### Attributes
|
||||
|
||||
* `size`. The disk size, in MiB.
|
||||
* `fullName`. Name that will be written to `${destination}/nix-support/full-name`.
|
||||
@@ -20,14 +20,14 @@ Thus, any pure Nix derivation should run unmodified.
|
||||
|
||||
If the build fails and Nix is run with the `-K/--keep-failed` option, a script `run-vm` will be left behind in the temporary build directory that allows you to boot into the VM and debug it interactively.
|
||||
|
||||
### Attributes {#vm-tools-runInLinuxVM-attributes}
|
||||
### Attributes
|
||||
|
||||
* `preVM` (optional). Shell command to be evaluated *before* the VM is started (i.e., on the host).
|
||||
* `memSize` (optional, default `512`). The memory size of the VM in MiB.
|
||||
* `diskImage` (optional). A file system image to be attached to `/dev/sda`.
|
||||
Note that currently we expect the image to contain a filesystem, not a full disk image with a partition table etc.
|
||||
|
||||
### Examples {#vm-tools-runInLinuxVM-examples}
|
||||
### Examples
|
||||
|
||||
Build the derivation hello inside a VM:
|
||||
```nix
|
||||
@@ -56,13 +56,13 @@ runInLinuxVM (hello.overrideAttrs (_: {
|
||||
|
||||
Takes a file, such as an ISO, and extracts its contents into the store.
|
||||
|
||||
### Attributes {#vm-tools-extractFs-attributes}
|
||||
### Attributes
|
||||
|
||||
* `file`. Path to the file to be extracted.
|
||||
Note that currently we expect the image to contain a filesystem, not a full disk image with a partition table etc.
|
||||
* `fs` (optional). Filesystem of the contents of the file.
|
||||
|
||||
### Examples {#vm-tools-extractFs-examples}
|
||||
### Examples
|
||||
|
||||
Extract the contents of an ISO file:
|
||||
```nix
|
||||
@@ -82,7 +82,7 @@ Like [](#vm-tools-runInLinuxVM), but instead of using `stdenv` from the Nix stor
|
||||
|
||||
Generate a script that can be used to run an interactive session in the given image.
|
||||
|
||||
### Examples {#vm-tools-makeImageTestScript-examples}
|
||||
### Examples
|
||||
|
||||
Create a script for running a Fedora 27 VM:
|
||||
```nix
|
||||
@@ -100,7 +100,7 @@ makeImageTestScript diskImages.ubuntu2004x86_64
|
||||
|
||||
A set of functions that build a predefined set of minimal Linux distributions images.
|
||||
|
||||
### Images {#vm-tools-diskImageFuns-images}
|
||||
### Images
|
||||
|
||||
* Fedora
|
||||
* `fedora26x86_64`
|
||||
@@ -126,12 +126,12 @@ A set of functions that build a predefined set of minimal Linux distributions im
|
||||
* `debian11i386`
|
||||
* `debian11x86_64`
|
||||
|
||||
### Attributes {#vm-tools-diskImageFuns-attributes}
|
||||
### Attributes
|
||||
|
||||
* `size` (optional, defaults to `4096`). The size of the image, in MiB.
|
||||
* `extraPackages` (optional). A list names of additional packages from the distribution that should be included in the image.
|
||||
|
||||
### Examples {#vm-tools-diskImageFuns-examples}
|
||||
### Examples
|
||||
|
||||
8GiB image containing Firefox in addition to the default packages:
|
||||
```nix
|
||||
@@ -1,31 +1,17 @@
|
||||
# Testers {#chap-testers}
|
||||
This chapter describes several testing builders which are available in the `testers` namespace.
|
||||
This chapter describes several testing builders which are available in the <literal>testers</literal> namespace.
|
||||
|
||||
## `hasPkgConfigModules` {#tester-hasPkgConfigModules}
|
||||
## `hasPkgConfigModule` {#tester-hasPkgConfigModule}
|
||||
|
||||
<!-- Old anchor name so links still work -->
|
||||
[]{#tester-hasPkgConfigModule}
|
||||
Checks whether a package exposes a given list of `pkg-config` modules.
|
||||
If the `moduleNames` argument is omitted, `hasPkgConfigModules` will
|
||||
use `meta.pkgConfigModules`.
|
||||
Checks whether a package exposes a certain `pkg-config` module.
|
||||
|
||||
Example:
|
||||
|
||||
```nix
|
||||
passthru.tests.pkg-config = testers.hasPkgConfigModules {
|
||||
passthru.tests.pkg-config = testers.hasPkgConfigModule {
|
||||
package = finalAttrs.finalPackage;
|
||||
moduleNames = [ "libfoo" ];
|
||||
};
|
||||
```
|
||||
|
||||
If the package in question has `meta.pkgConfigModules` set, it is even simpler:
|
||||
|
||||
```nix
|
||||
passthru.tests.pkg-config = testers.hasPkgConfigModules {
|
||||
package = finalAttrs.finalPackage;
|
||||
};
|
||||
|
||||
meta.pkgConfigModules = [ "libfoo" ];
|
||||
moduleName = "libfoo";
|
||||
}
|
||||
```
|
||||
|
||||
## `testVersion` {#tester-testVersion}
|
||||
223
doc/builders/trivial-builders.chapter.md
Normal file
223
doc/builders/trivial-builders.chapter.md
Normal file
@@ -0,0 +1,223 @@
|
||||
# Trivial builders {#chap-trivial-builders}
|
||||
|
||||
Nixpkgs provides a couple of functions that help with building derivations. The most important one, `stdenv.mkDerivation`, has already been documented above. The following functions wrap `stdenv.mkDerivation`, making it easier to use in certain cases.
|
||||
|
||||
## `runCommand` {#trivial-builder-runCommand}
|
||||
|
||||
This takes three arguments, `name`, `env`, and `buildCommand`. `name` is just the name that Nix will append to the store path in the same way that `stdenv.mkDerivation` uses its `name` attribute. `env` is an attribute set specifying environment variables that will be set for this derivation. These attributes are then passed to the wrapped `stdenv.mkDerivation`. `buildCommand` specifies the commands that will be run to create this derivation. Note that you will need to create `$out` for Nix to register the command as successful.
|
||||
|
||||
An example of using `runCommand` is provided below.
|
||||
|
||||
```nix
|
||||
(import <nixpkgs> {}).runCommand "my-example" {} ''
|
||||
echo My example command is running
|
||||
|
||||
mkdir $out
|
||||
|
||||
echo I can write data to the Nix store > $out/message
|
||||
|
||||
echo I can also run basic commands like:
|
||||
|
||||
echo ls
|
||||
ls
|
||||
|
||||
echo whoami
|
||||
whoami
|
||||
|
||||
echo date
|
||||
date
|
||||
''
|
||||
```
|
||||
|
||||
## `runCommandCC` {#trivial-builder-runCommandCC}
|
||||
|
||||
This works just like `runCommand`. The only difference is that it also provides a C compiler in `buildCommand`'s environment. To minimize your dependencies, you should only use this if you are sure you will need a C compiler as part of running your command.
|
||||
|
||||
## `runCommandLocal` {#trivial-builder-runCommandLocal}
|
||||
|
||||
Variant of `runCommand` that forces the derivation to be built locally, it is not substituted. This is intended for very cheap commands (<1s execution time). It saves on the network round-trip and can speed up a build.
|
||||
|
||||
::: {.note}
|
||||
This sets [`allowSubstitutes` to `false`](https://nixos.org/nix/manual/#adv-attr-allowSubstitutes), so only use `runCommandLocal` if you are certain the user will always have a builder for the `system` of the derivation. This should be true for most trivial use cases (e.g., just copying some files to a different location or adding symlinks) because there the `system` is usually the same as `builtins.currentSystem`.
|
||||
:::
|
||||
|
||||
## `writeTextFile`, `writeText`, `writeTextDir`, `writeScript`, `writeScriptBin` {#trivial-builder-writeText}
|
||||
|
||||
These functions write `text` to the Nix store. This is useful for creating scripts from Nix expressions. `writeTextFile` takes an attribute set and expects two arguments, `name` and `text`. `name` corresponds to the name used in the Nix store path. `text` will be the contents of the file. You can also set `executable` to true to make this file have the executable bit set.
|
||||
|
||||
Many more commands wrap `writeTextFile` including `writeText`, `writeTextDir`, `writeScript`, and `writeScriptBin`. These are convenience functions over `writeTextFile`.
|
||||
|
||||
Here are a few examples:
|
||||
```nix
|
||||
# Writes my-file to /nix/store/<store path>
|
||||
writeTextFile {
|
||||
name = "my-file";
|
||||
text = ''
|
||||
Contents of File
|
||||
'';
|
||||
}
|
||||
# See also the `writeText` helper function below.
|
||||
|
||||
# Writes executable my-file to /nix/store/<store path>/bin/my-file
|
||||
writeTextFile {
|
||||
name = "my-file";
|
||||
text = ''
|
||||
Contents of File
|
||||
'';
|
||||
executable = true;
|
||||
destination = "/bin/my-file";
|
||||
}
|
||||
# Writes contents of file to /nix/store/<store path>
|
||||
writeText "my-file"
|
||||
''
|
||||
Contents of File
|
||||
'';
|
||||
# Writes contents of file to /nix/store/<store path>/share/my-file
|
||||
writeTextDir "share/my-file"
|
||||
''
|
||||
Contents of File
|
||||
'';
|
||||
# Writes my-file to /nix/store/<store path> and makes executable
|
||||
writeScript "my-file"
|
||||
''
|
||||
Contents of File
|
||||
'';
|
||||
# Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
|
||||
writeScriptBin "my-file"
|
||||
''
|
||||
Contents of File
|
||||
'';
|
||||
# Writes my-file to /nix/store/<store path> and makes executable.
|
||||
writeShellScript "my-file"
|
||||
''
|
||||
Contents of File
|
||||
'';
|
||||
# Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
|
||||
writeShellScriptBin "my-file"
|
||||
''
|
||||
Contents of File
|
||||
'';
|
||||
|
||||
```
|
||||
|
||||
## `concatTextFile`, `concatText`, `concatScript` {#trivial-builder-concatText}
|
||||
|
||||
These functions concatenate `files` to the Nix store in a single file. This is useful for configuration files structured in lines of text. `concatTextFile` takes an attribute set and expects two arguments, `name` and `files`. `name` corresponds to the name used in the Nix store path. `files` will be the files to be concatenated. You can also set `executable` to true to make this file have the executable bit set.
|
||||
`concatText` and`concatScript` are simple wrappers over `concatTextFile`.
|
||||
|
||||
Here are a few examples:
|
||||
```nix
|
||||
|
||||
# Writes my-file to /nix/store/<store path>
|
||||
concatTextFile {
|
||||
name = "my-file";
|
||||
files = [ drv1 "${drv2}/path/to/file" ];
|
||||
}
|
||||
# See also the `concatText` helper function below.
|
||||
|
||||
# Writes executable my-file to /nix/store/<store path>/bin/my-file
|
||||
concatTextFile {
|
||||
name = "my-file";
|
||||
files = [ drv1 "${drv2}/path/to/file" ];
|
||||
executable = true;
|
||||
destination = "/bin/my-file";
|
||||
}
|
||||
# Writes contents of files to /nix/store/<store path>
|
||||
concatText "my-file" [ file1 file2 ]
|
||||
|
||||
# Writes contents of files to /nix/store/<store path>
|
||||
concatScript "my-file" [ file1 file2 ]
|
||||
```
|
||||
|
||||
## `writeShellApplication` {#trivial-builder-writeShellApplication}
|
||||
|
||||
This can be used to easily produce a shell script that has some dependencies (`runtimeInputs`). It automatically sets the `PATH` of the script to contain all of the listed inputs, sets some sanity shellopts (`errexit`, `nounset`, `pipefail`), and checks the resulting script with [`shellcheck`](https://github.com/koalaman/shellcheck).
|
||||
|
||||
For example, look at the following code:
|
||||
|
||||
```nix
|
||||
writeShellApplication {
|
||||
name = "show-nixos-org";
|
||||
|
||||
runtimeInputs = [ curl w3m ];
|
||||
|
||||
text = ''
|
||||
curl -s 'https://nixos.org' | w3m -dump -T text/html
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
Unlike with normal `writeShellScriptBin`, there is no need to manually write out `${curl}/bin/curl`, setting the PATH
|
||||
was handled by `writeShellApplication`. Moreover, the script is being checked with `shellcheck` for more strict
|
||||
validation.
|
||||
|
||||
## `symlinkJoin` {#trivial-builder-symlinkJoin}
|
||||
|
||||
This can be used to put many derivations into the same directory structure. It works by creating a new derivation and adding symlinks to each of the paths listed. It expects two arguments, `name`, and `paths`. `name` is the name used in the Nix store path for the created derivation. `paths` is a list of paths that will be symlinked. These paths can be to Nix store derivations or any other subdirectory contained within.
|
||||
Here is an example:
|
||||
```nix
|
||||
# adds symlinks of hello and stack to current build and prints "links added"
|
||||
symlinkJoin { name = "myexample"; paths = [ pkgs.hello pkgs.stack ]; postBuild = "echo links added"; }
|
||||
```
|
||||
This creates a derivation with a directory structure like the following:
|
||||
```
|
||||
/nix/store/sglsr5g079a5235hy29da3mq3hv8sjmm-myexample
|
||||
|-- bin
|
||||
| |-- hello -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10/bin/hello
|
||||
| `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/bin/stack
|
||||
`-- share
|
||||
|-- bash-completion
|
||||
| `-- completions
|
||||
| `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/bash-completion/completions/stack
|
||||
|-- fish
|
||||
| `-- vendor_completions.d
|
||||
| `-- stack.fish -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/fish/vendor_completions.d/stack.fish
|
||||
...
|
||||
```
|
||||
|
||||
## `writeReferencesToFile` {#trivial-builder-writeReferencesToFile}
|
||||
|
||||
Writes the closure of transitive dependencies to a file.
|
||||
|
||||
This produces the equivalent of `nix-store -q --requisites`.
|
||||
|
||||
For example,
|
||||
|
||||
```nix
|
||||
writeReferencesToFile (writeScriptBin "hi" ''${hello}/bin/hello'')
|
||||
```
|
||||
|
||||
produces an output path `/nix/store/<hash>-runtime-deps` containing
|
||||
|
||||
```nix
|
||||
/nix/store/<hash>-hello-2.10
|
||||
/nix/store/<hash>-hi
|
||||
/nix/store/<hash>-libidn2-2.3.0
|
||||
/nix/store/<hash>-libunistring-0.9.10
|
||||
/nix/store/<hash>-glibc-2.32-40
|
||||
```
|
||||
|
||||
You can see that this includes `hi`, the original input path,
|
||||
`hello`, which is a direct reference, but also
|
||||
the other paths that are indirectly required to run `hello`.
|
||||
|
||||
## `writeDirectReferencesToFile` {#trivial-builder-writeDirectReferencesToFile}
|
||||
|
||||
Writes the set of references to the output file, that is, their immediate dependencies.
|
||||
|
||||
This produces the equivalent of `nix-store -q --references`.
|
||||
|
||||
For example,
|
||||
|
||||
```nix
|
||||
writeDirectReferencesToFile (writeScriptBin "hi" ''${hello}/bin/hello'')
|
||||
```
|
||||
|
||||
produces an output path `/nix/store/<hash>-runtime-references` containing
|
||||
|
||||
```nix
|
||||
/nix/store/<hash>-hello-2.10
|
||||
```
|
||||
|
||||
but none of `hello`'s dependencies because those are not referenced directly
|
||||
by `hi`'s output.
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
outputPath = "share/doc/nixpkgs";
|
||||
indexPath = "manual.html";
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
# Contributing to Nixpkgs {#part-contributing}
|
||||
|
||||
```{=include=} chapters
|
||||
contributing/quick-start.chapter.md
|
||||
contributing/coding-conventions.chapter.md
|
||||
contributing/submitting-changes.chapter.md
|
||||
contributing/vulnerability-roundup.chapter.md
|
||||
contributing/reviewing-contributions.chapter.md
|
||||
contributing/contributing-to-documentation.chapter.md
|
||||
```
|
||||
@@ -1,63 +1,691 @@
|
||||
# Coding conventions {#chap-conventions}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
|
||||
## Syntax {#sec-syntax}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
- Use 2 spaces of indentation per indentation level in Nix expressions, 4 spaces in shell scripts.
|
||||
|
||||
- Do not use tab characters, i.e. configure your editor to use soft tabs. For instance, use `(setq-default indent-tabs-mode nil)` in Emacs. Everybody has different tab settings so it’s asking for trouble.
|
||||
|
||||
- Use `lowerCamelCase` for variable names, not `UpperCamelCase`. Note, this rule does not apply to package attribute names, which instead follow the rules in [](#sec-package-naming).
|
||||
|
||||
- Function calls with attribute set arguments are written as
|
||||
|
||||
```nix
|
||||
foo {
|
||||
arg = ...;
|
||||
}
|
||||
```
|
||||
|
||||
not
|
||||
|
||||
```nix
|
||||
foo
|
||||
{
|
||||
arg = ...;
|
||||
}
|
||||
```
|
||||
|
||||
Also fine is
|
||||
|
||||
```nix
|
||||
foo { arg = ...; }
|
||||
```
|
||||
|
||||
if it's a short call.
|
||||
|
||||
- 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 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";
|
||||
}
|
||||
];
|
||||
```
|
||||
|
||||
- Short lists or attribute sets can be written on one line:
|
||||
|
||||
```nix
|
||||
# A short list.
|
||||
list = [ elem1 elem2 elem3 ];
|
||||
|
||||
# A short set.
|
||||
attrs = { x = 1280; y = 1024; };
|
||||
```
|
||||
|
||||
- Breaking in the middle of a function argument can give hard-to-read code, like
|
||||
|
||||
```nix
|
||||
someFunction { x = 1280;
|
||||
y = 1024; } otherArg
|
||||
yetAnotherArg
|
||||
```
|
||||
|
||||
(especially if the argument is very large, spanning multiple lines).
|
||||
|
||||
Better:
|
||||
|
||||
```nix
|
||||
someFunction
|
||||
{ x = 1280; y = 1024; }
|
||||
otherArg
|
||||
yetAnotherArg
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```nix
|
||||
let res = { x = 1280; y = 1024; };
|
||||
in someFunction res otherArg yetAnotherArg
|
||||
```
|
||||
|
||||
- The bodies of functions, asserts, and withs are not indented to prevent a lot of superfluous indentation levels, i.e.
|
||||
|
||||
```nix
|
||||
{ arg1, arg2 }:
|
||||
assert system == "i686-linux";
|
||||
stdenv.mkDerivation { ...
|
||||
```
|
||||
|
||||
not
|
||||
|
||||
```nix
|
||||
{ arg1, arg2 }:
|
||||
assert system == "i686-linux";
|
||||
stdenv.mkDerivation { ...
|
||||
```
|
||||
|
||||
- Function formal arguments are written as:
|
||||
|
||||
```nix
|
||||
{ arg1, arg2, arg3 }:
|
||||
```
|
||||
|
||||
but if they don't fit on one line they're written as:
|
||||
|
||||
```nix
|
||||
{ arg1, arg2, arg3
|
||||
, arg4, ...
|
||||
, # Some comment...
|
||||
argN
|
||||
}:
|
||||
```
|
||||
|
||||
- Functions should list their expected arguments as precisely as possible. That is, write
|
||||
|
||||
```nix
|
||||
{ stdenv, fetchurl, perl }: ...
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```nix
|
||||
args: with args; ...
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```nix
|
||||
{ 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:
|
||||
|
||||
```nix
|
||||
{ stdenv, doCoverageAnalysis ? false, ... } @ args:
|
||||
|
||||
stdenv.mkDerivation (args // {
|
||||
... if doCoverageAnalysis then "bla" else "" ...
|
||||
})
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```nix
|
||||
args:
|
||||
|
||||
args.stdenv.mkDerivation (args // {
|
||||
... if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "" ...
|
||||
})
|
||||
```
|
||||
|
||||
- Unnecessary string conversions should be avoided. Do
|
||||
|
||||
```nix
|
||||
rev = version;
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```nix
|
||||
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;
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```nix
|
||||
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.
|
||||
If this is done a follow up pull request _should_ be created to change the code to `lib.optional(s)`.
|
||||
|
||||
- Arguments should be listed in the order they are used, with the exception of `lib`, which always goes first.
|
||||
|
||||
## Package naming {#sec-package-naming}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
The key words _must_, _must not_, _required_, _shall_, _shall not_, _should_, _should not_, _recommended_, _may_, and _optional_ in this section are to be interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119). Only _emphasized_ words are to be interpreted in this way.
|
||||
|
||||
In Nixpkgs, there are generally three different names associated with a package:
|
||||
|
||||
- The `pname` attribute of the derivation. This is what most users see, in particular when using `nix-env`.
|
||||
|
||||
- The variable name used for the instantiated package in `all-packages.nix`, and when passing it as a dependency to other functions. Typically this is called the _package attribute name_. This is what Nix expression authors see. It can also be used when installing using `nix-env -iA`.
|
||||
|
||||
- The filename for (the directory containing) the Nix expression.
|
||||
|
||||
Most of the time, these are the same. For instance, the package `e2fsprogs` has a `pname` attribute `"e2fsprogs"`, is bound to the variable name `e2fsprogs` in `all-packages.nix`, and the Nix expression is in `pkgs/os-specific/linux/e2fsprogs/default.nix`.
|
||||
|
||||
There are a few naming guidelines:
|
||||
|
||||
- The `pname` attribute _should_ be identical to the upstream package name.
|
||||
|
||||
- The `pname` and the `version` attribute _must not_ contain uppercase letters — e.g., `"mplayer" instead of `"MPlayer"`.
|
||||
|
||||
- The `version` attribute _must_ start with a digit e.g`"0.3.1rc2".
|
||||
|
||||
- If a package is not a release but a commit from a repository, then the `version` attribute _must_ be the date of that (fetched) commit. The date _must_ be in `"unstable-YYYY-MM-DD"` format.
|
||||
|
||||
- Dashes in the package `pname` _should_ be preserved in new variable names, rather than converted to underscores or camel cased — e.g., `http-parser` instead of `http_parser` or `httpParser`. The hyphenated style is preferred in all three package names.
|
||||
|
||||
- If there are multiple versions of a package, this _should_ be reflected in the variable names in `all-packages.nix`, e.g. `json-c_0_9` and `json-c_0_11`. If there is an obvious “default” version, make an attribute like `json-c = json-c_0_9;`. See also [](#sec-versioning)
|
||||
|
||||
## File naming and organisation {#sec-organisation}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
Names of files and directories should be in lowercase, with dashes between words — not in camel case. For instance, it should be `all-packages.nix`, not `allPackages.nix` or `AllPackages.nix`.
|
||||
|
||||
### Hierarchy {#sec-hierarchy}
|
||||
|
||||
Each package should be stored in its own directory somewhere in the `pkgs/` tree, i.e. in `pkgs/category/subcategory/.../pkgname`. Below are some rules for picking the right category for a package. Many packages fall under several categories; what matters is the _primary_ purpose of a package. For example, the `libxml2` package builds both a library and some tools; but it’s a library foremost, so it goes under `pkgs/development/libraries`.
|
||||
|
||||
When in doubt, consider refactoring the `pkgs/` tree, e.g. creating new categories or splitting up an existing category.
|
||||
|
||||
**If it’s used to support _software development_:**
|
||||
|
||||
- **If it’s a _library_ used by other packages:**
|
||||
|
||||
- `development/libraries` (e.g. `libxml2`)
|
||||
|
||||
- **If it’s a _compiler_:**
|
||||
|
||||
- `development/compilers` (e.g. `gcc`)
|
||||
|
||||
- **If it’s an _interpreter_:**
|
||||
|
||||
- `development/interpreters` (e.g. `guile`)
|
||||
|
||||
- **If it’s a (set of) development _tool(s)_:**
|
||||
|
||||
- **If it’s a _parser generator_ (including lexers):**
|
||||
|
||||
- `development/tools/parsing` (e.g. `bison`, `flex`)
|
||||
|
||||
- **If it’s a _build manager_:**
|
||||
|
||||
- `development/tools/build-managers` (e.g. `gnumake`)
|
||||
|
||||
- **If it’s a _language server_:**
|
||||
|
||||
- `development/tools/language-servers` (e.g. `ccls` or `rnix-lsp`)
|
||||
|
||||
- **Else:**
|
||||
|
||||
- `development/tools/misc` (e.g. `binutils`)
|
||||
|
||||
- **Else:**
|
||||
|
||||
- `development/misc`
|
||||
|
||||
**If it’s a (set of) _tool(s)_:**
|
||||
|
||||
(A tool is a relatively small program, especially one intended to be used non-interactively.)
|
||||
|
||||
- **If it’s for _networking_:**
|
||||
|
||||
- `tools/networking` (e.g. `wget`)
|
||||
|
||||
- **If it’s for _text processing_:**
|
||||
|
||||
- `tools/text` (e.g. `diffutils`)
|
||||
|
||||
- **If it’s a _system utility_, i.e., something related or essential to the operation of a system:**
|
||||
|
||||
- `tools/system` (e.g. `cron`)
|
||||
|
||||
- **If it’s an _archiver_ (which may include a compression function):**
|
||||
|
||||
- `tools/archivers` (e.g. `zip`, `tar`)
|
||||
|
||||
- **If it’s a _compression_ program:**
|
||||
|
||||
- `tools/compression` (e.g. `gzip`, `bzip2`)
|
||||
|
||||
- **If it’s a _security_-related program:**
|
||||
|
||||
- `tools/security` (e.g. `nmap`, `gnupg`)
|
||||
|
||||
- **Else:**
|
||||
|
||||
- `tools/misc`
|
||||
|
||||
**If it’s a _shell_:**
|
||||
|
||||
- `shells` (e.g. `bash`)
|
||||
|
||||
**If it’s a _server_:**
|
||||
|
||||
- **If it’s a web server:**
|
||||
|
||||
- `servers/http` (e.g. `apache-httpd`)
|
||||
|
||||
- **If it’s an implementation of the X Windowing System:**
|
||||
|
||||
- `servers/x11` (e.g. `xorg` — this includes the client libraries and programs)
|
||||
|
||||
- **Else:**
|
||||
|
||||
- `servers/misc`
|
||||
|
||||
**If it’s a _desktop environment_:**
|
||||
|
||||
- `desktops` (e.g. `kde`, `gnome`, `enlightenment`)
|
||||
|
||||
**If it’s a _window manager_:**
|
||||
|
||||
- `applications/window-managers` (e.g. `awesome`, `stumpwm`)
|
||||
|
||||
**If it’s an _application_:**
|
||||
|
||||
A (typically large) program with a distinct user interface, primarily used interactively.
|
||||
|
||||
- **If it’s a _version management system_:**
|
||||
|
||||
- `applications/version-management` (e.g. `subversion`)
|
||||
|
||||
- **If it’s a _terminal emulator_:**
|
||||
|
||||
- `applications/terminal-emulators` (e.g. `alacritty` or `rxvt` or `termite`)
|
||||
|
||||
- **If it’s a _file manager_:**
|
||||
|
||||
- `applications/file-managers` (e.g. `mc` or `ranger` or `pcmanfm`)
|
||||
|
||||
- **If it’s for _video playback / editing_:**
|
||||
|
||||
- `applications/video` (e.g. `vlc`)
|
||||
|
||||
- **If it’s for _graphics viewing / editing_:**
|
||||
|
||||
- `applications/graphics` (e.g. `gimp`)
|
||||
|
||||
- **If it’s for _networking_:**
|
||||
|
||||
- **If it’s a _mailreader_:**
|
||||
|
||||
- `applications/networking/mailreaders` (e.g. `thunderbird`)
|
||||
|
||||
- **If it’s a _newsreader_:**
|
||||
|
||||
- `applications/networking/newsreaders` (e.g. `pan`)
|
||||
|
||||
- **If it’s a _web browser_:**
|
||||
|
||||
- `applications/networking/browsers` (e.g. `firefox`)
|
||||
|
||||
- **Else:**
|
||||
|
||||
- `applications/networking/misc`
|
||||
|
||||
- **Else:**
|
||||
|
||||
- `applications/misc`
|
||||
|
||||
**If it’s _data_ (i.e., does not have a straight-forward executable semantics):**
|
||||
|
||||
- **If it’s a _font_:**
|
||||
|
||||
- `data/fonts`
|
||||
|
||||
- **If it’s an _icon theme_:**
|
||||
|
||||
- `data/icons`
|
||||
|
||||
- **If it’s related to _SGML/XML processing_:**
|
||||
|
||||
- **If it’s an _XML DTD_:**
|
||||
|
||||
- `data/sgml+xml/schemas/xml-dtd` (e.g. `docbook`)
|
||||
|
||||
- **If it’s an _XSLT stylesheet_:**
|
||||
|
||||
(Okay, these are executable...)
|
||||
|
||||
- `data/sgml+xml/stylesheets/xslt` (e.g. `docbook-xsl`)
|
||||
|
||||
- **If it’s a _theme_ for a _desktop environment_, a _window manager_ or a _display manager_:**
|
||||
|
||||
- `data/themes`
|
||||
|
||||
**If it’s a _game_:**
|
||||
|
||||
- `games`
|
||||
|
||||
**Else:**
|
||||
|
||||
- `misc`
|
||||
|
||||
### Versioning {#sec-versioning}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
Because every version of a package in Nixpkgs creates a potential maintenance burden, old versions of a package should not be kept unless there is a good reason to do so. For instance, Nixpkgs contains several versions of GCC because other packages don’t build with the latest version of GCC. Other examples are having both the latest stable and latest pre-release version of a package, or to keep several major releases of an application that differ significantly in functionality.
|
||||
|
||||
If there is only one version of a package, its Nix expression should be named `e2fsprogs/default.nix`. If there are multiple versions, this should be reflected in the filename, e.g. `e2fsprogs/1.41.8.nix` and `e2fsprogs/1.41.9.nix`. The version in the filename should leave out unnecessary detail. For instance, if we keep the latest Firefox 2.0.x and 3.5.x versions in Nixpkgs, they should be named `firefox/2.0.nix` and `firefox/3.5.nix`, respectively (which, at a given point, might contain versions `2.0.0.20` and `3.5.4`). If a version requires many auxiliary files, you can use a subdirectory for each version, e.g. `firefox/2.0/default.nix` and `firefox/3.5/default.nix`.
|
||||
|
||||
All versions of a package _must_ be included in `all-packages.nix` to make sure that they evaluate correctly.
|
||||
|
||||
## Fetching Sources {#sec-sources}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
There are multiple ways to fetch a package source in nixpkgs. The general guideline is that you should package reproducible sources with a high degree of availability. Right now there is only one fetcher which has mirroring support and that is `fetchurl`. Note that you should also prefer protocols which have a corresponding proxy environment variable.
|
||||
|
||||
You can find many source fetch helpers in `pkgs/build-support/fetch*`.
|
||||
|
||||
In the file `pkgs/top-level/all-packages.nix` you can find fetch helpers, these have names on the form `fetchFrom*`. The intention of these are to provide snapshot fetches but using the same api as some of the version controlled fetchers from `pkgs/build-support/`. As an example going from bad to good:
|
||||
|
||||
- Bad: Uses `git://` which won't be proxied.
|
||||
|
||||
```nix
|
||||
src = fetchgit {
|
||||
url = "git@github.com:NixOS/nix.git"
|
||||
url = "git://github.com/NixOS/nix.git";
|
||||
rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae";
|
||||
hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ=";
|
||||
}
|
||||
```
|
||||
|
||||
- Better: This is ok, but an archive fetch will still be faster.
|
||||
|
||||
```nix
|
||||
src = fetchgit {
|
||||
url = "https://github.com/NixOS/nix.git";
|
||||
rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae";
|
||||
hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ=";
|
||||
}
|
||||
```
|
||||
|
||||
- Best: Fetches a snapshot archive and you get the rev you want.
|
||||
|
||||
```nix
|
||||
src = fetchFromGitHub {
|
||||
owner = "NixOS";
|
||||
repo = "nix";
|
||||
rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae";
|
||||
hash = "ha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ=";
|
||||
}
|
||||
```
|
||||
|
||||
When fetching from GitHub, commits must always be referenced by their full commit hash. This is because GitHub shares commit hashes among all forks and returns `404 Not Found` when a short commit hash is ambiguous. It already happens for some short, 6-character commit hashes in `nixpkgs`.
|
||||
It is a practical vector for a denial-of-service attack by pushing large amounts of auto generated commits into forks and was already [demonstrated against GitHub Actions Beta](https://blog.teddykatz.com/2019/11/12/github-actions-dos.html).
|
||||
|
||||
Find the value to put as `hash` by running `nix-shell -p nix-prefetch-github --run "nix-prefetch-github --rev 1f795f9f44607cc5bec70d1300150bfefcef2aae NixOS nix"`.
|
||||
|
||||
## Obtaining source hash {#sec-source-hashes}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
Preferred source hash type is sha256. There are several ways to get it.
|
||||
|
||||
1. Prefetch URL (with `nix-prefetch-XXX URL`, where `XXX` is one of `url`, `git`, `hg`, `cvs`, `bzr`, `svn`). Hash is printed to stdout.
|
||||
|
||||
2. Prefetch by package source (with `nix-prefetch-url '<nixpkgs>' -A PACKAGE.src`, where `PACKAGE` is package attribute name). Hash is printed to stdout.
|
||||
|
||||
This works well when you've upgraded existing package version and want to find out new hash, but is useless if package can't be accessed by attribute or package has multiple sources (`.srcs`, architecture-dependent sources, etc).
|
||||
|
||||
3. Upstream provided hash: use it when upstream provides `sha256` or `sha512` (when upstream provides `md5`, don't use it, compute `sha256` instead).
|
||||
|
||||
A little nuance is that `nix-prefetch-*` tools produce hash encoded with `base32`, but upstream usually provides hexadecimal (`base16`) encoding. Fetchers understand both formats. Nixpkgs does not standardize on any one format.
|
||||
|
||||
You can convert between formats with nix-hash, for example:
|
||||
|
||||
```ShellSession
|
||||
$ nix-hash --type sha256 --to-base32 HASH
|
||||
```
|
||||
|
||||
4. Extracting hash from local source tarball can be done with `sha256sum`. Use `nix-prefetch-url file:///path/to/tarball` if you want base32 hash.
|
||||
|
||||
5. Fake hash: set the hash to one of
|
||||
|
||||
- `""`
|
||||
- `lib.fakeHash`
|
||||
- `lib.fakeSha256`
|
||||
- `lib.fakeSha512`
|
||||
|
||||
in the package expression, attempt build and extract correct hash from error messages.
|
||||
|
||||
::: {.warning}
|
||||
You must use one of these four fake hashes and not some arbitrarily-chosen hash.
|
||||
|
||||
See [](#sec-source-hashes-security).
|
||||
:::
|
||||
|
||||
This is last resort method when reconstructing source URL is non-trivial and `nix-prefetch-url -A` isn’t applicable (for example, [one of `kodi` dependencies](https://github.com/NixOS/nixpkgs/blob/d2ab091dd308b99e4912b805a5eb088dd536adb9/pkgs/applications/video/kodi/default.nix#L73)). The easiest way then would be replace hash with a fake one and rebuild. Nix build will fail and error message will contain desired hash.
|
||||
|
||||
|
||||
### Obtaining hashes securely {#sec-source-hashes-security}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
Let's say Man-in-the-Middle (MITM) sits close to your network. Then instead of fetching source you can fetch malware, and instead of source hash you get hash of malware. Here are security considerations for this scenario:
|
||||
|
||||
- `http://` URLs are not secure to prefetch hash from;
|
||||
|
||||
- hashes from upstream (in method 3) should be obtained via secure protocol;
|
||||
|
||||
- `https://` URLs are secure in methods 1, 2, 3;
|
||||
|
||||
- `https://` URLs are secure in method 5 *only if* you use one of the listed fake hashes. If you use any other hash, `fetchurl` will pass `--insecure` to `curl` and may then degrade to HTTP in case of TLS certificate expiration.
|
||||
|
||||
## Patches {#sec-patches}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
Patches available online should be retrieved using `fetchpatch`.
|
||||
|
||||
```nix
|
||||
patches = [
|
||||
(fetchpatch {
|
||||
name = "fix-check-for-using-shared-freetype-lib.patch";
|
||||
url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=8f5d285";
|
||||
hash = "sha256-uRcxaCjd+WAuGrXOmGfFeu79cUILwkRdBu48mwcBE7g=";
|
||||
})
|
||||
];
|
||||
```
|
||||
|
||||
Otherwise, you can add a `.patch` file to the `nixpkgs` repository. In the interest of keeping our maintenance burden to a minimum, only patches that are unique to `nixpkgs` should be added in this way.
|
||||
|
||||
If a patch is available online but does not cleanly apply, it can be modified in some fixed ways by using additional optional arguments for `fetchpatch`. Check [](#fetchpatch) for details.
|
||||
|
||||
```nix
|
||||
patches = [ ./0001-changes.patch ];
|
||||
```
|
||||
|
||||
If you do need to do create this sort of patch file, one way to do so is with git:
|
||||
|
||||
1. Move to the root directory of the source code you're patching.
|
||||
|
||||
```ShellSession
|
||||
$ cd the/program/source
|
||||
```
|
||||
|
||||
2. If a git repository is not already present, create one and stage all of the source files.
|
||||
|
||||
```ShellSession
|
||||
$ git init
|
||||
$ git add .
|
||||
```
|
||||
|
||||
3. Edit some files to make whatever changes need to be included in the patch.
|
||||
|
||||
4. Use git to create a diff, and pipe the output to a patch file:
|
||||
|
||||
```ShellSession
|
||||
$ git diff -a > nixpkgs/pkgs/the/package/0001-changes.patch
|
||||
```
|
||||
|
||||
## Package tests {#sec-package-tests}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
Tests are important to ensure quality and make reviews and automatic updates easy.
|
||||
|
||||
The following types of tests exists:
|
||||
|
||||
* [NixOS **module tests**](https://nixos.org/manual/nixos/stable/#sec-nixos-tests), which spawn one or more NixOS VMs. They exercise both NixOS modules and the packaged programs used within them. For example, a NixOS module test can start a web server VM running the `nginx` module, and a client VM running `curl` or a graphical `firefox`, and test that they can talk to each other and display the correct content.
|
||||
* Nix **package tests** are a lightweight alternative to NixOS module tests. They should be used to create simple integration tests for packages, but cannot test NixOS services, and some programs with graphical user interfaces may also be difficult to test with them.
|
||||
* The **`checkPhase` of a package**, which should execute the unit tests that are included in the source code of a package.
|
||||
|
||||
Here in the nixpkgs manual we describe mostly _package tests_; for _module tests_ head over to the corresponding [section in the NixOS manual](https://nixos.org/manual/nixos/stable/#sec-nixos-tests).
|
||||
|
||||
### Writing inline package tests {#ssec-inline-package-tests-writing}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
For very simple tests, they can be written inline:
|
||||
|
||||
```nix
|
||||
{ …, yq-go }:
|
||||
|
||||
buildGoModule rec {
|
||||
…
|
||||
|
||||
passthru.tests = {
|
||||
simple = runCommand "${pname}-test" {} ''
|
||||
echo "test: 1" | ${yq-go}/bin/yq eval -j > $out
|
||||
[ "$(cat $out | tr -d $'\n ')" = '{"test":1}' ]
|
||||
'';
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### Writing larger package tests {#ssec-package-tests-writing}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
This is an example using the `phoronix-test-suite` package with the current best practices.
|
||||
|
||||
Add the tests in `passthru.tests` to the package definition like this:
|
||||
|
||||
```nix
|
||||
{ stdenv, lib, fetchurl, callPackage }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
…
|
||||
|
||||
passthru.tests = {
|
||||
simple-execution = callPackage ./tests.nix { };
|
||||
};
|
||||
|
||||
meta = { … };
|
||||
}
|
||||
```
|
||||
|
||||
Create `tests.nix` in the package directory:
|
||||
|
||||
```nix
|
||||
{ runCommand, phoronix-test-suite }:
|
||||
|
||||
let
|
||||
inherit (phoronix-test-suite) pname version;
|
||||
in
|
||||
|
||||
runCommand "${pname}-tests" { meta.timeout = 60; }
|
||||
''
|
||||
# automatic initial setup to prevent interactive questions
|
||||
${phoronix-test-suite}/bin/phoronix-test-suite enterprise-setup >/dev/null
|
||||
# get version of installed program and compare with package version
|
||||
if [[ `${phoronix-test-suite}/bin/phoronix-test-suite version` != *"${version}"* ]]; then
|
||||
echo "Error: program version does not match package version"
|
||||
exit 1
|
||||
fi
|
||||
# run dummy command
|
||||
${phoronix-test-suite}/bin/phoronix-test-suite dummy_module.dummy-command >/dev/null
|
||||
# needed for Nix to register the command as successful
|
||||
touch $out
|
||||
''
|
||||
```
|
||||
|
||||
### Running package tests {#ssec-package-tests-running}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
You can run these tests with:
|
||||
|
||||
```ShellSession
|
||||
$ cd path/to/nixpkgs
|
||||
$ nix-build -A phoronix-test-suite.tests
|
||||
```
|
||||
|
||||
### Examples of package tests {#ssec-package-tests-examples}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
Here are examples of package tests:
|
||||
|
||||
- [Jasmin compile test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/jasmin/test-assemble-hello-world/default.nix)
|
||||
- [Lobster compile test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/lobster/test-can-run-hello-world.nix)
|
||||
- [Spacy annotation test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/spacy/annotation-test/default.nix)
|
||||
- [Libtorch test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/science/math/libtorch/test/default.nix)
|
||||
- [Multiple tests for nanopb](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/nanopb/default.nix)
|
||||
|
||||
### Linking NixOS module tests to a package {#ssec-nixos-tests-linking}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
Like [package tests](#ssec-package-tests-writing) as shown above, [NixOS module tests](https://nixos.org/manual/nixos/stable/#sec-nixos-tests) can also be linked to a package, so that the tests can be easily run when changing the related package.
|
||||
|
||||
For example, assuming we're packaging `nginx`, we can link its module test via `passthru.tests`:
|
||||
|
||||
```nix
|
||||
{ stdenv, lib, nixosTests }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
...
|
||||
|
||||
passthru.tests = {
|
||||
nginx = nixosTests.nginx;
|
||||
};
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Import From Derivation {#ssec-import-from-derivation}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
Import From Derivation (IFD) is disallowed in Nixpkgs for performance reasons:
|
||||
[Hydra] evaluates the entire package set, and sequential builds during evaluation would increase evaluation times to become impractical.
|
||||
|
||||
[Hydra]: https://github.com/NixOS/hydra
|
||||
|
||||
Import From Derivation can be worked around in some cases by committing generated intermediate files to version control and reading those instead.
|
||||
|
||||
<!-- TODO: remove the following and link to Nix manual once https://github.com/NixOS/nix/pull/7332 is merged -->
|
||||
|
||||
See also [NixOS Wiki: Import From Derivation].
|
||||
|
||||
[NixOS Wiki: Import From Derivation]: https://nixos.wiki/wiki/Import_From_Derivation
|
||||
|
||||
@@ -1,11 +1,118 @@
|
||||
# Contributing to Nixpkgs documentation {#chap-contributing}
|
||||
# Contributing to this documentation {#chap-contributing}
|
||||
|
||||
This section has been moved to [doc/README.md](https://github.com/NixOS/nixpkgs/blob/master/doc/README.md).
|
||||
The sources of the Nixpkgs manual are in the [doc](https://github.com/NixOS/nixpkgs/tree/master/doc) subdirectory of the Nixpkgs repository. The manual is still partially written in DocBook but it is progressively being converted to [Markdown](#sec-contributing-markup).
|
||||
|
||||
## devmode {#sec-contributing-devmode}
|
||||
You can quickly check your edits with `make`:
|
||||
|
||||
This section has been moved to [doc/README.md](https://github.com/NixOS/nixpkgs/blob/master/doc/README.md).
|
||||
```ShellSession
|
||||
$ cd /path/to/nixpkgs/doc
|
||||
$ nix-shell
|
||||
[nix-shell]$ make
|
||||
```
|
||||
|
||||
If you experience problems, run `make debug` to help understand the docbook errors.
|
||||
|
||||
After making modifications to the manual, it's important to build it before committing. You can do that as follows:
|
||||
|
||||
```ShellSession
|
||||
$ cd /path/to/nixpkgs/doc
|
||||
$ nix-shell
|
||||
[nix-shell]$ make clean
|
||||
[nix-shell]$ nix-build .
|
||||
```
|
||||
|
||||
If the build succeeds, the manual will be in `./result/share/doc/nixpkgs/manual.html`.
|
||||
|
||||
## Syntax {#sec-contributing-markup}
|
||||
|
||||
This section has been moved to [doc/README.md](https://github.com/NixOS/nixpkgs/blob/master/doc/README.md).
|
||||
As per [RFC 0072](https://github.com/NixOS/rfcs/pull/72), all new documentation content should be written in [CommonMark](https://commonmark.org/) Markdown dialect.
|
||||
|
||||
Additional syntax extensions are available, all of which can be used in NixOS option documentation. The following extensions are currently used:
|
||||
|
||||
- []{#ssec-contributing-markup-anchors}
|
||||
Explicitly defined **anchors** on headings, to allow linking to sections. These should be always used, to ensure the anchors can be linked even when the heading text changes, and to prevent conflicts between [automatically assigned identifiers](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/auto_identifiers.md).
|
||||
|
||||
It uses the widely compatible [header attributes](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/attributes.md) syntax:
|
||||
|
||||
```markdown
|
||||
## Syntax {#sec-contributing-markup}
|
||||
```
|
||||
|
||||
::: {.note}
|
||||
NixOS option documentation does not support headings in general.
|
||||
:::
|
||||
|
||||
- []{#ssec-contributing-markup-anchors-inline}
|
||||
**Inline anchors**, which allow linking arbitrary place in the text (e.g. individual list items, sentences…).
|
||||
|
||||
They are defined using a hybrid of the link syntax with the attributes syntax known from headings, called [bracketed spans](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/bracketed_spans.md):
|
||||
|
||||
```markdown
|
||||
- []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`.
|
||||
```
|
||||
|
||||
- []{#ssec-contributing-markup-automatic-links}
|
||||
If you **omit a link text** for a link pointing to a section, the text will be substituted automatically. For example, `[](#chap-contributing)` will result in [](#chap-contributing).
|
||||
|
||||
This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing).
|
||||
|
||||
- []{#ssec-contributing-markup-inline-roles}
|
||||
If you want to link to a man page, you can use `` {manpage}`nix.conf(5)` ``, which will turn into {manpage}`nix.conf(5)`. The references will turn into links when a mapping exists in {file}`doc/manpage-urls.json`.
|
||||
|
||||
A few markups for other kinds of literals are also available:
|
||||
|
||||
- `` {command}`rm -rfi` `` turns into {command}`rm -rfi`
|
||||
- `` {env}`XDG_DATA_DIRS` `` turns into {env}`XDG_DATA_DIRS`
|
||||
- `` {file}`/etc/passwd` `` turns into {file}`/etc/passwd`
|
||||
- `` {option}`networking.useDHCP` `` turns into {option}`networking.useDHCP`
|
||||
- `` {var}`/etc/passwd` `` turns into {var}`/etc/passwd`
|
||||
|
||||
These literal kinds are used mostly in NixOS option documentation.
|
||||
|
||||
This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/syntax/syntax.html#roles-an-in-line-extension-point). Though, the feature originates from [reStructuredText](https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-manpage) with slightly different syntax.
|
||||
|
||||
- []{#ssec-contributing-markup-admonitions}
|
||||
**Admonitions**, set off from the text to bring attention to something.
|
||||
|
||||
It uses pandoc’s [fenced `div`s syntax](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/fenced_divs.md):
|
||||
|
||||
```markdown
|
||||
::: {.warning}
|
||||
This is a warning
|
||||
:::
|
||||
```
|
||||
|
||||
which renders as
|
||||
|
||||
> ::: {.warning}
|
||||
> 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)
|
||||
|
||||
- []{#ssec-contributing-markup-definition-lists}
|
||||
[**Definition lists**](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/definition_lists.md), for defining a group of terms:
|
||||
|
||||
```markdown
|
||||
pear
|
||||
: green or yellow bulbous fruit
|
||||
|
||||
watermelon
|
||||
: green fruit with red flesh
|
||||
```
|
||||
|
||||
which renders as
|
||||
|
||||
> pear
|
||||
> : green or yellow bulbous fruit
|
||||
>
|
||||
> watermelon
|
||||
> : green fruit with red flesh
|
||||
|
||||
For contributing to the legacy parts, please see [DocBook: The Definitive Guide](https://tdg.docbook.org/) or the [DocBook rocks! primer](https://web.archive.org/web/20200816233747/https://docbook.rocks/).
|
||||
|
||||
@@ -1,3 +1,77 @@
|
||||
# Quick Start to Adding a Package {#chap-quick-start}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
To add a package to Nixpkgs:
|
||||
|
||||
1. Checkout the Nixpkgs source tree:
|
||||
|
||||
```ShellSession
|
||||
$ git clone https://github.com/NixOS/nixpkgs
|
||||
$ cd nixpkgs
|
||||
```
|
||||
|
||||
2. Find a good place in the Nixpkgs tree to add the Nix expression for your package. For instance, a library package typically goes into `pkgs/development/libraries/pkgname`, while a web browser goes into `pkgs/applications/networking/browsers/pkgname`. See [](#sec-organisation) for some hints on the tree organisation. Create a directory for your package, e.g.
|
||||
|
||||
```ShellSession
|
||||
$ mkdir pkgs/development/libraries/libfoo
|
||||
```
|
||||
|
||||
3. In the package directory, create a Nix expression — a piece of code that describes how to build the package. In this case, it should be a _function_ that is called with the package dependencies as arguments, and returns a build of the package in the Nix store. The expression should usually be called `default.nix`.
|
||||
|
||||
```ShellSession
|
||||
$ emacs pkgs/development/libraries/libfoo/default.nix
|
||||
$ git add pkgs/development/libraries/libfoo/default.nix
|
||||
```
|
||||
|
||||
You can have a look at the existing Nix expressions under `pkgs/` to see how it’s done. Here are some good ones:
|
||||
|
||||
- GNU Hello: [`pkgs/applications/misc/hello/default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/hello/default.nix). Trivial package, which specifies some `meta` attributes which is good practice.
|
||||
|
||||
- GNU cpio: [`pkgs/tools/archivers/cpio/default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/archivers/cpio/default.nix). Also a simple package. The generic builder in `stdenv` does everything for you. It has no dependencies beyond `stdenv`.
|
||||
|
||||
- GNU Multiple Precision arithmetic library (GMP): [`pkgs/development/libraries/gmp/5.1.x.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/gmp/5.1.x.nix). Also done by the generic builder, but has a dependency on `m4`.
|
||||
|
||||
- Pan, a GTK-based newsreader: [`pkgs/applications/networking/newsreaders/pan/default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/newsreaders/pan/default.nix). Has an optional dependency on `gtkspell`, which is only built if `spellCheck` is `true`.
|
||||
|
||||
- Apache HTTPD: [`pkgs/servers/http/apache-httpd/2.4.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/http/apache-httpd/2.4.nix). A bunch of optional features, variable substitutions in the configure flags, a post-install hook, and miscellaneous hackery.
|
||||
|
||||
- buildMozillaMach: [`pkgs/applications/networking/browser/firefox/common.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/browsers/firefox/common.nix). A reusable build function for Firefox, Thunderbird and Librewolf.
|
||||
|
||||
- JDiskReport, a Java utility: [`pkgs/tools/misc/jdiskreport/default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/misc/jdiskreport/default.nix). Nixpkgs doesn’t have a decent `stdenv` for Java yet so this is pretty ad-hoc.
|
||||
|
||||
- XML::Simple, a Perl module: [`pkgs/top-level/perl-packages.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/perl-packages.nix) (search for the `XMLSimple` attribute). Most Perl modules are so simple to build that they are defined directly in `perl-packages.nix`; no need to make a separate file for them.
|
||||
|
||||
- Adobe Reader: [`pkgs/applications/misc/adobe-reader/default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/adobe-reader/default.nix). Shows how binary-only packages can be supported. In particular the [builder](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/adobe-reader/builder.sh) uses `patchelf` to set the RUNPATH and ELF interpreter of the executables so that the right libraries are found at runtime.
|
||||
|
||||
Some notes:
|
||||
|
||||
- All [`meta`](#chap-meta) attributes are optional, but it’s still a good idea to provide at least the `description`, `homepage` and [`license`](#sec-meta-license).
|
||||
|
||||
- You can use `nix-prefetch-url url` to get the SHA-256 hash of source distributions. There are similar commands as `nix-prefetch-git` and `nix-prefetch-hg` available in `nix-prefetch-scripts` package.
|
||||
|
||||
- A list of schemes for `mirror://` URLs can be found in [`pkgs/build-support/fetchurl/mirrors.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/fetchurl/mirrors.nix).
|
||||
|
||||
The exact syntax and semantics of the Nix expression language, including the built-in function, are described in the Nix manual in the [chapter on writing Nix expressions](https://hydra.nixos.org/job/nix/trunk/tarball/latest/download-by-type/doc/manual/#chap-writing-nix-expressions).
|
||||
|
||||
4. Add a call to the function defined in the previous step to [`pkgs/top-level/all-packages.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/all-packages.nix) with some descriptive name for the variable, e.g. `libfoo`.
|
||||
|
||||
```ShellSession
|
||||
$ emacs pkgs/top-level/all-packages.nix
|
||||
```
|
||||
|
||||
The attributes in that file are sorted by category (like “Development / Libraries”) that more-or-less correspond to the directory structure of Nixpkgs, and then by attribute name.
|
||||
|
||||
5. To test whether the package builds, run the following command from the root of the nixpkgs source tree:
|
||||
|
||||
```ShellSession
|
||||
$ nix-build -A libfoo
|
||||
```
|
||||
|
||||
where `libfoo` should be the variable name defined in the previous step. You may want to add the flag `-K` to keep the temporary build directory in case something fails. If the build succeeds, a symlink `./result` to the package in the Nix store is created.
|
||||
|
||||
6. If you want to install the package into your profile (optional), do
|
||||
|
||||
```ShellSession
|
||||
$ nix-env -f . -iA libfoo
|
||||
```
|
||||
|
||||
7. Optionally commit the new package and open a pull request [to nixpkgs](https://github.com/NixOS/nixpkgs/pulls), or use [the Patches category](https://discourse.nixos.org/t/about-the-patches-category/477) on Discourse for sending a patch without a GitHub account.
|
||||
|
||||
@@ -1,35 +1,319 @@
|
||||
# Reviewing contributions {#chap-reviewing-contributions}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
::: {.warning}
|
||||
The following section is a draft, and the policy for reviewing is still being discussed in issues such as [#11166](https://github.com/NixOS/nixpkgs/issues/11166) and [#20836](https://github.com/NixOS/nixpkgs/issues/20836).
|
||||
:::
|
||||
|
||||
The Nixpkgs project receives a fairly high number of contributions via GitHub pull requests. Reviewing and approving these is an important task and a way to contribute to the project.
|
||||
|
||||
The high change rate of Nixpkgs makes any pull request that remains open for too long subject to conflicts that will require extra work from the submitter or the merger. Reviewing pull requests in a timely manner and being responsive to the comments is the key to avoid this issue. GitHub provides sort filters that can be used to see the [most recently](https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc) and the [least recently](https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-asc) updated pull requests. We highly encourage looking at [this list of ready to merge, unreviewed pull requests](https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+review%3Anone+status%3Asuccess+-label%3A%222.status%3A+work-in-progress%22+no%3Aproject+no%3Aassignee+no%3Amilestone).
|
||||
|
||||
When reviewing a pull request, please always be nice and polite. Controversial changes can lead to controversial opinions, but it is important to respect every community member and their work.
|
||||
|
||||
GitHub provides reactions as a simple and quick way to provide feedback to pull requests or any comments. The thumb-down reaction should be used with care and if possible accompanied with some explanation so the submitter has directions to improve their contribution.
|
||||
|
||||
pull request reviews should include a list of what has been reviewed in a comment, so other reviewers and mergers can know the state of the review.
|
||||
|
||||
All the review template samples provided in this section are generic and meant as examples. Their usage is optional and the reviewer is free to adapt them to their liking.
|
||||
|
||||
## Package updates {#reviewing-contributions-package-updates}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
A package update is the most trivial and common type of pull request. These pull requests mainly consist of updating the version part of the package name and the source hash.
|
||||
|
||||
It can happen that non-trivial updates include patches or more complex changes.
|
||||
|
||||
Reviewing process:
|
||||
|
||||
- Ensure that the package versioning fits the guidelines.
|
||||
- Ensure that the commit text fits the guidelines.
|
||||
- Ensure that the package maintainers are notified.
|
||||
- [CODEOWNERS](https://help.github.com/articles/about-codeowners) will make GitHub notify users based on the submitted changes, but it can happen that it misses some of the package maintainers.
|
||||
- Ensure that the meta field information is correct.
|
||||
- License can change with version updates, so it should be checked to match the upstream license.
|
||||
- If the package has no maintainer, a maintainer must be set. This can be the update submitter or a community member that accepts to take maintainership of the package.
|
||||
- Ensure that the code contains no typos.
|
||||
- Building the package locally.
|
||||
- pull requests are often targeted to the master or staging branch, and building the pull request locally when it is submitted can trigger many source builds.
|
||||
- It is possible to rebase the changes on nixos-unstable or nixpkgs-unstable for easier review by running the following commands from a nixpkgs clone.
|
||||
|
||||
```ShellSession
|
||||
$ git fetch origin nixos-unstable
|
||||
$ git fetch origin pull/PRNUMBER/head
|
||||
$ git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD
|
||||
```
|
||||
|
||||
- The first command fetches the nixos-unstable branch.
|
||||
- The second command fetches the pull request changes, `PRNUMBER` is the number at the end of the pull request title and `BASEBRANCH` the base branch of the pull request.
|
||||
- The third command rebases the pull request changes to the nixos-unstable branch.
|
||||
- The [nixpkgs-review](https://github.com/Mic92/nixpkgs-review) tool can be used to review a pull request content in a single command. `PRNUMBER` should be replaced by the number at the end of the pull request title. You can also provide the full github pull request url.
|
||||
|
||||
```ShellSession
|
||||
$ nix-shell -p nixpkgs-review --run "nixpkgs-review pr PRNUMBER"
|
||||
```
|
||||
- Running every binary.
|
||||
|
||||
Sample template for a package update review is provided below.
|
||||
|
||||
```markdown
|
||||
##### Reviewed points
|
||||
|
||||
- [ ] package name fits guidelines
|
||||
- [ ] package version fits guidelines
|
||||
- [ ] package build on ARCHITECTURE
|
||||
- [ ] executables tested on ARCHITECTURE
|
||||
- [ ] all depending packages build
|
||||
|
||||
##### Possible improvements
|
||||
|
||||
##### Comments
|
||||
```
|
||||
|
||||
## New packages {#reviewing-contributions-new-packages}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
New packages are a common type of pull requests. These pull requests consists in adding a new nix-expression for a package.
|
||||
|
||||
Review process:
|
||||
|
||||
- Ensure that the package versioning fits the guidelines.
|
||||
- Ensure that the commit name fits the guidelines.
|
||||
- Ensure that the meta fields contain correct information.
|
||||
- License must match the upstream license.
|
||||
- Platforms should be set (or the package will not get binary substitutes).
|
||||
- Maintainers must be set. This can be the package submitter or a community member that accepts taking up maintainership of the package.
|
||||
- Report detected typos.
|
||||
- Ensure the package source:
|
||||
- Uses mirror URLs when available.
|
||||
- Uses the most appropriate functions (e.g. packages from GitHub should use `fetchFromGitHub`).
|
||||
- Building the package locally.
|
||||
- Running every binary.
|
||||
|
||||
Sample template for a new package review is provided below.
|
||||
|
||||
```markdown
|
||||
##### Reviewed points
|
||||
|
||||
- [ ] package path fits guidelines
|
||||
- [ ] package name fits guidelines
|
||||
- [ ] package version fits guidelines
|
||||
- [ ] package build on ARCHITECTURE
|
||||
- [ ] executables tested on ARCHITECTURE
|
||||
- [ ] `meta.description` is set and fits guidelines
|
||||
- [ ] `meta.license` fits upstream license
|
||||
- [ ] `meta.platforms` is set
|
||||
- [ ] `meta.maintainers` is set
|
||||
- [ ] build time only dependencies are declared in `nativeBuildInputs`
|
||||
- [ ] source is fetched using the appropriate function
|
||||
- [ ] the list of `phases` is not overridden
|
||||
- [ ] when a phase (like `installPhase`) is overridden it starts with `runHook preInstall` and ends with `runHook postInstall`.
|
||||
- [ ] patches that are remotely available are fetched with `fetchpatch`
|
||||
|
||||
##### Possible improvements
|
||||
|
||||
##### Comments
|
||||
```
|
||||
|
||||
## Module updates {#reviewing-contributions-module-updates}
|
||||
|
||||
This section has been moved to [nixos/README.md](https://github.com/NixOS/nixpkgs/blob/master/nixos/README.md).
|
||||
Module updates are submissions changing modules in some ways. These often contains changes to the options or introduce new options.
|
||||
|
||||
Reviewing process:
|
||||
|
||||
- Ensure that the module maintainers are notified.
|
||||
- [CODEOWNERS](https://help.github.com/articles/about-codeowners/) will make GitHub notify users based on the submitted changes, but it can happen that it misses some of the package maintainers.
|
||||
- Ensure that the module tests, if any, are succeeding.
|
||||
- Ensure that the introduced options are correct.
|
||||
- Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated).
|
||||
- Description, default and example should be provided.
|
||||
- Ensure that option changes are backward compatible.
|
||||
- `mkRenamedOptionModuleWith` provides a way to make option changes backward compatible.
|
||||
- Ensure that removed options are declared with `mkRemovedOptionModule`
|
||||
- Ensure that changes that are not backward compatible are mentioned in release notes.
|
||||
- Ensure that documentations affected by the change is updated.
|
||||
|
||||
Sample template for a module update review is provided below.
|
||||
|
||||
```markdown
|
||||
##### Reviewed points
|
||||
|
||||
- [ ] changes are backward compatible
|
||||
- [ ] removed options are declared with `mkRemovedOptionModule`
|
||||
- [ ] changes that are not backward compatible are documented in release notes
|
||||
- [ ] module tests succeed on ARCHITECTURE
|
||||
- [ ] options types are appropriate
|
||||
- [ ] options description is set
|
||||
- [ ] options example is provided
|
||||
- [ ] documentation affected by the changes is updated
|
||||
|
||||
##### Possible improvements
|
||||
|
||||
##### Comments
|
||||
```
|
||||
|
||||
## New modules {#reviewing-contributions-new-modules}
|
||||
|
||||
This section has been moved to [nixos/README.md](https://github.com/NixOS/nixpkgs/blob/master/nixos/README.md).
|
||||
New modules submissions introduce a new module to NixOS.
|
||||
|
||||
Reviewing process:
|
||||
|
||||
- Ensure that the module tests, if any, are succeeding.
|
||||
- Ensure that the introduced options are correct.
|
||||
- Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated).
|
||||
- Description, default and example should be provided.
|
||||
- Ensure that module `meta` field is present
|
||||
- Maintainers should be declared in `meta.maintainers`.
|
||||
- Module documentation should be declared with `meta.doc`.
|
||||
- Ensure that the module respect other modules functionality.
|
||||
- For example, enabling a module should not open firewall ports by default.
|
||||
|
||||
Sample template for a new module review is provided below.
|
||||
|
||||
```markdown
|
||||
##### Reviewed points
|
||||
|
||||
- [ ] module path fits the guidelines
|
||||
- [ ] module tests succeed on ARCHITECTURE
|
||||
- [ ] options have appropriate types
|
||||
- [ ] options have default
|
||||
- [ ] options have example
|
||||
- [ ] options have descriptions
|
||||
- [ ] No unneeded package is added to environment.systemPackages
|
||||
- [ ] meta.maintainers is set
|
||||
- [ ] module documentation is declared in meta.doc
|
||||
|
||||
##### Possible improvements
|
||||
|
||||
##### Comments
|
||||
```
|
||||
|
||||
## Individual maintainer list {#reviewing-contributions-individual-maintainer-list}
|
||||
|
||||
This section has been moved to [maintainers/README.md](https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md).
|
||||
When adding users to `maintainers/maintainer-list.nix`, the following
|
||||
checks should be performed:
|
||||
|
||||
- If the user has specified a GPG key, verify that the commit is
|
||||
signed by their key.
|
||||
|
||||
First, validate that the commit adding the maintainer is signed by
|
||||
the key the maintainer listed. Check out the pull request and
|
||||
compare its signing key with the listed key in the commit.
|
||||
|
||||
If the commit is not signed or it is signed by a different user, ask
|
||||
them to either recommit using that key or to remove their key
|
||||
information.
|
||||
|
||||
Given a maintainter entry like this:
|
||||
|
||||
``` nix
|
||||
{
|
||||
example = {
|
||||
email = "user@example.com";
|
||||
name = "Example User";
|
||||
keys = [{
|
||||
fingerprint = "0000 0000 2A70 6423 0AED 3C11 F04F 7A19 AAA6 3AFE";
|
||||
}];
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
First receive their key from a keyserver:
|
||||
|
||||
$ gpg --recv-keys 0xF04F7A19AAA63AFE
|
||||
gpg: key 0xF04F7A19AAA63AFE: public key "Example <user@example.com>" imported
|
||||
gpg: Total number processed: 1
|
||||
gpg: imported: 1
|
||||
|
||||
Then check the commit is signed by that key:
|
||||
|
||||
$ git log --show-signature
|
||||
commit b87862a4f7d32319b1de428adb6cdbdd3a960153
|
||||
gpg: Signature made Wed Mar 12 13:32:24 2003 +0000
|
||||
gpg: using RSA key 000000002A7064230AED3C11F04F7A19AAA63AFE
|
||||
gpg: Good signature from "Example User <user@example.com>
|
||||
Author: Example User <user@example.com>
|
||||
Date: Wed Mar 12 13:32:24 2003 +0000
|
||||
|
||||
maintainers: adding example
|
||||
|
||||
and validate that there is a `Good signature` and the printed key
|
||||
matches the user's submitted key.
|
||||
|
||||
Note: GitHub's "Verified" label does not display the user's full key
|
||||
fingerprint, and should not be used for validating the key matches.
|
||||
|
||||
- If the user has specified a `github` account name, ensure they have
|
||||
also specified a `githubId` and verify the two match.
|
||||
|
||||
Maintainer entries that include a `github` field must also include
|
||||
their `githubId`. People can and do change their GitHub name
|
||||
frequently, and the ID is used as the official and stable identity
|
||||
of the maintainer.
|
||||
|
||||
Given a maintainer entry like this:
|
||||
|
||||
``` nix
|
||||
{
|
||||
example = {
|
||||
email = "user@example.com";
|
||||
name = "Example User";
|
||||
github = "ghost";
|
||||
githubId = 10137;
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
First, make sure that the listed GitHub handle matches the author of
|
||||
the commit.
|
||||
|
||||
Then, visit the URL `https://api.github.com/users/ghost` and
|
||||
validate that the `id` field matches the provided `githubId`.
|
||||
|
||||
## Maintainer teams {#reviewing-contributions-maintainer-teams}
|
||||
|
||||
This section has been moved to [maintainers/README.md](https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md).
|
||||
Feel free to create a new maintainer team in `maintainers/team-list.nix`
|
||||
when a group is collectively responsible for a collection of packages.
|
||||
Use taste and personal judgement when deciding if a team is warranted.
|
||||
|
||||
Teams are allowed to define their own rules about membership.
|
||||
|
||||
For example, some teams will represent a business or other group which
|
||||
wants to carefully track its members. Other teams may be very open about
|
||||
who can join, and allow anybody to participate.
|
||||
|
||||
When reviewing changes to a team, read the team's scope and the context
|
||||
around the member list for indications about the team's membership
|
||||
policy.
|
||||
|
||||
In any case, request reviews from the existing team members. If the team
|
||||
lists no specific membership policy, feel free to merge changes to the
|
||||
team after giving the existing members a few days to respond.
|
||||
|
||||
*Important:* If a team says it is a closed group, do not merge additions
|
||||
to the team without an approval by at least one existing member.
|
||||
|
||||
## Other submissions {#reviewing-contributions-other-submissions}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
Other type of submissions requires different reviewing steps.
|
||||
|
||||
If you consider having enough knowledge and experience in a topic and would like to be a long-term reviewer for related submissions, please contact the current reviewers for that topic. They will give you information about the reviewing process. The main reviewers for a topic can be hard to find as there is no list, but checking past pull requests to see who reviewed or git-blaming the code to see who committed to that topic can give some hints.
|
||||
|
||||
Container system, boot system and library changes are some examples of the pull requests fitting this category.
|
||||
|
||||
## Merging pull requests {#reviewing-contributions--merging-pull-requests}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
It is possible for community members that have enough knowledge and experience on a special topic to contribute by merging pull requests.
|
||||
|
||||
In case the PR is stuck waiting for the original author to apply a trivial
|
||||
change (a typo, capitalisation change, etc.) and the author allowed the members
|
||||
to modify the PR, consider applying it yourself. (or commit the existing review
|
||||
suggestion) You should pay extra attention to make sure the addition doesn't go
|
||||
against the idea of the original PR and would not be opposed by the author.
|
||||
|
||||
<!--
|
||||
The following paragraphs about how to deal with unactive contributors is just a proposition and should be modified to what the community agrees to be the right policy.
|
||||
|
||||
Please note that contributors with commit rights unactive for more than three months will have their commit rights revoked.
|
||||
-->
|
||||
|
||||
Please see the discussion in [GitHub nixpkgs issue #50105](https://github.com/NixOS/nixpkgs/issues/50105) for information on how to proceed to be granted this level of access.
|
||||
|
||||
In a case a contributor definitively leaves the Nix community, they should create an issue or post on [Discourse](https://discourse.nixos.org) with references of packages and modules they maintain so the maintainership can be taken over by other contributors.
|
||||
|
||||
@@ -1,88 +1,302 @@
|
||||
# Submitting changes {#chap-submitting-changes}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
## Making patches {#submitting-changes-making-patches}
|
||||
|
||||
- Read [Manual (How to write packages for Nix)](https://nixos.org/nixpkgs/manual/).
|
||||
|
||||
- Fork [the Nixpkgs repository](https://github.com/nixos/nixpkgs/) on GitHub.
|
||||
|
||||
- Create a branch for your future fix.
|
||||
|
||||
- You can make branch from a commit of your local `nixos-version`. That will help you to avoid additional local compilations. Because you will receive packages from binary cache. For example
|
||||
|
||||
```ShellSession
|
||||
$ nixos-version --hash
|
||||
0998212
|
||||
$ git checkout 0998212
|
||||
$ git checkout -b 'fix/pkg-name-update'
|
||||
```
|
||||
|
||||
- Please avoid working directly on the `master` branch.
|
||||
|
||||
- Make commits of logical units.
|
||||
|
||||
- If you removed pkgs or made some major NixOS changes, write about it in the release notes for the next stable release. For example `nixos/doc/manual/release-notes/rl-2003.xml`.
|
||||
|
||||
- Check for unnecessary whitespace with `git diff --check` before committing.
|
||||
|
||||
- Format the commit in a following way:
|
||||
|
||||
```
|
||||
(pkg-name | nixos/<module>): (from -> to | init at version | refactor | etc)
|
||||
Additional information.
|
||||
```
|
||||
|
||||
- Examples:
|
||||
- `nginx: init at 2.0.1`
|
||||
- `firefox: 54.0.1 -> 55.0`
|
||||
- `nixos/hydra: add bazBaz option`
|
||||
- `nixos/nginx: refactor config generation`
|
||||
|
||||
- Test your changes. If you work with
|
||||
|
||||
- nixpkgs:
|
||||
|
||||
- update pkg
|
||||
- `nix-env -iA pkg-attribute-name -f <path to your local nixpkgs folder>`
|
||||
- add pkg
|
||||
- Make sure it’s in `pkgs/top-level/all-packages.nix`
|
||||
- `nix-env -iA pkg-attribute-name -f <path to your local nixpkgs folder>`
|
||||
- _If you don’t want to install pkg in you profile_.
|
||||
- `nix-build -A pkg-attribute-name <path to your local nixpkgs folder>` and check results in the folder `result`. It will appear in the same directory where you did `nix-build`.
|
||||
- If you installed your package with `nix-env`, you can run `nix-env -e pkg-name` where `pkg-name` is as reported by `nix-env -q` to uninstall it from your system.
|
||||
|
||||
- NixOS and its modules:
|
||||
- You can add new module to your NixOS configuration file (usually it’s `/etc/nixos/configuration.nix`). And do `sudo nixos-rebuild test -I nixpkgs=<path to your local nixpkgs folder> --fast`.
|
||||
|
||||
- If you have commits `pkg-name: oh, forgot to insert whitespace`: squash commits in this case. Use `git rebase -i`.
|
||||
|
||||
- [Rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) your branch against current `master`.
|
||||
|
||||
## Submitting changes {#submitting-changes-submitting-changes}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
- Push your changes to your fork of nixpkgs.
|
||||
- Create the pull request
|
||||
- Follow [the contribution guidelines](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#submitting-changes).
|
||||
|
||||
## Submitting security fixes {#submitting-changes-submitting-security-fixes}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
Security fixes are submitted in the same way as other changes and thus the same guidelines apply.
|
||||
|
||||
- If a new version fixing the vulnerability has been released, update the package;
|
||||
- If the security fix comes in the form of a patch and a CVE is available, then add the patch to the Nixpkgs tree, and apply it to the package.
|
||||
The name of the patch should be the CVE identifier, so e.g. `CVE-2019-13636.patch`; If a patch is fetched the name needs to be set as well, e.g.:
|
||||
|
||||
```nix
|
||||
(fetchpatch {
|
||||
name = "CVE-2019-11068.patch";
|
||||
url = "https://gitlab.gnome.org/GNOME/libxslt/commit/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch";
|
||||
hash = "sha256-SEKe/8HcW0UBHCfPTTOnpRlzmV2nQPPeL6HOMxBZd14=";
|
||||
})
|
||||
```
|
||||
|
||||
If a security fix applies to both master and a stable release then, similar to regular changes, they are preferably delivered via master first and cherry-picked to the release branch.
|
||||
|
||||
Critical security fixes may by-pass the staging branches and be delivered directly to release branches such as `master` and `release-*`.
|
||||
|
||||
## Deprecating/removing packages {#submitting-changes-deprecating-packages}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
There is currently no policy when to remove a package.
|
||||
|
||||
Before removing a package, one should try to find a new maintainer or fix smaller issues first.
|
||||
|
||||
### Steps to remove a package from Nixpkgs {#steps-to-remove-a-package-from-nixpkgs}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
We use jbidwatcher as an example for a discontinued project here.
|
||||
|
||||
1. Have Nixpkgs checked out locally and up to date.
|
||||
1. Create a new branch for your change, e.g. `git checkout -b jbidwatcher`
|
||||
1. Remove the actual package including its directory, e.g. `git rm -rf pkgs/applications/misc/jbidwatcher`
|
||||
1. Remove the package from the list of all packages (`pkgs/top-level/all-packages.nix`).
|
||||
1. Add an alias for the package name in `pkgs/top-level/aliases.nix` (There is also `pkgs/applications/editors/vim/plugins/aliases.nix`. Package sets typically do not have aliases, so we can't add them there.)
|
||||
|
||||
For example in this case:
|
||||
|
||||
```
|
||||
jbidwatcher = throw "jbidwatcher was discontinued in march 2021"; # added 2021-03-15
|
||||
```
|
||||
|
||||
The throw message should explain in short why the package was removed for users that still have it installed.
|
||||
|
||||
1. Test if the changes introduced any issues by running `nix-env -qaP -f . --show-trace`. It should show the list of packages without errors.
|
||||
1. Commit the changes. Explain again why the package was removed. If it was declared discontinued upstream, add a link to the source.
|
||||
|
||||
```ShellSession
|
||||
$ git add pkgs/applications/misc/jbidwatcher/default.nix pkgs/top-level/all-packages.nix pkgs/top-level/aliases.nix
|
||||
$ git commit
|
||||
```
|
||||
|
||||
Example commit message:
|
||||
|
||||
```
|
||||
jbidwatcher: remove
|
||||
|
||||
project was discontinued in march 2021. the program does not work anymore because ebay changed the login.
|
||||
|
||||
https://web.archive.org/web/20210315205723/http://www.jbidwatcher.com/
|
||||
```
|
||||
|
||||
1. Push changes to your GitHub fork with `git push`
|
||||
1. Create a pull request against Nixpkgs. Mention the package maintainer.
|
||||
|
||||
This is how the pull request looks like in this case: [https://github.com/NixOS/nixpkgs/pull/116470](https://github.com/NixOS/nixpkgs/pull/116470)
|
||||
|
||||
## Pull Request Template {#submitting-changes-pull-request-template}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
The pull request template helps determine what steps have been made for a contribution so far, and will help guide maintainers on the status of a change. The motivation section of the PR should include any extra details the title does not address and link any existing issues related to the pull request.
|
||||
|
||||
When a PR is created, it will be pre-populated with some checkboxes detailed below:
|
||||
|
||||
### Tested using sandboxing {#submitting-changes-tested-with-sandbox}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
When sandbox builds are enabled, Nix will setup an isolated environment for each build process. It is used to remove further hidden dependencies set by the build environment to improve reproducibility. This includes access to the network during the build outside of `fetch*` functions and files outside the Nix store. Depending on the operating system access to other resources are blocked as well (ex. inter process communication is isolated on Linux); see [sandbox](https://nixos.org/nix/manual/#conf-sandbox) in Nix manual for details.
|
||||
|
||||
Sandboxing is not enabled by default in Nix due to a small performance hit on each build. In pull requests for [nixpkgs](https://github.com/NixOS/nixpkgs/) people are asked to test builds with sandboxing enabled (see `Tested using sandboxing` in the pull request template) because in<https://nixos.org/hydra/> sandboxing is also used.
|
||||
|
||||
Depending if you use NixOS or other platforms you can use one of the following methods to enable sandboxing **before** building the package:
|
||||
|
||||
- **Globally enable sandboxing on NixOS**: add the following to `configuration.nix`
|
||||
|
||||
```nix
|
||||
nix.useSandbox = true;
|
||||
```
|
||||
|
||||
- **Globally enable sandboxing on non-NixOS platforms**: add the following to: `/etc/nix/nix.conf`
|
||||
|
||||
```ini
|
||||
sandbox = true
|
||||
```
|
||||
|
||||
### Built on platform(s) {#submitting-changes-platform-diversity}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
Many Nix packages are designed to run on multiple platforms. As such, it’s important to let the maintainer know which platforms your changes have been tested on. It’s not always practical to test a change on all platforms, and is not required for a pull request to be merged. Only check the systems you tested the build on in this section.
|
||||
|
||||
### Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests) {#submitting-changes-nixos-tests}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
Packages with automated tests are much more likely to be merged in a timely fashion because it doesn’t require as much manual testing by the maintainer to verify the functionality of the package. If there are existing tests for the package, they should be run to verify your changes do not break the tests. Tests can only be run on Linux. For more details on writing and running tests, see the [section in the NixOS manual](https://nixos.org/nixos/manual/index.html#sec-nixos-tests).
|
||||
|
||||
### Tested compilation of all pkgs that depend on this change using `nixpkgs-review` {#submitting-changes-tested-compilation}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
If you are updating a package’s version, you can use `nixpkgs-review` to make sure all packages that depend on the updated package still compile correctly. The `nixpkgs-review` utility can look for and build all dependencies either based on uncommitted changes with the `wip` option or specifying a GitHub pull request number.
|
||||
|
||||
Review changes from pull request number 12345:
|
||||
|
||||
```ShellSession
|
||||
nix-shell -p nixpkgs-review --run "nixpkgs-review pr 12345"
|
||||
```
|
||||
|
||||
Alternatively, with flakes (and analogously for the other commands below):
|
||||
|
||||
```ShellSession
|
||||
nix run nixpkgs#nixpkgs-review -- pr 12345
|
||||
```
|
||||
|
||||
Review uncommitted changes:
|
||||
|
||||
```ShellSession
|
||||
nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
|
||||
```
|
||||
|
||||
Review changes from last commit:
|
||||
|
||||
```ShellSession
|
||||
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
|
||||
```
|
||||
|
||||
### Tested execution of all binary files (usually in `./result/bin/`) {#submitting-changes-tested-execution}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
It’s important to test any executables generated by a build when you change or create a package in nixpkgs. This can be done by looking in `./result/bin` and running any files in there, or at a minimum, the main executable for the package. For example, if you make a change to texlive, you probably would only check the binaries associated with the change you made rather than testing all of them.
|
||||
|
||||
### Meets Nixpkgs contribution standards {#submitting-changes-contribution-standards}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
The last checkbox is fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). The contributing document has detailed information on standards the Nix community has for commit messages, reviews, licensing of contributions you make to the project, etc... Everyone should read and understand the standards the community has for contributing before submitting a pull request.
|
||||
|
||||
## Hotfixing pull requests {#submitting-changes-hotfixing-pull-requests}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
- Make the appropriate changes in you branch.
|
||||
- Don’t create additional commits, do
|
||||
- `git rebase -i`
|
||||
- `git push --force` to your branch.
|
||||
|
||||
## Commit policy {#submitting-changes-commit-policy}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
- Commits must be sufficiently tested before being merged, both for the master and staging branches.
|
||||
- Hydra builds for master and staging should not be used as testing platform, it’s a build farm for changes that have been already tested.
|
||||
- When changing the bootloader installation process, extra care must be taken. Grub installations cannot be rolled back, hence changes may break people’s installations forever. For any non-trivial change to the bootloader please file a PR asking for review, especially from \@edolstra.
|
||||
|
||||
### Branches {#submitting-changes-branches}
|
||||
```{.graphviz caption="Staging workflow"}
|
||||
digraph {
|
||||
"small changes" [shape=none]
|
||||
"mass-rebuilds and other large changes" [shape=none]
|
||||
"critical security fixes" [shape=none]
|
||||
"broken staging-next fixes" [shape=none]
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
"small changes" -> master
|
||||
"mass-rebuilds and other large changes" -> staging
|
||||
"critical security fixes" -> master
|
||||
"broken staging-next fixes" -> "staging-next"
|
||||
|
||||
#### Master branch {#submitting-changes-master-branch}
|
||||
"staging-next" -> master [color="#E85EB0"] [label="stabilization ends"] [fontcolor="#E85EB0"]
|
||||
"staging" -> "staging-next" [color="#E85EB0"] [label="stabilization starts"] [fontcolor="#E85EB0"]
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
master -> "staging-next" -> staging [color="#5F5EE8"] [label="every six hours (GitHub Action)"] [fontcolor="#5F5EE8"]
|
||||
}
|
||||
```
|
||||
|
||||
#### Staging branch {#submitting-changes-staging-branch}
|
||||
[This GitHub Action](https://github.com/NixOS/nixpkgs/blob/master/.github/workflows/periodic-merge-6h.yml) brings changes from `master` to `staging-next` and from `staging-next` to `staging` every 6 hours; these are the blue arrows in the diagram above. The purple arrows in the diagram above are done manually and much less frequently. You can get an idea of how often these merges occur by looking at the git history.
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
|
||||
#### Staging-next branch {#submitting-changes-staging-next-branch}
|
||||
### Master branch {#submitting-changes-master-branch}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
The `master` branch is the main development branch. It should only see non-breaking commits that do not cause mass rebuilds.
|
||||
|
||||
#### Stable release branches {#submitting-changes-stable-release-branches}
|
||||
### Staging branch {#submitting-changes-staging-branch}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
The `staging` branch is a development branch where mass-rebuilds go. Mass rebuilds are commits that cause rebuilds for many packages, like more than 500 (or perhaps, if it's 'light' packages, 1000). It should only see non-breaking mass-rebuild commits. That means it is not to be used for testing, and changes must have been well tested already. If the branch is already in a broken state, please refrain from adding extra new breakages.
|
||||
|
||||
During the process of a releasing a new NixOS version, this branch or the release-critical packages can be restricted to non-breaking changes.
|
||||
|
||||
### Staging-next branch {#submitting-changes-staging-next-branch}
|
||||
|
||||
The `staging-next` branch is for stabilizing mass-rebuilds submitted to the `staging` branch prior to merging them into `master`. Mass-rebuilds must go via the `staging` branch. It must only see non-breaking commits that are fixing issues blocking it from being merged into the `master` branch.
|
||||
|
||||
If the branch is already in a broken state, please refrain from adding extra new breakages. Stabilize it for a few days and then merge into master.
|
||||
|
||||
During the process of a releasing a new NixOS version, this branch or the release-critical packages can be restricted to non-breaking changes.
|
||||
|
||||
### Stable release branches {#submitting-changes-stable-release-branches}
|
||||
|
||||
The same staging workflow applies to stable release branches, but the main branch is called `release-*` instead of `master`.
|
||||
|
||||
Example branch names: `release-21.11`, `staging-21.11`, `staging-next-21.11`.
|
||||
|
||||
Most changes added to the stable release branches are cherry-picked (“backported”) from the `master` and staging branches.
|
||||
|
||||
#### Automatically backporting a Pull Request {#submitting-changes-stable-release-branches-automatic-backports}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
Assign label `backport <branch>` (e.g. `backport release-21.11`) to the PR and a backport PR is automatically created after the PR is merged.
|
||||
|
||||
#### Manually backporting changes {#submitting-changes-stable-release-branches-manual-backports}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
Cherry-pick changes via `git cherry-pick -x <original commit>` so that the original commit id is included in the commit message.
|
||||
|
||||
Add a reason for the backport when it is not obvious from the original commit message. You can do this by cherry picking with `git cherry-pick -xe <original commit>`, which allows editing the commit message. This is not needed for minor version updates that include security and bug fixes but don't add new features or when the commit fixes an otherwise broken package.
|
||||
|
||||
Here is an example of a cherry-picked commit message with good reason description:
|
||||
|
||||
```
|
||||
zfs: Keep trying root import until it works
|
||||
|
||||
Works around #11003.
|
||||
|
||||
(cherry picked from commit 98b213a11041af39b39473906b595290e2a4e2f9)
|
||||
|
||||
Reason: several people cannot boot with ZFS on NVMe
|
||||
```
|
||||
|
||||
Other examples of reasons are:
|
||||
|
||||
- Previously the build would fail due to, e.g., `getaddrinfo` not being defined
|
||||
- The previous download links were all broken
|
||||
- Crash when starting on some X11 systems
|
||||
|
||||
#### Acceptable backport criteria {#acceptable-backport-criteria}
|
||||
|
||||
This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
The stable branch does have some changes which cannot be backported. Most notable are breaking changes. The desire is to have stable users be uninterrupted when updating packages.
|
||||
|
||||
However, many changes are able to be backported, including:
|
||||
- New Packages / Modules
|
||||
- Security / Patch updates
|
||||
- Version updates which include new functionality (but no breaking changes)
|
||||
- Services which require a client to be up-to-date regardless. (E.g. `spotify`, `steam`, or `discord`)
|
||||
- Security critical applications (E.g. `firefox`)
|
||||
|
||||
@@ -1,11 +1,45 @@
|
||||
# Vulnerability Roundup {#chap-vulnerability-roundup}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
|
||||
## Issues {#vulnerability-roundup-issues}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
Vulnerable packages in Nixpkgs are managed using issues.
|
||||
Currently opened ones can be found using the following:
|
||||
|
||||
[github.com/NixOS/nixpkgs/issues?q=is:issue+is:open+"Vulnerability+roundup"](https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue+is%3Aopen+%22Vulnerability+roundup%22)
|
||||
|
||||
Each issue correspond to a vulnerable version of a package; As a consequence:
|
||||
|
||||
- One issue can contain several CVEs;
|
||||
- One CVE can be shared across several issues;
|
||||
- A single package can be concerned by several issues.
|
||||
|
||||
|
||||
A "Vulnerability roundup" issue usually respects the following format:
|
||||
|
||||
```txt
|
||||
<link to relevant package search on search.nix.gsc.io>, <link to relevant files in Nixpkgs on GitHub>
|
||||
|
||||
<list of related CVEs, their CVSS score, and the impacted NixOS version>
|
||||
|
||||
<list of the scanned Nixpkgs versions>
|
||||
|
||||
<list of relevant contributors>
|
||||
```
|
||||
|
||||
Note that there can be an extra comment containing links to previously reported (and still open) issues for the same package.
|
||||
|
||||
|
||||
## Triaging and Fixing {#vulnerability-roundup-triaging-and-fixing}
|
||||
|
||||
This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
|
||||
**Note**: An issue can be a "false positive" (i.e. automatically opened, but without the package it refers to being actually vulnerable).
|
||||
If you find such a "false positive", comment on the issue an explanation of why it falls into this category, linking as much information as the necessary to help maintainers double check.
|
||||
|
||||
If you are investigating a "true positive":
|
||||
|
||||
- Find the earliest patched version or a code patch in the CVE details;
|
||||
- Is the issue already patched (version up-to-date or patch applied manually) in Nixpkgs's `master` branch?
|
||||
- **No**:
|
||||
- [Submit a security fix](#submitting-changes-submitting-security-fixes);
|
||||
- Once the fix is merged into `master`, [submit the change to the vulnerable release branch(es)](https://nixos.org/manual/nixpkgs/stable/#submitting-changes-stable-release-branches);
|
||||
- **Yes**: [Backport the change to the vulnerable release branch(es)](https://nixos.org/manual/nixpkgs/stable/#submitting-changes-stable-release-branches).
|
||||
- When the patch has made it into all the relevant branches (`master`, and the vulnerable releases), close the relevant issue(s).
|
||||
|
||||
150
doc/default.nix
150
doc/default.nix
@@ -1,151 +1,43 @@
|
||||
{ pkgs ? (import ./.. { }), nixpkgs ? { }}:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
inherit (lib) hasPrefix removePrefix;
|
||||
|
||||
common = import ./common.nix;
|
||||
|
||||
lib-docs = import ./doc-support/lib-function-docs.nix {
|
||||
inherit pkgs nixpkgs;
|
||||
libsets = [
|
||||
{ name = "asserts"; description = "assertion functions"; }
|
||||
{ name = "attrsets"; description = "attribute set functions"; }
|
||||
{ name = "strings"; description = "string manipulation functions"; }
|
||||
{ name = "versions"; description = "version string functions"; }
|
||||
{ name = "trivial"; description = "miscellaneous functions"; }
|
||||
{ name = "fixedPoints"; baseName = "fixed-points"; description = "explicit recursion functions"; }
|
||||
{ name = "lists"; description = "list manipulation functions"; }
|
||||
{ name = "debug"; description = "debugging functions"; }
|
||||
{ name = "options"; description = "NixOS / nixpkgs option handling"; }
|
||||
{ name = "path"; description = "path functions"; }
|
||||
{ name = "filesystem"; description = "filesystem functions"; }
|
||||
{ name = "fileset"; description = "file set functions"; }
|
||||
{ name = "sources"; description = "source filtering functions"; }
|
||||
{ name = "cli"; description = "command-line serialization functions"; }
|
||||
{ name = "gvariant"; description = "GVariant formatted string serialization functions"; }
|
||||
{ name = "customisation"; description = "Functions to customise (derivation-related) functions, derivatons, or attribute sets"; }
|
||||
];
|
||||
};
|
||||
|
||||
epub = pkgs.runCommand "manual.epub" {
|
||||
nativeBuildInputs = with pkgs; [ libxslt zip ];
|
||||
|
||||
epub = ''
|
||||
<book xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
version="5.0"
|
||||
xml:id="nixpkgs-manual">
|
||||
<info>
|
||||
<title>Nixpkgs Manual</title>
|
||||
<subtitle>Version ${pkgs.lib.version}</subtitle>
|
||||
</info>
|
||||
<chapter>
|
||||
<title>Temporarily unavailable</title>
|
||||
<para>
|
||||
The Nixpkgs manual is currently not available in EPUB format,
|
||||
please use the <link xlink:href="https://nixos.org/nixpkgs/manual">HTML manual</link>
|
||||
instead.
|
||||
</para>
|
||||
<para>
|
||||
If you've used the EPUB manual in the past and it has been useful to you, please
|
||||
<link xlink:href="https://github.com/NixOS/nixpkgs/issues/237234">let us know</link>.
|
||||
</para>
|
||||
</chapter>
|
||||
</book>
|
||||
'';
|
||||
|
||||
passAsFile = [ "epub" ];
|
||||
} ''
|
||||
mkdir scratch
|
||||
xsltproc \
|
||||
--param chapter.autolabel 0 \
|
||||
--nonet \
|
||||
--output scratch/ \
|
||||
${pkgs.docbook_xsl_ns}/xml/xsl/docbook/epub/docbook.xsl \
|
||||
$epubPath
|
||||
|
||||
echo "application/epub+zip" > mimetype
|
||||
zip -0Xq "$out" mimetype
|
||||
cd scratch && zip -Xr9D "$out" *
|
||||
'';
|
||||
|
||||
# NB: This file describes the Nixpkgs manual, which happens to use module
|
||||
# docs infra originally developed for NixOS.
|
||||
optionsDoc = pkgs.nixosOptionsDoc {
|
||||
inherit (pkgs.lib.evalModules {
|
||||
modules = [ ../pkgs/top-level/config.nix ];
|
||||
class = "nixpkgsConfig";
|
||||
}) options;
|
||||
documentType = "none";
|
||||
transformOptions = opt:
|
||||
opt // {
|
||||
declarations =
|
||||
map
|
||||
(decl:
|
||||
if hasPrefix (toString ../..) (toString decl)
|
||||
then
|
||||
let subpath = removePrefix "/" (removePrefix (toString ../.) (toString decl));
|
||||
in { url = "https://github.com/NixOS/nixpkgs/blob/master/${subpath}"; name = subpath; }
|
||||
else decl)
|
||||
opt.declarations;
|
||||
};
|
||||
};
|
||||
doc-support = import ./doc-support { inherit pkgs nixpkgs; };
|
||||
in pkgs.stdenv.mkDerivation {
|
||||
name = "nixpkgs-manual";
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
nixos-render-docs
|
||||
pandoc
|
||||
graphviz
|
||||
libxml2
|
||||
libxslt
|
||||
zip
|
||||
jing
|
||||
xmlformat
|
||||
];
|
||||
|
||||
src = ./.;
|
||||
src = pkgs.nix-gitignore.gitignoreSource [] ./.;
|
||||
|
||||
postPatch = ''
|
||||
ln -s ${optionsDoc.optionsJSON}/share/doc/nixos/options.json ./config-options.json
|
||||
ln -s ${doc-support} ./doc-support/result
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
cat \
|
||||
./functions/library.md.in \
|
||||
${lib-docs}/index.md \
|
||||
> ./functions/library.md
|
||||
substitute ./manual.md.in ./manual.md \
|
||||
--replace '@MANUAL_VERSION@' '${pkgs.lib.version}'
|
||||
|
||||
mkdir -p out/media
|
||||
|
||||
mkdir -p out/highlightjs
|
||||
cp -t out/highlightjs \
|
||||
${pkgs.documentation-highlighter}/highlight.pack.js \
|
||||
${pkgs.documentation-highlighter}/LICENSE \
|
||||
${pkgs.documentation-highlighter}/mono-blue.css \
|
||||
${pkgs.documentation-highlighter}/loader.js
|
||||
|
||||
cp -t out ./overrides.css ./style.css
|
||||
|
||||
nixos-render-docs manual html \
|
||||
--manpage-urls ./manpage-urls.json \
|
||||
--revision ${pkgs.lib.trivial.revisionWithDefault (pkgs.rev or "master")} \
|
||||
--stylesheet style.css \
|
||||
--stylesheet overrides.css \
|
||||
--stylesheet highlightjs/mono-blue.css \
|
||||
--script ./highlightjs/highlight.pack.js \
|
||||
--script ./highlightjs/loader.js \
|
||||
--toc-depth 1 \
|
||||
--section-toc-depth 1 \
|
||||
manual.md \
|
||||
out/index.html
|
||||
preBuild = ''
|
||||
make -j$NIX_BUILD_CORES render-md
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
dest="$out/${common.outputPath}"
|
||||
dest="$out/share/doc/nixpkgs"
|
||||
mkdir -p "$(dirname "$dest")"
|
||||
mv out "$dest"
|
||||
mv "$dest/index.html" "$dest/${common.indexPath}"
|
||||
mv out/html "$dest"
|
||||
mv "$dest/index.html" "$dest/manual.html"
|
||||
|
||||
cp ${epub} "$dest/nixpkgs-manual.epub"
|
||||
mv out/epub/manual.epub "$dest/nixpkgs-manual.epub"
|
||||
|
||||
mkdir -p $out/nix-support/
|
||||
echo "doc manual $dest ${common.indexPath}" >> $out/nix-support/hydra-build-products
|
||||
echo "doc manual $dest manual.html" >> $out/nix-support/hydra-build-products
|
||||
echo "doc manual $dest nixpkgs-manual.epub" >> $out/nix-support/hydra-build-products
|
||||
'';
|
||||
|
||||
# Environment variables
|
||||
PANDOC_LUA_FILTERS_DIR = "${pkgs.pandoc-lua-filters}/share/pandoc/filters";
|
||||
PANDOC_LINK_MANPAGES_FILTER = import build-aux/pandoc-filters/link-manpages.nix { inherit pkgs; };
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# Development of Nixpkgs {#part-development}
|
||||
|
||||
This section shows you how Nixpkgs is being developed and how you can interact with the contributors and the latest updates.
|
||||
If you are interested in contributing yourself, see [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
|
||||
<!-- In the future this section should also include: How to test pull requests, how to know if pull requests are available in channels, etc. -->
|
||||
|
||||
```{=include=} chapters
|
||||
development/opening-issues.chapter.md
|
||||
```
|
||||
@@ -1,7 +0,0 @@
|
||||
# Opening issues {#sec-opening-issues}
|
||||
|
||||
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
||||
* Make sure there is no open issue on the topic
|
||||
* [Submit a new issue](https://github.com/NixOS/nixpkgs/issues/new/choose) by choosing the kind of topic and fill out the template
|
||||
|
||||
<!-- In the future this section could also include more detailed information on the issue templates -->
|
||||
87
doc/doc-support/default.nix
Normal file
87
doc/doc-support/default.nix
Normal file
@@ -0,0 +1,87 @@
|
||||
{ pkgs ? (import ../.. {}), nixpkgs ? { }}:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
inherit (lib) hasPrefix removePrefix;
|
||||
|
||||
libsets = [
|
||||
{ name = "asserts"; description = "assertion functions"; }
|
||||
{ name = "attrsets"; description = "attribute set functions"; }
|
||||
{ name = "strings"; description = "string manipulation functions"; }
|
||||
{ name = "versions"; description = "version string functions"; }
|
||||
{ name = "trivial"; description = "miscellaneous functions"; }
|
||||
{ name = "lists"; description = "list manipulation functions"; }
|
||||
{ name = "debug"; description = "debugging functions"; }
|
||||
{ name = "options"; description = "NixOS / nixpkgs option handling"; }
|
||||
{ name = "path"; description = "path functions"; }
|
||||
{ name = "filesystem"; description = "filesystem functions"; }
|
||||
{ name = "sources"; description = "source filtering functions"; }
|
||||
{ name = "cli"; description = "command-line serialization functions"; }
|
||||
];
|
||||
|
||||
locationsXml = import ./lib-function-locations.nix { inherit pkgs nixpkgs libsets; };
|
||||
functionDocs = import ./lib-function-docs.nix { inherit locationsXml pkgs libsets; };
|
||||
version = pkgs.lib.version;
|
||||
|
||||
epub-xsl = pkgs.writeText "epub.xsl" ''
|
||||
<?xml version='1.0'?>
|
||||
<xsl:stylesheet
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
version="1.0">
|
||||
<xsl:import href="${pkgs.docbook_xsl_ns}/xml/xsl/docbook/epub/docbook.xsl" />
|
||||
<xsl:import href="${./parameters.xml}"/>
|
||||
</xsl:stylesheet>
|
||||
'';
|
||||
|
||||
xhtml-xsl = pkgs.writeText "xhtml.xsl" ''
|
||||
<?xml version='1.0'?>
|
||||
<xsl:stylesheet
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
version="1.0">
|
||||
<xsl:import href="${pkgs.docbook_xsl_ns}/xml/xsl/docbook/xhtml/docbook.xsl" />
|
||||
<xsl:import href="${./parameters.xml}"/>
|
||||
</xsl:stylesheet>
|
||||
'';
|
||||
|
||||
# NB: This file describes the Nixpkgs manual, which happens to use module
|
||||
# docs infra originally developed for NixOS.
|
||||
optionsDoc = pkgs.nixosOptionsDoc {
|
||||
inherit (pkgs.lib.evalModules {
|
||||
modules = [ ../../pkgs/top-level/config.nix ];
|
||||
class = "nixpkgsConfig";
|
||||
}) options;
|
||||
documentType = "none";
|
||||
transformOptions = opt:
|
||||
opt // {
|
||||
declarations =
|
||||
map
|
||||
(decl:
|
||||
if hasPrefix (toString ../..) (toString decl)
|
||||
then
|
||||
let subpath = removePrefix "/" (removePrefix (toString ../..) (toString decl));
|
||||
in { url = "https://github.com/NixOS/nixpkgs/blob/master/${subpath}"; name = subpath; }
|
||||
else decl)
|
||||
opt.declarations;
|
||||
};
|
||||
};
|
||||
|
||||
in pkgs.runCommand "doc-support" {}
|
||||
''
|
||||
mkdir result
|
||||
(
|
||||
cd result
|
||||
ln -s ${locationsXml} ./function-locations.xml
|
||||
ln -s ${functionDocs} ./function-docs
|
||||
ln -s ${optionsDoc.optionsDocBook} ./config-options.docbook.xml
|
||||
|
||||
ln -s ${pkgs.docbook5}/xml/rng/docbook/docbook.rng ./docbook.rng
|
||||
ln -s ${pkgs.docbook_xsl_ns}/xml/xsl ./xsl
|
||||
ln -s ${epub-xsl} ./epub.xsl
|
||||
ln -s ${xhtml-xsl} ./xhtml.xsl
|
||||
|
||||
ln -s ${./xmlformat.conf} ./xmlformat.conf
|
||||
ln -s ${pkgs.documentation-highlighter} ./highlightjs
|
||||
|
||||
echo -n "${version}" > ./version
|
||||
)
|
||||
mv result $out
|
||||
''
|
||||
@@ -1,41 +1,36 @@
|
||||
# Generates the documentation for library functions via nixdoc.
|
||||
|
||||
{ pkgs, nixpkgs, libsets }:
|
||||
{ pkgs, locationsXml, libsets }:
|
||||
|
||||
with pkgs;
|
||||
|
||||
let
|
||||
locationsJSON = import ./lib-function-locations.nix { inherit pkgs nixpkgs libsets; };
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
with pkgs; stdenv.mkDerivation {
|
||||
name = "nixpkgs-lib-docs";
|
||||
src = ../../lib;
|
||||
|
||||
buildInputs = [ nixdoc ];
|
||||
installPhase = ''
|
||||
function docgen {
|
||||
name=$1
|
||||
baseName=$2
|
||||
description=$3
|
||||
# TODO: wrap lib.$name in <literal>, make nixdoc not escape it
|
||||
if [[ -e "../lib/$baseName.nix" ]]; then
|
||||
nixdoc -c "$name" -d "lib.$name: $description" -l ${locationsJSON} -f "$baseName.nix" > "$out/$name.md"
|
||||
# TODO: wrap lib.$1 in <literal>, make nixdoc not escape it
|
||||
if [[ -e "../lib/$1.nix" ]]; then
|
||||
nixdoc -c "$1" -d "lib.$1: $2" -f "$1.nix" > "$out/$1.xml"
|
||||
else
|
||||
nixdoc -c "$name" -d "lib.$name: $description" -l ${locationsJSON} -f "$baseName/default.nix" > "$out/$name.md"
|
||||
nixdoc -c "$1" -d "lib.$1: $2" -f "$1/default.nix" > "$out/$1.xml"
|
||||
fi
|
||||
echo "$out/$name.md" >> "$out/index.md"
|
||||
echo "<xi:include href='$1.xml' />" >> "$out/index.xml"
|
||||
}
|
||||
|
||||
mkdir -p "$out"
|
||||
|
||||
cat > "$out/index.md" << 'EOF'
|
||||
```{=include=} sections
|
||||
cat > "$out/index.xml" << 'EOF'
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
EOF
|
||||
|
||||
${lib.concatMapStrings ({ name, baseName ? name, description }: ''
|
||||
docgen ${name} ${baseName} ${lib.escapeShellArg description}
|
||||
${lib.concatMapStrings ({ name, description }: ''
|
||||
docgen ${name} ${lib.escapeShellArg description}
|
||||
'') libsets}
|
||||
|
||||
echo '```' >> "$out/index.md"
|
||||
echo "</root>" >> "$out/index.xml"
|
||||
|
||||
ln -s ${locationsXml} $out/locations.xml
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -58,18 +58,28 @@ let
|
||||
[ "-prime" ];
|
||||
|
||||
urlPrefix = "https://github.com/NixOS/nixpkgs/blob/${revision}";
|
||||
jsonLocs = builtins.listToAttrs
|
||||
(builtins.map
|
||||
({ name, value }: {
|
||||
name = sanitizeId name;
|
||||
value =
|
||||
let
|
||||
text = "${value.file}:${builtins.toString value.line}";
|
||||
target = "${urlPrefix}/${value.file}#L${builtins.toString value.line}";
|
||||
in
|
||||
"[${text}](${target}) in `<nixpkgs>`";
|
||||
})
|
||||
relativeLocs);
|
||||
xmlstrings = (nixpkgsLib.strings.concatMapStrings
|
||||
({ name, value }:
|
||||
''
|
||||
<section><title>${name}</title>
|
||||
<para xml:id="${sanitizeId name}">
|
||||
Located at
|
||||
<link
|
||||
xlink:href="${urlPrefix}/${value.file}#L${builtins.toString value.line}">${value.file}:${builtins.toString value.line}</link>
|
||||
in <literal><nixpkgs></literal>.
|
||||
</para>
|
||||
</section>
|
||||
'')
|
||||
relativeLocs);
|
||||
|
||||
in
|
||||
pkgs.writeText "locations.json" (builtins.toJSON jsonLocs)
|
||||
in pkgs.writeText
|
||||
"locations.xml"
|
||||
''
|
||||
<section xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
version="5">
|
||||
<title>All the locations for every lib function</title>
|
||||
<para>This file is only for inclusion by other files.</para>
|
||||
${xmlstrings}
|
||||
</section>
|
||||
''
|
||||
|
||||
19
doc/doc-support/parameters.xml
Normal file
19
doc/doc-support/parameters.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version='1.0'?>
|
||||
<xsl:stylesheet
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
version="1.0">
|
||||
<xsl:param name="chapter.autolabel" select="0" />
|
||||
<xsl:param name="part.autolabel" select="0" />
|
||||
<xsl:param name="preface.autolabel" select="0" />
|
||||
<xsl:param name="reference.autolabel" select="0" />
|
||||
<xsl:param name="section.autolabel" select="0" />
|
||||
<xsl:param name="html.stylesheet" select="'style.css overrides.css highlightjs/mono-blue.css'" />
|
||||
<xsl:param name="html.script" select="'./highlightjs/highlight.pack.js ./highlightjs/loader.js'" />
|
||||
<xsl:param name="xref.with.number.and.title" select="0" />
|
||||
<xsl:param name="use.id.as.filename" select="1" />
|
||||
<xsl:param name="generate.section.toc.level" select="1" />
|
||||
<xsl:param name="toc.section.depth" select="0" />
|
||||
<xsl:param name="admon.style" select="''" />
|
||||
<xsl:param name="callout.graphics.extension" select="'.svg'" />
|
||||
<xsl:param name="generate.consistent.ids" select="1" />
|
||||
</xsl:stylesheet>
|
||||
72
doc/doc-support/xmlformat.conf
Normal file
72
doc/doc-support/xmlformat.conf
Normal file
@@ -0,0 +1,72 @@
|
||||
#
|
||||
# DocBook Configuration file for "xmlformat"
|
||||
# see http://www.kitebird.com/software/xmlformat/
|
||||
# 10 Sept. 2004
|
||||
#
|
||||
|
||||
# Only block elements
|
||||
ackno address appendix article biblioentry bibliography bibliomixed \
|
||||
biblioset blockquote book bridgehead callout calloutlist caption caution \
|
||||
chapter chapterinfo classsynopsis cmdsynopsis colophon constraintdef \
|
||||
constructorsynopsis dedication destructorsynopsis entry epigraph equation example \
|
||||
figure formalpara funcsynopsis glossary glossdef glossdiv glossentry glosslist \
|
||||
glosssee glossseealso graphic graphicco highlights imageobjectco important \
|
||||
index indexdiv indexentry indexinfo info informalequation informalexample \
|
||||
informalfigure informaltable legalnotice literallayout lot lotentry mediaobject \
|
||||
mediaobjectco msgmain msgset note orderedlist para part preface primaryie \
|
||||
procedure qandadiv qandaentry qandaset refentry refentrytitle reference \
|
||||
refnamediv refsect1 refsect2 refsect3 refsection revhistory screenshot sect1 \
|
||||
sect2 sect3 sect4 sect5 section seglistitem set setindex sidebar simpara \
|
||||
simplesect step substeps synopfragment synopsis table term title \
|
||||
toc variablelist varlistentry warning itemizedlist listitem \
|
||||
footnote colspec partintro row simplelist subtitle tbody tgroup thead tip
|
||||
format block
|
||||
normalize no
|
||||
|
||||
|
||||
#appendix bibliography chapter glossary preface reference
|
||||
# element-break 3
|
||||
|
||||
sect1 section
|
||||
element-break 2
|
||||
|
||||
|
||||
#
|
||||
para abstract
|
||||
format block
|
||||
entry-break 1
|
||||
exit-break 1
|
||||
normalize yes
|
||||
|
||||
title
|
||||
format block
|
||||
normalize = yes
|
||||
entry-break = 0
|
||||
exit-break = 0
|
||||
|
||||
# Inline elements
|
||||
abbrev accel acronym action application citation citebiblioid citerefentry citetitle \
|
||||
classname co code command computeroutput constant country database date email emphasis \
|
||||
envar errorcode errorname errortext errortype exceptionname fax filename \
|
||||
firstname firstterm footnoteref foreignphrase funcdef funcparams function \
|
||||
glossterm group guibutton guiicon guilabel guimenu guimenuitem guisubmenu \
|
||||
hardware holder honorific indexterm inlineequation inlinegraphic inlinemediaobject \
|
||||
interface interfacename \
|
||||
keycap keycode keycombo keysym lineage link literal manvolnum markup medialabel \
|
||||
menuchoice methodname methodparam modifier mousebutton olink ooclass ooexception \
|
||||
oointerface option optional otheraddr othername package paramdef parameter personname \
|
||||
phrase pob postcode productname prompt property quote refpurpose replaceable \
|
||||
returnvalue revnumber sgmltag state street structfield structname subscript \
|
||||
superscript surname symbol systemitem token trademark type ulink userinput \
|
||||
uri varargs varname void wordasword xref year mathphrase member tag
|
||||
format inline
|
||||
|
||||
programlisting screen
|
||||
format verbatim
|
||||
entry-break = 0
|
||||
exit-break = 0
|
||||
|
||||
# This is needed so that the spacing inside those tags is kept.
|
||||
term cmdsynopsis arg
|
||||
normalize yes
|
||||
format block
|
||||
@@ -1,11 +0,0 @@
|
||||
# Functions reference {#chap-functions}
|
||||
|
||||
The nixpkgs repository has several utility functions to manipulate Nix expressions.
|
||||
|
||||
```{=include=} sections
|
||||
functions/library.md
|
||||
functions/generators.section.md
|
||||
functions/debug.section.md
|
||||
functions/prefer-remote-fetch.section.md
|
||||
functions/nix-gitignore.section.md
|
||||
```
|
||||
14
doc/functions.xml
Normal file
14
doc/functions.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<chapter xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
xml:id="chap-functions">
|
||||
<title>Functions reference</title>
|
||||
<para>
|
||||
The nixpkgs repository has several utility functions to manipulate Nix expressions.
|
||||
</para>
|
||||
<xi:include href="functions/library.xml" />
|
||||
<xi:include href="functions/generators.section.xml" />
|
||||
<xi:include href="functions/debug.section.xml" />
|
||||
<xi:include href="functions/prefer-remote-fetch.section.xml" />
|
||||
<xi:include href="functions/nix-gitignore.section.xml" />
|
||||
</chapter>
|
||||
@@ -16,7 +16,7 @@ let
|
||||
if v == true then ''"yes"''
|
||||
else if v == false then ''"no"''
|
||||
else if isString v then ''"${v}"''
|
||||
# and delegates all other values to the default generator
|
||||
# and delegats all other values to the default generator
|
||||
else generators.mkValueStringDefault {} v;
|
||||
} ":";
|
||||
};
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# Nixpkgs Library Functions {#sec-functions-library}
|
||||
|
||||
Nixpkgs provides a standard library at `pkgs.lib`, or through `import <nixpkgs/lib>`.
|
||||
|
||||
<!-- nixdoc-generated documentation must be appended here during build! -->
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user