blob: 22068bf8b2efdbdb2eaf4bfb8b24db93ffa760fd (
plain)
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
|
{
lib,
pkgs,
config,
...
}: let
cfg = config.collinux.services.dufs;
modularService = {
lib,
config,
options,
...
}: let
cfg = config.dufs;
in {
options.dufs = {
package = lib.mkOption {
description = "the `dufs` package";
type = lib.types.package;
};
dir = lib.mkOption {
description = "root directory of the fileserver";
type = lib.types.str;
};
};
config =
{process.argv = [(lib.getExe cfg.package) cfg.dir "--bind" "/run/dufs/dufs.sock"];}
// lib.optionalAttrs (options ? systemd) {
systemd.service = {
wants = ["network-online.target"];
after = ["network-online.target"];
wantedBy = ["multi-user.target"];
serviceConfig = {
DynamicUser = true;
Group = "caddy";
SupplementaryGroups = "fileserver";
RuntimeDirectory = "dufs";
RuntimeDirectoryMode = "0750";
UMask = "0002";
ProtectSystem = "strict";
ProtectHome = true;
PrivateTmp = true;
NoNewPrivileges = true;
};
};
};
};
in
lib.mkIf cfg.enable {
users.groups."fileserver" = {};
system.services."dufs" = {
imports = [modularService];
dufs = {
package = pkgs.dufs;
dir = "/media";
};
};
services.caddy.virtualHosts."files.ganymede".extraConfig = ''
import internal
reverse_proxy unix//run/dufs/dufs.sock
'';
collinux.services.glance.homelabServices."files" = {
url = "https://files.ganymede";
icon = "mdi:folder";
};
}
|