Sorry, my apologies, i wrote this up to replay to your originally post, but accidentally deleted it. I will try to address all your questions here.
Not clear what you mean by “a nix environment”.
To answer your original question about the environment. (Pardon incorrect terminology). I have a base OS of Ubuntu 22.04. I have multi-user nix installed on top of Ubuntu. I enter the source directory and source/prep the build environment using the following command:
nix flake --experimental-features 'nix-command flakes'. This project is based on buildroot, and if you’re nor familiar with buildroot, the build process involves many scripts and checkouts from other repos during the build process, so it is difficult to patch files once the build process has started (at least to my knowledge).
Is this part of a nix build, or in a nix-shell/nix shell?
I presume the latter, nix-shell/shell since it uses flakes, but not 100% sure on the terminology. I am running
nix flake not
Is the flake public (and if so can we have a link)?
The flake is not public, i might be able to trim it down by using a trivial buildroot project.
What exact code are you using to replace the /bin/sh shebang?
The process i currently run to get around this shebang issue: I let the process build as normal. At some point it fails with
/bin/sh: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_ABI_DT_RELR’ not found (required by /nix/store/ylaxayp4xlq28x6iv3l05gnl3s5dxmr9-glibc-2.37-8/lib/libdl.so.2)
I believe this happens b/c
fs/common.mk:75 in buildroot generates a script to run
fakeroot, and that script calls
#!/bin/sh directly which then casues issues. The workaround is to find the
sh installed by nix, so i run the following while in the
nix flake env:
» which sh
I edit the
fs/common.mk file and replace
I re-run the build process, and everything builds, links and it happy.
Other Notes: This process runs fine without the workaround if the native OS is NixOS since you can symlink
I hope this gives more insight into the environment and process. apologies for not be more clear about it previously.