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:
parent
367577d9a6
commit
e1a94ad852
9 changed files with 569 additions and 116 deletions
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue