1{
2 pkgs ? import <nixpkgs> { },
3 feature,
4}:
5
6pkgs.runCommandNoCC "${feature}-present" { requiredSystemFeatures = [ feature ]; } ''
7 if [[ ! -e /${feature}-files ]]; then
8 echo "The host declares ${feature} support, but doesn't expose /${feature}-files" >&2
9 exit 1
10 fi
11 libcudaLocation=/run/opengl-driver/lib/libcuda.so
12 if [[ -e "$libcudaLocation" || -h "$libcudaLocation" ]] ; then
13 true # we're good
14 else
15 echo "The host declares ${feature} support, but it the hook fails to handle the hostPath != guestPath cases" >&2
16 exit 1
17 fi
18 if cat "$libcudaLocation" | xargs test fakeContent = ; then
19 true # we're good
20 else
21 echo "The host declares ${feature} support, but it seems to fail to follow symlinks" >&2
22 echo "The content of /run/opengl-driver/lib/libcuda.so is: $(cat /run/opengl-driver/lib/libcuda.so)" >&2
23 exit 1
24 fi
25 touch $out
26''