···1213To use one or more CUDA packages in an expression, give the expression a `cudaPackages` parameter, and in case CUDA is optional
14```nix
15-cudaSupport ? false
16-cudaPackages ? {}
00017```
1819When using `callPackage`, you can choose to pass in a different variant, e.g.
···1213To use one or more CUDA packages in an expression, give the expression a `cudaPackages` parameter, and in case CUDA is optional
14```nix
15+{ config
16+, cudaSupport ? config.cudaSupport
17+, cudaPackages ? { }
18+, ...
19+}:
20```
2122When using `callPackage`, you can choose to pass in a different variant, e.g.
···1+From 982d38084f08950863b55043f36ce5548bd73635 Mon Sep 17 00:00:00 2001
2+From: Maximilian Bosch <maximilian@mbosch.me>
3+Date: Mon, 24 Jul 2023 19:12:25 +0200
4+Subject: [PATCH] Strip away BUILDCONFIG
5+6+The `BuildConfig` field in `libsofficeapp.so` includes the entire
7+`PKG_CONFIG_PATH` and subsequently references to a lot of `dev` outputs
8+of library dependencies blowing up the closure.
9+10+Since this is not strictly needed and the inputs are comprehensible via
11+`nix derivation show`, this doesn't bring a real benefit in the case of
12+nixpkgs anyways.
13+---
14+ desktop/source/lib/init.cxx | 2 +-
15+ 1 file changed, 1 insertion(+), 1 deletion(-)
16+17+diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
18+index 8d830c0cbd00..fbdc86aa7115 100644
19+--- a/desktop/source/lib/init.cxx
20++++ b/desktop/source/lib/init.cxx
21+@@ -7097,7 +7097,7 @@ static char* lo_getVersionInfo(SAL_UNUSED_PARAMETER LibreOfficeKit* /*pThis*/)
22+ "\"ProductVersion\": \"%PRODUCTVERSION\", "
23+ "\"ProductExtension\": \"%PRODUCTEXTENSION\", "
24+ "\"BuildId\": \"%BUILDID\", "
25+- "\"BuildConfig\": \"" BUILDCONFIG "\" "
26++ "\"BuildConfig\": \"removed to avoid runtime dependencies against dev outputs of each dependency. Use 'nix derivation show' against the package to find out details about BuildConfig.\" "
27+ "}"));
28+ }
29+30+--
31+2.40.1
32+
+16
pkgs/applications/office/libreoffice/default.nix
···214 tar -xf ${srcs.translations}
215 '';
2160000000000000000217 ### QT/KDE
218 #
219 # configure.ac assumes that the first directory that contains headers and
···214 tar -xf ${srcs.translations}
215 '';
216217+ # Remove build config to reduce the amount of `-dev` outputs in the
218+ # runtime closure. This was introduced in upstream commit
219+ # cbfac11330882c7d0a817b6c37a08b2ace2b66f4, so the patch doesn't apply
220+ # for 7.4.
221+ patches = lib.optionals (lib.versionAtLeast version "7.5") [
222+ ./0001-Strip-away-BUILDCONFIG.patch
223+ ];
224+225+ # libreoffice tries to reference the BUILDCONFIG (e.g. PKG_CONFIG_PATH)
226+ # in the binary causing the closure size to blow up because of many unnecessary
227+ # dependencies to dev outputs. This behavior was patched away in nixpkgs
228+ # (see above), make sure these don't leak again by accident.
229+ disallowedRequisites = lib.concatMap
230+ (x: lib.optional (x?dev) x.dev)
231+ buildInputs;
232+233 ### QT/KDE
234 #
235 # configure.ac assumes that the first directory that contains headers and
+1-1
pkgs/applications/radio/urh/default.nix
···33 homepage = "https://github.com/jopohl/urh";
34 description = "Universal Radio Hacker: investigate wireless protocols like a boss";
35 license = licenses.gpl3;
36- platforms = platforms.linux;
37 maintainers = with maintainers; [ fpletz ];
38 };
39}
···33 homepage = "https://github.com/jopohl/urh";
34 description = "Universal Radio Hacker: investigate wireless protocols like a boss";
35 license = licenses.gpl3;
36+ platforms = platforms.unix;
37 maintainers = with maintainers; [ fpletz ];
38 };
39}
···24, libkrb5
25, krb5
26, makeWrapper
027, ncurses5
28, numactl
29, nss
···31, python3 # FIXME: CUDAToolkit 10 may still need python27
32, pulseaudio
33, requireFile
034, stdenv
35, backendStdenv # E.g. gcc11Stdenv, set in extension.nix
36, unixODBC
···80 addOpenGLRunpath
81 autoPatchelfHook
82 autoAddOpenGLRunpathHook
083 ] ++ lib.optionals (lib.versionOlder version "11") [
84 libsForQt5.wrapQtAppsHook
85 ] ++ lib.optionals (lib.versionAtLeast version "11.8") [
86 qt6Packages.wrapQtAppsHook
87 ];
00088 buildInputs = lib.optionals (lib.versionOlder version "11") [
89 libsForQt5.qt5.qtwebengine
90 freeglut
···129 (lib.getLib libtiff)
130 qt6Packages.qtwayland
131 rdma-core
132- ucx
133 xorg.libxshmfence
134 xorg.libxkbfile
135 ] ++ (lib.optionals (lib.versionAtLeast version "12.1") (map lib.getLib ([
···280 sed -i "1 i#define _BITS_FLOATN_H" "$out/include/host_defines.h"
281 '' +
282 # Point NVCC at a compatible compiler
283- # FIXME: redist cuda_nvcc copy-pastes this code
284- # Refer to comments in the overrides for cuda_nvcc for explanation
285 # CUDA_TOOLKIT_ROOT_DIR is legacy,
286 # Cf. https://cmake.org/cmake/help/latest/module/FindCUDA.html#input-variables
287- # NOTE: We unconditionally set -Xfatbin=-compress-all, which reduces the size of the compiled
288- # binaries. If binaries grow over 2GB, they will fail to link. This is a problem for us, as
289- # the default set of CUDA capabilities we build can regularly cause this to occur (for
290- # example, with Magma).
291 ''
292 mkdir -p $out/nix-support
293 cat <<EOF >> $out/nix-support/setup-hook
294 cmakeFlags+=' -DCUDA_TOOLKIT_ROOT_DIR=$out'
295- cmakeFlags+=' -DCUDA_HOST_COMPILER=${backendStdenv.cc}/bin'
296- cmakeFlags+=' -DCMAKE_CUDA_HOST_COMPILER=${backendStdenv.cc}/bin'
297- if [ -z "\''${CUDAHOSTCXX-}" ]; then
298- export CUDAHOSTCXX=${backendStdenv.cc}/bin;
299- fi
300- export NVCC_PREPEND_FLAGS+=' --compiler-bindir=${backendStdenv.cc}/bin -Xfatbin=-compress-all'
301 EOF
302303 # Move some libraries to the lib output so that programs that
···24, libkrb5
25, krb5
26, makeWrapper
27+, markForCudatoolkitRootHook
28, ncurses5
29, numactl
30, nss
···32, python3 # FIXME: CUDAToolkit 10 may still need python27
33, pulseaudio
34, requireFile
35+, setupCudaHook
36, stdenv
37, backendStdenv # E.g. gcc11Stdenv, set in extension.nix
38, unixODBC
···82 addOpenGLRunpath
83 autoPatchelfHook
84 autoAddOpenGLRunpathHook
85+ markForCudatoolkitRootHook
86 ] ++ lib.optionals (lib.versionOlder version "11") [
87 libsForQt5.wrapQtAppsHook
88 ] ++ lib.optionals (lib.versionAtLeast version "11.8") [
89 qt6Packages.wrapQtAppsHook
90 ];
91+ depsTargetTargetPropagated = [
92+ setupCudaHook
93+ ];
94 buildInputs = lib.optionals (lib.versionOlder version "11") [
95 libsForQt5.qt5.qtwebengine
96 freeglut
···135 (lib.getLib libtiff)
136 qt6Packages.qtwayland
137 rdma-core
138+ (ucx.override { enableCuda = false; }) # Avoid infinite recursion
139 xorg.libxshmfence
140 xorg.libxkbfile
141 ] ++ (lib.optionals (lib.versionAtLeast version "12.1") (map lib.getLib ([
···286 sed -i "1 i#define _BITS_FLOATN_H" "$out/include/host_defines.h"
287 '' +
288 # Point NVCC at a compatible compiler
00289 # CUDA_TOOLKIT_ROOT_DIR is legacy,
290 # Cf. https://cmake.org/cmake/help/latest/module/FindCUDA.html#input-variables
0000291 ''
292 mkdir -p $out/nix-support
293 cat <<EOF >> $out/nix-support/setup-hook
294 cmakeFlags+=' -DCUDA_TOOLKIT_ROOT_DIR=$out'
000000295 EOF
296297 # Move some libraries to the lib output so that programs that
···1+# shellcheck shell=bash
2+3+# CMake's enable_language(CUDA) runs a compiler test and it doesn't account for
4+# CUDAToolkit_ROOT. We have to help it locate libcudart
5+export NVCC_APPEND_FLAGS+=" -L@cudartRoot@/lib -I@cudartRoot@/include"
···1+# shellcheck shell=bash
2+3+echo Sourcing setup-cuda-hook >&2
4+5+extendCUDAToolkit_ROOT() {
6+ if [[ -f "$1/nix-support/include-in-cudatoolkit-root" ]] ; then
7+ addToSearchPathWithCustomDelimiter ";" CUDAToolkit_ROOT "$1"
8+9+ if [[ -d "$1/include" ]] ; then
10+ addToSearchPathWithCustomDelimiter ";" CUDAToolkit_INCLUDE_DIR "$1/include"
11+ fi
12+ fi
13+}
14+15+addEnvHooks "$targetOffset" extendCUDAToolkit_ROOT
16+17+setupCUDAToolkitCompilers() {
18+ echo Executing setupCUDAToolkitCompilers >&2
19+20+ if [[ -n "${dontSetupCUDAToolkitCompilers-}" ]] ; then
21+ return
22+ fi
23+24+ # Point NVCC at a compatible compiler
25+26+ # For CMake-based projects:
27+ # https://cmake.org/cmake/help/latest/module/FindCUDA.html#input-variables
28+ # https://cmake.org/cmake/help/latest/envvar/CUDAHOSTCXX.html
29+ # https://cmake.org/cmake/help/latest/variable/CMAKE_CUDA_HOST_COMPILER.html
30+31+ export cmakeFlags+=" -DCUDA_HOST_COMPILER=@ccFullPath@"
32+ export cmakeFlags+=" -DCMAKE_CUDA_HOST_COMPILER=@ccFullPath@"
33+34+ # For non-CMake projects:
35+ # We prepend --compiler-bindir to nvcc flags.
36+ # Downstream packages can override these, because NVCC
37+ # uses the last --compiler-bindir it gets on the command line.
38+ # FIXME: this results in "incompatible redefinition" warnings.
39+ # https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#compiler-bindir-directory-ccbin
40+ if [ -z "${CUDAHOSTCXX-}" ]; then
41+ export CUDAHOSTCXX="@ccFullPath@";
42+ fi
43+44+ export NVCC_PREPEND_FLAGS+=" --compiler-bindir=@ccRoot@/bin"
45+46+ # NOTE: We set -Xfatbin=-compress-all, which reduces the size of the compiled
47+ # binaries. If binaries grow over 2GB, they will fail to link. This is a problem for us, as
48+ # the default set of CUDA capabilities we build can regularly cause this to occur (for
49+ # example, with Magma).
50+ #
51+ # @SomeoneSerge: original comment was made by @ConnorBaker in .../cudatoolkit/common.nix
52+ if [[ -z "${dontCompressFatbin-}" ]]; then
53+ export NVCC_PREPEND_FLAGS+=" -Xfatbin=-compress-all"
54+ fi
55+56+ # CMake's enable_language(CUDA) runs a compiler test and it doesn't account for
57+ # CUDAToolkit_ROOT. We have to help it locate libcudart
58+ if [[ -z "${nvccDontPrependCudartFlags-}" ]] ; then
59+ export NVCC_APPEND_FLAGS+=" -L@cudartRoot@/lib -I@cudartRoot@/include"
60+ fi
61+}
62+63+setupCMakeCUDAToolkit_ROOT() {
64+ export cmakeFlags+=" -DCUDAToolkit_INCLUDE_DIR=$CUDAToolkit_INCLUDE_DIR -DCUDAToolkit_ROOT=$CUDAToolkit_ROOT"
65+}
66+67+postHooks+=(setupCUDAToolkitCompilers)
68+preConfigureHooks+=(setupCMakeCUDAToolkit_ROOT)
···27 inherit (prev.backendStdenv) cc;
28 in
29 {
30- # Point NVCC at a compatible compiler
31- # FIXME: non-redist cudatoolkit copy-pastes this code
003233- # For CMake-based projects:
34- # https://cmake.org/cmake/help/latest/module/FindCUDA.html#input-variables
35- # https://cmake.org/cmake/help/latest/envvar/CUDAHOSTCXX.html
36- # https://cmake.org/cmake/help/latest/variable/CMAKE_CUDA_HOST_COMPILER.html
3738- # For non-CMake projects:
39- # We prepend --compiler-bindir to nvcc flags.
40- # Downstream packages can override these, because NVCC
41- # uses the last --compiler-bindir it gets on the command line.
42- # FIXME: this results in "incompatible redefinition" warnings.
43- # https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#compiler-bindir-directory-ccbin
44- # NOTE: We unconditionally set -Xfatbin=-compress-all, which reduces the size of the
45- # compiled binaries. If binaries grow over 2GB, they will fail to link. This is a problem
46- # for us, as the default set of CUDA capabilities we build can regularly cause this to
47- # occur (for example, with Magma).
48- postInstall = (oldAttrs.postInstall or "") + ''
49- mkdir -p $out/nix-support
50- cat <<EOF >> $out/nix-support/setup-hook
51- cmakeFlags+=' -DCUDA_HOST_COMPILER=${cc}/bin'
52- cmakeFlags+=' -DCMAKE_CUDA_HOST_COMPILER=${cc}/bin'
53- if [ -z "\''${CUDAHOSTCXX-}" ]; then
54- export CUDAHOSTCXX=${cc}/bin;
55- fi
56- export NVCC_PREPEND_FLAGS+=' --compiler-bindir=${cc}/bin -Xfatbin=-compress-all'
57- EOF
58- '';
59 });
6061 cuda_nvprof = prev.cuda_nvprof.overrideAttrs (oldAttrs: {
···27 inherit (prev.backendStdenv) cc;
28 in
29 {
30+ # Required by cmake's enable_language(CUDA) to build a test program
31+ # When implementing cross-compilation support: this is
32+ # final.pkgs.targetPackages.cudaPackages.cuda_cudart
33+ env.cudartRoot = "${prev.lib.getDev final.cuda_cudart}";
3435+ # Point NVCC at a compatible compiler
0003637+ # Desiredata: whenever a package (e.g. magma) adds cuda_nvcc to
38+ # nativeBuildInputs (offsets `(-1, 0)`), magma should also source the
39+ # setupCudaHook, i.e. we want it the hook to be propagated into the
40+ # same nativeBuildInputs.
41+ #
42+ # Logically, cuda_nvcc should include the hook in depsHostHostPropagated,
43+ # so that the final offsets for the propagated hook would be `(-1, 0) +
44+ # (0, 0) = (-1, 0)`.
45+ #
46+ # In practice, TargetTarget appears to work:
47+ # https://gist.github.com/fd80ff142cd25e64603618a3700e7f82
48+ depsTargetTargetPropagated = [
49+ final.setupCudaHook
50+ ];
000000051 });
5253 cuda_nvprof = prev.cuda_nvprof.overrideAttrs (oldAttrs: {
···4, avxSupport ? stdenv.hostPlatform.avxSupport
5, avx2Support ? stdenv.hostPlatform.avx2Support
6, avx512Support ? stdenv.hostPlatform.avx512Support
07# Enable NIVIA GPU support
8# Note, that this needs to be built on a system with a GPU
9# present for the tests to succeed.
10-, enableCuda ? false
11# type of GPU architecture
12, nvidiaArch ? "sm_60"
13, cudatoolkit
···4, avxSupport ? stdenv.hostPlatform.avxSupport
5, avx2Support ? stdenv.hostPlatform.avx2Support
6, avx512Support ? stdenv.hostPlatform.avx512Support
7+, config
8# Enable NIVIA GPU support
9# Note, that this needs to be built on a system with a GPU
10# present for the tests to succeed.
11+, enableCuda ? config.cudaSupport
12# type of GPU architecture
13, nvidiaArch ? "sm_60"
14, cudatoolkit
···37, blas
38, enableContrib ? true
3940-, enableCuda ? (config.cudaSupport or false) && stdenv.hostPlatform.isx86_64
41, enableCublas ? enableCuda
42, enableCudnn ? false # NOTE: CUDNN has a large impact on closure size so we disable it by default
43, enableCufft ? enableCuda
···37, blas
38, enableContrib ? true
3940+, enableCuda ? config.cudaSupport && stdenv.hostPlatform.isx86_64
41, enableCublas ? enableCuda
42, enableCudnn ? false # NOTE: CUDNN has a large impact on closure size so we disable it by default
43, enableCufft ? enableCuda
+2-2
pkgs/development/libraries/openmpi/default.nix
···1{ lib, stdenv, fetchurl, gfortran, perl, libnl
2, rdma-core, zlib, numactl, libevent, hwloc, targetPackages, symlinkJoin
3, libpsm2, libfabric, pmix, ucx
4-5# Enable CUDA support
6-, cudaSupport ? false, cudatoolkit
78# Enable the Sun Grid Engine bindings
9, enableSGE ? false
···17# that in nix as well. It would make some things easier and less confusing, but
18# it would also make the default tensorflow package unfree. See
19# https://groups.google.com/a/tensorflow.org/forum/#!topic/developers/iRCt5m4qUz0
20-, cudaSupport ? false
021, cudaPackages ? { }
22, cudaCapabilities ? cudaPackages.cudaFlags.cudaCapabilities
23, mklSupport ? false, mkl
···17# that in nix as well. It would make some things easier and less confusing, but
18# it would also make the default tensorflow package unfree. See
19# https://groups.google.com/a/tensorflow.org/forum/#!topic/developers/iRCt5m4qUz0
20+, config
21+, cudaSupport ? config.cudaSupport
22, cudaPackages ? { }
23, cudaCapabilities ? cudaPackages.cudaFlags.cudaCapabilities
24, mklSupport ? false, mkl
···1-# Wrap only the haskell-related tests from tests.writers
2-# in their own derivation for Hydra CI in the haskell-updates
3-# jobset. Can presumably removed as soon as tests.writers is
4-# always green on darwin as well:
5-# https://github.com/NixOS/nixpkgs/issues/126182
6-{ runCommand, tests }:
7-8-let
9- inherit (tests.writers)
10- writeTest
11- bin
12- simple
13- path
14- ;
15-in
16-17-runCommand "test-haskell-writers" {
18- meta = {
19- inherit (tests.writers.meta) platforms;
20- };
21-} ''
22- ${writeTest "success" "test-haskell-bin-writer" "${bin.haskell}/bin/${bin.haskell.name}"}
23- ${writeTest "success" "test-haskell-simple-writer" simple.haskell}
24- ${writeTest "success" "test-haskell-path-writer" path.haskell}
25- touch $out
26-''