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