2 description = "Open source ARC implementation";
5 url = "https://git.immae.eu/perso/Immae/Config/Nix.git";
9 inputs.flake-utils.url = "github:numtide/flake-utils";
10 inputs.nixpkgs.url = "github:NixOS/nixpkgs";
12 outputs = { self, myuids, flake-utils, nixpkgs }: flake-utils.lib.eachSystem ["aarch64-linux" "i686-linux" "x86_64-linux"] (system:
14 pkgs = import nixpkgs { inherit system; overlays = []; };
16 packages.opendmarc = pkgs.callPackage ./. {};
17 defaultPackage = packages.opendmarc;
18 legacyPackages.opendmarc = packages.opendmarc;
19 apps.opendmarc = flake-utils.lib.mkApp { drv = packages.opendmarc; };
20 defaultApp = apps.opendmarc;
23 build = defaultPackage;
24 } // pkgs.lib.optionalAttrs (builtins.elem system pkgs.lib.systems.doubles.linux) {
26 let testing = import (nixpkgs + "/nixos/lib/testing-python.nix") { inherit system; };
29 server = { pkgs, ... }: {
30 imports = [ self.nixosModule ];
31 config.services.opendmarc.enable = true;
36 server.wait_for_unit("opendmarc.service")
37 server.succeed("[ -S /run/opendmarc/opendmarc.sock ]")
43 opendmarc = final: prev: {
44 opendmarc = self.defaultPackage."${final.system}";
47 overlay = overlays.opendmarc;
48 nixosModule = { config, lib, pkgs, ... }:
50 cfg = config.services.opendmarc;
51 defaultSock = "/run/opendmarc/opendmarc.sock";
52 args = [ "-f" "-l" "-p" "local:${cfg.socket}" ] ++ lib.optionals (cfg.configFile != null) [ "-c" cfg.configFile ];
55 services.opendmarc = {
56 enable = lib.mkOption {
57 type = lib.types.bool;
59 description = "Whether to enable the OpenDMARC sender authentication system.";
62 socket = lib.mkOption {
64 default = defaultSock;
65 description = "Socket which is used for communication with OpenDMARC.";
70 default = "opendmarc";
71 description = "User for the daemon.";
74 group = lib.mkOption {
76 default = "opendmarc";
77 description = "Group for the daemon.";
80 configFile = lib.mkOption {
81 type = lib.types.nullOr lib.types.path;
83 description = "Additional OpenDMARC configuration.";
89 config = lib.mkIf cfg.enable {
90 nixpkgs.overlays = [ self.overlay ];
91 users.users = lib.optionalAttrs (cfg.user == "opendmarc") {
94 uid = myuids.lib.uids.opendmarc;
98 users.groups = lib.optionalAttrs (cfg.group == "opendmarc") {
99 opendmarc.gid = myuids.lib.gids.opendmarc;
102 environment.systemPackages = [ pkgs.opendmarc ];
104 systemd.services.opendmarc = {
105 description = "OpenDMARC daemon";
106 after = [ "network.target" ];
107 wantedBy = [ "multi-user.target" ];
110 ExecStart = "${self.defaultApp."${pkgs.system}".program} ${lib.escapeShellArgs args}";
113 RuntimeDirectory = lib.optional (cfg.socket == defaultSock) "opendmarc";
114 PermissionsStartOnly = true;