1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-13 12:19:09 +00:00

Add meta.maintainers option

This commit is contained in:
Robert Hensing 2021-03-07 15:46:08 +01:00
parent adb8ac0453
commit 617604488e
3 changed files with 68 additions and 0 deletions

View file

@ -227,6 +227,19 @@ information on the `-I` flag look at the nix-build [manpage](https://nixos.org/m
darwin-rebuild switch -I darwin=.
```
If you're adding a module, please add yourself to `meta.maintainers`, for example
```nix
meta.maintainers = [
lib.maintainers.alice or "alice"
];
options.services.alicebot = # ...
```
The `or` operator takes care of graceful degradation when `lib` from Nixpkgs
goes out of sync.
Also feel free to contact me if you have questions,
- Matrix - @daiderd:matrix.org, you can find me in [#macos:nixos.org](https://matrix.to/#/#macos:nixos.org)
- @lnl7 on twitter

54
modules/meta.nix Normal file
View file

@ -0,0 +1,54 @@
# This module was derived from
# https://github.com/NixOS/nixpkgs/blob/000387627d26f245a6d9a0a7a60b7feddecaeec0/nixos/modules/misc/meta.nix
{ lib, ... }:
with lib;
let
maintainer = mkOptionType {
name = "maintainer";
check = email: elem email (attrValues lib.maintainers);
merge = loc: defs: listToAttrs (singleton (nameValuePair (last defs).file (last defs).value));
};
listOfMaintainers = 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':
maintainer.merge (loc ++ ["[${toString n}-${toString m}]"])
[{ inherit (def) file; value = def'; }]) def.value) defs));
};
in
{
options = {
meta = {
maintainers = mkOption {
type = listOfMaintainers;
internal = true;
default = [];
example = [ lib.maintainers.all ];
description = ''
List of maintainers of each module. This option should be defined at
most once per module.
NOTE: <literal>lib</literal> comes from Nixpkgs, which can go out of
sync with nix-darwin. For this reason, use definitions like
<literal>maintainers.alice or "alice"</literal>.
'';
};
};
};
meta.maintainers = [
maintainers.roberth or "roberth"
];
}

View file

@ -1,6 +1,7 @@
[
./alias.nix
./documentation
./meta.nix
./misc/ids.nix
./misc/lib.nix
./security/pam.nix