2022-08-26 10:21:05 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
2021-11-15 10:02:05 +00:00
|
|
|
let
|
|
|
|
cfg = config.services.userdata;
|
|
|
|
in
|
|
|
|
{
|
2022-08-26 10:21:05 +00:00
|
|
|
fileSystems = lib.mkIf cfg.useBinds {
|
|
|
|
"/var/lib/pleroma" = {
|
|
|
|
device = "/volumes/${cfg.pleroma.location}/pleroma";
|
|
|
|
options = [ "bind" ];
|
|
|
|
};
|
|
|
|
"/var/lib/postgresql" = {
|
|
|
|
device = "/volumes/${cfg.pleroma.location}/postgresql";
|
|
|
|
options = [ "bind" ];
|
|
|
|
};
|
|
|
|
};
|
2021-11-15 10:02:05 +00:00
|
|
|
services = {
|
|
|
|
pleroma = {
|
|
|
|
enable = cfg.pleroma.enable;
|
|
|
|
user = "pleroma";
|
|
|
|
group = "pleroma";
|
|
|
|
configs = [
|
2021-11-18 18:19:26 +00:00
|
|
|
(builtins.replaceStrings
|
2022-07-19 12:18:46 +00:00
|
|
|
[ "$DOMAIN" "$LUSER" ]
|
|
|
|
[ cfg.domain cfg.username ]
|
2021-11-22 16:53:43 +00:00
|
|
|
(builtins.readFile ./config.exs))
|
2021-11-15 10:02:05 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
postgresql = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.postgresql_12;
|
|
|
|
initialScript = "/etc/setup.psql";
|
2022-07-19 12:18:46 +00:00
|
|
|
ensureDatabases = [
|
|
|
|
"pleroma"
|
|
|
|
];
|
|
|
|
ensureUsers = [
|
|
|
|
{
|
|
|
|
name = "pleroma";
|
|
|
|
ensurePermissions = {
|
|
|
|
"DATABASE pleroma" = "ALL PRIVILEGES";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
2021-11-15 10:02:05 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
environment.etc."setup.psql".text = ''
|
2022-07-19 12:18:46 +00:00
|
|
|
CREATE USER pleroma;
|
2021-11-15 10:02:05 +00:00
|
|
|
CREATE DATABASE pleroma OWNER pleroma;
|
|
|
|
\c pleroma;
|
|
|
|
--Extensions made by ecto.migrate that need superuser access
|
|
|
|
CREATE EXTENSION IF NOT EXISTS citext;
|
|
|
|
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
|
|
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
|
|
|
'';
|
|
|
|
users.users.pleroma = {
|
|
|
|
extraGroups = [ "postgres" ];
|
2021-11-15 10:29:20 +00:00
|
|
|
isNormalUser = false;
|
|
|
|
isSystemUser = true;
|
2022-04-20 10:22:16 +00:00
|
|
|
group = "pleroma";
|
2021-11-15 10:02:05 +00:00
|
|
|
};
|
|
|
|
}
|