···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.
216216217217-### Branches {#submitting-changes-branches}
218218-219219-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).
217217+::: {.figure #fig-staging-workflow}
218218+# Staging workflow
219219+<!-- generated from ./staging-workflow.dot using: dot -Tsvg staging-workflow.dot > staging-workflow.svg -->
220220+
221221+:::
236222237237-Hydra runs automatic builds for the green branches.
223223+[This GitHub Action](https://github.com/NixOS/nixpkgs/blob/master/.github/workflows/periodic-merge-6h.yml) brings changes from `master` to `staging-next` and from `staging-next` to `staging` every 6 hours; these are the blue arrows in the diagram above. The purple arrows in the diagram above are done manually and much less frequently. You can get an idea of how often these merges occur by looking at the git history.
238224239239-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.
243225244244-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-280280-281281-#### Master branch {#submitting-changes-master-branch}
226226+### Master branch {#submitting-changes-master-branch}
282227283228The `master` branch is the main development branch. It should only see non-breaking commits that do not cause mass rebuilds.
284229285285-#### Staging branch {#submitting-changes-staging-branch}
230230+### Staging branch {#submitting-changes-staging-branch}
286231287232The `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.
288233289234During the process of a releasing a new NixOS version, this branch or the release-critical packages can be restricted to non-breaking changes.
290235291291-#### Staging-next branch {#submitting-changes-staging-next-branch}
236236+### Staging-next branch {#submitting-changes-staging-next-branch}
292237293238The `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.
294239···296241297242During the process of a releasing a new NixOS version, this branch or the release-critical packages can be restricted to non-breaking changes.
298243299299-#### Stable release branches {#submitting-changes-stable-release-branches}
244244+### Stable release branches {#submitting-changes-stable-release-branches}
300245301246The same staging workflow applies to stable release branches, but the main branch is called `release-*` instead of `master`.
302247