From f237e669f28dce343b7366523ef94fe4cf869b58 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 10 Aug 2022 17:54:09 +0200 Subject: Patch /usr/bin/file to file when on nixos (#30718) These changes make many packages build on nixos where nearly nothing comes from /bin or /usr/bin (the only things in "system locations" are /bin/sh and /usr/bin/env, all the rest is found through PATH). Many configuration scripts hardcode /usr/bin/file instead of using the one from PATH. This patches them to use file from PATH. --- lib/spack/spack/build_systems/autotools.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py index 0a9946a1c0..97b5e9ef51 100644 --- a/lib/spack/spack/build_systems/autotools.py +++ b/lib/spack/spack/build_systems/autotools.py @@ -238,6 +238,15 @@ To resolve this problem, please try the following: fs.copy(substitutes[name], abs_path) os.chmod(abs_path, mode) + @run_before("configure") + def _patch_usr_bin_file(self): + """On NixOS file is not available in /usr/bin/file. Patch configure + scripts to use file from path.""" + + if self.spec.os.startswith("nixos"): + for configure_file in fs.find(".", files=["configure"], recursive=True): + fs.filter_file("/usr/bin/file", "file", configure_file, string=True) + @run_before("configure") def _set_autotools_environment_variables(self): """Many autotools builds use a version of mknod.m4 that fails when -- cgit v1.2.3-70-g09d2