aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-12-13 19:09:36 +0100
committerEelco Dolstra <edolstra@gmail.com>2021-12-13 19:09:36 +0100
commit775bdc0d9e872831f4faeed1d05ab13dac232d39 (patch)
treeedf5b793f2a1cb5ec4a5a2c318d3c6e385f04683 /src/nix
parentf133001dc8c849053b8af9933902d11f274426bd (diff)
parenta2473823d748b0249804d393c739622146954d02 (diff)
Merge branch 'pname-main-program' of https://github.com/figsoda/nix
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/app.cc3
-rw-r--r--src/nix/run.md7
2 files changed, 7 insertions, 3 deletions
diff --git a/src/nix/app.cc b/src/nix/app.cc
index 9719a65dd..2fcf4752c 100644
--- a/src/nix/app.cc
+++ b/src/nix/app.cc
@@ -83,11 +83,14 @@ UnresolvedApp Installable::toApp(EvalState & state)
auto outPath = cursor->getAttr(state.sOutPath)->getString();
auto outputName = cursor->getAttr(state.sOutputName)->getString();
auto name = cursor->getAttr(state.sName)->getString();
+ auto aPname = cursor->maybeGetAttr("pname");
auto aMeta = cursor->maybeGetAttr("meta");
auto aMainProgram = aMeta ? aMeta->maybeGetAttr("mainProgram") : nullptr;
auto mainProgram =
aMainProgram
? aMainProgram->getString()
+ : aPname
+ ? aPname->getString()
: DrvName(name).name;
auto program = outPath + "/bin/" + mainProgram;
return UnresolvedApp { App {
diff --git a/src/nix/run.md b/src/nix/run.md
index a76750376..697db9a96 100644
--- a/src/nix/run.md
+++ b/src/nix/run.md
@@ -44,9 +44,10 @@ program specified by the app definition.
If *installable* evaluates to a derivation, it will try to execute the
program `<out>/bin/<name>`, where *out* is the primary output store
path of the derivation and *name* is the `meta.mainProgram` attribute
-of the derivation if it exists, and otherwise the name part of the
-value of the `name` attribute of the derivation (e.g. if `name` is set
-to `hello-1.10`, it will run `$out/bin/hello`).
+of the derivation if it exists, and otherwise the `pname` attribute of
+the derivation or the name part of the value of the `name` attribute of
+the derivation (e.g. if `name` is set to `hello-1.10`, it will run
+`$out/bin/hello`).
# Flake output attributes