nix-community / impermanence

Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz]
MIT License
1.03k stars 77 forks source link

Make bash scripts work in cross-compiled environments. #100

Closed plietar closed 1 year ago

plietar commented 2 years ago

When cross-compiling, patchShebangs requires the host platform's bash to be present in the HOST_PATH environment variable. However, when using pkgs.runCommand, only the build platform's bash is added to the PATH. The result is that the shebang is not replaced, and the script fails to run because the activation scripts don't have bash in their environment.

Using an explicit mkDerivation lets us add the host bash as a buildInput, which makes patchShebangs work as expected.

For context, I'm using impermanence on a Raspberry Pi 0. Since no binary cache exists for that platform, I cross-compile the entire OS and configuration from an x86_64 host and only push the resulting closure.

plietar commented 1 year ago

I'd completely missed the fact that runCommand accepts the usual derivation attributes. Should be good now.

talyz commented 1 year ago

Thanks!