Files
sp-config/sp-modules/simple-nixos-mailserver/common.nix

26 lines
740 B
Nix
Raw Normal View History

{ config, pkgs, ... }:
2024-12-20 18:41:07 +04:00
rec {
auth-passthru = config.passthru.selfprivacy.auth;
2024-12-20 18:41:07 +04:00
domain = config.selfprivacy.domain;
is-auth-enabled = config.selfprivacy.modules.auth.enable or false;
2024-12-20 18:41:07 +04:00
appendLdapBindPwd =
{ name, file, prefix, suffix ? "", passwordFile, destination }:
pkgs.writeScript "append-ldap-bind-pwd-in-${name}" ''
#!${pkgs.stdenv.shell}
set -euo pipefail
baseDir=$(dirname ${destination})
if (! test -d "$baseDir"); then
mkdir -p $baseDir
chmod 755 $baseDir
fi
cat ${file} > ${destination}
echo -n '${prefix}' >> ${destination}
cat ${passwordFile} >> ${destination}
echo -n '${suffix}' >> ${destination}
chmod 600 ${destination}
'';
}