diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2021-01-23 23:26:11 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2021-01-24 00:12:09 +0100 |
commit | 3d11eafc9c516321901908338befe4c04b58f3aa (patch) | |
tree | e16d8e92eeabfb834424772b71e8833e864e4849 /modules/webapps | |
parent | ce95026934c4ea8c647365f68eb195459fcdff08 (diff) | |
download | Nix-3d11eafc9c516321901908338befe4c04b58f3aa.tar.gz Nix-3d11eafc9c516321901908338befe4c04b58f3aa.tar.zst Nix-3d11eafc9c516321901908338befe4c04b58f3aa.zip |
Use peertube flake in modules
Diffstat (limited to 'modules/webapps')
-rw-r--r-- | modules/webapps/peertube.nix | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/modules/webapps/peertube.nix b/modules/webapps/peertube.nix deleted file mode 100644 index 1d76e9b..0000000 --- a/modules/webapps/peertube.nix +++ /dev/null | |||
@@ -1,108 +0,0 @@ | |||
1 | { lib, pkgs, config, ... }: | ||
2 | let | ||
3 | name = "peertube"; | ||
4 | cfg = config.services.peertube; | ||
5 | |||
6 | uid = config.ids.uids.peertube; | ||
7 | gid = config.ids.gids.peertube; | ||
8 | in | ||
9 | { | ||
10 | options.services.peertube = { | ||
11 | enable = lib.mkEnableOption "Enable Peertube’s service"; | ||
12 | user = lib.mkOption { | ||
13 | type = lib.types.str; | ||
14 | default = name; | ||
15 | description = "User account under which Peertube runs"; | ||
16 | }; | ||
17 | group = lib.mkOption { | ||
18 | type = lib.types.str; | ||
19 | default = name; | ||
20 | description = "Group under which Peertube runs"; | ||
21 | }; | ||
22 | dataDir = lib.mkOption { | ||
23 | type = lib.types.path; | ||
24 | default = "/var/lib/${name}"; | ||
25 | description = '' | ||
26 | The directory where Peertube stores its data. | ||
27 | ''; | ||
28 | }; | ||
29 | configFile = lib.mkOption { | ||
30 | type = lib.types.path; | ||
31 | description = '' | ||
32 | The configuration file path for Peertube. | ||
33 | ''; | ||
34 | }; | ||
35 | package = lib.mkOption { | ||
36 | type = lib.types.package; | ||
37 | default = pkgs.webapps.peertube; | ||
38 | description = '' | ||
39 | Peertube package to use. | ||
40 | ''; | ||
41 | }; | ||
42 | # Output variables | ||
43 | systemdStateDirectory = lib.mkOption { | ||
44 | type = lib.types.str; | ||
45 | # Use ReadWritePaths= instead if varDir is outside of /var/lib | ||
46 | default = assert lib.strings.hasPrefix "/var/lib/" cfg.dataDir; | ||
47 | lib.strings.removePrefix "/var/lib/" cfg.dataDir; | ||
48 | description = '' | ||
49 | Adjusted Peertube data directory for systemd | ||
50 | ''; | ||
51 | readOnly = true; | ||
52 | }; | ||
53 | }; | ||
54 | |||
55 | config = lib.mkIf cfg.enable { | ||
56 | users.users = lib.optionalAttrs (cfg.user == name) { | ||
57 | "${name}" = { | ||
58 | inherit uid; | ||
59 | group = cfg.group; | ||
60 | description = "Peertube user"; | ||
61 | home = cfg.dataDir; | ||
62 | useDefaultShell = true; | ||
63 | }; | ||
64 | }; | ||
65 | users.groups = lib.optionalAttrs (cfg.group == name) { | ||
66 | "${name}" = { | ||
67 | inherit gid; | ||
68 | }; | ||
69 | }; | ||
70 | |||
71 | systemd.services.peertube = { | ||
72 | description = "Peertube"; | ||
73 | wantedBy = [ "multi-user.target" ]; | ||
74 | after = [ "network.target" "postgresql.service" ]; | ||
75 | wants = [ "postgresql.service" ]; | ||
76 | |||
77 | environment.NODE_CONFIG_DIR = "${cfg.dataDir}/config"; | ||
78 | environment.NODE_ENV = "production"; | ||
79 | environment.HOME = cfg.package; | ||
80 | |||
81 | path = [ pkgs.nodejs pkgs.bashInteractive pkgs.ffmpeg pkgs.openssl ]; | ||
82 | |||
83 | script = '' | ||
84 | install -m 0750 -d ${cfg.dataDir}/config | ||
85 | ln -sf ${cfg.configFile} ${cfg.dataDir}/config/production.yaml | ||
86 | ln -sf ${cfg.package}/config/default.yaml ${cfg.dataDir}/config/default.yaml | ||
87 | exec npm run start | ||
88 | ''; | ||
89 | |||
90 | serviceConfig = { | ||
91 | User = cfg.user; | ||
92 | Group = cfg.group; | ||
93 | WorkingDirectory = cfg.package; | ||
94 | StateDirectory = cfg.systemdStateDirectory; | ||
95 | StateDirectoryMode = 0750; | ||
96 | PrivateTmp = true; | ||
97 | ProtectHome = true; | ||
98 | ProtectControlGroups = true; | ||
99 | Restart = "always"; | ||
100 | Type = "simple"; | ||
101 | TimeoutSec = 60; | ||
102 | }; | ||
103 | |||
104 | unitConfig.RequiresMountsFor = cfg.dataDir; | ||
105 | }; | ||
106 | }; | ||
107 | } | ||
108 | |||