blob: d78eafe8d174b9671943e9aa4120ce6f237e9a0a (
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
|
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.emile.filebrowser;
in
with lib;
{
options.services.emile.filebrowser = {
enable = mkEnableOption "Enable filebrowser";
# ip and port to listen on
address = mkOption {
type = types.str;
default = "127.0.0.1";
example = "0.0.0.0";
description = "The address the service listens on";
};
port = mkOption {
type = types.int;
default = 8080;
example = 8080;
description = "The port the service listens on";
};
root = mkOption {
type = types.str;
default = null;
example = "/data";
description = "The directory to serve";
};
};
config = mkIf cfg.enable {
systemd.services.filebrowser = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
RestartSec = 5;
Restart = "always";
};
path = [ pkgs.filebrowser pkgs.getent ];
# don't want the filebrowser.db to appear in the root? change it here (after --database)
serviceConfig.ExecStart = ''${pkgs.filebrowser}/bin/filebrowser \
-a ${cfg.address} \
-p ${toString cfg.port} \
--database ${cfg.root}/filebrowser.db \
-r ${cfg.root}
'';
};
};
}
|