summaryrefslogtreecommitdiffstats
path: root/lib/meta.nix
diff options
context:
space:
mode:
authorSilvan Mosberger <github@infinisil.com>2023-08-16 02:19:22 +0200
committerGitHub <noreply@github.com>2023-08-16 02:19:22 +0200
commit6adb20e9655362150e4ad6dc3b31640098c96a1f (patch)
tree09e4b64c7ded3df866b73053d5a0ea4e01f317d0 /lib/meta.nix
parent85ab6c7af62f3c2fdc0add09957445a5cc8f3e30 (diff)
parenta9a29b70590d95761044fb976b8135c9087ee24b (diff)
Merge pull request #248895 from Scrumplex/getExe2
Diffstat (limited to 'lib/meta.nix')
-rw-r--r--lib/meta.nix25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/meta.nix b/lib/meta.nix
index 21404b3a2bfa..44730a71551e 100644
--- a/lib/meta.nix
+++ b/lib/meta.nix
@@ -143,9 +143,24 @@ rec {
=> "/nix/store/am9ml4f4ywvivxnkiaqwr0hyxka1xjsf-mustache-go-1.3.0/bin/mustache"
*/
getExe = x:
- "${lib.getBin x}/bin/${x.meta.mainProgram or (
- # This could be turned into an error when 23.05 is at end of life
- lib.warn "getExe: Package ${lib.strings.escapeNixIdentifier x.meta.name or x.pname or x.name} does not have the meta.mainProgram attribute. We'll assume that the main program has the same name for now, but this behavior is deprecated, because it leads to surprising errors when the assumption does not hold. If the package has a main program, please set `meta.mainProgram` in its definition to make this warning go away. Otherwise, if the package does not have a main program, or if you don't control its definition, specify the full path to the program, such as \"\${lib.getBin foo}/bin/bar\"."
- lib.getName x
- )}";
+ let
+ y = x.meta.mainProgram or (
+ # This could be turned into an error when 23.05 is at end of life
+ lib.warn "getExe: Package ${lib.strings.escapeNixIdentifier x.meta.name or x.pname or x.name} does not have the meta.mainProgram attribute. We'll assume that the main program has the same name for now, but this behavior is deprecated, because it leads to surprising errors when the assumption does not hold. If the package has a main program, please set `meta.mainProgram` in its definition to make this warning go away. Otherwise, if the package does not have a main program, or if you don't control its definition, use getExe' to specify the name to the program, such as lib.getExe' foo \"bar\"."
+ lib.getName
+ x
+ );
+ in
+ getExe' x y;
+
+ /* Get the path of a program of a derivation.
+
+ Type: getExe' :: derivation -> string -> string
+ Example:
+ getExe' pkgs.hello "hello"
+ => "/nix/store/g124820p9hlv4lj8qplzxw1c44dxaw1k-hello-2.12/bin/hello"
+ getExe' pkgs.imagemagick "convert"
+ => "/nix/store/5rs48jamq7k6sal98ymj9l4k2bnwq515-imagemagick-7.1.1-15/bin/convert"
+ */
+ getExe' = x: y: "${lib.getBin x}/bin/${y}";
}