modules: move meta at top level

This commit is contained in:
Eric Sagnes 2016-05-09 14:53:27 +09:00
parent 898435d16e
commit 4cdfeb78f9
9 changed files with 103 additions and 95 deletions

View file

@ -105,8 +105,12 @@ rec {
/* Massage a module into canonical form, that is, a set consisting /* Massage a module into canonical form, that is, a set consisting
of options, config and imports attributes. */ of options, config and imports attributes. */
unifyModuleSyntax = file: key: m: unifyModuleSyntax = file: key: m:
let metaSet = if m ? meta
then { meta = m.meta; }
else {};
in
if m ? config || m ? options then if m ? config || m ? options then
let badAttrs = removeAttrs m ["imports" "options" "config" "key" "_file"]; in let badAttrs = removeAttrs m ["imports" "options" "config" "key" "_file" "meta"]; in
if badAttrs != {} then if badAttrs != {} then
throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. This is caused by assignments to the top-level attributes `config' or `options'." throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. This is caused by assignments to the top-level attributes `config' or `options'."
else else
@ -114,14 +118,14 @@ rec {
key = toString m.key or key; key = toString m.key or key;
imports = m.imports or []; imports = m.imports or [];
options = m.options or {}; options = m.options or {};
config = m.config or {}; config = mkMerge [ (m.config or {}) metaSet ];
} }
else else
{ file = m._file or file; { file = m._file or file;
key = toString m.key or key; key = toString m.key or key;
imports = m.require or [] ++ m.imports or []; imports = m.require or [] ++ m.imports or [];
options = {}; options = {};
config = removeAttrs m ["key" "_file" "require" "imports"]; config = mkMerge [ (removeAttrs m ["key" "_file" "require" "imports"]) metaSet ];
}; };
applyIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then applyIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then

View file

@ -62,4 +62,9 @@ in
environment.systemPackages = [ cfg.package gtk2_cache gtk3_cache ]; environment.systemPackages = [ cfg.package gtk2_cache gtk3_cache ];
}; };
meta = {
maintainers = with lib.maintainers; [ ericsagnes ];
doc = ./default.xml;
};
} }

View file

@ -57,7 +57,5 @@ in
}; };
}; };
config = {
meta.maintainers = singleton lib.maintainers.pierron; meta.maintainers = singleton lib.maintainers.pierron;
};
} }

View file

@ -290,9 +290,10 @@ in
systemd.targets."acme-certificates" = {}; systemd.targets."acme-certificates" = {};
}) })
{ meta.maintainers = with lib.maintainers; [ abbradar fpletz globin ];
meta.doc = ./acme.xml;
}
]; ];
meta = {
maintainers = with lib.maintainers; [ abbradar fpletz globin ];
doc = ./acme.xml;
};
} }

View file

@ -253,4 +253,6 @@ in
}; };
meta.doc = ./postgresql.xml;
} }

View file

@ -511,4 +511,7 @@ in {
}; };
}; };
meta.doc = ./gitlab.xml;
} }

View file

@ -534,6 +534,7 @@ in {
(mkIf (cfg.enable && cfg.listenHost != "localhost") { (mkIf (cfg.enable && cfg.listenHost != "localhost") {
networking.firewall.allowedTCPPorts = [ cfg.listenPort ]; networking.firewall.allowedTCPPorts = [ cfg.listenPort ];
}) })
{ meta.doc = ./doc.xml; }
]; ];
meta.doc = ./doc.xml;
} }

View file

@ -95,8 +95,7 @@ in
###### implementation ###### implementation
config = mkMerge [ config = mkIf cfg.enable {
(mkIf cfg.enable {
users.users.teamspeak = { users.users.teamspeak = {
description = "Teamspeak3 voice communication server daemon"; description = "Teamspeak3 voice communication server daemon";
group = group; group = group;
@ -133,9 +132,7 @@ in
PermissionsStartOnly = true; PermissionsStartOnly = true;
}; };
}; };
}) };
{
meta.maintainers = with lib.maintainers; [ arobyn ]; meta.maintainers = with lib.maintainers; [ arobyn ];
}
];
} }

View file

@ -111,8 +111,7 @@ in {
}; };
}; };
config = mkMerge [ config = mkIf cfg.enable {
(mkIf cfg.enable {
assertions = flip mapAttrsToList cfg.networks (name: cfg: { assertions = flip mapAttrsToList cfg.networks (name: cfg: {
assertion = cfg.psk == null || cfg.pskRaw == null; assertion = cfg.psk == null || cfg.pskRaw == null;
message = ''networking.wireless."${name}".psk and networking.wireless."${name}".pskRaw are mutually exclusive''; message = ''networking.wireless."${name}".psk and networking.wireless."${name}".pskRaw are mutually exclusive'';
@ -159,9 +158,7 @@ in {
services.udev.extraRules = '' services.udev.extraRules = ''
ACTION=="add|remove", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", RUN+="${config.systemd.package}/bin/systemctl try-restart wpa_supplicant.service" ACTION=="add|remove", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", RUN+="${config.systemd.package}/bin/systemctl try-restart wpa_supplicant.service"
''; '';
}) };
{
meta.maintainers = with lib.maintainers; [ globin ]; meta.maintainers = with lib.maintainers; [ globin ];
}
];
} }