move from real users to passwd file
This commit is contained in:
parent
4fc8a1ed05
commit
2d0648e0f4
|
@ -14,10 +14,14 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
# along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
{ config }:
|
{ config, lib }:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.mailserver;
|
cfg = config.mailserver;
|
||||||
|
# passwd :: [ String ]
|
||||||
|
passwd = lib.mapAttrsToList
|
||||||
|
(name: value: "${name}:${value.hashedPassword}:${builtins.toString cfg.vmailUID}:${builtins.toString cfg.vmailUID}::${cfg.mailDirectory}:/run/current-system/sw/bin/nologin:")
|
||||||
|
cfg.loginAccounts;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# cert :: PATH
|
# cert :: PATH
|
||||||
|
@ -37,4 +41,6 @@ in
|
||||||
else if cfg.certificateScheme == 3
|
else if cfg.certificateScheme == 3
|
||||||
then "/var/lib/acme/${cfg.fqdn}/key.pem"
|
then "/var/lib/acme/${cfg.fqdn}/key.pem"
|
||||||
else throw "Error: Certificate Scheme must be in { 1, 2, 3 }";
|
else throw "Error: Certificate Scheme must be in { 1, 2, 3 }";
|
||||||
|
# passwdFile :: PATH
|
||||||
|
passwdFile = builtins.toFile "passwd" (lib.concatStringsSep "\n" passwd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
with (import ./common.nix { inherit config; });
|
with (import ./common.nix { inherit config lib; });
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.mailserver;
|
cfg = config.mailserver;
|
||||||
|
@ -31,6 +31,7 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
enableImap = enableImap;
|
enableImap = enableImap;
|
||||||
enablePop3 = enablePop3;
|
enablePop3 = enablePop3;
|
||||||
|
enablePAM = false;
|
||||||
mailGroup = vmailGroupName;
|
mailGroup = vmailGroupName;
|
||||||
mailUser = vmailUserName;
|
mailUser = vmailUserName;
|
||||||
mailLocation = dovecot_maildir;
|
mailLocation = dovecot_maildir;
|
||||||
|
@ -74,6 +75,11 @@ in
|
||||||
mail_plugins = $mail_plugins sieve
|
mail_plugins = $mail_plugins sieve
|
||||||
}
|
}
|
||||||
|
|
||||||
|
passdb {
|
||||||
|
driver = passwd-file
|
||||||
|
args = ${passwdFile}
|
||||||
|
}
|
||||||
|
|
||||||
service auth {
|
service auth {
|
||||||
unix_listener /var/lib/postfix/queue/private/auth {
|
unix_listener /var/lib/postfix/queue/private/auth {
|
||||||
mode = 0660
|
mode = 0660
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
with (import ./common.nix { inherit config; });
|
with (import ./common.nix { inherit config lib; });
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib.strings) concatStringsSep;
|
inherit (lib.strings) concatStringsSep;
|
||||||
|
|
|
@ -28,16 +28,6 @@ let
|
||||||
group = vmailGroupName;
|
group = vmailGroupName;
|
||||||
};
|
};
|
||||||
|
|
||||||
# accountsToUser :: String -> UserRecord
|
|
||||||
accountsToUser = account: {
|
|
||||||
isNormalUser = false;
|
|
||||||
group = vmailGroupName;
|
|
||||||
inherit (account) hashedPassword name;
|
|
||||||
};
|
|
||||||
|
|
||||||
# mail_users :: { [String]: UserRecord }
|
|
||||||
mail_users = lib.foldl (prev: next: prev // { "${next.name}" = next; }) {}
|
|
||||||
(map accountsToUser (lib.attrValues loginAccounts));
|
|
||||||
|
|
||||||
virtualMailUsersActivationScript = pkgs.writeScript "activate-virtual-mail-users" ''
|
virtualMailUsersActivationScript = pkgs.writeScript "activate-virtual-mail-users" ''
|
||||||
#!${pkgs.stdenv.shell}
|
#!${pkgs.stdenv.shell}
|
||||||
|
@ -77,7 +67,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
# define all users
|
# define all users
|
||||||
users.users = mail_users // {
|
users.users = {
|
||||||
"${vmail_user.name}" = lib.mkForce vmail_user;
|
"${vmail_user.name}" = lib.mkForce vmail_user;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue