1 { lib, pkgs, config, myconfig, mylibs, ... }:
3 peertube = pkgs.callPackage ./peertube.nix {
4 inherit (mylibs) fetchedGithub;
5 env = myconfig.env.tools.peertube;
8 cfg = config.services.myWebsites.tools.peertube;
10 options.services.myWebsites.tools.peertube = {
11 enable = lib.mkEnableOption "enable Peertube's website";
14 config = lib.mkIf cfg.enable {
15 ids.uids.peertube = myconfig.env.tools.peertube.user.uid;
16 ids.gids.peertube = myconfig.env.tools.peertube.user.gid;
18 users.users.peertube = {
20 uid = config.ids.uids.peertube;
22 description = "Peertube user";
23 home = peertube.varDir;
24 useDefaultShell = true;
25 extraGroups = [ "keys" ];
28 users.groups.peertube.gid = config.ids.gids.peertube;
30 systemd.services.peertube = {
31 description = "Peertube";
32 wantedBy = [ "multi-user.target" ];
33 after = [ "network.target" "postgresql.service" "tools-peertube-key.service" ];
34 wants = [ "postgresql.service" "tools-peertube-key.service" ];
36 environment.NODE_CONFIG_DIR = "${peertube.varDir}/config";
37 environment.NODE_ENV = "production";
38 environment.HOME = peertube.webappDir;
40 path = [ pkgs.nodejs pkgs.bashInteractive pkgs.ffmpeg pkgs.openssl ];
49 WorkingDirectory = peertube.webappDir;
52 ProtectControlGroups = true;
58 unitConfig.RequiresMountsFor = peertube.varDir;
61 deployment.keys.tools-peertube = {
62 destDir = "/run/keys/webapps";
66 text = peertube.config;
69 system.activationScripts.peertube = {
72 install -m 0750 -o peertube -g peertube -d ${peertube.varDir}
73 install -m 0750 -o peertube -g peertube -d ${peertube.varDir}/config
74 ln -sf /run/keys/webapps/tools-peertube ${peertube.varDir}/config/production.yaml
78 services.myWebsites.tools.modules = [
79 "headers" "proxy" "proxy_http" "proxy_wstunnel"
81 security.acme.certs."eldiron".extraDomains."peertube.immae.eu" = null;
82 services.myWebsites.tools.vhostConfs.peertube = {
84 hosts = [ "peertube.immae.eu" ];
87 ProxyPass / http://localhost:${peertube.listenPort}/
88 ProxyPassReverse / http://localhost:${peertube.listenPort}/
91 RequestHeader set X-Real-IP %{REMOTE_ADDR}s
93 ProxyPass /tracker/socket ws://127.0.0.1:${peertube.listenPort}/tracker/socket
94 ProxyPassReverse /tracker/socket ws://127.0.0.1:${peertube.listenPort}/tracker/socket
96 ProxyPass /socket.io ws://127.0.0.1:${peertube.listenPort}/socket.io
97 ProxyPassReverse /socket.io ws://127.0.0.1:${peertube.listenPort}/socket.io