···
1
-
{ config, lib, pkgs, ... }:
cfg = config.services.pleroma;
services.pleroma = with lib; {
enable = mkEnableOption "pleroma";
···
Have a look to Pleroma section in the NixOS manual for more
secretConfigFile = mkOption {
···
76
-
groups."${cfg.group}" = {};
82
+
groups."${cfg.group}" = { };
environment.systemPackages = [ cfg.package ];
···
import_config "${cfg.secretConfigFile}"
93
-
systemd.services = let
94
-
commonSystemdServiceConfig = {
97
-
WorkingDirectory = "~";
98
-
StateDirectory = "pleroma pleroma/static pleroma/uploads";
99
-
StateDirectoryMode = "700";
100
-
# Systemd sandboxing directives.
101
-
# Taken from the upstream contrib systemd service at
102
-
# pleroma/installation/pleroma.service
104
-
ProtectHome = true;
105
-
ProtectSystem = "full";
106
-
PrivateDevices = false;
107
-
NoNewPrivileges = true;
108
-
CapabilityBoundingSet = "~CAP_SYS_ADMIN";
101
+
commonSystemdServiceConfig = {
104
+
WorkingDirectory = "~";
105
+
StateDirectory = "pleroma pleroma/static pleroma/uploads";
106
+
StateDirectoryMode = "700";
107
+
# Systemd sandboxing directives.
108
+
# Taken from the upstream contrib systemd service at
109
+
# pleroma/installation/pleroma.service
111
+
ProtectHome = true;
112
+
ProtectSystem = "full";
113
+
PrivateDevices = false;
114
+
NoNewPrivileges = true;
115
+
CapabilityBoundingSet = "~CAP_SYS_ADMIN";
112
-
pleroma-migrations = {
113
-
description = "Pleroma social network migrations";
114
-
wants = [ "network-online.target" ];
115
-
after = [ "network-online.target" "postgresql.service" ];
116
-
wantedBy = [ "pleroma.service" ];
117
-
environment.RELEASE_COOKIE = "/var/lib/pleroma/.cookie";
118
-
serviceConfig = commonSystemdServiceConfig // {
120
-
# Checking the conf file is there then running the database
121
-
# migration before each service start, just in case there are
122
-
# some pending ones.
124
-
# It's sub-optimal as we'll always run this, even if pleroma
125
-
# has not been updated. But the no-op process is pretty fast.
126
-
# Better be safe than sorry migration-wise.
128
-
let preScript = pkgs.writers.writeBashBin "pleroma-migrations" ''
129
-
if [ ! -f /var/lib/pleroma/.cookie ]
131
-
echo "Creating cookie file"
132
-
dd if=/dev/urandom bs=1 count=16 | hexdump -e '16/1 "%02x"' > /var/lib/pleroma/.cookie
134
-
${cfg.package}/bin/pleroma_ctl migrate
136
-
in "${preScript}/bin/pleroma-migrations";
138
-
# disksup requires bash
139
-
path = [ pkgs.bash ];
120
+
pleroma-migrations = {
121
+
description = "Pleroma social network migrations";
122
+
wants = [ "network-online.target" ];
124
+
"network-online.target"
125
+
"postgresql.service"
127
+
wantedBy = [ "pleroma.service" ];
128
+
environment.RELEASE_COOKIE = "/var/lib/pleroma/.cookie";
129
+
serviceConfig = commonSystemdServiceConfig // {
131
+
# Checking the conf file is there then running the database
132
+
# migration before each service start, just in case there are
133
+
# some pending ones.
135
+
# It's sub-optimal as we'll always run this, even if pleroma
136
+
# has not been updated. But the no-op process is pretty fast.
137
+
# Better be safe than sorry migration-wise.
140
+
preScript = pkgs.writers.writeBashBin "pleroma-migrations" ''
141
+
if [ ! -f /var/lib/pleroma/.cookie ]
143
+
echo "Creating cookie file"
144
+
dd if=/dev/urandom bs=1 count=16 | hexdump -e '16/1 "%02x"' > /var/lib/pleroma/.cookie
146
+
${cfg.package}/bin/pleroma_ctl migrate
149
+
"${preScript}/bin/pleroma-migrations";
151
+
# disksup requires bash
152
+
path = [ pkgs.bash ];
143
-
description = "Pleroma social network";
144
-
wants = [ "pleroma-migrations.service" ];
145
-
after = [ "pleroma-migrations.service" ];
146
-
wantedBy = [ "multi-user.target" ];
147
-
restartTriggers = [ config.environment.etc."/pleroma/config.exs".source ];
148
-
environment.RELEASE_COOKIE = "/var/lib/pleroma/.cookie";
149
-
serviceConfig = commonSystemdServiceConfig // {
151
-
ExecStart = "${cfg.package}/bin/pleroma start";
152
-
ExecStop = "${cfg.package}/bin/pleroma stop";
153
-
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
156
+
description = "Pleroma social network";
157
+
wants = [ "pleroma-migrations.service" ];
158
+
after = [ "pleroma-migrations.service" ];
159
+
wantedBy = [ "multi-user.target" ];
160
+
restartTriggers = [ config.environment.etc."/pleroma/config.exs".source ];
161
+
environment.RELEASE_COOKIE = "/var/lib/pleroma/.cookie";
162
+
serviceConfig = commonSystemdServiceConfig // {
164
+
ExecStart = "${cfg.package}/bin/pleroma start";
165
+
ExecStop = "${cfg.package}/bin/pleroma stop";
166
+
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
168
+
# disksup requires bash
169
+
path = [ pkgs.bash ];
155
-
# disksup requires bash
156
-
path = [ pkgs.bash ];
meta.maintainers = with lib.maintainers; [ picnoir ];