about summary refs log tree commit diff
path: root/lib/meta.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/meta.nix')
-rw-r--r--lib/meta.nix14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/meta.nix b/lib/meta.nix
index 5b1f7ee5ff2d1..74b94211552b6 100644
--- a/lib/meta.nix
+++ b/lib/meta.nix
@@ -126,4 +126,18 @@ rec {
         lib.warn "getLicenseFromSpdxId: No license matches the given SPDX ID: ${licstr}"
         { shortName = licstr; }
       );
+
+  /* Get the path to the main program of a derivation with either
+     meta.mainProgram or pname or name
+
+     Type: getExe :: derivation -> string
+
+     Example:
+       getExe pkgs.hello
+       => "/nix/store/g124820p9hlv4lj8qplzxw1c44dxaw1k-hello-2.12/bin/hello"
+       getExe pkgs.mustache-go
+       => "/nix/store/am9ml4f4ywvivxnkiaqwr0hyxka1xjsf-mustache-go-1.3.0/bin/mustache"
+  */
+  getExe = x:
+    "${lib.getBin x}/bin/${x.meta.mainProgram or (lib.getName x)}";
 }