Loading nixos/modules/services/web-apps/mastodon.nix +22 −5 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ let TRUSTED_PROXY_IP = cfg.trustedProxy; } // lib.optionalAttrs (cfg.redis.createLocally && cfg.redis.enableUnixSocket) { REDIS_URL = "unix://${config.services.redis.servers.mastodon.unixSocket}"; } // lib.optionalAttrs (cfg.database.host != "/run/postgresql" && cfg.database.port != null) { DB_PORT = toString cfg.database.port; } // lib.optionalAttrs cfg.smtp.authenticate { SMTP_LOGIN = cfg.smtp.user; } // lib.optionalAttrs (cfg.elasticsearch.host != null) { ES_HOST = cfg.elasticsearch.host; } Loading Loading @@ -116,9 +117,11 @@ let threads = toString (if processCfg.threads == null then cfg.sidekiqThreads else processCfg.threads); in { after = [ "network.target" "mastodon-init-dirs.service" ] ++ lib.optional cfg.redis.createLocally "redis-mastodon.service" ++ lib.optional databaseActuallyCreateLocally "postgresql.service" ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; requires = [ "mastodon-init-dirs.service" ] ++ lib.optional cfg.redis.createLocally "redis-mastodon.service" ++ lib.optional databaseActuallyCreateLocally "postgresql.service" ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; description = "Mastodon sidekiq${jobClassLabel}"; Loading Loading @@ -146,9 +149,11 @@ let name = "mastodon-streaming-${toString i}"; value = { after = [ "network.target" "mastodon-init-dirs.service" ] ++ lib.optional cfg.redis.createLocally "redis-mastodon.service" ++ lib.optional databaseActuallyCreateLocally "postgresql.service" ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; requires = [ "mastodon-init-dirs.service" ] ++ lib.optional cfg.redis.createLocally "redis-mastodon.service" ++ lib.optional databaseActuallyCreateLocally "postgresql.service" ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; wantedBy = [ "mastodon.target" "mastodon-streaming.target" ]; Loading Loading @@ -404,6 +409,12 @@ in { type = lib.types.port; default = 31637; }; enableUnixSocket = lib.mkOption { description = lib.mdDoc "Use Unix socket"; type = lib.types.bool; default = true; }; }; database = { Loading Loading @@ -751,9 +762,11 @@ in { systemd.services.mastodon-web = { after = [ "network.target" "mastodon-init-dirs.service" ] ++ lib.optional cfg.redis.createLocally "redis-mastodon.service" ++ lib.optional databaseActuallyCreateLocally "postgresql.service" ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; requires = [ "mastodon-init-dirs.service" ] ++ lib.optional cfg.redis.createLocally "redis-mastodon.service" ++ lib.optional databaseActuallyCreateLocally "postgresql.service" ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; wantedBy = [ "mastodon.target" ]; Loading Loading @@ -834,11 +847,14 @@ in { enable = true; hostname = lib.mkDefault "${cfg.localDomain}"; }; services.redis.servers.mastodon = lib.mkIf (cfg.redis.createLocally && cfg.redis.host == "127.0.0.1") { services.redis.servers.mastodon = lib.mkIf cfg.redis.createLocally (lib.mkMerge [ { enable = true; } (lib.mkIf (!cfg.redis.enableUnixSocket) { port = cfg.redis.port; bind = "127.0.0.1"; }; }) ]); services.postgresql = lib.mkIf databaseActuallyCreateLocally { enable = true; ensureUsers = [ Loading @@ -859,6 +875,7 @@ in { }; }) (lib.attrsets.setAttrByPath [ cfg.user "packages" ] [ cfg.package pkgs.imagemagick ]) (lib.mkIf (cfg.redis.createLocally && cfg.redis.enableUnixSocket) {${config.services.mastodon.user}.extraGroups = [ "redis-mastodon" ];}) ]; users.groups.${cfg.group}.members = lib.optional cfg.configureNginx config.services.nginx.user; Loading nixos/tests/web-apps/mastodon/standard.nix +0 −6 Original line number Diff line number Diff line Loading @@ -34,12 +34,6 @@ in pki.certificateFiles = [ "${cert pkgs}/cert.pem" ]; }; services.redis.servers.mastodon = { enable = true; bind = "127.0.0.1"; port = 31637; }; # TODO remove once https://github.com/NixOS/nixpkgs/pull/266270 is resolved. services.postgresql.package = pkgs.postgresql_14; Loading Loading
nixos/modules/services/web-apps/mastodon.nix +22 −5 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ let TRUSTED_PROXY_IP = cfg.trustedProxy; } // lib.optionalAttrs (cfg.redis.createLocally && cfg.redis.enableUnixSocket) { REDIS_URL = "unix://${config.services.redis.servers.mastodon.unixSocket}"; } // lib.optionalAttrs (cfg.database.host != "/run/postgresql" && cfg.database.port != null) { DB_PORT = toString cfg.database.port; } // lib.optionalAttrs cfg.smtp.authenticate { SMTP_LOGIN = cfg.smtp.user; } // lib.optionalAttrs (cfg.elasticsearch.host != null) { ES_HOST = cfg.elasticsearch.host; } Loading Loading @@ -116,9 +117,11 @@ let threads = toString (if processCfg.threads == null then cfg.sidekiqThreads else processCfg.threads); in { after = [ "network.target" "mastodon-init-dirs.service" ] ++ lib.optional cfg.redis.createLocally "redis-mastodon.service" ++ lib.optional databaseActuallyCreateLocally "postgresql.service" ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; requires = [ "mastodon-init-dirs.service" ] ++ lib.optional cfg.redis.createLocally "redis-mastodon.service" ++ lib.optional databaseActuallyCreateLocally "postgresql.service" ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; description = "Mastodon sidekiq${jobClassLabel}"; Loading Loading @@ -146,9 +149,11 @@ let name = "mastodon-streaming-${toString i}"; value = { after = [ "network.target" "mastodon-init-dirs.service" ] ++ lib.optional cfg.redis.createLocally "redis-mastodon.service" ++ lib.optional databaseActuallyCreateLocally "postgresql.service" ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; requires = [ "mastodon-init-dirs.service" ] ++ lib.optional cfg.redis.createLocally "redis-mastodon.service" ++ lib.optional databaseActuallyCreateLocally "postgresql.service" ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; wantedBy = [ "mastodon.target" "mastodon-streaming.target" ]; Loading Loading @@ -404,6 +409,12 @@ in { type = lib.types.port; default = 31637; }; enableUnixSocket = lib.mkOption { description = lib.mdDoc "Use Unix socket"; type = lib.types.bool; default = true; }; }; database = { Loading Loading @@ -751,9 +762,11 @@ in { systemd.services.mastodon-web = { after = [ "network.target" "mastodon-init-dirs.service" ] ++ lib.optional cfg.redis.createLocally "redis-mastodon.service" ++ lib.optional databaseActuallyCreateLocally "postgresql.service" ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; requires = [ "mastodon-init-dirs.service" ] ++ lib.optional cfg.redis.createLocally "redis-mastodon.service" ++ lib.optional databaseActuallyCreateLocally "postgresql.service" ++ lib.optional cfg.automaticMigrations "mastodon-init-db.service"; wantedBy = [ "mastodon.target" ]; Loading Loading @@ -834,11 +847,14 @@ in { enable = true; hostname = lib.mkDefault "${cfg.localDomain}"; }; services.redis.servers.mastodon = lib.mkIf (cfg.redis.createLocally && cfg.redis.host == "127.0.0.1") { services.redis.servers.mastodon = lib.mkIf cfg.redis.createLocally (lib.mkMerge [ { enable = true; } (lib.mkIf (!cfg.redis.enableUnixSocket) { port = cfg.redis.port; bind = "127.0.0.1"; }; }) ]); services.postgresql = lib.mkIf databaseActuallyCreateLocally { enable = true; ensureUsers = [ Loading @@ -859,6 +875,7 @@ in { }; }) (lib.attrsets.setAttrByPath [ cfg.user "packages" ] [ cfg.package pkgs.imagemagick ]) (lib.mkIf (cfg.redis.createLocally && cfg.redis.enableUnixSocket) {${config.services.mastodon.user}.extraGroups = [ "redis-mastodon" ];}) ]; users.groups.${cfg.group}.members = lib.optional cfg.configureNginx config.services.nginx.user; Loading
nixos/tests/web-apps/mastodon/standard.nix +0 −6 Original line number Diff line number Diff line Loading @@ -34,12 +34,6 @@ in pki.certificateFiles = [ "${cert pkgs}/cert.pem" ]; }; services.redis.servers.mastodon = { enable = true; bind = "127.0.0.1"; port = 31637; }; # TODO remove once https://github.com/NixOS/nixpkgs/pull/266270 is resolved. services.postgresql.package = pkgs.postgresql_14; Loading