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