···11-# How to contribute
11+# Contributing to Nixpkgs
22+33+This document is for people wanting to contribute to the implementation of Nixpkgs.
44+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).
55+66+As such, a GitHub account is recommended, which you can sign up for [here](https://github.com/signup).
77+See [here](https://discourse.nixos.org/t/about-the-patches-category/477) for how to contribute without a GitHub account.
88+99+Additionally this document assumes that you already know how to use GitHub and Git.
1010+If that's not the case, we recommend learning about it first [here](https://docs.github.com/en/get-started/quickstart/hello-world).
1111+1212+## Overview
1313+[overview]: #overview
21433-Note: contributing implies licensing those contributions
44-under the terms of [COPYING](COPYING), which is an MIT-like license.
1515+This file contains general contributing information, but individual parts also have more specific information to them in their respective `README.md` files, linked here:
1616+- [`lib`](./lib/README.md): Sources and documentation of the [library functions](https://nixos.org/manual/nixpkgs/stable/#chap-functions)
1717+- [`maintainers`](./maintainers/README.md): Nixpkgs maintainer and team listings, maintainer scripts
1818+- [`pkgs`](./pkgs/README.md): Package and [builder](https://nixos.org/manual/nixpkgs/stable/#part-builders) definitions
1919+- [`doc`](./doc/README.md): Sources and infrastructure for the [Nixpkgs manual](https://nixos.org/manual/nixpkgs/stable/)
2020+- [`nixos`](./nixos/README.md): Implementation of [NixOS](https://nixos.org/manual/nixos/stable/)
52166-## Opening issues
2222+# How to's
72388-* Make sure you have a [GitHub account](https://github.com/signup/free)
99-* Make sure there is no open issue on the topic
1010-* [Submit a new issue](https://github.com/NixOS/nixpkgs/issues/new/choose) by choosing the kind of topic and fill out the template
2424+## How to create pull requests
2525+[pr-create]: #how-to-create-pull-requests
11261212-## Submitting changes
2727+This section describes in some detail how changes can be made and proposed with pull requests.
13281414-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.
2929+> **Note**
3030+> Be aware that contributing implies licensing those contributions under the terms of [COPYING](./COPYING), an MIT-like license.
15311616-Below is a short excerpt of some points in there:
3232+0. Set up a local version of Nixpkgs to work with using GitHub and Git
3333+ 1. [Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository) the [Nixpkgs repository](https://github.com/nixos/nixpkgs/).
3434+ 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.
3535+ 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).
17361818-* Format the commit messages in the following way:
3737+1. Figure out the branch that should be used for this change by going through [this section][branch].
3838+ If in doubt use `master`, that's where most changes should go.
3939+ This can be changed later by [rebasing][rebase].
19404141+2. Create and switch to a new Git branch, ideally such that:
4242+ - The name of the branch hints at the change you'd like to implement, e.g. `update-hello`.
4343+ - The base of the branch includes the most recent changes on the base branch from step 1, we'll assume `master` here.
4444+4545+ ```bash
4646+ # Make sure you have the latest changes from upstream Nixpkgs
4747+ git fetch upstream
4848+4949+ # Create and switch to a new branch based off the master branch in Nixpkgs
5050+ git switch --create update-hello upstream/master
5151+ ```
5252+5353+ 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:
5454+ - The commit of the latest `nixpkgs-unstable` channel, available [here](https://channels.nixos.org/nixpkgs-unstable/git-revision).
5555+ - 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'`
5656+ - If you're using NixOS, the commit of your NixOS installation, available with `nixos-version --revision`.
5757+5858+ Once you have an appropriate commit you can use it instead of `upstream/master` in the above command:
5959+ ```bash
6060+ git switch --create update-hello <the desired base commit>
6161+ ```
6262+6363+3. Make the desired changes in the local Nixpkgs repository using an editor of your choice.
6464+ Make sure to:
6565+ - Adhere to both the [general code conventions][code-conventions], and the code conventions specific to the part you're making changes to.
6666+ See the [overview section][overview] for more specific information.
6767+ - Test the changes.
6868+ See the [overview section][overview] for more specific information.
6969+ - If necessary, document the change.
7070+ See the [overview section][overview] for more specific information.
7171+7272+4. Commit your changes using `git commit`.
7373+ Make sure to adhere to the [commit conventions](#commit-conventions).
7474+7575+ Repeat the steps 3-4 as many times as necessary.
7676+ Advance to the next step if all the commits (viewable with `git log`) make sense together.
7777+7878+5. Push your commits to your fork of Nixpkgs.
7979+ ```
8080+ git push --set-upstream origin HEAD
8181+ ```
8282+8383+ The above command will output a link that allows you to directly quickly do the next step:
8484+ ```
8585+ remote: Create a pull request for 'update-hello' on GitHub by visiting:
8686+ remote: https://github.com/myUser/nixpkgs/pull/new/update-hello
8787+ ```
8888+8989+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.
9090+ Use the branch from step 2 as the pull requests base branch.
9191+ Go through the [pull request template](#pull-request-template) in the pre-filled default description.
9292+9393+7. Respond to review comments, potential CI failures and potential merge conflicts by updating the pull request.
9494+ Always keep the pull request in a mergeable state.
9595+9696+ 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.
9797+ See [the OfBorg Readme](https://github.com/NixOS/ofborg#readme) for more details.
9898+9999+ - To add new commits, repeat steps 3-4 and push the result using
100100+ ```
101101+ git push
102102+ ```
103103+104104+ - To change existing commits you will have to [rewrite Git history](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History).
105105+ Useful Git commands that can help a lot with this are `git commit --patch --amend` and `git rebase --interactive`.
106106+ With a rewritten history you need to force-push the commits using
107107+ ```
108108+ git push --force-with-lease
109109+ ```
110110+111111+ - 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`.
112112+ 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
113113+ ```
114114+ git fetch upstream
115115+ git rebase upstream/master
116116+ git push --force-with-lease
117117+ ```
118118+119119+ - If you need to change the base branch of the pull request, you can do so by [rebasing][rebase].
120120+121121+8. If your pull request is merged and [acceptable for releases][release-acceptable] you may [backport][pr-backport] the pull request.
122122+123123+### Pull request template
124124+[pr-template]: #pull-request-template
125125+126126+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.
127127+128128+When a PR is created, it will be pre-populated with some checkboxes detailed below:
129129+130130+#### Tested using sandboxing
131131+132132+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.
133133+134134+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.
135135+136136+Depending if you use NixOS or other platforms you can use one of the following methods to enable sandboxing **before** building the package:
137137+138138+- **Globally enable sandboxing on NixOS**: add the following to `configuration.nix`
139139+140140+ ```nix
141141+ nix.settings.sandbox = true;
20142 ```
2121- (pkg-name | nixos/<module>): (from -> to | init at version | refactor | etc)
143143+144144+- **Globally enable sandboxing on non-NixOS platforms**: add the following to: `/etc/nix/nix.conf`
221452323- (Motivation for change. Link to release notes. Additional information.)
146146+ ```ini
147147+ sandbox = true
24148 ```
251492626- 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).
150150+#### Built on platform(s)
151151+152152+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.
153153+154154+#### Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
155155+156156+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).
157157+158158+#### Tested compilation of all pkgs that depend on this change using `nixpkgs-review`
271592828- Examples:
160160+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.
291613030- * nginx: init at 2.0.1
3131- * firefox: 54.0.1 -> 55.0
3232- https://www.mozilla.org/en-US/firefox/55.0/releasenotes/
3333- * nixos/hydra: add bazBaz option
162162+Review changes from pull request number 12345:
341633535- Dual baz behavior is needed to do foo.
3636- * nixos/nginx: refactor config generation
164164+```ShellSession
165165+nix-shell -p nixpkgs-review --run "nixpkgs-review pr 12345"
166166+```
371673838- The old config generation system used impure shell scripts and could break in specific circumstances (see #1234).
168168+Alternatively, with flakes (and analogously for the other commands below):
391694040-* `meta.description` must:
4141- * Be short, just one sentence.
4242- * Be capitalized.
4343- * Not start with the package name.
4444- * More generally, it should not refer to the package name.
4545- * Not end with a period (or any punctuation for that matter).
4646- * Aim to inform while avoiding subjective language.
4747-* `meta.license` must be set and fit the upstream license.
4848- * If there is no upstream license, `meta.license` should default to `lib.licenses.unfree`.
4949- * If in doubt, try to contact the upstream developers for clarification.
5050-* `meta.mainProgram` must be set when appropriate.
5151-* `meta.maintainers` should be set.
170170+```ShellSession
171171+nix run nixpkgs#nixpkgs-review -- pr 12345
172172+```
521735353-See the nixpkgs manual for more details on [standard meta-attributes](https://nixos.org/nixpkgs/manual/#sec-standard-meta-attributes).
174174+Review uncommitted changes:
541755555-## Writing good commit messages
176176+```ShellSession
177177+nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
178178+```
561795757-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.
180180+Review changes from last commit:
581815959-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.
182182+```ShellSession
183183+nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
184184+```
601856161-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.
6262-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`.
6363-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).
186186+#### Tested execution of all binary files (usually in `./result/bin/`)
641876565-## Testing changes
188188+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.
661896767-To run the main types of tests locally:
190190+#### Meets Nixpkgs contribution standards
681916969-- Run package-internal tests with `nix-build --attr pkgs.PACKAGE.passthru.tests`
7070-- 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`
7171-- 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`
7272-- See `lib/tests/NAME.nix` for instructions on running specific library tests
192192+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.
731937474-## Rebasing between branches (i.e. from master to staging)
194194+### Rebasing between branches (i.e. from master to staging)
195195+[rebase]: #rebasing-between-branches-ie-from-master-to-staging
7519676197From time to time, changes between branches must be rebased, for example, if the
77198number of new rebuilds they would cause is too large for the target branch. When
···115236git push origin feature --force-with-lease
116237```
117238118118-### Something went wrong and a lot of people were pinged
239239+#### Something went wrong and a lot of people were pinged
119240120241It happens. Remember to be kind, especially to new contributors.
121242There is no way back, so the pull request should be closed and locked
···145266This is not a bulletproof method though, as OfBorg still does review requests even on draft PRs.
146267```
147268148148-## Backporting changes
269269+## How to backport pull requests
270270+[pr-backport]: #how-to-backport-pull-requests
271271+272272+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.
273273+274274+### Automatically backporting changes
275275+276276+> **Note**
277277+> You have to be a [Nixpkgs maintainer](./maintainers) to automatically create a backport pull request.
278278+279279+Add the [`backport release-YY.MM` label](https://github.com/NixOS/nixpkgs/labels?q=backport) to the pull request on the `master` branch.
280280+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.
281281+This can be done on both open or already merged pull requests.
282282+283283+### Manually backporting changes
284284+285285+To manually create a backport pull request, follow [the standard pull request process][pr-create], with these notable differences:
286286+287287+- Use `release-YY.MM` for the base branch, both for the local branch and the pull request.
288288+ > **Warning**
289289+ > Do not use the `nixos-YY.MM` branch, that is a branch pointing to the tested release channel commit
290290+291291+- 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.
292292+ 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.
293293+ Here is [an example](https://github.com/nixos/nixpkgs/commit/5688c39af5a6c5f3d646343443683da880eaefb8) of this.
294294+295295+ > **Warning**
296296+ > Ensure the commits exists on the master branch.
297297+ > 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.
298298+299299+- In the pull request description, link to the original pull request to `master`.
300300+ The pull request title should include `[YY.MM]` matching the release you're backporting to.
301301+302302+- 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.
303303+ This way maintainers can keep track of missing backports easier.
304304+305305+## How to review pull requests
306306+[pr-review]: #how-to-review-pull-requests
307307+308308+> **Warning**
309309+> 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).
310310+311311+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.
312312+313313+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).
314314+315315+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.
316316+317317+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.
318318+319319+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.
320320+321321+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.
322322+323323+To get more information about how to review specific parts of Nixpkgs, refer to the documents linked to in the [overview section][overview].
324324+325325+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.
326326+327327+Container system, boot system and library changes are some examples of the pull requests fitting this category.
328328+329329+## How to merge pull requests
330330+[pr-merge]: #how-to-merge-pull-requests
331331+332332+The *Nixpkgs committers* are people who have been given
333333+permission to merge.
334334+335335+It is possible for community members that have enough knowledge and experience on a special topic to contribute by merging pull requests.
336336+337337+In case the PR is stuck waiting for the original author to apply a trivial
338338+change (a typo, capitalisation change, etc.) and the author allowed the members
339339+to modify the PR, consider applying it yourself (or commit the existing review
340340+suggestion). You should pay extra attention to make sure the addition doesn't go
341341+against the idea of the original PR and would not be opposed by the author.
342342+343343+<!--
344344+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.
345345+346346+Please note that contributors with commit rights unactive for more than three months will have their commit rights revoked.
347347+-->
348348+349349+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.
350350+351351+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.
352352+353353+# Flow of merged pull requests
354354+355355+After a pull requests is merged, it eventually makes it to the [official Hydra CI](https://hydra.nixos.org/).
356356+Hydra regularly evaluates and builds Nixpkgs, updating [the official channels](http://channels.nixos.org/) when specific Hydra jobs succeeded.
357357+See [Nix Channel Status](https://status.nixos.org/) for the current channels and their state.
358358+Here's a brief overview of the main Git branches and what channels they're used for:
359359+360360+- `master`: The main branch, used for the unstable channels such as `nixpkgs-unstable`, `nixos-unstable` and `nixos-unstable-small`.
361361+- `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`.
362362+363363+When a channel is updated, a corresponding Git branch is also updated to point to the corresponding commit.
364364+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).
365365+366366+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/).
367367+368368+See [this section][branch] to know when to use the release branches.
369369+370370+## Staging
371371+[staging]: #staging
372372+373373+The staging workflow exists to batch Hydra builds of many packages together.
374374+375375+It works by directing commits that cause [mass rebuilds][mass-rebuild] to a separate `staging` branch that isn't directly built by Hydra.
376376+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).
377377+The `staging-next` branch should then only receive direct commits in order to fix Hydra builds.
378378+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).
379379+This is done manually in order to ensure it's a good use of Hydra's computing resources.
380380+By keeping the `staging-next` branch separate from `staging`, this batching does not block developers from merging changes into `staging`.
381381+382382+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`.
383383+This is implemented using GitHub workflows [here](.github/workflows/periodic-merge-6h.yml) and [here](.github/workflows/periodic-merge-24h.yml).
384384+385385+> **Note**
386386+> Changes must be sufficiently tested before being merged into any branch.
387387+> Hydra builds should not be used as testing platform.
388388+389389+Here is a Git history diagram showing the flow of commits between the three branches:
390390+```mermaid
391391+%%{init: {
392392+ 'theme': 'base',
393393+ 'themeVariables': {
394394+ 'gitInv0': '#ff0000',
395395+ 'gitInv1': '#ff0000',
396396+ 'git2': '#ff4444',
397397+ 'commitLabelFontSize': '15px'
398398+ },
399399+ 'gitGraph': {
400400+ 'showCommitLabel':true,
401401+ 'mainBranchName': 'master',
402402+ 'rotateCommitLabel': true
403403+ }
404404+} }%%
405405+gitGraph
406406+ commit id:" "
407407+ branch staging-next
408408+ branch staging
409409+410410+ checkout master
411411+ checkout staging
412412+ checkout master
413413+ commit id:" "
414414+ checkout staging-next
415415+ merge master id:"automatic"
416416+ checkout staging
417417+ merge staging-next id:"automatic "
418418+419419+ checkout staging-next
420420+ merge staging type:HIGHLIGHT id:"manual"
421421+ commit id:"fixup"
422422+423423+ checkout master
424424+ checkout staging
425425+ checkout master
426426+ commit id:" "
427427+ checkout staging-next
428428+ merge master id:"automatic "
429429+ checkout staging
430430+ merge staging-next id:"automatic "
431431+432432+ checkout staging-next
433433+ commit id:"fixup "
434434+ checkout master
435435+ merge staging-next type:HIGHLIGHT id:"manual (PR)"
436436+```
437437+438438+439439+Here's an overview of the different branches:
440440+441441+| branch | `master` | `staging` | `staging-next` |
442442+| --- | --- | --- | --- |
443443+| Used for development | ✔️ | ✔️ | ❌ |
444444+| Built by Hydra | ✔️ | ❌ | ✔️ |
445445+| [Mass rebuilds][mass-rebuild] | ❌ | ✔️ | ⚠️ Only to fix Hydra builds |
446446+| Critical security fixes | ✔️ for non-mass-rebuilds | ❌ | ✔️ for mass-rebuilds |
447447+| Automatically merged into | `staging-next` | - | `staging` |
448448+| Manually merged into | - | `staging-next` | `master` |
449449+450450+The staging workflow is used for all main branches, `master` and `release-YY.MM`, with corresponding names:
451451+- `master`/`release-YY.MM`
452452+- `staging`/`staging-YY.MM`
453453+- `staging-next`/`staging-next-YY.MM`
454454+455455+# Conventions
456456+457457+## Branch conventions
458458+<!-- This section is relevant to both contributors and reviewers -->
459459+[branch]: #branch-conventions
460460+461461+Most changes should go to the `master` branch, but sometimes other branches should be used instead.
462462+Use the following decision process to figure out which one it should be:
463463+464464+Is the change [acceptable for releases][release-acceptable] and do you wish to have the change in the release?
465465+- No: Use the `master` branch, do not backport the pull request.
466466+- Yes: Can the change be implemented the same way on the `master` and release branches?
467467+ For example, a packages major version might differ between the `master` and release branches, such that separate security patches are required.
468468+ - Yes: Use the `master` branch and [backport the pull request](#backporting-changes).
469469+ - No: Create separate pull requests to the `master` and `release-XX.YY` branches.
470470+471471+Furthermore, if the change causes a [mass rebuild][mass-rebuild], use the appropriate staging branch instead:
472472+- Mass rebuilds to `master` should go to `staging` instead.
473473+- Mass rebuilds to `release-XX.YY` should go to `staging-XX.YY` instead.
474474+475475+See [this section][staging] for more details about such changes propagate between the branches.
476476+477477+### Changes acceptable for releases
478478+[release-acceptable]: #changes-acceptable-for-releases
479479+480480+Only changes to supported releases may be accepted.
481481+The oldest supported release (`YYMM`) can be found using
482482+```
483483+nix-instantiate --eval -A lib.trivial.oldestSupportedRelease
484484+```
485485+486486+The release branches should generally not receive any breaking changes, both for the Nix expressions and derivations.
487487+So these changes are acceptable to backport:
488488+- New packages, modules and functions
489489+- Security fixes
490490+- Package version updates
491491+ - Patch versions with fixes
492492+ - Minor versions with new functionality, but no breaking changes
493493+494494+In addition, major package version updates with breaking changes are also acceptable for:
495495+- Services that would fail without up-to-date client software, such as `spotify`, `steam`, and `discord`
496496+- Security critical applications, such as `firefox` and `chromium`
497497+498498+### Changes causing mass rebuilds
499499+[mass-rebuild]: #changes-causing-mass-rebuilds
500500+501501+Which changes cause mass rebuilds is not formally defined.
502502+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.
503503+As a rule of thumb, if the number of rebuilds is **over 500**, it can be considered a mass rebuild.
504504+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).
505505+506506+## Commit conventions
507507+[commit-conventions]: #commit-conventions
508508+509509+- Create a commit for each logical unit.
510510+511511+- Check for unnecessary whitespace with `git diff --check` before committing.
512512+513513+- If you have commits `pkg-name: oh, forgot to insert whitespace`: squash commits in this case. Use `git rebase -i`.
514514+515515+- Format the commit messages in the following way:
516516+517517+ ```
518518+ (pkg-name | nixos/<module>): (from -> to | init at version | refactor | etc)
519519+520520+ (Motivation for change. Link to release notes. Additional information.)
521521+ ```
522522+523523+ 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).
524524+525525+ Examples:
526526+527527+ * nginx: init at 2.0.1
528528+ * firefox: 54.0.1 -> 55.0
529529+530530+ https://www.mozilla.org/en-US/firefox/55.0/releasenotes/
531531+ * nixos/hydra: add bazBaz option
532532+533533+ Dual baz behavior is needed to do foo.
534534+ * nixos/nginx: refactor config generation
535535+536536+ The old config generation system used impure shell scripts and could break in specific circumstances (see #1234).
537537+538538+### Writing good commit messages
539539+540540+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.
541541+542542+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.
543543+544544+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.
149545150150-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).
546546+## Code conventions
547547+[code-conventions]: #code-conventions
151548152152-You can add a label such as `backport release-23.05` to a PR, so that merging it will
153153-automatically create a backport (via [a GitHub Action](.github/workflows/backport.yml)).
154154-This also works for pull requests that have already been merged, and might take a couple of minutes to trigger.
549549+### Release notes
155550156156-You can also create the backport manually:
551551+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).
157552158158-1. Take note of the commits in which the change was introduced into `master` branch.
159159-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`.
160160-3. Create a branch for your change, e.g. `git checkout -b backport`.
161161-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.
162162-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]`.
163163-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.
553553+### File naming and organisation
164554165165-## Criteria for Backporting changes
555555+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`.
166556167167-Anything that does not cause user or downstream dependency regressions can be backported. This includes:
168168-- New Packages / Modules
169169-- Security / Patch updates
170170-- Version updates which include new functionality (but no breaking changes)
171171-- Services which require a client to be up-to-date regardless. (E.g. `spotify`, `steam`, or `discord`)
172172-- Security critical applications (E.g. `firefox`)
557557+### Syntax
558558+559559+- Use 2 spaces of indentation per indentation level in Nix expressions, 4 spaces in shell scripts.
173560174174-## Reviewing contributions
561561+- 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.
175562176176-See the nixpkgs manual for more details on how to [Review contributions](https://nixos.org/nixpkgs/manual/#chap-reviewing-contributions).
563563+- 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).
564564+565565+- Function calls with attribute set arguments are written as
566566+567567+ ```nix
568568+ foo {
569569+ arg = ...;
570570+ }
571571+ ```
572572+573573+ not
574574+575575+ ```nix
576576+ foo
577577+ {
578578+ arg = ...;
579579+ }
580580+ ```
581581+582582+ Also fine is
583583+584584+ ```nix
585585+ foo { arg = ...; }
586586+ ```
587587+588588+ if it's a short call.
589589+590590+- In attribute sets or lists that span multiple lines, the attribute names or list elements should be aligned:
591591+592592+ ```nix
593593+ # A long list.
594594+ list = [
595595+ elem1
596596+ elem2
597597+ elem3
598598+ ];
599599+600600+ # A long attribute set.
601601+ attrs = {
602602+ attr1 = short_expr;
603603+ attr2 =
604604+ if true then big_expr else big_expr;
605605+ };
606606+607607+ # Combined
608608+ listOfAttrs = [
609609+ {
610610+ attr1 = 3;
611611+ attr2 = "fff";
612612+ }
613613+ {
614614+ attr1 = 5;
615615+ attr2 = "ggg";
616616+ }
617617+ ];
618618+ ```
619619+620620+- Short lists or attribute sets can be written on one line:
621621+622622+ ```nix
623623+ # A short list.
624624+ list = [ elem1 elem2 elem3 ];
625625+626626+ # A short set.
627627+ attrs = { x = 1280; y = 1024; };
628628+ ```
629629+630630+- Breaking in the middle of a function argument can give hard-to-read code, like
631631+632632+ ```nix
633633+ someFunction { x = 1280;
634634+ y = 1024; } otherArg
635635+ yetAnotherArg
636636+ ```
637637+638638+ (especially if the argument is very large, spanning multiple lines).
639639+640640+ Better:
641641+642642+ ```nix
643643+ someFunction
644644+ { x = 1280; y = 1024; }
645645+ otherArg
646646+ yetAnotherArg
647647+ ```
648648+649649+ or
650650+651651+ ```nix
652652+ let res = { x = 1280; y = 1024; };
653653+ in someFunction res otherArg yetAnotherArg
654654+ ```
655655+656656+- The bodies of functions, asserts, and withs are not indented to prevent a lot of superfluous indentation levels, i.e.
657657+658658+ ```nix
659659+ { arg1, arg2 }:
660660+ assert system == "i686-linux";
661661+ stdenv.mkDerivation { ...
662662+ ```
663663+664664+ not
665665+666666+ ```nix
667667+ { arg1, arg2 }:
668668+ assert system == "i686-linux";
669669+ stdenv.mkDerivation { ...
670670+ ```
671671+672672+- Function formal arguments are written as:
673673+674674+ ```nix
675675+ { arg1, arg2, arg3 }:
676676+ ```
677677+678678+ but if they don't fit on one line they're written as:
679679+680680+ ```nix
681681+ { arg1, arg2, arg3
682682+ , arg4, ...
683683+ , # Some comment...
684684+ argN
685685+ }:
686686+ ```
687687+688688+- Functions should list their expected arguments as precisely as possible. That is, write
689689+690690+ ```nix
691691+ { stdenv, fetchurl, perl }: ...
692692+ ```
693693+694694+ instead of
695695+696696+ ```nix
697697+ args: with args; ...
698698+ ```
699699+700700+ or
701701+702702+ ```nix
703703+ { stdenv, fetchurl, perl, ... }: ...
704704+ ```
705705+706706+ 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:
707707+708708+ ```nix
709709+ { stdenv, doCoverageAnalysis ? false, ... } @ args:
710710+711711+ stdenv.mkDerivation (args // {
712712+ ... if doCoverageAnalysis then "bla" else "" ...
713713+ })
714714+ ```
715715+716716+ instead of
717717+718718+ ```nix
719719+ args:
720720+721721+ args.stdenv.mkDerivation (args // {
722722+ ... if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "" ...
723723+ })
724724+ ```
725725+726726+- Unnecessary string conversions should be avoided. Do
727727+728728+ ```nix
729729+ rev = version;
730730+ ```
731731+732732+ instead of
733733+734734+ ```nix
735735+ rev = "${version}";
736736+ ```
737737+738738+- Building lists conditionally _should_ be done with `lib.optional(s)` instead of using `if cond then [ ... ] else null` or `if cond then [ ... ] else [ ]`.
739739+740740+ ```nix
741741+ buildInputs = lib.optional stdenv.isDarwin iconv;
742742+ ```
743743+744744+ instead of
745745+746746+ ```nix
747747+ buildInputs = if stdenv.isDarwin then [ iconv ] else null;
748748+ ```
749749+750750+ As an exception, an explicit conditional expression with null can be used when fixing a important bug without triggering a mass rebuild.
751751+ If this is done a follow up pull request _should_ be created to change the code to `lib.optional(s)`.
752752+753753+- Arguments should be listed in the order they are used, with the exception of `lib`, which always goes first.
+1-20
README.md
···7070page gives a sense of the project activity.
71717272Community contributions are always welcome through GitHub Issues and
7373-Pull Requests. When pull requests are made, our tooling automation bot,
7474-[OfBorg](https://github.com/NixOS/ofborg) will perform various checks
7575-to help ensure expression quality.
7676-7777-The *Nixpkgs maintainers* are people who have assigned themselves to
7878-maintain specific individual packages. We encourage people who care
7979-about a package to assign themselves as a maintainer. When a pull
8080-request is made against a package, OfBorg will notify the appropriate
8181-maintainer(s). The *Nixpkgs committers* are people who have been given
8282-permission to merge.
8383-8484-Most contributions are based on and merged into these branches:
8585-8686-* `master` is the main branch where all small contributions go
8787-* `staging` is branched from master, changes that have a big impact on
8888- Hydra builds go to this branch
8989-* `staging-next` is branched from staging and only fixes to stabilize
9090- and security fixes with a big impact on Hydra builds should be
9191- contributed to this branch. This branch is merged into master when
9292- deemed of sufficiently high quality
7373+Pull Requests.
93749475For more information about contributing to the project, please visit
9576the [contributing page](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
+107-4
doc/README.md
···11-22-# Nixpkgs/doc
11+# Contributing to the Nixpkgs manual
3243This directory houses the sources files for the Nixpkgs manual.
54···7687[Docs for Nixpkgs stable](https://nixos.org/manual/nixpkgs/stable/) are also available.
981010-If you want to contribute to the documentation, [here's how to do it](https://nixos.org/manual/nixpkgs/unstable/#chap-contributing).
99+If you're only getting started with Nix, go to [nixos.org/learn](https://nixos.org/learn).
1010+1111+## Contributing to this documentation
1212+1313+You can quickly check your edits with `nix-build`:
1414+1515+```ShellSession
1616+$ cd /path/to/nixpkgs
1717+$ nix-build doc
1818+```
1919+2020+If the build succeeds, the manual will be in `./result/share/doc/nixpkgs/manual.html`.
2121+2222+### devmode
2323+2424+The shell in the manual source directory makes available a command, `devmode`.
2525+It is a daemon, that:
2626+1. watches the manual's source for changes and when they occur — rebuilds
2727+2. HTTP serves the manual, injecting a script that triggers reload on changes
2828+3. opens the manual in the default browser
2929+3030+## Syntax
3131+3232+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.
3333+3434+Additional syntax extensions are available, all of which can be used in NixOS option documentation. The following extensions are currently used:
3535+3636+#### Tables
3737+3838+Tables, using the [GitHub-flavored Markdown syntax](https://github.github.com/gfm/#tables-extension-).
3939+4040+#### Anchors
4141+4242+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).
4343+4444+It uses the widely compatible [header attributes](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/attributes.md) syntax:
4545+4646+```markdown
4747+## Syntax {#sec-contributing-markup}
4848+```
4949+5050+> **Note**
5151+> NixOS option documentation does not support headings in general.
5252+5353+#### Inline Anchors
5454+5555+Allow linking arbitrary place in the text (e.g. individual list items, sentences…).
5656+5757+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):
5858+5959+```markdown
6060+- []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`.
6161+```
6262+6363+#### Automatic links
6464+6565+If you **omit a link text** for a link pointing to a section, the text will be substituted automatically. For example `[](#chap-contributing)`.
6666+6767+This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing).
6868+6969+#### Roles
7070+7171+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).
7272+7373+A few markups for other kinds of literals are also available:
7474+7575+- `` {command}`rm -rfi` ``
7676+- `` {env}`XDG_DATA_DIRS` ``
7777+- `` {file}`/etc/passwd` ``
7878+- `` {option}`networking.useDHCP` ``
7979+- `` {var}`/etc/passwd` ``
8080+8181+These literal kinds are used mostly in NixOS option documentation.
8282+8383+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.
8484+8585+#### Admonitions
8686+8787+Set off from the text to bring attention to something.
8888+8989+It uses pandoc’s [fenced `div`s syntax](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/fenced_divs.md):
9090+9191+```markdown
9292+::: {.warning}
9393+This is a warning
9494+:::
9595+```
9696+9797+The following are supported:
9898+9999+- [`caution`](https://tdg.docbook.org/tdg/5.0/caution.html)
100100+- [`important`](https://tdg.docbook.org/tdg/5.0/important.html)
101101+- [`note`](https://tdg.docbook.org/tdg/5.0/note.html)
102102+- [`tip`](https://tdg.docbook.org/tdg/5.0/tip.html)
103103+- [`warning`](https://tdg.docbook.org/tdg/5.0/warning.html)
104104+105105+#### [Definition lists](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/definition_lists.md)
106106+107107+For defining a group of terms:
108108+109109+```markdown
110110+pear
111111+: green or yellow bulbous fruit
111121212-If you're only getting started with Nix, go to [nixos.org/learn](https://nixos.org/learn).
113113+watermelon
114114+: green fruit with red flesh
115115+```
+17-647
doc/contributing/coding-conventions.chapter.md
···11# Coding conventions {#chap-conventions}
2233-## Syntax {#sec-syntax}
44-55-- Use 2 spaces of indentation per indentation level in Nix expressions, 4 spaces in shell scripts.
66-77-- 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.
88-99-- 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).
1010-1111-- Function calls with attribute set arguments are written as
1212-1313- ```nix
1414- foo {
1515- arg = ...;
1616- }
1717- ```
1818-1919- not
2020-2121- ```nix
2222- foo
2323- {
2424- arg = ...;
2525- }
2626- ```
2727-2828- Also fine is
2929-3030- ```nix
3131- foo { arg = ...; }
3232- ```
3333-3434- if it's a short call.
3535-3636-- In attribute sets or lists that span multiple lines, the attribute names or list elements should be aligned:
3737-3838- ```nix
3939- # A long list.
4040- list = [
4141- elem1
4242- elem2
4343- elem3
4444- ];
4545-4646- # A long attribute set.
4747- attrs = {
4848- attr1 = short_expr;
4949- attr2 =
5050- if true then big_expr else big_expr;
5151- };
5252-5353- # Combined
5454- listOfAttrs = [
5555- {
5656- attr1 = 3;
5757- attr2 = "fff";
5858- }
5959- {
6060- attr1 = 5;
6161- attr2 = "ggg";
6262- }
6363- ];
6464- ```
6565-6666-- Short lists or attribute sets can be written on one line:
6767-6868- ```nix
6969- # A short list.
7070- list = [ elem1 elem2 elem3 ];
7171-7272- # A short set.
7373- attrs = { x = 1280; y = 1024; };
7474- ```
7575-7676-- Breaking in the middle of a function argument can give hard-to-read code, like
7777-7878- ```nix
7979- someFunction { x = 1280;
8080- y = 1024; } otherArg
8181- yetAnotherArg
8282- ```
8383-8484- (especially if the argument is very large, spanning multiple lines).
8585-8686- Better:
8787-8888- ```nix
8989- someFunction
9090- { x = 1280; y = 1024; }
9191- otherArg
9292- yetAnotherArg
9393- ```
9494-9595- or
9696-9797- ```nix
9898- let res = { x = 1280; y = 1024; };
9999- in someFunction res otherArg yetAnotherArg
100100- ```
101101-102102-- The bodies of functions, asserts, and withs are not indented to prevent a lot of superfluous indentation levels, i.e.
103103-104104- ```nix
105105- { arg1, arg2 }:
106106- assert system == "i686-linux";
107107- stdenv.mkDerivation { ...
108108- ```
109109-110110- not
111111-112112- ```nix
113113- { arg1, arg2 }:
114114- assert system == "i686-linux";
115115- stdenv.mkDerivation { ...
116116- ```
117117-118118-- Function formal arguments are written as:
119119-120120- ```nix
121121- { arg1, arg2, arg3 }:
122122- ```
123123-124124- but if they don't fit on one line they're written as:
125125-126126- ```nix
127127- { arg1, arg2, arg3
128128- , arg4, ...
129129- , # Some comment...
130130- argN
131131- }:
132132- ```
133133-134134-- Functions should list their expected arguments as precisely as possible. That is, write
135135-136136- ```nix
137137- { stdenv, fetchurl, perl }: ...
138138- ```
139139-140140- instead of
141141-142142- ```nix
143143- args: with args; ...
144144- ```
145145-146146- or
147147-148148- ```nix
149149- { stdenv, fetchurl, perl, ... }: ...
150150- ```
151151-152152- 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:
153153-154154- ```nix
155155- { stdenv, doCoverageAnalysis ? false, ... } @ args:
156156-157157- stdenv.mkDerivation (args // {
158158- ... if doCoverageAnalysis then "bla" else "" ...
159159- })
160160- ```
161161-162162- instead of
163163-164164- ```nix
165165- args:
166166-167167- args.stdenv.mkDerivation (args // {
168168- ... if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "" ...
169169- })
170170- ```
171171-172172-- Unnecessary string conversions should be avoided. Do
173173-174174- ```nix
175175- rev = version;
176176- ```
177177-178178- instead of
179179-180180- ```nix
181181- rev = "${version}";
182182- ```
183183-184184-- Building lists conditionally _should_ be done with `lib.optional(s)` instead of using `if cond then [ ... ] else null` or `if cond then [ ... ] else [ ]`.
185185-186186- ```nix
187187- buildInputs = lib.optional stdenv.isDarwin iconv;
188188- ```
189189-190190- instead of
33+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
1914192192- ```nix
193193- buildInputs = if stdenv.isDarwin then [ iconv ] else null;
194194- ```
55+## Syntax {#sec-syntax}
1956196196- As an exception, an explicit conditional expression with null can be used when fixing a important bug without triggering a mass rebuild.
197197- If this is done a follow up pull request _should_ be created to change the code to `lib.optional(s)`.
198198-199199-- Arguments should be listed in the order they are used, with the exception of `lib`, which always goes first.
77+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
20082019## Package naming {#sec-package-naming}
20210203203-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.
204204-205205-In Nixpkgs, there are generally three different names associated with a package:
206206-207207-- The `pname` attribute of the derivation. This is what most users see, in particular when using `nix-env`.
208208-209209-- 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`.
210210-211211-- The filename for (the directory containing) the Nix expression.
212212-213213-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`.
214214-215215-There are a few naming guidelines:
216216-217217-- The `pname` attribute _should_ be identical to the upstream package name.
218218-219219-- The `pname` and the `version` attribute _must not_ contain uppercase letters — e.g., `"mplayer" instead of `"MPlayer"`.
220220-221221-- The `version` attribute _must_ start with a digit e.g`"0.3.1rc2".
222222-223223-- 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.
224224-225225-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"`.
226226-227227-- 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.
228228-229229-- 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)
1111+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
2301223113## File naming and organisation {#sec-organisation}
23214233233-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`.
234234-235235-### Hierarchy {#sec-hierarchy}
236236-237237-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`.
238238-239239-When in doubt, consider refactoring the `pkgs/` tree, e.g. creating new categories or splitting up an existing category.
240240-241241-**If it’s used to support _software development_:**
242242-243243-- **If it’s a _library_ used by other packages:**
244244-245245- - `development/libraries` (e.g. `libxml2`)
246246-247247-- **If it’s a _compiler_:**
248248-249249- - `development/compilers` (e.g. `gcc`)
250250-251251-- **If it’s an _interpreter_:**
252252-253253- - `development/interpreters` (e.g. `guile`)
254254-255255-- **If it’s a (set of) development _tool(s)_:**
256256-257257- - **If it’s a _parser generator_ (including lexers):**
258258-259259- - `development/tools/parsing` (e.g. `bison`, `flex`)
260260-261261- - **If it’s a _build manager_:**
262262-263263- - `development/tools/build-managers` (e.g. `gnumake`)
264264-265265- - **If it’s a _language server_:**
266266-267267- - `development/tools/language-servers` (e.g. `ccls` or `rnix-lsp`)
268268-269269- - **Else:**
270270-271271- - `development/tools/misc` (e.g. `binutils`)
272272-273273-- **Else:**
274274-275275- - `development/misc`
276276-277277-**If it’s a (set of) _tool(s)_:**
278278-279279-(A tool is a relatively small program, especially one intended to be used non-interactively.)
280280-281281-- **If it’s for _networking_:**
282282-283283- - `tools/networking` (e.g. `wget`)
284284-285285-- **If it’s for _text processing_:**
286286-287287- - `tools/text` (e.g. `diffutils`)
288288-289289-- **If it’s a _system utility_, i.e., something related or essential to the operation of a system:**
290290-291291- - `tools/system` (e.g. `cron`)
292292-293293-- **If it’s an _archiver_ (which may include a compression function):**
294294-295295- - `tools/archivers` (e.g. `zip`, `tar`)
296296-297297-- **If it’s a _compression_ program:**
298298-299299- - `tools/compression` (e.g. `gzip`, `bzip2`)
300300-301301-- **If it’s a _security_-related program:**
302302-303303- - `tools/security` (e.g. `nmap`, `gnupg`)
304304-305305-- **Else:**
306306-307307- - `tools/misc`
308308-309309-**If it’s a _shell_:**
310310-311311-- `shells` (e.g. `bash`)
312312-313313-**If it’s a _server_:**
314314-315315-- **If it’s a web server:**
316316-317317- - `servers/http` (e.g. `apache-httpd`)
318318-319319-- **If it’s an implementation of the X Windowing System:**
320320-321321- - `servers/x11` (e.g. `xorg` — this includes the client libraries and programs)
322322-323323-- **Else:**
324324-325325- - `servers/misc`
326326-327327-**If it’s a _desktop environment_:**
328328-329329-- `desktops` (e.g. `kde`, `gnome`, `enlightenment`)
330330-331331-**If it’s a _window manager_:**
332332-333333-- `applications/window-managers` (e.g. `awesome`, `stumpwm`)
334334-335335-**If it’s an _application_:**
336336-337337-A (typically large) program with a distinct user interface, primarily used interactively.
338338-339339-- **If it’s a _version management system_:**
340340-341341- - `applications/version-management` (e.g. `subversion`)
342342-343343-- **If it’s a _terminal emulator_:**
344344-345345- - `applications/terminal-emulators` (e.g. `alacritty` or `rxvt` or `termite`)
346346-347347-- **If it’s a _file manager_:**
348348-349349- - `applications/file-managers` (e.g. `mc` or `ranger` or `pcmanfm`)
350350-351351-- **If it’s for _video playback / editing_:**
352352-353353- - `applications/video` (e.g. `vlc`)
354354-355355-- **If it’s for _graphics viewing / editing_:**
356356-357357- - `applications/graphics` (e.g. `gimp`)
358358-359359-- **If it’s for _networking_:**
360360-361361- - **If it’s a _mailreader_:**
362362-363363- - `applications/networking/mailreaders` (e.g. `thunderbird`)
364364-365365- - **If it’s a _newsreader_:**
366366-367367- - `applications/networking/newsreaders` (e.g. `pan`)
368368-369369- - **If it’s a _web browser_:**
370370-371371- - `applications/networking/browsers` (e.g. `firefox`)
372372-373373- - **Else:**
374374-375375- - `applications/networking/misc`
376376-377377-- **Else:**
378378-379379- - `applications/misc`
380380-381381-**If it’s _data_ (i.e., does not have a straight-forward executable semantics):**
382382-383383-- **If it’s a _font_:**
384384-385385- - `data/fonts`
386386-387387-- **If it’s an _icon theme_:**
388388-389389- - `data/icons`
390390-391391-- **If it’s related to _SGML/XML processing_:**
392392-393393- - **If it’s an _XML DTD_:**
394394-395395- - `data/sgml+xml/schemas/xml-dtd` (e.g. `docbook`)
396396-397397- - **If it’s an _XSLT stylesheet_:**
398398-399399- (Okay, these are executable...)
400400-401401- - `data/sgml+xml/stylesheets/xslt` (e.g. `docbook-xsl`)
402402-403403-- **If it’s a _theme_ for a _desktop environment_, a _window manager_ or a _display manager_:**
404404-405405- - `data/themes`
406406-407407-**If it’s a _game_:**
408408-409409-- `games`
410410-411411-**Else:**
412412-413413-- `misc`
1515+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
4141641517### Versioning {#sec-versioning}
41618417417-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.
418418-419419-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`.
420420-421421-All versions of a package _must_ be included in `all-packages.nix` to make sure that they evaluate correctly.
1919+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
4222042321## Fetching Sources {#sec-sources}
42422425425-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.
426426-427427-You can find many source fetch helpers in `pkgs/build-support/fetch*`.
428428-429429-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:
430430-431431-- Bad: Uses `git://` which won't be proxied.
432432-433433- ```nix
434434- src = fetchgit {
435435- url = "git@github.com:NixOS/nix.git"
436436- url = "git://github.com/NixOS/nix.git";
437437- rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae";
438438- hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ=";
439439- }
440440- ```
441441-442442-- Better: This is ok, but an archive fetch will still be faster.
443443-444444- ```nix
445445- src = fetchgit {
446446- url = "https://github.com/NixOS/nix.git";
447447- rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae";
448448- hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ=";
449449- }
450450- ```
451451-452452-- Best: Fetches a snapshot archive and you get the rev you want.
453453-454454- ```nix
455455- src = fetchFromGitHub {
456456- owner = "NixOS";
457457- repo = "nix";
458458- rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae";
459459- hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ=";
460460- }
461461- ```
462462-463463-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`.
464464-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).
465465-466466-Find the value to put as `hash` by running `nix-shell -p nix-prefetch-github --run "nix-prefetch-github --rev 1f795f9f44607cc5bec70d1300150bfefcef2aae NixOS nix"`.
2323+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
4672446825## Obtaining source hash {#sec-source-hashes}
46926470470-Preferred source hash type is sha256. There are several ways to get it.
471471-472472-1. Prefetch URL (with `nix-prefetch-XXX URL`, where `XXX` is one of `url`, `git`, `hg`, `cvs`, `bzr`, `svn`). Hash is printed to stdout.
473473-474474-2. Prefetch by package source (with `nix-prefetch-url '<nixpkgs>' -A PACKAGE.src`, where `PACKAGE` is package attribute name). Hash is printed to stdout.
475475-476476- 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).
477477-478478-3. Upstream provided hash: use it when upstream provides `sha256` or `sha512` (when upstream provides `md5`, don't use it, compute `sha256` instead).
479479-480480- 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.
481481-482482- You can convert between formats with nix-hash, for example:
483483-484484- ```ShellSession
485485- $ nix-hash --type sha256 --to-base32 HASH
486486- ```
487487-488488-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.
489489-490490-5. Fake hash: set the hash to one of
491491-492492- - `""`
493493- - `lib.fakeHash`
494494- - `lib.fakeSha256`
495495- - `lib.fakeSha512`
496496-497497- in the package expression, attempt build and extract correct hash from error messages.
498498-499499- ::: {.warning}
500500- You must use one of these four fake hashes and not some arbitrarily-chosen hash.
501501-502502- See [](#sec-source-hashes-security).
503503- :::
504504-505505- 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.
506506-2727+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
5072850829### Obtaining hashes securely {#sec-source-hashes-security}
50930510510-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:
511511-512512-- `http://` URLs are not secure to prefetch hash from;
513513-514514-- hashes from upstream (in method 3) should be obtained via secure protocol;
515515-516516-- `https://` URLs are secure in methods 1, 2, 3;
517517-518518-- `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.
3131+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
5193252033## Patches {#sec-patches}
52134522522-Patches available online should be retrieved using `fetchpatch`.
523523-524524-```nix
525525-patches = [
526526- (fetchpatch {
527527- name = "fix-check-for-using-shared-freetype-lib.patch";
528528- url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=8f5d285";
529529- hash = "sha256-uRcxaCjd+WAuGrXOmGfFeu79cUILwkRdBu48mwcBE7g=";
530530- })
531531-];
532532-```
533533-534534-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.
535535-536536-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.
537537-538538-```nix
539539-patches = [ ./0001-changes.patch ];
540540-```
541541-542542-If you do need to do create this sort of patch file, one way to do so is with git:
543543-544544-1. Move to the root directory of the source code you're patching.
545545-546546- ```ShellSession
547547- $ cd the/program/source
548548- ```
549549-550550-2. If a git repository is not already present, create one and stage all of the source files.
551551-552552- ```ShellSession
553553- $ git init
554554- $ git add .
555555- ```
556556-557557-3. Edit some files to make whatever changes need to be included in the patch.
558558-559559-4. Use git to create a diff, and pipe the output to a patch file:
560560-561561- ```ShellSession
562562- $ git diff -a > nixpkgs/pkgs/the/package/0001-changes.patch
563563- ```
3535+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
5643656537## Package tests {#sec-package-tests}
56638567567-Tests are important to ensure quality and make reviews and automatic updates easy.
568568-569569-The following types of tests exists:
570570-571571-* [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.
572572-* 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.
573573-* The **`checkPhase` of a package**, which should execute the unit tests that are included in the source code of a package.
574574-575575-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).
3939+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
5764057741### Writing inline package tests {#ssec-inline-package-tests-writing}
57842579579-For very simple tests, they can be written inline:
580580-581581-```nix
582582-{ …, yq-go }:
583583-584584-buildGoModule rec {
585585- …
586586-587587- passthru.tests = {
588588- simple = runCommand "${pname}-test" {} ''
589589- echo "test: 1" | ${yq-go}/bin/yq eval -j > $out
590590- [ "$(cat $out | tr -d $'\n ')" = '{"test":1}' ]
591591- '';
592592- };
593593-}
594594-```
4343+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
5954459645### Writing larger package tests {#ssec-package-tests-writing}
59746598598-This is an example using the `phoronix-test-suite` package with the current best practices.
599599-600600-Add the tests in `passthru.tests` to the package definition like this:
601601-602602-```nix
603603-{ stdenv, lib, fetchurl, callPackage }:
604604-605605-stdenv.mkDerivation {
606606- …
607607-608608- passthru.tests = {
609609- simple-execution = callPackage ./tests.nix { };
610610- };
611611-612612- meta = { … };
613613-}
614614-```
615615-616616-Create `tests.nix` in the package directory:
617617-618618-```nix
619619-{ runCommand, phoronix-test-suite }:
620620-621621-let
622622- inherit (phoronix-test-suite) pname version;
623623-in
624624-625625-runCommand "${pname}-tests" { meta.timeout = 60; }
626626- ''
627627- # automatic initial setup to prevent interactive questions
628628- ${phoronix-test-suite}/bin/phoronix-test-suite enterprise-setup >/dev/null
629629- # get version of installed program and compare with package version
630630- if [[ `${phoronix-test-suite}/bin/phoronix-test-suite version` != *"${version}"* ]]; then
631631- echo "Error: program version does not match package version"
632632- exit 1
633633- fi
634634- # run dummy command
635635- ${phoronix-test-suite}/bin/phoronix-test-suite dummy_module.dummy-command >/dev/null
636636- # needed for Nix to register the command as successful
637637- touch $out
638638- ''
639639-```
4747+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
6404864149### Running package tests {#ssec-package-tests-running}
64250643643-You can run these tests with:
644644-645645-```ShellSession
646646-$ cd path/to/nixpkgs
647647-$ nix-build -A phoronix-test-suite.tests
648648-```
5151+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
6495265053### Examples of package tests {#ssec-package-tests-examples}
65154652652-Here are examples of package tests:
653653-654654-- [Jasmin compile test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/jasmin/test-assemble-hello-world/default.nix)
655655-- [Lobster compile test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/lobster/test-can-run-hello-world.nix)
656656-- [Spacy annotation test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/spacy/annotation-test/default.nix)
657657-- [Libtorch test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/science/math/libtorch/test/default.nix)
658658-- [Multiple tests for nanopb](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/nanopb/default.nix)
5555+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
6595666057### Linking NixOS module tests to a package {#ssec-nixos-tests-linking}
66158662662-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.
663663-664664-For example, assuming we're packaging `nginx`, we can link its module test via `passthru.tests`:
665665-666666-```nix
667667-{ stdenv, lib, nixosTests }:
668668-669669-stdenv.mkDerivation {
670670- ...
671671-672672- passthru.tests = {
673673- nginx = nixosTests.nginx;
674674- };
675675-676676- ...
677677-}
678678-```
5959+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
6796068061### Import From Derivation {#ssec-import-from-derivation}
68162682682-Import From Derivation (IFD) is disallowed in Nixpkgs for performance reasons:
683683-[Hydra] evaluates the entire package set, and sequential builds during evaluation would increase evaluation times to become impractical.
684684-685685-[Hydra]: https://github.com/NixOS/hydra
686686-687687-Import From Derivation can be worked around in some cases by committing generated intermediate files to version control and reading those instead.
688688-689689-<!-- TODO: remove the following and link to Nix manual once https://github.com/NixOS/nix/pull/7332 is merged -->
690690-691691-See also [NixOS Wiki: Import From Derivation].
692692-693693-[NixOS Wiki: Import From Derivation]: https://nixos.wiki/wiki/Import_From_Derivation
6363+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
···11# Contributing to Nixpkgs documentation {#chap-contributing}
2233-The sources of the Nixpkgs manual are in the [doc](https://github.com/NixOS/nixpkgs/tree/master/doc) subdirectory of the Nixpkgs repository.
44-55-You can quickly check your edits with `nix-build`:
66-77-```ShellSession
88-$ cd /path/to/nixpkgs
99-$ nix-build doc
1010-```
1111-1212-If the build succeeds, the manual will be in `./result/share/doc/nixpkgs/manual.html`.
33+This section has been moved to [doc/README.md](https://github.com/NixOS/nixpkgs/blob/master/doc/README.md).
134145## devmode {#sec-contributing-devmode}
1561616-The shell in the manual source directory makes available a command, `devmode`.
1717-It is a daemon, that:
1818-1. watches the manual's source for changes and when they occur — rebuilds
1919-2. HTTP serves the manual, injecting a script that triggers reload on changes
2020-3. opens the manual in the default browser
77+This section has been moved to [doc/README.md](https://github.com/NixOS/nixpkgs/blob/master/doc/README.md).
218229## Syntax {#sec-contributing-markup}
23102424-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.
2525-2626-Additional syntax extensions are available, all of which can be used in NixOS option documentation. The following extensions are currently used:
2727-2828-- []{#ssec-contributing-markup-tables}
2929- Tables, using the [GitHub-flavored Markdown syntax](https://github.github.com/gfm/#tables-extension-).
3030-3131-- []{#ssec-contributing-markup-anchors}
3232- 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).
3333-3434- It uses the widely compatible [header attributes](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/attributes.md) syntax:
3535-3636- ```markdown
3737- ## Syntax {#sec-contributing-markup}
3838- ```
3939-4040- ::: {.note}
4141- NixOS option documentation does not support headings in general.
4242- :::
4343-4444-- []{#ssec-contributing-markup-anchors-inline}
4545- **Inline anchors**, which allow linking arbitrary place in the text (e.g. individual list items, sentences…).
4646-4747- 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):
4848-4949- ```markdown
5050- - []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`.
5151- ```
5252-5353-- []{#ssec-contributing-markup-automatic-links}
5454- 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).
5555-5656- This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing).
5757-5858-- []{#ssec-contributing-markup-inline-roles}
5959- 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`.
6060-6161- A few markups for other kinds of literals are also available:
6262-6363- - `` {command}`rm -rfi` `` turns into {command}`rm -rfi`
6464- - `` {env}`XDG_DATA_DIRS` `` turns into {env}`XDG_DATA_DIRS`
6565- - `` {file}`/etc/passwd` `` turns into {file}`/etc/passwd`
6666- - `` {option}`networking.useDHCP` `` turns into {option}`networking.useDHCP`
6767- - `` {var}`/etc/passwd` `` turns into {var}`/etc/passwd`
6868-6969- These literal kinds are used mostly in NixOS option documentation.
7070-7171- 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.
7272-7373-- []{#ssec-contributing-markup-admonitions}
7474- **Admonitions**, set off from the text to bring attention to something.
7575-7676- It uses pandoc’s [fenced `div`s syntax](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/fenced_divs.md):
7777-7878- ```markdown
7979- ::: {.warning}
8080- This is a warning
8181- :::
8282- ```
8383-8484- which renders as
8585-8686- > ::: {.warning}
8787- > This is a warning.
8888- > :::
8989-9090- The following are supported:
9191-9292- - [`caution`](https://tdg.docbook.org/tdg/5.0/caution.html)
9393- - [`important`](https://tdg.docbook.org/tdg/5.0/important.html)
9494- - [`note`](https://tdg.docbook.org/tdg/5.0/note.html)
9595- - [`tip`](https://tdg.docbook.org/tdg/5.0/tip.html)
9696- - [`warning`](https://tdg.docbook.org/tdg/5.0/warning.html)
9797-9898-- []{#ssec-contributing-markup-definition-lists}
9999- [**Definition lists**](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/definition_lists.md), for defining a group of terms:
100100-101101- ```markdown
102102- pear
103103- : green or yellow bulbous fruit
104104-105105- watermelon
106106- : green fruit with red flesh
107107- ```
108108-109109- which renders as
110110-111111- > pear
112112- > : green or yellow bulbous fruit
113113- >
114114- > watermelon
115115- > : green fruit with red flesh
1111+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
···11# Quick Start to Adding a Package {#chap-quick-start}
2233-To add a package to Nixpkgs:
44-55-1. Checkout the Nixpkgs source tree:
66-77- ```ShellSession
88- $ git clone https://github.com/NixOS/nixpkgs
99- $ cd nixpkgs
1010- ```
1111-1212-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.
1313-1414- ```ShellSession
1515- $ mkdir pkgs/development/libraries/libfoo
1616- ```
1717-1818-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`.
1919-2020- ```ShellSession
2121- $ emacs pkgs/development/libraries/libfoo/default.nix
2222- $ git add pkgs/development/libraries/libfoo/default.nix
2323- ```
2424-2525- You can have a look at the existing Nix expressions under `pkgs/` to see how it’s done. Here are some good ones:
2626-2727- - 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.
2828-2929- - 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`.
3030-3131- - 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`.
3232-3333- - 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`.
3434-3535- - 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.
3636-3737- - 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.
3838-3939- - 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.
4040-4141- - 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.
4242-4343- - 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.
4444-4545- Some notes:
4646-4747- - 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).
4848-4949- - 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.
5050-5151- - 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).
5252-5353- 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).
5454-5555-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`.
5656-5757- ```ShellSession
5858- $ emacs pkgs/top-level/all-packages.nix
5959- ```
6060-6161- 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.
6262-6363-5. To test whether the package builds, run the following command from the root of the nixpkgs source tree:
6464-6565- ```ShellSession
6666- $ nix-build -A libfoo
6767- ```
6868-6969- 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.
7070-7171-6. If you want to install the package into your profile (optional), do
7272-7373- ```ShellSession
7474- $ nix-env -f . -iA libfoo
7575- ```
7676-7777-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.
33+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
···11# Reviewing contributions {#chap-reviewing-contributions}
2233-::: {.warning}
44-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).
55-:::
66-77-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.
88-99-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).
1010-1111-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.
1212-1313-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.
1414-1515-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.
1616-1717-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.
33+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
184195## Package updates {#reviewing-contributions-package-updates}
2062121-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.
2222-2323-It can happen that non-trivial updates include patches or more complex changes.
2424-2525-Reviewing process:
2626-2727-- Ensure that the package versioning fits the guidelines.
2828-- Ensure that the commit text fits the guidelines.
2929-- Ensure that the package maintainers are notified.
3030- - [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.
3131-- Ensure that the meta field information is correct.
3232- - License can change with version updates, so it should be checked to match the upstream license.
3333- - 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.
3434-- Ensure that the code contains no typos.
3535-- Building the package locally.
3636- - 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.
3737- - 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.
3838-3939- ```ShellSession
4040- $ git fetch origin nixos-unstable
4141- $ git fetch origin pull/PRNUMBER/head
4242- $ git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD
4343- ```
4444-4545- - The first command fetches the nixos-unstable branch.
4646- - 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.
4747- - The third command rebases the pull request changes to the nixos-unstable branch.
4848- - 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.
4949-5050- ```ShellSession
5151- $ nix-shell -p nixpkgs-review --run "nixpkgs-review pr PRNUMBER"
5252- ```
5353-- Running every binary.
5454-5555-Sample template for a package update review is provided below.
5656-5757-```markdown
5858-##### Reviewed points
5959-6060-- [ ] package name fits guidelines
6161-- [ ] package version fits guidelines
6262-- [ ] package build on ARCHITECTURE
6363-- [ ] executables tested on ARCHITECTURE
6464-- [ ] all depending packages build
6565-- [ ] patches have a comment describing either the upstream URL or a reason why the patch wasn't upstreamed
6666-- [ ] patches that are remotely available are fetched rather than vendored
6767-6868-##### Possible improvements
6969-7070-##### Comments
7171-```
77+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
728739## New packages {#reviewing-contributions-new-packages}
74107575-New packages are a common type of pull requests. These pull requests consists in adding a new nix-expression for a package.
7676-7777-Review process:
7878-7979-- Ensure that the package versioning fits the guidelines.
8080-- Ensure that the commit name fits the guidelines.
8181-- Ensure that the meta fields contain correct information.
8282- - License must match the upstream license.
8383- - Platforms should be set (or the package will not get binary substitutes).
8484- - Maintainers must be set. This can be the package submitter or a community member that accepts taking up maintainership of the package.
8585-- Report detected typos.
8686-- Ensure the package source:
8787- - Uses mirror URLs when available.
8888- - Uses the most appropriate functions (e.g. packages from GitHub should use `fetchFromGitHub`).
8989-- Building the package locally.
9090-- Running every binary.
9191-9292-Sample template for a new package review is provided below.
9393-9494-```markdown
9595-##### Reviewed points
9696-9797-- [ ] package path fits guidelines
9898-- [ ] package name fits guidelines
9999-- [ ] package version fits guidelines
100100-- [ ] package build on ARCHITECTURE
101101-- [ ] executables tested on ARCHITECTURE
102102-- [ ] `meta.description` is set and fits guidelines
103103-- [ ] `meta.license` fits upstream license
104104-- [ ] `meta.platforms` is set
105105-- [ ] `meta.maintainers` is set
106106-- [ ] build time only dependencies are declared in `nativeBuildInputs`
107107-- [ ] source is fetched using the appropriate function
108108-- [ ] the list of `phases` is not overridden
109109-- [ ] when a phase (like `installPhase`) is overridden it starts with `runHook preInstall` and ends with `runHook postInstall`.
110110-- [ ] patches have a comment describing either the upstream URL or a reason why the patch wasn't upstreamed
111111-- [ ] patches that are remotely available are fetched rather than vendored
112112-113113-##### Possible improvements
114114-115115-##### Comments
116116-```
1111+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
1171211813## Module updates {#reviewing-contributions-module-updates}
11914120120-Module updates are submissions changing modules in some ways. These often contains changes to the options or introduce new options.
121121-122122-Reviewing process:
123123-124124-- Ensure that the module maintainers are notified.
125125- - [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.
126126-- Ensure that the module tests, if any, are succeeding.
127127-- Ensure that the introduced options are correct.
128128- - Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated).
129129- - Description, default and example should be provided.
130130-- Ensure that option changes are backward compatible.
131131- - `mkRenamedOptionModuleWith` provides a way to make option changes backward compatible.
132132-- Ensure that removed options are declared with `mkRemovedOptionModule`
133133-- Ensure that changes that are not backward compatible are mentioned in release notes.
134134-- Ensure that documentations affected by the change is updated.
135135-136136-Sample template for a module update review is provided below.
137137-138138-```markdown
139139-##### Reviewed points
140140-141141-- [ ] changes are backward compatible
142142-- [ ] removed options are declared with `mkRemovedOptionModule`
143143-- [ ] changes that are not backward compatible are documented in release notes
144144-- [ ] module tests succeed on ARCHITECTURE
145145-- [ ] options types are appropriate
146146-- [ ] options description is set
147147-- [ ] options example is provided
148148-- [ ] documentation affected by the changes is updated
149149-150150-##### Possible improvements
151151-152152-##### Comments
153153-```
1515+This section has been moved to [nixos/README.md](https://github.com/NixOS/nixpkgs/blob/master/nixos/README.md).
1541615517## New modules {#reviewing-contributions-new-modules}
15618157157-New modules submissions introduce a new module to NixOS.
158158-159159-Reviewing process:
160160-161161-- Ensure that the module tests, if any, are succeeding.
162162-- Ensure that the introduced options are correct.
163163- - Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated).
164164- - Description, default and example should be provided.
165165-- Ensure that module `meta` field is present
166166- - Maintainers should be declared in `meta.maintainers`.
167167- - Module documentation should be declared with `meta.doc`.
168168-- Ensure that the module respect other modules functionality.
169169- - For example, enabling a module should not open firewall ports by default.
170170-171171-Sample template for a new module review is provided below.
172172-173173-```markdown
174174-##### Reviewed points
175175-176176-- [ ] module path fits the guidelines
177177-- [ ] module tests succeed on ARCHITECTURE
178178-- [ ] options have appropriate types
179179-- [ ] options have default
180180-- [ ] options have example
181181-- [ ] options have descriptions
182182-- [ ] No unneeded package is added to environment.systemPackages
183183-- [ ] meta.maintainers is set
184184-- [ ] module documentation is declared in meta.doc
185185-186186-##### Possible improvements
187187-188188-##### Comments
189189-```
1919+This section has been moved to [nixos/README.md](https://github.com/NixOS/nixpkgs/blob/master/nixos/README.md).
1902019121## Individual maintainer list {#reviewing-contributions-individual-maintainer-list}
19222193193-When adding users to `maintainers/maintainer-list.nix`, the following
194194-checks should be performed:
195195-196196-- If the user has specified a GPG key, verify that the commit is
197197- signed by their key.
198198-199199- First, validate that the commit adding the maintainer is signed by
200200- the key the maintainer listed. Check out the pull request and
201201- compare its signing key with the listed key in the commit.
202202-203203- If the commit is not signed or it is signed by a different user, ask
204204- them to either recommit using that key or to remove their key
205205- information.
206206-207207- Given a maintainer entry like this:
208208-209209- ``` nix
210210- {
211211- example = {
212212- email = "user@example.com";
213213- name = "Example User";
214214- keys = [{
215215- fingerprint = "0000 0000 2A70 6423 0AED 3C11 F04F 7A19 AAA6 3AFE";
216216- }];
217217- }
218218- };
219219- ```
220220-221221- First receive their key from a keyserver:
222222-223223- $ gpg --recv-keys 0xF04F7A19AAA63AFE
224224- gpg: key 0xF04F7A19AAA63AFE: public key "Example <user@example.com>" imported
225225- gpg: Total number processed: 1
226226- gpg: imported: 1
227227-228228- Then check the commit is signed by that key:
229229-230230- $ git log --show-signature
231231- commit b87862a4f7d32319b1de428adb6cdbdd3a960153
232232- gpg: Signature made Wed Mar 12 13:32:24 2003 +0000
233233- gpg: using RSA key 000000002A7064230AED3C11F04F7A19AAA63AFE
234234- gpg: Good signature from "Example User <user@example.com>
235235- Author: Example User <user@example.com>
236236- Date: Wed Mar 12 13:32:24 2003 +0000
237237-238238- maintainers: adding example
239239-240240- and validate that there is a `Good signature` and the printed key
241241- matches the user's submitted key.
242242-243243- Note: GitHub's "Verified" label does not display the user's full key
244244- fingerprint, and should not be used for validating the key matches.
245245-246246-- If the user has specified a `github` account name, ensure they have
247247- also specified a `githubId` and verify the two match.
248248-249249- Maintainer entries that include a `github` field must also include
250250- their `githubId`. People can and do change their GitHub name
251251- frequently, and the ID is used as the official and stable identity
252252- of the maintainer.
253253-254254- Given a maintainer entry like this:
255255-256256- ``` nix
257257- {
258258- example = {
259259- email = "user@example.com";
260260- name = "Example User";
261261- github = "ghost";
262262- githubId = 10137;
263263- }
264264- };
265265- ```
266266-267267- First, make sure that the listed GitHub handle matches the author of
268268- the commit.
269269-270270- Then, visit the URL `https://api.github.com/users/ghost` and
271271- validate that the `id` field matches the provided `githubId`.
2323+This section has been moved to [maintainers/README.md](https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md).
2722427325## Maintainer teams {#reviewing-contributions-maintainer-teams}
27426275275-Feel free to create a new maintainer team in `maintainers/team-list.nix`
276276-when a group is collectively responsible for a collection of packages.
277277-Use taste and personal judgement when deciding if a team is warranted.
278278-279279-Teams are allowed to define their own rules about membership.
280280-281281-For example, some teams will represent a business or other group which
282282-wants to carefully track its members. Other teams may be very open about
283283-who can join, and allow anybody to participate.
284284-285285-When reviewing changes to a team, read the team's scope and the context
286286-around the member list for indications about the team's membership
287287-policy.
288288-289289-In any case, request reviews from the existing team members. If the team
290290-lists no specific membership policy, feel free to merge changes to the
291291-team after giving the existing members a few days to respond.
292292-293293-*Important:* If a team says it is a closed group, do not merge additions
294294-to the team without an approval by at least one existing member.
2727+This section has been moved to [maintainers/README.md](https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md).
2952829629## Other submissions {#reviewing-contributions-other-submissions}
29730298298-Other type of submissions requires different reviewing steps.
299299-300300-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.
301301-302302-Container system, boot system and library changes are some examples of the pull requests fitting this category.
3131+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
3033230433## Merging pull requests {#reviewing-contributions--merging-pull-requests}
30534306306-It is possible for community members that have enough knowledge and experience on a special topic to contribute by merging pull requests.
307307-308308-In case the PR is stuck waiting for the original author to apply a trivial
309309-change (a typo, capitalisation change, etc.) and the author allowed the members
310310-to modify the PR, consider applying it yourself. (or commit the existing review
311311-suggestion) You should pay extra attention to make sure the addition doesn't go
312312-against the idea of the original PR and would not be opposed by the author.
313313-314314-<!--
315315-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.
316316-317317-Please note that contributors with commit rights unactive for more than three months will have their commit rights revoked.
318318--->
319319-320320-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.
321321-322322-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.
3535+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
···11# Submitting changes {#chap-submitting-changes}
2233-## Making patches {#submitting-changes-making-patches}
44-55-- Read [Manual (How to write packages for Nix)](https://nixos.org/nixpkgs/manual/).
66-77-- Fork [the Nixpkgs repository](https://github.com/nixos/nixpkgs/) on GitHub.
88-99-- Create a branch for your future fix.
1010-1111- - 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
1212-1313- ```ShellSession
1414- $ nixos-version --hash
1515- 0998212
1616- $ git checkout 0998212
1717- $ git checkout -b 'fix/pkg-name-update'
1818- ```
1919-2020- - Please avoid working directly on the `master` branch.
2121-2222-- Make commits of logical units.
2323-2424-- 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`.
2525-2626-- Check for unnecessary whitespace with `git diff --check` before committing.
2727-2828-- Format the commit in a following way:
2929-3030- ```
3131- (pkg-name | nixos/<module>): (from -> to | init at version | refactor | etc)
3232- Additional information.
3333- ```
3434-3535- - Examples:
3636- - `nginx: init at 2.0.1`
3737- - `firefox: 54.0.1 -> 55.0`
3838- - `nixos/hydra: add bazBaz option`
3939- - `nixos/nginx: refactor config generation`
4040-4141-- Test your changes. If you work with
4242-4343- - nixpkgs:
4444-4545- - update pkg
4646- - `nix-env -iA pkg-attribute-name -f <path to your local nixpkgs folder>`
4747- - add pkg
4848- - Make sure it’s in `pkgs/top-level/all-packages.nix`
4949- - `nix-env -iA pkg-attribute-name -f <path to your local nixpkgs folder>`
5050- - _If you don’t want to install pkg in you profile_.
5151- - `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`.
5252- - 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.
5353-5454- - NixOS and its modules:
5555- - 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`.
5656-5757-- If you have commits `pkg-name: oh, forgot to insert whitespace`: squash commits in this case. Use `git rebase -i`.
5858-5959-- [Rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) your branch against current `master`.
33+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
604615## Submitting changes {#submitting-changes-submitting-changes}
6266363-- Push your changes to your fork of nixpkgs.
6464-- Create the pull request
6565-- Follow [the contribution guidelines](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#submitting-changes).
77+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
668679## Submitting security fixes {#submitting-changes-submitting-security-fixes}
68106969-Security fixes are submitted in the same way as other changes and thus the same guidelines apply.
7070-7171-- If a new version fixing the vulnerability has been released, update the package;
7272-- 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.
7373- 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.:
7474-7575- ```nix
7676- (fetchpatch {
7777- name = "CVE-2019-11068.patch";
7878- url = "https://gitlab.gnome.org/GNOME/libxslt/commit/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch";
7979- hash = "sha256-SEKe/8HcW0UBHCfPTTOnpRlzmV2nQPPeL6HOMxBZd14=";
8080- })
8181- ```
8282-8383-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.
8484-8585-Critical security fixes may by-pass the staging branches and be delivered directly to release branches such as `master` and `release-*`.
1111+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
86128713## Deprecating/removing packages {#submitting-changes-deprecating-packages}
88148989-There is currently no policy when to remove a package.
9090-9191-Before removing a package, one should try to find a new maintainer or fix smaller issues first.
1515+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
92169317### Steps to remove a package from Nixpkgs {#steps-to-remove-a-package-from-nixpkgs}
94189595-We use jbidwatcher as an example for a discontinued project here.
9696-9797-1. Have Nixpkgs checked out locally and up to date.
9898-1. Create a new branch for your change, e.g. `git checkout -b jbidwatcher`
9999-1. Remove the actual package including its directory, e.g. `git rm -rf pkgs/applications/misc/jbidwatcher`
100100-1. Remove the package from the list of all packages (`pkgs/top-level/all-packages.nix`).
101101-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.)
102102-103103- For example in this case:
104104-105105- ```
106106- jbidwatcher = throw "jbidwatcher was discontinued in march 2021"; # added 2021-03-15
107107- ```
108108-109109- The throw message should explain in short why the package was removed for users that still have it installed.
110110-111111-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.
112112-1. Commit the changes. Explain again why the package was removed. If it was declared discontinued upstream, add a link to the source.
113113-114114- ```ShellSession
115115- $ git add pkgs/applications/misc/jbidwatcher/default.nix pkgs/top-level/all-packages.nix pkgs/top-level/aliases.nix
116116- $ git commit
117117- ```
118118-119119- Example commit message:
120120-121121- ```
122122- jbidwatcher: remove
123123-124124- project was discontinued in march 2021. the program does not work anymore because ebay changed the login.
125125-126126- https://web.archive.org/web/20210315205723/http://www.jbidwatcher.com/
127127- ```
128128-129129-1. Push changes to your GitHub fork with `git push`
130130-1. Create a pull request against Nixpkgs. Mention the package maintainer.
131131-132132-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)
1919+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
1332013421## Pull Request Template {#submitting-changes-pull-request-template}
13522136136-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.
137137-138138-When a PR is created, it will be pre-populated with some checkboxes detailed below:
2323+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
1392414025### Tested using sandboxing {#submitting-changes-tested-with-sandbox}
14126142142-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.
143143-144144-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.
145145-146146-Depending if you use NixOS or other platforms you can use one of the following methods to enable sandboxing **before** building the package:
147147-148148-- **Globally enable sandboxing on NixOS**: add the following to `configuration.nix`
149149-150150- ```nix
151151- nix.useSandbox = true;
152152- ```
153153-154154-- **Globally enable sandboxing on non-NixOS platforms**: add the following to: `/etc/nix/nix.conf`
155155-156156- ```ini
157157- sandbox = true
158158- ```
2727+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
1592816029### Built on platform(s) {#submitting-changes-platform-diversity}
16130162162-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.
3131+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
1633216433### Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests) {#submitting-changes-nixos-tests}
16534166166-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).
3535+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
1673616837### Tested compilation of all pkgs that depend on this change using `nixpkgs-review` {#submitting-changes-tested-compilation}
16938170170-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.
171171-172172-Review changes from pull request number 12345:
173173-174174-```ShellSession
175175-nix-shell -p nixpkgs-review --run "nixpkgs-review pr 12345"
176176-```
177177-178178-Alternatively, with flakes (and analogously for the other commands below):
179179-180180-```ShellSession
181181-nix run nixpkgs#nixpkgs-review -- pr 12345
182182-```
183183-184184-Review uncommitted changes:
185185-186186-```ShellSession
187187-nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
188188-```
189189-190190-Review changes from last commit:
191191-192192-```ShellSession
193193-nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
194194-```
3939+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
1954019641### Tested execution of all binary files (usually in `./result/bin/`) {#submitting-changes-tested-execution}
19742198198-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.
4343+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
1994420045### Meets Nixpkgs contribution standards {#submitting-changes-contribution-standards}
20146202202-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.
4747+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
2034820449## Hotfixing pull requests {#submitting-changes-hotfixing-pull-requests}
20550206206-- Make the appropriate changes in you branch.
207207-- Don’t create additional commits, do
208208- - `git rebase -i`
209209- - `git push --force` to your branch.
5151+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
2105221153## Commit policy {#submitting-changes-commit-policy}
21254213213-- Commits must be sufficiently tested before being merged, both for the master and staging branches.
214214-- 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.
215215-- 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.
5555+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
2165621757### Branches {#submitting-changes-branches}
21858219219-The `nixpkgs` repository has three major branches:
220220-- `master`
221221-- `staging`
222222-- `staging-next`
223223-224224-The most important distinction between them is that `staging`
225225-(colored red in the diagram below) can receive commits which cause
226226-a mass-rebuild (for example, anything that changes the `drvPath` of
227227-`stdenv`). The other two branches `staging-next` and `master`
228228-(colored green in the diagram below) can *not* receive commits which
229229-cause a mass-rebuild.
230230-231231-Arcs between the branches show possible merges into these branches,
232232-either from other branches or from independently submitted PRs. The
233233-colors of these edges likewise show whether or not they could
234234-trigger a mass rebuild (red) or must not trigger a mass rebuild
235235-(green).
236236-237237-Hydra runs automatic builds for the green branches.
238238-239239-Notice that the automatic merges are all green arrows. This is by
240240-design. Any merge which might cause a mass rebuild on a branch
241241-which has automatic builds (`staging-next`, `master`) will be a
242242-manual merge to make sure it is good use of compute power.
243243-244244-Nixpkgs has two branches so that there is one branch (`staging`)
245245-which accepts mass-rebuilding commits, and one fast-rebuilding
246246-branch which accepts independent PRs (`master`). The `staging-next`
247247-branch allows the Hydra operators to batch groups of commits to
248248-`staging` to be built. By keeping the `staging-next` branch
249249-separate from `staging`, this batching does not block
250250-developers from merging changes into `staging`.
251251-252252-```{.graphviz caption="Staging workflow"}
253253-digraph {
254254- master [color="green" fontcolor=green]
255255- "staging-next" [color="green" fontcolor=green]
256256- staging [color="red" fontcolor=red]
257257-258258- "small changes" [fontcolor=green shape=none]
259259- "small changes" -> master [color=green]
260260-261261- "mass-rebuilds and other large changes" [fontcolor=red shape=none]
262262- "mass-rebuilds and other large changes" -> staging [color=red]
263263-264264- "critical security fixes" [fontcolor=green shape=none]
265265- "critical security fixes" -> master [color=green]
266266-267267- "staging fixes which do not cause staging to mass-rebuild" [fontcolor=green shape=none]
268268- "staging fixes which do not cause staging to mass-rebuild" -> "staging-next" [color=green]
269269-270270- "staging-next" -> master [color="red"] [label="manual merge"] [fontcolor="red"]
271271- "staging" -> "staging-next" [color="red"] [label="manual merge"] [fontcolor="red"]
272272-273273- master -> "staging-next" [color="green"] [label="automatic merge (GitHub Action)"] [fontcolor="green"]
274274- "staging-next" -> staging [color="green"] [label="automatic merge (GitHub Action)"] [fontcolor="green"]
275275-}
276276-```
277277-278278-[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.
279279-5959+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
2806028161#### Master branch {#submitting-changes-master-branch}
28262283283-The `master` branch is the main development branch. It should only see non-breaking commits that do not cause mass rebuilds.
6363+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
2846428565#### Staging branch {#submitting-changes-staging-branch}
28666287287-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.
288288-289289-During the process of a releasing a new NixOS version, this branch or the release-critical packages can be restricted to non-breaking changes.
6767+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
2906829169#### Staging-next branch {#submitting-changes-staging-next-branch}
29270293293-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.
294294-295295-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.
296296-297297-During the process of a releasing a new NixOS version, this branch or the release-critical packages can be restricted to non-breaking changes.
7171+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
2987229973#### Stable release branches {#submitting-changes-stable-release-branches}
30074301301-The same staging workflow applies to stable release branches, but the main branch is called `release-*` instead of `master`.
302302-303303-Example branch names: `release-21.11`, `staging-21.11`, `staging-next-21.11`.
304304-305305-Most changes added to the stable release branches are cherry-picked (“backported”) from the `master` and staging branches.
7575+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
3067630777#### Automatically backporting a Pull Request {#submitting-changes-stable-release-branches-automatic-backports}
30878309309-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.
7979+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
3108031181#### Manually backporting changes {#submitting-changes-stable-release-branches-manual-backports}
31282313313-Cherry-pick changes via `git cherry-pick -x <original commit>` so that the original commit id is included in the commit message.
314314-315315-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.
316316-317317-Here is an example of a cherry-picked commit message with good reason description:
318318-319319-```
320320-zfs: Keep trying root import until it works
321321-322322-Works around #11003.
323323-324324-(cherry picked from commit 98b213a11041af39b39473906b595290e2a4e2f9)
325325-326326-Reason: several people cannot boot with ZFS on NVMe
327327-```
328328-329329-Other examples of reasons are:
330330-331331-- Previously the build would fail due to, e.g., `getaddrinfo` not being defined
332332-- The previous download links were all broken
333333-- Crash when starting on some X11 systems
8383+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
3348433585#### Acceptable backport criteria {#acceptable-backport-criteria}
33686337337-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.
8787+This section has been moved to [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
33888339339-However, many changes are able to be backported, including:
340340-- New Packages / Modules
341341-- Security / Patch updates
342342-- Version updates which include new functionality (but no breaking changes)
343343-- Services which require a client to be up-to-date regardless. (E.g. `spotify`, `steam`, or `discord`)
344344-- Security critical applications (E.g. `firefox`)
+4-38
doc/contributing/vulnerability-roundup.chapter.md
···11# Vulnerability Roundup {#chap-vulnerability-roundup}
2233-## Issues {#vulnerability-roundup-issues}
44-55-Vulnerable packages in Nixpkgs are managed using issues.
66-Currently opened ones can be found using the following:
77-88-[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)
99-1010-Each issue correspond to a vulnerable version of a package; As a consequence:
1111-1212-- One issue can contain several CVEs;
1313-- One CVE can be shared across several issues;
1414-- A single package can be concerned by several issues.
1515-1616-1717-A "Vulnerability roundup" issue usually respects the following format:
1818-1919-```txt
2020-<link to relevant package search on search.nix.gsc.io>, <link to relevant files in Nixpkgs on GitHub>
2121-2222-<list of related CVEs, their CVSS score, and the impacted NixOS version>
2323-2424-<list of the scanned Nixpkgs versions>
33+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
2542626-<list of relevant contributors>
2727-```
55+## Issues {#vulnerability-roundup-issues}
2862929-Note that there can be an extra comment containing links to previously reported (and still open) issues for the same package.
3030-77+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
318329## Triaging and Fixing {#vulnerability-roundup-triaging-and-fixing}
33103434-**Note**: An issue can be a "false positive" (i.e. automatically opened, but without the package it refers to being actually vulnerable).
3535-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.
3636-3737-If you are investigating a "true positive":
3838-3939-- Find the earliest patched version or a code patch in the CVE details;
4040-- Is the issue already patched (version up-to-date or patch applied manually) in Nixpkgs's `master` branch?
4141- - **No**:
4242- - [Submit a security fix](#submitting-changes-submitting-security-fixes);
4343- - 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);
4444- - **Yes**: [Backport the change to the vulnerable release branch(es)](https://nixos.org/manual/nixpkgs/stable/#submitting-changes-stable-release-branches).
4545-- When the patch has made it into all the relevant branches (`master`, and the vulnerable releases), close the relevant issue(s).
1111+This section has been moved to [pkgs/README.md](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md).
+10
doc/development.md
···11+# Development of Nixpkgs {#part-development}
22+33+This section shows you how Nixpkgs is being developed and how you can interact with the contributors and the latest updates.
44+If you are interested in contributing yourself, see [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
55+66+<!-- In the future this section should also include: How to test pull requests, how to know if pull requests are available in channels, etc. -->
77+88+```{=include=} chapters
99+development/opening-issues.chapter.md
1010+```
+7
doc/development/opening-issues.chapter.md
···11+# Opening issues {#sec-opening-issues}
22+33+* Make sure you have a [GitHub account](https://github.com/signup/free)
44+* Make sure there is no open issue on the topic
55+* [Submit a new issue](https://github.com/NixOS/nixpkgs/issues/new/choose) by choosing the kind of topic and fill out the template
66+77+<!-- In the future this section could also include more detailed information on the issue templates -->
···11+# Nixpkgs Maintainers
22+33+The *Nixpkgs maintainers* are people who have assigned themselves to
44+maintain specific individual packages. We encourage people who care
55+about a package to assign themselves as a maintainer. When a pull
66+request is made against a package, OfBorg will notify the appropriate
77+maintainer(s).
88+99+## Reviewing contributions
1010+1111+### Individual maintainer list
1212+1313+When adding users to [`maintainer-list.nix`](./maintainer-list.nix), the following
1414+checks should be performed:
1515+1616+- If the user has specified a GPG key, verify that the commit is
1717+ signed by their key.
1818+1919+ First, validate that the commit adding the maintainer is signed by
2020+ the key the maintainer listed. Check out the pull request and
2121+ compare its signing key with the listed key in the commit.
2222+2323+ If the commit is not signed or it is signed by a different user, ask
2424+ them to either recommit using that key or to remove their key
2525+ information.
2626+2727+ Given a maintainer entry like this:
2828+2929+ ``` nix
3030+ {
3131+ example = {
3232+ email = "user@example.com";
3333+ name = "Example User";
3434+ keys = [{
3535+ fingerprint = "0000 0000 2A70 6423 0AED 3C11 F04F 7A19 AAA6 3AFE";
3636+ }];
3737+ }
3838+ };
3939+ ```
4040+4141+ First receive their key from a keyserver:
4242+4343+ $ gpg --recv-keys 0xF04F7A19AAA63AFE
4444+ gpg: key 0xF04F7A19AAA63AFE: public key "Example <user@example.com>" imported
4545+ gpg: Total number processed: 1
4646+ gpg: imported: 1
4747+4848+ Then check the commit is signed by that key:
4949+5050+ $ git log --show-signature
5151+ commit b87862a4f7d32319b1de428adb6cdbdd3a960153
5252+ gpg: Signature made Wed Mar 12 13:32:24 2003 +0000
5353+ gpg: using RSA key 000000002A7064230AED3C11F04F7A19AAA63AFE
5454+ gpg: Good signature from "Example User <user@example.com>
5555+ Author: Example User <user@example.com>
5656+ Date: Wed Mar 12 13:32:24 2003 +0000
5757+5858+ maintainers: adding example
5959+6060+ and validate that there is a `Good signature` and the printed key
6161+ matches the user's submitted key.
6262+6363+ Note: GitHub's "Verified" label does not display the user's full key
6464+ fingerprint, and should not be used for validating the key matches.
6565+6666+- If the user has specified a `github` account name, ensure they have
6767+ also specified a `githubId` and verify the two match.
6868+6969+ Maintainer entries that include a `github` field must also include
7070+ their `githubId`. People can and do change their GitHub name
7171+ frequently, and the ID is used as the official and stable identity
7272+ of the maintainer.
7373+7474+ Given a maintainer entry like this:
7575+7676+ ``` nix
7777+ {
7878+ example = {
7979+ email = "user@example.com";
8080+ name = "Example User";
8181+ github = "ghost";
8282+ githubId = 10137;
8383+ }
8484+ };
8585+ ```
8686+8787+ First, make sure that the listed GitHub handle matches the author of
8888+ the commit.
8989+9090+ Then, visit the URL `https://api.github.com/users/ghost` and
9191+ validate that the `id` field matches the provided `githubId`.
9292+9393+### Maintainer teams
9494+9595+Feel free to create a new maintainer team in [`team-list.nix`](./team-list.nix)
9696+when a group is collectively responsible for a collection of packages.
9797+Use taste and personal judgement when deciding if a team is warranted.
9898+9999+Teams are allowed to define their own rules about membership.
100100+101101+For example, some teams will represent a business or other group which
102102+wants to carefully track its members. Other teams may be very open about
103103+who can join, and allow anybody to participate.
104104+105105+When reviewing changes to a team, read the team's scope and the context
106106+around the member list for indications about the team's membership
107107+policy.
108108+109109+In any case, request reviews from the existing team members. If the team
110110+lists no specific membership policy, feel free to merge changes to the
111111+team after giving the existing members a few days to respond.
112112+113113+*Important:* If a team says it is a closed group, do not merge additions
114114+to the team without an approval by at least one existing member.
-5
nixos/README
···11-*** NixOS ***
22-33-NixOS is a Linux distribution based on the purely functional package
44-management system Nix. More information can be found at
55-https://nixos.org/nixos and in the manual in doc/manual.
+86
nixos/README.md
···11+# NixOS
22+33+NixOS is a Linux distribution based on the purely functional package
44+management system Nix. More information can be found at
55+https://nixos.org/nixos and in the manual in doc/manual.
66+77+## Testing changes
88+99+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`.
1010+1111+## Reviewing contributions
1212+1313+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.
1414+1515+### Module updates
1616+1717+Module updates are submissions changing modules in some ways. These often contains changes to the options or introduce new options.
1818+1919+Reviewing process:
2020+2121+- Ensure that the module maintainers are notified.
2222+ - [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.
2323+- Ensure that the module tests, if any, are succeeding.
2424+- Ensure that the introduced options are correct.
2525+ - Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated).
2626+ - Description, default and example should be provided.
2727+- Ensure that option changes are backward compatible.
2828+ - `mkRenamedOptionModuleWith` provides a way to make option changes backward compatible.
2929+- Ensure that removed options are declared with `mkRemovedOptionModule`
3030+- Ensure that changes that are not backward compatible are mentioned in release notes.
3131+- Ensure that documentations affected by the change is updated.
3232+3333+Sample template for a module update review is provided below.
3434+3535+```markdown
3636+##### Reviewed points
3737+3838+- [ ] changes are backward compatible
3939+- [ ] removed options are declared with `mkRemovedOptionModule`
4040+- [ ] changes that are not backward compatible are documented in release notes
4141+- [ ] module tests succeed on ARCHITECTURE
4242+- [ ] options types are appropriate
4343+- [ ] options description is set
4444+- [ ] options example is provided
4545+- [ ] documentation affected by the changes is updated
4646+4747+##### Possible improvements
4848+4949+##### Comments
5050+```
5151+5252+### New modules
5353+5454+New modules submissions introduce a new module to NixOS.
5555+5656+Reviewing process:
5757+5858+- Ensure that the module tests, if any, are succeeding.
5959+- Ensure that the introduced options are correct.
6060+ - Type should be appropriate (string related types differs in their merging capabilities, `loaOf` and `string` types are deprecated).
6161+ - Description, default and example should be provided.
6262+- Ensure that module `meta` field is present
6363+ - Maintainers should be declared in `meta.maintainers`.
6464+ - Module documentation should be declared with `meta.doc`.
6565+- Ensure that the module respect other modules functionality.
6666+ - For example, enabling a module should not open firewall ports by default.
6767+6868+Sample template for a new module review is provided below.
6969+7070+```markdown
7171+##### Reviewed points
7272+7373+- [ ] module path fits the guidelines
7474+- [ ] module tests succeed on ARCHITECTURE
7575+- [ ] options have appropriate types
7676+- [ ] options have default
7777+- [ ] options have example
7878+- [ ] options have descriptions
7979+- [ ] No unneeded package is added to environment.systemPackages
8080+- [ ] meta.maintainers is set
8181+- [ ] module documentation is declared in meta.doc
8282+8383+##### Possible improvements
8484+8585+##### Comments
8686+```
+837
pkgs/README.md
···11+# Contributing to Nixpkgs packages
22+33+This document is for people wanting to contribute specifically to the package collection in Nixpkgs.
44+See the [CONTRIBUTING.md](../CONTRIBUTING.md) document for more general information.
55+66+## Overview
77+88+- [`top-level`](./top-level): Entrypoints, package set aggregations
99+ - [`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>`
1010+ - [`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> {…}`
1111+ - `*-packages.nix`, [`linux-kernels.nix`](./top-level/linux-kernels.nix), [`unixtools.nix`](./top-level/unixtools.nix): Aggregations of nested package sets defined in `development`
1212+ - [`aliases.nix`](./top-level/aliases.nix), [`python-aliases.nix`](./top-level/python-aliases.nix): Aliases for package definitions that have been renamed or removed
1313+ - `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
1414+- [`development`](./development)
1515+ - `*-modules`, `*-packages`, `*-pkgs`: Package definitions for nested package sets
1616+ - All other directories loosely categorise top-level package definitions, see [category hierarchy][categories]
1717+- [`build-support`](./build-support): [Builders](https://nixos.org/manual/nixpkgs/stable/#part-builders)
1818+ - `fetch*`: [Fetchers](https://nixos.org/manual/nixpkgs/stable/#chap-pkgs-fetchers)
1919+- [`stdenv`](./stdenv): [Standard environment](https://nixos.org/manual/nixpkgs/stable/#part-stdenv)
2020+- [`pkgs-lib`](./pkgs-lib): Definitions for utilities that need packages but are not needed for packages
2121+- [`test`](./test): Tests not directly associated with any specific packages
2222+- All other directories loosely categorise top-level packages definitions, see [category hierarchy][categories]
2323+2424+## Quick Start to Adding a Package
2525+2626+To add a package to Nixpkgs:
2727+2828+1. Checkout the Nixpkgs source tree:
2929+3030+ ```ShellSession
3131+ $ git clone https://github.com/NixOS/nixpkgs
3232+ $ cd nixpkgs
3333+ ```
3434+3535+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.
3636+3737+ ```ShellSession
3838+ $ mkdir pkgs/development/libraries/libfoo
3939+ ```
4040+4141+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`.
4242+4343+ ```ShellSession
4444+ $ emacs pkgs/development/libraries/libfoo/default.nix
4545+ $ git add pkgs/development/libraries/libfoo/default.nix
4646+ ```
4747+4848+ You can have a look at the existing Nix expressions under `pkgs/` to see how it’s done. Here are some good ones:
4949+5050+ - GNU Hello: [`pkgs/applications/misc/hello/default.nix`](applications/misc/hello/default.nix). Trivial package, which specifies some `meta` attributes which is good practice.
5151+5252+ - 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`.
5353+5454+ - 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`.
5555+5656+ - 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`.
5757+5858+ - 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.
5959+6060+ - buildMozillaMach: [`pkgs/applications/networking/browser/firefox/common.nix`](applications/networking/browsers/firefox/common.nix). A reusable build function for Firefox, Thunderbird and Librewolf.
6161+6262+ - 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.
6363+6464+ - 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.
6565+6666+ - 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.
6767+6868+ Some notes:
6969+7070+ - 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).
7171+7272+ - 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.
7373+7474+ - A list of schemes for `mirror://` URLs can be found in [`pkgs/build-support/fetchurl/mirrors.nix`](build-support/fetchurl/mirrors.nix).
7575+7676+ 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/).
7777+7878+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`.
7979+8080+ ```ShellSession
8181+ $ emacs pkgs/top-level/all-packages.nix
8282+ ```
8383+8484+ 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.
8585+8686+5. To test whether the package builds, run the following command from the root of the nixpkgs source tree:
8787+8888+ ```ShellSession
8989+ $ nix-build -A libfoo
9090+ ```
9191+9292+ 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.
9393+9494+6. If you want to install the package into your profile (optional), do
9595+9696+ ```ShellSession
9797+ $ nix-env -f . -iA libfoo
9898+ ```
9999+100100+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.
101101+102102+## Category Hierarchy
103103+[categories]: #category-hierarchy
104104+105105+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`.
106106+107107+When in doubt, consider refactoring the `pkgs/` tree, e.g. creating new categories or splitting up an existing category.
108108+109109+**If it’s used to support _software development_:**
110110+111111+- **If it’s a _library_ used by other packages:**
112112+113113+ - `development/libraries` (e.g. `libxml2`)
114114+115115+- **If it’s a _compiler_:**
116116+117117+ - `development/compilers` (e.g. `gcc`)
118118+119119+- **If it’s an _interpreter_:**
120120+121121+ - `development/interpreters` (e.g. `guile`)
122122+123123+- **If it’s a (set of) development _tool(s)_:**
124124+125125+ - **If it’s a _parser generator_ (including lexers):**
126126+127127+ - `development/tools/parsing` (e.g. `bison`, `flex`)
128128+129129+ - **If it’s a _build manager_:**
130130+131131+ - `development/tools/build-managers` (e.g. `gnumake`)
132132+133133+ - **If it’s a _language server_:**
134134+135135+ - `development/tools/language-servers` (e.g. `ccls` or `rnix-lsp`)
136136+137137+ - **Else:**
138138+139139+ - `development/tools/misc` (e.g. `binutils`)
140140+141141+- **Else:**
142142+143143+ - `development/misc`
144144+145145+**If it’s a (set of) _tool(s)_:**
146146+147147+(A tool is a relatively small program, especially one intended to be used non-interactively.)
148148+149149+- **If it’s for _networking_:**
150150+151151+ - `tools/networking` (e.g. `wget`)
152152+153153+- **If it’s for _text processing_:**
154154+155155+ - `tools/text` (e.g. `diffutils`)
156156+157157+- **If it’s a _system utility_, i.e., something related or essential to the operation of a system:**
158158+159159+ - `tools/system` (e.g. `cron`)
160160+161161+- **If it’s an _archiver_ (which may include a compression function):**
162162+163163+ - `tools/archivers` (e.g. `zip`, `tar`)
164164+165165+- **If it’s a _compression_ program:**
166166+167167+ - `tools/compression` (e.g. `gzip`, `bzip2`)
168168+169169+- **If it’s a _security_-related program:**
170170+171171+ - `tools/security` (e.g. `nmap`, `gnupg`)
172172+173173+- **Else:**
174174+175175+ - `tools/misc`
176176+177177+**If it’s a _shell_:**
178178+179179+- `shells` (e.g. `bash`)
180180+181181+**If it’s a _server_:**
182182+183183+- **If it’s a web server:**
184184+185185+ - `servers/http` (e.g. `apache-httpd`)
186186+187187+- **If it’s an implementation of the X Windowing System:**
188188+189189+ - `servers/x11` (e.g. `xorg` — this includes the client libraries and programs)
190190+191191+- **Else:**
192192+193193+ - `servers/misc`
194194+195195+**If it’s a _desktop environment_:**
196196+197197+- `desktops` (e.g. `kde`, `gnome`, `enlightenment`)
198198+199199+**If it’s a _window manager_:**
200200+201201+- `applications/window-managers` (e.g. `awesome`, `stumpwm`)
202202+203203+**If it’s an _application_:**
204204+205205+A (typically large) program with a distinct user interface, primarily used interactively.
206206+207207+- **If it’s a _version management system_:**
208208+209209+ - `applications/version-management` (e.g. `subversion`)
210210+211211+- **If it’s a _terminal emulator_:**
212212+213213+ - `applications/terminal-emulators` (e.g. `alacritty` or `rxvt` or `termite`)
214214+215215+- **If it’s a _file manager_:**
216216+217217+ - `applications/file-managers` (e.g. `mc` or `ranger` or `pcmanfm`)
218218+219219+- **If it’s for _video playback / editing_:**
220220+221221+ - `applications/video` (e.g. `vlc`)
222222+223223+- **If it’s for _graphics viewing / editing_:**
224224+225225+ - `applications/graphics` (e.g. `gimp`)
226226+227227+- **If it’s for _networking_:**
228228+229229+ - **If it’s a _mailreader_:**
230230+231231+ - `applications/networking/mailreaders` (e.g. `thunderbird`)
232232+233233+ - **If it’s a _newsreader_:**
234234+235235+ - `applications/networking/newsreaders` (e.g. `pan`)
236236+237237+ - **If it’s a _web browser_:**
238238+239239+ - `applications/networking/browsers` (e.g. `firefox`)
240240+241241+ - **Else:**
242242+243243+ - `applications/networking/misc`
244244+245245+- **Else:**
246246+247247+ - `applications/misc`
248248+249249+**If it’s _data_ (i.e., does not have a straight-forward executable semantics):**
250250+251251+- **If it’s a _font_:**
252252+253253+ - `data/fonts`
254254+255255+- **If it’s an _icon theme_:**
256256+257257+ - `data/icons`
258258+259259+- **If it’s related to _SGML/XML processing_:**
260260+261261+ - **If it’s an _XML DTD_:**
262262+263263+ - `data/sgml+xml/schemas/xml-dtd` (e.g. `docbook`)
264264+265265+ - **If it’s an _XSLT stylesheet_:**
266266+267267+ (Okay, these are executable...)
268268+269269+ - `data/sgml+xml/stylesheets/xslt` (e.g. `docbook-xsl`)
270270+271271+- **If it’s a _theme_ for a _desktop environment_, a _window manager_ or a _display manager_:**
272272+273273+ - `data/themes`
274274+275275+**If it’s a _game_:**
276276+277277+- `games`
278278+279279+**Else:**
280280+281281+- `misc`
282282+283283+# Conventions
284284+285285+## Package naming
286286+287287+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.
288288+289289+In Nixpkgs, there are generally three different names associated with a package:
290290+291291+- The `pname` attribute of the derivation. This is what most users see, in particular when using `nix-env`.
292292+293293+- 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`.
294294+295295+- The filename for (the directory containing) the Nix expression.
296296+297297+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`.
298298+299299+There are a few naming guidelines:
300300+301301+- The `pname` attribute _should_ be identical to the upstream package name.
302302+303303+- The `pname` and the `version` attribute _must not_ contain uppercase letters — e.g., `"mplayer" instead of `"MPlayer"`.
304304+305305+- The `version` attribute _must_ start with a digit e.g`"0.3.1rc2".
306306+307307+- 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.
308308+309309+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"`.
310310+311311+- 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.
312312+313313+- 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].
314314+315315+## Versioning
316316+[versioning]: #versioning
317317+318318+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.
319319+320320+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`.
321321+322322+All versions of a package _must_ be included in `all-packages.nix` to make sure that they evaluate correctly.
323323+324324+## Meta attributes
325325+326326+* `meta.description` must:
327327+ * Be short, just one sentence.
328328+ * Be capitalized.
329329+ * Not start with the package name.
330330+ * More generally, it should not refer to the package name.
331331+ * Not end with a period (or any punctuation for that matter).
332332+ * Aim to inform while avoiding subjective language.
333333+* `meta.license` must be set and fit the upstream license.
334334+ * If there is no upstream license, `meta.license` should default to `lib.licenses.unfree`.
335335+ * If in doubt, try to contact the upstream developers for clarification.
336336+* `meta.mainProgram` must be set when appropriate.
337337+* `meta.maintainers` should be set.
338338+339339+See the nixpkgs manual for more details on [standard meta-attributes](https://nixos.org/nixpkgs/manual/#sec-standard-meta-attributes).
340340+341341+### Import From Derivation
342342+343343+Import From Derivation (IFD) is disallowed in Nixpkgs for performance reasons:
344344+[Hydra] evaluates the entire package set, and sequential builds during evaluation would increase evaluation times to become impractical.
345345+346346+[Hydra]: https://github.com/NixOS/hydra
347347+348348+Import From Derivation can be worked around in some cases by committing generated intermediate files to version control and reading those instead.
349349+350350+<!-- TODO: remove the following and link to Nix manual once https://github.com/NixOS/nix/pull/7332 is merged -->
351351+352352+See also [NixOS Wiki: Import From Derivation].
353353+354354+[NixOS Wiki: Import From Derivation]: https://nixos.wiki/wiki/Import_From_Derivation
355355+356356+## Sources
357357+358358+### Fetching Sources
359359+360360+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.
361361+362362+You can find many source fetch helpers in `pkgs/build-support/fetch*`.
363363+364364+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:
365365+366366+- Bad: Uses `git://` which won't be proxied.
367367+368368+ ```nix
369369+ src = fetchgit {
370370+ url = "git@github.com:NixOS/nix.git"
371371+ url = "git://github.com/NixOS/nix.git";
372372+ rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae";
373373+ hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ=";
374374+ }
375375+ ```
376376+377377+- Better: This is ok, but an archive fetch will still be faster.
378378+379379+ ```nix
380380+ src = fetchgit {
381381+ url = "https://github.com/NixOS/nix.git";
382382+ rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae";
383383+ hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ=";
384384+ }
385385+ ```
386386+387387+- Best: Fetches a snapshot archive and you get the rev you want.
388388+389389+ ```nix
390390+ src = fetchFromGitHub {
391391+ owner = "NixOS";
392392+ repo = "nix";
393393+ rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae";
394394+ hash = "sha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ=";
395395+ }
396396+ ```
397397+398398+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`.
399399+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).
400400+401401+Find the value to put as `hash` by running `nix-shell -p nix-prefetch-github --run "nix-prefetch-github --rev 1f795f9f44607cc5bec70d1300150bfefcef2aae NixOS nix"`.
402402+403403+#### Obtaining source hash
404404+405405+Preferred source hash type is sha256. There are several ways to get it.
406406+407407+1. Prefetch URL (with `nix-prefetch-XXX URL`, where `XXX` is one of `url`, `git`, `hg`, `cvs`, `bzr`, `svn`). Hash is printed to stdout.
408408+409409+2. Prefetch by package source (with `nix-prefetch-url '<nixpkgs>' -A PACKAGE.src`, where `PACKAGE` is package attribute name). Hash is printed to stdout.
410410+411411+ 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).
412412+413413+3. Upstream provided hash: use it when upstream provides `sha256` or `sha512` (when upstream provides `md5`, don't use it, compute `sha256` instead).
414414+415415+ 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.
416416+417417+ You can convert between formats with nix-hash, for example:
418418+419419+ ```ShellSession
420420+ $ nix-hash --type sha256 --to-base32 HASH
421421+ ```
422422+423423+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.
424424+425425+5. Fake hash: set the hash to one of
426426+427427+ - `""`
428428+ - `lib.fakeHash`
429429+ - `lib.fakeSha256`
430430+ - `lib.fakeSha512`
431431+432432+ in the package expression, attempt build and extract correct hash from error messages.
433433+434434+ > **Warning**
435435+ > You must use one of these four fake hashes and not some arbitrarily-chosen hash.
436436+ > See [here][secure-hashes]
437437+438438+ 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.
439439+440440+441441+#### Obtaining hashes securely
442442+[secure-hashes]: #obtaining-hashes-securely
443443+444444+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:
445445+446446+- `http://` URLs are not secure to prefetch hash from;
447447+448448+- hashes from upstream (in method 3) should be obtained via secure protocol;
449449+450450+- `https://` URLs are secure in methods 1, 2, 3;
451451+452452+- `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.
453453+454454+### Patches
455455+456456+Patches available online should be retrieved using `fetchpatch`.
457457+458458+```nix
459459+patches = [
460460+ (fetchpatch {
461461+ name = "fix-check-for-using-shared-freetype-lib.patch";
462462+ url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=8f5d285";
463463+ hash = "sha256-uRcxaCjd+WAuGrXOmGfFeu79cUILwkRdBu48mwcBE7g=";
464464+ })
465465+];
466466+```
467467+468468+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.
469469+470470+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.
471471+472472+```nix
473473+patches = [ ./0001-changes.patch ];
474474+```
475475+476476+If you do need to do create this sort of patch file, one way to do so is with git:
477477+478478+1. Move to the root directory of the source code you're patching.
479479+480480+ ```ShellSession
481481+ $ cd the/program/source
482482+ ```
483483+484484+2. If a git repository is not already present, create one and stage all of the source files.
485485+486486+ ```ShellSession
487487+ $ git init
488488+ $ git add .
489489+ ```
490490+491491+3. Edit some files to make whatever changes need to be included in the patch.
492492+493493+4. Use git to create a diff, and pipe the output to a patch file:
494494+495495+ ```ShellSession
496496+ $ git diff -a > nixpkgs/pkgs/the/package/0001-changes.patch
497497+ ```
498498+499499+## Deprecating/removing packages
500500+501501+There is currently no policy when to remove a package.
502502+503503+Before removing a package, one should try to find a new maintainer or fix smaller issues first.
504504+505505+### Steps to remove a package from Nixpkgs
506506+507507+We use jbidwatcher as an example for a discontinued project here.
508508+509509+1. Have Nixpkgs checked out locally and up to date.
510510+1. Create a new branch for your change, e.g. `git checkout -b jbidwatcher`
511511+1. Remove the actual package including its directory, e.g. `git rm -rf pkgs/applications/misc/jbidwatcher`
512512+1. Remove the package from the list of all packages (`pkgs/top-level/all-packages.nix`).
513513+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.)
514514+515515+ For example in this case:
516516+517517+ ```
518518+ jbidwatcher = throw "jbidwatcher was discontinued in march 2021"; # added 2021-03-15
519519+ ```
520520+521521+ The throw message should explain in short why the package was removed for users that still have it installed.
522522+523523+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.
524524+1. Commit the changes. Explain again why the package was removed. If it was declared discontinued upstream, add a link to the source.
525525+526526+ ```ShellSession
527527+ $ git add pkgs/applications/misc/jbidwatcher/default.nix pkgs/top-level/all-packages.nix pkgs/top-level/aliases.nix
528528+ $ git commit
529529+ ```
530530+531531+ Example commit message:
532532+533533+ ```
534534+ jbidwatcher: remove
535535+536536+ project was discontinued in march 2021. the program does not work anymore because ebay changed the login.
537537+538538+ https://web.archive.org/web/20210315205723/http://www.jbidwatcher.com/
539539+ ```
540540+541541+1. Push changes to your GitHub fork with `git push`
542542+1. Create a pull request against Nixpkgs. Mention the package maintainer.
543543+544544+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)
545545+546546+## Package tests
547547+548548+To run the main types of tests locally:
549549+550550+- Run package-internal tests with `nix-build --attr pkgs.PACKAGE.passthru.tests`
551551+- 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`
552552+- 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`
553553+- See `lib/tests/NAME.nix` for instructions on running specific library tests
554554+555555+Tests are important to ensure quality and make reviews and automatic updates easy.
556556+557557+The following types of tests exists:
558558+559559+* [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.
560560+* 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.
561561+* The **`checkPhase` of a package**, which should execute the unit tests that are included in the source code of a package.
562562+563563+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).
564564+565565+### Writing inline package tests
566566+567567+For very simple tests, they can be written inline:
568568+569569+```nix
570570+{ …, yq-go }:
571571+572572+buildGoModule rec {
573573+ …
574574+575575+ passthru.tests = {
576576+ simple = runCommand "${pname}-test" {} ''
577577+ echo "test: 1" | ${yq-go}/bin/yq eval -j > $out
578578+ [ "$(cat $out | tr -d $'\n ')" = '{"test":1}' ]
579579+ '';
580580+ };
581581+}
582582+```
583583+584584+### Writing larger package tests
585585+[larger-package-tests]: #writing-larger-package-tests
586586+587587+This is an example using the `phoronix-test-suite` package with the current best practices.
588588+589589+Add the tests in `passthru.tests` to the package definition like this:
590590+591591+```nix
592592+{ stdenv, lib, fetchurl, callPackage }:
593593+594594+stdenv.mkDerivation {
595595+ …
596596+597597+ passthru.tests = {
598598+ simple-execution = callPackage ./tests.nix { };
599599+ };
600600+601601+ meta = { … };
602602+}
603603+```
604604+605605+Create `tests.nix` in the package directory:
606606+607607+```nix
608608+{ runCommand, phoronix-test-suite }:
609609+610610+let
611611+ inherit (phoronix-test-suite) pname version;
612612+in
613613+614614+runCommand "${pname}-tests" { meta.timeout = 60; }
615615+ ''
616616+ # automatic initial setup to prevent interactive questions
617617+ ${phoronix-test-suite}/bin/phoronix-test-suite enterprise-setup >/dev/null
618618+ # get version of installed program and compare with package version
619619+ if [[ `${phoronix-test-suite}/bin/phoronix-test-suite version` != *"${version}"* ]]; then
620620+ echo "Error: program version does not match package version"
621621+ exit 1
622622+ fi
623623+ # run dummy command
624624+ ${phoronix-test-suite}/bin/phoronix-test-suite dummy_module.dummy-command >/dev/null
625625+ # needed for Nix to register the command as successful
626626+ touch $out
627627+ ''
628628+```
629629+630630+### Running package tests
631631+632632+You can run these tests with:
633633+634634+```ShellSession
635635+$ cd path/to/nixpkgs
636636+$ nix-build -A phoronix-test-suite.tests
637637+```
638638+639639+### Examples of package tests
640640+641641+Here are examples of package tests:
642642+643643+- [Jasmin compile test](development/compilers/jasmin/test-assemble-hello-world/default.nix)
644644+- [Lobster compile test](development/compilers/lobster/test-can-run-hello-world.nix)
645645+- [Spacy annotation test](development/python-modules/spacy/annotation-test/default.nix)
646646+- [Libtorch test](development/libraries/science/math/libtorch/test/default.nix)
647647+- [Multiple tests for nanopb](development/libraries/nanopb/default.nix)
648648+649649+### Linking NixOS module tests to a package
650650+651651+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.
652652+653653+For example, assuming we're packaging `nginx`, we can link its module test via `passthru.tests`:
654654+655655+```nix
656656+{ stdenv, lib, nixosTests }:
657657+658658+stdenv.mkDerivation {
659659+ ...
660660+661661+ passthru.tests = {
662662+ nginx = nixosTests.nginx;
663663+ };
664664+665665+ ...
666666+}
667667+```
668668+669669+## Reviewing contributions
670670+671671+### Package updates
672672+673673+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.
674674+675675+It can happen that non-trivial updates include patches or more complex changes.
676676+677677+Reviewing process:
678678+679679+- Ensure that the package versioning fits the guidelines.
680680+- Ensure that the commit text fits the guidelines.
681681+- Ensure that the package maintainers are notified.
682682+ - [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.
683683+- Ensure that the meta field information is correct.
684684+ - License can change with version updates, so it should be checked to match the upstream license.
685685+ - 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.
686686+- Ensure that the code contains no typos.
687687+- Building the package locally.
688688+ - 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.
689689+ - 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.
690690+691691+ ```ShellSession
692692+ $ git fetch origin nixos-unstable
693693+ $ git fetch origin pull/PRNUMBER/head
694694+ $ git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD
695695+ ```
696696+697697+ - The first command fetches the nixos-unstable branch.
698698+ - 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.
699699+ - The third command rebases the pull request changes to the nixos-unstable branch.
700700+ - 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.
701701+702702+ ```ShellSession
703703+ $ nix-shell -p nixpkgs-review --run "nixpkgs-review pr PRNUMBER"
704704+ ```
705705+- Running every binary.
706706+707707+Sample template for a package update review is provided below.
708708+709709+```markdown
710710+##### Reviewed points
711711+712712+- [ ] package name fits guidelines
713713+- [ ] package version fits guidelines
714714+- [ ] package build on ARCHITECTURE
715715+- [ ] executables tested on ARCHITECTURE
716716+- [ ] all depending packages build
717717+- [ ] patches have a comment describing either the upstream URL or a reason why the patch wasn't upstreamed
718718+- [ ] patches that are remotely available are fetched rather than vendored
719719+720720+##### Possible improvements
721721+722722+##### Comments
723723+```
724724+725725+### New packages
726726+727727+New packages are a common type of pull requests. These pull requests consists in adding a new nix-expression for a package.
728728+729729+Review process:
730730+731731+- Ensure that the package versioning fits the guidelines.
732732+- Ensure that the commit name fits the guidelines.
733733+- Ensure that the meta fields contain correct information.
734734+ - License must match the upstream license.
735735+ - Platforms should be set (or the package will not get binary substitutes).
736736+ - Maintainers must be set. This can be the package submitter or a community member that accepts taking up maintainership of the package.
737737+- Report detected typos.
738738+- Ensure the package source:
739739+ - Uses mirror URLs when available.
740740+ - Uses the most appropriate functions (e.g. packages from GitHub should use `fetchFromGitHub`).
741741+- Building the package locally.
742742+- Running every binary.
743743+744744+Sample template for a new package review is provided below.
745745+746746+```markdown
747747+##### Reviewed points
748748+749749+- [ ] package path fits guidelines
750750+- [ ] package name fits guidelines
751751+- [ ] package version fits guidelines
752752+- [ ] package build on ARCHITECTURE
753753+- [ ] executables tested on ARCHITECTURE
754754+- [ ] `meta.description` is set and fits guidelines
755755+- [ ] `meta.license` fits upstream license
756756+- [ ] `meta.platforms` is set
757757+- [ ] `meta.maintainers` is set
758758+- [ ] build time only dependencies are declared in `nativeBuildInputs`
759759+- [ ] source is fetched using the appropriate function
760760+- [ ] the list of `phases` is not overridden
761761+- [ ] when a phase (like `installPhase`) is overridden it starts with `runHook preInstall` and ends with `runHook postInstall`.
762762+- [ ] patches have a comment describing either the upstream URL or a reason why the patch wasn't upstreamed
763763+- [ ] patches that are remotely available are fetched rather than vendored
764764+765765+##### Possible improvements
766766+767767+##### Comments
768768+```
769769+770770+## Security
771771+772772+### Submitting security fixes
773773+[security-fixes]: #submitting-security-fixes
774774+775775+Security fixes are submitted in the same way as other changes and thus the same guidelines apply.
776776+777777+- If a new version fixing the vulnerability has been released, update the package;
778778+- 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.
779779+ 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.:
780780+781781+ ```nix
782782+ (fetchpatch {
783783+ name = "CVE-2019-11068.patch";
784784+ url = "https://gitlab.gnome.org/GNOME/libxslt/commit/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch";
785785+ hash = "sha256-SEKe/8HcW0UBHCfPTTOnpRlzmV2nQPPeL6HOMxBZd14=";
786786+ })
787787+ ```
788788+789789+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.
790790+791791+Critical security fixes may by-pass the staging branches and be delivered directly to release branches such as `master` and `release-*`.
792792+793793+### Vulnerability Roundup
794794+795795+#### Issues
796796+797797+Vulnerable packages in Nixpkgs are managed using issues.
798798+Currently opened ones can be found using the following:
799799+800800+[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)
801801+802802+Each issue correspond to a vulnerable version of a package; As a consequence:
803803+804804+- One issue can contain several CVEs;
805805+- One CVE can be shared across several issues;
806806+- A single package can be concerned by several issues.
807807+808808+809809+A "Vulnerability roundup" issue usually respects the following format:
810810+811811+```txt
812812+<link to relevant package search on search.nix.gsc.io>, <link to relevant files in Nixpkgs on GitHub>
813813+814814+<list of related CVEs, their CVSS score, and the impacted NixOS version>
815815+816816+<list of the scanned Nixpkgs versions>
817817+818818+<list of relevant contributors>
819819+```
820820+821821+Note that there can be an extra comment containing links to previously reported (and still open) issues for the same package.
822822+823823+824824+#### Triaging and Fixing
825825+826826+**Note**: An issue can be a "false positive" (i.e. automatically opened, but without the package it refers to being actually vulnerable).
827827+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.
828828+829829+If you are investigating a "true positive":
830830+831831+- Find the earliest patched version or a code patch in the CVE details;
832832+- Is the issue already patched (version up-to-date or patch applied manually) in Nixpkgs's `master` branch?
833833+ - **No**:
834834+ - [Submit a security fix][security-fixes];
835835+ - Once the fix is merged into `master`, [submit the change to the vulnerable release branch(es)](../CONTRIBUTING.md#how-to-backport-pull-requests);
836836+ - **Yes**: [Backport the change to the vulnerable release branch(es)](../CONTRIBUTING.md#how-to-backport-pull-requests).
837837+- When the patch has made it into all the relevant branches (`master`, and the vulnerable releases), close the relevant issue(s).