2 description = "Open source ARC implementation";
5 url = "path:../myuids";
7 inputs.flake-utils.url = "github:numtide/flake-utils";
8 inputs.nixpkgs.url = "github:NixOS/nixpkgs";
10 outputs = { self, myuids, flake-utils, nixpkgs }: flake-utils.lib.eachSystem ["aarch64-linux" "i686-linux" "x86_64-linux"] (system:
12 pkgs = import nixpkgs { inherit system; overlays = []; };
14 packages.opendmarc = pkgs.callPackage ./. {};
15 defaultPackage = packages.opendmarc;
16 legacyPackages.opendmarc = packages.opendmarc;
17 apps.opendmarc = flake-utils.lib.mkApp { drv = packages.opendmarc; };
18 defaultApp = apps.opendmarc;
21 build = defaultPackage;
22 } // pkgs.lib.optionalAttrs (builtins.elem system pkgs.lib.systems.doubles.linux) {
24 let testing = import (nixpkgs + "/nixos/lib/testing-python.nix") { inherit system; };
27 server = { pkgs, ... }: {
28 imports = [ self.nixosModule ];
29 config.services.opendmarc.enable = true;
34 server.wait_for_unit("opendmarc.service")
35 server.succeed("[ -S /run/opendmarc/opendmarc.sock ]")
41 opendmarc = final: prev: {
42 opendmarc = self.defaultPackage."${final.system}";
45 overlay = overlays.opendmarc;
46 nixosModule = { config, lib, pkgs, ... }:
48 cfg = config.services.opendmarc;
49 defaultSock = "/run/opendmarc/opendmarc.sock";
50 args = [ "-f" "-l" "-p" "local:${cfg.socket}" ] ++ lib.optionals (cfg.configFile != null) [ "-c" cfg.configFile ];
52 # Necessary for situations where flake gets included multiple times
53 key = builtins.hashString "sha256" (builtins.path { path = self.sourceInfo.outPath; name = "source"; });
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;