git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #107030 from cpcloud/nomad-nvml

nomad: add optional nvml support

commit20489e31cd2cada27690612689a3bf5e608c5109 authorSandro <sandro.jaeckel@gmail.com> dateSun 3 Jan 2021, 10:19 (6 years ago) parent590feee1f91cad
4 files changed+48−18
pkgs/applications/networking/cluster/nomad/0.11.nix+6−2 pkgs/applications/networking/cluster/nomad/0.12.nix+6−2 pkgs/applications/networking/cluster/nomad/generic.nix+32−14 pkgs/top-level/all-packages.nix+4
pkgs/applications/networking/cluster/nomad/0.11.nix+6−2
@@ -1,7 +1,11 @@
1−{ callPackage, buildGoPackage }:
1+{ callPackage
2+, buildGoPackage
3+, nvidia_x11
4+, nvidiaGpuSupport
5+}:
26
37callPackage ./generic.nix {
4− inherit buildGoPackage;
8+ inherit buildGoPackage nvidia_x11 nvidiaGpuSupport;
59 version = "0.11.8";
610 sha256 = "1dhh07bifr02jh2lls8fv1d9ra67ymgh8qxqvpvm0cd0qdd469z1";
711}
pkgs/applications/networking/cluster/nomad/0.12.nix+6−2
@@ -1,7 +1,11 @@
1−{ callPackage, buildGoPackage }:
1+{ callPackage
2+, buildGoPackage
3+, nvidia_x11
4+, nvidiaGpuSupport
5+}:
26
37callPackage ./generic.nix {
4− inherit buildGoPackage;
8+ inherit buildGoPackage nvidia_x11 nvidiaGpuSupport;
59 version = "0.12.9";
610 sha256 = "1a0ig6pb0z3qp7zk4jgz3h241bifmjlyqsfikyy3sxdnzj7yha27";
711}
pkgs/applications/networking/cluster/nomad/generic.nix+32−14
@@ -1,4 +1,12 @@
1−{ stdenv, buildGoPackage, fetchFromGitHub, version, sha256 }:
1+{ lib
2+, buildGoPackage
3+, fetchFromGitHub
4+, version
5+, sha256
6+, nvidiaGpuSupport
7+, patchelf
8+, nvidia_x11
9+}:
210
311buildGoPackage rec {
412 pname = "nomad";
@@ -14,23 +22,33 @@ buildGoPackage rec {
1422 inherit rev sha256;
1523 };
1624
25+ nativeBuildInputs = lib.optionals nvidiaGpuSupport [
26+ patchelf
27+ ];
28+
1729 # ui:
1830 # Nomad release commits include the compiled version of the UI, but the file
1931 # is only included if we build with the ui tag.
20− # nonvidia:
21− # We disable Nvidia GPU scheduling on Linux, as it doesn't work there:
22− # Ref: https://github.com/hashicorp/nomad/issues/5535
23− preBuild = let
24− tags = ["ui"]
25− ++ stdenv.lib.optional stdenv.isLinux "nonvidia";
26− tagsString = stdenv.lib.concatStringsSep " " tags;
27− in ''
28− export buildFlagsArray=(
29− -tags="${tagsString}"
30− )
31− '';
32+ preBuild =
33+ let
34+ tags = [ "ui" ] ++ lib.optional (!nvidiaGpuSupport) "nonvidia";
35+ tagsString = lib.concatStringsSep " " tags;
36+ in
37+ ''
38+ export buildFlagsArray=(
39+ -tags="${tagsString}"
40+ )
41+ '';
42+
43+ # The dependency on NVML isn't explicit. We have to make it so otherwise the
44+ # binary will not know where to look for the relevant symbols.
45+ postFixup = lib.optionalString nvidiaGpuSupport ''
46+ for bin in $out/bin/*; do
47+ patchelf --add-needed "${nvidia_x11}/lib/libnvidia-ml.so" "$bin"
48+ done
49+ '';
3250
33− meta = with stdenv.lib; {
51+ meta = with lib; {
3452 homepage = "https://www.nomadproject.io/";
3553 description = "A Distributed, Highly Available, Datacenter-Aware Scheduler";
3654 platforms = platforms.unix;
pkgs/top-level/all-packages.nix+4
@@ -6129,9 +6129,13 @@ in
61296129 # with different versions we pin Go for all versions.
61306130 nomad_0_11 = callPackage ../applications/networking/cluster/nomad/0.11.nix {
61316131 buildGoPackage = buildGo114Package;
6132+ inherit (linuxPackages) nvidia_x11;
6133+ nvidiaGpuSupport = config.cudaSupport or (!stdenv.isLinux);
61326134 };
61336135 nomad_0_12 = callPackage ../applications/networking/cluster/nomad/0.12.nix {
61346136 buildGoPackage = buildGo114Package;
6137+ inherit (linuxPackages) nvidia_x11;
6138+ nvidiaGpuSupport = config.cudaSupport or (!stdenv.isLinux);
61356139 };
61366140 nomad_1_0 = callPackage ../applications/networking/cluster/nomad/1.0.nix {
61376141 buildGoPackage = buildGo115Package;