Merge pull request #245243 from tweag/contributing-combining

Clean up contributing documentation

authored by

Silvan Mosberger and committed by
GitHub
50d11650 b392b28a

+1875 -1658
+9
.github/CODEOWNERS
··· 63 /.github/PULL_REQUEST_TEMPLATE.md @infinisil 64 /doc/contributing/ @fricklerhandwerk @infinisil 65 /doc/contributing/contributing-to-documentation.chapter.md @jtojnar @fricklerhandwerk @infinisil 66 67 # NixOS Internals 68 /nixos/default.nix @infinisil
··· 63 /.github/PULL_REQUEST_TEMPLATE.md @infinisil 64 /doc/contributing/ @fricklerhandwerk @infinisil 65 /doc/contributing/contributing-to-documentation.chapter.md @jtojnar @fricklerhandwerk @infinisil 66 + /lib/README.md @infinisil 67 + /doc/README.md @infinisil 68 + /nixos/README.md @infinisil 69 + /pkgs/README.md @infinisil 70 + /maintainers/README.md @infinisil 71 + 72 + # User-facing development documentation 73 + /doc/development.md @infinisil 74 + /doc/development @infinisil 75 76 # NixOS Internals 77 /nixos/default.nix @infinisil
+647 -70
CONTRIBUTING.md
··· 1 - # How to contribute 2 3 - Note: contributing implies licensing those contributions 4 - under the terms of [COPYING](COPYING), which is an MIT-like license. 5 6 - ## Opening issues 7 8 - * Make sure you have a [GitHub account](https://github.com/signup/free) 9 - * Make sure there is no open issue on the topic 10 - * [Submit a new issue](https://github.com/NixOS/nixpkgs/issues/new/choose) by choosing the kind of topic and fill out the template 11 12 - ## Submitting changes 13 14 - 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. 15 16 - Below is a short excerpt of some points in there: 17 18 - * Format the commit messages in the following way: 19 20 ``` 21 - (pkg-name | nixos/<module>): (from -> to | init at version | refactor | etc) 22 23 - (Motivation for change. Link to release notes. Additional information.) 24 ``` 25 26 - 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). 27 28 - Examples: 29 30 - * nginx: init at 2.0.1 31 - * firefox: 54.0.1 -> 55.0 32 - https://www.mozilla.org/en-US/firefox/55.0/releasenotes/ 33 - * nixos/hydra: add bazBaz option 34 35 - Dual baz behavior is needed to do foo. 36 - * nixos/nginx: refactor config generation 37 38 - The old config generation system used impure shell scripts and could break in specific circumstances (see #1234). 39 40 - * `meta.description` must: 41 - * Be short, just one sentence. 42 - * Be capitalized. 43 - * Not start with the package name. 44 - * More generally, it should not refer to the package name. 45 - * Not end with a period (or any punctuation for that matter). 46 - * Aim to inform while avoiding subjective language. 47 - * `meta.license` must be set and fit the upstream license. 48 - * If there is no upstream license, `meta.license` should default to `lib.licenses.unfree`. 49 - * If in doubt, try to contact the upstream developers for clarification. 50 - * `meta.mainProgram` must be set when appropriate. 51 - * `meta.maintainers` should be set. 52 53 - See the nixpkgs manual for more details on [standard meta-attributes](https://nixos.org/nixpkgs/manual/#sec-standard-meta-attributes). 54 55 - ## Writing good commit messages 56 57 - 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. 58 59 - 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. 60 61 - 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. 62 - 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`. 63 - 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). 64 65 - ## Testing changes 66 67 - To run the main types of tests locally: 68 69 - - Run package-internal tests with `nix-build --attr pkgs.PACKAGE.passthru.tests` 70 - - Run [NixOS tests](https://nixos.org/manual/nixos/unstable/#sec-nixos-tests) with `nix-build --attr nixosTest.NAME`, where `NAME` is the name of the test listed in `nixos/tests/all-tests.nix` 71 - - Run [global package tests](https://nixos.org/manual/nixpkgs/unstable/#sec-package-tests) with `nix-build --attr tests.PACKAGE`, where `PACKAGE` is the name of the test listed in `pkgs/test/default.nix` 72 - - See `lib/tests/NAME.nix` for instructions on running specific library tests 73 74 - ## Rebasing between branches (i.e. from master to staging) 75 76 From time to time, changes between branches must be rebased, for example, if the 77 number of new rebuilds they would cause is too large for the target branch. When ··· 115 git push origin feature --force-with-lease 116 ``` 117 118 - ### Something went wrong and a lot of people were pinged 119 120 It happens. Remember to be kind, especially to new contributors. 121 There is no way back, so the pull request should be closed and locked ··· 145 This is not a bulletproof method though, as OfBorg still does review requests even on draft PRs. 146 ``` 147 148 - ## Backporting changes 149 150 - 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). 151 152 - You can add a label such as `backport release-23.05` to a PR, so that merging it will 153 - automatically create a backport (via [a GitHub Action](.github/workflows/backport.yml)). 154 - This also works for pull requests that have already been merged, and might take a couple of minutes to trigger. 155 156 - You can also create the backport manually: 157 158 - 1. Take note of the commits in which the change was introduced into `master` branch. 159 - 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`. 160 - 3. Create a branch for your change, e.g. `git checkout -b backport`. 161 - 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. 162 - 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]`. 163 - 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. 164 165 - ## Criteria for Backporting changes 166 167 - Anything that does not cause user or downstream dependency regressions can be backported. This includes: 168 - - New Packages / Modules 169 - - Security / Patch updates 170 - - Version updates which include new functionality (but no breaking changes) 171 - - Services which require a client to be up-to-date regardless. (E.g. `spotify`, `steam`, or `discord`) 172 - - Security critical applications (E.g. `firefox`) 173 174 - ## Reviewing contributions 175 176 - See the nixpkgs manual for more details on how to [Review contributions](https://nixos.org/nixpkgs/manual/#chap-reviewing-contributions).
··· 1 + # Contributing to Nixpkgs 2 + 3 + This document is for people wanting to contribute to the implementation of Nixpkgs. 4 + 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). 5 + 6 + As such, a GitHub account is recommended, which you can sign up for [here](https://github.com/signup). 7 + See [here](https://discourse.nixos.org/t/about-the-patches-category/477) for how to contribute without a GitHub account. 8 + 9 + Additionally this document assumes that you already know how to use GitHub and Git. 10 + If that's not the case, we recommend learning about it first [here](https://docs.github.com/en/get-started/quickstart/hello-world). 11 + 12 + ## Overview 13 + [overview]: #overview 14 15 + This file contains general contributing information, but individual parts also have more specific information to them in their respective `README.md` files, linked here: 16 + - [`lib`](./lib/README.md): Sources and documentation of the [library functions](https://nixos.org/manual/nixpkgs/stable/#chap-functions) 17 + - [`maintainers`](./maintainers/README.md): Nixpkgs maintainer and team listings, maintainer scripts 18 + - [`pkgs`](./pkgs/README.md): Package and [builder](https://nixos.org/manual/nixpkgs/stable/#part-builders) definitions 19 + - [`doc`](./doc/README.md): Sources and infrastructure for the [Nixpkgs manual](https://nixos.org/manual/nixpkgs/stable/) 20 + - [`nixos`](./nixos/README.md): Implementation of [NixOS](https://nixos.org/manual/nixos/stable/) 21 22 + # How to's 23 24 + ## How to create pull requests 25 + [pr-create]: #how-to-create-pull-requests 26 27 + This section describes in some detail how changes can be made and proposed with pull requests. 28 29 + > **Note** 30 + > Be aware that contributing implies licensing those contributions under the terms of [COPYING](./COPYING), an MIT-like license. 31 32 + 0. Set up a local version of Nixpkgs to work with using GitHub and Git 33 + 1. [Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository) the [Nixpkgs repository](https://github.com/nixos/nixpkgs/). 34 + 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. 35 + 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). 36 37 + 1. Figure out the branch that should be used for this change by going through [this section][branch]. 38 + If in doubt use `master`, that's where most changes should go. 39 + This can be changed later by [rebasing][rebase]. 40 41 + 2. Create and switch to a new Git branch, ideally such that: 42 + - The name of the branch hints at the change you'd like to implement, e.g. `update-hello`. 43 + - The base of the branch includes the most recent changes on the base branch from step 1, we'll assume `master` here. 44 + 45 + ```bash 46 + # Make sure you have the latest changes from upstream Nixpkgs 47 + git fetch upstream 48 + 49 + # Create and switch to a new branch based off the master branch in Nixpkgs 50 + git switch --create update-hello upstream/master 51 + ``` 52 + 53 + 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: 54 + - The commit of the latest `nixpkgs-unstable` channel, available [here](https://channels.nixos.org/nixpkgs-unstable/git-revision). 55 + - 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'` 56 + - If you're using NixOS, the commit of your NixOS installation, available with `nixos-version --revision`. 57 + 58 + Once you have an appropriate commit you can use it instead of `upstream/master` in the above command: 59 + ```bash 60 + git switch --create update-hello <the desired base commit> 61 + ``` 62 + 63 + 3. Make the desired changes in the local Nixpkgs repository using an editor of your choice. 64 + Make sure to: 65 + - Adhere to both the [general code conventions][code-conventions], and the code conventions specific to the part you're making changes to. 66 + See the [overview section][overview] for more specific information. 67 + - Test the changes. 68 + See the [overview section][overview] for more specific information. 69 + - If necessary, document the change. 70 + See the [overview section][overview] for more specific information. 71 + 72 + 4. Commit your changes using `git commit`. 73 + Make sure to adhere to the [commit conventions](#commit-conventions). 74 + 75 + Repeat the steps 3-4 as many times as necessary. 76 + Advance to the next step if all the commits (viewable with `git log`) make sense together. 77 + 78 + 5. Push your commits to your fork of Nixpkgs. 79 + ``` 80 + git push --set-upstream origin HEAD 81 + ``` 82 + 83 + The above command will output a link that allows you to directly quickly do the next step: 84 + ``` 85 + remote: Create a pull request for 'update-hello' on GitHub by visiting: 86 + remote: https://github.com/myUser/nixpkgs/pull/new/update-hello 87 + ``` 88 + 89 + 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. 90 + Use the branch from step 2 as the pull requests base branch. 91 + Go through the [pull request template](#pull-request-template) in the pre-filled default description. 92 + 93 + 7. Respond to review comments, potential CI failures and potential merge conflicts by updating the pull request. 94 + Always keep the pull request in a mergeable state. 95 + 96 + 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. 97 + See [the OfBorg Readme](https://github.com/NixOS/ofborg#readme) for more details. 98 + 99 + - To add new commits, repeat steps 3-4 and push the result using 100 + ``` 101 + git push 102 + ``` 103 + 104 + - To change existing commits you will have to [rewrite Git history](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History). 105 + Useful Git commands that can help a lot with this are `git commit --patch --amend` and `git rebase --interactive`. 106 + With a rewritten history you need to force-push the commits using 107 + ``` 108 + git push --force-with-lease 109 + ``` 110 + 111 + - 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`. 112 + 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 113 + ``` 114 + git fetch upstream 115 + git rebase upstream/master 116 + git push --force-with-lease 117 + ``` 118 + 119 + - If you need to change the base branch of the pull request, you can do so by [rebasing][rebase]. 120 + 121 + 8. If your pull request is merged and [acceptable for releases][release-acceptable] you may [backport][pr-backport] the pull request. 122 + 123 + ### Pull request template 124 + [pr-template]: #pull-request-template 125 + 126 + 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. 127 + 128 + When a PR is created, it will be pre-populated with some checkboxes detailed below: 129 + 130 + #### Tested using sandboxing 131 + 132 + 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. 133 + 134 + 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. 135 + 136 + Depending if you use NixOS or other platforms you can use one of the following methods to enable sandboxing **before** building the package: 137 + 138 + - **Globally enable sandboxing on NixOS**: add the following to `configuration.nix` 139 + 140 + ```nix 141 + nix.settings.sandbox = true; 142 ``` 143 + 144 + - **Globally enable sandboxing on non-NixOS platforms**: add the following to: `/etc/nix/nix.conf` 145 146 + ```ini 147 + sandbox = true 148 ``` 149 150 + #### Built on platform(s) 151 + 152 + 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. 153 + 154 + #### Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests) 155 + 156 + 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). 157 + 158 + #### Tested compilation of all pkgs that depend on this change using `nixpkgs-review` 159 160 + 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. 161 162 + Review changes from pull request number 12345: 163 164 + ```ShellSession 165 + nix-shell -p nixpkgs-review --run "nixpkgs-review pr 12345" 166 + ``` 167 168 + Alternatively, with flakes (and analogously for the other commands below): 169 170 + ```ShellSession 171 + nix run nixpkgs#nixpkgs-review -- pr 12345 172 + ``` 173 174 + Review uncommitted changes: 175 176 + ```ShellSession 177 + nix-shell -p nixpkgs-review --run "nixpkgs-review wip" 178 + ``` 179 180 + Review changes from last commit: 181 182 + ```ShellSession 183 + nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD" 184 + ``` 185 186 + #### Tested execution of all binary files (usually in `./result/bin/`) 187 188 + 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. 189 190 + #### Meets Nixpkgs contribution standards 191 192 + 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. 193 194 + ### Rebasing between branches (i.e. from master to staging) 195 + [rebase]: #rebasing-between-branches-ie-from-master-to-staging 196 197 From time to time, changes between branches must be rebased, for example, if the 198 number of new rebuilds they would cause is too large for the target branch. When ··· 236 git push origin feature --force-with-lease 237 ``` 238 239 + #### Something went wrong and a lot of people were pinged 240 241 It happens. Remember to be kind, especially to new contributors. 242 There is no way back, so the pull request should be closed and locked ··· 266 This is not a bulletproof method though, as OfBorg still does review requests even on draft PRs. 267 ``` 268 269 + ## How to backport pull requests 270 + [pr-backport]: #how-to-backport-pull-requests 271 + 272 + 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. 273 + 274 + ### Automatically backporting changes 275 + 276 + > **Note** 277 + > You have to be a [Nixpkgs maintainer](./maintainers) to automatically create a backport pull request. 278 + 279 + Add the [`backport release-YY.MM` label](https://github.com/NixOS/nixpkgs/labels?q=backport) to the pull request on the `master` branch. 280 + 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. 281 + This can be done on both open or already merged pull requests. 282 + 283 + ### Manually backporting changes 284 + 285 + To manually create a backport pull request, follow [the standard pull request process][pr-create], with these notable differences: 286 + 287 + - Use `release-YY.MM` for the base branch, both for the local branch and the pull request. 288 + > **Warning** 289 + > Do not use the `nixos-YY.MM` branch, that is a branch pointing to the tested release channel commit 290 + 291 + - 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. 292 + 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. 293 + Here is [an example](https://github.com/nixos/nixpkgs/commit/5688c39af5a6c5f3d646343443683da880eaefb8) of this. 294 + 295 + > **Warning** 296 + > Ensure the commits exists on the master branch. 297 + > 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. 298 + 299 + - In the pull request description, link to the original pull request to `master`. 300 + The pull request title should include `[YY.MM]` matching the release you're backporting to. 301 + 302 + - 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. 303 + This way maintainers can keep track of missing backports easier. 304 + 305 + ## How to review pull requests 306 + [pr-review]: #how-to-review-pull-requests 307 + 308 + > **Warning** 309 + > 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). 310 + 311 + 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. 312 + 313 + 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). 314 + 315 + 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. 316 + 317 + 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. 318 + 319 + 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. 320 + 321 + 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. 322 + 323 + To get more information about how to review specific parts of Nixpkgs, refer to the documents linked to in the [overview section][overview]. 324 + 325 + 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. 326 + 327 + Container system, boot system and library changes are some examples of the pull requests fitting this category. 328 + 329 + ## How to merge pull requests 330 + [pr-merge]: #how-to-merge-pull-requests 331 + 332 + The *Nixpkgs committers* are people who have been given 333 + permission to merge. 334 + 335 + It is possible for community members that have enough knowledge and experience on a special topic to contribute by merging pull requests. 336 + 337 + In case the PR is stuck waiting for the original author to apply a trivial 338 + change (a typo, capitalisation change, etc.) and the author allowed the members 339 + to modify the PR, consider applying it yourself (or commit the existing review 340 + suggestion). You should pay extra attention to make sure the addition doesn't go 341 + against the idea of the original PR and would not be opposed by the author. 342 + 343 + <!-- 344 + 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. 345 + 346 + Please note that contributors with commit rights unactive for more than three months will have their commit rights revoked. 347 + --> 348 + 349 + 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. 350 + 351 + 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. 352 + 353 + # Flow of merged pull requests 354 + 355 + After a pull requests is merged, it eventually makes it to the [official Hydra CI](https://hydra.nixos.org/). 356 + Hydra regularly evaluates and builds Nixpkgs, updating [the official channels](http://channels.nixos.org/) when specific Hydra jobs succeeded. 357 + See [Nix Channel Status](https://status.nixos.org/) for the current channels and their state. 358 + Here's a brief overview of the main Git branches and what channels they're used for: 359 + 360 + - `master`: The main branch, used for the unstable channels such as `nixpkgs-unstable`, `nixos-unstable` and `nixos-unstable-small`. 361 + - `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`. 362 + 363 + When a channel is updated, a corresponding Git branch is also updated to point to the corresponding commit. 364 + 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). 365 + 366 + 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/). 367 + 368 + See [this section][branch] to know when to use the release branches. 369 + 370 + ## Staging 371 + [staging]: #staging 372 + 373 + The staging workflow exists to batch Hydra builds of many packages together. 374 + 375 + It works by directing commits that cause [mass rebuilds][mass-rebuild] to a separate `staging` branch that isn't directly built by Hydra. 376 + 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). 377 + The `staging-next` branch should then only receive direct commits in order to fix Hydra builds. 378 + 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). 379 + This is done manually in order to ensure it's a good use of Hydra's computing resources. 380 + By keeping the `staging-next` branch separate from `staging`, this batching does not block developers from merging changes into `staging`. 381 + 382 + 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`. 383 + This is implemented using GitHub workflows [here](.github/workflows/periodic-merge-6h.yml) and [here](.github/workflows/periodic-merge-24h.yml). 384 + 385 + > **Note** 386 + > Changes must be sufficiently tested before being merged into any branch. 387 + > Hydra builds should not be used as testing platform. 388 + 389 + Here is a Git history diagram showing the flow of commits between the three branches: 390 + ```mermaid 391 + %%{init: { 392 + 'theme': 'base', 393 + 'themeVariables': { 394 + 'gitInv0': '#ff0000', 395 + 'gitInv1': '#ff0000', 396 + 'git2': '#ff4444', 397 + 'commitLabelFontSize': '15px' 398 + }, 399 + 'gitGraph': { 400 + 'showCommitLabel':true, 401 + 'mainBranchName': 'master', 402 + 'rotateCommitLabel': true 403 + } 404 + } }%% 405 + gitGraph 406 + commit id:" " 407 + branch staging-next 408 + branch staging 409 + 410 + checkout master 411 + checkout staging 412 + checkout master 413 + commit id:" " 414 + checkout staging-next 415 + merge master id:"automatic" 416 + checkout staging 417 + merge staging-next id:"automatic " 418 + 419 + checkout staging-next 420 + merge staging type:HIGHLIGHT id:"manual" 421 + commit id:"fixup" 422 + 423 + checkout master 424 + checkout staging 425 + checkout master 426 + commit id:" " 427 + checkout staging-next 428 + merge master id:"automatic " 429 + checkout staging 430 + merge staging-next id:"automatic " 431 + 432 + checkout staging-next 433 + commit id:"fixup " 434 + checkout master 435 + merge staging-next type:HIGHLIGHT id:"manual (PR)" 436 + ``` 437 + 438 + 439 + Here's an overview of the different branches: 440 + 441 + | branch | `master` | `staging` | `staging-next` | 442 + | --- | --- | --- | --- | 443 + | Used for development | ✔️ | ✔️ | ❌ | 444 + | Built by Hydra | ✔️ | ❌ | ✔️ | 445 + | [Mass rebuilds][mass-rebuild] | ❌ | ✔️ | ⚠️ Only to fix Hydra builds | 446 + | Critical security fixes | ✔️ for non-mass-rebuilds | ❌ | ✔️ for mass-rebuilds | 447 + | Automatically merged into | `staging-next` | - | `staging` | 448 + | Manually merged into | - | `staging-next` | `master` | 449 + 450 + The staging workflow is used for all main branches, `master` and `release-YY.MM`, with corresponding names: 451 + - `master`/`release-YY.MM` 452 + - `staging`/`staging-YY.MM` 453 + - `staging-next`/`staging-next-YY.MM` 454 + 455 + # Conventions 456 + 457 + ## Branch conventions 458 + <!-- This section is relevant to both contributors and reviewers --> 459 + [branch]: #branch-conventions 460 + 461 + Most changes should go to the `master` branch, but sometimes other branches should be used instead. 462 + Use the following decision process to figure out which one it should be: 463 + 464 + Is the change [acceptable for releases][release-acceptable] and do you wish to have the change in the release? 465 + - No: Use the `master` branch, do not backport the pull request. 466 + - Yes: Can the change be implemented the same way on the `master` and release branches? 467 + For example, a packages major version might differ between the `master` and release branches, such that separate security patches are required. 468 + - Yes: Use the `master` branch and [backport the pull request](#backporting-changes). 469 + - No: Create separate pull requests to the `master` and `release-XX.YY` branches. 470 + 471 + Furthermore, if the change causes a [mass rebuild][mass-rebuild], use the appropriate staging branch instead: 472 + - Mass rebuilds to `master` should go to `staging` instead. 473 + - Mass rebuilds to `release-XX.YY` should go to `staging-XX.YY` instead. 474 + 475 + See [this section][staging] for more details about such changes propagate between the branches. 476 + 477 + ### Changes acceptable for releases 478 + [release-acceptable]: #changes-acceptable-for-releases 479 + 480 + Only changes to supported releases may be accepted. 481 + The oldest supported release (`YYMM`) can be found using 482 + ``` 483 + nix-instantiate --eval -A lib.trivial.oldestSupportedRelease 484 + ``` 485 + 486 + The release branches should generally not receive any breaking changes, both for the Nix expressions and derivations. 487 + So these changes are acceptable to backport: 488 + - New packages, modules and functions 489 + - Security fixes 490 + - Package version updates 491 + - Patch versions with fixes 492 + - Minor versions with new functionality, but no breaking changes 493 + 494 + In addition, major package version updates with breaking changes are also acceptable for: 495 + - Services that would fail without up-to-date client software, such as `spotify`, `steam`, and `discord` 496 + - Security critical applications, such as `firefox` and `chromium` 497 + 498 + ### Changes causing mass rebuilds 499 + [mass-rebuild]: #changes-causing-mass-rebuilds 500 + 501 + Which changes cause mass rebuilds is not formally defined. 502 + 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. 503 + As a rule of thumb, if the number of rebuilds is **over 500**, it can be considered a mass rebuild. 504 + 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). 505 + 506 + ## Commit conventions 507 + [commit-conventions]: #commit-conventions 508 + 509 + - Create a commit for each logical unit. 510 + 511 + - Check for unnecessary whitespace with `git diff --check` before committing. 512 + 513 + - If you have commits `pkg-name: oh, forgot to insert whitespace`: squash commits in this case. Use `git rebase -i`. 514 + 515 + - Format the commit messages in the following way: 516 + 517 + ``` 518 + (pkg-name | nixos/<module>): (from -> to | init at version | refactor | etc) 519 + 520 + (Motivation for change. Link to release notes. Additional information.) 521 + ``` 522 + 523 + 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). 524 + 525 + Examples: 526 + 527 + * nginx: init at 2.0.1 528 + * firefox: 54.0.1 -> 55.0 529 + 530 + https://www.mozilla.org/en-US/firefox/55.0/releasenotes/ 531 + * nixos/hydra: add bazBaz option 532 + 533 + Dual baz behavior is needed to do foo. 534 + * nixos/nginx: refactor config generation 535 + 536 + The old config generation system used impure shell scripts and could break in specific circumstances (see #1234). 537 + 538 + ### Writing good commit messages 539 + 540 + 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. 541 + 542 + 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. 543 + 544 + 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. 545 546 + ## Code conventions 547 + [code-conventions]: #code-conventions 548 549 + ### Release notes 550 551 + 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). 552 553 + ### File naming and organisation 554 555 + 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`. 556 557 + ### Syntax 558 + 559 + - Use 2 spaces of indentation per indentation level in Nix expressions, 4 spaces in shell scripts. 560 561 + - 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. 562 563 + - 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). 564 + 565 + - Function calls with attribute set arguments are written as 566 + 567 + ```nix 568 + foo { 569 + arg = ...; 570 + } 571 + ``` 572 + 573 + not 574 + 575 + ```nix 576 + foo 577 + { 578 + arg = ...; 579 + } 580 + ``` 581 + 582 + Also fine is 583 + 584 + ```nix 585 + foo { arg = ...; } 586 + ``` 587 + 588 + if it's a short call. 589 + 590 + - In attribute sets or lists that span multiple lines, the attribute names or list elements should be aligned: 591 + 592 + ```nix 593 + # A long list. 594 + list = [ 595 + elem1 596 + elem2 597 + elem3 598 + ]; 599 + 600 + # A long attribute set. 601 + attrs = { 602 + attr1 = short_expr; 603 + attr2 = 604 + if true then big_expr else big_expr; 605 + }; 606 + 607 + # Combined 608 + listOfAttrs = [ 609 + { 610 + attr1 = 3; 611 + attr2 = "fff"; 612 + } 613 + { 614 + attr1 = 5; 615 + attr2 = "ggg"; 616 + } 617 + ]; 618 + ``` 619 + 620 + - Short lists or attribute sets can be written on one line: 621 + 622 + ```nix 623 + # A short list. 624 + list = [ elem1 elem2 elem3 ]; 625 + 626 + # A short set. 627 + attrs = { x = 1280; y = 1024; }; 628 + ``` 629 + 630 + - Breaking in the middle of a function argument can give hard-to-read code, like 631 + 632 + ```nix 633 + someFunction { x = 1280; 634 + y = 1024; } otherArg 635 + yetAnotherArg 636 + ``` 637 + 638 + (especially if the argument is very large, spanning multiple lines). 639 + 640 + Better: 641 + 642 + ```nix 643 + someFunction 644 + { x = 1280; y = 1024; } 645 + otherArg 646 + yetAnotherArg 647 + ``` 648 + 649 + or 650 + 651 + ```nix 652 + let res = { x = 1280; y = 1024; }; 653 + in someFunction res otherArg yetAnotherArg 654 + ``` 655 + 656 + - The bodies of functions, asserts, and withs are not indented to prevent a lot of superfluous indentation levels, i.e. 657 + 658 + ```nix 659 + { arg1, arg2 }: 660 + assert system == "i686-linux"; 661 + stdenv.mkDerivation { ... 662 + ``` 663 + 664 + not 665 + 666 + ```nix 667 + { arg1, arg2 }: 668 + assert system == "i686-linux"; 669 + stdenv.mkDerivation { ... 670 + ``` 671 + 672 + - Function formal arguments are written as: 673 + 674 + ```nix 675 + { arg1, arg2, arg3 }: 676 + ``` 677 + 678 + but if they don't fit on one line they're written as: 679 + 680 + ```nix 681 + { arg1, arg2, arg3 682 + , arg4, ... 683 + , # Some comment... 684 + argN 685 + }: 686 + ``` 687 + 688 + - Functions should list their expected arguments as precisely as possible. That is, write 689 + 690 + ```nix 691 + { stdenv, fetchurl, perl }: ... 692 + ``` 693 + 694 + instead of 695 + 696 + ```nix 697 + args: with args; ... 698 + ``` 699 + 700 + or 701 + 702 + ```nix 703 + { stdenv, fetchurl, perl, ... }: ... 704 + ``` 705 + 706 + 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: 707 + 708 + ```nix 709 + { stdenv, doCoverageAnalysis ? false, ... } @ args: 710 + 711 + stdenv.mkDerivation (args // { 712 + ... if doCoverageAnalysis then "bla" else "" ... 713 + }) 714 + ``` 715 + 716 + instead of 717 + 718 + ```nix 719 + args: 720 + 721 + args.stdenv.mkDerivation (args // { 722 + ... if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "" ... 723 + }) 724 + ``` 725 + 726 + - Unnecessary string conversions should be avoided. Do 727 + 728 + ```nix 729 + rev = version; 730 + ``` 731 + 732 + instead of 733 + 734 + ```nix 735 + rev = "${version}"; 736 + ``` 737 + 738 + - Building lists conditionally _should_ be done with `lib.optional(s)` instead of using `if cond then [ ... ] else null` or `if cond then [ ... ] else [ ]`. 739 + 740 + ```nix 741 + buildInputs = lib.optional stdenv.isDarwin iconv; 742 + ``` 743 + 744 + instead of 745 + 746 + ```nix 747 + buildInputs = if stdenv.isDarwin then [ iconv ] else null; 748 + ``` 749 + 750 + As an exception, an explicit conditional expression with null can be used when fixing a important bug without triggering a mass rebuild. 751 + If this is done a follow up pull request _should_ be created to change the code to `lib.optional(s)`. 752 + 753 + - Arguments should be listed in the order they are used, with the exception of `lib`, which always goes first.
+1 -20
README.md
··· 70 page gives a sense of the project activity. 71 72 Community contributions are always welcome through GitHub Issues and 73 - Pull Requests. When pull requests are made, our tooling automation bot, 74 - [OfBorg](https://github.com/NixOS/ofborg) will perform various checks 75 - to help ensure expression quality. 76 - 77 - The *Nixpkgs maintainers* are people who have assigned themselves to 78 - maintain specific individual packages. We encourage people who care 79 - about a package to assign themselves as a maintainer. When a pull 80 - request is made against a package, OfBorg will notify the appropriate 81 - maintainer(s). The *Nixpkgs committers* are people who have been given 82 - permission to merge. 83 - 84 - Most contributions are based on and merged into these branches: 85 - 86 - * `master` is the main branch where all small contributions go 87 - * `staging` is branched from master, changes that have a big impact on 88 - Hydra builds go to this branch 89 - * `staging-next` is branched from staging and only fixes to stabilize 90 - and security fixes with a big impact on Hydra builds should be 91 - contributed to this branch. This branch is merged into master when 92 - deemed of sufficiently high quality 93 94 For more information about contributing to the project, please visit 95 the [contributing page](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
··· 70 page gives a sense of the project activity. 71 72 Community contributions are always welcome through GitHub Issues and 73 + Pull Requests. 74 75 For more information about contributing to the project, please visit 76 the [contributing page](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
+107 -4
doc/README.md
··· 1 - 2 - # Nixpkgs/doc 3 4 This directory houses the sources files for the Nixpkgs manual. 5 ··· 7 8 [Docs for Nixpkgs stable](https://nixos.org/manual/nixpkgs/stable/) are also available. 9 10 - If you want to contribute to the documentation, [here's how to do it](https://nixos.org/manual/nixpkgs/unstable/#chap-contributing). 11 12 - If you're only getting started with Nix, go to [nixos.org/learn](https://nixos.org/learn).
··· 1 + # Contributing to the Nixpkgs manual 2 3 This directory houses the sources files for the Nixpkgs manual. 4 ··· 6 7 [Docs for Nixpkgs stable](https://nixos.org/manual/nixpkgs/stable/) are also available. 8 9 + If you're only getting started with Nix, go to [nixos.org/learn](https://nixos.org/learn). 10 + 11 + ## Contributing to this documentation 12 + 13 + You can quickly check your edits with `nix-build`: 14 + 15 + ```ShellSession 16 + $ cd /path/to/nixpkgs 17 + $ nix-build doc 18 + ``` 19 + 20 + If the build succeeds, the manual will be in `./result/share/doc/nixpkgs/manual.html`. 21 + 22 + ### devmode 23 + 24 + The shell in the manual source directory makes available a command, `devmode`. 25 + It is a daemon, that: 26 + 1. watches the manual's source for changes and when they occur — rebuilds 27 + 2. HTTP serves the manual, injecting a script that triggers reload on changes 28 + 3. opens the manual in the default browser 29 + 30 + ## Syntax 31 + 32 + 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. 33 + 34 + Additional syntax extensions are available, all of which can be used in NixOS option documentation. The following extensions are currently used: 35 + 36 + #### Tables 37 + 38 + Tables, using the [GitHub-flavored Markdown syntax](https://github.github.com/gfm/#tables-extension-). 39 + 40 + #### Anchors 41 + 42 + 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). 43 + 44 + It uses the widely compatible [header attributes](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/attributes.md) syntax: 45 + 46 + ```markdown 47 + ## Syntax {#sec-contributing-markup} 48 + ``` 49 + 50 + > **Note** 51 + > NixOS option documentation does not support headings in general. 52 + 53 + #### Inline Anchors 54 + 55 + Allow linking arbitrary place in the text (e.g. individual list items, sentences…). 56 + 57 + 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): 58 + 59 + ```markdown 60 + - []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`. 61 + ``` 62 + 63 + #### Automatic links 64 + 65 + If you **omit a link text** for a link pointing to a section, the text will be substituted automatically. For example `[](#chap-contributing)`. 66 + 67 + This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing). 68 + 69 + #### Roles 70 + 71 + 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). 72 + 73 + A few markups for other kinds of literals are also available: 74 + 75 + - `` {command}`rm -rfi` `` 76 + - `` {env}`XDG_DATA_DIRS` `` 77 + - `` {file}`/etc/passwd` `` 78 + - `` {option}`networking.useDHCP` `` 79 + - `` {var}`/etc/passwd` `` 80 + 81 + These literal kinds are used mostly in NixOS option documentation. 82 + 83 + 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. 84 + 85 + #### Admonitions 86 + 87 + Set off from the text to bring attention to something. 88 + 89 + It uses pandoc’s [fenced `div`s syntax](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/fenced_divs.md): 90 + 91 + ```markdown 92 + ::: {.warning} 93 + This is a warning 94 + ::: 95 + ``` 96 + 97 + The following are supported: 98 + 99 + - [`caution`](https://tdg.docbook.org/tdg/5.0/caution.html) 100 + - [`important`](https://tdg.docbook.org/tdg/5.0/important.html) 101 + - [`note`](https://tdg.docbook.org/tdg/5.0/note.html) 102 + - [`tip`](https://tdg.docbook.org/tdg/5.0/tip.html) 103 + - [`warning`](https://tdg.docbook.org/tdg/5.0/warning.html) 104 + 105 + #### [Definition lists](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/definition_lists.md) 106 + 107 + For defining a group of terms: 108 + 109 + ```markdown 110 + pear 111 + : green or yellow bulbous fruit 112 113 + watermelon 114 + : green fruit with red flesh 115 + ```
+17 -647
doc/contributing/coding-conventions.chapter.md
··· 1 # Coding conventions {#chap-conventions} 2 3 - ## Syntax {#sec-syntax} 4 - 5 - - Use 2 spaces of indentation per indentation level in Nix expressions, 4 spaces in shell scripts. 6 - 7 - - 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. 8 - 9 - - 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). 10 - 11 - - Function calls with attribute set arguments are written as 12 - 13 - ```nix 14 - foo { 15 - arg = ...; 16 - } 17 - ``` 18 - 19 - not 20 - 21 - ```nix 22 - foo 23 - { 24 - arg = ...; 25 - } 26 - ``` 27 - 28 - Also fine is 29 - 30 - ```nix 31 - foo { arg = ...; } 32 - ``` 33 - 34 - if it's a short call. 35 - 36 - - In attribute sets or lists that span multiple lines, the attribute names or list elements should be aligned: 37 - 38 - ```nix 39 - # A long list. 40 - list = [ 41 - elem1 42 - elem2 43 - elem3 44 - ]; 45 - 46 - # A long attribute set. 47 - attrs = { 48 - attr1 = short_expr; 49 - attr2 = 50 - if true then big_expr else big_expr; 51 - }; 52 - 53 - # Combined 54 - listOfAttrs = [ 55 - { 56 - attr1 = 3; 57 - attr2 = "fff"; 58 - } 59 - { 60 - attr1 = 5; 61 - attr2 = "ggg"; 62 - } 63 - ]; 64 - ``` 65 - 66 - - Short lists or attribute sets can be written on one line: 67 - 68 - ```nix 69 - # A short list. 70 - list = [ elem1 elem2 elem3 ]; 71 - 72 - # A short set. 73 - attrs = { x = 1280; y = 1024; }; 74 - ``` 75 - 76 - - Breaking in the middle of a function argument can give hard-to-read code, like 77 - 78 - ```nix 79 - someFunction { x = 1280; 80 - y = 1024; } otherArg 81 - yetAnotherArg 82 - ``` 83 - 84 - (especially if the argument is very large, spanning multiple lines). 85 - 86 - Better: 87 - 88 - ```nix 89 - someFunction 90 - { x = 1280; y = 1024; } 91 - otherArg 92 - yetAnotherArg 93 - ``` 94 - 95 - or 96 - 97 - ```nix 98 - let res = { x = 1280; y = 1024; }; 99 - in someFunction res otherArg yetAnotherArg 100 - ``` 101 - 102 - - The bodies of functions, asserts, and withs are not indented to prevent a lot of superfluous indentation levels, i.e. 103 - 104 - ```nix 105 - { arg1, arg2 }: 106 - assert system == "i686-linux"; 107 - stdenv.mkDerivation { ... 108 - ``` 109 - 110 - not 111 - 112 - ```nix 113 - { arg1, arg2 }: 114 - assert system == "i686-linux"; 115 - stdenv.mkDerivation { ... 116 - ``` 117 - 118 - - Function formal arguments are written as: 119 - 120 - ```nix 121 - { arg1, arg2, arg3 }: 122 - ``` 123 - 124 - but if they don't fit on one line they're written as: 125 - 126 - ```nix 127 - { arg1, arg2, arg3 128 - , arg4, ... 129 - , # Some comment... 130 - argN 131 - }: 132 - ``` 133 - 134 - - Functions should list their expected arguments as precisely as possible. That is, write 135 - 136 - ```nix 137 - { stdenv, fetchurl, perl }: ... 138 - ``` 139 - 140 - instead of 141 - 142 - ```nix 143 - args: with args; ... 144 - ``` 145 - 146 - or 147 - 148 - ```nix 149 - { stdenv, fetchurl, perl, ... }: ... 150 - ``` 151 - 152 - 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: 153 - 154 - ```nix 155 - { stdenv, doCoverageAnalysis ? false, ... } @ args: 156 - 157 - stdenv.mkDerivation (args // { 158 - ... if doCoverageAnalysis then "bla" else "" ... 159 - }) 160 - ``` 161 - 162 - instead of 163 - 164 - ```nix 165 - args: 166 - 167 - args.stdenv.mkDerivation (args // { 168 - ... if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "" ... 169 - }) 170 - ``` 171 - 172 - - Unnecessary string conversions should be avoided. Do 173 - 174 - ```nix 175 - rev = version; 176 - ``` 177 - 178 - instead of 179 - 180 - ```nix 181 - rev = "${version}"; 182 - ``` 183 - 184 - - Building lists conditionally _should_ be done with `lib.optional(s)` instead of using `if cond then [ ... ] else null` or `if cond then [ ... ] else [ ]`. 185 - 186 - ```nix 187 - buildInputs = lib.optional stdenv.isDarwin iconv; 188 - ``` 189 - 190 - instead of 191 192 - ```nix 193 - buildInputs = if stdenv.isDarwin then [ iconv ] else null; 194 - ``` 195 196 - As an exception, an explicit conditional expression with null can be used when fixing a important bug without triggering a mass rebuild. 197 - If this is done a follow up pull request _should_ be created to change the code to `lib.optional(s)`. 198 - 199 - - Arguments should be listed in the order they are used, with the exception of `lib`, which always goes first. 200 201 ## Package naming {#sec-package-naming} 202 203 - 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. 204 - 205 - In Nixpkgs, there are generally three different names associated with a package: 206 - 207 - - The `pname` attribute of the derivation. This is what most users see, in particular when using `nix-env`. 208 - 209 - - 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`. 210 - 211 - - The filename for (the directory containing) the Nix expression. 212 - 213 - 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`. 214 - 215 - There are a few naming guidelines: 216 - 217 - - The `pname` attribute _should_ be identical to the upstream package name. 218 - 219 - - The `pname` and the `version` attribute _must not_ contain uppercase letters — e.g., `"mplayer" instead of `"MPlayer"`. 220 - 221 - - The `version` attribute _must_ start with a digit e.g`"0.3.1rc2". 222 - 223 - - If a package is a commit from a repository without a version assigned, then the `version` attribute _should_ be the latest upstream version preceding that commit, followed by `-unstable-` and the date of the (fetched) commit. The date _must_ be in `"YYYY-MM-DD"` format. 224 - 225 - Example: Given a project had its latest releases `2.2` in November 2021, and `3.0` in January 2022, a commit authored on March 15, 2022 for an upcoming bugfix release `2.2.1` would have `version = "2.2-unstable-2022-03-15"`. 226 - 227 - - 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. 228 - 229 - - 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) 230 231 ## File naming and organisation {#sec-organisation} 232 233 - 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`. 234 - 235 - ### Hierarchy {#sec-hierarchy} 236 - 237 - 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`. 238 - 239 - When in doubt, consider refactoring the `pkgs/` tree, e.g. creating new categories or splitting up an existing category. 240 - 241 - **If it’s used to support _software development_:** 242 - 243 - - **If it’s a _library_ used by other packages:** 244 - 245 - - `development/libraries` (e.g. `libxml2`) 246 - 247 - - **If it’s a _compiler_:** 248 - 249 - - `development/compilers` (e.g. `gcc`) 250 - 251 - - **If it’s an _interpreter_:** 252 - 253 - - `development/interpreters` (e.g. `guile`) 254 - 255 - - **If it’s a (set of) development _tool(s)_:** 256 - 257 - - **If it’s a _parser generator_ (including lexers):** 258 - 259 - - `development/tools/parsing` (e.g. `bison`, `flex`) 260 - 261 - - **If it’s a _build manager_:** 262 - 263 - - `development/tools/build-managers` (e.g. `gnumake`) 264 - 265 - - **If it’s a _language server_:** 266 - 267 - - `development/tools/language-servers` (e.g. `ccls` or `rnix-lsp`) 268 - 269 - - **Else:** 270 - 271 - - `development/tools/misc` (e.g. `binutils`) 272 - 273 - - **Else:** 274 - 275 - - `development/misc` 276 - 277 - **If it’s a (set of) _tool(s)_:** 278 - 279 - (A tool is a relatively small program, especially one intended to be used non-interactively.) 280 - 281 - - **If it’s for _networking_:** 282 - 283 - - `tools/networking` (e.g. `wget`) 284 - 285 - - **If it’s for _text processing_:** 286 - 287 - - `tools/text` (e.g. `diffutils`) 288 - 289 - - **If it’s a _system utility_, i.e., something related or essential to the operation of a system:** 290 - 291 - - `tools/system` (e.g. `cron`) 292 - 293 - - **If it’s an _archiver_ (which may include a compression function):** 294 - 295 - - `tools/archivers` (e.g. `zip`, `tar`) 296 - 297 - - **If it’s a _compression_ program:** 298 - 299 - - `tools/compression` (e.g. `gzip`, `bzip2`) 300 - 301 - - **If it’s a _security_-related program:** 302 - 303 - - `tools/security` (e.g. `nmap`, `gnupg`) 304 - 305 - - **Else:** 306 - 307 - - `tools/misc` 308 - 309 - **If it’s a _shell_:** 310 - 311 - - `shells` (e.g. `bash`) 312 - 313 - **If it’s a _server_:** 314 - 315 - - **If it’s a web server:** 316 - 317 - - `servers/http` (e.g. `apache-httpd`) 318 - 319 - - **If it’s an implementation of the X Windowing System:** 320 - 321 - - `servers/x11` (e.g. `xorg` — this includes the client libraries and programs) 322 - 323 - - **Else:** 324 - 325 - - `servers/misc` 326 - 327 - **If it’s a _desktop environment_:** 328 - 329 - - `desktops` (e.g. `kde`, `gnome`, `enlightenment`) 330 - 331 - **If it’s a _window manager_:** 332 - 333 - - `applications/window-managers` (e.g. `awesome`, `stumpwm`) 334 - 335 - **If it’s an _application_:** 336 - 337 - A (typically large) program with a distinct user interface, primarily used interactively. 338 - 339 - - **If it’s a _version management system_:** 340 - 341 - - `applications/version-management` (e.g. `subversion`) 342 - 343 - - **If it’s a _terminal emulator_:** 344 - 345 - - `applications/terminal-emulators` (e.g. `alacritty` or `rxvt` or `termite`) 346 - 347 - - **If it’s a _file manager_:** 348 - 349 - - `applications/file-managers` (e.g. `mc` or `ranger` or `pcmanfm`) 350 - 351 - - **If it’s for _video playback / editing_:** 352 - 353 - - `applications/video` (e.g. `vlc`) 354 - 355 - - **If it’s for _graphics viewing / editing_:** 356 - 357 - - `applications/graphics` (e.g. `gimp`) 358 - 359 - - **If it’s for _networking_:** 360 - 361 - - **If it’s a _mailreader_:** 362 - 363 - - `applications/networking/mailreaders` (e.g. `thunderbird`) 364 - 365 - - **If it’s a _newsreader_:** 366 - 367 - - `applications/networking/newsreaders` (e.g. `pan`) 368 - 369 - - **If it’s a _web browser_:** 370 - 371 - - `applications/networking/browsers` (e.g. `firefox`) 372 - 373 - - **Else:** 374 - 375 - - `applications/networking/misc` 376 - 377 - - **Else:** 378 - 379 - - `applications/misc` 380 - 381 - **If it’s _data_ (i.e., does not have a straight-forward executable semantics):** 382 - 383 - - **If it’s a _font_:** 384 - 385 - - `data/fonts` 386 - 387 - - **If it’s an _icon theme_:** 388 - 389 - - `data/icons` 390 - 391 - - **If it’s related to _SGML/XML processing_:** 392 - 393 - - **If it’s an _XML DTD_:** 394 - 395 - - `data/sgml+xml/schemas/xml-dtd` (e.g. `docbook`) 396 - 397 - - **If it’s an _XSLT stylesheet_:** 398 - 399 - (Okay, these are executable...) 400 - 401 - - `data/sgml+xml/stylesheets/xslt` (e.g. `docbook-xsl`) 402 - 403 - - **If it’s a _theme_ for a _desktop environment_, a _window manager_ or a _display manager_:** 404 - 405 - - `data/themes` 406 - 407 - **If it’s a _game_:** 408 - 409 - - `games` 410 - 411 - **Else:** 412 - 413 - - `misc` 414 415 ### Versioning {#sec-versioning} 416 417 - 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. 418 - 419 - 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`. 420 - 421 - All versions of a package _must_ be included in `all-packages.nix` to make sure that they evaluate correctly. 422 423 ## Fetching Sources {#sec-sources} 424 425 - 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. 426 - 427 - You can find many source fetch helpers in `pkgs/build-support/fetch*`. 428 - 429 - 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: 430 - 431 - - Bad: Uses `git://` which won't be proxied. 432 - 433 - ```nix 434 - src = fetchgit { 435 - url = "git@github.com:NixOS/nix.git" 436 - url = "git://github.com/NixOS/nix.git"; 437 - rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; 438 - hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ="; 439 - } 440 - ``` 441 - 442 - - Better: This is ok, but an archive fetch will still be faster. 443 - 444 - ```nix 445 - src = fetchgit { 446 - url = "https://github.com/NixOS/nix.git"; 447 - rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; 448 - hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ="; 449 - } 450 - ``` 451 - 452 - - Best: Fetches a snapshot archive and you get the rev you want. 453 - 454 - ```nix 455 - src = fetchFromGitHub { 456 - owner = "NixOS"; 457 - repo = "nix"; 458 - rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; 459 - hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ="; 460 - } 461 - ``` 462 - 463 - 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`. 464 - 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). 465 - 466 - Find the value to put as `hash` by running `nix-shell -p nix-prefetch-github --run "nix-prefetch-github --rev 1f795f9f44607cc5bec70d1300150bfefcef2aae NixOS nix"`. 467 468 ## Obtaining source hash {#sec-source-hashes} 469 470 - Preferred source hash type is sha256. There are several ways to get it. 471 - 472 - 1. Prefetch URL (with `nix-prefetch-XXX URL`, where `XXX` is one of `url`, `git`, `hg`, `cvs`, `bzr`, `svn`). Hash is printed to stdout. 473 - 474 - 2. Prefetch by package source (with `nix-prefetch-url '<nixpkgs>' -A PACKAGE.src`, where `PACKAGE` is package attribute name). Hash is printed to stdout. 475 - 476 - 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). 477 - 478 - 3. Upstream provided hash: use it when upstream provides `sha256` or `sha512` (when upstream provides `md5`, don't use it, compute `sha256` instead). 479 - 480 - 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. 481 - 482 - You can convert between formats with nix-hash, for example: 483 - 484 - ```ShellSession 485 - $ nix-hash --type sha256 --to-base32 HASH 486 - ``` 487 - 488 - 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. 489 - 490 - 5. Fake hash: set the hash to one of 491 - 492 - - `""` 493 - - `lib.fakeHash` 494 - - `lib.fakeSha256` 495 - - `lib.fakeSha512` 496 - 497 - in the package expression, attempt build and extract correct hash from error messages. 498 - 499 - ::: {.warning} 500 - You must use one of these four fake hashes and not some arbitrarily-chosen hash. 501 - 502 - See [](#sec-source-hashes-security). 503 - ::: 504 - 505 - 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. 506 - 507 508 ### Obtaining hashes securely {#sec-source-hashes-security} 509 510 - 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: 511 - 512 - - `http://` URLs are not secure to prefetch hash from; 513 - 514 - - hashes from upstream (in method 3) should be obtained via secure protocol; 515 - 516 - - `https://` URLs are secure in methods 1, 2, 3; 517 - 518 - - `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. 519 520 ## Patches {#sec-patches} 521 522 - Patches available online should be retrieved using `fetchpatch`. 523 - 524 - ```nix 525 - patches = [ 526 - (fetchpatch { 527 - name = "fix-check-for-using-shared-freetype-lib.patch"; 528 - url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=8f5d285"; 529 - hash = "sha256-uRcxaCjd+WAuGrXOmGfFeu79cUILwkRdBu48mwcBE7g="; 530 - }) 531 - ]; 532 - ``` 533 - 534 - 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. 535 - 536 - 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. 537 - 538 - ```nix 539 - patches = [ ./0001-changes.patch ]; 540 - ``` 541 - 542 - If you do need to do create this sort of patch file, one way to do so is with git: 543 - 544 - 1. Move to the root directory of the source code you're patching. 545 - 546 - ```ShellSession 547 - $ cd the/program/source 548 - ``` 549 - 550 - 2. If a git repository is not already present, create one and stage all of the source files. 551 - 552 - ```ShellSession 553 - $ git init 554 - $ git add . 555 - ``` 556 - 557 - 3. Edit some files to make whatever changes need to be included in the patch. 558 - 559 - 4. Use git to create a diff, and pipe the output to a patch file: 560 - 561 - ```ShellSession 562 - $ git diff -a > nixpkgs/pkgs/the/package/0001-changes.patch 563 - ``` 564 565 ## Package tests {#sec-package-tests} 566 567 - Tests are important to ensure quality and make reviews and automatic updates easy. 568 - 569 - The following types of tests exists: 570 - 571 - * [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. 572 - * 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. 573 - * The **`checkPhase` of a package**, which should execute the unit tests that are included in the source code of a package. 574 - 575 - 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). 576 577 ### Writing inline package tests {#ssec-inline-package-tests-writing} 578 579 - For very simple tests, they can be written inline: 580 - 581 - ```nix 582 - { …, yq-go }: 583 - 584 - buildGoModule rec { 585 - 586 - 587 - passthru.tests = { 588 - simple = runCommand "${pname}-test" {} '' 589 - echo "test: 1" | ${yq-go}/bin/yq eval -j > $out 590 - [ "$(cat $out | tr -d $'\n ')" = '{"test":1}' ] 591 - ''; 592 - }; 593 - } 594 - ``` 595 596 ### Writing larger package tests {#ssec-package-tests-writing} 597 598 - This is an example using the `phoronix-test-suite` package with the current best practices. 599 - 600 - Add the tests in `passthru.tests` to the package definition like this: 601 - 602 - ```nix 603 - { stdenv, lib, fetchurl, callPackage }: 604 - 605 - stdenv.mkDerivation { 606 - 607 - 608 - passthru.tests = { 609 - simple-execution = callPackage ./tests.nix { }; 610 - }; 611 - 612 - meta = { … }; 613 - } 614 - ``` 615 - 616 - Create `tests.nix` in the package directory: 617 - 618 - ```nix 619 - { runCommand, phoronix-test-suite }: 620 - 621 - let 622 - inherit (phoronix-test-suite) pname version; 623 - in 624 - 625 - runCommand "${pname}-tests" { meta.timeout = 60; } 626 - '' 627 - # automatic initial setup to prevent interactive questions 628 - ${phoronix-test-suite}/bin/phoronix-test-suite enterprise-setup >/dev/null 629 - # get version of installed program and compare with package version 630 - if [[ `${phoronix-test-suite}/bin/phoronix-test-suite version` != *"${version}"* ]]; then 631 - echo "Error: program version does not match package version" 632 - exit 1 633 - fi 634 - # run dummy command 635 - ${phoronix-test-suite}/bin/phoronix-test-suite dummy_module.dummy-command >/dev/null 636 - # needed for Nix to register the command as successful 637 - touch $out 638 - '' 639 - ``` 640 641 ### Running package tests {#ssec-package-tests-running} 642 643 - You can run these tests with: 644 - 645 - ```ShellSession 646 - $ cd path/to/nixpkgs 647 - $ nix-build -A phoronix-test-suite.tests 648 - ``` 649 650 ### Examples of package tests {#ssec-package-tests-examples} 651 652 - Here are examples of package tests: 653 - 654 - - [Jasmin compile test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/jasmin/test-assemble-hello-world/default.nix) 655 - - [Lobster compile test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/lobster/test-can-run-hello-world.nix) 656 - - [Spacy annotation test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/spacy/annotation-test/default.nix) 657 - - [Libtorch test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/science/math/libtorch/test/default.nix) 658 - - [Multiple tests for nanopb](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/nanopb/default.nix) 659 660 ### Linking NixOS module tests to a package {#ssec-nixos-tests-linking} 661 662 - 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. 663 - 664 - For example, assuming we're packaging `nginx`, we can link its module test via `passthru.tests`: 665 - 666 - ```nix 667 - { stdenv, lib, nixosTests }: 668 - 669 - stdenv.mkDerivation { 670 - ... 671 - 672 - passthru.tests = { 673 - nginx = nixosTests.nginx; 674 - }; 675 - 676 - ... 677 - } 678 - ``` 679 680 ### Import From Derivation {#ssec-import-from-derivation} 681 682 - Import From Derivation (IFD) is disallowed in Nixpkgs for performance reasons: 683 - [Hydra] evaluates the entire package set, and sequential builds during evaluation would increase evaluation times to become impractical. 684 - 685 - [Hydra]: https://github.com/NixOS/hydra 686 - 687 - Import From Derivation can be worked around in some cases by committing generated intermediate files to version control and reading those instead. 688 - 689 - <!-- TODO: remove the following and link to Nix manual once https://github.com/NixOS/nix/pull/7332 is merged --> 690 - 691 - See also [NixOS Wiki: Import From Derivation]. 692 - 693 - [NixOS Wiki: Import From Derivation]: https://nixos.wiki/wiki/Import_From_Derivation
··· 1 # Coding conventions {#chap-conventions} 2 3 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 4 5 + ## Syntax {#sec-syntax} 6 7 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 8 9 ## Package naming {#sec-package-naming} 10 11 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 12 13 ## File naming and organisation {#sec-organisation} 14 15 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 16 17 ### Versioning {#sec-versioning} 18 19 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 20 21 ## Fetching Sources {#sec-sources} 22 23 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 24 25 ## Obtaining source hash {#sec-source-hashes} 26 27 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 28 29 ### Obtaining hashes securely {#sec-source-hashes-security} 30 31 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 32 33 ## Patches {#sec-patches} 34 35 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 36 37 ## Package tests {#sec-package-tests} 38 39 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 40 41 ### Writing inline package tests {#ssec-inline-package-tests-writing} 42 43 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 44 45 ### Writing larger package tests {#ssec-package-tests-writing} 46 47 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 48 49 ### Running package tests {#ssec-package-tests-running} 50 51 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 52 53 ### Examples of package tests {#ssec-package-tests-examples} 54 55 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 56 57 ### Linking NixOS module tests to a package {#ssec-nixos-tests-linking} 58 59 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 60 61 ### Import From Derivation {#ssec-import-from-derivation} 62 63 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
+3 -107
doc/contributing/contributing-to-documentation.chapter.md
··· 1 # Contributing to Nixpkgs documentation {#chap-contributing} 2 3 - The sources of the Nixpkgs manual are in the [doc](https://github.com/NixOS/nixpkgs/tree/master/doc) subdirectory of the Nixpkgs repository. 4 - 5 - You can quickly check your edits with `nix-build`: 6 - 7 - ```ShellSession 8 - $ cd /path/to/nixpkgs 9 - $ nix-build doc 10 - ``` 11 - 12 - If the build succeeds, the manual will be in `./result/share/doc/nixpkgs/manual.html`. 13 14 ## devmode {#sec-contributing-devmode} 15 16 - The shell in the manual source directory makes available a command, `devmode`. 17 - It is a daemon, that: 18 - 1. watches the manual's source for changes and when they occur — rebuilds 19 - 2. HTTP serves the manual, injecting a script that triggers reload on changes 20 - 3. opens the manual in the default browser 21 22 ## Syntax {#sec-contributing-markup} 23 24 - 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. 25 - 26 - Additional syntax extensions are available, all of which can be used in NixOS option documentation. The following extensions are currently used: 27 - 28 - - []{#ssec-contributing-markup-tables} 29 - Tables, using the [GitHub-flavored Markdown syntax](https://github.github.com/gfm/#tables-extension-). 30 - 31 - - []{#ssec-contributing-markup-anchors} 32 - 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). 33 - 34 - It uses the widely compatible [header attributes](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/attributes.md) syntax: 35 - 36 - ```markdown 37 - ## Syntax {#sec-contributing-markup} 38 - ``` 39 - 40 - ::: {.note} 41 - NixOS option documentation does not support headings in general. 42 - ::: 43 - 44 - - []{#ssec-contributing-markup-anchors-inline} 45 - **Inline anchors**, which allow linking arbitrary place in the text (e.g. individual list items, sentences…). 46 - 47 - 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): 48 - 49 - ```markdown 50 - - []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`. 51 - ``` 52 - 53 - - []{#ssec-contributing-markup-automatic-links} 54 - 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). 55 - 56 - This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing). 57 - 58 - - []{#ssec-contributing-markup-inline-roles} 59 - 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`. 60 - 61 - A few markups for other kinds of literals are also available: 62 - 63 - - `` {command}`rm -rfi` `` turns into {command}`rm -rfi` 64 - - `` {env}`XDG_DATA_DIRS` `` turns into {env}`XDG_DATA_DIRS` 65 - - `` {file}`/etc/passwd` `` turns into {file}`/etc/passwd` 66 - - `` {option}`networking.useDHCP` `` turns into {option}`networking.useDHCP` 67 - - `` {var}`/etc/passwd` `` turns into {var}`/etc/passwd` 68 - 69 - These literal kinds are used mostly in NixOS option documentation. 70 - 71 - 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. 72 - 73 - - []{#ssec-contributing-markup-admonitions} 74 - **Admonitions**, set off from the text to bring attention to something. 75 - 76 - It uses pandoc’s [fenced `div`s syntax](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/fenced_divs.md): 77 - 78 - ```markdown 79 - ::: {.warning} 80 - This is a warning 81 - ::: 82 - ``` 83 - 84 - which renders as 85 - 86 - > ::: {.warning} 87 - > This is a warning. 88 - > ::: 89 - 90 - The following are supported: 91 - 92 - - [`caution`](https://tdg.docbook.org/tdg/5.0/caution.html) 93 - - [`important`](https://tdg.docbook.org/tdg/5.0/important.html) 94 - - [`note`](https://tdg.docbook.org/tdg/5.0/note.html) 95 - - [`tip`](https://tdg.docbook.org/tdg/5.0/tip.html) 96 - - [`warning`](https://tdg.docbook.org/tdg/5.0/warning.html) 97 - 98 - - []{#ssec-contributing-markup-definition-lists} 99 - [**Definition lists**](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/definition_lists.md), for defining a group of terms: 100 - 101 - ```markdown 102 - pear 103 - : green or yellow bulbous fruit 104 - 105 - watermelon 106 - : green fruit with red flesh 107 - ``` 108 - 109 - which renders as 110 - 111 - > pear 112 - > : green or yellow bulbous fruit 113 - > 114 - > watermelon 115 - > : green fruit with red flesh
··· 1 # Contributing to Nixpkgs documentation {#chap-contributing} 2 3 + This section has been moved to [doc/README.md](https://github.com/NixOS/nixpkgs/blob/master/doc/README.md). 4 5 ## devmode {#sec-contributing-devmode} 6 7 + This section has been moved to [doc/README.md](https://github.com/NixOS/nixpkgs/blob/master/doc/README.md). 8 9 ## Syntax {#sec-contributing-markup} 10 11 + This section has been moved to [doc/README.md](https://github.com/NixOS/nixpkgs/blob/master/doc/README.md).
+1 -75
doc/contributing/quick-start.chapter.md
··· 1 # Quick Start to Adding a Package {#chap-quick-start} 2 3 - To add a package to Nixpkgs: 4 - 5 - 1. Checkout the Nixpkgs source tree: 6 - 7 - ```ShellSession 8 - $ git clone https://github.com/NixOS/nixpkgs 9 - $ cd nixpkgs 10 - ``` 11 - 12 - 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. 13 - 14 - ```ShellSession 15 - $ mkdir pkgs/development/libraries/libfoo 16 - ``` 17 - 18 - 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`. 19 - 20 - ```ShellSession 21 - $ emacs pkgs/development/libraries/libfoo/default.nix 22 - $ git add pkgs/development/libraries/libfoo/default.nix 23 - ``` 24 - 25 - You can have a look at the existing Nix expressions under `pkgs/` to see how it’s done. Here are some good ones: 26 - 27 - - 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. 28 - 29 - - 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`. 30 - 31 - - 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`. 32 - 33 - - 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`. 34 - 35 - - 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. 36 - 37 - - 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. 38 - 39 - - 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. 40 - 41 - - 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. 42 - 43 - - 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. 44 - 45 - Some notes: 46 - 47 - - 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). 48 - 49 - - 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. 50 - 51 - - 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). 52 - 53 - 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). 54 - 55 - 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`. 56 - 57 - ```ShellSession 58 - $ emacs pkgs/top-level/all-packages.nix 59 - ``` 60 - 61 - 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. 62 - 63 - 5. To test whether the package builds, run the following command from the root of the nixpkgs source tree: 64 - 65 - ```ShellSession 66 - $ nix-build -A libfoo 67 - ``` 68 - 69 - 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. 70 - 71 - 6. If you want to install the package into your profile (optional), do 72 - 73 - ```ShellSession 74 - $ nix-env -f . -iA libfoo 75 - ``` 76 - 77 - 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 # Quick Start to Adding a Package {#chap-quick-start} 2 3 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
+9 -296
doc/contributing/reviewing-contributions.chapter.md
··· 1 # Reviewing contributions {#chap-reviewing-contributions} 2 3 - ::: {.warning} 4 - 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). 5 - ::: 6 - 7 - 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. 8 - 9 - 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). 10 - 11 - 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. 12 - 13 - 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. 14 - 15 - 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. 16 - 17 - 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. 18 19 ## Package updates {#reviewing-contributions-package-updates} 20 21 - 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. 22 - 23 - It can happen that non-trivial updates include patches or more complex changes. 24 - 25 - Reviewing process: 26 - 27 - - Ensure that the package versioning fits the guidelines. 28 - - Ensure that the commit text fits the guidelines. 29 - - Ensure that the package maintainers are notified. 30 - - [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. 31 - - Ensure that the meta field information is correct. 32 - - License can change with version updates, so it should be checked to match the upstream license. 33 - - 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. 34 - - Ensure that the code contains no typos. 35 - - Building the package locally. 36 - - 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. 37 - - 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. 38 - 39 - ```ShellSession 40 - $ git fetch origin nixos-unstable 41 - $ git fetch origin pull/PRNUMBER/head 42 - $ git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD 43 - ``` 44 - 45 - - The first command fetches the nixos-unstable branch. 46 - - 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. 47 - - The third command rebases the pull request changes to the nixos-unstable branch. 48 - - 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. 49 - 50 - ```ShellSession 51 - $ nix-shell -p nixpkgs-review --run "nixpkgs-review pr PRNUMBER" 52 - ``` 53 - - Running every binary. 54 - 55 - Sample template for a package update review is provided below. 56 - 57 - ```markdown 58 - ##### Reviewed points 59 - 60 - - [ ] package name fits guidelines 61 - - [ ] package version fits guidelines 62 - - [ ] package build on ARCHITECTURE 63 - - [ ] executables tested on ARCHITECTURE 64 - - [ ] all depending packages build 65 - - [ ] patches have a comment describing either the upstream URL or a reason why the patch wasn't upstreamed 66 - - [ ] patches that are remotely available are fetched rather than vendored 67 - 68 - ##### Possible improvements 69 - 70 - ##### Comments 71 - ``` 72 73 ## New packages {#reviewing-contributions-new-packages} 74 75 - New packages are a common type of pull requests. These pull requests consists in adding a new nix-expression for a package. 76 - 77 - Review process: 78 - 79 - - Ensure that the package versioning fits the guidelines. 80 - - Ensure that the commit name fits the guidelines. 81 - - Ensure that the meta fields contain correct information. 82 - - License must match the upstream license. 83 - - Platforms should be set (or the package will not get binary substitutes). 84 - - Maintainers must be set. This can be the package submitter or a community member that accepts taking up maintainership of the package. 85 - - Report detected typos. 86 - - Ensure the package source: 87 - - Uses mirror URLs when available. 88 - - Uses the most appropriate functions (e.g. packages from GitHub should use `fetchFromGitHub`). 89 - - Building the package locally. 90 - - Running every binary. 91 - 92 - Sample template for a new package review is provided below. 93 - 94 - ```markdown 95 - ##### Reviewed points 96 - 97 - - [ ] package path fits guidelines 98 - - [ ] package name fits guidelines 99 - - [ ] package version fits guidelines 100 - - [ ] package build on ARCHITECTURE 101 - - [ ] executables tested on ARCHITECTURE 102 - - [ ] `meta.description` is set and fits guidelines 103 - - [ ] `meta.license` fits upstream license 104 - - [ ] `meta.platforms` is set 105 - - [ ] `meta.maintainers` is set 106 - - [ ] build time only dependencies are declared in `nativeBuildInputs` 107 - - [ ] source is fetched using the appropriate function 108 - - [ ] the list of `phases` is not overridden 109 - - [ ] when a phase (like `installPhase`) is overridden it starts with `runHook preInstall` and ends with `runHook postInstall`. 110 - - [ ] patches have a comment describing either the upstream URL or a reason why the patch wasn't upstreamed 111 - - [ ] patches that are remotely available are fetched rather than vendored 112 - 113 - ##### Possible improvements 114 - 115 - ##### Comments 116 - ``` 117 118 ## Module updates {#reviewing-contributions-module-updates} 119 120 - Module updates are submissions changing modules in some ways. These often contains changes to the options or introduce new options. 121 - 122 - Reviewing process: 123 - 124 - - Ensure that the module maintainers are notified. 125 - - [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. 126 - - Ensure that the module tests, if any, are succeeding. 127 - - Ensure that the introduced options are correct. 128 - - Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated). 129 - - Description, default and example should be provided. 130 - - Ensure that option changes are backward compatible. 131 - - `mkRenamedOptionModuleWith` provides a way to make option changes backward compatible. 132 - - Ensure that removed options are declared with `mkRemovedOptionModule` 133 - - Ensure that changes that are not backward compatible are mentioned in release notes. 134 - - Ensure that documentations affected by the change is updated. 135 - 136 - Sample template for a module update review is provided below. 137 - 138 - ```markdown 139 - ##### Reviewed points 140 - 141 - - [ ] changes are backward compatible 142 - - [ ] removed options are declared with `mkRemovedOptionModule` 143 - - [ ] changes that are not backward compatible are documented in release notes 144 - - [ ] module tests succeed on ARCHITECTURE 145 - - [ ] options types are appropriate 146 - - [ ] options description is set 147 - - [ ] options example is provided 148 - - [ ] documentation affected by the changes is updated 149 - 150 - ##### Possible improvements 151 - 152 - ##### Comments 153 - ``` 154 155 ## New modules {#reviewing-contributions-new-modules} 156 157 - New modules submissions introduce a new module to NixOS. 158 - 159 - Reviewing process: 160 - 161 - - Ensure that the module tests, if any, are succeeding. 162 - - Ensure that the introduced options are correct. 163 - - Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated). 164 - - Description, default and example should be provided. 165 - - Ensure that module `meta` field is present 166 - - Maintainers should be declared in `meta.maintainers`. 167 - - Module documentation should be declared with `meta.doc`. 168 - - Ensure that the module respect other modules functionality. 169 - - For example, enabling a module should not open firewall ports by default. 170 - 171 - Sample template for a new module review is provided below. 172 - 173 - ```markdown 174 - ##### Reviewed points 175 - 176 - - [ ] module path fits the guidelines 177 - - [ ] module tests succeed on ARCHITECTURE 178 - - [ ] options have appropriate types 179 - - [ ] options have default 180 - - [ ] options have example 181 - - [ ] options have descriptions 182 - - [ ] No unneeded package is added to environment.systemPackages 183 - - [ ] meta.maintainers is set 184 - - [ ] module documentation is declared in meta.doc 185 - 186 - ##### Possible improvements 187 - 188 - ##### Comments 189 - ``` 190 191 ## Individual maintainer list {#reviewing-contributions-individual-maintainer-list} 192 193 - When adding users to `maintainers/maintainer-list.nix`, the following 194 - checks should be performed: 195 - 196 - - If the user has specified a GPG key, verify that the commit is 197 - signed by their key. 198 - 199 - First, validate that the commit adding the maintainer is signed by 200 - the key the maintainer listed. Check out the pull request and 201 - compare its signing key with the listed key in the commit. 202 - 203 - If the commit is not signed or it is signed by a different user, ask 204 - them to either recommit using that key or to remove their key 205 - information. 206 - 207 - Given a maintainer entry like this: 208 - 209 - ``` nix 210 - { 211 - example = { 212 - email = "user@example.com"; 213 - name = "Example User"; 214 - keys = [{ 215 - fingerprint = "0000 0000 2A70 6423 0AED 3C11 F04F 7A19 AAA6 3AFE"; 216 - }]; 217 - } 218 - }; 219 - ``` 220 - 221 - First receive their key from a keyserver: 222 - 223 - $ gpg --recv-keys 0xF04F7A19AAA63AFE 224 - gpg: key 0xF04F7A19AAA63AFE: public key "Example <user@example.com>" imported 225 - gpg: Total number processed: 1 226 - gpg: imported: 1 227 - 228 - Then check the commit is signed by that key: 229 - 230 - $ git log --show-signature 231 - commit b87862a4f7d32319b1de428adb6cdbdd3a960153 232 - gpg: Signature made Wed Mar 12 13:32:24 2003 +0000 233 - gpg: using RSA key 000000002A7064230AED3C11F04F7A19AAA63AFE 234 - gpg: Good signature from "Example User <user@example.com> 235 - Author: Example User <user@example.com> 236 - Date: Wed Mar 12 13:32:24 2003 +0000 237 - 238 - maintainers: adding example 239 - 240 - and validate that there is a `Good signature` and the printed key 241 - matches the user's submitted key. 242 - 243 - Note: GitHub's "Verified" label does not display the user's full key 244 - fingerprint, and should not be used for validating the key matches. 245 - 246 - - If the user has specified a `github` account name, ensure they have 247 - also specified a `githubId` and verify the two match. 248 - 249 - Maintainer entries that include a `github` field must also include 250 - their `githubId`. People can and do change their GitHub name 251 - frequently, and the ID is used as the official and stable identity 252 - of the maintainer. 253 - 254 - Given a maintainer entry like this: 255 - 256 - ``` nix 257 - { 258 - example = { 259 - email = "user@example.com"; 260 - name = "Example User"; 261 - github = "ghost"; 262 - githubId = 10137; 263 - } 264 - }; 265 - ``` 266 - 267 - First, make sure that the listed GitHub handle matches the author of 268 - the commit. 269 - 270 - Then, visit the URL `https://api.github.com/users/ghost` and 271 - validate that the `id` field matches the provided `githubId`. 272 273 ## Maintainer teams {#reviewing-contributions-maintainer-teams} 274 275 - Feel free to create a new maintainer team in `maintainers/team-list.nix` 276 - when a group is collectively responsible for a collection of packages. 277 - Use taste and personal judgement when deciding if a team is warranted. 278 - 279 - Teams are allowed to define their own rules about membership. 280 - 281 - For example, some teams will represent a business or other group which 282 - wants to carefully track its members. Other teams may be very open about 283 - who can join, and allow anybody to participate. 284 - 285 - When reviewing changes to a team, read the team's scope and the context 286 - around the member list for indications about the team's membership 287 - policy. 288 - 289 - In any case, request reviews from the existing team members. If the team 290 - lists no specific membership policy, feel free to merge changes to the 291 - team after giving the existing members a few days to respond. 292 - 293 - *Important:* If a team says it is a closed group, do not merge additions 294 - to the team without an approval by at least one existing member. 295 296 ## Other submissions {#reviewing-contributions-other-submissions} 297 298 - Other type of submissions requires different reviewing steps. 299 - 300 - 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. 301 - 302 - Container system, boot system and library changes are some examples of the pull requests fitting this category. 303 304 ## Merging pull requests {#reviewing-contributions--merging-pull-requests} 305 306 - It is possible for community members that have enough knowledge and experience on a special topic to contribute by merging pull requests. 307 - 308 - In case the PR is stuck waiting for the original author to apply a trivial 309 - change (a typo, capitalisation change, etc.) and the author allowed the members 310 - to modify the PR, consider applying it yourself. (or commit the existing review 311 - suggestion) You should pay extra attention to make sure the addition doesn't go 312 - against the idea of the original PR and would not be opposed by the author. 313 - 314 - <!-- 315 - 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. 316 - 317 - Please note that contributors with commit rights unactive for more than three months will have their commit rights revoked. 318 - --> 319 - 320 - 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. 321 - 322 - 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 # Reviewing contributions {#chap-reviewing-contributions} 2 3 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 4 5 ## Package updates {#reviewing-contributions-package-updates} 6 7 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 8 9 ## New packages {#reviewing-contributions-new-packages} 10 11 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 12 13 ## Module updates {#reviewing-contributions-module-updates} 14 15 + This section has been moved to [nixos/README.md](https://github.com/NixOS/nixpkgs/blob/master/nixos/README.md). 16 17 ## New modules {#reviewing-contributions-new-modules} 18 19 + This section has been moved to [nixos/README.md](https://github.com/NixOS/nixpkgs/blob/master/nixos/README.md). 20 21 ## Individual maintainer list {#reviewing-contributions-individual-maintainer-list} 22 23 + This section has been moved to [maintainers/README.md](https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md). 24 25 ## Maintainer teams {#reviewing-contributions-maintainer-teams} 26 27 + This section has been moved to [maintainers/README.md](https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md). 28 29 ## Other submissions {#reviewing-contributions-other-submissions} 30 31 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 32 33 ## Merging pull requests {#reviewing-contributions--merging-pull-requests} 34 35 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
-16
doc/contributing/staging-workflow.dot
··· 1 - digraph { 2 - "small changes" [shape=none] 3 - "mass-rebuilds and other large changes" [shape=none] 4 - "critical security fixes" [shape=none] 5 - "broken staging-next fixes" [shape=none] 6 - 7 - "small changes" -> master 8 - "mass-rebuilds and other large changes" -> staging 9 - "critical security fixes" -> master 10 - "broken staging-next fixes" -> "staging-next" 11 - 12 - "staging-next" -> master [color="#E85EB0"] [label="stabilization ends"] [fontcolor="#E85EB0"] 13 - "staging" -> "staging-next" [color="#E85EB0"] [label="stabilization starts"] [fontcolor="#E85EB0"] 14 - 15 - master -> "staging-next" -> staging [color="#5F5EE8"] [label="every six hours (GitHub Action)"] [fontcolor="#5F5EE8"] 16 - }
···
-102
doc/contributing/staging-workflow.svg
··· 1 - <?xml version="1.0" encoding="UTF-8" standalone="no"?> 2 - <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 3 - "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> 4 - <!-- Generated by graphviz version 7.1.0 (0) 5 - --> 6 - <!-- Pages: 1 --> 7 - <svg width="743pt" height="291pt" 8 - viewBox="0.00 0.00 743.00 291.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> 9 - <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 287)"> 10 - <polygon fill="white" stroke="none" points="-4,4 -4,-287 739,-287 739,4 -4,4"/> 11 - <!-- small changes --> 12 - <g id="node1" class="node"> 13 - <title>small changes</title> 14 - <text text-anchor="middle" x="59" y="-261.3" font-family="Times,serif" font-size="14.00">small changes</text> 15 - </g> 16 - <!-- master --> 17 - <g id="node5" class="node"> 18 - <title>master</title> 19 - <ellipse fill="none" stroke="black" cx="139" cy="-192" rx="43.59" ry="18"/> 20 - <text text-anchor="middle" x="139" y="-188.3" font-family="Times,serif" font-size="14.00">master</text> 21 - </g> 22 - <!-- small changes&#45;&gt;master --> 23 - <g id="edge1" class="edge"> 24 - <title>small changes&#45;&gt;master</title> 25 - <path fill="none" stroke="black" d="M77.96,-247.17C88.42,-237.89 101.55,-226.23 112.96,-216.11"/> 26 - <polygon fill="black" stroke="black" points="114.99,-218.99 120.14,-209.74 110.34,-213.76 114.99,-218.99"/> 27 - </g> 28 - <!-- mass&#45;rebuilds and other large changes --> 29 - <g id="node2" class="node"> 30 - <title>mass&#45;rebuilds and other large changes</title> 31 - <text text-anchor="middle" x="588" y="-101.3" font-family="Times,serif" font-size="14.00">mass&#45;rebuilds and other large changes</text> 32 - </g> 33 - <!-- staging --> 34 - <g id="node6" class="node"> 35 - <title>staging</title> 36 - <ellipse fill="none" stroke="black" cx="438" cy="-18" rx="45.49" ry="18"/> 37 - <text text-anchor="middle" x="438" y="-14.3" font-family="Times,serif" font-size="14.00">staging</text> 38 - </g> 39 - <!-- mass&#45;rebuilds and other large changes&#45;&gt;staging --> 40 - <g id="edge2" class="edge"> 41 - <title>mass&#45;rebuilds and other large changes&#45;&gt;staging</title> 42 - <path fill="none" stroke="black" d="M587.48,-87.47C586.26,-76.55 582.89,-62.7 574,-54 553.19,-33.63 522.2,-24.65 495.05,-20.86"/> 43 - <polygon fill="black" stroke="black" points="495.53,-17.39 485.2,-19.71 494.72,-24.35 495.53,-17.39"/> 44 - </g> 45 - <!-- critical security fixes --> 46 - <g id="node3" class="node"> 47 - <title>critical security fixes</title> 48 - <text text-anchor="middle" x="219" y="-261.3" font-family="Times,serif" font-size="14.00">critical security fixes</text> 49 - </g> 50 - <!-- critical security fixes&#45;&gt;master --> 51 - <g id="edge3" class="edge"> 52 - <title>critical security fixes&#45;&gt;master</title> 53 - <path fill="none" stroke="black" d="M200.04,-247.17C189.58,-237.89 176.45,-226.23 165.04,-216.11"/> 54 - <polygon fill="black" stroke="black" points="167.66,-213.76 157.86,-209.74 163.01,-218.99 167.66,-213.76"/> 55 - </g> 56 - <!-- broken staging&#45;next fixes --> 57 - <g id="node4" class="node"> 58 - <title>broken staging&#45;next fixes</title> 59 - <text text-anchor="middle" x="414" y="-188.3" font-family="Times,serif" font-size="14.00">broken staging&#45;next fixes</text> 60 - </g> 61 - <!-- staging&#45;next --> 62 - <g id="node7" class="node"> 63 - <title>staging&#45;next</title> 64 - <ellipse fill="none" stroke="black" cx="272" cy="-105" rx="68.79" ry="18"/> 65 - <text text-anchor="middle" x="272" y="-101.3" font-family="Times,serif" font-size="14.00">staging&#45;next</text> 66 - </g> 67 - <!-- broken staging&#45;next fixes&#45;&gt;staging&#45;next --> 68 - <g id="edge4" class="edge"> 69 - <title>broken staging&#45;next fixes&#45;&gt;staging&#45;next</title> 70 - <path fill="none" stroke="black" d="M410.2,-174.42C406.88,-163.48 400.98,-149.62 391,-141 377.77,-129.56 360.96,-121.86 344.17,-116.67"/> 71 - <polygon fill="black" stroke="black" points="345.21,-113.33 334.63,-114.02 343.33,-120.07 345.21,-113.33"/> 72 - </g> 73 - <!-- master&#45;&gt;staging&#45;next --> 74 - <g id="edge7" class="edge"> 75 - <title>master&#45;&gt;staging&#45;next</title> 76 - <path fill="none" stroke="#5f5ee8" d="M96.55,-187.26C53.21,-181.83 -4.5,-169.14 20,-141 41.99,-115.74 126.36,-108.13 191.48,-106.11"/> 77 - <polygon fill="#5f5ee8" stroke="#5f5ee8" points="191.57,-109.61 201.47,-105.85 191.38,-102.62 191.57,-109.61"/> 78 - <text text-anchor="middle" x="133" y="-144.8" font-family="Times,serif" font-size="14.00" fill="#5f5ee8">every six hours (GitHub Action)</text> 79 - </g> 80 - <!-- staging&#45;&gt;staging&#45;next --> 81 - <g id="edge6" class="edge"> 82 - <title>staging&#45;&gt;staging&#45;next</title> 83 - <path fill="none" stroke="#e85eb0" d="M434.55,-36.2C431.48,-47.12 425.89,-60.72 416,-69 397.61,-84.41 373.51,-93.23 350.31,-98.23"/> 84 - <polygon fill="#e85eb0" stroke="#e85eb0" points="349.67,-94.79 340.5,-100.1 350.98,-101.66 349.67,-94.79"/> 85 - <text text-anchor="middle" x="493.5" y="-57.8" font-family="Times,serif" font-size="14.00" fill="#e85eb0">stabilization starts</text> 86 - </g> 87 - <!-- staging&#45;next&#45;&gt;master --> 88 - <g id="edge5" class="edge"> 89 - <title>staging&#45;next&#45;&gt;master</title> 90 - <path fill="none" stroke="#e85eb0" d="M268.22,-123.46C265.05,-134.22 259.46,-147.52 250,-156 233.94,-170.4 211.98,-178.87 191.83,-183.86"/> 91 - <polygon fill="#e85eb0" stroke="#e85eb0" points="191.35,-180.38 182.34,-185.96 192.86,-187.22 191.35,-180.38"/> 92 - <text text-anchor="middle" x="323.5" y="-144.8" font-family="Times,serif" font-size="14.00" fill="#e85eb0">stabilization ends</text> 93 - </g> 94 - <!-- staging&#45;next&#45;&gt;staging --> 95 - <g id="edge8" class="edge"> 96 - <title>staging&#45;next&#45;&gt;staging</title> 97 - <path fill="none" stroke="#5f5ee8" d="M221.07,-92.46C194.72,-84.14 170.92,-71.32 186,-54 210.78,-25.54 314.74,-19.48 381.15,-18.6"/> 98 - <polygon fill="#5f5ee8" stroke="#5f5ee8" points="380.79,-22.1 390.76,-18.51 380.73,-15.1 380.79,-22.1"/> 99 - <text text-anchor="middle" x="299" y="-57.8" font-family="Times,serif" font-size="14.00" fill="#5f5ee8">every six hours (GitHub Action)</text> 100 - </g> 101 - </g> 102 - </svg>
···
+22 -278
doc/contributing/submitting-changes.chapter.md
··· 1 # Submitting changes {#chap-submitting-changes} 2 3 - ## Making patches {#submitting-changes-making-patches} 4 - 5 - - Read [Manual (How to write packages for Nix)](https://nixos.org/nixpkgs/manual/). 6 - 7 - - Fork [the Nixpkgs repository](https://github.com/nixos/nixpkgs/) on GitHub. 8 - 9 - - Create a branch for your future fix. 10 - 11 - - 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 12 - 13 - ```ShellSession 14 - $ nixos-version --hash 15 - 0998212 16 - $ git checkout 0998212 17 - $ git checkout -b 'fix/pkg-name-update' 18 - ``` 19 - 20 - - Please avoid working directly on the `master` branch. 21 - 22 - - Make commits of logical units. 23 - 24 - - 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`. 25 - 26 - - Check for unnecessary whitespace with `git diff --check` before committing. 27 - 28 - - Format the commit in a following way: 29 - 30 - ``` 31 - (pkg-name | nixos/<module>): (from -> to | init at version | refactor | etc) 32 - Additional information. 33 - ``` 34 - 35 - - Examples: 36 - - `nginx: init at 2.0.1` 37 - - `firefox: 54.0.1 -> 55.0` 38 - - `nixos/hydra: add bazBaz option` 39 - - `nixos/nginx: refactor config generation` 40 - 41 - - Test your changes. If you work with 42 - 43 - - nixpkgs: 44 - 45 - - update pkg 46 - - `nix-env -iA pkg-attribute-name -f <path to your local nixpkgs folder>` 47 - - add pkg 48 - - Make sure it’s in `pkgs/top-level/all-packages.nix` 49 - - `nix-env -iA pkg-attribute-name -f <path to your local nixpkgs folder>` 50 - - _If you don’t want to install pkg in you profile_. 51 - - `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`. 52 - - 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. 53 - 54 - - NixOS and its modules: 55 - - 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`. 56 - 57 - - If you have commits `pkg-name: oh, forgot to insert whitespace`: squash commits in this case. Use `git rebase -i`. 58 - 59 - - [Rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) your branch against current `master`. 60 61 ## Submitting changes {#submitting-changes-submitting-changes} 62 63 - - Push your changes to your fork of nixpkgs. 64 - - Create the pull request 65 - - Follow [the contribution guidelines](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#submitting-changes). 66 67 ## Submitting security fixes {#submitting-changes-submitting-security-fixes} 68 69 - Security fixes are submitted in the same way as other changes and thus the same guidelines apply. 70 - 71 - - If a new version fixing the vulnerability has been released, update the package; 72 - - 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. 73 - 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.: 74 - 75 - ```nix 76 - (fetchpatch { 77 - name = "CVE-2019-11068.patch"; 78 - url = "https://gitlab.gnome.org/GNOME/libxslt/commit/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch"; 79 - hash = "sha256-SEKe/8HcW0UBHCfPTTOnpRlzmV2nQPPeL6HOMxBZd14="; 80 - }) 81 - ``` 82 - 83 - 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. 84 - 85 - Critical security fixes may by-pass the staging branches and be delivered directly to release branches such as `master` and `release-*`. 86 87 ## Deprecating/removing packages {#submitting-changes-deprecating-packages} 88 89 - There is currently no policy when to remove a package. 90 - 91 - Before removing a package, one should try to find a new maintainer or fix smaller issues first. 92 93 ### Steps to remove a package from Nixpkgs {#steps-to-remove-a-package-from-nixpkgs} 94 95 - We use jbidwatcher as an example for a discontinued project here. 96 - 97 - 1. Have Nixpkgs checked out locally and up to date. 98 - 1. Create a new branch for your change, e.g. `git checkout -b jbidwatcher` 99 - 1. Remove the actual package including its directory, e.g. `git rm -rf pkgs/applications/misc/jbidwatcher` 100 - 1. Remove the package from the list of all packages (`pkgs/top-level/all-packages.nix`). 101 - 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.) 102 - 103 - For example in this case: 104 - 105 - ``` 106 - jbidwatcher = throw "jbidwatcher was discontinued in march 2021"; # added 2021-03-15 107 - ``` 108 - 109 - The throw message should explain in short why the package was removed for users that still have it installed. 110 - 111 - 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. 112 - 1. Commit the changes. Explain again why the package was removed. If it was declared discontinued upstream, add a link to the source. 113 - 114 - ```ShellSession 115 - $ git add pkgs/applications/misc/jbidwatcher/default.nix pkgs/top-level/all-packages.nix pkgs/top-level/aliases.nix 116 - $ git commit 117 - ``` 118 - 119 - Example commit message: 120 - 121 - ``` 122 - jbidwatcher: remove 123 - 124 - project was discontinued in march 2021. the program does not work anymore because ebay changed the login. 125 - 126 - https://web.archive.org/web/20210315205723/http://www.jbidwatcher.com/ 127 - ``` 128 - 129 - 1. Push changes to your GitHub fork with `git push` 130 - 1. Create a pull request against Nixpkgs. Mention the package maintainer. 131 - 132 - 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) 133 134 ## Pull Request Template {#submitting-changes-pull-request-template} 135 136 - 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. 137 - 138 - When a PR is created, it will be pre-populated with some checkboxes detailed below: 139 140 ### Tested using sandboxing {#submitting-changes-tested-with-sandbox} 141 142 - 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. 143 - 144 - 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. 145 - 146 - Depending if you use NixOS or other platforms you can use one of the following methods to enable sandboxing **before** building the package: 147 - 148 - - **Globally enable sandboxing on NixOS**: add the following to `configuration.nix` 149 - 150 - ```nix 151 - nix.useSandbox = true; 152 - ``` 153 - 154 - - **Globally enable sandboxing on non-NixOS platforms**: add the following to: `/etc/nix/nix.conf` 155 - 156 - ```ini 157 - sandbox = true 158 - ``` 159 160 ### Built on platform(s) {#submitting-changes-platform-diversity} 161 162 - 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. 163 164 ### Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests) {#submitting-changes-nixos-tests} 165 166 - 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). 167 168 ### Tested compilation of all pkgs that depend on this change using `nixpkgs-review` {#submitting-changes-tested-compilation} 169 170 - 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. 171 - 172 - Review changes from pull request number 12345: 173 - 174 - ```ShellSession 175 - nix-shell -p nixpkgs-review --run "nixpkgs-review pr 12345" 176 - ``` 177 - 178 - Alternatively, with flakes (and analogously for the other commands below): 179 - 180 - ```ShellSession 181 - nix run nixpkgs#nixpkgs-review -- pr 12345 182 - ``` 183 - 184 - Review uncommitted changes: 185 - 186 - ```ShellSession 187 - nix-shell -p nixpkgs-review --run "nixpkgs-review wip" 188 - ``` 189 - 190 - Review changes from last commit: 191 - 192 - ```ShellSession 193 - nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD" 194 - ``` 195 196 ### Tested execution of all binary files (usually in `./result/bin/`) {#submitting-changes-tested-execution} 197 198 - 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. 199 200 ### Meets Nixpkgs contribution standards {#submitting-changes-contribution-standards} 201 202 - 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. 203 204 ## Hotfixing pull requests {#submitting-changes-hotfixing-pull-requests} 205 206 - - Make the appropriate changes in you branch. 207 - - Don’t create additional commits, do 208 - - `git rebase -i` 209 - - `git push --force` to your branch. 210 211 ## Commit policy {#submitting-changes-commit-policy} 212 213 - - Commits must be sufficiently tested before being merged, both for the master and staging branches. 214 - - 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. 215 - - 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. 216 217 ### Branches {#submitting-changes-branches} 218 219 - The `nixpkgs` repository has three major branches: 220 - - `master` 221 - - `staging` 222 - - `staging-next` 223 - 224 - The most important distinction between them is that `staging` 225 - (colored red in the diagram below) can receive commits which cause 226 - a mass-rebuild (for example, anything that changes the `drvPath` of 227 - `stdenv`). The other two branches `staging-next` and `master` 228 - (colored green in the diagram below) can *not* receive commits which 229 - cause a mass-rebuild. 230 - 231 - Arcs between the branches show possible merges into these branches, 232 - either from other branches or from independently submitted PRs. The 233 - colors of these edges likewise show whether or not they could 234 - trigger a mass rebuild (red) or must not trigger a mass rebuild 235 - (green). 236 - 237 - Hydra runs automatic builds for the green branches. 238 - 239 - Notice that the automatic merges are all green arrows. This is by 240 - design. Any merge which might cause a mass rebuild on a branch 241 - which has automatic builds (`staging-next`, `master`) will be a 242 - manual merge to make sure it is good use of compute power. 243 - 244 - Nixpkgs has two branches so that there is one branch (`staging`) 245 - which accepts mass-rebuilding commits, and one fast-rebuilding 246 - branch which accepts independent PRs (`master`). The `staging-next` 247 - branch allows the Hydra operators to batch groups of commits to 248 - `staging` to be built. By keeping the `staging-next` branch 249 - separate from `staging`, this batching does not block 250 - developers from merging changes into `staging`. 251 - 252 - ```{.graphviz caption="Staging workflow"} 253 - digraph { 254 - master [color="green" fontcolor=green] 255 - "staging-next" [color="green" fontcolor=green] 256 - staging [color="red" fontcolor=red] 257 - 258 - "small changes" [fontcolor=green shape=none] 259 - "small changes" -> master [color=green] 260 - 261 - "mass-rebuilds and other large changes" [fontcolor=red shape=none] 262 - "mass-rebuilds and other large changes" -> staging [color=red] 263 - 264 - "critical security fixes" [fontcolor=green shape=none] 265 - "critical security fixes" -> master [color=green] 266 - 267 - "staging fixes which do not cause staging to mass-rebuild" [fontcolor=green shape=none] 268 - "staging fixes which do not cause staging to mass-rebuild" -> "staging-next" [color=green] 269 - 270 - "staging-next" -> master [color="red"] [label="manual merge"] [fontcolor="red"] 271 - "staging" -> "staging-next" [color="red"] [label="manual merge"] [fontcolor="red"] 272 - 273 - master -> "staging-next" [color="green"] [label="automatic merge (GitHub Action)"] [fontcolor="green"] 274 - "staging-next" -> staging [color="green"] [label="automatic merge (GitHub Action)"] [fontcolor="green"] 275 - } 276 - ``` 277 - 278 - [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 green arrows in the diagram above. The red 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. 279 - 280 281 #### Master branch {#submitting-changes-master-branch} 282 283 - The `master` branch is the main development branch. It should only see non-breaking commits that do not cause mass rebuilds. 284 285 #### Staging branch {#submitting-changes-staging-branch} 286 287 - 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. 288 - 289 - During the process of a releasing a new NixOS version, this branch or the release-critical packages can be restricted to non-breaking changes. 290 291 #### Staging-next branch {#submitting-changes-staging-next-branch} 292 293 - 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. 294 - 295 - 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. 296 - 297 - During the process of a releasing a new NixOS version, this branch or the release-critical packages can be restricted to non-breaking changes. 298 299 #### Stable release branches {#submitting-changes-stable-release-branches} 300 301 - The same staging workflow applies to stable release branches, but the main branch is called `release-*` instead of `master`. 302 - 303 - Example branch names: `release-21.11`, `staging-21.11`, `staging-next-21.11`. 304 - 305 - Most changes added to the stable release branches are cherry-picked (“backported”) from the `master` and staging branches. 306 307 #### Automatically backporting a Pull Request {#submitting-changes-stable-release-branches-automatic-backports} 308 309 - 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. 310 311 #### Manually backporting changes {#submitting-changes-stable-release-branches-manual-backports} 312 313 - Cherry-pick changes via `git cherry-pick -x <original commit>` so that the original commit id is included in the commit message. 314 - 315 - 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. 316 - 317 - Here is an example of a cherry-picked commit message with good reason description: 318 - 319 - ``` 320 - zfs: Keep trying root import until it works 321 - 322 - Works around #11003. 323 - 324 - (cherry picked from commit 98b213a11041af39b39473906b595290e2a4e2f9) 325 - 326 - Reason: several people cannot boot with ZFS on NVMe 327 - ``` 328 - 329 - Other examples of reasons are: 330 - 331 - - Previously the build would fail due to, e.g., `getaddrinfo` not being defined 332 - - The previous download links were all broken 333 - - Crash when starting on some X11 systems 334 335 #### Acceptable backport criteria {#acceptable-backport-criteria} 336 337 - 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. 338 339 - However, many changes are able to be backported, including: 340 - - New Packages / Modules 341 - - Security / Patch updates 342 - - Version updates which include new functionality (but no breaking changes) 343 - - Services which require a client to be up-to-date regardless. (E.g. `spotify`, `steam`, or `discord`) 344 - - Security critical applications (E.g. `firefox`)
··· 1 # Submitting changes {#chap-submitting-changes} 2 3 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 4 5 ## Submitting changes {#submitting-changes-submitting-changes} 6 7 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 8 9 ## Submitting security fixes {#submitting-changes-submitting-security-fixes} 10 11 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 12 13 ## Deprecating/removing packages {#submitting-changes-deprecating-packages} 14 15 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 16 17 ### Steps to remove a package from Nixpkgs {#steps-to-remove-a-package-from-nixpkgs} 18 19 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 20 21 ## Pull Request Template {#submitting-changes-pull-request-template} 22 23 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 24 25 ### Tested using sandboxing {#submitting-changes-tested-with-sandbox} 26 27 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 28 29 ### Built on platform(s) {#submitting-changes-platform-diversity} 30 31 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 32 33 ### Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests) {#submitting-changes-nixos-tests} 34 35 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 36 37 ### Tested compilation of all pkgs that depend on this change using `nixpkgs-review` {#submitting-changes-tested-compilation} 38 39 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 40 41 ### Tested execution of all binary files (usually in `./result/bin/`) {#submitting-changes-tested-execution} 42 43 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 44 45 ### Meets Nixpkgs contribution standards {#submitting-changes-contribution-standards} 46 47 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 48 49 ## Hotfixing pull requests {#submitting-changes-hotfixing-pull-requests} 50 51 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 52 53 ## Commit policy {#submitting-changes-commit-policy} 54 55 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 56 57 ### Branches {#submitting-changes-branches} 58 59 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 60 61 #### Master branch {#submitting-changes-master-branch} 62 63 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 64 65 #### Staging branch {#submitting-changes-staging-branch} 66 67 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 68 69 #### Staging-next branch {#submitting-changes-staging-next-branch} 70 71 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 72 73 #### Stable release branches {#submitting-changes-stable-release-branches} 74 75 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 76 77 #### Automatically backporting a Pull Request {#submitting-changes-stable-release-branches-automatic-backports} 78 79 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 80 81 #### Manually backporting changes {#submitting-changes-stable-release-branches-manual-backports} 82 83 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 84 85 #### Acceptable backport criteria {#acceptable-backport-criteria} 86 87 + This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 88
+4 -38
doc/contributing/vulnerability-roundup.chapter.md
··· 1 # Vulnerability Roundup {#chap-vulnerability-roundup} 2 3 - ## Issues {#vulnerability-roundup-issues} 4 - 5 - Vulnerable packages in Nixpkgs are managed using issues. 6 - Currently opened ones can be found using the following: 7 - 8 - [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) 9 - 10 - Each issue correspond to a vulnerable version of a package; As a consequence: 11 - 12 - - One issue can contain several CVEs; 13 - - One CVE can be shared across several issues; 14 - - A single package can be concerned by several issues. 15 - 16 - 17 - A "Vulnerability roundup" issue usually respects the following format: 18 - 19 - ```txt 20 - <link to relevant package search on search.nix.gsc.io>, <link to relevant files in Nixpkgs on GitHub> 21 - 22 - <list of related CVEs, their CVSS score, and the impacted NixOS version> 23 - 24 - <list of the scanned Nixpkgs versions> 25 26 - <list of relevant contributors> 27 - ``` 28 29 - Note that there can be an extra comment containing links to previously reported (and still open) issues for the same package. 30 - 31 32 ## Triaging and Fixing {#vulnerability-roundup-triaging-and-fixing} 33 34 - **Note**: An issue can be a "false positive" (i.e. automatically opened, but without the package it refers to being actually vulnerable). 35 - 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. 36 - 37 - If you are investigating a "true positive": 38 - 39 - - Find the earliest patched version or a code patch in the CVE details; 40 - - Is the issue already patched (version up-to-date or patch applied manually) in Nixpkgs's `master` branch? 41 - - **No**: 42 - - [Submit a security fix](#submitting-changes-submitting-security-fixes); 43 - - 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); 44 - - **Yes**: [Backport the change to the vulnerable release branch(es)](https://nixos.org/manual/nixpkgs/stable/#submitting-changes-stable-release-branches). 45 - - When the patch has made it into all the relevant branches (`master`, and the vulnerable releases), close the relevant issue(s).
··· 1 # Vulnerability Roundup {#chap-vulnerability-roundup} 2 3 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 4 5 + ## Issues {#vulnerability-roundup-issues} 6 7 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md). 8 9 ## Triaging and Fixing {#vulnerability-roundup-triaging-and-fixing} 10 11 + This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
+10
doc/development.md
···
··· 1 + # Development of Nixpkgs {#part-development} 2 + 3 + This section shows you how Nixpkgs is being developed and how you can interact with the contributors and the latest updates. 4 + If you are interested in contributing yourself, see [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). 5 + 6 + <!-- In the future this section should also include: How to test pull requests, how to know if pull requests are available in channels, etc. --> 7 + 8 + ```{=include=} chapters 9 + development/opening-issues.chapter.md 10 + ```
+7
doc/development/opening-issues.chapter.md
···
··· 1 + # Opening issues {#sec-opening-issues} 2 + 3 + * Make sure you have a [GitHub account](https://github.com/signup/free) 4 + * Make sure there is no open issue on the topic 5 + * [Submit a new issue](https://github.com/NixOS/nixpkgs/issues/new/choose) by choosing the kind of topic and fill out the template 6 + 7 + <!-- In the future this section could also include more detailed information on the issue templates -->
+1
doc/manual.md.in
··· 10 lib.md 11 stdenv.md 12 builders.md 13 contributing.md 14 ```
··· 10 lib.md 11 stdenv.md 12 builders.md 13 + development.md 14 contributing.md 15 ```
+114
maintainers/README.md
···
··· 1 + # Nixpkgs Maintainers 2 + 3 + The *Nixpkgs maintainers* are people who have assigned themselves to 4 + maintain specific individual packages. We encourage people who care 5 + about a package to assign themselves as a maintainer. When a pull 6 + request is made against a package, OfBorg will notify the appropriate 7 + maintainer(s). 8 + 9 + ## Reviewing contributions 10 + 11 + ### Individual maintainer list 12 + 13 + When adding users to [`maintainer-list.nix`](./maintainer-list.nix), the following 14 + checks should be performed: 15 + 16 + - If the user has specified a GPG key, verify that the commit is 17 + signed by their key. 18 + 19 + First, validate that the commit adding the maintainer is signed by 20 + the key the maintainer listed. Check out the pull request and 21 + compare its signing key with the listed key in the commit. 22 + 23 + If the commit is not signed or it is signed by a different user, ask 24 + them to either recommit using that key or to remove their key 25 + information. 26 + 27 + Given a maintainer entry like this: 28 + 29 + ``` nix 30 + { 31 + example = { 32 + email = "user@example.com"; 33 + name = "Example User"; 34 + keys = [{ 35 + fingerprint = "0000 0000 2A70 6423 0AED 3C11 F04F 7A19 AAA6 3AFE"; 36 + }]; 37 + } 38 + }; 39 + ``` 40 + 41 + First receive their key from a keyserver: 42 + 43 + $ gpg --recv-keys 0xF04F7A19AAA63AFE 44 + gpg: key 0xF04F7A19AAA63AFE: public key "Example <user@example.com>" imported 45 + gpg: Total number processed: 1 46 + gpg: imported: 1 47 + 48 + Then check the commit is signed by that key: 49 + 50 + $ git log --show-signature 51 + commit b87862a4f7d32319b1de428adb6cdbdd3a960153 52 + gpg: Signature made Wed Mar 12 13:32:24 2003 +0000 53 + gpg: using RSA key 000000002A7064230AED3C11F04F7A19AAA63AFE 54 + gpg: Good signature from "Example User <user@example.com> 55 + Author: Example User <user@example.com> 56 + Date: Wed Mar 12 13:32:24 2003 +0000 57 + 58 + maintainers: adding example 59 + 60 + and validate that there is a `Good signature` and the printed key 61 + matches the user's submitted key. 62 + 63 + Note: GitHub's "Verified" label does not display the user's full key 64 + fingerprint, and should not be used for validating the key matches. 65 + 66 + - If the user has specified a `github` account name, ensure they have 67 + also specified a `githubId` and verify the two match. 68 + 69 + Maintainer entries that include a `github` field must also include 70 + their `githubId`. People can and do change their GitHub name 71 + frequently, and the ID is used as the official and stable identity 72 + of the maintainer. 73 + 74 + Given a maintainer entry like this: 75 + 76 + ``` nix 77 + { 78 + example = { 79 + email = "user@example.com"; 80 + name = "Example User"; 81 + github = "ghost"; 82 + githubId = 10137; 83 + } 84 + }; 85 + ``` 86 + 87 + First, make sure that the listed GitHub handle matches the author of 88 + the commit. 89 + 90 + Then, visit the URL `https://api.github.com/users/ghost` and 91 + validate that the `id` field matches the provided `githubId`. 92 + 93 + ### Maintainer teams 94 + 95 + Feel free to create a new maintainer team in [`team-list.nix`](./team-list.nix) 96 + when a group is collectively responsible for a collection of packages. 97 + Use taste and personal judgement when deciding if a team is warranted. 98 + 99 + Teams are allowed to define their own rules about membership. 100 + 101 + For example, some teams will represent a business or other group which 102 + wants to carefully track its members. Other teams may be very open about 103 + who can join, and allow anybody to participate. 104 + 105 + When reviewing changes to a team, read the team's scope and the context 106 + around the member list for indications about the team's membership 107 + policy. 108 + 109 + In any case, request reviews from the existing team members. If the team 110 + lists no specific membership policy, feel free to merge changes to the 111 + team after giving the existing members a few days to respond. 112 + 113 + *Important:* If a team says it is a closed group, do not merge additions 114 + to the team without an approval by at least one existing member.
-5
nixos/README
··· 1 - *** NixOS *** 2 - 3 - NixOS is a Linux distribution based on the purely functional package 4 - management system Nix. More information can be found at 5 - https://nixos.org/nixos and in the manual in doc/manual.
···
+86
nixos/README.md
···
··· 1 + # NixOS 2 + 3 + NixOS is a Linux distribution based on the purely functional package 4 + management system Nix. More information can be found at 5 + https://nixos.org/nixos and in the manual in doc/manual. 6 + 7 + ## Testing changes 8 + 9 + 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`. 10 + 11 + ## Reviewing contributions 12 + 13 + 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. 14 + 15 + ### Module updates 16 + 17 + Module updates are submissions changing modules in some ways. These often contains changes to the options or introduce new options. 18 + 19 + Reviewing process: 20 + 21 + - Ensure that the module maintainers are notified. 22 + - [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. 23 + - Ensure that the module tests, if any, are succeeding. 24 + - Ensure that the introduced options are correct. 25 + - Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated). 26 + - Description, default and example should be provided. 27 + - Ensure that option changes are backward compatible. 28 + - `mkRenamedOptionModuleWith` provides a way to make option changes backward compatible. 29 + - Ensure that removed options are declared with `mkRemovedOptionModule` 30 + - Ensure that changes that are not backward compatible are mentioned in release notes. 31 + - Ensure that documentations affected by the change is updated. 32 + 33 + Sample template for a module update review is provided below. 34 + 35 + ```markdown 36 + ##### Reviewed points 37 + 38 + - [ ] changes are backward compatible 39 + - [ ] removed options are declared with `mkRemovedOptionModule` 40 + - [ ] changes that are not backward compatible are documented in release notes 41 + - [ ] module tests succeed on ARCHITECTURE 42 + - [ ] options types are appropriate 43 + - [ ] options description is set 44 + - [ ] options example is provided 45 + - [ ] documentation affected by the changes is updated 46 + 47 + ##### Possible improvements 48 + 49 + ##### Comments 50 + ``` 51 + 52 + ### New modules 53 + 54 + New modules submissions introduce a new module to NixOS. 55 + 56 + Reviewing process: 57 + 58 + - Ensure that the module tests, if any, are succeeding. 59 + - Ensure that the introduced options are correct. 60 + - Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated). 61 + - Description, default and example should be provided. 62 + - Ensure that module `meta` field is present 63 + - Maintainers should be declared in `meta.maintainers`. 64 + - Module documentation should be declared with `meta.doc`. 65 + - Ensure that the module respect other modules functionality. 66 + - For example, enabling a module should not open firewall ports by default. 67 + 68 + Sample template for a new module review is provided below. 69 + 70 + ```markdown 71 + ##### Reviewed points 72 + 73 + - [ ] module path fits the guidelines 74 + - [ ] module tests succeed on ARCHITECTURE 75 + - [ ] options have appropriate types 76 + - [ ] options have default 77 + - [ ] options have example 78 + - [ ] options have descriptions 79 + - [ ] No unneeded package is added to environment.systemPackages 80 + - [ ] meta.maintainers is set 81 + - [ ] module documentation is declared in meta.doc 82 + 83 + ##### Possible improvements 84 + 85 + ##### Comments 86 + ```
+837
pkgs/README.md
···
··· 1 + # Contributing to Nixpkgs packages 2 + 3 + This document is for people wanting to contribute specifically to the package collection in Nixpkgs. 4 + See the [CONTRIBUTING.md](../CONTRIBUTING.md) document for more general information. 5 + 6 + ## Overview 7 + 8 + - [`top-level`](./top-level): Entrypoints, package set aggregations 9 + - [`impure.nix`](./top-level/impure.nix), [`default.nix`](./top-level/default.nix), [`config.nix`](./top-level/config.nix): Definitions for the evaluation entry point of `import <nixpkgs>` 10 + - [`stage.nix`](./top-level/stage.nix), [`all-packages.nix`](./top-level/all-packages.nix), [`splice.nix`](./top-level/splice.nix): Definitions for the top-level attribute set made available through `import <nixpkgs> {…}` 11 + - `*-packages.nix`, [`linux-kernels.nix`](./top-level/linux-kernels.nix), [`unixtools.nix`](./top-level/unixtools.nix): Aggregations of nested package sets defined in `development` 12 + - [`aliases.nix`](./top-level/aliases.nix), [`python-aliases.nix`](./top-level/python-aliases.nix): Aliases for package definitions that have been renamed or removed 13 + - `release*.nix`, [`make-tarball.nix`](./top-level/make-tarball.nix), [`packages-config.nix`](./top-level/packages-config.nix), [`metrics.nix`](./top-level/metrics.nix), [`nixpkgs-basic-release-checks.nix`](./top-level/nixpkgs-basic-release-checks.nix): Entry-points and utilities used by Hydra for continuous integration 14 + - [`development`](./development) 15 + - `*-modules`, `*-packages`, `*-pkgs`: Package definitions for nested package sets 16 + - All other directories loosely categorise top-level package definitions, see [category hierarchy][categories] 17 + - [`build-support`](./build-support): [Builders](https://nixos.org/manual/nixpkgs/stable/#part-builders) 18 + - `fetch*`: [Fetchers](https://nixos.org/manual/nixpkgs/stable/#chap-pkgs-fetchers) 19 + - [`stdenv`](./stdenv): [Standard environment](https://nixos.org/manual/nixpkgs/stable/#part-stdenv) 20 + - [`pkgs-lib`](./pkgs-lib): Definitions for utilities that need packages but are not needed for packages 21 + - [`test`](./test): Tests not directly associated with any specific packages 22 + - All other directories loosely categorise top-level packages definitions, see [category hierarchy][categories] 23 + 24 + ## Quick Start to Adding a Package 25 + 26 + To add a package to Nixpkgs: 27 + 28 + 1. Checkout the Nixpkgs source tree: 29 + 30 + ```ShellSession 31 + $ git clone https://github.com/NixOS/nixpkgs 32 + $ cd nixpkgs 33 + ``` 34 + 35 + 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 the [category hierarchy section][categories] for some hints on the tree organisation. Create a directory for your package, e.g. 36 + 37 + ```ShellSession 38 + $ mkdir pkgs/development/libraries/libfoo 39 + ``` 40 + 41 + 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`. 42 + 43 + ```ShellSession 44 + $ emacs pkgs/development/libraries/libfoo/default.nix 45 + $ git add pkgs/development/libraries/libfoo/default.nix 46 + ``` 47 + 48 + You can have a look at the existing Nix expressions under `pkgs/` to see how it’s done. Here are some good ones: 49 + 50 + - GNU Hello: [`pkgs/applications/misc/hello/default.nix`](applications/misc/hello/default.nix). Trivial package, which specifies some `meta` attributes which is good practice. 51 + 52 + - GNU cpio: [`pkgs/tools/archivers/cpio/default.nix`](tools/archivers/cpio/default.nix). Also a simple package. The generic builder in `stdenv` does everything for you. It has no dependencies beyond `stdenv`. 53 + 54 + - GNU Multiple Precision arithmetic library (GMP): [`pkgs/development/libraries/gmp/5.1.x.nix`](development/libraries/gmp/5.1.x.nix). Also done by the generic builder, but has a dependency on `m4`. 55 + 56 + - Pan, a GTK-based newsreader: [`pkgs/applications/networking/newsreaders/pan/default.nix`](applications/networking/newsreaders/pan/default.nix). Has an optional dependency on `gtkspell`, which is only built if `spellCheck` is `true`. 57 + 58 + - Apache HTTPD: [`pkgs/servers/http/apache-httpd/2.4.nix`](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. 59 + 60 + - buildMozillaMach: [`pkgs/applications/networking/browser/firefox/common.nix`](applications/networking/browsers/firefox/common.nix). A reusable build function for Firefox, Thunderbird and Librewolf. 61 + 62 + - JDiskReport, a Java utility: [`pkgs/tools/misc/jdiskreport/default.nix`](tools/misc/jdiskreport/default.nix). Nixpkgs doesn’t have a decent `stdenv` for Java yet so this is pretty ad-hoc. 63 + 64 + - XML::Simple, a Perl module: [`pkgs/top-level/perl-packages.nix`](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. 65 + 66 + - Adobe Reader: [`pkgs/applications/misc/adobe-reader/default.nix`](applications/misc/adobe-reader/default.nix). Shows how binary-only packages can be supported. In particular the [builder](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. 67 + 68 + Some notes: 69 + 70 + - All [`meta`](https://nixos.org/manual/nixpkgs/stable/#chap-meta) attributes are optional, but it’s still a good idea to provide at least the `description`, `homepage` and [`license`](https://nixos.org/manual/nixpkgs/stable/#sec-meta-license). 71 + 72 + - 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. 73 + 74 + - A list of schemes for `mirror://` URLs can be found in [`pkgs/build-support/fetchurl/mirrors.nix`](build-support/fetchurl/mirrors.nix). 75 + 76 + The exact syntax and semantics of the Nix expression language, including the built-in function, are [described in the Nix manual](https://nixos.org/manual/nix/stable/language/). 77 + 78 + 4. Add a call to the function defined in the previous step to [`pkgs/top-level/all-packages.nix`](top-level/all-packages.nix) with some descriptive name for the variable, e.g. `libfoo`. 79 + 80 + ```ShellSession 81 + $ emacs pkgs/top-level/all-packages.nix 82 + ``` 83 + 84 + 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. 85 + 86 + 5. To test whether the package builds, run the following command from the root of the nixpkgs source tree: 87 + 88 + ```ShellSession 89 + $ nix-build -A libfoo 90 + ``` 91 + 92 + 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. 93 + 94 + 6. If you want to install the package into your profile (optional), do 95 + 96 + ```ShellSession 97 + $ nix-env -f . -iA libfoo 98 + ``` 99 + 100 + 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. 101 + 102 + ## Category Hierarchy 103 + [categories]: #category-hierarchy 104 + 105 + 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`. 106 + 107 + When in doubt, consider refactoring the `pkgs/` tree, e.g. creating new categories or splitting up an existing category. 108 + 109 + **If it’s used to support _software development_:** 110 + 111 + - **If it’s a _library_ used by other packages:** 112 + 113 + - `development/libraries` (e.g. `libxml2`) 114 + 115 + - **If it’s a _compiler_:** 116 + 117 + - `development/compilers` (e.g. `gcc`) 118 + 119 + - **If it’s an _interpreter_:** 120 + 121 + - `development/interpreters` (e.g. `guile`) 122 + 123 + - **If it’s a (set of) development _tool(s)_:** 124 + 125 + - **If it’s a _parser generator_ (including lexers):** 126 + 127 + - `development/tools/parsing` (e.g. `bison`, `flex`) 128 + 129 + - **If it’s a _build manager_:** 130 + 131 + - `development/tools/build-managers` (e.g. `gnumake`) 132 + 133 + - **If it’s a _language server_:** 134 + 135 + - `development/tools/language-servers` (e.g. `ccls` or `rnix-lsp`) 136 + 137 + - **Else:** 138 + 139 + - `development/tools/misc` (e.g. `binutils`) 140 + 141 + - **Else:** 142 + 143 + - `development/misc` 144 + 145 + **If it’s a (set of) _tool(s)_:** 146 + 147 + (A tool is a relatively small program, especially one intended to be used non-interactively.) 148 + 149 + - **If it’s for _networking_:** 150 + 151 + - `tools/networking` (e.g. `wget`) 152 + 153 + - **If it’s for _text processing_:** 154 + 155 + - `tools/text` (e.g. `diffutils`) 156 + 157 + - **If it’s a _system utility_, i.e., something related or essential to the operation of a system:** 158 + 159 + - `tools/system` (e.g. `cron`) 160 + 161 + - **If it’s an _archiver_ (which may include a compression function):** 162 + 163 + - `tools/archivers` (e.g. `zip`, `tar`) 164 + 165 + - **If it’s a _compression_ program:** 166 + 167 + - `tools/compression` (e.g. `gzip`, `bzip2`) 168 + 169 + - **If it’s a _security_-related program:** 170 + 171 + - `tools/security` (e.g. `nmap`, `gnupg`) 172 + 173 + - **Else:** 174 + 175 + - `tools/misc` 176 + 177 + **If it’s a _shell_:** 178 + 179 + - `shells` (e.g. `bash`) 180 + 181 + **If it’s a _server_:** 182 + 183 + - **If it’s a web server:** 184 + 185 + - `servers/http` (e.g. `apache-httpd`) 186 + 187 + - **If it’s an implementation of the X Windowing System:** 188 + 189 + - `servers/x11` (e.g. `xorg` — this includes the client libraries and programs) 190 + 191 + - **Else:** 192 + 193 + - `servers/misc` 194 + 195 + **If it’s a _desktop environment_:** 196 + 197 + - `desktops` (e.g. `kde`, `gnome`, `enlightenment`) 198 + 199 + **If it’s a _window manager_:** 200 + 201 + - `applications/window-managers` (e.g. `awesome`, `stumpwm`) 202 + 203 + **If it’s an _application_:** 204 + 205 + A (typically large) program with a distinct user interface, primarily used interactively. 206 + 207 + - **If it’s a _version management system_:** 208 + 209 + - `applications/version-management` (e.g. `subversion`) 210 + 211 + - **If it’s a _terminal emulator_:** 212 + 213 + - `applications/terminal-emulators` (e.g. `alacritty` or `rxvt` or `termite`) 214 + 215 + - **If it’s a _file manager_:** 216 + 217 + - `applications/file-managers` (e.g. `mc` or `ranger` or `pcmanfm`) 218 + 219 + - **If it’s for _video playback / editing_:** 220 + 221 + - `applications/video` (e.g. `vlc`) 222 + 223 + - **If it’s for _graphics viewing / editing_:** 224 + 225 + - `applications/graphics` (e.g. `gimp`) 226 + 227 + - **If it’s for _networking_:** 228 + 229 + - **If it’s a _mailreader_:** 230 + 231 + - `applications/networking/mailreaders` (e.g. `thunderbird`) 232 + 233 + - **If it’s a _newsreader_:** 234 + 235 + - `applications/networking/newsreaders` (e.g. `pan`) 236 + 237 + - **If it’s a _web browser_:** 238 + 239 + - `applications/networking/browsers` (e.g. `firefox`) 240 + 241 + - **Else:** 242 + 243 + - `applications/networking/misc` 244 + 245 + - **Else:** 246 + 247 + - `applications/misc` 248 + 249 + **If it’s _data_ (i.e., does not have a straight-forward executable semantics):** 250 + 251 + - **If it’s a _font_:** 252 + 253 + - `data/fonts` 254 + 255 + - **If it’s an _icon theme_:** 256 + 257 + - `data/icons` 258 + 259 + - **If it’s related to _SGML/XML processing_:** 260 + 261 + - **If it’s an _XML DTD_:** 262 + 263 + - `data/sgml+xml/schemas/xml-dtd` (e.g. `docbook`) 264 + 265 + - **If it’s an _XSLT stylesheet_:** 266 + 267 + (Okay, these are executable...) 268 + 269 + - `data/sgml+xml/stylesheets/xslt` (e.g. `docbook-xsl`) 270 + 271 + - **If it’s a _theme_ for a _desktop environment_, a _window manager_ or a _display manager_:** 272 + 273 + - `data/themes` 274 + 275 + **If it’s a _game_:** 276 + 277 + - `games` 278 + 279 + **Else:** 280 + 281 + - `misc` 282 + 283 + # Conventions 284 + 285 + ## Package naming 286 + 287 + 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. 288 + 289 + In Nixpkgs, there are generally three different names associated with a package: 290 + 291 + - The `pname` attribute of the derivation. This is what most users see, in particular when using `nix-env`. 292 + 293 + - 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`. 294 + 295 + - The filename for (the directory containing) the Nix expression. 296 + 297 + 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`. 298 + 299 + There are a few naming guidelines: 300 + 301 + - The `pname` attribute _should_ be identical to the upstream package name. 302 + 303 + - The `pname` and the `version` attribute _must not_ contain uppercase letters — e.g., `"mplayer" instead of `"MPlayer"`. 304 + 305 + - The `version` attribute _must_ start with a digit e.g`"0.3.1rc2". 306 + 307 + - If a package is a commit from a repository without a version assigned, then the `version` attribute _should_ be the latest upstream version preceding that commit, followed by `-unstable-` and the date of the (fetched) commit. The date _must_ be in `"YYYY-MM-DD"` format. 308 + 309 + Example: Given a project had its latest releases `2.2` in November 2021, and `3.0` in January 2022, a commit authored on March 15, 2022 for an upcoming bugfix release `2.2.1` would have `version = "2.2-unstable-2022-03-15"`. 310 + 311 + - 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. 312 + 313 + - 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 [versioning][versioning]. 314 + 315 + ## Versioning 316 + [versioning]: #versioning 317 + 318 + 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. 319 + 320 + 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`. 321 + 322 + All versions of a package _must_ be included in `all-packages.nix` to make sure that they evaluate correctly. 323 + 324 + ## Meta attributes 325 + 326 + * `meta.description` must: 327 + * Be short, just one sentence. 328 + * Be capitalized. 329 + * Not start with the package name. 330 + * More generally, it should not refer to the package name. 331 + * Not end with a period (or any punctuation for that matter). 332 + * Aim to inform while avoiding subjective language. 333 + * `meta.license` must be set and fit the upstream license. 334 + * If there is no upstream license, `meta.license` should default to `lib.licenses.unfree`. 335 + * If in doubt, try to contact the upstream developers for clarification. 336 + * `meta.mainProgram` must be set when appropriate. 337 + * `meta.maintainers` should be set. 338 + 339 + See the nixpkgs manual for more details on [standard meta-attributes](https://nixos.org/nixpkgs/manual/#sec-standard-meta-attributes). 340 + 341 + ### Import From Derivation 342 + 343 + Import From Derivation (IFD) is disallowed in Nixpkgs for performance reasons: 344 + [Hydra] evaluates the entire package set, and sequential builds during evaluation would increase evaluation times to become impractical. 345 + 346 + [Hydra]: https://github.com/NixOS/hydra 347 + 348 + Import From Derivation can be worked around in some cases by committing generated intermediate files to version control and reading those instead. 349 + 350 + <!-- TODO: remove the following and link to Nix manual once https://github.com/NixOS/nix/pull/7332 is merged --> 351 + 352 + See also [NixOS Wiki: Import From Derivation]. 353 + 354 + [NixOS Wiki: Import From Derivation]: https://nixos.wiki/wiki/Import_From_Derivation 355 + 356 + ## Sources 357 + 358 + ### Fetching Sources 359 + 360 + 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. 361 + 362 + You can find many source fetch helpers in `pkgs/build-support/fetch*`. 363 + 364 + 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: 365 + 366 + - Bad: Uses `git://` which won't be proxied. 367 + 368 + ```nix 369 + src = fetchgit { 370 + url = "git@github.com:NixOS/nix.git" 371 + url = "git://github.com/NixOS/nix.git"; 372 + rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; 373 + hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ="; 374 + } 375 + ``` 376 + 377 + - Better: This is ok, but an archive fetch will still be faster. 378 + 379 + ```nix 380 + src = fetchgit { 381 + url = "https://github.com/NixOS/nix.git"; 382 + rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; 383 + hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ="; 384 + } 385 + ``` 386 + 387 + - Best: Fetches a snapshot archive and you get the rev you want. 388 + 389 + ```nix 390 + src = fetchFromGitHub { 391 + owner = "NixOS"; 392 + repo = "nix"; 393 + rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; 394 + hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ="; 395 + } 396 + ``` 397 + 398 + 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`. 399 + 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). 400 + 401 + Find the value to put as `hash` by running `nix-shell -p nix-prefetch-github --run "nix-prefetch-github --rev 1f795f9f44607cc5bec70d1300150bfefcef2aae NixOS nix"`. 402 + 403 + #### Obtaining source hash 404 + 405 + Preferred source hash type is sha256. There are several ways to get it. 406 + 407 + 1. Prefetch URL (with `nix-prefetch-XXX URL`, where `XXX` is one of `url`, `git`, `hg`, `cvs`, `bzr`, `svn`). Hash is printed to stdout. 408 + 409 + 2. Prefetch by package source (with `nix-prefetch-url '<nixpkgs>' -A PACKAGE.src`, where `PACKAGE` is package attribute name). Hash is printed to stdout. 410 + 411 + 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). 412 + 413 + 3. Upstream provided hash: use it when upstream provides `sha256` or `sha512` (when upstream provides `md5`, don't use it, compute `sha256` instead). 414 + 415 + 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. 416 + 417 + You can convert between formats with nix-hash, for example: 418 + 419 + ```ShellSession 420 + $ nix-hash --type sha256 --to-base32 HASH 421 + ``` 422 + 423 + 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. 424 + 425 + 5. Fake hash: set the hash to one of 426 + 427 + - `""` 428 + - `lib.fakeHash` 429 + - `lib.fakeSha256` 430 + - `lib.fakeSha512` 431 + 432 + in the package expression, attempt build and extract correct hash from error messages. 433 + 434 + > **Warning** 435 + > You must use one of these four fake hashes and not some arbitrarily-chosen hash. 436 + > See [here][secure-hashes] 437 + 438 + 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. 439 + 440 + 441 + #### Obtaining hashes securely 442 + [secure-hashes]: #obtaining-hashes-securely 443 + 444 + 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: 445 + 446 + - `http://` URLs are not secure to prefetch hash from; 447 + 448 + - hashes from upstream (in method 3) should be obtained via secure protocol; 449 + 450 + - `https://` URLs are secure in methods 1, 2, 3; 451 + 452 + - `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. 453 + 454 + ### Patches 455 + 456 + Patches available online should be retrieved using `fetchpatch`. 457 + 458 + ```nix 459 + patches = [ 460 + (fetchpatch { 461 + name = "fix-check-for-using-shared-freetype-lib.patch"; 462 + url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=8f5d285"; 463 + hash = "sha256-uRcxaCjd+WAuGrXOmGfFeu79cUILwkRdBu48mwcBE7g="; 464 + }) 465 + ]; 466 + ``` 467 + 468 + 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. 469 + 470 + 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 [the `fetchpatch` reference](https://nixos.org/manual/nixpkgs/unstable/#fetchpatch) for details. 471 + 472 + ```nix 473 + patches = [ ./0001-changes.patch ]; 474 + ``` 475 + 476 + If you do need to do create this sort of patch file, one way to do so is with git: 477 + 478 + 1. Move to the root directory of the source code you're patching. 479 + 480 + ```ShellSession 481 + $ cd the/program/source 482 + ``` 483 + 484 + 2. If a git repository is not already present, create one and stage all of the source files. 485 + 486 + ```ShellSession 487 + $ git init 488 + $ git add . 489 + ``` 490 + 491 + 3. Edit some files to make whatever changes need to be included in the patch. 492 + 493 + 4. Use git to create a diff, and pipe the output to a patch file: 494 + 495 + ```ShellSession 496 + $ git diff -a > nixpkgs/pkgs/the/package/0001-changes.patch 497 + ``` 498 + 499 + ## Deprecating/removing packages 500 + 501 + There is currently no policy when to remove a package. 502 + 503 + Before removing a package, one should try to find a new maintainer or fix smaller issues first. 504 + 505 + ### Steps to remove a package from Nixpkgs 506 + 507 + We use jbidwatcher as an example for a discontinued project here. 508 + 509 + 1. Have Nixpkgs checked out locally and up to date. 510 + 1. Create a new branch for your change, e.g. `git checkout -b jbidwatcher` 511 + 1. Remove the actual package including its directory, e.g. `git rm -rf pkgs/applications/misc/jbidwatcher` 512 + 1. Remove the package from the list of all packages (`pkgs/top-level/all-packages.nix`). 513 + 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.) 514 + 515 + For example in this case: 516 + 517 + ``` 518 + jbidwatcher = throw "jbidwatcher was discontinued in march 2021"; # added 2021-03-15 519 + ``` 520 + 521 + The throw message should explain in short why the package was removed for users that still have it installed. 522 + 523 + 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. 524 + 1. Commit the changes. Explain again why the package was removed. If it was declared discontinued upstream, add a link to the source. 525 + 526 + ```ShellSession 527 + $ git add pkgs/applications/misc/jbidwatcher/default.nix pkgs/top-level/all-packages.nix pkgs/top-level/aliases.nix 528 + $ git commit 529 + ``` 530 + 531 + Example commit message: 532 + 533 + ``` 534 + jbidwatcher: remove 535 + 536 + project was discontinued in march 2021. the program does not work anymore because ebay changed the login. 537 + 538 + https://web.archive.org/web/20210315205723/http://www.jbidwatcher.com/ 539 + ``` 540 + 541 + 1. Push changes to your GitHub fork with `git push` 542 + 1. Create a pull request against Nixpkgs. Mention the package maintainer. 543 + 544 + 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) 545 + 546 + ## Package tests 547 + 548 + To run the main types of tests locally: 549 + 550 + - Run package-internal tests with `nix-build --attr pkgs.PACKAGE.passthru.tests` 551 + - Run [NixOS tests](https://nixos.org/manual/nixos/unstable/#sec-nixos-tests) with `nix-build --attr nixosTest.NAME`, where `NAME` is the name of the test listed in `nixos/tests/all-tests.nix` 552 + - Run [global package tests](https://nixos.org/manual/nixpkgs/unstable/#sec-package-tests) with `nix-build --attr tests.PACKAGE`, where `PACKAGE` is the name of the test listed in `pkgs/test/default.nix` 553 + - See `lib/tests/NAME.nix` for instructions on running specific library tests 554 + 555 + Tests are important to ensure quality and make reviews and automatic updates easy. 556 + 557 + The following types of tests exists: 558 + 559 + * [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. 560 + * 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. 561 + * The **`checkPhase` of a package**, which should execute the unit tests that are included in the source code of a package. 562 + 563 + 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). 564 + 565 + ### Writing inline package tests 566 + 567 + For very simple tests, they can be written inline: 568 + 569 + ```nix 570 + { …, yq-go }: 571 + 572 + buildGoModule rec { 573 + 574 + 575 + passthru.tests = { 576 + simple = runCommand "${pname}-test" {} '' 577 + echo "test: 1" | ${yq-go}/bin/yq eval -j > $out 578 + [ "$(cat $out | tr -d $'\n ')" = '{"test":1}' ] 579 + ''; 580 + }; 581 + } 582 + ``` 583 + 584 + ### Writing larger package tests 585 + [larger-package-tests]: #writing-larger-package-tests 586 + 587 + This is an example using the `phoronix-test-suite` package with the current best practices. 588 + 589 + Add the tests in `passthru.tests` to the package definition like this: 590 + 591 + ```nix 592 + { stdenv, lib, fetchurl, callPackage }: 593 + 594 + stdenv.mkDerivation { 595 + 596 + 597 + passthru.tests = { 598 + simple-execution = callPackage ./tests.nix { }; 599 + }; 600 + 601 + meta = { … }; 602 + } 603 + ``` 604 + 605 + Create `tests.nix` in the package directory: 606 + 607 + ```nix 608 + { runCommand, phoronix-test-suite }: 609 + 610 + let 611 + inherit (phoronix-test-suite) pname version; 612 + in 613 + 614 + runCommand "${pname}-tests" { meta.timeout = 60; } 615 + '' 616 + # automatic initial setup to prevent interactive questions 617 + ${phoronix-test-suite}/bin/phoronix-test-suite enterprise-setup >/dev/null 618 + # get version of installed program and compare with package version 619 + if [[ `${phoronix-test-suite}/bin/phoronix-test-suite version` != *"${version}"* ]]; then 620 + echo "Error: program version does not match package version" 621 + exit 1 622 + fi 623 + # run dummy command 624 + ${phoronix-test-suite}/bin/phoronix-test-suite dummy_module.dummy-command >/dev/null 625 + # needed for Nix to register the command as successful 626 + touch $out 627 + '' 628 + ``` 629 + 630 + ### Running package tests 631 + 632 + You can run these tests with: 633 + 634 + ```ShellSession 635 + $ cd path/to/nixpkgs 636 + $ nix-build -A phoronix-test-suite.tests 637 + ``` 638 + 639 + ### Examples of package tests 640 + 641 + Here are examples of package tests: 642 + 643 + - [Jasmin compile test](development/compilers/jasmin/test-assemble-hello-world/default.nix) 644 + - [Lobster compile test](development/compilers/lobster/test-can-run-hello-world.nix) 645 + - [Spacy annotation test](development/python-modules/spacy/annotation-test/default.nix) 646 + - [Libtorch test](development/libraries/science/math/libtorch/test/default.nix) 647 + - [Multiple tests for nanopb](development/libraries/nanopb/default.nix) 648 + 649 + ### Linking NixOS module tests to a package 650 + 651 + Like [package tests][larger-package-tests] 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. 652 + 653 + For example, assuming we're packaging `nginx`, we can link its module test via `passthru.tests`: 654 + 655 + ```nix 656 + { stdenv, lib, nixosTests }: 657 + 658 + stdenv.mkDerivation { 659 + ... 660 + 661 + passthru.tests = { 662 + nginx = nixosTests.nginx; 663 + }; 664 + 665 + ... 666 + } 667 + ``` 668 + 669 + ## Reviewing contributions 670 + 671 + ### Package updates 672 + 673 + 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. 674 + 675 + It can happen that non-trivial updates include patches or more complex changes. 676 + 677 + Reviewing process: 678 + 679 + - Ensure that the package versioning fits the guidelines. 680 + - Ensure that the commit text fits the guidelines. 681 + - Ensure that the package maintainers are notified. 682 + - [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. 683 + - Ensure that the meta field information is correct. 684 + - License can change with version updates, so it should be checked to match the upstream license. 685 + - 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. 686 + - Ensure that the code contains no typos. 687 + - Building the package locally. 688 + - 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. 689 + - 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. 690 + 691 + ```ShellSession 692 + $ git fetch origin nixos-unstable 693 + $ git fetch origin pull/PRNUMBER/head 694 + $ git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD 695 + ``` 696 + 697 + - The first command fetches the nixos-unstable branch. 698 + - 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. 699 + - The third command rebases the pull request changes to the nixos-unstable branch. 700 + - 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. 701 + 702 + ```ShellSession 703 + $ nix-shell -p nixpkgs-review --run "nixpkgs-review pr PRNUMBER" 704 + ``` 705 + - Running every binary. 706 + 707 + Sample template for a package update review is provided below. 708 + 709 + ```markdown 710 + ##### Reviewed points 711 + 712 + - [ ] package name fits guidelines 713 + - [ ] package version fits guidelines 714 + - [ ] package build on ARCHITECTURE 715 + - [ ] executables tested on ARCHITECTURE 716 + - [ ] all depending packages build 717 + - [ ] patches have a comment describing either the upstream URL or a reason why the patch wasn't upstreamed 718 + - [ ] patches that are remotely available are fetched rather than vendored 719 + 720 + ##### Possible improvements 721 + 722 + ##### Comments 723 + ``` 724 + 725 + ### New packages 726 + 727 + New packages are a common type of pull requests. These pull requests consists in adding a new nix-expression for a package. 728 + 729 + Review process: 730 + 731 + - Ensure that the package versioning fits the guidelines. 732 + - Ensure that the commit name fits the guidelines. 733 + - Ensure that the meta fields contain correct information. 734 + - License must match the upstream license. 735 + - Platforms should be set (or the package will not get binary substitutes). 736 + - Maintainers must be set. This can be the package submitter or a community member that accepts taking up maintainership of the package. 737 + - Report detected typos. 738 + - Ensure the package source: 739 + - Uses mirror URLs when available. 740 + - Uses the most appropriate functions (e.g. packages from GitHub should use `fetchFromGitHub`). 741 + - Building the package locally. 742 + - Running every binary. 743 + 744 + Sample template for a new package review is provided below. 745 + 746 + ```markdown 747 + ##### Reviewed points 748 + 749 + - [ ] package path fits guidelines 750 + - [ ] package name fits guidelines 751 + - [ ] package version fits guidelines 752 + - [ ] package build on ARCHITECTURE 753 + - [ ] executables tested on ARCHITECTURE 754 + - [ ] `meta.description` is set and fits guidelines 755 + - [ ] `meta.license` fits upstream license 756 + - [ ] `meta.platforms` is set 757 + - [ ] `meta.maintainers` is set 758 + - [ ] build time only dependencies are declared in `nativeBuildInputs` 759 + - [ ] source is fetched using the appropriate function 760 + - [ ] the list of `phases` is not overridden 761 + - [ ] when a phase (like `installPhase`) is overridden it starts with `runHook preInstall` and ends with `runHook postInstall`. 762 + - [ ] patches have a comment describing either the upstream URL or a reason why the patch wasn't upstreamed 763 + - [ ] patches that are remotely available are fetched rather than vendored 764 + 765 + ##### Possible improvements 766 + 767 + ##### Comments 768 + ``` 769 + 770 + ## Security 771 + 772 + ### Submitting security fixes 773 + [security-fixes]: #submitting-security-fixes 774 + 775 + Security fixes are submitted in the same way as other changes and thus the same guidelines apply. 776 + 777 + - If a new version fixing the vulnerability has been released, update the package; 778 + - 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. 779 + 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.: 780 + 781 + ```nix 782 + (fetchpatch { 783 + name = "CVE-2019-11068.patch"; 784 + url = "https://gitlab.gnome.org/GNOME/libxslt/commit/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch"; 785 + hash = "sha256-SEKe/8HcW0UBHCfPTTOnpRlzmV2nQPPeL6HOMxBZd14="; 786 + }) 787 + ``` 788 + 789 + 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. 790 + 791 + Critical security fixes may by-pass the staging branches and be delivered directly to release branches such as `master` and `release-*`. 792 + 793 + ### Vulnerability Roundup 794 + 795 + #### Issues 796 + 797 + Vulnerable packages in Nixpkgs are managed using issues. 798 + Currently opened ones can be found using the following: 799 + 800 + [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) 801 + 802 + Each issue correspond to a vulnerable version of a package; As a consequence: 803 + 804 + - One issue can contain several CVEs; 805 + - One CVE can be shared across several issues; 806 + - A single package can be concerned by several issues. 807 + 808 + 809 + A "Vulnerability roundup" issue usually respects the following format: 810 + 811 + ```txt 812 + <link to relevant package search on search.nix.gsc.io>, <link to relevant files in Nixpkgs on GitHub> 813 + 814 + <list of related CVEs, their CVSS score, and the impacted NixOS version> 815 + 816 + <list of the scanned Nixpkgs versions> 817 + 818 + <list of relevant contributors> 819 + ``` 820 + 821 + Note that there can be an extra comment containing links to previously reported (and still open) issues for the same package. 822 + 823 + 824 + #### Triaging and Fixing 825 + 826 + **Note**: An issue can be a "false positive" (i.e. automatically opened, but without the package it refers to being actually vulnerable). 827 + 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. 828 + 829 + If you are investigating a "true positive": 830 + 831 + - Find the earliest patched version or a code patch in the CVE details; 832 + - Is the issue already patched (version up-to-date or patch applied manually) in Nixpkgs's `master` branch? 833 + - **No**: 834 + - [Submit a security fix][security-fixes]; 835 + - Once the fix is merged into `master`, [submit the change to the vulnerable release branch(es)](../CONTRIBUTING.md#how-to-backport-pull-requests); 836 + - **Yes**: [Backport the change to the vulnerable release branch(es)](../CONTRIBUTING.md#how-to-backport-pull-requests). 837 + - When the patch has made it into all the relevant branches (`master`, and the vulnerable releases), close the relevant issue(s).