From 14d83dafcd7e3608d7618b0fc28c84fa32f8f658 Mon Sep 17 00:00:00 2001 From: Snorre Date: Thu, 3 Apr 2025 11:22:48 +0200 Subject: [PATCH] fixed lists of strings not being able to be converted to xml --- modules/options/default.nix | 24 +++++++++++++++++++++--- modules/options/network.nix | 10 +++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/modules/options/default.nix b/modules/options/default.nix index 0525ee1..c9157d4 100644 --- a/modules/options/default.nix +++ b/modules/options/default.nix @@ -21,6 +21,21 @@ in mkIf cfg.enable ( let + listOfStrPrepass = xml: (builtins.mapAttrs (name: value: + ( + if ((name == "content") && (builtins.isList value)) + then + if (builtins.all builtins.isString value) + then # listOf str + (builtins.map (content: { + name = "string"; + inherit content; + })) + else # Lis of something else + warnIf (!(builtins.all builtins.isAttrs value)) "Recieved list of mixed values. This will most likely not evaluate correctly" (listOfStrPrepass value) + else (listOfStrPrepass value) + ) + xml)); toXml = name: x: (toXMLGeneric { inherit name; properties = { @@ -30,10 +45,13 @@ in content = x; }); in { - system.activationScripts."link-network-xml" = - lib.stringAfter ["var"] (let content = toXml "NetworkConfiguration" cfg.network; in '' + system.activationScripts."link-network-xml" = lib.stringAfter ["var"] ( + let + content = toXml "NetworkConfiguration" (listOfStrPrepass cfg.network); + in '' ${pkgs.writeTextFile}/bin/writeTextFile /var/lib/jellyfin/config/network.xml '${strings.escape ["'"] content}' - ''); + '' + ); } ); } diff --git a/modules/options/network.nix b/modules/options/network.nix index 6fe9831..f0c601d 100644 --- a/modules/options/network.nix +++ b/modules/options/network.nix @@ -69,7 +69,15 @@ with lib; { default = ["veth"]; }; EnablePublishedServerUriByRequest = mkEnableOption "Enable published server uri by request"; - PublishedServerUriBySubnet = mkEnableOption "UNIMPLEMENTED"; + PublishedServerUriBySubnet = mkOption { + type = with types; listOf str; + description = '' + Override the URI used by Jellyfin, based on the interface, or client IP address. + + For example: `["internal=http://jellyfin.example.com" "external=https://jellyfin.example.com"]` or `["all=https://jellyfin.example.com"]` + ''; + default = []; + }; RemoteIpFilter = mkOption { type = types.str; description = "Remote ip filter";