···3636- [`options.nix`](options.nix): `lib.options` for anything relating to option definitions
3737- [`types.nix`](types.nix): `lib.types` for module system types
38383939+## PR Guidelines
4040+4141+Follow these guidelines for proposing a change to the interface of `lib`.
4242+4343+### Provide a Motivation
4444+4545+Clearly describe why the change is necessary and its use cases.
4646+4747+Make sure that the change benefits the user more than the added mental effort of looking it up and keeping track of its definition.
4848+If the same can reasonably be done with the existing interface,
4949+consider just updating the documentation with more examples and links.
5050+This is also known as the [Fairbairn Threshold](https://wiki.haskell.org/Fairbairn_threshold).
5151+5252+Through this principle we avoid the human cost of duplicated functionality in an overly large library.
5353+5454+### Make one PR for each change
5555+5656+Don't have multiple changes in one PR, instead split it up into multiple ones.
5757+5858+This keeps the conversation focused and has a higher chance of getting merged.
5959+6060+### Name the interface appropriately
6161+6262+When introducing new names to the interface, such as new function, or new function attributes,
6363+make sure to name it appropriately.
6464+6565+Names should be self-explanatory and consistent with the rest of `lib`.
6666+If there's no obvious best name, include the alternatives you considered.
6767+6868+### Write documentation
6969+7070+Update the [reference documentation](#reference-documentation) to reflect the change.
7171+7272+Be generous with links to related functionality.
7373+7474+### Write tests
7575+7676+Add good test coverage for the change, including:
7777+7878+- Tests for edge cases, such as empty values or lists.
7979+- Tests for tricky inputs, such as a string with string context or a path that doesn't exist.
8080+- Test all code paths, such as `if-then-else` branches and returned attributes.
8181+- If the tests for the sub-library are written in bash,
8282+ test messages of custom errors, such as `throw` or `abortMsg`,
8383+8484+ At the time this is only not necessary for sub-libraries tested with [`tests/misc.nix`](./tests/misc.nix).
8585+8686+See [running tests](#running-tests) for more details on the test suites.
8787+8888+### Write tidy code
8989+9090+Name variables well, even if they're internal.
9191+The code should be as self-explanatory as possible.
9292+Be generous with code comments when appropriate.
9393+9494+As a baseline, follow the [Nixpkgs code conventions](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#code-conventions).
9595+9696+### Write efficient code
9797+9898+Nix generally does not have free abstractions.
9999+Be aware that seemingly straightforward changes can cause more allocations and a decrease in performance.
100100+That said, don't optimise prematurely, especially in new code.
101101+39102## Reference documentation
4010341104Reference documentation for library functions is written above each function as a multi-line comment.