Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/mastodon: remove pin for postgresql version #335768

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nixos/modules/services/web-apps/mastodon.nix
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ in {
'' + lib.optionalString (!databaseActuallyCreateLocally) ''
unset PGPASSWORD
'';
path = [ cfg.package pkgs.postgresql ];
path = [ cfg.package config.services.postgresql.package ];
environment = env // lib.optionalAttrs (!databaseActuallyCreateLocally) {
PGHOST = cfg.database.host;
PGPORT = toString cfg.database.port;
Expand Down
34 changes: 17 additions & 17 deletions nixos/tests/web-apps/mastodon/remote-databases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ let
192.168.2.103 mastodon.local
'';

postgresqlPassword = "thisisnotasecret";
redisPassword = "thisisnotasecrettoo";

in
{
name = "mastodon-remote-postgresql";
Expand All @@ -19,9 +22,7 @@ in
databases = { config, ... }: {
environment = {
etc = {
"redis/password-redis-db".text = ''
ogjhJL8ynrP7MazjYOF6
'';
"redis/password-redis-db".text = redisPassword;
};
};
networking = {
Expand All @@ -46,16 +47,19 @@ in

services.postgresql = {
enable = true;
# TODO remove once https://github.com/NixOS/nixpkgs/pull/266270 is resolved.
package = pkgs.postgresql_14;
enableTCPIP = true;
authentication = ''
hostnossl mastodon_local mastodon_test 192.168.2.201/32 md5
hostnossl mastodon mastodon 192.168.2.201/32 md5
'';
ensureDatabases = [ "mastodon" ];
ensureUsers = [
{
name = "mastodon";
ensureDBOwnership = true;
}
];
initialScript = pkgs.writeText "postgresql_init.sql" ''
CREATE ROLE mastodon_test LOGIN PASSWORD 'SoDTZcISc3f1M1LJsRLT';
CREATE DATABASE mastodon_local TEMPLATE template0 ENCODING UTF8;
GRANT ALL PRIVILEGES ON DATABASE mastodon_local TO mastodon_test;
CREATE ROLE mastodon LOGIN PASSWORD '${postgresqlPassword}';
'';
};
};
Expand Down Expand Up @@ -100,12 +104,8 @@ in

environment = {
etc = {
"mastodon/password-redis-db".text = ''
ogjhJL8ynrP7MazjYOF6
'';
"mastodon/password-posgressql-db".text = ''
SoDTZcISc3f1M1LJsRLT
'';
"mastodon/password-redis-db".text = redisPassword;
"mastodon/password-posgressql-db".text = postgresqlPassword;
};
};

Expand Down Expand Up @@ -138,8 +138,8 @@ in
createLocally = false;
host = "192.168.2.102";
port = 5432;
name = "mastodon_local";
user = "mastodon_test";
name = "mastodon";
user = "mastodon";
passwordFile = "/etc/mastodon/password-posgressql-db";
};
smtp = {
Expand Down
3 changes: 0 additions & 3 deletions nixos/tests/web-apps/mastodon/standard.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ in
pki.certificateFiles = [ "${cert pkgs}/cert.pem" ];
};

# TODO remove once https://github.com/NixOS/nixpkgs/pull/266270 is resolved.
services.postgresql.package = pkgs.postgresql_14;

services.mastodon = {
enable = true;
configureNginx = true;
Expand Down