Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 36 lines 1.3 kB view raw
1# TODO(@connorbaker): cuda_cudart.dev depends on crt/host_config.h, which is from 2# (getDev cuda_nvcc). It would be nice to be able to encode that. 3{ addDriverRunpath, lib }: 4prevAttrs: { 5 # Remove once cuda-find-redist-features has a special case for libcuda 6 outputs = 7 prevAttrs.outputs or [ ] 8 ++ lib.lists.optionals (!(builtins.elem "stubs" prevAttrs.outputs)) [ "stubs" ]; 9 10 allowFHSReferences = false; 11 12 # The libcuda stub's pkg-config doesn't follow the general pattern: 13 postPatch = 14 prevAttrs.postPatch or "" 15 + '' 16 while IFS= read -r -d $'\0' path; do 17 sed -i \ 18 -e "s|^libdir\s*=.*/lib\$|libdir=''${!outputLib}/lib/stubs|" \ 19 -e "s|^Libs\s*:\(.*\)\$|Libs: \1 -Wl,-rpath,${addDriverRunpath.driverLink}/lib|" \ 20 "$path" 21 done < <(find -iname 'cuda-*.pc' -print0) 22 '' 23 # Namelink may not be enough, add a soname. 24 # Cf. https://gitlab.kitware.com/cmake/cmake/-/issues/25536 25 + '' 26 if [[ -f lib/stubs/libcuda.so && ! -f lib/stubs/libcuda.so.1 ]]; then 27 ln -s libcuda.so lib/stubs/libcuda.so.1 28 fi 29 ''; 30 31 postFixup = prevAttrs.postFixup or "" + '' 32 moveToOutput lib/stubs "$stubs" 33 ln -s "$stubs"/lib/stubs/* "$stubs"/lib/ 34 ln -s "$stubs"/lib/stubs "''${!outputLib}/lib/stubs" 35 ''; 36}