Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1 2# Maintainer Workflow 3 4The goal of the [@NixOS/haskell](https://github.com/orgs/NixOS/teams/haskell) 5team is to keep the Haskell packages in Nixpkgs up-to-date, while making sure 6there are no Haskell-related evaluation errors or build errors that get into 7the Nixpkgs `master` branch. 8 9We do this by periodically merging an updated set of Haskell packages on the 10`haskell-updates` branch into the `master` branch. Each member of the team 11takes a two week period where they are in charge of merging the 12`haskell-updates` branch into `master`. This is the documentation for this 13workflow. 14 15The workflow generally proceeds in three main steps: 16 171. create the initial `haskell-updates` PR, and update Stackage and Hackage snapshots 181. wait for contributors to fix newly broken Haskell packages 191. merge `haskell-updates` into `master` 20 21Each of these steps is described in a separate section. 22 23There is a script that automates the workflow for merging the currently open 24`haskell-updates` PR into `master` and opening the next PR. It is described 25at the end of this document. 26 27## Initial `haskell-updates` PR 28 29In this section we create the PR for merging `haskell-updates` into `master`. 30 311. Make sure the `haskell-updates` branch is up-to-date with `master`. 32 331. Update the Stackage Nightly resolver used by Nixpkgs and create a commit: 34 35 ```console 36 $ ./maintainers/scripts/haskell/update-stackage.sh --do-commit 37 ``` 38 391. Update the Hackage package set used by Nixpkgs and create a commit: 40 41 ```console 42 $ ./maintainers/scripts/haskell/update-hackage.sh --do-commit 43 ``` 44 451. Regenerate the Haskell package set used in Nixpkgs and create a commit: 46 47 ```console 48 $ ./maintainers/scripts/haskell/regenerate-hackage-packages.sh --do-commit 49 ``` 50 511. Push these commits to the `haskell-updates` branch of the NixOS/nixpkgs repository. 52 531. Open a PR on Nixpkgs for merging `haskell-updates` into `master`. The recommended 54 PR title and body text are described in the `merge-and-open-pr.sh` section. 55 56## Notify Maintainers and Fix Broken Packages 57 58After you've done the previous steps, Hydra will start building the new and 59updated Haskell packages. You can see the progress Hydra is making at 60https://hydra.nixos.org/jobset/nixpkgs/haskell-updates. This Hydra jobset is 61defined in the file [release-haskell.nix](../../top-level/release-haskell.nix). 62 63### Notify Maintainers 64 65When Hydra finishes building all the updated packages for the `haskell-updates` 66jobset, you should generate a build report to notify maintainers of their 67newly broken packages. You can do that with the following commands: 68 69```console 70$ ./maintainers/scripts/haskell/hydra-report.hs get-report 71$ ./maintainers/scripts/haskell/hydra-report.hs ping-maintainers 72``` 73 74The `hydra-report.hs ping-maintainers` command generates a Markdown document 75that you can paste in a GitHub comment on the PR opened above. This 76comment describes which Haskell packages are now failing to build. It also 77pings the maintainers so that they know to fix up their packages. 78 79It may be helpful to pipe `hydra-report.hs ping-maintainers` into `xclip` 80(XOrg) or `wl-copy` (Wayland) in order to post on GitHub. 81 82This build report can be fetched and re-generated for new Hydra evaluations. 83It may help contributors to try to keep the GitHub comment updated with the 84most recent build report. 85 86Maintainers should be given at least 7 days to fix up their packages when they 87break. If maintainers don't fix up their packages within 7 days, then they 88may be marked broken before merging `haskell-updates` into `master`. 89 90### Fix Broken Packages 91 92After getting the build report, you can see which packages and Hydra jobs are 93failing to build. The most important jobs are the 94[`maintained`](https://hydra.nixos.org/job/nixpkgs/haskell-updates/maintained) and 95[`mergeable`](https://hydra.nixos.org/job/nixpkgs/haskell-updates/mergeable) 96jobs. These are both defined in 97[`release-haskell.nix`](../../top-level/release-haskell.nix). 98 99`mergeable` is a set of the most important Haskell packages, including things 100like Pandoc and XMonad. These packages are widely used. We would like to 101always keep these building. 102 103`maintained` is a set of Haskell packages that have maintainers in Nixpkgs. 104We should be proactive in working with maintainers to keep their packages 105building. 106 107Steps to fix Haskell packages that are failing to build is out of scope for 108this document, but it usually requires fixing up dependencies that are now 109out-of-bounds. 110 111### Mark Broken Packages 112 113Packages that do not get fixed can be marked broken with the following 114commands. First check which packages are broken: 115 116```console 117$ ./maintainers/scripts/haskell/hydra-report.hs get-report 118$ ./maintainers/scripts/haskell/hydra-report.hs mark-broken-list 119``` 120 121This shows a list of packages that reported a build failure on `x86_64-linux` on Hydra. 122 123Next, run the following command: 124 125```console 126$ ./maintainers/scripts/haskell/mark-broken.sh --do-commit 127``` 128 129This first opens up an editor with the broken package list. Some of these 130packages may have a maintainer in Nixpkgs. If these maintainers have not been 131given 7 days to fix up their package, then make sure to remove those packages 132from the list before continuing. After saving and exiting the editor, the 133following will happen: 134 135- Packages from the list will be added to 136 [`configuration-hackage2nix/broken.yaml`](configuration-hackage2nix/broken.yaml). 137 This is a list of Haskell packages that are known to be broken. 138 139- [`hackage-packages.nix`](hackage-packages.nix) will be regenerated. This 140 will mark all Haskell pacakges in `configuration-hackage2nix/broken.yaml` 141 as `broken`. 142 143- The 144 [`configuration-hackage2nix/transitive-broken.yaml`](configuration-hackage2nix/transitive-broken.yaml) 145 file will be updated. This is a list of Haskell packages that 146 depend on a package in `configuration-hackage2nix/broken.yaml` or 147 `configuration-hackage2nix/transitive-broken.yaml` 148 149- `hackage-packages.nix` will be regenerated again. This will set 150 `hydraPlatforms = none` for all the packages in 151 `configuration-hackage2nix/transitive-broken.yaml`. This makes 152 sure that Hydra does not try to build any of these packages. 153 154- All updated files will be committed. 155 156## Merge `haskell-updates` into `master` 157 158Now it is time to merge the `haskell-updates` PR you opened above. 159 160Before doing this, make sure of the following: 161 162- All Haskell packages that fail to build are correctly marked broken or 163 transitively broken. 164 165- The `maintained` and `mergeable` jobs are passing on Hydra. 166 167- The maintainers for any maintained Haskell packages that are newly broken 168 have been pinged on GitHub and given at least a week to fix their packages. 169 This is especially important for widely-used packages like `cachix`. 170 171- Make sure you first merge the `master` branch into `haskell-updates`. Wait 172 for Hydra to evaluate the new `haskell-updates` jobset. Make sure you only 173 merge `haskell-updates` into `master` when there are no evaluation errors. 174 175- Due to Hydra having only a small number of Darwin build machines, the 176 `haskell-updates` jobset on Hydra often has many queued Darwin jobs. 177 In order to not have these queued Darwin jobs prevent the `haskell-updates` 178 branch from being merged to `master` in a timely manner, we have special 179 rules for Darwin jobs. 180 181 - It is alright to merge the `haskell-updates` branch to `master` if 182 there are remaining queued Darwin jobs on Hydra. 183 184 - We would like to keep GHC and the `mergeable` job building on Darwin. 185 Do not merge the `haskell-updates` branch to `master` if GHC is failing 186 to build, or the `mergeable` job has failing Darwin constituent jobs. 187 188 If GHC and the `mergeable` job are not failing, but merely queued, 189 it is alright to merge the `haskell-updates` branch to `master`. 190 191 - We do not need to keep the `maintained` job building on Darwin. 192 If `maintained` packages are failing on Darwin, it is helpful to 193 mark them as broken on that platform. 194 195When you've double-checked these points, go ahead and merge the `haskell-updates` PR. 196After merging, **make sure not to delete the `haskell-updates` branch**, since it 197causes all currently open Haskell-related pull-requests to be automatically closed on GitHub. 198 199## Script for Merging `haskell-updates` and Opening a New PR 200 201There is a script that automates merging the current `haskell-updates` PR and 202opening the next one. When you want to merge the currently open 203`haskell-updates` PR, you can run the script with the following steps: 204 2051. Make sure you have previously authenticated with the `gh` command. The 206 script uses the `gh` command to merge the current PR and open a new one. 207 You should only need to do this once. 208 209 This command can be used to authenticate: 210 211 ```console 212 $ gh auth login 213 ``` 214 215 This command can be used to confirm that you have already authenticated: 216 217 ```console 218 $ gh auth status 219 ``` 220 2211. Make sure you have setup your `~/.cabal/config` file for authentication 222 for uploading the NixOS package versions to Hackage. See the following 223 section for details on how to do this. 224 2251. Make sure you have correctly marked packages broken. One of the previous 226 sections explains how to do this. 227 228 In short: 229 230 ```console 231 $ ./maintainers/scripts/haskell/hydra-report.hs get-report 232 $ ./maintainers/scripts/haskell/hydra-report.hs mark-broken-list 233 $ ./maintainers/scripts/haskell/mark-broken.sh --do-commit 234 ``` 235 2361. Merge `master` into `haskell-updates` and make sure to push to the 237 `haskell-updates` branch. (This can be skipped if `master` has recently 238 been merged into `haskell-updates`.) 239 2401. Go to https://hydra.nixos.org/jobset/nixpkgs/haskell-updates and force an 241 evaluation of the `haskell-updates` jobset. See one of the following 242 sections for how to do this. Make sure there are no evaluation errors. If 243 there are remaining evaluation errors, fix them before continuing with this 244 merge. 245 2461. Run the script to merge `haskell-updates`: 247 248 ```console 249 $ ./maintainers/scripts/haskell/merge-and-open-pr.sh PR_NUM_OF_CURRENT_HASKELL_UPDATES_PR 250 ``` 251 252 Find the PR number easily [here](https://github.com/nixos/nixpkgs/pulls?q=is%3Apr+is%3Aopen+head%3Ahaskell-updates) 253 254 This does the following things: 255 256 1. Fetches `origin`, makes sure you currently have the `haskell-updates` 257 branch checked out, and makes sure your currently checked-out 258 `haskell-updates` branch is on the same commit as 259 `origin/haskell-updates`. 260 261 1. Merges the currently open `haskell-updates` PR. 262 263 1. Updates the version of Haskell packages in NixOS on Hackage. 264 265 1. Updates Stackage and Hackage snapshots. Regenerates the Haskell package set. 266 267 1. Pushes the commits updating Stackage and Hackage and opens a new 268 `haskell-updates` PR on Nixpkgs. If you'd like to do this by hand, 269 look in the script for the recommended PR title and body text. 270 271## Update Hackage Version Information 272 273After merging into `master` you can update what Hackage displays as the current 274version in NixOS for every individual package. To do this you run 275`maintainers/scripts/haskell/upload-nixos-package-list-to-hackage.sh`. See the 276script for how to provide credentials. Once you have configured credentials, 277running this takes only a few seconds. 278 279## Additional Info 280 281Here are some additional tips that didn't fit in above. 282 283- Hydra tries to evaluate the `haskell-updates` branch (in the 284 [`nixpkgs:haskell-updates`](https://hydra.nixos.org/jobset/nixpkgs/haskell-updates) 285 jobset) every 4 hours. It is possible to force a new Hydra evaluation without 286 waiting 4 hours by the following steps: 287 288 1. Log into Hydra with your GitHub or Google account. 289 1. Go to the [nixpkgs:haskell-updates](https://hydra.nixos.org/jobset/nixpkgs/haskell-updates) jobset. 290 1. Click the `Actions` button. 291 1. Select `Evaluate this jobset`. 292 1. If you refresh the page, there should be a new `Evaluation running since:` line. 293 1. Evaluations take about 10 minutes to finish. 294 295- It is sometimes helpful to update the version of 296 [`cabal2nix` / `hackage2nix`](https://github.com/NixOS/cabal2nix) that our 297 maintainer scripts use. This can be done with the 298 [`maintainers/scripts/haskell/update-cabal2nix-unstable.sh`](../../../maintainers/scripts/haskell/update-cabal2nix-unstable.sh) 299 script. 300 301 You might want to do this if a user contributes a fix to `cabal2nix` that 302 will immediately fix a Haskell package in Nixpkgs. First, merge in 303 the PR to `cabal2nix`, then run `update-cabal2nix-upstable.sh`. Finally, run 304 [`regenerate-hackage-packages.sh`](../../../maintainers/scripts/haskell/regenerate-hackage-packages.sh) 305 to regenerate the Hackage package set with the updated version of `hackage2nix`. 306 307- Make sure never to update the Hackage package hashes in 308 [`pkgs/data/misc/hackage/`](../../../pkgs/data/misc/hackage/), or the 309 pinned Stackage Nightly versions on the release branches (like 310 `release-21.05`). 311 312 This means that the 313 [`update-hackage.sh`](../../../maintainers/scripts/haskell/update-hackage.sh) 314 and 315 [`update-stackage.sh`](../../../maintainers/scripts/haskell/update-stackage.sh) 316 scripts should never be used on the release branches. 317 318 However, changing other files in `./.` and regenerating the package set is encouraged. 319 This can be done with 320 [`regenerate-hackage-packages.sh`](../../../maintainers/scripts/haskell/regenerate-hackage-packages.sh) 321 as described above. 322 323- The Haskell team members generally hang out in the Matrix room 324 [#haskell:nixos.org](https://matrix.to/#/#haskell:nixos.org). 325 326- This is a checklist for things that need to happen when a new 327 member is added to the Nixpkgs Haskell team. 328 329 1. Add the person to the 330 [@NixOS/haskell](https://github.com/orgs/NixOS/teams/haskell) 331 team. You may need to ask someone in the NixOS organization 332 to do this, like [@domenkozar](https://github.com/domenkozar). 333 This gives the new member access to the GitHub repos like 334 [cabal2nix](https://github.com/NixOS/cabal2nix). 335 336 1. Add the person as a maintainer for the following packages 337 on Hackage: 338 - https://hackage.haskell.org/package/cabal2nix 339 - https://hackage.haskell.org/package/distribution-nixpkgs 340 - https://hackage.haskell.org/package/hackage-db 341 - https://hackage.haskell.org/package/jailbreak-cabal 342 - https://hackage.haskell.org/package/language-nix 343 344 1. Add the person to the `haskell` team in 345 [`maintainers/team-list.nix`](../../../maintainers/team-list.nix). 346 This team is responsible for some important packages in 347 [release-haskell.nix](../../top-level/release-haskell.nix). 348 349 1. Update the 350 [Nextcloud Calendar](https://cloud.maralorn.de/apps/calendar/p/H6migHmKX7xHoTFa) 351 and work the new member into the `haskell-updates` rotation. 352 353 1. Optionally, have the new member add themselves to the Haskell 354 section in [`CODEOWNERS`](../../../.github/CODEOWNERS). This 355 will cause them to get pinged on most Haskell-related PRs.