2 description = "Open source ARC implementation";
5 url = "https://git.immae.eu/perso/Immae/Config/Nix.git";
10 url = "https://git.immae.eu/perso/Immae/Config/Nix.git";
12 dir = "flakes/libspf2";
14 inputs.flake-utils.url = "github:numtide/flake-utils";
15 inputs.nixpkgs.url = "github:NixOS/nixpkgs";
17 outputs = { self, myuids, libspf2, flake-utils, nixpkgs }: flake-utils.lib.eachSystem ["aarch64-linux" "i686-linux" "x86_64-linux"] (system:
19 libspf2' = libspf2.defaultPackage."${system}";
20 pkgs = import nixpkgs { inherit system; overlays = []; };
21 inherit (pkgs) fetchurl stdenv libbsd perl openssl libmilter file libnsl;
23 packages.opendmarc = stdenv.mkDerivation rec {
28 url = "mirror://sourceforge/opendmarc/files/${pname}-${version}.tar.gz";
29 sha256 = "1yrggj8yq0915y2i34gfz2xpl1w2lgb1vggp67rwspgzm40lng11";
34 "--with-spf2-include=${libspf2'}/include/spf2"
35 "--with-spf2-lib=${libspf2'}/lib/"
36 "--with-milter=${libmilter}"
39 buildInputs = [ libspf2' libbsd openssl libmilter perl libnsl ];
42 description = "Free open source software implementation of the DMARC specification";
43 homepage = "http://www.trusteddomain.org/opendmarc/";
44 platforms = stdenv.lib.platforms.unix;
48 defaultPackage = packages.opendmarc;
49 legacyPackages.opendmarc = packages.opendmarc;
50 apps.opendmarc = flake-utils.lib.mkApp { drv = packages.opendmarc; };
51 defaultApp = apps.opendmarc;
54 build = defaultPackage;
55 } // pkgs.lib.optionalAttrs (builtins.elem system pkgs.lib.systems.doubles.linux) {
57 let testing = import (nixpkgs + "/nixos/lib/testing-python.nix") { inherit system; };
60 server = { pkgs, ... }: {
61 imports = [ self.nixosModule ];
62 config.services.opendmarc.enable = true;
67 server.wait_for_unit("opendmarc.service")
68 server.succeed("[ -S /run/opendmarc/opendmarc.sock ]")
73 nixosModule = { config, lib, pkgs, ... }:
75 cfg = config.services.opendmarc;
76 defaultSock = "local:/run/opendmarc/opendmarc.sock";
77 args = [ "-f" "-l" "-p" cfg.socket ] ++ lib.optionals (cfg.configFile != null) [ "-c" cfg.configFile ];
80 services.opendmarc = {
81 enable = lib.mkOption {
82 type = lib.types.bool;
84 description = "Whether to enable the OpenDMARC sender authentication system.";
87 socket = lib.mkOption {
89 default = defaultSock;
90 description = "Socket which is used for communication with OpenDMARC.";
95 default = "opendmarc";
96 description = "User for the daemon.";
99 group = lib.mkOption {
100 type = lib.types.str;
101 default = "opendmarc";
102 description = "Group for the daemon.";
105 configFile = lib.mkOption {
106 type = lib.types.nullOr lib.types.path;
108 description = "Additional OpenDMARC configuration.";
114 config = lib.mkIf cfg.enable {
115 users.users = lib.optionalAttrs (cfg.user == "opendmarc") {
118 uid = myuids.lib.uids.opendmarc;
122 users.groups = lib.optionalAttrs (cfg.group == "opendmarc") {
123 opendmarc.gid = myuids.lib.gids.opendmarc;
126 environment.systemPackages = [ self.defaultPackage."${pkgs.system}" ];
128 systemd.services.opendmarc = {
129 description = "OpenDMARC daemon";
130 after = [ "network.target" ];
131 wantedBy = [ "multi-user.target" ];
134 ExecStart = "${self.defaultApp."${pkgs.system}".program} ${lib.escapeShellArgs args}";
137 RuntimeDirectory = lib.optional (cfg.socket == defaultSock) "opendmarc";
138 PermissionsStartOnly = true;