Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/eval/compare/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
beforeResultDir,
afterResultDir,
touchedFilesJson,
byName ? false,
}:
let
/*
Expand Down Expand Up @@ -119,6 +120,7 @@ let
maintainers = import ./maintainers.nix {
changedattrs = lib.attrNames (lib.groupBy (a: a.name) rebuildsPackagePlatformAttrs);
changedpathsjson = touchedFilesJson;
inherit byName;
};
in
runCommand "compare"
Expand Down
22 changes: 19 additions & 3 deletions ci/eval/compare/maintainers.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Almost directly vendored from https://github.com/NixOS/ofborg/blob/5a4e743f192fb151915fcbe8789922fa401ecf48/ofborg/src/maintainers.nix
{ changedattrs, changedpathsjson }:
{
changedattrs,
changedpathsjson,
byName ? false,
}:
let
pkgs = import ../../.. {
system = "x86_64-linux";
Expand Down Expand Up @@ -41,7 +45,18 @@ let
) validPackageAttributes;

attrsWithMaintainers = builtins.map (
pkg: pkg // { maintainers = (pkg.package.meta or { }).maintainers or [ ]; }
pkg:
let
meta = pkg.package.meta or { };
in
pkg
// {
# TODO: Refactor this so we can ping entire teams instead of the individual members.
# Note that this will require keeping track of GH team IDs in "maintainers/teams.nix".
maintainers =
meta.maintainers or [ ]
++ lib.flatten (map (team: team.members or [ ]) (meta.teams or [ ]));
}
) attrsWithPackages;

relevantFilenames =
Expand Down Expand Up @@ -83,12 +98,13 @@ let
pkg:
builtins.map (maintainer: {
id = maintainer.githubId;
inherit (maintainer) github;
packageName = pkg.name;
dueToFiles = pkg.filenames;
}) pkg.maintainers
) attrsWithModifiedFiles;

byMaintainer = lib.groupBy (ping: toString ping.id) listToPing;
byMaintainer = lib.groupBy (ping: toString ping.${if byName then "github" else "id"}) listToPing;

packagesPerMaintainer = lib.attrsets.mapAttrs (
maintainer: packages: builtins.map (pkg: pkg.packageName) packages
Expand Down
3 changes: 3 additions & 0 deletions doc/redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@
"typst-package-scope-and-usage": [
"index.html#typst-package-scope-and-usage"
],
"var-meta-teams": [
"index.html#var-meta-teams"
],
"variables-specifying-dependencies": [
"index.html#variables-specifying-dependencies"
],
Expand Down
4 changes: 4 additions & 0 deletions doc/stdenv/meta.chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ For details, see [Source provenance](#sec-meta-sourceProvenance).

A list of the maintainers of this Nix expression. Maintainers are defined in [`nixpkgs/maintainers/maintainer-list.nix`](https://github.com/NixOS/nixpkgs/blob/master/maintainers/maintainer-list.nix). There is no restriction to becoming a maintainer, just add yourself to that list in a separate commit titled “maintainers: add alice” in the same pull request, and reference maintainers with `maintainers = with lib.maintainers; [ alice bob ]`.

### `teams` {#var-meta-teams}

A list of the teams of this Nix expression. Teams are defined in [`nixpkgs/maintainers/team-list.nix`](https://github.com/NixOS/nixpkgs/blob/master/maintainers/team-list.nix), and can be defined in a package with `meta.teams = with lib.teams; [ team1 team2 ]`.

### `mainProgram` {#var-meta-mainProgram}

The name of the main binary for the package. This affects the binary `nix run` executes. Example: `"rg"`
Expand Down
11 changes: 11 additions & 0 deletions maintainers/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ The maintainer is designated by a `selector` which must be one of:

[`maintainer-list.nix`]: ../maintainer-list.nix

### `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

Expand Down
78 changes: 78 additions & 0 deletions maintainers/scripts/get-maintainer-pings-between.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p git jq

# Outputs a list of maintainers that would be pinged across two nixpkgs revisions.
# Authors:
# Morgan Jones (@numinit)
# Tristan Ross (@RossComputerGuy)

set -euo pipefail

if [ $# -lt 2 ]; then
echo "Usage: $0 <rev-from> <rev-to>" >&2
exit 1
fi

repo="$(git rev-parse --show-toplevel)"
system="$(nix-instantiate --eval --expr builtins.currentSystem)"
rev1="$(git -C "$repo" rev-parse "$1")"
rev2="$(git -C "$repo" rev-parse "$2")"

echo "Touched files:" >&2
git -C "$repo" diff --name-only "$rev1" "$rev2" \
| jq --raw-input --slurp 'split("\n")[:-1]' | tee "$TMPDIR/touched-files.json" >&2

# Runs an eval in the given worktree, outputting the path to $TMPDIR/$1.path.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the latter part of this comment is now inaccurate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

# $1: The revision SHA.
eval_in_worktree() (
mkdir -p .worktree
local rev="$1"
local tree=".worktree/$rev"
if [ ! -d "$tree" ]; then
git -C "$repo" worktree add -f -d "$tree" "$rev" >&2
fi
cd "$tree"

local workdir="$TMPDIR/$rev"
rm -rf "$workdir"
mkdir -p "$workdir"

nix-build ci -A eval.attrpathsSuperset -o "$workdir/paths" >&2
mkdir -p "$workdir/intermediates"
nix-build ci -A eval.singleSystem \
--arg evalSystem "$system" \
--arg attrpathFile "$workdir/paths/paths.json" \
--arg chunkSize ${CHUNK_SIZE:-10000} \
-o "$workdir/intermediates/.intermediate-1" >&2

# eval.combine nix-build needs a directory, not a symlink
cp -RL "$workdir/intermediates/.intermediate-1" "$workdir/intermediates/intermediate-1"
chmod -R +w "$workdir/intermediates/intermediate-1"
rm -rf "$workdir/intermediates/.intermediate-1"

nix-build ci -A eval.combine \
--arg resultsDir "$workdir/intermediates" \
-o "$workdir/result" >&2
)

eval_in_worktree "$rev1" &
pid1=$!
eval_in_worktree "$rev2" &
pid2=$!

wait $pid1
wait $pid2

path1="$TMPDIR/$rev1"
path2="$TMPDIR/$rev2"

# Use the repo this script was executed in to get accurate maintainer info
nix-build "$repo/ci" -A eval.compare \
--arg beforeResultDir "$path1/result" \
--arg afterResultDir "$path2/result" \
--arg touchedFilesJson "$TMPDIR/touched-files.json" \
--arg byName true \
-o comparison

echo "Pinged maintainers (check $repo/comparison for more details)" >&2
jq < comparison/maintainers.json
8 changes: 6 additions & 2 deletions pkgs/stdenv/generic/check-meta.nix
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ let

hasUnfreeLicense = attrs: hasLicense attrs && isUnfree attrs.meta.license;

hasNoMaintainers = attrs: attrs ? meta.maintainers && (length attrs.meta.maintainers) == 0;
hasNoMaintainers =
attrs:
(attrs ? meta.maintainers && (length attrs.meta.maintainers) == 0)
&& (attrs ? meta.teams && (length attrs.meta.teams) == 0);

isMarkedBroken = attrs: attrs.meta.broken or false;

Expand Down Expand Up @@ -368,6 +371,7 @@ let
];
sourceProvenance = listOf attrs;
maintainers = listOf (attrsOf any); # TODO use the maintainer type from lib/tests/maintainer-module.nix
teams = listOf (attrsOf any); # TODO similar to maintainers, use a teams type
priority = int;
pkgConfigModules = listOf str;
inherit platforms;
Expand Down Expand Up @@ -534,7 +538,7 @@ let
{
valid = "warn";
reason = "maintainerless";
errormsg = "has no maintainers";
errormsg = "has no maintainers or teams";
}
# -----
else
Expand Down