From ee9afc74c2b97e2ea86befad743f07d71e17e31c Mon Sep 17 00:00:00 2001 From: laniakea Date: Sat, 11 Apr 2026 13:52:15 +0300 Subject: [PATCH] setting up invidious was a mess --- server/configuration.nix | 1 + server/iv.nix | 72 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 server/iv.nix diff --git a/server/configuration.nix b/server/configuration.nix index 9c6103b..24f1a6b 100644 --- a/server/configuration.nix +++ b/server/configuration.nix @@ -8,6 +8,7 @@ ./matrix.nix ./element.nix ./forgejo.nix + ./iv.nix ]; nixpkgs.config.permittedInsecurePackages = [ diff --git a/server/iv.nix b/server/iv.nix new file mode 100644 index 0000000..66996cb --- /dev/null +++ b/server/iv.nix @@ -0,0 +1,72 @@ +{ config, pkgs, lib, ... }: +let + companionImage = pkgs.dockerTools.pullImage { + imageName = "quay.io/invidious/invidious-companion"; + imageDigest = "sha256:1f59440ef39c4a3377be6d9dc76a7adebb7cfc9b7be03f671dd06741d01be491"; + finalImageName = "invidious-companion"; + finalImageTag = "latest"; + os = "linux"; + arch = "amd64"; + sha256 = "sha256-QsKu0XyHYvad/saO4zDrHZU9o4GzihK30pMITYpcVoI="; + }; +in +{ + services.invidious = { + enable = true; + domain = "iv.itamar.site"; + port = 3002; + nginx.enable = true; + extraSettingsFile = "/var/lib/invidious/companion-secret.yaml"; + settings = { + https_only = true; + registration_enabled = false; + statistics_enabled = false; + default_user_preferences = { + locale = "en-US"; + dark_mode = "dark"; + thin_mode = false; + default_home = "feed"; + feed_menu = ["Popular" "Trending" "Subscriptions" "Playlists"]; + player_style = "invidious"; + quality = "hd720"; + volume = 100; + autoplay = false; + comments = ["youtube" ""]; + related_videos = true; + }; + }; + }; + + virtualisation.docker.enable = true; + + virtualisation.oci-containers = { + backend = "docker"; + containers.invidious-companion = { + image = "invidious-companion:latest"; + imageFile = companionImage; + ports = [ "127.0.0.1:3001:8282" ]; + environmentFiles = [ "/var/lib/invidious/companion-env" ]; + volumes = [ "/var/lib/invidious-companion-cache:/var/tmp/youtubei.js" ]; + extraOptions = [ "--no-healthcheck" ]; + }; + }; + + services.nginx = { + enable = true; + recommendedTlsSettings = true; + recommendedOptimisation = true; + recommendedGzipSettings = true; + recommendedProxySettings = true; + virtualHosts."iv.itamar.site" = { + enableACME = true; + forceSSL = true; + }; + }; + + security.acme = { + acceptTerms = true; + defaults.email = "admin@itamar.site"; + }; + + networking.firewall.allowedTCPPorts = [ 80 443 ]; +}