blob: 2704944fb9f15ce878ccb5e498e448ebdf3ae1bb (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
{
pkgs,
shell-library,
...
}: let
shellLibraryDeps =
builtins.attrValues {inherit (pkgs) mktemp dash;};
in {
makeShellScriptWithLibrary = {
dependencies,
name,
script,
...
}: let
shellDependencies = dependencies ++ shellLibraryDeps;
in
pkgs.runCommandLocal name {
nativeBuildInputs = [pkgs.makeWrapper] ++ shellDependencies;
} ''
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 shellDependencies}
'';
# This dumps the extra things in the default path; TODO fix this
makeShellScriptWithLibraryAndKeepPath = {
dependencies,
name,
script,
...
}: let
shellDependencies = dependencies ++ shellLibraryDeps;
in
pkgs.runCommandLocal name {
nativeBuildInputs = [pkgs.makeWrapper] ++ shellDependencies;
} ''
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 shellDependencies}
'';
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}"
'';
}
|