diff options
author | sils <sils@sils.li> | 2023-10-14 15:28:05 +0200 |
---|---|---|
committer | sils <sils@sils.li> | 2023-10-14 15:28:05 +0200 |
commit | 04e4866a17853d583c943b52ec2b9c5e7518e4ae (patch) | |
tree | bd079002dbebd4fffc533596c3f4e5a99a6b3a56 /system/services/invidious/default.nix | |
parent | Fix(system/services/etebase): Add proxy parameters (diff) | |
parent | fix(system/services/mastodon): Correctly avoid string casts (diff) | |
download | nixos-server-04e4866a17853d583c943b52ec2b9c5e7518e4ae.tar.gz nixos-server-04e4866a17853d583c943b52ec2b9c5e7518e4ae.zip |
Merge branch 'main' into etebase
Diffstat (limited to '')
-rw-r--r-- | system/services/invidious/default.nix | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/system/services/invidious/default.nix b/system/services/invidious/default.nix new file mode 100644 index 0000000..a1d202c --- /dev/null +++ b/system/services/invidious/default.nix @@ -0,0 +1,48 @@ +{ + config, + lib, + pkgs, + ... +}: let + cfg = config.services.invidious; +in { + services.invidious = { + enable = true; + database = { + createLocally = true; + }; + domain = "invidious.vhack.eu"; + nginx.enable = true; + extraSettingsFile = "$CREDENTIALS_DIRECTORY/hmac"; + + settings = { + check_tables = true; + }; + }; + systemd.services.invidious.serviceConfig = { + LoadCredential = "hmac:${config.age.secrets.invidiousHmac.path}"; + + ExecStart = let + # taken from the invidious module + settingsFormat = pkgs.formats.json {}; + settingsFile = settingsFormat.generate "invidious-settings" cfg.settings; + + jqFilter = + "." + + lib.optionalString (cfg.database.host != null) "[0].db.password = \"'\"'\"$(cat ${lib.escapeShellArg cfg.database.passwordFile})\"'\"'\"" + + " | .[0]" + + lib.optionalString (cfg.extraSettingsFile != null) " * .[1]"; + + # don't escape extraSettingsFile, to allow variable substitution + jqFiles = + settingsFile + + lib.optionalString (cfg.extraSettingsFile != null) " \"${cfg.extraSettingsFile}\""; + in + lib.mkForce (pkgs.writeScript "start-invidious" '' + #! ${pkgs.dash}/bin/dash + + export INVIDIOUS_CONFIG="$(${pkgs.jq}/bin/jq -s "${jqFilter}" ${jqFiles})" + exec ${cfg.package}/bin/invidious + ''); + }; +} |