From 709ab63d5adb0abb9ce00a9629efa4f0db404eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandra=20=C3=98stermark?= Date: Wed, 12 Nov 2025 19:55:42 +0100 Subject: [PATCH] preserve env var yaml tags for recyclarr config --- nixarr/recyclarr/default.nix | 46 +++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/nixarr/recyclarr/default.nix b/nixarr/recyclarr/default.nix index d65da17..d69fc9a 100644 --- a/nixarr/recyclarr/default.nix +++ b/nixarr/recyclarr/default.nix @@ -8,7 +8,51 @@ with lib; let cfg = config.nixarr.recyclarr; globals = config.util-nixarr.globals; nixarr = config.nixarr; - format = pkgs.formats.yaml {}; + yamlGenerator = {preserved-tags ? []}: let + selectors = + pkgs.lib.strings.concatStringsSep "/" + (builtins.map (x: '' + with((.. | select(kind == "scalar") | select(test("^!${x} .*"))); . = sub("!${x} ", "") | . tag="!${x}") + '')) + preserved-tags; + in { + generate = name: value: + pkgs.callPackage ( + { + runCommand, + yq-go, + }: + runCommand name + { + nativeBuildInputs = [yq-go]; + value = builtins.toJSON value; + passAsFile = ["value"]; + preferLocalBuild = true; + } + '' + yq '${selectors}' "$valuePath" -o yaml > $out + '' + ) {}; + type = let + baseType = pkgs.lib.types.oneOf [ + pkgs.lib.types.bool + pkgs.lib.types.int + pkgs.lib.types.float + pkgs.lib.types.float + (pkgs.lib.types.attrsOf valueType) + (pkgs.lib.types.listOf valueType) + ]; + valueType = + (pkgs.lib.types.nullOr baseType) + // { + description = "Yaml value"; + }; + in + valueType; + }; + format = yamlGenerator { + preserved-tags = ["env_var"]; + }; # Generate configuration file from Nix attribute set if provided generatedConfigFile = format.generate "recyclarr-config.yml" cfg.configuration;