services.exim -> krebs.exim
This commit is contained in:
parent
f9d42f3a81
commit
96301634b9
@ -13,6 +13,7 @@ let
|
|||||||
./buildbot/slave.nix
|
./buildbot/slave.nix
|
||||||
./build.nix
|
./build.nix
|
||||||
./current.nix
|
./current.nix
|
||||||
|
./exim.nix
|
||||||
./exim-retiolum.nix
|
./exim-retiolum.nix
|
||||||
./exim-smarthost.nix
|
./exim-smarthost.nix
|
||||||
./fetchWallpaper.nix
|
./fetchWallpaper.nix
|
||||||
|
@ -1,111 +1,80 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }: with config.krebs.lib; let
|
||||||
|
cfg = config.krebs.exim;
|
||||||
let
|
in {
|
||||||
inherit (lib) mkIf mkOption singleton types;
|
options.krebs.exim = {
|
||||||
inherit (pkgs) coreutils exim;
|
enable = mkEnableOption "krebs.exim";
|
||||||
cfg = config.services.exim;
|
config = mkOption {
|
||||||
in
|
type = types.str;
|
||||||
|
default = "";
|
||||||
{
|
description = ''
|
||||||
|
Verbatim Exim configuration. This should not contain exim_user,
|
||||||
###### interface
|
exim_group, exim_path, or spool_directory.
|
||||||
|
'';
|
||||||
options = {
|
};
|
||||||
|
user = mkOption {
|
||||||
services.exim = {
|
type = types.user;
|
||||||
|
default = {
|
||||||
enable = mkOption {
|
name = "exim";
|
||||||
type = types.bool;
|
home = "/var/spool/exim";
|
||||||
default = false;
|
};
|
||||||
description = "Whether to enable the Exim mail transfer agent.";
|
description = ''
|
||||||
};
|
User to use when no root privileges are required.
|
||||||
|
In particular, this applies when receiving messages and when doing
|
||||||
config = mkOption {
|
remote deliveries. (Local deliveries run as various non-root users,
|
||||||
type = types.string;
|
typically as the owner of a local mailbox.) Specifying this value
|
||||||
default = "";
|
as root is not supported.
|
||||||
description = ''
|
'';
|
||||||
Verbatim Exim configuration. This should not contain exim_user,
|
};
|
||||||
exim_group, exim_path, or spool_directory.
|
group = mkOption {
|
||||||
'';
|
type = types.group;
|
||||||
};
|
default = {
|
||||||
|
name = "exim";
|
||||||
user = mkOption {
|
};
|
||||||
type = types.string;
|
description = ''
|
||||||
default = "exim";
|
Group to use when no root privileges are required.
|
||||||
description = ''
|
'';
|
||||||
User to use when no root privileges are required.
|
|
||||||
In particular, this applies when receiving messages and when doing
|
|
||||||
remote deliveries. (Local deliveries run as various non-root users,
|
|
||||||
typically as the owner of a local mailbox.) Specifying this value
|
|
||||||
as root is not supported.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
group = mkOption {
|
|
||||||
type = types.string;
|
|
||||||
default = "exim";
|
|
||||||
description = ''
|
|
||||||
Group to use when no root privileges are required.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
spoolDir = mkOption {
|
|
||||||
type = types.string;
|
|
||||||
default = "/var/spool/exim";
|
|
||||||
description = ''
|
|
||||||
Location of the spool directory of exim.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
|
||||||
###### implementation
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
etc."exim.conf".text = ''
|
etc."exim.conf".text = ''
|
||||||
exim_user = ${cfg.user}
|
exim_user = ${cfg.user.name}
|
||||||
exim_group = ${cfg.group}
|
exim_group = ${cfg.group.name}
|
||||||
exim_path = /var/setuid-wrappers/exim
|
exim_path = /var/setuid-wrappers/exim
|
||||||
spool_directory = ${cfg.spoolDir}
|
spool_directory = ${cfg.user.home}
|
||||||
${cfg.config}
|
${cfg.config}
|
||||||
'';
|
'';
|
||||||
systemPackages = [ exim ];
|
systemPackages = [ pkgs.exim ];
|
||||||
};
|
};
|
||||||
|
krebs.setuid = {
|
||||||
users.extraUsers = singleton {
|
exim = {
|
||||||
name = cfg.user;
|
filename = "${pkgs.exim}/bin/exim";
|
||||||
description = "Exim mail transfer agent user";
|
mode = "4111";
|
||||||
uid = config.ids.uids.exim;
|
};
|
||||||
group = cfg.group;
|
sendmail = {
|
||||||
};
|
filename = "${pkgs.exim}/bin/exim";
|
||||||
|
mode = "4111";
|
||||||
users.extraGroups = singleton {
|
};
|
||||||
name = cfg.group;
|
};
|
||||||
gid = config.ids.gids.exim;
|
systemd.services.exim = {
|
||||||
};
|
restartTriggers = [
|
||||||
|
config.environment.etc."exim.conf".source
|
||||||
security.setuidPrograms = [ "exim" ];
|
];
|
||||||
|
serviceConfig = {
|
||||||
systemd.services.exim = {
|
ExecStart = "${pkgs.exim}/bin/exim -bdf -q30m";
|
||||||
description = "Exim Mail Daemon";
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
||||||
wantedBy = [ "multi-user.target" ];
|
};
|
||||||
serviceConfig = {
|
wantedBy = [ "multi-user.target" ];
|
||||||
ExecStart = "${exim}/bin/exim -bdf -q30m";
|
};
|
||||||
ExecReload = "${coreutils}/bin/kill -HUP $MAINPID";
|
users = {
|
||||||
|
groups.${cfg.group.name} = {
|
||||||
|
inherit (cfg.group) name gid;
|
||||||
|
};
|
||||||
|
users.${cfg.user.name} = {
|
||||||
|
inherit (cfg.user) home name uid;
|
||||||
|
createHome = true;
|
||||||
|
group = cfg.group.name;
|
||||||
};
|
};
|
||||||
preStart = ''
|
|
||||||
if ! test -d ${cfg.spoolDir}; then
|
|
||||||
${coreutils}/bin/mkdir -p ${cfg.spoolDir}
|
|
||||||
${coreutils}/bin/chown ${cfg.user}:${cfg.group} ${cfg.spoolDir}
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user