nixos: only enable spipe when user specifies
Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
parent
33eced411f
commit
b470c93c1e
@ -7,7 +7,14 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
services.spiped = mkOption {
|
services.spiped = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable the spiped service module.";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkOption {
|
||||||
type = types.attrsOf (types.submodule (
|
type = types.attrsOf (types.submodule (
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
@ -156,12 +163,13 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = {
|
config = mkIf cfg.enable {
|
||||||
assertions = mapAttrsToList (name: c: {
|
assertions = mapAttrsToList (name: c: {
|
||||||
assertion = (c.encrypt -> !c.decrypt) || (c.decrypt -> c.encrypt);
|
assertion = (c.encrypt -> !c.decrypt) || (c.decrypt -> c.encrypt);
|
||||||
message = "A pipe must either encrypt or decrypt";
|
message = "A pipe must either encrypt or decrypt";
|
||||||
}) cfg;
|
}) cfg.config;
|
||||||
|
|
||||||
users.extraGroups.spiped.gid = config.ids.gids.spiped;
|
users.extraGroups.spiped.gid = config.ids.gids.spiped;
|
||||||
users.extraUsers.spiped = {
|
users.extraUsers.spiped = {
|
||||||
@ -189,7 +197,7 @@ in
|
|||||||
script = "exec ${pkgs.spiped}/bin/spiped -F `cat /etc/spiped/$1.spec`";
|
script = "exec ${pkgs.spiped}/bin/spiped -F `cat /etc/spiped/$1.spec`";
|
||||||
};
|
};
|
||||||
|
|
||||||
system.activationScripts.spiped = optionalString (cfg != {})
|
system.activationScripts.spiped = optionalString (cfg.config != {})
|
||||||
"mkdir -p /var/lib/spiped";
|
"mkdir -p /var/lib/spiped";
|
||||||
|
|
||||||
# Setup spiped config files
|
# Setup spiped config files
|
||||||
@ -207,6 +215,6 @@ in
|
|||||||
(if cfg.disableReresolution then "-R"
|
(if cfg.disableReresolution then "-R"
|
||||||
else "-r ${toString cfg.resolveRefresh}")
|
else "-r ${toString cfg.resolveRefresh}")
|
||||||
];
|
];
|
||||||
}) cfg;
|
}) cfg.config;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user