nixos/peertube: add secretsFile option

Izorkin 9195f02b 32673128

Changed files
+28
nixos
modules
services
web-apps
tests
web-apps
+21
nixos/modules/services/web-apps/peertube.nix
···
description = lib.mdDoc "Configure nginx as a reverse proxy for peertube.";
};
+
secrets = {
+
secretsFile = lib.mkOption {
+
type = lib.types.nullOr lib.types.path;
+
default = null;
+
example = "/run/secrets/peertube";
+
description = lib.mdDoc ''
+
Secrets to run PeerTube.
+
Generate one using `openssl rand -hex 32`
+
'';
+
};
+
};
+
database = {
createLocally = lib.mkOption {
type = lib.types.bool;
···
<option>services.peertube.serviceEnvironmentFile</option> points to
a file in the Nix store. You should use a quoted absolute path to
prevent this.
+
'';
+
}
+
{ assertion = cfg.secrets.secretsFile != null;
+
message = ''
+
<option>services.peertube.secrets.secretsFile</option> needs to be set.
'';
}
{ assertion = !(cfg.redis.enableUnixSocket && (cfg.redis.host != null || cfg.redis.port != null));
···
#!/bin/sh
umask 077
cat > /var/lib/peertube/config/local.yaml <<EOF
+
${lib.optionalString (cfg.secrets.secretsFile != null) ''
+
secrets:
+
peertube: '$(cat ${cfg.secrets.secretsFile})'
+
''}
${lib.optionalString ((!cfg.database.createLocally) && (cfg.database.passwordFile != null)) ''
database:
password: '$(cat ${cfg.database.passwordFile})'
+7
nixos/tests/web-apps/peertube.nix
···
server = { pkgs, ... }: {
environment = {
etc = {
+
"peertube/secrets-peertube".text = ''
+
063d9c60d519597acef26003d5ecc32729083965d09181ef3949200cbe5f09ee
+
'';
"peertube/password-posgressql-db".text = ''
0gUN0C1mgST6czvjZ8T9
'';
···
enable = true;
localDomain = "peertube.local";
enableWebHttps = false;
+
+
secrets = {
+
secretsFile = "/etc/peertube/secrets-peertube";
+
};
database = {
host = "192.168.2.10";