diff --git a/mail-server/dovecot-version.nix b/mail-server/dovecot-version.nix deleted file mode 100644 index 4c00972..0000000 --- a/mail-server/dovecot-version.nix +++ /dev/null @@ -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 -'' diff --git a/mail-server/dovecot.nix b/mail-server/dovecot.nix index bb85c21..604a62e 100644 --- a/mail-server/dovecot.nix +++ b/mail-server/dovecot.nix @@ -23,9 +23,6 @@ let maildirLayoutAppendix = lib.optionalString cfg.useFsLayout ":LAYOUT=fs"; - dovecotVersion = builtins.fromJSON - (builtins.readFile (pkgs.callPackage ./dovecot-version.nix {})); - # maildir in format "/${domain}/${user}" dovecotMaildir = "maildir:${cfg.mailDirectory}/%d/%n${maildirLayoutAppendix}"; @@ -79,7 +76,7 @@ in mail_access_groups = ${vmailGroupName} 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 ''} diff --git a/mail-server/systemd.nix b/mail-server/systemd.nix index 9567a98..3bc78bf 100644 --- a/mail-server/systemd.nix +++ b/mail-server/systemd.nix @@ -19,11 +19,8 @@ let cfg = config.mailserver; - createDhParameterFile = let - dovecotVersion = builtins.fromJSON - (builtins.readFile (pkgs.callPackage ./dovecot-version.nix {})); - in lib.optionalString - (dovecotVersion.major == 2 && dovecotVersion.minor >= 3) + createDhParameterFile = + lib.optionalString (lib.versionAtLeast (lib.getVersion pkgs.dovecot) "2.3") '' # Create a dh parameter file if [ ! -s "${cfg.certificateDirectory}/dh.pem" ]