depot/third_party/tvl/nix/binify/default.nix
Default email c4fb0432ae Project import generated by Copybara.
GitOrigin-RevId: 3fc1143a04da49a92c3663813c6a0c1e8ccd477f
2020-09-29 23:42:59 -04:00

16 lines
516 B
Nix

{ pkgs, lib, ... }:
# Create a store path where the executable `exe`
# is linked to $out/bin/${name}.
# This is useful for e.g. including it as a “package”
# in `buildInputs` of a shell.nix.
#
# For example, if I have the exeutable /nix/store/…-hello,
# I can make it into /nix/store/…-binify-hello/bin/hello
# with `binify { exe = …; name = "hello" }`.
{ exe, name }:
pkgs.runCommandLocal "${name}-bin" {} ''
mkdir -p $out/bin
ln -sT ${lib.escapeShellArg exe} $out/bin/${lib.escapeShellArg name}
''