From 2cf7ffd71d8e5fd29b0a5c7073b677182dc925f1 Mon Sep 17 00:00:00 2001 From: Elliot Cameron Date: Thu, 29 Feb 2024 18:08:39 -0500 Subject: [PATCH 1/6] yaml-ccp: allow overriding static build --- pkgs/development/libraries/yaml-cpp/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/yaml-cpp/default.nix b/pkgs/development/libraries/yaml-cpp/default.nix index 20d546e346b8..6526561c6ef7 100644 --- a/pkgs/development/libraries/yaml-cpp/default.nix +++ b/pkgs/development/libraries/yaml-cpp/default.nix @@ -3,6 +3,7 @@ , fetchFromGitHub , gitUpdater , cmake +, static ? stdenv.hostPlatform.isStatic }: stdenv.mkDerivation rec { @@ -24,7 +25,7 @@ stdenv.mkDerivation rec { cmakeFlags = [ "-DYAML_CPP_BUILD_TOOLS=false" - "-DYAML_BUILD_SHARED_LIBS=${lib.boolToString (!stdenv.hostPlatform.isStatic)}" + (lib.cmakeBool "YAML_BUILD_SHARED_LIBS" (!static)) "-DINSTALL_GTEST=false" ]; From ca5b44fbd011933618be66ad9bd40decf0aa9192 Mon Sep 17 00:00:00 2001 From: Elliot Cameron Date: Thu, 29 Feb 2024 18:09:15 -0500 Subject: [PATCH 2/6] dcgm: fix build by using static yaml-cpp --- pkgs/os-specific/linux/dcgm/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/dcgm/default.nix b/pkgs/os-specific/linux/dcgm/default.nix index f3ebdf1427eb..63fb669d922c 100644 --- a/pkgs/os-specific/linux/dcgm/default.nix +++ b/pkgs/os-specific/linux/dcgm/default.nix @@ -26,6 +26,7 @@ let }); jsoncpp-static = jsoncpp.override { enableStatic = true; }; + yaml-cpp-static = yaml-cpp.override { static = true; }; # DCGM depends on 3 different versions of CUDA at the same time. # The runtime closure, thankfully, is quite small because most things @@ -123,7 +124,7 @@ in gcc11Stdenv.mkDerivation rec { fmt_9 jsoncpp-static libevent-nossl-static - yaml-cpp + yaml-cpp-static ]; disallowedReferences = lib.concatMap (x: x.pkgSet) cudaPackageSetByVersion; From f7b4ce1cfe07acb31191fed323e306afa0fe5799 Mon Sep 17 00:00:00 2001 From: Elliot Cameron Date: Thu, 29 Feb 2024 18:13:24 -0500 Subject: [PATCH 3/6] dcgm: 3.2.5 -> 3.3.5 --- pkgs/os-specific/linux/dcgm/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/dcgm/default.nix b/pkgs/os-specific/linux/dcgm/default.nix index 63fb669d922c..7017c34a7ddd 100644 --- a/pkgs/os-specific/linux/dcgm/default.nix +++ b/pkgs/os-specific/linux/dcgm/default.nix @@ -86,13 +86,13 @@ let # C.f. https://github.com/NVIDIA/DCGM/blob/7e1012302679e4bb7496483b32dcffb56e528c92/dcgmbuild/build.sh#L22 in gcc11Stdenv.mkDerivation rec { pname = "dcgm"; - version = "3.2.5"; # N.B: If you change this, be sure prometheus-dcgm-exporter supports this version. + version = "3.3.5"; # N.B: If you change this, be sure prometheus-dcgm-exporter supports this version. src = fetchFromGitHub { owner = "NVIDIA"; repo = "DCGM"; rev = "refs/tags/v${version}"; - hash = "sha256-iMyYOr3dSpdRV2S/TlB/tEOAWYhK09373ZRbd5vzogQ="; + hash = "sha256-n/uWvgvxAGfr1X51XgtHfFGDOO5AMBSV5UWQQpsylpg="; }; # Add our paths to the CUDA paths so FindCuda.cmake can find them. From d1e7e92949ad9f0eb7f2756bb08c392366d200a1 Mon Sep 17 00:00:00 2001 From: Elliot Cameron Date: Thu, 29 Feb 2024 18:17:26 -0500 Subject: [PATCH 4/6] prometheus-dcgm-exporter: 3.2.5-3.1.7 -> 3.3.5-3.4.0 Changes to go.mod are no longer needed because the package upgraded to go 1.21. --- .../prometheus/dcgm-exporter/default.nix | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/pkgs/servers/monitoring/prometheus/dcgm-exporter/default.nix b/pkgs/servers/monitoring/prometheus/dcgm-exporter/default.nix index c995d4036ae0..a2e5d052290f 100644 --- a/pkgs/servers/monitoring/prometheus/dcgm-exporter/default.nix +++ b/pkgs/servers/monitoring/prometheus/dcgm-exporter/default.nix @@ -3,31 +3,19 @@ , fetchFromGitHub , cudaPackages , dcgm -, linuxPackages }: buildGoModule rec { pname = "dcgm-exporter"; # The first portion of this version string corresponds to a compatible DCGM # version. - version = "3.2.5-3.1.7"; # N.B: If you change this, update dcgm as well to the matching version. + version = "3.3.5-3.4.0"; # N.B: If you change this, update dcgm as well to the matching version. src = fetchFromGitHub { owner = "NVIDIA"; repo = pname; rev = "refs/tags/${version}"; - hash = "sha256-+Hviq+iu1LBcy2VwmCX5xOq1I/zevfydesVlrVorGOI="; - }; - - # Upgrade to go 1.17 during the vendoring FOD build because it fails otherwise. - overrideModAttrs = _: { - preBuild = '' - substituteInPlace go.mod --replace 'go 1.16' 'go 1.17' - go mod tidy - ''; - postInstall = '' - cp go.mod "$out/go.mod" - ''; + hash = "sha256-IOVPEK+9ogBZJYns2pTyJwHUBMN8JqG1THTJPvpCwdo="; }; CGO_LDFLAGS = "-ldcgm"; @@ -40,12 +28,7 @@ buildGoModule rec { # symbols are available on startup. hardeningDisable = [ "bindnow" ]; - # Copy the modified go.mod we got from the vendoring process. - preBuild = '' - cp vendor/go.mod go.mod - ''; - - vendorHash = "sha256-Fjvx15e/psxoqoS6c6GhiQfe7g2aI40EmPR26xLhrzg="; + vendorHash = "sha256-urKa0O8QZnM8cWjPcGVhoAWhx6fCdMmhRX0JOriRaig="; nativeBuildInputs = [ cudaPackages.autoAddOpenGLRunpathHook From a9e897c9474e7e3016c11067588857fe4791cd8b Mon Sep 17 00:00:00 2001 From: Elliot Cameron Date: Fri, 15 Mar 2024 14:57:20 -0400 Subject: [PATCH 5/6] libevent: add static build option --- pkgs/development/libraries/libevent/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/libevent/default.nix b/pkgs/development/libraries/libevent/default.nix index 782d86f1f581..92c076f59ee1 100644 --- a/pkgs/development/libraries/libevent/default.nix +++ b/pkgs/development/libraries/libevent/default.nix @@ -1,6 +1,8 @@ { lib, stdenv, fetchurl, findutils, fixDarwinDylibNames , sslSupport ? true, openssl , fetchpatch + +, static ? stdenv.hostPlatform.isStatic }: stdenv.mkDerivation rec { @@ -20,7 +22,10 @@ stdenv.mkDerivation rec { }) ]; - configureFlags = lib.optional (!sslSupport) "--disable-openssl"; + configureFlags = lib.flatten [ + (lib.optional (!sslSupport) "--disable-openssl") + (lib.optionals static ["--disable-shared" "--with-pic"]) + ]; preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") '' MACOSX_DEPLOYMENT_TARGET=10.16 From d86fc14f8bb7ab11985d43c0129169c4129f56ba Mon Sep 17 00:00:00 2001 From: Elliot Cameron Date: Fri, 15 Mar 2024 15:02:37 -0400 Subject: [PATCH 6/6] dcgm: add static build option Currently only one dependency (yaml-cpp) actually supports being either static or dynamic because DCGM's build system hard-codes the use of static artifacts for other dependencies. We note that in the comments as future work. --- pkgs/os-specific/linux/dcgm/default.nix | 31 +++++++++++-------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/pkgs/os-specific/linux/dcgm/default.nix b/pkgs/os-specific/linux/dcgm/default.nix index 7017c34a7ddd..351c0909de3b 100644 --- a/pkgs/os-specific/linux/dcgm/default.nix +++ b/pkgs/os-specific/linux/dcgm/default.nix @@ -15,19 +15,10 @@ , symlinkJoin , tclap_1_4 , yaml-cpp + +, static ? gcc11Stdenv.hostPlatform.isStatic }: let - # Flags copied from DCGM's libevent build script - libevent-nossl = libevent.override { sslSupport = false; }; - libevent-nossl-static = libevent-nossl.overrideAttrs (super: { - CFLAGS = "-Wno-cast-function-type -Wno-implicit-fallthrough -fPIC"; - CXXFLAGS = "-Wno-cast-function-type -Wno-implicit-fallthrough -fPIC"; - configureFlags = super.configureFlags ++ [ "--disable-shared" "--with-pic" ]; - }); - - jsoncpp-static = jsoncpp.override { enableStatic = true; }; - yaml-cpp-static = yaml-cpp.override { static = true; }; - # DCGM depends on 3 different versions of CUDA at the same time. # The runtime closure, thankfully, is quite small because most things # are statically linked. @@ -117,14 +108,18 @@ in gcc11Stdenv.mkDerivation rec { ]; buildInputs = [ - plog.dev # header-only - tclap_1_4 # header-only - + # Header-only catch2 - fmt_9 - jsoncpp-static - libevent-nossl-static - yaml-cpp-static + plog.dev + tclap_1_4 + + # Dependencies that can be either static or dynamic. + (fmt_9.override { enableShared = !static; }) # DCGM's build uses the static outputs regardless of enableShared + (yaml-cpp.override { inherit static; stdenv = gcc11Stdenv; }) + + # TODO: Dependencies that DCGM's CMake hard-codes to be static-only. + (jsoncpp.override { enableStatic = true; }) + (libevent.override { sslSupport = false; static = true; }) ]; disallowedReferences = lib.concatMap (x: x.pkgSet) cudaPackageSetByVersion;