Use nixpkgs functions to check dovecot version

This commit is contained in:
Brian Olsen 2018-05-13 03:17:22 +02:00 committed by Ruben Maher
parent 1c76e0a119
commit 410c6c410b
3 changed files with 3 additions and 21 deletions

View file

@ -1,12 +0,0 @@
{ dovecot, gawk, gnused, jq, runCommand }:
runCommand "dovecot-version" {
buildInputs = [dovecot gnused jq];
} ''
jq -n \
--arg dovecot_version "$(dovecot --version |
sed 's/\([0-9.]*\).*/\1/' |
awk -F '.' '{ print $1"."$2"."$3 }')" \
'[$dovecot_version | split("."), ["major", "minor", "patch"]]
| transpose | map( { (.[1]): .[0] | tonumber }) | add' > $out
''

View file

@ -23,9 +23,6 @@ let
maildirLayoutAppendix = lib.optionalString cfg.useFsLayout ":LAYOUT=fs"; maildirLayoutAppendix = lib.optionalString cfg.useFsLayout ":LAYOUT=fs";
dovecotVersion = builtins.fromJSON
(builtins.readFile (pkgs.callPackage ./dovecot-version.nix {}));
# maildir in format "/${domain}/${user}" # maildir in format "/${domain}/${user}"
dovecotMaildir = "maildir:${cfg.mailDirectory}/%d/%n${maildirLayoutAppendix}"; dovecotMaildir = "maildir:${cfg.mailDirectory}/%d/%n${maildirLayoutAppendix}";
@ -79,7 +76,7 @@ in
mail_access_groups = ${vmailGroupName} mail_access_groups = ${vmailGroupName}
ssl = required ssl = required
${lib.optionalString (dovecotVersion.major == 2 && dovecotVersion.minor >= 3) '' ${lib.optionalString (lib.versionAtLeast (lib.getVersion pkgs.dovecot) "2.3") ''
ssl_dh = <${certificateDirectory}/dh.pem ssl_dh = <${certificateDirectory}/dh.pem
''} ''}

View file

@ -19,11 +19,8 @@
let let
cfg = config.mailserver; cfg = config.mailserver;
createDhParameterFile = let createDhParameterFile =
dovecotVersion = builtins.fromJSON lib.optionalString (lib.versionAtLeast (lib.getVersion pkgs.dovecot) "2.3")
(builtins.readFile (pkgs.callPackage ./dovecot-version.nix {}));
in lib.optionalString
(dovecotVersion.major == 2 && dovecotVersion.minor >= 3)
'' ''
# Create a dh parameter file # Create a dh parameter file
if [ ! -s "${cfg.certificateDirectory}/dh.pem" ] if [ ! -s "${cfg.certificateDirectory}/dh.pem" ]