Merge pull request #76 from eqyiel/detect-dovecot-version

dovecot: read dovecot version into nix variable
This commit is contained in:
Robin Raymond 2018-02-17 16:03:58 +01:00 committed by GitHub
commit e2eaa48b40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 14 deletions

View file

@ -325,16 +325,6 @@ in
'';
};
dovecot23 = mkOption {
type = types.bool;
default = false;
description =
''
Activate this if you use Dovecot 2.3, so SSL works.
TODO: Remove this!
'';
};
dhParamBitLength = mkOption {
type = types.int;
default = 2048;

View file

@ -0,0 +1,12 @@
{ 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

@ -24,6 +24,8 @@ let
# maildir in format "/${domain}/${user}"
dovecot_maildir = "maildir:${cfg.mailDirectory}/%d/%n";
dovecotVersion = builtins.fromJSON
(builtins.readFile (pkgs.callPackage ./dovecot-version.nix {}));
in
{
config = with cfg; lib.mkIf enable {
@ -61,7 +63,9 @@ in
mail_access_groups = ${vmailGroupName}
ssl = required
${lib.optionalString dovecot23 "ssl_dh = <${certificateDirectory}/dh.pem"}
${lib.optionalString (dovecotVersion.major == 2 && dovecotVersion.minor >= 3) ''
ssl_dh = <${certificateDirectory}/dh.pem
''}
service lmtp {
unix_listener /var/lib/postfix/queue/private/dovecot-lmtp {

View file

@ -91,7 +91,12 @@ in
${create_certificate}
${lib.optionalString cfg.dovecot23 "${createDhParameterFile}"}
${let
dovecotVersion = builtins.fromJSON
(builtins.readFile (pkgs.callPackage ./dovecot-version.nix {}));
in lib.optionalString
(dovecotVersion.major == 2 && dovecotVersion.minor >= 3)
createDhParameterFile}
'';
};

View file

@ -28,7 +28,6 @@ import <nixpkgs/nixos/tests/make-test.nix> {
fqdn = "mail.example.com";
domains = [ "example.com" "example2.com" ];
dhParamBitLength = 512;
dovecot23 = true;
loginAccounts = {
"user1@example.com" = {

View file

@ -28,7 +28,6 @@ import <nixpkgs/nixos/tests/make-test.nix> {
fqdn = "mail.example.com";
domains = [ "example.com" ];
dhParamBitLength = 512;
dovecot23 = true;
loginAccounts = {
"user1@example.com" = {