From 5fd47f0f8ffba9ef78c57049d235f655820babcc Mon Sep 17 00:00:00 2001 From: hotburger <33610620+hotburger@users.noreply.github.com> Date: Thu, 9 Oct 2025 14:15:52 -0700 Subject: [PATCH] nixos/searx: use types from pkgs.formats --- nixos/modules/services/networking/searx.nix | 30 ++++++--------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/nixos/modules/services/networking/searx.nix b/nixos/modules/services/networking/searx.nix index 16dec56fd3d9..da2f6c970321 100644 --- a/nixos/modules/services/networking/searx.nix +++ b/nixos/modules/services/networking/searx.nix @@ -20,13 +20,13 @@ let runDir = "/run/searx"; cfg = config.services.searx; + yamlFormat = pkgs.formats.yaml { }; + tomlFormat = pkgs.formats.toml { }; - settingsFile = pkgs.writeText "settings.yml" ( - builtins.toJSON (removeAttrs cfg.settings [ "redis" ]) - ); + settingsFile = yamlFormat.generate "settings.yml" (builtins.removeAttrs cfg.settings [ "redis" ]); - faviconsSettingsFile = (pkgs.formats.toml { }).generate "favicons.toml" cfg.faviconsSettings; - limiterSettingsFile = (pkgs.formats.toml { }).generate "limiter.toml" cfg.limiterSettings; + faviconsSettingsFile = tomlFormat.generate "favicons.toml" cfg.faviconsSettings; + limiterSettingsFile = tomlFormat.generate "limiter.toml" cfg.limiterSettings; generateConfig = '' cd ${runDir} @@ -37,20 +37,6 @@ let ${pkgs.envsubst}/bin/envsubst < ${settingsFile} > settings.yml ) ''; - - settingType = - with types; - (oneOf [ - bool - int - float - str - (listOf settingType) - (attrsOf settingType) - ]) - // { - description = "JSON value"; - }; in { options = { @@ -115,7 +101,7 @@ in lib.warn "Obsolete option `services.searx.settings.redis' is used. It was renamed to `services.searx.settings.valkey'" config.redis ); - freeformType = settingType; + freeformType = yamlFormat.type; } ); default = { }; @@ -162,7 +148,7 @@ in }; faviconsSettings = mkOption { - type = types.attrsOf settingType; + type = types.attrsOf tomlFormat.type; default = { }; example = literalExpression '' { @@ -190,7 +176,7 @@ in }; limiterSettings = mkOption { - type = types.attrsOf settingType; + type = types.attrsOf tomlFormat.type; default = { }; example = literalExpression '' {