Commit 93de6bf9 authored by Izorkin's avatar Izorkin Committed by Manuel Bärenz
Browse files

nixos/mastodon: add smtp assertions

parent 33db1dc0
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -372,17 +372,19 @@ in {
        };

        user = lib.mkOption {
          type = lib.types.nullOr lib.types.str;
          default = null;
          example = "mastodon@example.com";
          description = lib.mdDoc "SMTP login name.";
          type = lib.types.str;
        };

        passwordFile = lib.mkOption {
          type = lib.types.nullOr lib.types.path;
          default = null;
          example = "/var/lib/mastodon/secrets/smtp-password";
          description = lib.mdDoc ''
            Path to file containing the SMTP password.
          '';
          default = "/var/lib/mastodon/secrets/smtp-password";
          example = "/run/keys/mastodon-smtp-password";
          type = lib.types.str;
        };
      };

@@ -467,6 +469,20 @@ in {
        assertion = databaseActuallyCreateLocally -> (cfg.user == cfg.database.user);
        message = ''For local automatic database provisioning (services.mastodon.database.createLocally == true) with peer authentication (services.mastodon.database.host == "/run/postgresql") to work services.mastodon.user and services.mastodon.database.user must be identical.'';
      }
      {
        assertion = cfg.smtp.authenticate -> (cfg.smtp.user != null);
        message = ''
          <option>services.mastodon.smtp.user</option> needs to be set if
            <option>services.mastodon.smtp.authenticate</option> is enabled.
        '';
      }
      {
        assertion = cfg.smtp.authenticate -> (cfg.smtp.passwordFile != null);
        message = ''
          <option>services.mastodon.smtp.passwordFile</option> needs to be set if
            <option>services.mastodon.smtp.authenticate</option> is enabled.
        '';
      }
    ];

    systemd.services.mastodon-init-dirs = {