clamav: Use freshclam.conf defined by clamav-updater module if enabled

+10 -6
+6 -5
nixos/modules/services/security/clamav.nix
··· 16 16 17 17 ${cfg.daemon.extraConfig} 18 18 ''; 19 + pkg = pkgs.clamav.override { freshclamConf = cfg.updater.config; }; 19 20 in 20 21 { 21 22 options = { ··· 54 55 }; 55 56 56 57 config = mkIf cfg.updater.enable or cfg.daemon.enable { 57 - environment.systemPackages = [ pkgs.clamav ]; 58 + environment.systemPackages = [ pkg ]; 58 59 users.extraUsers = singleton { 59 60 name = clamavUser; 60 61 uid = config.ids.uids.clamav; ··· 76 77 77 78 systemd.services.clamd = mkIf cfg.daemon.enable { 78 79 description = "ClamAV daemon (clamd)"; 79 - path = [ pkgs.clamav ]; 80 + path = [ pkg ]; 80 81 after = [ "network.target" "freshclam.service" ]; 81 82 requires = [ "freshclam.service" ]; 82 83 wantedBy = [ "multi-user.target" ]; ··· 87 88 chown ${clamavUser}:${clamavGroup} ${runDir} 88 89 ''; 89 90 serviceConfig = { 90 - ExecStart = "${pkgs.clamav}/bin/clamd --config-file=${clamdConfigFile}"; 91 + ExecStart = "${pkg}/bin/clamd --config-file=${clamdConfigFile}"; 91 92 Type = "forking"; 92 93 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 93 94 Restart = "on-failure"; ··· 100 101 description = "ClamAV updater (freshclam)"; 101 102 after = [ "network.target" ]; 102 103 wantedBy = [ "multi-user.target" ]; 103 - path = [ pkgs.clamav ]; 104 + path = [ pkg ]; 104 105 preStart = '' 105 106 mkdir -m 0755 -p ${stateDir} 106 107 chown ${clamavUser}:${clamavGroup} ${stateDir} 107 108 ''; 108 109 serviceConfig = { 109 - ExecStart = "${pkgs.clamav}/bin/freshclam --daemon --config-file=${pkgs.writeText "freshclam.conf" cfg.updater.config}"; 110 + ExecStart = "${pkg}/bin/freshclam --daemon --config-file=${pkgs.writeText "freshclam.conf" cfg.updater.config}"; 110 111 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 111 112 Restart = "on-failure"; 112 113 RestartSec = "10s";
+4 -1
pkgs/tools/security/clamav/default.nix
··· 1 1 { stdenv, fetchurl, zlib, bzip2, libiconv, libxml2, openssl, ncurses, curl 2 - , libmilter, pcre }: 2 + , libmilter, pcre, freshclamConf ? null }: 3 + 3 4 stdenv.mkDerivation rec { 4 5 name = "clamav-${version}"; 5 6 version = "0.99"; ··· 23 24 "--enable-milter" 24 25 "--disable-clamav" 25 26 ]; 27 + 28 + fixupPhase = if (freshclamConf != null) then ''echo "${freshclamConf}" > $out/etc/freshclam.conf'' else ""; 26 29 27 30 meta = with stdenv.lib; { 28 31 homepage = http://www.clamav.net;