Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 87157b2bd322
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e845d19ae368
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Oct 9, 2020

  1. Remove Lazy

    This fixes a crash during startup when compiling Nix as a single
    compilation unit.
    edolstra committed Oct 9, 2020
    Copy the full SHA
    e845d19 View commit details
Showing with 18 additions and 64 deletions.
  1. +0 −48 src/libutil/lazy.hh
  2. +18 −16 src/libutil/util.cc
48 changes: 0 additions & 48 deletions src/libutil/lazy.hh

This file was deleted.

34 changes: 18 additions & 16 deletions src/libutil/util.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "lazy.hh"
#include "util.hh"
#include "affinity.hh"
#include "sync.hh"
@@ -522,21 +521,24 @@ std::string getUserName()
}


static Lazy<Path> getHome2([]() {
auto homeDir = getEnv("HOME");
if (!homeDir) {
std::vector<char> buf(16384);
struct passwd pwbuf;
struct passwd * pw;
if (getpwuid_r(geteuid(), &pwbuf, buf.data(), buf.size(), &pw) != 0
|| !pw || !pw->pw_dir || !pw->pw_dir[0])
throw Error("cannot determine user's home directory");
homeDir = pw->pw_dir;
}
return *homeDir;
});

Path getHome() { return getHome2(); }
Path getHome()
{
static Path homeDir = []()
{
auto homeDir = getEnv("HOME");
if (!homeDir) {
std::vector<char> buf(16384);
struct passwd pwbuf;
struct passwd * pw;
if (getpwuid_r(geteuid(), &pwbuf, buf.data(), buf.size(), &pw) != 0
|| !pw || !pw->pw_dir || !pw->pw_dir[0])
throw Error("cannot determine user's home directory");
homeDir = pw->pw_dir;
}
return *homeDir;
}();
return homeDir;
}


Path getCacheDir()