Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/libcmd/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,12 @@ ProcessLineResult NixRepl::processLine(std::string line)
// runProgram redirects stdout to a StringSink,
// using runProgram2 to allow editors to display their UI
runProgram2({
.program = editor,
.lookupPath = true,
.args = std::move(args),
.spawnOptions =
{
.program = editor,
.lookupPath = true,
.args = std::move(args),
},
.isInteractive = true,
});

Expand Down
2 changes: 1 addition & 1 deletion src/libfetchers/git-lfs-fetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ LfsApiInfo getLfsApi(ParsedURL url)
args.push_back(string_to_os_string(url.renderPath(/*encode=*/false)));
args.push_back(OS_STR("download"));

auto [status, output] = runProgram({.program = "ssh", .args = args});
auto [status, output] = runProgram({{.program = "ssh", .args = args}});
Comment thread
philiptaron marked this conversation as resolved.

if (output.empty())
throw Error(
Expand Down
30 changes: 20 additions & 10 deletions src/libfetchers/git-utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,14 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
gitArgs.push_back(string_to_os_string(url));
gitArgs.push_back(string_to_os_string(refspec));

auto status = runProgram({.program = GIT_PROGRAM, .args = gitArgs, .isInteractive = true}).first;
auto [status, _] = runProgram({
.spawnOptions =
{
.program = GIT_PROGRAM,
.args = gitArgs,
},
.isInteractive = true,
});

if (status > 0)
throw Error("Failed to fetch git repository '%s'", url);
Expand Down Expand Up @@ -791,15 +798,18 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>

// Run verification command
auto [status, output] = runProgram({
.program = GIT_PROGRAM,
.args{
OS_STR("-c"),
OS_STR("gpg.ssh.allowedSignersFile=") + allowedSignersFile.native(),
OS_STR("-C"),
path.native(),
OS_STR("verify-commit"),
string_to_os_string(rev.gitRev()),
},
.spawnOptions =
{
.program = GIT_PROGRAM,
.args{
OS_STR("-c"),
OS_STR("gpg.ssh.allowedSignersFile=") + allowedSignersFile.native(),
OS_STR("-C"),
path.native(),
OS_STR("verify-commit"),
string_to_os_string(rev.gitRev()),
},
},
.mergeStderrToStdout = true,
});

Expand Down
29 changes: 16 additions & 13 deletions src/libfetchers/git.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ std::optional<std::string> readHead(const std::filesystem::path & path)
{
auto [status, output] = runProgram(
RunOptions{
.program = GIT_PROGRAM,
// FIXME: use 'HEAD' to avoid returning all refs
.args = {OS_STR("ls-remote"), OS_STR("--symref"), path.native()},
.spawnOptions =
{
.program = GIT_PROGRAM,
// FIXME: use 'HEAD' to avoid returning all refs
.args = {OS_STR("ls-remote"), OS_STR("--symref"), path.native()},
},
.isInteractive = true,
});
if (status != 0)
Expand Down Expand Up @@ -501,16 +504,16 @@ struct GitInputScheme : InputScheme

auto result = runProgram(
RunOptions{
.program = GIT_PROGRAM,
.args{
OS_STR("-C"),
repoPath->native(),
OS_STR("--git-dir"),
string_to_os_string(repoInfo.gitDir),
OS_STR("check-ignore"),
OS_STR("--quiet"),
string_to_os_string(std::string(path.rel())),
},
{.program = GIT_PROGRAM,
.args{
OS_STR("-C"),
repoPath->native(),
OS_STR("--git-dir"),
string_to_os_string(repoInfo.gitDir),
OS_STR("check-ignore"),
OS_STR("--quiet"),
string_to_os_string(std::string(path.rel())),
}},
});
auto exitCode =
#ifndef WIN32 // TODO abstract over exit status handling on Windows
Expand Down
7 changes: 6 additions & 1 deletion src/libfetchers/mercurial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ static RunOptions hgOptions(OsStrings args)
// Set HGPLAIN: this means we get consistent output from hg and avoids leakage from a user or system .hgrc.
env[OS_STR("HGPLAIN")] = OS_STR("");

return {.program = HG_PROGRAM, .lookupPath = true, .args = std::move(args), .environment = env};
return {{
.program = HG_PROGRAM,
.lookupPath = true,
.args = std::move(args),
.environment = env,
}};
}

// runProgram wrapper that uses hgOptions instead of stock RunOptions.
Expand Down
2 changes: 1 addition & 1 deletion src/libmain/shared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ RunPager::RunPager()
return;

/* TODO re-enable on Windows, once a child can be given our pipe as its
stdin: `RunOptions` has no `standardIn`, and `spawnProcess` hardcodes a
stdin: `RunOptions` has no `standardIn`, and `spawnProgram` hardcodes a
null one. Printing unpaged beats failing the command. */
#ifdef _WIN32
return;
Expand Down
14 changes: 8 additions & 6 deletions src/libstore/build/derivation-builder-impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ static void handleDiffHook(
try {
auto diffRes = runProgram(
RunOptions{
.program = diffHook,
.lookupPath = true,
.args = {tryA, tryB, drvPath, tmpDir},
.spawnOptions =
{.program = diffHook,
.lookupPath = true,
.args = {tryA, tryB, drvPath, tmpDir},
#ifndef _WIN32
.uid = uid,
.gid = gid,
.uid = uid,
.gid = gid,
#endif
.chdir = "/"});
.chdir = "/"},
});
if (!statusOk(diffRes.first))
throw ExecError(diffRes.first, "diff-hook program %s %s", PathFmt(diffHook), statusToString(diffRes.first));

Expand Down
4 changes: 2 additions & 2 deletions src/libstore/build/derivation-building-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,8 @@ Goal::Co DerivationBuildingGoal::buildLocally(
if (worker.settings.postBuildHook.get() != "") {
#ifdef _WIN32
/* Nothing here needs `fork`: the child only sets the environment,
redirects stdout/stderr and execs, which `spawnProcess` already
does. What is missing is that `spawnProcess` is not exported,
redirects stdout/stderr and execs, which `spawnProgram` already
does. What is missing is that `spawnProgram` is not exported,
and that the worker needs an `AsyncPipe` tied to the completion
port rather than the plain `Pipe` this produces. Throw rather
than silently skip the hook. */
Expand Down
2 changes: 0 additions & 2 deletions src/libstore/include/nix/store/ssh.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ private:
void addCommonSSHOpts(OsStrings & args);
bool isMasterRunning();

#ifndef _WIN32 // TODO re-enable on Windows, once we can fork.
std::filesystem::path startMaster();
#endif

public:

Expand Down
Loading
Loading