Skip to content

enh: add a list of known nvidia drivers as an attr in nixGL #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
43 changes: 43 additions & 0 deletions dynamicWrapper.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
'';
}
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
enable32bits = isIntelX86Platform;
enableIntelX86Extensions = isIntelX86Platform;
};

in rec {

packages = {
Expand All @@ -39,6 +40,8 @@
pkgs = final;
enable32bits = isIntelX86Platform;
enableIntelX86Extensions = isIntelX86Platform;
} // {
nixGLDynamic = final.callPackage ./dynamicWrapper.nix {};
};
};
};
Expand Down
10 changes: 10 additions & 0 deletions known_drivers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Nvidia drivers

A single nix expression listing known nvidia driver versions and their corresponding hashes.
To be used as input to flakes that use nixGL

The list of version/hash pairs can be regenerated by the `mk-nvidia-drivers.py` script,
which fetches the list of drivers at https://download.nvidia.com/XFree86/Linux-x86_64/
for each version, attempts to locate a runfile using the same url template as used to
generate the nixGLNvidia wrappers, then run nix-prefetch-url to get the hash, then
cleans the downloaded runfile out the store.
Loading
Loading