Files
nixpkgs/lib/modules/generic/meta-maintainers.nix
cinereal aca42ac26a lib/services: make the portable service module self-contained
`lib/services/service.nix` reached outside of `lib/` for two class-agnostic
module fragments: `modules/generic/meta-maintainers.nix` and
`nixos/modules/misc/assertions.nix`. That prevents `lib/` from being used as a
standalone tree, which is exactly how `nixos/modules/misc/documentation.nix`
consumes it when building `lazy-options.json`.

Host both fragments in `lib/` and expose them as `lib.genericModules`, so that
consumers outside `lib/` reach them through the `lib` module argument instead of
a filesystem-relative import. The old locations become re-exports, keeping
`modules/generic/meta-maintainers.nix` importable as documented in
`modules/README.md` and `nixos/modules/misc/assertions.nix` usable from
`nixos/modules/module-list.nix`.

`lib` now shares the `filteredModules` tree in `documentation.nix`, so that
`declarations` pointing into it are stripped like the ones pointing into
`modules` and `nixos`, rather than leaving a disallowed store path reference in
`lazy-options.json`.

Assisted-by: Claude:claude-opus-5
2026-08-30 21:18:31 +02:00

60 lines
1.7 KiB
Nix

# Test:
# ../../../modules/generic/meta-maintainers/test.nix
{ lib, ... }:
let
inherit (lib)
mkOption
types
;
# The resulting value of this type shows where all values were defined
sourceList = types.listOf types.raw // {
merge = loc: defs: lib.listToAttrs (lib.map ({ file, value }: lib.nameValuePair file value) defs);
};
in
{
_class = null; # not specific to NixOS
options = {
meta = {
maintainers = mkOption {
type =
let
allMaintainers = lib.attrValues lib.maintainers;
in
lib.types.addCheck sourceList (lib.all (v: lib.elem v allMaintainers))
// {
description = "list of lib.maintainers";
};
default = [ ];
example = lib.literalExpression "[ lib.maintainers.alice lib.maintainers.bob ]";
description = ''
List of maintainers of each module.
This option should be defined at most once per module.
The option value is not a list of maintainers, but an attribute set that maps module file names to lists of maintainers.
'';
};
teams = mkOption {
type =
let
allTeams = lib.attrValues lib.teams;
in
lib.types.addCheck sourceList (lib.all (v: lib.elem v allTeams))
// {
description = "list of lib.teams";
};
default = [ ];
example = lib.literalExpression "[ lib.teams.acme lib.teams.haskell ]";
description = ''
List of team maintainers of each module.
This option should be defined at most once per module.
'';
};
};
};
meta.maintainers = with lib.maintainers; [
pierron
roberth
];
}