Skip to content

Commit

Permalink
stdenv/mkDerivation: derive pname and version when not given
Browse files Browse the repository at this point in the history
  • Loading branch information
Synthetica9 committed May 26, 2021
1 parent f8a7316 commit ab64e0c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkgs/stdenv/generic/make-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,15 @@ in rec {
if attrs ? name
then attrs.name + hostSuffix
else "${attrs.pname}${staticMarker}${hostSuffix}-${attrs.version}";
}) // {
}) // (let
# If only `name` is given, automatically derive pname and version:
pname = lib.getName attrs.name;
version = lib.getVersion attrs.name;
in
lib.optionalAttrs
(!(attrs ? pname || attrs ? version) && attrs ? name && pname != "" && version != "")
{ inherit pname version; }
) // {
builder = attrs.realBuilder or stdenv.shell;
args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
inherit stdenv;
Expand Down

0 comments on commit ab64e0c

Please sign in to comment.