feat(nix/binify): add binify

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" }`.

Change-Id: I600bdcd8f143bca2dd8dfbb165a9a5a8d6397622
Reviewed-on: https://cl.tvl.fyi/c/depot/+/624
Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
Profpatsch 2020-06-27 05:34:23 +02:00
parent b6cb20b2d0
commit 17eba437a7
2 changed files with 17 additions and 0 deletions

16
nix/binify/default.nix Normal file
View file

@ -0,0 +1,16 @@
{ 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 "binify-${name}" {} ''
mkdir -p $out/bin
ln -sT ${lib.escapeShellArg exe} $out/bin/${lib.escapeShellArg name}
''

View file

@ -115,6 +115,7 @@ let
rsync
runCommand
runCommandNoCC
runCommandLocal
rustPlatform
rustc
sbcl