-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib/meta: add getExe to get the main program of a drv #167247
Conversation
Duplicate of #138418 |
007ec62
to
939caff
Compare
alright there's 3 choices now A fourth option would be based on the comment by @roberth #138418 (comment) |
071e49d
to
861a862
Compare
861a862
to
379b9c8
Compare
=> "/nix/store/am9ml4f4ywvivxnkiaqwr0hyxka1xjsf-mustache-go-1.3.0/bin/mustache" | ||
*/ | ||
getExe = x: | ||
"${lib.getBin x}/bin/${x.meta.mainProgram or (lib.getName x)}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having second thoughts about the lib.getName x
part.
- A package should make its main program explicit. Explicit is good.
- When
/bin/${name}
does not exist, the error is delayed until runtime, and most likely the caller won't know why/bin/foo
, which doesn't exist, was ever accessed. Especially if they didn't make the call togetExe
themselves; for example when a NixOS option does it for them.
Should we make meta.mainProgram
mandatory for getExe
? I think we should!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or at least we could warn about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll have to be a warning for at least a release as this is already used widely outside of nixpkgs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description of changes
add a way to get the main program of a derivation
Closes #137032
Alternative to #158461
based on a comment by @edolstra
hopefully this at least unstalls #158461
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes