Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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