handle nixGLDefault with nvidiaVersionFile
This commit is contained in:
parent
7aa1cce7c6
commit
4c09910428
19
nixGL.nix
19
nixGL.nix
|
@ -33,7 +33,7 @@ let
|
||||||
# Add an impure parameter to force the rebuild on each access.
|
# Add an impure parameter to force the rebuild on each access.
|
||||||
time = builtins.currentTime;
|
time = builtins.currentTime;
|
||||||
}
|
}
|
||||||
"cp /proc/driver/nvidia/version $out";
|
"cp /proc/driver/nvidia/version $out || touch $out";
|
||||||
|
|
||||||
# The nvidia version. Either fixed by the `nvidiaVersion` argument, or
|
# The nvidia version. Either fixed by the `nvidiaVersion` argument, or
|
||||||
# auto-detected. Auto-detection is impure.
|
# auto-detected. Auto-detection is impure.
|
||||||
|
@ -46,8 +46,10 @@ let
|
||||||
data = builtins.readFile _nvidiaVersionFile;
|
data = builtins.readFile _nvidiaVersionFile;
|
||||||
versionMatch = builtins.match ".*Module +([0-9]+\\.[0-9]+).*" data;
|
versionMatch = builtins.match ".*Module +([0-9]+\\.[0-9]+).*" data;
|
||||||
in
|
in
|
||||||
assert builtins.length versionMatch == 1;
|
if versionMatch != null then
|
||||||
builtins.head versionMatch;
|
builtins.head versionMatch
|
||||||
|
else
|
||||||
|
null;
|
||||||
|
|
||||||
addNvidiaVersion = drv: drv.overrideAttrs(oldAttrs: {
|
addNvidiaVersion = drv: drv.overrideAttrs(oldAttrs: {
|
||||||
name = oldAttrs.name + "-${_nvidiaVersion}";
|
name = oldAttrs.name + "-${_nvidiaVersion}";
|
||||||
|
@ -187,8 +189,9 @@ in
|
||||||
# The output derivation contains nixGL which point either to
|
# The output derivation contains nixGL which point either to
|
||||||
# nixGLNvidia or nixGLIntel using an heuristic.
|
# nixGLNvidia or nixGLIntel using an heuristic.
|
||||||
nixGLDefault =
|
nixGLDefault =
|
||||||
if builtins.pathExists "/proc/driver/nvidia/version"
|
if _nvidiaVersion != null then
|
||||||
then nixGLCommon nixGLNvidia
|
nixGLCommon nixGLNvidia
|
||||||
else nixGLCommon nixGLIntel;
|
else
|
||||||
|
nixGLCommon nixGLIntel
|
||||||
}
|
;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user