nix-community / nix-ld-rs

Run unpatched dynamic binaries on NixOS [maintainer=@zhaofengli @Mic92]
MIT License
141 stars 0 forks source link

Config File Support #5

Open rickvanprim opened 9 months ago

rickvanprim commented 9 months ago

I'm trying to see if I can get bazelisk working in a Nix (container) environment for https://github.com/bazelbuild/continuous-integration/pull/1799 and I'm running into an issue where Bazel (and many executables it launches) run fine with nix-ld-rs (it gets past the child process issue that nix-ld has) but in some cases Bazel insists on running a child process with a clean environment and hard-coded PATH.

I think the nixpkgs version of Bazel patches out this behavior, if I'm interpreting this correctly (https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/build-managers/bazel/nix-hacks.patch). If nix-ld-rs could fall back to reading /etc/nix-ld.conf (for example) to get the values for NIX_LD and NIX_LD_LIBRARY_PATH, that would work around this particular case.

I'm assuming not having config file support is a pretty deliberate choice for a reason I'm not considering. If not and this functionality would be a good addition, I'd be happy to take a stab at a PR.

Mic92 commented 2 months ago

I didn't added a configuration file in nix-ld, because it was a bit of a pain to achieve this without libc. In nix-ld-rs this should be easier now. However should only support system or user level configuration and not look up files in projects i.e. .nix-ld.conf. The latter one is a security risk as it allows code execution - except if we would allow to define safe prefixes like git or gdb does.