Home Explore Blog CI



nixpkgs

maintainers/scripts/README.md
3953d533459de06b87c9f32e9ec76e8b33e14b46010f08dc00000003000009c0
# Maintainer scripts

This folder contains various executable scripts for nixpkgs maintainers,
and supporting data or nixlang files as needed.
These scripts generally aren't a stable interface and may changed or be removed.

What follows is a (very incomplete) overview of available scripts.


## Metadata

### `get-maintainer.sh`

`get-maintainer.sh [selector] value` returns a JSON object describing
a given nixpkgs maintainer, equivalent to `lib.maintainers.${x} // { handle = x; }`.

This allows looking up a maintainer's attrset (including GitHub and Matrix
handles, email address etc.) based on any of their handles, more correctly and
robustly than text search through `maintainer-list.nix`.

```
❯ ./get-maintainer.sh nicoo
{
  "email": "nicoo@debian.org",
  "github": "nbraud",
  "githubId": 1155801,
  "keys": [
    {
      "fingerprint": "E44E 9EA5 4B8E 256A FB73 49D3 EC9D 3708 72BC 7A8C"
    }
  ],
  "name": "nicoo",
  "handle": "nicoo"
}

❯ ./get-maintainer.sh name 'Silvan Mosberger'
{
  "email": "contact@infinisil.com",
  "github": "infinisil",
  "githubId": 20525370,
  "keys": [
    {
      "fingerprint": "6C2B 55D4 4E04 8266 6B7D  DA1A 422E 9EDA E015 7170"
    }
  ],
  "matrix": "@infinisil:matrix.org",
  "name": "Silvan Mosberger",
  "handle": "infinisil"
}
```

The maintainer is designated by a `selector` which must be one of:
- `handle` (default): the maintainer's attribute name in `lib.maintainers`;
- `email`, `name`, `github`, `githubId`, `matrix`, `name`:
  attributes of the maintainer's object, matched exactly;
  see [`maintainer-list.nix`] for the fields' definition.


### `get-maintainer-pings-between.sh`

Gets which maintainers would be pinged between two Nixpkgs revisions.
Outputs a JSON object on stdout mapping GitHub usernames to the attributes
that they would be getting pinged for.

Example:

```sh
maintainers/scripts/get-maintainer-pings-between.sh HEAD^ HEAD
```

## Conventions

### `sha-to-sri.py`

`sha-to-sri.py path ...` (atomically) rewrites hash attributes (named `hash` or `sha(1|256|512)`)
into the SRI format: `hash = "{hash name}-{base64 encoded value}"`.

`path` must point to either a nix file, or a directory which will be automatically traversed.

`sha-to-sri.py` automatically skips files whose first non-empty line contains `generated by` or `do not edit`.
Moreover, when walking a directory tree, the script will skip files whose name is `yarn.nix` or contains `generated`.

Chunks
a1da7606 (1st chunk of `maintainers/scripts/README.md`)
Title: Nixpkgs Maintainer Scripts: Metadata and Conventions
Summary
This section describes some of the executable scripts available for Nixpkgs maintainers, focusing on those related to metadata and conventions. `get-maintainer.sh` retrieves maintainer information as a JSON object based on different selectors like handle, email, or name. `get-maintainer-pings-between.sh` identifies which maintainers would be pinged between two Nixpkgs revisions. `sha-to-sri.py` converts hash attributes to SRI format in Nix files.