From d8cb98b5156011db1ceb4773ed4713c91804d4bc Mon Sep 17 00:00:00 2001 From: Jared Baur Date: Fri, 26 Dec 2025 22:29:42 -0800 Subject: [PATCH] nixos/knot-resolver: skip config validation when cross-compiling Since this module allows for customizing the manager package (which is also used for config validation) as opposed to pulling the build-platform compatible variant from the package-set, we cannot assume this package is capable of being executed on the build platform. --- .../services/networking/knot-resolver.nix | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/networking/knot-resolver.nix b/nixos/modules/services/networking/knot-resolver.nix index 96b39745a02f..9574859293d1 100644 --- a/nixos/modules/services/networking/knot-resolver.nix +++ b/nixos/modules/services/networking/knot-resolver.nix @@ -7,17 +7,28 @@ let cfg = config.services.knot-resolver; # pkgs.writers.yaml_1_1.generate with additional kresctl validate - configFile = - pkgs.runCommandLocal "knot-resolver.yaml" + configFile = pkgs.callPackage ( + { + runCommandLocal, + remarshal_0_17, + stdenv, + }: + runCommandLocal "knot-resolver.yaml" { - nativeBuildInputs = [ pkgs.remarshal_0_17 ]; + nativeBuildInputs = [ remarshal_0_17 ]; value = builtins.toJSON cfg.settings; passAsFile = [ "value" ]; } '' json2yaml "$valuePath" "$out" - ${cfg.managerPackage}/bin/kresctl validate "$out" - ''; + ${ + # We skip validation if the build platform cannot execute # the binary targeting the host platform. + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + ${cfg.managerPackage}/bin/kresctl validate "$out" + '' + } + '' + ) { }; in { meta.maintainers = [