From 93d523cb03f9b5816aa79053dbdd2ff3110c37ed Mon Sep 17 00:00:00 2001 From: David McFarland Date: Thu, 9 Oct 2025 10:25:12 -0300 Subject: [PATCH] file: fix cross build for windows platforms This should be a more general fix than the original windows one. This is needed because upstream uses `EXEEXT` for build stuff: # FIXME: Build file natively as well so that it can be used to compile # the target's magic file; for now we bail if the local version does not match if IS_CROSS_COMPILE FILE_COMPILE = file${EXEEXT} FILE_COMPILE_DEP = else FILE_COMPILE = $(top_builddir)/src/file${EXEEXT} FILE_COMPILE_DEP = $(FILE_COMPILE) endif --- pkgs/tools/misc/file/default.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/tools/misc/file/default.nix b/pkgs/tools/misc/file/default.nix index c96214519966..34f58c1f92a8 100644 --- a/pkgs/tools/misc/file/default.nix +++ b/pkgs/tools/misc/file/default.nix @@ -2,7 +2,7 @@ lib, stdenv, fetchurl, - file, + buildPackages, zlib, libgnurx, updateAutotoolsGnuConfigScriptsHook, @@ -51,14 +51,16 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook - ] - ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) file; + ]; buildInputs = [ zlib ] ++ lib.optional stdenv.hostPlatform.isMinGW libgnurx; # https://bugs.astron.com/view.php?id=382 doCheck = !stdenv.buildPlatform.isMusl; - makeFlags = lib.optional stdenv.hostPlatform.isWindows "FILE_COMPILE=file"; + # In native builds, it will use the newly-compiled file instead. + makeFlags = lib.optional ( + !lib.systems.equals stdenv.hostPlatform stdenv.buildPlatform + ) "FILE_COMPILE=${lib.getExe buildPackages.file}"; passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;