7 cfg = config.services.invidious-router;
8 settingsFormat = pkgs.formats.yaml {};
9 configFile = settingsFormat.generate "config.yaml" cfg.settings;
11 meta.maintainers = [lib.maintainers.sils];
13 options.services.invidious-router = {
14 enable = lib.mkEnableOption "the invidious-router service";
16 type = lib.types.port;
22 address = lib.mkOption {
24 default = "127.0.0.1";
26 Address on which invidious-router should listen on.
29 settings = lib.mkOption {
30 type = lib.types.submodule {
31 freeformType = settingsFormat.type;
35 listen = "127.0.0.1:8050";
36 enable_youtube_fallback = false;
37 reload_instance_list_interval = "60s";
41 url = "https://api.invidious.io/instances.json";
42 filter_regions = true;
51 allowed_status_codes = [
56 filter_by_response_time = {
58 qty_of_top_results = 3;
61 remove_no_ratio = true;
62 text_not_present = "YouTube is currently trying to block Invidious instances";
66 Configuration for invidious-router.
67 Check https://gitlab.com/gaincoder/invidious-router#configuration
68 for configuration options.
71 package = lib.mkOption {
72 type = lib.types.package;
73 default = pkgs.invidious-router;
74 defaultText = lib.literalExpression "pkgs.invidious-router";
76 The invidious-router package to use.
80 enable = lib.mkEnableOption ''
81 Automatic nginx proxy configuration
83 domain = lib.mkOption {
85 example = "invidious-router.example.com";
87 The domain on which invidious-router should be served.
90 extraDomains = lib.mkOption {
91 type = lib.types.listOf lib.types.str;
94 Additional domains to serve invidious-router on.
99 config = lib.mkIf cfg.enable {
100 systemd.services.invidious-router = {
101 wantedBy = ["multi-user.target"];
103 Restart = "on-failure";
104 ExecStart = "${lib.getExe cfg.package} --configfile ${configFile}";
109 services.nginx.virtualHosts = lib.mkIf cfg.nginx.enable {
110 ${cfg.nginx.domain} = {
112 recommendedProxySettings = true;
113 proxyPass = "http://${cfg.address}:${toString cfg.port}";
117 serverAliases = cfg.nginx.extraDomains;