about summary refs log tree commit diff stats
path: root/lib/default.nix
blob: 20088dc43cb2f8b0c0e7b182307b5d0a9d416f37 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
  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}" --set PATH ${pkgs.lib.makeBinPath dependencies}
    '';

  makeShellScriptWithLibraryUnwrapped = {
    name,
    script,
    ...
  }:
    pkgs.runCommandLocal name {
      nativeBuildInputs = [];
    } ''
      install -m755 ${script} -D "$out/bin/${name}"
      sed -i 's|%SHELL_LIBRARY_PATH|${shell-library}/lib|' "$out/bin/${name}"
      patchShebangs "$out/bin/${name}"
    '';
}