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