Commit 516a14cd authored by Silvan Mosberger's avatar Silvan Mosberger
Browse files

modules/generic/meta-maintainers.nix: Simplify

There was no need for it to be this complicated.

Notably the maintainer check was never used anyways, because only its
merge function was used, which doesn't do a check

There is a minor functional change with this commit, which is that even
if explicitly `meta.maintainers = []`, that module will be in the result
when it wasn't before. I deem this insignificant.
parent 563bfc7b
Loading
Loading
Loading
Loading
+4 −31
Original line number Diff line number Diff line
@@ -4,39 +4,12 @@
let
  inherit (lib)
    mkOption
    mkOptionType
    types
    ;

  maintainer = mkOptionType {
    name = "maintainer";
    check = email: lib.elem email (lib.attrValues lib.maintainers);
    merge = loc: defs: {
      # lib.last: Perhaps this could be merged instead, if "at most once per module"
      # is a problem (see option description).
      ${(lib.last defs).file} = (lib.last defs).value;
    };
  };

  listOfMaintainers = types.listOf maintainer // {
    merge =
      loc: defs:
      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
        )
      );
  # 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
{
@@ -44,7 +17,7 @@ in
  options = {
    meta = {
      maintainers = mkOption {
        type = listOfMaintainers;
        type = sourceList;
        default = [ ];
        example = lib.literalExpression "[ lib.maintainers.alice lib.maintainers.bob ]";
        description = ''