refactor(tvix): getEnv(): Return std::optional
This allows distinguishing between an empty value and no value.
Patch ported from upstream at
ba87b08f85
Change-Id: I061cc8e16b1a7a0341adfc3b0edca1c0c51d5c97
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1884
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
This commit is contained in:
parent
c5f3b12f04
commit
785cb3a754
17 changed files with 66 additions and 66 deletions
10
third_party/nix/src/nix-build/nix-build.cc
vendored
10
third_party/nix/src/nix-build/nix-build.cc
vendored
|
|
@ -377,9 +377,12 @@ static void _main(int argc, char** argv) {
|
|||
/* Figure out what bash shell to use. If $NIX_BUILD_SHELL
|
||||
is not set, then build bashInteractive from
|
||||
<nixpkgs>. */
|
||||
auto shell = getEnv("NIX_BUILD_SHELL", "");
|
||||
auto opt_shell = getEnv("NIX_BUILD_SHELL");
|
||||
std::string shell;
|
||||
|
||||
if (shell.empty()) {
|
||||
if (opt_shell.has_value()) {
|
||||
shell = opt_shell.value();
|
||||
} else {
|
||||
try {
|
||||
auto expr = state->parseExprFromString(
|
||||
"(import <nixpkgs> {}).bashInteractive", absPath("."));
|
||||
|
|
@ -427,7 +430,8 @@ static void _main(int argc, char** argv) {
|
|||
// Set the environment.
|
||||
auto env = getEnv();
|
||||
|
||||
auto tmp = getEnv("TMPDIR", getEnv("XDG_RUNTIME_DIR", "/tmp"));
|
||||
auto tmp =
|
||||
getEnv("TMPDIR").value_or(getEnv("XDG_RUNTIME_DIR").value_or("/tmp"));
|
||||
|
||||
if (pure) {
|
||||
decltype(env) newEnv;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue