blob: b226760acbf1cdf76dd261992dfdae245d215c87 (
plain)
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
|
pkgs:
let
inherit (builtins)
map elem;
inherit (pkgs) stdenv;
in
pkg: inst:
stdenv.mkDerivation {
# I don't like using `name' instead of `pname' and `version', but
# regrettably not all packages use `pname' and `version' yet, so for the
# sake of consistency, we treat all packages as if they didn't use `pname'
# and `version'.
name = pkg.name + "-shim";
nativeBuildInputs = [pkg];
dontUnpack = true;
buildPhase = ''
if [ -d ${pkg}/bin ]; then
mkdir -p "$out/bin"
for exe in $(ls "${pkg}/bin/"); do
cat >"$out/bin/$exe" <<EOF
#!/bin/sh
term=urxvt
which \$term >/dev/null 2>&1 || term=xterm
if [ "\$DISPLAY" ]; then
\$term -e nix shell '${inst}' --command '$exe' \$*
else
nix shell '${inst}' --command '$exe' \$*
fi
EOF
chmod +x "$out/bin/$exe"
done
fi
for dir in "share/applications" "share/icons"; do
if [ -d "${pkg}/$dir" ]; then
mkdir -p "$out/$dir"
cp -a "${pkg}/$dir/"* "$out/$dir"
fi
done
'';
}
|