]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/tools/peertube/default.nix
Update nix unstable
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / peertube / default.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
f3a8fab5 2let
ab8f306d 3 env = config.myEnv.tools.peertube;
4288c2f2 4 cfg = config.myServices.websites.tools.peertube;
d42bbbe6 5 pcfg = config.services.peertube;
f3a8fab5 6in {
4288c2f2 7 options.myServices.websites.tools.peertube = {
f3a8fab5
IB
8 enable = lib.mkEnableOption "enable Peertube's website";
9 };
10
11 config = lib.mkIf cfg.enable {
d880826a
IB
12 services.duplyBackup.profiles.peertube = {
13 rootDir = pcfg.dataDir;
14 };
d42bbbe6
IB
15 services.peertube = {
16 enable = true;
17 configFile = "/var/secrets/webapps/tools-peertube";
f3a8fab5 18 };
d42bbbe6 19 users.users.peertube.extraGroups = [ "keys" ];
f3a8fab5 20
1a718805 21 secrets.keys = [{
f3a8fab5
IB
22 dest = "webapps/tools-peertube";
23 user = "peertube";
24 group = "peertube";
25 permissions = "0640";
26 text = ''
27 listen:
28 hostname: 'localhost'
ab8f306d 29 port: ${toString config.myEnv.ports.peertube}
f3a8fab5
IB
30 webserver:
31 https: true
32 hostname: 'peertube.immae.eu'
33 port: 443
f3a8fab5
IB
34 database:
35 hostname: '${env.postgresql.socket}'
36 port: 5432
37 suffix: '_prod'
38 username: '${env.postgresql.user}'
39 password: '${env.postgresql.password}'
40 pool:
41 max: 5
42 redis:
43 socket: '${env.redis.socket}'
44 auth: null
ab8f306d 45 db: ${env.redis.db}
f3a8fab5
IB
46 smtp:
47 transport: sendmail
48 sendmail: '/run/wrappers/bin/sendmail'
f3a8fab5
IB
49 from_address: 'peertube@tools.immae.eu'
50 storage:
d42bbbe6
IB
51 tmp: '${pcfg.dataDir}/storage/tmp/'
52 avatars: '${pcfg.dataDir}/storage/avatars/'
53 videos: '${pcfg.dataDir}/storage/videos/'
b639cc33 54 streaming_playlists: '${pcfg.dataDir}/storage/streaming-playlists/'
d42bbbe6
IB
55 redundancy: '${pcfg.dataDir}/storage/videos/'
56 logs: '${pcfg.dataDir}/storage/logs/'
57 previews: '${pcfg.dataDir}/storage/previews/'
58 thumbnails: '${pcfg.dataDir}/storage/thumbnails/'
59 torrents: '${pcfg.dataDir}/storage/torrents/'
60 captions: '${pcfg.dataDir}/storage/captions/'
61 cache: '${pcfg.dataDir}/storage/cache/'
b639cc33 62 plugins: '${pcfg.dataDir}/storage/plugins/'
3d11eafc 63 client_overrides: '${pcfg.dataDir}/storage/client-overrides/'
f3a8fab5
IB
64 '';
65 }];
66
29f8cb85 67 services.websites.env.tools.modules = [
f3a8fab5
IB
68 "headers" "proxy" "proxy_http" "proxy_wstunnel"
69 ];
17f6eae9
IB
70 services.filesWatcher.peertube = {
71 restart = true;
72 paths = [ pcfg.configFile ];
73 };
74
29f8cb85 75 services.websites.env.tools.vhostConfs.peertube = {
f3a8fab5 76 certName = "eldiron";
7df420c2 77 addToCerts = true;
f3a8fab5
IB
78 hosts = [ "peertube.immae.eu" ];
79 root = null;
80 extraConfig = [ ''
f826c67c
IB
81 RewriteEngine On
82
83 RewriteCond %{REQUEST_URI} ^/socket.io [NC]
84 RewriteCond %{QUERY_STRING} transport=websocket [NC]
ab8f306d 85 RewriteRule /(.*) ws://localhost:${toString env.listenPort}/$1 [P,NE,QSA,L]
f826c67c
IB
86
87 RewriteCond %{REQUEST_URI} ^/tracker/socket [NC]
ab8f306d 88 RewriteRule /(.*) ws://localhost:${toString env.listenPort}/$1 [P,NE,QSA,L]
f826c67c 89
ab8f306d
IB
90 ProxyPass / http://localhost:${toString env.listenPort}/
91 ProxyPassReverse / http://localhost:${toString env.listenPort}/
f3a8fab5
IB
92
93 ProxyPreserveHost On
94 RequestHeader set X-Real-IP %{REMOTE_ADDR}s
f3a8fab5
IB
95 '' ];
96 };
97 };
98}