From 2d2cef06136b00fad0048ab87a3992b9d4a109cc Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Fri, 31 Oct 2025 17:36:59 +0100 Subject: [PATCH 1/2] haskellPackages.nix-paths: provide pkgs.nix for libraryToolDepends --- .../haskell-modules/configuration-common.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index 985ea3165e3d5..215812ba99a87 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -652,6 +652,16 @@ with haskellLib; # https://github.com/awakesecurity/nix-graph/issues/5 nix-graph = doJailbreak super.nix-graph; + # Pass in `pkgs.nix` for the required tools. This means that overriding + # them sort of works, but only if you override all instances. + nix-paths = super.nix-paths.override { + nix-build = pkgs.nix; + nix-env = pkgs.nix; + nix-hash = pkgs.nix; + nix-instantiate = pkgs.nix; + nix-store = pkgs.nix; + }; + # Fix `mv` not working on directories turtle = appendPatches [ (pkgs.fetchpatch { From 966cfdba11af513502b4874b2f6a1024ec418449 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Fri, 31 Oct 2025 17:41:13 +0100 Subject: [PATCH 2/2] haskellPackages.nix-paths:don't use build tools when cross compiling Using build-tools is somewhat flawed since it relies on the host tools being executable at build time which is not always the case, e.g. when cross-compiling. The simplest solution (patching being the alternative) is to simply use the flag that makes nix-paths use PATH at runtime. --- .../haskell-modules/configuration-common.nix | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index 215812ba99a87..1523e9b8f6998 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -654,13 +654,28 @@ with haskellLib; # Pass in `pkgs.nix` for the required tools. This means that overriding # them sort of works, but only if you override all instances. - nix-paths = super.nix-paths.override { - nix-build = pkgs.nix; - nix-env = pkgs.nix; - nix-hash = pkgs.nix; - nix-instantiate = pkgs.nix; - nix-store = pkgs.nix; - }; + nix-paths = + if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then + super.nix-paths.override { + nix-build = pkgs.nix; + nix-env = pkgs.nix; + nix-hash = pkgs.nix; + nix-instantiate = pkgs.nix; + nix-store = pkgs.nix; + } + else + # When cross-compiling, nix-paths won't be able to detect + # the path to the (host) tools at build time from PATH, + # so we instruct it to check at runtime. + enableCabalFlag "allow-relative-paths" ( + super.nix-paths { + nix-build = null; + nix-env = null; + nix-hash = null; + nix-instantiate = null; + nix-store = null; + } + ); # Fix `mv` not working on directories turtle = appendPatches [