From 33a30b1d2a1ed29486dc35255172cd77a4cb277e Mon Sep 17 00:00:00 2001 From: Snorre Ettrup Altschul Date: Fri, 4 Apr 2025 00:53:14 +0200 Subject: [PATCH] fixed shit --- modules/config.nix | 15 ++++++++++----- modules/options/default.nix | 29 ++++++++++++----------------- modules/options/system.nix | 10 +++++----- tests/xml.nix | 37 +++++++++++++++++-------------------- 4 files changed, 44 insertions(+), 47 deletions(-) diff --git a/modules/config.nix b/modules/config.nix index a25cebe..a39998b 100644 --- a/modules/config.nix +++ b/modules/config.nix @@ -1,10 +1,12 @@ { config, lib, + pkgs, ... }: with lib; let cfg = config.services.declarative-jellyfin; + toXml' = (import ../lib {nixpkgs = pkgs;}).toXMLGeneric; isStrList = x: builtins.all (x: builtins.isString x) x; prepass = x: if (builtins.isAttrs x) @@ -45,6 +47,9 @@ with lib; let content = prepass x; }); in { + imports = [ + ./options + ]; config = mkIf cfg.enable { @@ -63,11 +68,11 @@ in { file = "network.xml"; content = cfg.network; } - { - name = "EncodingOptions"; - file = "encoding.xml"; - content = cfg.encoding; - } + # { + # name = "EncodingOptions"; + # file = "encoding.xml"; + # content = cfg.encoding; + # } { name = "ServerConfiguration"; file = "system.xml"; diff --git a/modules/options/default.nix b/modules/options/default.nix index 37d014b..63bface 100644 --- a/modules/options/default.nix +++ b/modules/options/default.nix @@ -1,20 +1,15 @@ { - config, - pkgs, lib, ... -}: let - cfg = config.services.declarative-jellyfin; - toXml' = (import ../../lib {nixpkgs = pkgs;}).toXMLGeneric; -in - with lib; { - imports = [ - ./system.nix - ./encoding.nix - ./network.nix - ./branding.nix - ]; - options.services.declarative-jellyfin = { - enable = mkEnableOption "Jellyfin Service"; - }; - } +}: +with lib; { + imports = [ + ./system.nix + ./encoding.nix + ./network.nix + ./branding.nix + ]; + options.services.declarative-jellyfin = { + enable = mkEnableOption "Jellyfin Service"; + }; +} diff --git a/modules/options/system.nix b/modules/options/system.nix index 0095e23..209c64e 100644 --- a/modules/options/system.nix +++ b/modules/options/system.nix @@ -4,7 +4,7 @@ ... }: with lib; let - mkStrOption = default: description: { + mkStrOption = default: description: mkOption { type = types.str; inherit default description; }; @@ -335,20 +335,20 @@ in { default = true; }; - SlowResponseThresholdMs = { + SlowResponseThresholdMs = mkOption { type = types.int; default = 500; description = "How slow (in ms) would a response have to be before a warning is shown"; }; - CorsHosts = { + CorsHosts = mkOption { type = with types; listOf str; default = [ "*" ]; }; - ActivityLogRetentionDays = { + ActivityLogRetentionDays = mkOption { type = types.int; default = 30; }; @@ -410,7 +410,7 @@ in { ParallelImageEncodingLimit = mkOption { type = types.int; default = 0; - descriptio = '' + description = '' Maximum number of image encodings that are allowed to run in parallel. Setting this to 0 will choose a limit based on your systems core count. ''; diff --git a/tests/xml.nix b/tests/xml.nix index 908219a..057ef8f 100644 --- a/tests/xml.nix +++ b/tests/xml.nix @@ -14,26 +14,23 @@ in { ../modules/default.nix ]; - # assertions = let - # toXml = (import ../lib {nixpkgs = pkgs;}).toXMLGeneric; - # in [ - # { - # assertion = - # toXml {tag = "test";} - # == '' - # - # - # - # ''; - # message = "Generated XML is incorrect!"; - # } - # { - # assertion = false; - # message = "lmao"; - # } - # ]; - - ass = false; + assertions = let + toXml = (import ../lib {nixpkgs = pkgs;}).toXMLGeneric; + in [ + ( + let + xml = + toXml {tag = "test";}; + expected = '' + + + ''; + in { + assertion = xml == expected; + message = "Generated XML is incorrect!\nExpected \n\n${expected}\n\n but got \n\n${xml}\n"; + } + ) + ]; virtualisation.memorySize = 1024 * 2;