at 22.05-pre 71 lines 2.2 kB view raw
1{ lib 2, glibc 3, fetchFromGitHub 4, makeWrapper 5, buildGoPackage 6, linkFarm 7, writeShellScript 8, containerRuntimePath 9, configTemplate 10}: 11let 12 isolatedContainerRuntimePath = linkFarm "isolated_container_runtime_path" [ 13 { 14 name = "runc"; 15 path = containerRuntimePath; 16 } 17 ]; 18 warnIfXdgConfigHomeIsSet = writeShellScript "warn_if_xdg_config_home_is_set" '' 19 set -eo pipefail 20 21 if [ -n "$XDG_CONFIG_HOME" ]; then 22 echo >&2 "$(tput setaf 3)warning: \$XDG_CONFIG_HOME=$XDG_CONFIG_HOME$(tput sgr 0)" 23 fi 24 ''; 25in 26buildGoPackage rec { 27 pname = "nvidia-container-runtime"; 28 version = "3.5.0"; 29 30 src = fetchFromGitHub { 31 owner = "NVIDIA"; 32 repo = pname; 33 rev = "v${version}"; 34 sha256 = "sha256-+LZjsN/tKqsPJamoI8xo9LFv14c3e9vVlSP4NJhElcs="; 35 }; 36 37 goPackagePath = "github.com/nvidia/nvidia-container-runtime"; 38 ldflags = [ "-s" "-w" ]; 39 nativeBuildInputs = [ makeWrapper ]; 40 41 postInstall = '' 42 mkdir -p $out/etc/nvidia-container-runtime 43 44 # nvidia-container-runtime invokes docker-runc or runc if that isn't 45 # available on PATH. 46 # 47 # Also set XDG_CONFIG_HOME if it isn't already to allow overriding 48 # configuration. This in turn allows users to have the nvidia container 49 # runtime enabled for any number of higher level runtimes like docker and 50 # podman, i.e., there's no need to have mutually exclusivity on what high 51 # level runtime can enable the nvidia runtime because each high level 52 # runtime has its own config.toml file. 53 wrapProgram $out/bin/nvidia-container-runtime \ 54 --run "${warnIfXdgConfigHomeIsSet}" \ 55 --prefix PATH : ${isolatedContainerRuntimePath} \ 56 --set-default XDG_CONFIG_HOME $out/etc 57 58 cp ${configTemplate} $out/etc/nvidia-container-runtime/config.toml 59 60 substituteInPlace $out/etc/nvidia-container-runtime/config.toml \ 61 --subst-var-by glibcbin ${lib.getBin glibc} 62 ''; 63 64 meta = with lib; { 65 homepage = "https://github.com/NVIDIA/nvidia-container-runtime"; 66 description = "NVIDIA container runtime"; 67 license = licenses.asl20; 68 platforms = platforms.linux; 69 maintainers = with maintainers; [ cpcloud ]; 70 }; 71}