forked from nixcloud/nixcloud-webservices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
62 lines (51 loc) · 1.66 KB
/
default.nix
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
{ config, pkgs, lib, mkUniqueUser, mkUniqueGroup, ... }:
{
options = {};
meta = {
description = "A pair programming tool and library written in Golang";
homepage = "https://github.com/jeffail/leaps/";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ qknight ];
meta.platforms = lib.platforms.linux;
};
config = lib.mkIf config.enable {
# inject the leaps websocket for cooperative document opening/editing into proxyOptions
proxyOptions.websockets = {
ws = {
subpath = "/leaps/ws";
};
};
directories.www.postCreate = ''
cat > README.md <<EOF
# No files to edit other than this one?
You can add more files into \`${config.stateDir}/www\` to edit them
collaberatively via your Leaps instance.
EOF
'';
users.leaps = {
description = "Leaps server user";
home = "${config.stateDir}/www";
createHome = true;
group = "leaps";
};
groups.leaps = {};
systemd.services.leaps = {
description = "${config.uniqueName} main service (leaps)";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
User = "leaps";
Group = "leaps";
Restart = "on-failure";
WorkingDirectory = "${config.stateDir}/www";
PrivateTmp = true;
ExecStart = lib.concatMapStringsSep " " lib.escapeShellArg [
"${pkgs.leaps.bin}/bin/leaps"
"-path" config.proxyOptions.path
"-address" "${config.proxyOptions.ip}:${toString config.proxyOptions.port}"
];
};
};
tests.wanted = [ ./test.nix ];
};
}