From 5fbd9fee0b4b26cc7bcceb350e56e808c7a70e8c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 31 May 2019 23:45:13 +0200 Subject: Add 'nix app' command This is like 'nix run', except that the command to execute is defined in a flake output, e.g. defaultApp = { type = "app"; program = "${packages.blender_2_80}/bin/blender"; }; Thus you can do $ nix app blender-bin to start Blender from the 'blender-bin' flake. In the future, we can extend this with sandboxing. (For example we would want to be able to specify that Blender should not have network access by default and should only have access to certain paths in the user's home directory.) --- src/nix/run.cc | 101 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 23 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 35b763345..00a682832 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -8,6 +8,7 @@ #include "fs-accessor.hh" #include "progress-bar.hh" #include "affinity.hh" +#include "eval.hh" #if __linux__ #include @@ -19,7 +20,44 @@ using namespace nix; std::string chrootHelperName = "__run_in_chroot"; -struct CmdRun : InstallablesCommand +struct RunCommon : virtual Command +{ + void runProgram(ref store, + const std::string & program, + const Strings & args) + { + stopProgressBar(); + + restoreSignals(); + + restoreAffinity(); + + /* If this is a diverted store (i.e. its "logical" location + (typically /nix/store) differs from its "physical" location + (e.g. /home/eelco/nix/store), then run the command in a + chroot. For non-root users, this requires running it in new + mount and user namespaces. Unfortunately, + unshare(CLONE_NEWUSER) doesn't work in a multithreaded + program (which "nix" is), so we exec() a single-threaded + helper program (chrootHelper() below) to do the work. */ + auto store2 = store.dynamic_pointer_cast(); + + if (store2 && store->storeDir != store2->realStoreDir) { + Strings helperArgs = { chrootHelperName, store->storeDir, store2->realStoreDir, program }; + for (auto & arg : args) helperArgs.push_back(arg); + + execv(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data()); + + throw SysError("could not execute chroot helper"); + } + + execvp(program.c_str(), stringsToCharPtrs(args).data()); + + throw SysError("unable to execute '%s'", program); + } +}; + +struct CmdRun : InstallablesCommand, RunCommon { std::vector command = { "bash" }; StringSet keep, unset; @@ -147,42 +185,59 @@ struct CmdRun : InstallablesCommand setenv("PATH", concatStringsSep(":", unixPath).c_str(), 1); - std::string cmd = *command.begin(); Strings args; for (auto & arg : command) args.push_back(arg); - stopProgressBar(); + runProgram(store, *command.begin(), args); + } +}; - restoreSignals(); +static RegisterCommand r1(make_ref()); - restoreAffinity(); +struct CmdApp : InstallableCommand, RunCommon +{ + CmdApp() + { + } - /* If this is a diverted store (i.e. its "logical" location - (typically /nix/store) differs from its "physical" location - (e.g. /home/eelco/nix/store), then run the command in a - chroot. For non-root users, this requires running it in new - mount and user namespaces. Unfortunately, - unshare(CLONE_NEWUSER) doesn't work in a multithreaded - program (which "nix" is), so we exec() a single-threaded - helper program (chrootHelper() below) to do the work. */ - auto store2 = store.dynamic_pointer_cast(); + std::string name() override + { + return "app"; + } - if (store2 && store->storeDir != store2->realStoreDir) { - Strings helperArgs = { chrootHelperName, store->storeDir, store2->realStoreDir, cmd }; - for (auto & arg : args) helperArgs.push_back(arg); + std::string description() override + { + return "run a Nix application"; + } - execv(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data()); + Examples examples() override + { + return { + Example{ + "To run Blender:", + "nix app blender-bin" + }, + }; + } - throw SysError("could not execute chroot helper"); - } + Strings getDefaultFlakeAttrPaths() override + { + return {"defaultApp"}; + } - execvp(cmd.c_str(), stringsToCharPtrs(args).data()); + void run(ref store) override + { + auto state = getEvalState(); + + auto app = installable->toApp(*state); - throw SysError("unable to exec '%s'", cmd); + state->realiseContext(app.context); + + runProgram(store, app.program, {app.program}); } }; -static RegisterCommand r1(make_ref()); +static RegisterCommand r2(make_ref()); void chrootHelper(int argc, char * * argv) { -- cgit v1.2.3 From 2467c9837500b26aab5c1dcd3cac12cda44898ca Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 17 Jun 2019 16:58:59 +0200 Subject: nix app: Search for installable in the 'apps' output I.e. you can write $ nix app blender-bin:blender_2_80 which is equivalent to $ nix app blender-bin:apps.blender_2_80 --- src/nix/run.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 00a682832..62aae12f6 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -225,6 +225,11 @@ struct CmdApp : InstallableCommand, RunCommon return {"defaultApp"}; } + Strings getDefaultFlakeAttrPathPrefixes() override + { + return {"apps."}; + } + void run(ref store) override { auto state = getEvalState(); -- cgit v1.2.3 From 0d69f7f3f012aceb4c494f3c1cc866b378c5eac1 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 17 Jun 2019 17:05:37 +0200 Subject: nix app: Accept arguments Example: $ nix app blender-bin -- --version Blender 2.80 (sub 74) --- src/nix/run.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 62aae12f6..d30851d47 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -196,8 +196,11 @@ static RegisterCommand r1(make_ref()); struct CmdApp : InstallableCommand, RunCommon { + std::vector args; + CmdApp() { + expectArgs("args", &args); } std::string name() override @@ -238,7 +241,10 @@ struct CmdApp : InstallableCommand, RunCommon state->realiseContext(app.context); - runProgram(store, app.program, {app.program}); + Strings allArgs{app.program}; + for (auto & i : args) allArgs.push_back(i); + + runProgram(store, app.program, allArgs); } }; -- cgit v1.2.3 From a0de58f471c9087d8e6cc60a6078f9940a125b15 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 18 Jun 2019 16:01:35 +0200 Subject: Make subcommand construction in MultiCommand lazy --- src/nix/run.cc | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index d30851d47..9c15b6749 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -99,11 +99,6 @@ struct CmdRun : InstallablesCommand, RunCommon .handler([&](std::vector ss) { unset.insert(ss.front()); }); } - std::string name() override - { - return "run"; - } - std::string description() override { return "run a shell in which the specified packages are available"; @@ -192,7 +187,7 @@ struct CmdRun : InstallablesCommand, RunCommon } }; -static RegisterCommand r1(make_ref()); +static auto r1 = registerCommand("run"); struct CmdApp : InstallableCommand, RunCommon { @@ -203,11 +198,6 @@ struct CmdApp : InstallableCommand, RunCommon expectArgs("args", &args); } - std::string name() override - { - return "app"; - } - std::string description() override { return "run a Nix application"; @@ -248,7 +238,7 @@ struct CmdApp : InstallableCommand, RunCommon } }; -static RegisterCommand r2(make_ref()); +static auto r2 = registerCommand("app"); void chrootHelper(int argc, char * * argv) { -- cgit v1.2.3 From 7d38060a0da2698052e84a0cfee422d409a38187 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 15 Oct 2019 17:52:10 +0200 Subject: Support non-x86_64-linux system types in flakes A command like $ nix run nixpkgs#hello will now build the attribute 'packages.${system}.hello' rather than 'packages.hello'. Note that this does mean that the flake needs to export an attribute for every system type it supports, and you can't build on unsupported systems. So 'packages' typically looks like this: packages = nixpkgs.lib.genAttrs ["x86_64-linux" "i686-linux"] (system: { hello = ...; }); The 'checks', 'defaultPackage', 'devShell', 'apps' and 'defaultApp' outputs similarly are now attrsets that map system types to derivations/apps. 'nix flake check' checks that the derivations for all platforms evaluate correctly, but only builds the derivations in 'checks.${system}'. Fixes #2861. (That issue also talks about access to ~/.config/nixpkgs and --arg, but I think it's reasonable to say that flakes shouldn't support those.) The alternative to attribute selection is to pass the system type as an argument to the flake's 'outputs' function, e.g. 'outputs = { self, nixpkgs, system }: ...'. However, that approach would be at odds with hermetic evaluation and make it impossible to enumerate the packages provided by a flake. --- src/nix/run.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 01ec9a6f8..d444fd2eb 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -215,12 +215,12 @@ struct CmdApp : InstallableCommand, RunCommon Strings getDefaultFlakeAttrPaths() override { - return {"defaultApp"}; + return {"defaultApp." + settings.thisSystem.get()}; } Strings getDefaultFlakeAttrPathPrefixes() override { - return {"apps."}; + return {"apps." + settings.thisSystem.get() + "."}; } void run(ref store) override -- cgit v1.2.3 From d865085c7e66599ebcfb30b5e60c80565cc2b077 Mon Sep 17 00:00:00 2001 From: matthew Date: Thu, 31 Oct 2019 23:13:08 -0500 Subject: change deprecated attribute syntax in run examples --- src/nix/run.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index d444fd2eb..ed15527b8 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -113,15 +113,15 @@ struct CmdRun : InstallablesCommand, RunCommon }, Example{ "To start a shell providing youtube-dl from your 'nixpkgs' channel:", - "nix run nixpkgs.youtube-dl" + "nix run nixpkgs#youtube-dl" }, Example{ "To run GNU Hello:", - "nix run nixpkgs.hello -c hello --greeting 'Hi everybody!'" + "nix run nixpkgs#hello -c hello --greeting 'Hi everybody!'" }, Example{ "To run GNU Hello in a chroot store:", - "nix run --store ~/my-nix nixpkgs.hello -c hello" + "nix run --store ~/my-nix nixpkgs#hello -c hello" }, }; } -- cgit v1.2.3 From d2438f86d50399467b42284a0ba8f74e13b1defe Mon Sep 17 00:00:00 2001 From: matthew Date: Thu, 31 Oct 2019 20:46:49 -0500 Subject: environment fixes in run Move environment related code to a separate function. Create a new char** if ignoreEnvironment is set rather than calling clearEnv --- src/nix/run.cc | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index ed15527b8..33e821162 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -24,7 +24,7 @@ struct RunCommon : virtual Command { void runProgram(ref store, const std::string & program, - const Strings & args) + const Strings & args, char** env = environ) { stopProgressBar(); @@ -46,12 +46,12 @@ struct RunCommon : virtual Command Strings helperArgs = { chrootHelperName, store->storeDir, store2->realStoreDir, program }; for (auto & arg : args) helperArgs.push_back(arg); - execv(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data()); + execve(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data(), env); throw SysError("could not execute chroot helper"); } - execvp(program.c_str(), stringsToCharPtrs(args).data()); + execvpe(program.c_str(), stringsToCharPtrs(args).data(), env); throw SysError("unable to execute '%s'", program); } @@ -61,6 +61,7 @@ struct CmdRun : InstallablesCommand, RunCommon { std::vector command = { "bash" }; StringSet keep, unset; + Strings stringEnv; bool ignoreEnvironment = false; CmdRun() @@ -126,42 +127,44 @@ struct CmdRun : InstallablesCommand, RunCommon }; } - void run(ref store) override - { - auto outPaths = toStorePaths(store, Build, installables); - - auto accessor = store->getFSAccessor(); - + char** newEnviron() { if (ignoreEnvironment) { if (!unset.empty()) throw UsageError("--unset does not make sense with --ignore-environment"); - std::map kept; - for (auto & var : keep) { - auto s = getenv(var.c_str()); - if (s) kept[var] = s; + for (const auto & var : keep) { + auto val = getenv(var.c_str()); + if (val) stringEnv.emplace_back(fmt("%s=%s", var.c_str(), val)); } - clearEnv(); - - for (auto & var : kept) - setenv(var.first.c_str(), var.second.c_str(), 1); + return stringsToCharPtrs(stringEnv).data(); } else { - if (!keep.empty()) throw UsageError("--keep does not make sense without --ignore-environment"); - for (auto & var : unset) + for (const auto & var : unset) unsetenv(var.c_str()); + + return environ; } + } + + void run(ref store) override + { + auto outPaths = toStorePaths(store, Build, installables); + + auto accessor = store->getFSAccessor(); + std::unordered_set done; std::queue todo; for (auto & path : outPaths) todo.push(path); - auto unixPath = tokenizeString(getEnv("PATH"), ":"); + Strings unixPath; + if (!ignoreEnvironment || keep.find("PATH") != keep.end()) + unixPath = tokenizeString(getEnv("PATH"), ":"); while (!todo.empty()) { Path path = todo.front(); @@ -179,11 +182,16 @@ struct CmdRun : InstallablesCommand, RunCommon } setenv("PATH", concatStringsSep(":", unixPath).c_str(), 1); + if (ignoreEnvironment) { + keep.emplace("PATH"); + } else { + unset.erase("PATH"); + } Strings args; for (auto & arg : command) args.push_back(arg); - runProgram(store, *command.begin(), args); + runProgram(store, *command.begin(), args, newEnviron()); } }; -- cgit v1.2.3 From 693e8b1286dc3f39eb00871c91aaf96773e24a68 Mon Sep 17 00:00:00 2001 From: matthew Date: Mon, 4 Nov 2019 18:40:25 -0600 Subject: changes --- src/nix/run.cc | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 33e821162..d65a642c2 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -24,7 +24,7 @@ struct RunCommon : virtual Command { void runProgram(ref store, const std::string & program, - const Strings & args, char** env = environ) + const Strings & args) { stopProgressBar(); @@ -46,12 +46,12 @@ struct RunCommon : virtual Command Strings helperArgs = { chrootHelperName, store->storeDir, store2->realStoreDir, program }; for (auto & arg : args) helperArgs.push_back(arg); - execve(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data(), env); + execv(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data()); throw SysError("could not execute chroot helper"); } - execvpe(program.c_str(), stringsToCharPtrs(args).data(), env); + execvp(program.c_str(), stringsToCharPtrs(args).data()); throw SysError("unable to execute '%s'", program); } @@ -127,7 +127,7 @@ struct CmdRun : InstallablesCommand, RunCommon }; } - char** newEnviron() { + void setNewEnviron() { if (ignoreEnvironment) { if (!unset.empty()) @@ -138,7 +138,7 @@ struct CmdRun : InstallablesCommand, RunCommon if (val) stringEnv.emplace_back(fmt("%s=%s", var.c_str(), val)); } - return stringsToCharPtrs(stringEnv).data(); + environ = stringsToCharPtrs(stringEnv).data(); } else { if (!keep.empty()) @@ -146,8 +146,6 @@ struct CmdRun : InstallablesCommand, RunCommon for (const auto & var : unset) unsetenv(var.c_str()); - - return environ; } } @@ -162,9 +160,9 @@ struct CmdRun : InstallablesCommand, RunCommon std::queue todo; for (auto & path : outPaths) todo.push(path); - Strings unixPath; - if (!ignoreEnvironment || keep.find("PATH") != keep.end()) - unixPath = tokenizeString(getEnv("PATH"), ":"); + setNewEnviron(); + + auto unixPath = tokenizeString(getEnv("PATH"), ":"); while (!todo.empty()) { Path path = todo.front(); @@ -182,16 +180,11 @@ struct CmdRun : InstallablesCommand, RunCommon } setenv("PATH", concatStringsSep(":", unixPath).c_str(), 1); - if (ignoreEnvironment) { - keep.emplace("PATH"); - } else { - unset.erase("PATH"); - } Strings args; for (auto & arg : command) args.push_back(arg); - runProgram(store, *command.begin(), args, newEnviron()); + runProgram(store, *command.begin(), args); } }; -- cgit v1.2.3 From 6419f5028b30e8e43222d71d9fd45fd674eed1b7 Mon Sep 17 00:00:00 2001 From: matthew Date: Thu, 7 Nov 2019 17:18:31 -0600 Subject: use MixEnvironment in run and shell --- src/nix/run.cc | 51 ++------------------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index d65a642c2..0fbd0b8a8 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -57,12 +57,9 @@ struct RunCommon : virtual Command } }; -struct CmdRun : InstallablesCommand, RunCommon +struct CmdRun : InstallablesCommand, RunCommon, MixEnvironment { std::vector command = { "bash" }; - StringSet keep, unset; - Strings stringEnv; - bool ignoreEnvironment = false; CmdRun() { @@ -76,28 +73,6 @@ struct CmdRun : InstallablesCommand, RunCommon if (ss.empty()) throw UsageError("--command requires at least one argument"); command = ss; }); - - mkFlag() - .longName("ignore-environment") - .shortName('i') - .description("clear the entire environment (except those specified with --keep)") - .set(&ignoreEnvironment, true); - - mkFlag() - .longName("keep") - .shortName('k') - .description("keep specified environment variable") - .arity(1) - .labels({"name"}) - .handler([&](std::vector ss) { keep.insert(ss.front()); }); - - mkFlag() - .longName("unset") - .shortName('u') - .description("unset specified environment variable") - .arity(1) - .labels({"name"}) - .handler([&](std::vector ss) { unset.insert(ss.front()); }); } std::string description() override @@ -127,28 +102,6 @@ struct CmdRun : InstallablesCommand, RunCommon }; } - void setNewEnviron() { - if (ignoreEnvironment) { - - if (!unset.empty()) - throw UsageError("--unset does not make sense with --ignore-environment"); - - for (const auto & var : keep) { - auto val = getenv(var.c_str()); - if (val) stringEnv.emplace_back(fmt("%s=%s", var.c_str(), val)); - } - - environ = stringsToCharPtrs(stringEnv).data(); - - } else { - if (!keep.empty()) - throw UsageError("--keep does not make sense without --ignore-environment"); - - for (const auto & var : unset) - unsetenv(var.c_str()); - } - } - void run(ref store) override { auto outPaths = toStorePaths(store, Build, installables); @@ -160,7 +113,7 @@ struct CmdRun : InstallablesCommand, RunCommon std::queue todo; for (auto & path : outPaths) todo.push(path); - setNewEnviron(); + setEnviron(); auto unixPath = tokenizeString(getEnv("PATH"), ":"); -- cgit v1.2.3 From 5d8504b9789ffebabe8226227c4061dd48354177 Mon Sep 17 00:00:00 2001 From: Matthew Kenigsberg Date: Wed, 29 Apr 2020 14:02:37 -0600 Subject: rename nix run to nix shell and nix app to nix run --- src/nix/run.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 901b87fbb..f14e221e2 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -57,11 +57,11 @@ struct RunCommon : virtual Command } }; -struct CmdRun : InstallablesCommand, RunCommon, MixEnvironment +struct CmdShell : InstallablesCommand, RunCommon, MixEnvironment { std::vector command = { getEnv("SHELL").value_or("bash") }; - CmdRun() + CmdShell() { mkFlag() .longName("command") @@ -85,19 +85,19 @@ struct CmdRun : InstallablesCommand, RunCommon, MixEnvironment return { Example{ "To start a shell providing GNU Hello from NixOS 17.03:", - "nix run -f channel:nixos-17.03 hello" + "nix shell -f channel:nixos-17.03 hello" }, Example{ "To start a shell providing youtube-dl from your 'nixpkgs' channel:", - "nix run nixpkgs#youtube-dl" + "nix shell nixpkgs#youtube-dl" }, Example{ "To run GNU Hello:", - "nix run nixpkgs#hello -c hello --greeting 'Hi everybody!'" + "nix shell nixpkgs#hello -c hello --greeting 'Hi everybody!'" }, Example{ "To run GNU Hello in a chroot store:", - "nix run --store ~/my-nix nixpkgs#hello -c hello" + "nix shell --store ~/my-nix nixpkgs#hello -c hello" }, }; } @@ -141,13 +141,13 @@ struct CmdRun : InstallablesCommand, RunCommon, MixEnvironment } }; -static auto r1 = registerCommand("run"); +static auto r1 = registerCommand("shell"); -struct CmdApp : InstallableCommand, RunCommon +struct CmdRun : InstallableCommand, RunCommon { std::vector args; - CmdApp() + CmdRun() { expectArgs("args", &args); } @@ -162,7 +162,7 @@ struct CmdApp : InstallableCommand, RunCommon return { Example{ "To run Blender:", - "nix app blender-bin" + "nix run blender-bin" }, }; } @@ -192,7 +192,7 @@ struct CmdApp : InstallableCommand, RunCommon } }; -static auto r2 = registerCommand("app"); +static auto r2 = registerCommand("run"); void chrootHelper(int argc, char * * argv) { -- cgit v1.2.3 From e0c19ee620c53b52ca7cf69c19d414d782338be1 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 10 May 2020 21:35:07 +0200 Subject: Add completion for paths --- src/nix/run.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 3e2c8b4f3..3701ffe3d 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -149,7 +149,7 @@ struct CmdRun : InstallableCommand, RunCommon CmdRun() { - expectArgs("args", &args); + expectPathArgs("args", &args); } std::string description() override -- cgit v1.2.3 From 4c3c638a05e52cdc3bd96255873b711a28630288 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 11 May 2020 15:46:18 +0200 Subject: Cleanup --- src/nix/run.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 3701ffe3d..f9b1298f1 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -149,7 +149,11 @@ struct CmdRun : InstallableCommand, RunCommon CmdRun() { - expectPathArgs("args", &args); + expectArgs({ + .label = "args", + .handler = {&args}, + .completer = completePath + }); } std::string description() override -- cgit v1.2.3 From 5f64655ff429be08aa0787761697787e7050f373 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 15 May 2020 14:38:10 +0200 Subject: Move registry-related commands from 'nix flake' to 'nix registry' This makes 'nix flake' less cluttered and more consistent (it's only subcommands that operator on a flake). Also, the registry is not inherently flake-related (e.g. fetchTree could also use it to remap inputs). --- src/nix/run.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index f9b1298f1..2ab9d9ef4 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -108,7 +108,6 @@ struct CmdShell : InstallablesCommand, RunCommon, MixEnvironment auto accessor = store->getFSAccessor(); - std::unordered_set done; std::queue todo; for (auto & path : outPaths) todo.push(path.clone()); -- cgit v1.2.3 From 26cf0c674f543ec86a5ccb7e05a4773559bb8f8a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 29 Jun 2020 19:08:50 +0200 Subject: nix run: Use packages/legacyPackages as fallback if there is no app definition 'nix run' will try to run $out/bin/, where is the derivation name (excluding the version). This often works well: $ nix run nixpkgs#hello Hello, world! $ nix run nix -- --version nix (Nix) 2.4pre20200626_adf2fbb $ nix run patchelf -- --version patchelf 0.11.20200623.e61654b $ nix run nixpkgs#firefox -- --version Mozilla Firefox 77.0.1 $ nix run nixpkgs#gimp -- --version GNU Image Manipulation Program version 2.10.14 though not always: $ nix run nixpkgs#git error: unable to execute '/nix/store/kp7wp760l4gryq9s36x481b2x4rfklcy-git-2.25.4/bin/git-minimal': No such file or directory --- src/nix/run.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 204937cbc..59a6c7252 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -172,12 +172,18 @@ struct CmdRun : InstallableCommand, RunCommon Strings getDefaultFlakeAttrPaths() override { - return {"defaultApp." + settings.thisSystem.get()}; + Strings res{"defaultApp." + settings.thisSystem.get()}; + for (auto & s : SourceExprCommand::getDefaultFlakeAttrPaths()) + res.push_back(s); + return res; } Strings getDefaultFlakeAttrPathPrefixes() override { - return {"apps." + settings.thisSystem.get() + "."}; + Strings res{"apps." + settings.thisSystem.get() + ".", "packages"}; + for (auto & s : SourceExprCommand::getDefaultFlakeAttrPathPrefixes()) + res.push_back(s); + return res; } void run(ref store) override @@ -186,7 +192,7 @@ struct CmdRun : InstallableCommand, RunCommon auto app = installable->toApp(*state); - state->realiseContext(app.context); + state->store->buildPaths(app.context); Strings allArgs{app.program}; for (auto & i : args) allArgs.push_back(i); -- cgit v1.2.3 From 94eb5fad76cd086e3f49329532f81083726f89b3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 15 Jul 2020 20:05:42 +0200 Subject: Clean up RealiseMode --- src/nix/run.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 59a6c7252..a27538085 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -104,7 +104,7 @@ struct CmdShell : InstallablesCommand, RunCommon, MixEnvironment void run(ref store) override { - auto outPaths = toStorePaths(store, Build, installables); + auto outPaths = toStorePaths(store, Realise::Outputs, installables); auto accessor = store->getFSAccessor(); -- cgit v1.2.3 From 3624c042ace05db88794e87ee37f3296bab19bc8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 15 Jul 2020 20:22:52 +0200 Subject: nix: Add --derivation flag to operate on .drv paths For instance, 'nix why-depends --use-derivation nixpkgs#hello nixpkgs#glibc' shows why hello's .drv depends on glibc's .drv. --- src/nix/run.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index a27538085..cbaba9d90 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -104,7 +104,7 @@ struct CmdShell : InstallablesCommand, RunCommon, MixEnvironment void run(ref store) override { - auto outPaths = toStorePaths(store, Realise::Outputs, installables); + auto outPaths = toStorePaths(store, Realise::Outputs, OperateOn::Output, installables); auto accessor = store->getFSAccessor(); -- cgit v1.2.3 From f3280004e2be3f7533190ddf71ee1ec7c0d7d60d Mon Sep 17 00:00:00 2001 From: DavHau Date: Thu, 1 Oct 2020 11:34:13 +0700 Subject: add more examples to --help of `nix run` --- src/nix/run.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index cbaba9d90..e6584346e 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -167,6 +167,14 @@ struct CmdRun : InstallableCommand, RunCommon "To run Blender:", "nix run blender-bin" }, + Example{ + "To run vim from nixpkgs:", + "nix run nixpkgs#vim" + }, + Example{ + "To run vim from nixpkgs with arguments:", + "nix run nixpkgs#vim -- --help" + }, }; } -- cgit v1.2.3 From 85c8be6286e8f5464813a8a29b0b78d892498745 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 6 Oct 2020 13:36:55 +0200 Subject: Remove static variable name clashes This was useful for an experiment with building Nix as a single compilation unit. It's not very useful otherwise but also doesn't hurt... --- src/nix/run.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index e6584346e..790784382 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -140,7 +140,7 @@ struct CmdShell : InstallablesCommand, RunCommon, MixEnvironment } }; -static auto r1 = registerCommand("shell"); +static auto rCmdShell = registerCommand("shell"); struct CmdRun : InstallableCommand, RunCommon { @@ -209,7 +209,7 @@ struct CmdRun : InstallableCommand, RunCommon } }; -static auto r2 = registerCommand("run"); +static auto rCmdRun = registerCommand("run"); void chrootHelper(int argc, char * * argv) { -- cgit v1.2.3 From 438977731cf049cf47873d5825456d47a1aac541 Mon Sep 17 00:00:00 2001 From: regnat Date: Tue, 1 Dec 2020 14:57:56 +0100 Subject: shut up clang warnings - Fix some class/struct discrepancies - Explicit the overloading of `run` in the `Cmd*` classes - Ignore a warning in the generated lexer --- src/nix/run.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 790784382..92a52c6cd 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -22,6 +22,9 @@ std::string chrootHelperName = "__run_in_chroot"; struct RunCommon : virtual Command { + + using Command::run; + void runProgram(ref store, const std::string & program, const Strings & args) @@ -59,6 +62,9 @@ struct RunCommon : virtual Command struct CmdShell : InstallablesCommand, RunCommon, MixEnvironment { + + using InstallablesCommand::run; + std::vector command = { getEnv("SHELL").value_or("bash") }; CmdShell() @@ -144,6 +150,8 @@ static auto rCmdShell = registerCommand("shell"); struct CmdRun : InstallableCommand, RunCommon { + using InstallableCommand::run; + std::vector args; CmdRun() -- cgit v1.2.3 From 09660b855778531be14968b720308d092af4dd2e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 8 Dec 2020 17:16:23 +0100 Subject: Add 'nix run' and 'nix shell' manpages --- src/nix/run.cc | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 92a52c6cd..c2400f9ee 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -86,26 +86,11 @@ struct CmdShell : InstallablesCommand, RunCommon, MixEnvironment return "run a shell in which the specified packages are available"; } - Examples examples() override + std::string doc() override { - return { - Example{ - "To start a shell providing GNU Hello from NixOS 20.03:", - "nix shell nixpkgs/nixos-20.03#hello" - }, - Example{ - "To start a shell providing youtube-dl from your 'nixpkgs' channel:", - "nix shell nixpkgs#youtube-dl" - }, - Example{ - "To run GNU Hello:", - "nix shell nixpkgs#hello -c hello --greeting 'Hi everybody!'" - }, - Example{ - "To run GNU Hello in a chroot store:", - "nix shell --store ~/my-nix nixpkgs#hello -c hello" - }, - }; + return + #include "shell.md" + ; } void run(ref store) override @@ -168,22 +153,11 @@ struct CmdRun : InstallableCommand, RunCommon return "run a Nix application"; } - Examples examples() override + std::string doc() override { - return { - Example{ - "To run Blender:", - "nix run blender-bin" - }, - Example{ - "To run vim from nixpkgs:", - "nix run nixpkgs#vim" - }, - Example{ - "To run vim from nixpkgs with arguments:", - "nix run nixpkgs#vim -- --help" - }, - }; + return + #include "run.md" + ; } Strings getDefaultFlakeAttrPaths() override -- cgit v1.2.3 From 5373f4be3b1427ed73303448a1fa801726f4dfa0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 22 Dec 2020 12:28:50 +0100 Subject: chrootHelper: Handle symlinks in the root directory This is necessary on Ubuntu where /bin and /lib* are symlinks. --- src/nix/run.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 92a52c6cd..ec61fc79a 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -258,14 +258,16 @@ void chrootHelper(int argc, char * * argv) for (auto entry : readDirectory("/")) { auto src = "/" + entry.name; - auto st = lstat(src); - if (!S_ISDIR(st.st_mode)) continue; Path dst = tmpDir + "/" + entry.name; if (pathExists(dst)) continue; - if (mkdir(dst.c_str(), 0700) == -1) - throw SysError("creating directory '%s'", dst); - if (mount(src.c_str(), dst.c_str(), "", MS_BIND | MS_REC, 0) == -1) - throw SysError("mounting '%s' on '%s'", src, dst); + auto st = lstat(src); + if (S_ISDIR(st.st_mode)) { + if (mkdir(dst.c_str(), 0700) == -1) + throw SysError("creating directory '%s'", dst); + if (mount(src.c_str(), dst.c_str(), "", MS_BIND | MS_REC, 0) == -1) + throw SysError("mounting '%s' on '%s'", src, dst); + } else if (S_ISLNK(st.st_mode)) + createSymlink(readLink(src), dst); } char * cwd = getcwd(0, 0); -- cgit v1.2.3 From 3da9a9241cb9f8c284426c220ea285398d0328dd Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 13 Jan 2021 14:18:04 +0100 Subject: Convert option descriptions to Markdown --- src/nix/run.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 1340dd46f..ec9388234 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -72,7 +72,7 @@ struct CmdShell : InstallablesCommand, RunCommon, MixEnvironment addFlag({ .longName = "command", .shortName = 'c', - .description = "command and arguments to be executed; defaults to '$SHELL'", + .description = "Command and arguments to be executed, defaulting to `$SHELL`", .labels = {"command", "args"}, .handler = {[&](std::vector ss) { if (ss.empty()) throw UsageError("--command requires at least one argument"); -- cgit v1.2.3 From 255d145ba7ac907d1cba8d088da556b591627756 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 2 Mar 2021 03:50:41 +0000 Subject: Use `BuildableReq` for `buildPaths` and `ensurePath` This avoids an ambiguity where the `StorePathWithOutputs { drvPath, {} }` could mean "build `brvPath`" or "substitute `drvPath`" depending on context. It also brings the internals closer in line to the new CLI, by generalizing the `Buildable` type is used there and makes that distinction already. In doing so, relegate `StorePathWithOutputs` to being a type just for backwards compatibility (CLI and RPC). --- src/nix/run.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index ec9388234..2e9bb41cc 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -182,7 +182,7 @@ struct CmdRun : InstallableCommand, RunCommon auto app = installable->toApp(*state); - state->store->buildPaths(app.context); + state->store->buildPaths(toBuildableReqs(app.context)); Strings allArgs{app.program}; for (auto & i : args) allArgs.push_back(i); -- cgit v1.2.3 From 9b805d36ac70545fc4c0d863e21e0c2e5f2518a1 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 5 Apr 2021 09:48:18 -0400 Subject: Rename Buildable --- src/nix/run.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 2e9bb41cc..ba60e57d8 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -182,7 +182,7 @@ struct CmdRun : InstallableCommand, RunCommon auto app = installable->toApp(*state); - state->store->buildPaths(toBuildableReqs(app.context)); + state->store->buildPaths(toDerivedPaths(app.context)); Strings allArgs{app.program}; for (auto & i : args) allArgs.push_back(i); -- cgit v1.2.3 From 9b9e703df41d75949272059f9b8bc8b763e91fce Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 7 Apr 2021 13:10:02 +0200 Subject: restoreSignals() + restoreAffinity() -> restoreProcessContext() --- src/nix/run.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index ba60e57d8..b5d8ab38a 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -31,9 +31,7 @@ struct RunCommon : virtual Command { stopProgressBar(); - restoreSignals(); - - restoreAffinity(); + restoreProcessContext(); /* If this is a diverted store (i.e. its "logical" location (typically /nix/store) differs from its "physical" location -- cgit v1.2.3 From ca96f5219489c1002499bfe2c580fdd458219144 Mon Sep 17 00:00:00 2001 From: regnat Date: Mon, 17 May 2021 17:49:20 +0200 Subject: Split the parsing of an `App` and its resolving That way things (like `nix flake check`) can evaluate the `app` outputs without having to build anything --- src/nix/run.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index b5d8ab38a..f684c5ea4 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -178,9 +178,7 @@ struct CmdRun : InstallableCommand, RunCommon { auto state = getEvalState(); - auto app = installable->toApp(*state); - - state->store->buildPaths(toDerivedPaths(app.context)); + auto app = installable->toApp(*state).resolve(store); Strings allArgs{app.program}; for (auto & i : args) allArgs.push_back(i); -- cgit v1.2.3 From 4202a3bc4e7ce687be245539f6d796226f7d9e37 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 18 Jun 2021 17:04:11 +0200 Subject: UDSRemoteStore: Support the 'root' store parameter Useful when we're using a daemon with a chroot store, e.g. $ NIX_DAEMON_SOCKET_PATH=/tmp/chroot/nix/var/nix/daemon-socket/socket nix-daemon --store /tmp/chroot Then the client can now connect with $ nix build --store unix:///tmp/chroot/nix/var/nix/daemon-socket/socket?root=/tmp/chroot nixpkgs#hello --- src/nix/run.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index f684c5ea4..c0ba05a3e 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -43,8 +43,8 @@ struct RunCommon : virtual Command helper program (chrootHelper() below) to do the work. */ auto store2 = store.dynamic_pointer_cast(); - if (store2 && store->storeDir != store2->realStoreDir) { - Strings helperArgs = { chrootHelperName, store->storeDir, store2->realStoreDir, program }; + if (store2 && store->storeDir != store2->getRealStoreDir()) { + Strings helperArgs = { chrootHelperName, store->storeDir, store2->getRealStoreDir(), program }; for (auto & arg : args) helperArgs.push_back(arg); execv(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data()); -- cgit v1.2.3 From 8d9f7048cd3b09fb58f6bad0328f644b0ddaaa16 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 16 Jul 2021 16:04:47 +0200 Subject: Use eval-store in more places In particular, this now works: $ nix path-info --eval-store auto --store https://cache.nixos.org nixpkgs#hello Previously this would fail as it would try to upload the hello .drv to cache.nixos.org. Now the .drv is instantiated in the local store, and then we check for the existence of the outputs in cache.nixos.org. --- src/nix/run.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index c0ba05a3e..0c8afec2d 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -93,7 +93,7 @@ struct CmdShell : InstallablesCommand, RunCommon, MixEnvironment void run(ref store) override { - auto outPaths = toStorePaths(store, Realise::Outputs, OperateOn::Output, installables); + auto outPaths = toStorePaths(getEvalStore(), store, Realise::Outputs, OperateOn::Output, installables); auto accessor = store->getFSAccessor(); @@ -178,7 +178,7 @@ struct CmdRun : InstallableCommand, RunCommon { auto state = getEvalState(); - auto app = installable->toApp(*state).resolve(store); + auto app = installable->toApp(*state).resolve(getEvalStore(), store); Strings allArgs{app.program}; for (auto & i : args) allArgs.push_back(i); -- cgit v1.2.3 From ed5ad59dc16d8207f14c23f7fca903ee408eb54e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 27 Jul 2021 14:23:24 +0200 Subject: nix develop: Support chroot stores Fixes #5024. --- src/nix/run.cc | 63 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 0c8afec2d..7597b61f7 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -1,3 +1,4 @@ +#include "run.hh" #include "command.hh" #include "common-args.hh" #include "shared.hh" @@ -20,45 +21,43 @@ using namespace nix; std::string chrootHelperName = "__run_in_chroot"; -struct RunCommon : virtual Command -{ +namespace nix { - using Command::run; +void runProgramInStore(ref store, + const std::string & program, + const Strings & args) +{ + stopProgressBar(); - void runProgram(ref store, - const std::string & program, - const Strings & args) - { - stopProgressBar(); + restoreProcessContext(); - restoreProcessContext(); + /* If this is a diverted store (i.e. its "logical" location + (typically /nix/store) differs from its "physical" location + (e.g. /home/eelco/nix/store), then run the command in a + chroot. For non-root users, this requires running it in new + mount and user namespaces. Unfortunately, + unshare(CLONE_NEWUSER) doesn't work in a multithreaded program + (which "nix" is), so we exec() a single-threaded helper program + (chrootHelper() below) to do the work. */ + auto store2 = store.dynamic_pointer_cast(); - /* If this is a diverted store (i.e. its "logical" location - (typically /nix/store) differs from its "physical" location - (e.g. /home/eelco/nix/store), then run the command in a - chroot. For non-root users, this requires running it in new - mount and user namespaces. Unfortunately, - unshare(CLONE_NEWUSER) doesn't work in a multithreaded - program (which "nix" is), so we exec() a single-threaded - helper program (chrootHelper() below) to do the work. */ - auto store2 = store.dynamic_pointer_cast(); + if (store2 && store->storeDir != store2->getRealStoreDir()) { + Strings helperArgs = { chrootHelperName, store->storeDir, store2->getRealStoreDir(), program }; + for (auto & arg : args) helperArgs.push_back(arg); - if (store2 && store->storeDir != store2->getRealStoreDir()) { - Strings helperArgs = { chrootHelperName, store->storeDir, store2->getRealStoreDir(), program }; - for (auto & arg : args) helperArgs.push_back(arg); + execv(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data()); - execv(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data()); + throw SysError("could not execute chroot helper"); + } - throw SysError("could not execute chroot helper"); - } + execvp(program.c_str(), stringsToCharPtrs(args).data()); - execvp(program.c_str(), stringsToCharPtrs(args).data()); + throw SysError("unable to execute '%s'", program); +} - throw SysError("unable to execute '%s'", program); - } -}; +} -struct CmdShell : InstallablesCommand, RunCommon, MixEnvironment +struct CmdShell : InstallablesCommand, MixEnvironment { using InstallablesCommand::run; @@ -125,13 +124,13 @@ struct CmdShell : InstallablesCommand, RunCommon, MixEnvironment Strings args; for (auto & arg : command) args.push_back(arg); - runProgram(store, *command.begin(), args); + runProgramInStore(store, *command.begin(), args); } }; static auto rCmdShell = registerCommand("shell"); -struct CmdRun : InstallableCommand, RunCommon +struct CmdRun : InstallableCommand { using InstallableCommand::run; @@ -183,7 +182,7 @@ struct CmdRun : InstallableCommand, RunCommon Strings allArgs{app.program}; for (auto & i : args) allArgs.push_back(i); - runProgram(store, app.program, allArgs); + runProgramInStore(store, app.program, allArgs); } }; -- cgit v1.2.3 From 2d66a31f015a26f182f8a70fa09c635d1c7a1739 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 21 Aug 2021 20:17:05 +0200 Subject: nix {bundle,run}: drop broken flake attr-path prefixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “packages” was probably meant to be “packages.${system}.” but that is already listed in `getDefaultFlakeAttrPathPrefixes` in `installables`, which is probably why no one noticed it was broken. --- src/nix/run.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nix/run.cc') diff --git a/src/nix/run.cc b/src/nix/run.cc index 7597b61f7..b01fdebaa 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -167,7 +167,7 @@ struct CmdRun : InstallableCommand Strings getDefaultFlakeAttrPathPrefixes() override { - Strings res{"apps." + settings.thisSystem.get() + ".", "packages"}; + Strings res{"apps." + settings.thisSystem.get() + "."}; for (auto & s : SourceExprCommand::getDefaultFlakeAttrPathPrefixes()) res.push_back(s); return res; -- cgit v1.2.3