modules: move meta at top level
This commit is contained in:
parent
898435d16e
commit
4cdfeb78f9
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ in
|
||||||
default = [];
|
default = [];
|
||||||
example = [ lib.maintainers.all ];
|
example = [ 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.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@ -49,7 +49,7 @@ in
|
||||||
internal = true;
|
internal = true;
|
||||||
example = "./meta.xml";
|
example = "./meta.xml";
|
||||||
description = ''
|
description = ''
|
||||||
Documentation prologe for the set of options of each module. This
|
Documentation prologe for the set of options of each module. This
|
||||||
option should be defined at most once per module.
|
option should be defined at most once per module.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@ -57,7 +57,5 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
meta.maintainers = singleton lib.maintainers.pierron;
|
||||||
meta.maintainers = singleton lib.maintainers.pierron;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,4 +253,6 @@ in
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
meta.doc = ./postgresql.xml;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -511,4 +511,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
meta.doc = ./gitlab.xml;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,47 +95,44 @@ 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;
|
uid = config.ids.uids.teamspeak;
|
||||||
uid = config.ids.uids.teamspeak;
|
home = cfg.dataDir;
|
||||||
home = cfg.dataDir;
|
createHome = true;
|
||||||
createHome = true;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
users.groups.teamspeak = {
|
users.groups.teamspeak = {
|
||||||
gid = config.ids.gids.teamspeak;
|
gid = config.ids.gids.teamspeak;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.teamspeak3-server = {
|
systemd.services.teamspeak3-server = {
|
||||||
description = "Teamspeak3 voice communication server daemon";
|
description = "Teamspeak3 voice communication server daemon";
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
preStart = ''
|
preStart = ''
|
||||||
mkdir -p ${cfg.logPath}
|
mkdir -p ${cfg.logPath}
|
||||||
chown ${user}:${group} ${cfg.logPath}
|
chown ${user}:${group} ${cfg.logPath}
|
||||||
|
'';
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = ''
|
||||||
|
${ts3}/bin/ts3server \
|
||||||
|
dbsqlpath=${ts3}/lib/teamspeak/sql/ logpath=${cfg.logPath} \
|
||||||
|
voice_ip=${cfg.voiceIP} default_voice_port=${toString cfg.defaultVoicePort} \
|
||||||
|
filetransfer_ip=${cfg.fileTransferIP} filetransfer_port=${toString cfg.fileTransferPort} \
|
||||||
|
query_ip=${cfg.queryIP} query_port=${toString cfg.queryPort}
|
||||||
'';
|
'';
|
||||||
|
WorkingDirectory = cfg.dataDir;
|
||||||
serviceConfig = {
|
User = user;
|
||||||
ExecStart = ''
|
Group = group;
|
||||||
${ts3}/bin/ts3server \
|
PermissionsStartOnly = true;
|
||||||
dbsqlpath=${ts3}/lib/teamspeak/sql/ logpath=${cfg.logPath} \
|
|
||||||
voice_ip=${cfg.voiceIP} default_voice_port=${toString cfg.defaultVoicePort} \
|
|
||||||
filetransfer_ip=${cfg.fileTransferIP} filetransfer_port=${toString cfg.fileTransferPort} \
|
|
||||||
query_ip=${cfg.queryIP} query_port=${toString cfg.queryPort}
|
|
||||||
'';
|
|
||||||
WorkingDirectory = cfg.dataDir;
|
|
||||||
User = user;
|
|
||||||
Group = group;
|
|
||||||
PermissionsStartOnly = true;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
})
|
};
|
||||||
{
|
};
|
||||||
meta.maintainers = with lib.maintainers; [ arobyn ];
|
|
||||||
}
|
meta.maintainers = with lib.maintainers; [ arobyn ];
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,57 +111,54 @@ 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'';
|
});
|
||||||
});
|
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.wpa_supplicant ];
|
environment.systemPackages = [ pkgs.wpa_supplicant ];
|
||||||
|
|
||||||
services.dbus.packages = [ pkgs.wpa_supplicant ];
|
services.dbus.packages = [ pkgs.wpa_supplicant ];
|
||||||
|
|
||||||
# FIXME: start a separate wpa_supplicant instance per interface.
|
# FIXME: start a separate wpa_supplicant instance per interface.
|
||||||
systemd.services.wpa_supplicant = let
|
systemd.services.wpa_supplicant = let
|
||||||
ifaces = cfg.interfaces;
|
ifaces = cfg.interfaces;
|
||||||
deviceUnit = interface: [ "sys-subsystem-net-devices-${interface}.device" ];
|
deviceUnit = interface: [ "sys-subsystem-net-devices-${interface}.device" ];
|
||||||
in {
|
in {
|
||||||
description = "WPA Supplicant";
|
description = "WPA Supplicant";
|
||||||
|
|
||||||
after = [ "network-interfaces.target" ] ++ lib.concatMap deviceUnit ifaces;
|
after = [ "network-interfaces.target" ] ++ lib.concatMap deviceUnit ifaces;
|
||||||
requires = lib.concatMap deviceUnit ifaces;
|
requires = lib.concatMap deviceUnit ifaces;
|
||||||
wantedBy = [ "network.target" ];
|
wantedBy = [ "network.target" ];
|
||||||
|
|
||||||
path = [ pkgs.wpa_supplicant ];
|
path = [ pkgs.wpa_supplicant ];
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
${if ifaces == [] then ''
|
${if ifaces == [] then ''
|
||||||
for i in $(cd /sys/class/net && echo *); do
|
for i in $(cd /sys/class/net && echo *); do
|
||||||
DEVTYPE=
|
DEVTYPE=
|
||||||
source /sys/class/net/$i/uevent
|
source /sys/class/net/$i/uevent
|
||||||
if [ "$DEVTYPE" = "wlan" -o -e /sys/class/net/$i/wireless ]; then
|
if [ "$DEVTYPE" = "wlan" -o -e /sys/class/net/$i/wireless ]; then
|
||||||
ifaces="$ifaces''${ifaces:+ -N} -i$i"
|
ifaces="$ifaces''${ifaces:+ -N} -i$i"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
'' else ''
|
'' else ''
|
||||||
ifaces="${concatStringsSep " -N " (map (i: "-i${i}") ifaces)}"
|
ifaces="${concatStringsSep " -N " (map (i: "-i${i}") ifaces)}"
|
||||||
''}
|
''}
|
||||||
exec wpa_supplicant -s -u -D${cfg.driver} -c ${configFile} $ifaces
|
exec wpa_supplicant -s -u -D${cfg.driver} -c ${configFile} $ifaces
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
powerManagement.resumeCommands = ''
|
|
||||||
${config.systemd.package}/bin/systemctl try-restart wpa_supplicant
|
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
# Restart wpa_supplicant when a wlan device appears or disappears.
|
powerManagement.resumeCommands = ''
|
||||||
services.udev.extraRules = ''
|
${config.systemd.package}/bin/systemctl try-restart wpa_supplicant
|
||||||
ACTION=="add|remove", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", RUN+="${config.systemd.package}/bin/systemctl try-restart wpa_supplicant.service"
|
'';
|
||||||
'';
|
|
||||||
})
|
# Restart wpa_supplicant when a wlan device appears or disappears.
|
||||||
{
|
services.udev.extraRules = ''
|
||||||
meta.maintainers = with lib.maintainers; [ globin ];
|
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 ];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue