forked from LnL7/nix
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly scope
NIX_BIN_DIR
just to the nix CLI
It is no longer feasible to define it in libnixstore, and that's good.
- Loading branch information
1 parent
3519e78
commit 349a2ef
Showing
21 changed files
with
154 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "current-process.hh" | ||
#include "file-system.hh" | ||
#include "globals.hh" | ||
#include "bin-dir.hh" | ||
|
||
namespace nix { | ||
|
||
const Path & getNixBinDir() | ||
{ | ||
static const Path nixBinDir = canonPath(getEnvNonEmpty("NIX_BIN_DIR").value_or(NIX_BIN_DIR)); | ||
|
||
return nixBinDir; | ||
} | ||
|
||
void setNixBuildRemoteLocation() | ||
{ | ||
std::string nixExePath = getNixBinDir() + "/nix"; | ||
if (!pathExists(nixExePath)) { | ||
nixExePath = getSelfExe().value_or("nix"); | ||
} | ||
settings.buildHook = { | ||
nixExePath, | ||
"__build-remote", | ||
}; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
///@file | ||
|
||
#include "types.hh" | ||
|
||
namespace nix { | ||
|
||
/** | ||
* The directory where the main programs are stored. | ||
*/ | ||
const Path & getNixBinDir(); | ||
|
||
/** | ||
* @TODO update docs to match status quo, where NIX_BIN_DIR is not defined for libraries | ||
* | ||
* Set the build hook location | ||
* | ||
* For builds we perform a self-invocation, so Nix has to be self-aware. | ||
* That is, it has to know where it is installed. We don't think it's sentient. | ||
* | ||
* Normally, nix is installed according to `nixBinDir`, which is set at compile time, | ||
* but can be overridden. This makes for a great default that works even if this | ||
* code is linked as a library into some other program whose main is not aware | ||
* that it might need to be a build remote hook. | ||
* | ||
* However, it may not have been installed at all. For example, if it's a static build, | ||
* there's a good chance that it has been moved out of its installation directory. | ||
* That makes `nixBinDir` useless. 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 `getSelfExe()` to work on your platform. | ||
*/ | ||
void setNixBuildRemoteLocation(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.