about summary refs log tree commit diff stats
path: root/lib/default.nix
blob: 0e2caf1b3bc117f1e15d8a7b5bef3d346bcd6ecf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
  pkgs,
  shell-library,
  ...
}: {
  makeShellScriptWithLibrary = {
    dependencies,
    name,
    script,
    ...
  }:
    pkgs.runCommandLocal name {
      nativeBuildInputs = [pkgs.makeWrapper] ++ dependencies;
    } ''
      install -m755 ${script} -D "$out/bin/${name}"
      sed -i 's|%SHELL_LIBRARY_PATH|${shell-library}/lib|' "$out/bin/${name}"
      patchShebangs "$out/bin/${name}"
      wrapProgram "$out/bin/${name}" --prefix PATH : ${pkgs.lib.makeBinPath dependencies}
    '';
}