nixos/meta: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-30 00:46:31 +02:00
parent 0334b1bf8e
commit 9a8512f460

View File

@ -1,28 +1,25 @@
{ lib, ... }: { lib, ... }:
with lib;
let let
maintainer = mkOptionType { maintainer = lib.mkOptionType {
name = "maintainer"; name = "maintainer";
check = email: elem email (attrValues lib.maintainers); check = email: lib.elem email (lib.attrValues lib.maintainers);
merge = loc: defs: listToAttrs (singleton (nameValuePair (last defs).file (last defs).value)); merge = loc: defs: lib.listToAttrs (lib.singleton (lib.nameValuePair (lib.last defs).file (lib.last defs).value));
}; };
listOfMaintainers = types.listOf maintainer // { listOfMaintainers = lib.types.listOf maintainer // {
# Returns list of # Returns list of
# { "module-file" = [ # { "module-file" = [
# "maintainer1 <first@nixos.org>" # "maintainer1 <first@nixos.org>"
# "maintainer2 <second@nixos.org>" ]; # "maintainer2 <second@nixos.org>" ];
# } # }
merge = loc: defs: merge = loc: defs:
zipAttrs lib.zipAttrs
(flatten (imap1 (n: def: imap1 (m: def': (lib.flatten (lib.imap1 (n: def: lib.imap1 (m: def':
maintainer.merge (loc ++ ["[${toString n}-${toString m}]"]) maintainer.merge (loc ++ ["[${toString n}-${toString m}]"])
[{ inherit (def) file; value = def'; }]) def.value) defs)); [{ inherit (def) file; value = def'; }]) def.value) defs));
}; };
docFile = types.path // { docFile = lib.types.path // {
# Returns tuples of # Returns tuples of
# { file = "module location"; value = <path/to/doc.xml>; } # { file = "module location"; value = <path/to/doc.xml>; }
merge = loc: defs: defs; merge = loc: defs: defs;
@ -33,18 +30,18 @@ in
options = { options = {
meta = { meta = {
maintainers = mkOption { maintainers = lib.mkOption {
type = listOfMaintainers; type = listOfMaintainers;
internal = true; internal = true;
default = []; default = [];
example = literalExpression ''[ lib.maintainers.all ]''; example = lib.literalExpression ''[ lib.maintainers.all ]'';
description = '' description = ''
List of maintainers of each module. This option should be defined at List of maintainers of each module. This option should be defined at
most once per module. most once per module.
''; '';
}; };
doc = mkOption { doc = lib.mkOption {
type = docFile; type = docFile;
internal = true; internal = true;
example = "./meta.chapter.md"; example = "./meta.chapter.md";
@ -54,8 +51,8 @@ in
''; '';
}; };
buildDocsInSandbox = mkOption { buildDocsInSandbox = lib.mkOption {
type = types.bool // { type = lib.types.bool // {
merge = loc: defs: defs; merge = loc: defs: defs;
}; };
internal = true; internal = true;
@ -72,5 +69,5 @@ in
}; };
}; };
meta.maintainers = singleton lib.maintainers.pierron; meta.maintainers = lib.singleton lib.maintainers.pierron;
} }