-
-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathdynamicWrapper.nix
43 lines (37 loc) · 1.04 KB
/
dynamicWrapper.nix
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
{
pkgs,
writeTextFile,
runtimeShell,
gnugrep,
gnused,
shellcheck,
pcre
}:
writeTextFile rec {
name = "nixGL";
text = ''#!${runtimeShell}
driver_file=/proc/driver/nvidia/version
vers=$(${gnugrep}/bin/grep "Module" "$driver_file" |\
${gnused}/bin/sed -E "s/.*Module ([0-9.]+) .*/\1/")
if [ -z "$vers" ]; then
echo "Failed to parse your driver version from $driver_file. Does $driver_file exist?"
echo "Consider using nixGLNvidia-<version> directly instead."
exit 1
fi
if ! command -v nixGLNvidia-"$vers" &> /dev/null; then
echo "nixGLNvidia wrapper not found for $vers"
exit 1
fi
exec nixGLNvidia-"$vers" "$@"
'';
executable = true;
destination = "/bin/${name}";
checkPhase = ''
${shellcheck}/bin/shellcheck "$out/bin/${name}"
# Check that all the files listed in the output binary exists
for i in $(${pcre}/bin/pcregrep -o0 '/nix/store/.*?/[^ ":]+' $out/bin/${name})
do
ls $i > /dev/null || (echo "File $i, referenced in $out/bin/${name} does not exists."; exit -1)
done
'';
}