2025-03-04 13:21:29 +01:00
|
|
|
{ pkgs , ... } :
|
2025-03-04 13:13:22 +01:00
|
|
|
|
2025-03-04 16:02:02 +01:00
|
|
|
with pkgs ;
|
2025-03-04 13:13:22 +01:00
|
|
|
with pkgs . kernelmaft ;
|
|
|
|
|
|
|
|
{
|
|
|
|
systemd = {
|
|
|
|
units = {
|
|
|
|
"bookwyrm.service" = {
|
|
|
|
text = ''
|
|
|
|
[Unit]
|
2025-03-04 16:09:58 +01:00
|
|
|
|
2025-03-04 13:13:22 +01:00
|
|
|
After=network.target
|
|
|
|
|
|
|
|
[Service]
|
2025-03-04 16:09:58 +01:00
|
|
|
|
2025-03-09 17:24:09 +01:00
|
|
|
# 'initdb' fails harmlessly if it has been run on the database before
|
2025-03-04 16:14:51 +01:00
|
|
|
ExecStartPre=${coreutils-full}/bin/ln -sf ${bookwyrm}/var/lib/bookwyrm/VERSION /var/lib/bookwyrm/
|
2025-03-13 15:24:20 +01:00
|
|
|
ExecStartPre=${coreutils-full}/bin/mkdir -p /var/lib/bookwyrm/images
|
2025-03-09 14:48:32 +01:00
|
|
|
ExecStartPre=${bookwyrm}/bin/bookwyrm-env ${python311}/bin/python ${bookwyrm}/lib/python3.11/manage.py migrate
|
2025-03-09 17:24:09 +01:00
|
|
|
ExecStartPre=-${bookwyrm}/bin/bookwyrm-env ${python311}/bin/python ${bookwyrm}/lib/python3.11/manage.py initdb
|
2025-03-09 12:55:12 +01:00
|
|
|
ExecStart=${bookwyrm}/bin/bookwyrm-env ${bookwyrm}/bin/bookwyrm
|
2025-03-04 16:09:58 +01:00
|
|
|
|
2025-03-04 15:16:13 +01:00
|
|
|
WorkingDirectory=/var/lib/bookwyrm
|
2025-03-04 16:09:58 +01:00
|
|
|
|
|
|
|
# Creates /var/lib/bookwyrm directory
|
|
|
|
StateDirectory=bookwyrm
|
2025-03-04 17:00:35 +01:00
|
|
|
|
2025-03-07 13:19:18 +01:00
|
|
|
# Creates /run/bookwyrm directory
|
|
|
|
RuntimeDirectory=bookwyrm
|
|
|
|
|
2025-03-04 17:00:35 +01:00
|
|
|
User=bookwyrm
|
|
|
|
Group=bookwyrm
|
2025-03-04 18:09:13 +01:00
|
|
|
|
2025-03-04 18:30:27 +01:00
|
|
|
ProtectSystem=strict
|
|
|
|
ProtectHome=tmpfs
|
|
|
|
PrivateTmp=true
|
2025-03-04 18:09:13 +01:00
|
|
|
PrivateDevices=true
|
|
|
|
PrivateIPC=true
|
|
|
|
ProtectHostname=true
|
|
|
|
ProtectClock=true
|
|
|
|
ProtectKernelTunables=true
|
|
|
|
ProtectKernelModules=true
|
2025-03-04 18:30:27 +01:00
|
|
|
ProtectControlGroups=true
|
2025-03-04 18:09:13 +01:00
|
|
|
RestrictNamespaces=true
|
|
|
|
LockPersonality=true
|
|
|
|
RestrictRealtime=true
|
|
|
|
RestrictSUIDSGID=true
|
2025-03-04 13:13:22 +01:00
|
|
|
'' ;
|
|
|
|
} ;
|
|
|
|
} ;
|
|
|
|
} ;
|
2025-03-04 17:23:07 +01:00
|
|
|
|
|
|
|
users = {
|
|
|
|
groups = {
|
|
|
|
bookwyrm = {} ;
|
|
|
|
} ;
|
|
|
|
users = {
|
|
|
|
bookwyrm = {
|
|
|
|
group = "bookwyrm" ;
|
|
|
|
home = "/var/lib/bookwyrm" ;
|
|
|
|
isSystemUser = true ;
|
|
|
|
} ;
|
|
|
|
} ;
|
|
|
|
} ;
|
2025-03-08 16:14:09 +01:00
|
|
|
|
|
|
|
services = {
|
2025-03-11 13:44:32 +01:00
|
|
|
postgresql = {
|
2025-03-08 16:14:09 +01:00
|
|
|
ensureUsers = [
|
2025-03-08 16:29:55 +01:00
|
|
|
{
|
|
|
|
name = "bookwyrm" ;
|
|
|
|
ensureDBOwnership = true ;
|
|
|
|
}
|
2025-03-08 16:14:09 +01:00
|
|
|
] ;
|
|
|
|
ensureDatabases = [ "bookwyrm" ] ;
|
|
|
|
} ;
|
2025-03-13 13:38:46 +01:00
|
|
|
|
|
|
|
redis = {
|
|
|
|
servers = {
|
2025-03-13 13:50:32 +01:00
|
|
|
bookwyrm-activity = {
|
|
|
|
enable = true ;
|
2025-03-13 14:44:08 +01:00
|
|
|
user = "bookwyrm" ;
|
|
|
|
group = "bookwyrm" ;
|
2025-03-13 13:50:32 +01:00
|
|
|
} ;
|
|
|
|
bookwyrm-broker = {
|
2025-03-13 13:38:46 +01:00
|
|
|
enable = true ;
|
2025-03-13 14:44:08 +01:00
|
|
|
user = "bookwyrm" ;
|
|
|
|
group = "bookwyrm" ;
|
2025-03-13 13:38:46 +01:00
|
|
|
} ;
|
|
|
|
} ;
|
|
|
|
} ;
|
2025-03-08 16:14:09 +01:00
|
|
|
} ;
|
2025-03-04 13:13:22 +01:00
|
|
|
}
|