fix conditions for enabling services
Without this fix, kresd and others would get enabled even though the main mailserver option is disabled.
This commit is contained in:
parent
68232ddf87
commit
845e06e61a
7 changed files with 11 additions and 11 deletions
|
@ -19,7 +19,7 @@
|
||||||
let
|
let
|
||||||
cfg = config.mailserver.borgbackup;
|
cfg = config.mailserver.borgbackup;
|
||||||
|
|
||||||
methodFragment = lib.optional (cfg.compression.method != null) cfg.compression.method;
|
methodFragment = lib.optional (cfg.compression.method != null) cfg.compression.method;
|
||||||
autoFragment =
|
autoFragment =
|
||||||
if cfg.compression.auto && cfg.compression.method == null
|
if cfg.compression.auto && cfg.compression.method == null
|
||||||
then throw "compression.method must be set when using auto."
|
then throw "compression.method must be set when using auto."
|
||||||
|
@ -56,7 +56,7 @@ let
|
||||||
${cmdPostexec}
|
${cmdPostexec}
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
config = lib.mkIf config.mailserver.borgbackup.enable {
|
config = lib.mkIf (config.mailserver.enable && cfg.enable) {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
borgbackup
|
borgbackup
|
||||||
];
|
];
|
||||||
|
|
|
@ -20,7 +20,7 @@ let
|
||||||
cfg = config.mailserver;
|
cfg = config.mailserver;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf cfg.virusScanning {
|
config = lib.mkIf (cfg.enable && cfg.virusScanning) {
|
||||||
services.clamav.daemon.enable = true;
|
services.clamav.daemon.enable = true;
|
||||||
services.clamav.updater.enable = true;
|
services.clamav.updater.enable = true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@ let
|
||||||
cfg = config.mailserver;
|
cfg = config.mailserver;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf cfg.localDnsResolver {
|
config = lib.mkIf (cfg.enable && cfg.localDnsResolver) {
|
||||||
services.kresd.enable = true;
|
services.kresd.enable = true;
|
||||||
networking.nameservers = [ "127.0.0.1" ];
|
networking.nameservers = [ "127.0.0.1" ];
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@ let
|
||||||
cfg = config.mailserver;
|
cfg = config.mailserver;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf cfg.monitoring.enable {
|
config = lib.mkIf (cfg.enable && cfg.monitoring.enable) {
|
||||||
services.monit = {
|
services.monit = {
|
||||||
enable = true;
|
enable = true;
|
||||||
config = ''
|
config = ''
|
||||||
|
|
|
@ -24,7 +24,7 @@ let
|
||||||
acmeRoot = "/var/lib/acme/acme-challenge";
|
acmeRoot = "/var/lib/acme/acme-challenge";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf (cfg.certificateScheme == 3) {
|
config = lib.mkIf (cfg.enable && cfg.certificateScheme == 3) {
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
virtualHosts."${cfg.fqdn}" = {
|
virtualHosts."${cfg.fqdn}" = {
|
||||||
|
|
|
@ -22,17 +22,17 @@ let
|
||||||
cfg = config.mailserver;
|
cfg = config.mailserver;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = mkIf cfg.rebootAfterKernelUpgrade.enable {
|
config = mkIf (cfg.enable && cfg.rebootAfterKernelUpgrade.enable) {
|
||||||
systemd.services.nixos-upgrade.serviceConfig.ExecStartPost = pkgs.writeScript "post-upgrade-check" ''
|
systemd.services.nixos-upgrade.serviceConfig.ExecStartPost = pkgs.writeScript "post-upgrade-check" ''
|
||||||
#!${pkgs.stdenv.shell}
|
#!${pkgs.stdenv.shell}
|
||||||
|
|
||||||
# Checks whether the "current" kernel is different from the booted kernel
|
# Checks whether the "current" kernel is different from the booted kernel
|
||||||
# and then triggers a reboot so that the "current" kernel will be the booted one.
|
# and then triggers a reboot so that the "current" kernel will be the booted one.
|
||||||
# This is just an educated guess. If the links do not differ the kernels might still be different, according to spacefrogg in #nixos.
|
# This is just an educated guess. If the links do not differ the kernels might still be different, according to spacefrogg in #nixos.
|
||||||
|
|
||||||
current=$(readlink -f /run/current-system/kernel)
|
current=$(readlink -f /run/current-system/kernel)
|
||||||
booted=$(readlink -f /run/booted-system/kernel)
|
booted=$(readlink -f /run/booted-system/kernel)
|
||||||
|
|
||||||
if [ "$current" == "$booted" ]; then
|
if [ "$current" == "$booted" ]; then
|
||||||
echo "kernel version seems unchanged, skipping reboot" | systemd-cat --priority 4 --identifier "post-upgrade-check";
|
echo "kernel version seems unchanged, skipping reboot" | systemd-cat --priority 4 --identifier "post-upgrade-check";
|
||||||
else
|
else
|
||||||
|
|
|
@ -39,7 +39,7 @@ let
|
||||||
'';
|
'';
|
||||||
postexecString = optionalString postexecDefined "cmd_postexec ${postexecWrapped}";
|
postexecString = optionalString postexecDefined "cmd_postexec ${postexecWrapped}";
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.backup.enable {
|
config = mkIf (cfg.enable && cfg.backup.enable) {
|
||||||
services.rsnapshot = {
|
services.rsnapshot = {
|
||||||
enable = true;
|
enable = true;
|
||||||
cronIntervals = cfg.backup.cronIntervals;
|
cronIntervals = cfg.backup.cronIntervals;
|
||||||
|
|
Loading…
Reference in a new issue