From 93b21781633dee2329b025bc419e5ee932e86e55 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 10 Jul 2026 15:31:33 +0200 Subject: [PATCH] nixos/testing: allow `meta.teams` in tests, fix maintainer pings for tests With this patch I essentially get the expected list of maintainers for changes in nixos-tests. The downside of this approach is that the CI facility assumes that there's at most a single definition of `meta.maintainers`, however it can be more in a module-system context. For simplicity, just use the first definition location for the time being. Verified with let lib = import ./lib; maintainers = import ./ci/eval/compare/maintainers.nix { inherit lib; }; in maintainers { changedFiles = [ "nixos/tests/matrix/matrix-authentication-service.nix" ]; affectedAttrPaths = map (lib.splitString ".") [ "nixosTests.matrix-authentication-service" ]; } --- nixos/doc/manual/redirects.json | 3 +++ nixos/lib/testing/meta.nix | 37 +++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/nixos/doc/manual/redirects.json b/nixos/doc/manual/redirects.json index fa6f1989ba71..d8ae67eb09b9 100644 --- a/nixos/doc/manual/redirects.json +++ b/nixos/doc/manual/redirects.json @@ -2294,6 +2294,9 @@ "test-opt-meta.hydraPlatforms": [ "index.html#test-opt-meta.hydraPlatforms" ], + "test-opt-meta.teams": [ + "index.html#test-opt-meta.teams" + ], "test-opt-meta.timeout": [ "index.html#test-opt-meta.timeout" ], diff --git a/nixos/lib/testing/meta.nix b/nixos/lib/testing/meta.nix index 1e8f37cf9b51..2194c04f4eda 100644 --- a/nixos/lib/testing/meta.nix +++ b/nixos/lib/testing/meta.nix @@ -1,6 +1,20 @@ -{ lib, ... }: +{ lib, options, ... }: let inherit (lib) types mkOption literalMD; + + # Approximate position of meta.teams / meta.maintainers in nixos tests. + # Right now this assumes only one such position and ignores other definitions. + # FIXME allow having multiple `maintainersPosition` et al.. + getPosition = + definitionsWithLocations: + if definitionsWithLocations == [ ] then + null + else + { + file = (lib.head definitionsWithLocations).file; + column = 0; + line = 1; + }; in { options = { @@ -12,7 +26,7 @@ in ''; apply = lib.filterAttrs (k: v: v != null); type = types.submodule ( - { config, ... }: + { options, config, ... }: { options = { maintainers = mkOption { @@ -22,6 +36,25 @@ in The [list of maintainers](https://nixos.org/manual/nixpkgs/stable/#var-meta-maintainers) for this test. ''; }; + maintainersPosition = mkOption { + internal = true; + readOnly = true; + type = types.nullOr types.attrs; + default = getPosition options.maintainers.definitionsWithLocations; + }; + teams = mkOption { + type = types.listOf types.raw; + default = [ ]; + description = '' + The [list of maintainer-teams](https://nixos.org/manual/nixpkgs/stable/#var-meta-teams) for this test. + ''; + }; + teamsPosition = mkOption { + internal = true; + readOnly = true; + type = types.nullOr types.attrs; + default = getPosition options.teams.definitionsWithLocations; + }; timeout = mkOption { type = types.nullOr types.int; default = 3600; # 1 hour