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