From c153a351659e4596acfc31f00bf594343cbfcd68 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Thu, 30 Jul 2026 14:05:39 +0200 Subject: modules: Use namespaces That might make it easier in the future to merge different server configs together (and thusly facilitate code-reuse.). --- modules/vhack/pe/peertube/module.nix | 124 +++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 modules/vhack/pe/peertube/module.nix (limited to 'modules/vhack/pe/peertube/module.nix') diff --git a/modules/vhack/pe/peertube/module.nix b/modules/vhack/pe/peertube/module.nix new file mode 100644 index 0000000..e65e0b5 --- /dev/null +++ b/modules/vhack/pe/peertube/module.nix @@ -0,0 +1,124 @@ +{ + config, + lib, + ... +}: let + cfg = config.vhack.peertube; +in { + options.vhack.peertube = { + enable = lib.mkEnableOption '' + the peertube video platform. + ''; + peertubeGeneral = lib.mkOption { + type = lib.types.path; + description = "The age encrypted general secret file passed to agenix"; + }; + smtpPasswordFile = lib.mkOption { + type = lib.types.path; + description = "The age encrypted smtp password file passed to agenix"; + }; + }; + + config = lib.mkIf cfg.enable { + services.peertube = { + enable = true; + + configureNginx = true; + localDomain = "peertube.vhack.eu"; + enableWebHttps = true; + listenWeb = 443; + + smtp = { + createLocally = false; + passwordFile = "${config.age.secrets.peertubeSmtp.path}"; + }; + database = { + createLocally = true; + }; + redis = { + enableUnixSocket = true; + createLocally = true; + }; + + secrets.secretsFile = "${config.age.secrets.peertubeGeneral.path}"; + + settings = { + signup = { + enabled = true; + + limit = 10; # When the limit is reached, registrations are disabled. -1 == unlimited + + minimum_age = 18; # Used to configure the signup form + + # Users fill a form to register so moderators can accept/reject the registration + requires_approval = true; + requires_email_verification = true; + }; + user = { + video_quota = "10GB"; + video_quota_daily = "2GB"; + }; + auto_blacklist = { + videos = { + of_users = { + enabled = true; + }; + }; + }; + listen.hostname = "127.0.0.1"; + instance.name = "PeerTube at Vhack.eu"; + + admin.email = "admin@vhack.eu"; + + smtp = let + emailAddress = "peertube@vhack.eu"; + in { + transport = "smtp"; + hostname = "mail.foss-syndicate.org"; + 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 = cfg.peertubeGeneral; + mode = "700"; + owner = "peertube"; + group = "peertube"; + }; + peertubeSmtp = { + file = cfg.smtpPasswordFile; + mode = "700"; + owner = "peertube"; + group = "peertube"; + }; + }; + + vhack.persist.directories = [ + { + directory = "/var/lib/peertube"; + user = "peertube"; + group = "peertube"; + mode = "0700"; + } + ]; + users = { + users.peertube.uid = config.vhack.constants.ids.uids.peertube; + groups.peertube.gid = config.vhack.constants.ids.gids.peertube; + users.redis-peertube.uid = config.vhack.constants.ids.uids.redis-peertube; + groups.redis-peertube.gid = config.vhack.constants.ids.gids.redis-peertube; + }; + }; +} -- cgit v1.3.1