fix(tvix/config): properly handle nonexistent config files
If the global nix config, or any available user nix config location, does not exist, then the loadConfFile() function will throw and not finish initalizing the Nix configuration. Change-Id: I6db83bca54d9b66699356d107720603476e32c23 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1657 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
parent
b76cd7253a
commit
290df663af
1 changed files with 7 additions and 2 deletions
9
third_party/nix/src/libstore/globals.cc
vendored
9
third_party/nix/src/libstore/globals.cc
vendored
|
@ -1,6 +1,7 @@
|
|||
#include "libstore/globals.hh"
|
||||
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <thread>
|
||||
|
||||
|
@ -70,7 +71,9 @@ Settings::Settings()
|
|||
}
|
||||
|
||||
void loadConfFile() {
|
||||
globalConfig.applyConfigFile(settings.nixConfDir + "/nix.conf");
|
||||
if (std::filesystem::exists(settings.nixConfDir + "/nix.conf")) {
|
||||
globalConfig.applyConfigFile(settings.nixConfDir + "/nix.conf");
|
||||
}
|
||||
|
||||
/* We only want to send overrides to the daemon, i.e. stuff from
|
||||
~/.nix/nix.conf or the command line. */
|
||||
|
@ -80,7 +83,9 @@ void loadConfFile() {
|
|||
// Iterate over them in reverse so that the ones appearing first in the path
|
||||
// take priority
|
||||
for (auto dir = dirs.rbegin(); dir != dirs.rend(); dir++) {
|
||||
globalConfig.applyConfigFile(*dir + "/nix/nix.conf");
|
||||
if (std::filesystem::exists(*dir + "/nix.conf")) {
|
||||
globalConfig.applyConfigFile(*dir + "/nix/nix.conf");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue