fixed lists of strings not being able to be converted to xml

This commit is contained in:
Snorre 2025-04-03 11:22:48 +02:00
parent 99595ddfb5
commit 14d83dafcd
2 changed files with 30 additions and 4 deletions

View file

@ -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}'
'');
''
);
}
);
}

View file

@ -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";