1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 06:01:48 +02:00

More comment rewording as requested

Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
This commit is contained in:
John Ericson 2024-10-09 10:58:44 -04:00
parent f7db612e8b
commit 0db8ff820b
3 changed files with 9 additions and 7 deletions

View file

@ -13,11 +13,12 @@ fs::path getNixBin(std::optional<std::string_view> binaryNameOpt)
{
auto getBinaryName = [&] { return binaryNameOpt ? *binaryNameOpt : "nix"; };
// If the environment variable is set, use it unconditionally
// If the environment variable is set, use it unconditionally.
if (auto envOpt = getEnvNonEmpty("NIX_BIN_DIR"))
return fs::path{*envOpt} / std::string{getBinaryName()};
// Use some-times avaiable OS tricks to get to the path of this Nix, and try that
// Try OS tricks, if available, to get to the path of this Nix, and
// see if we can find the right executable next to that.
if (auto selfOpt = getSelfExe()) {
fs::path path{*selfOpt};
if (binaryNameOpt)

View file

@ -17,9 +17,9 @@ namespace nix {
* Instead, we'll query the OS for the path to the current executable,
* using `getSelfExe()`.
*
* As a last resort, we resort to `PATH`. Hopefully we find a `nix`
* there that's compatible. If you're porting Nix to a new platform,
* that might be good enough for a while, but you'll want to improve
* As a last resort, we rely on `PATH`. Hopefully we find a `nix` there
* that's compatible. If you're porting Nix to a new platform, that
* might be good enough for a while, but you'll want to improve
* `getSelfExe()` to work on your platform.
*
* @param binary_name the exact binary name we're looking up. Might be