From 26ac1346609eeab7ca2ba7360a515604f36f221c Mon Sep 17 00:00:00 2001 From: Robin Raymond Date: Sat, 2 Sep 2017 13:58:42 +0200 Subject: [PATCH] make users into module --- default.nix | 7 +------ mail-server/users.nix | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/default.nix b/default.nix index 5b5e015..d570c52 100644 --- a/default.nix +++ b/default.nix @@ -249,6 +249,7 @@ in imports = [ ./mail-server/clamav.nix + ./mail-server/users.nix ]; config = mkIf cfg.enable { @@ -275,11 +276,5 @@ in hostPrefix domain dkimSelector dkimKeyDirectory; }; - users = import ./mail-server/users.nix { - inherit lib; - inherit (cfg) vmailUIDStart vmailUserName vmailGroupName domain - mailDirectory - loginAccounts; - }; }; } diff --git a/mail-server/users.nix b/mail-server/users.nix index cae2b83..a8cbcc9 100644 --- a/mail-server/users.nix +++ b/mail-server/users.nix @@ -14,8 +14,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see -{ lib, vmailUIDStart, vmailUserName, vmailGroupName, domain, mailDirectory, -loginAccounts }: +{ config, pkgs, lib, ... }: + +with config.mailserver; let vmail_user = [{ @@ -40,11 +41,14 @@ let in { - # set the vmail gid to a specific value - groups = { - vmail = { gid = vmailUIDStart; }; - }; - # define all users - extraUsers = vmail_user ++ mail_user; + config = lib.mkIf enable { + # set the vmail gid to a specific value + users.groups = { + vmail = { gid = vmailUIDStart; }; + }; + + # define all users + users.extraUsers = vmail_user ++ mail_user; + }; }