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