diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-06-29 19:08:50 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-06-29 19:08:50 +0200 |
commit | 26cf0c674f543ec86a5ccb7e05a4773559bb8f8a (patch) | |
tree | 9544ce8a48f6b7fc72fa8bbf86879a7e7887a864 /src/nix/run.cc | |
parent | 50f13b06fb1b2f50a97323c000d1094d090f08ea (diff) |
nix run: Use packages/legacyPackages as fallback if there is no app definition
'nix run' will try to run $out/bin/<name>, where <name> 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
Diffstat (limited to 'src/nix/run.cc')
-rw-r--r-- | src/nix/run.cc | 12 |
1 files changed, 9 insertions, 3 deletions
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> 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); |