summary refs log tree commit diff stats
path: root/modules/nixos/vhack/peertube/default.nix
blob: c9a15d0a24cfeed3b36694db1fc5765a169461c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
  config,
  lib,
  pkgs,
  ...
}: let
  cfg = config.vhack.peertube;
in {
  options.vhack.peertube = {
    enable = lib.mkEnableOption ''
      the peertube video platform.
    '';
  };

  config = lib.mkIf cfg.enable {
    services.peertube = {
      enable = true;

      configureNginx = true;
      localDomain = "peertube.vhack.eu";

      smtp = {
        createLocally = true;
        passwordFile = "${config.age.secrets.peertubeSmtp.path}";
      };
      database = {
        createLocally = true;
      };
      redis = {
        enableUnixSocket = true;
        createLocally = true;
      };

      secrets.secretsFile = "${config.age.secrets.peertubeGeneral.path}";

      settings = {
        listen.hostname = "127.0.0.1";
        instance.name = "PeerTube at Vhack.eu";

        smtp = let
          emailAddress = "peertube@vhack.eu";
        in {
          sendmail = "${pkgs.postfix}/bin/sendmail";

          transport = "sendmail";
          hostname = "server1.vhack.eu";
          port = 587;
          username = emailAddress;
          tls = true;
          disable_starttls = true;
          from_address = emailAddress;
        };
      };
    };

    # The `configureNginx` option does not do this for some reason
    # TODO(@bpeetz): Find out why <2024-06-27>
    services.nginx.virtualHosts."${config.services.peertube.localDomain}" = {
      enableACME = true;
      forceSSL = true;
    };

    age.secrets = {
      peertubeGeneral = {
        file = ./secrets/general.age;
        mode = "700";
        owner = "peertube";
        group = "peertube";
      };
      peertubeSmtp = {
        file = ./secrets/smtp.age;
        mode = "700";
        owner = "peertube";
        group = "peertube";
      };
    };

    environment.persistence."/srv".directories = [
      {
        directory = "/var/lib/peertube";
        user = "peertube";
        group = "peertube";
        mode = "0700";
      }
    ];
  };
}