This commit is contained in:
parent
73230ab0cd
commit
052f734a96
|
@ -15,4 +15,4 @@ jobs:
|
|||
|
||||
- name: nix flake check
|
||||
run: |
|
||||
nix flake check --show-trace
|
||||
nix flake check --show-trace --print-build-logs
|
||||
|
|
|
@ -22,14 +22,16 @@ in
|
|||
mkIf cfg.enable
|
||||
(
|
||||
let
|
||||
isStrList = x: builtins.all (x: builtins.isString x) x;
|
||||
prepass = x:
|
||||
if (builtins.isAttrs x)
|
||||
then
|
||||
if !(builtins.hasAttr "tag" x)
|
||||
then
|
||||
attrsets.mapAttrsToList (tag: value: {
|
||||
attrsets.mapAttrsToList
|
||||
(tag: value: {
|
||||
inherit tag;
|
||||
content = value;
|
||||
content = prepass value;
|
||||
})
|
||||
x
|
||||
else if (builtins.hasAttr "content" x)
|
||||
|
@ -39,8 +41,16 @@ in
|
|||
}
|
||||
else x
|
||||
else if (builtins.isList x)
|
||||
then builtins.map prepass x
|
||||
else throw "wtf";
|
||||
then
|
||||
if (isStrList x)
|
||||
then
|
||||
(builtins.map (content: {
|
||||
tag = "string";
|
||||
inherit content;
|
||||
})
|
||||
x)
|
||||
else builtins.map prepass x
|
||||
else x;
|
||||
|
||||
toXml = tag: x: (toXml' {
|
||||
inherit tag;
|
||||
|
@ -48,19 +58,21 @@ in
|
|||
"xmlns:xsi" = "http://www.w3.org/2001/XMLSchema-instance";
|
||||
"xmlns:xsd" = "http://www.w3.org/2001/XMLSchema";
|
||||
};
|
||||
content = x;
|
||||
content = prepass x;
|
||||
});
|
||||
in {
|
||||
system.activationScripts."link-network-xml" = lib.stringAfter ["var"] (
|
||||
let
|
||||
content = toXml "NetworkConfiguration" (prepass cfg.network);
|
||||
in ''
|
||||
mkdir -p /var/lib/jellyfin/config
|
||||
if [ ! -f "/var/lib/jellyfin/config/network.xml" ]; then
|
||||
echo '${strings.escape ["'"] content}' > /var/lib/jellyfin/config/network.xml
|
||||
fi
|
||||
''
|
||||
);
|
||||
system.activationScripts."link-network-xml" =
|
||||
lib.stringAfter ["var"]
|
||||
(
|
||||
let
|
||||
storeFile = pkgs.writeText "network.xml" (toXml "NetworkConfiguration" cfg.network);
|
||||
in ''
|
||||
echo "[Declarative Jellyfin] Creating /var/lib/jellyfin/config"
|
||||
mkdir -p "/var/lib/jellyfin/config"
|
||||
echo "[Declarative Jellyfin] Linking ${storeFile} to /var/lib/jellyfin/config/network.xml"
|
||||
cp -s "${storeFile}" "/var/lib/jellyfin/config/network.xml"
|
||||
''
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ in {
|
|||
../modules/default.nix
|
||||
];
|
||||
|
||||
virtualisation.memorySize = 1024;
|
||||
virtualisation.memorySize = 1024 * 2;
|
||||
|
||||
services.declarative-jellyfin = {
|
||||
enable = true;
|
||||
|
@ -28,24 +28,31 @@ in {
|
|||
};
|
||||
|
||||
# stfu i dont care about python linting
|
||||
skipLint = true;
|
||||
# skipLint = true;
|
||||
|
||||
testScript = ''
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
machine.start()
|
||||
machine.wait_for_unit("multi-user.target");
|
||||
|
||||
with subtest("Jellyfin URI"):
|
||||
machine.succeed("ls /var/lib/jellyfin")
|
||||
tree = ET.parse("/var/lib/jellyfin/config/network.xml")
|
||||
# stupid fucking hack because you cant open files in python for some reason
|
||||
xml = machine.succeed("cat /var/lib/jellyfin/config/network.xml")
|
||||
tree = ET.ElementTree(ET.fromstring(xml))
|
||||
root = tree.getroot()
|
||||
found = False
|
||||
for child in root:
|
||||
if child.tag == "PublishedServerUriBySubnet":
|
||||
found = True
|
||||
print(child)
|
||||
assert False
|
||||
try:
|
||||
if child[0].text == "all=https://test.test.test":
|
||||
break
|
||||
except:
|
||||
print("An error occured when trying to parse xml")
|
||||
print(xml)
|
||||
assert False, "Exception occured, check output above"
|
||||
else:
|
||||
assert False, "The shit was not found"
|
||||
|
||||
machine.shutdown()
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue