blob: d019bd3c55640648eb27753644173f3de925f2d7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
{
config,
lib,
pkgs,
pkgsUnstable,
nixpkgs-unstable,
...
}: let
cfg = config.vhack.sharkey;
in {
imports = [
# TODO(@bpeetz): Remove this import once we update to NixOS 25.11 <2025-07-12>
"${nixpkgs-unstable}/nixos/modules/services/web-apps/sharkey.nix"
];
options.vhack.sharkey = {
enable = lib.mkEnableOption "sharkey";
fqdn = lib.mkOption {
description = "The fully qualified domain name of this instance.";
type = lib.types.str;
example = "sharkey.shonk.social";
};
package = lib.mkOption {
type = lib.types.package;
default = pkgsUnstable.sharkey;
defaultText = lib.literalExpression "vhackPackages.sharkey";
description = "Sharkey package to use.";
};
mediaDirectory = lib.mkOption {
type = lib.types.path;
default = "/var/lib/sharkey";
description = "The directory where sharkey stores it's data.";
};
settings = lib.mkOption {
inherit (pkgs.formats.yaml {}) type;
default = {};
description = ''
Extra Configuration for Sharkey, see
<link xlink:href="https://activitypub.software/TransFem-org/Sharkey/-/blob/develop/.config/example.yml"/>
for supported settings.
Note, that this is applied on-top of the neccessary config.
'';
};
};
config = lib.mkIf cfg.enable {
services = {
sharkey = {
enable = true;
inherit (cfg) package;
openFirewall = false;
setupRedis = true;
setupPostgresql = true;
settings =
cfg.settings
// {
url = "https://${cfg.fqdn}/";
port = 5312;
inherit (cfg) mediaDirectory;
fulltextSearch.provider = "sqlLike";
};
};
nginx.virtualHosts."${cfg.fqdn}" = {
locations."/" = {
proxyPass = "http://127.0.0.1:${toString config.services.sharkey.settings.port}";
proxyWebsockets = true;
};
enableACME = true;
forceSSL = true;
};
};
systemd.services.sharkey = {
requires = ["network-online.target"];
# TODO(@bpeetz): `postgresql.target` is only available in NixOS 25.11, as such we
# need to override this back to the postgresql.service. <2025-07-12>
after = lib.mkForce [
"network-online.target"
"postgresql.service"
"redis-sharkey.service"
];
bindsTo = lib.mkForce [
"postgresql.service"
"redis-sharkey.service"
];
serviceConfig = {
# The upstream service uses DynamicUsers, which currently poses issues to our
# directory persisting strategy.
User = "sharkey";
Group = "sharkey";
DynamicUser = lib.mkForce false;
};
};
vhack = {
nginx.enable = true;
persist.directories = [
{
directory = "${config.services.redis.servers."sharkey".settings.dir}";
user = "sharkey";
group = "redis-sharey";
mode = "0770";
}
{
directory = "${cfg.mediaDirectory}";
user = "sharkey";
group = "sharkey";
mode = "0700";
}
];
};
users = {
groups.sharkey = {
gid = config.vhack.constants.ids.gids.sharkey;
};
users.sharkey = {
isSystemUser = true;
group = "sharkey";
uid = config.vhack.constants.ids.uids.sharkey;
home = cfg.package;
packages = [cfg.package];
};
groups.redis-sharkey = {
gid = config.vhack.constants.ids.gids.redis-sharkey;
};
users.redis-sharkey = {
group = "redis-sharkey";
uid = config.vhack.constants.ids.uids.redis-sharkey;
};
};
};
}
|