1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 00:11:17 +02:00

Backport 'nix dev-shell' from the flakes branch

This also adds a '--profile' option to 'nix build' (replacing 'nix-env
--set').
This commit is contained in:
Eelco Dolstra 2020-03-30 19:14:17 +02:00
parent 367577d9a6
commit e1a94ad852
9 changed files with 569 additions and 116 deletions

View file

@ -478,6 +478,17 @@ Path createTempDir(const Path & tmpRoot, const Path & prefix,
}
std::pair<AutoCloseFD, Path> createTempFile(const Path & prefix)
{
Path tmpl(getEnv("TMPDIR").value_or("/tmp") + "/" + prefix + ".XXXXXX");
// Strictly speaking, this is UB, but who cares...
AutoCloseFD fd(mkstemp((char *) tmpl.c_str()));
if (!fd)
throw SysError("creating temporary file '%s'", tmpl);
return {std::move(fd), tmpl};
}
std::string getUserName()
{
auto pw = getpwuid(geteuid());