Skip to content

Commit

Permalink
{pkgs/development/cuda-modules,pkgs/test/cuda,pkgs/top-level/cuda-pac…
Browse files Browse the repository at this point in the history
…kages.nix}: reformat all CUDA files with nixfmt-rfc-style 2023-03-01

```bash
nix run github:NixOS/nixpkgs/ab6071eb54cc9b66dda436111d4f569e4e56cbf4#nixfmt-rfc-style -L --allow-import-from-derivation -- pkgs/development/cuda-modules pkgs/test/cuda pkgs/top-level/cuda-packages.nix
```
  • Loading branch information
Connor Baker committed Apr 1, 2024
1 parent 7f797a6 commit 93b08a7
Show file tree
Hide file tree
Showing 34 changed files with 961 additions and 981 deletions.
2 changes: 1 addition & 1 deletion pkgs/development/cuda-modules/backend-stdenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ let
assertCondition = true;
in

/* TODO: Consider testing whether we in fact use the newer libstdc++ */
# TODO: Consider testing whether we in fact use the newer libstdc++

lib.extendDerivation assertCondition passthruExtra cudaStdenv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{hostPlatform, lib}:
{ hostPlatform, lib }:
let
# Samples are built around the CUDA Toolkit, which is not available for
# aarch64. Check for both CUDA version and platform.
Expand All @@ -8,7 +8,7 @@ let
extension =
final: _:
lib.attrsets.optionalAttrs platformIsSupported {
cuda-library-samples = final.callPackage ./generic.nix {};
cuda-library-samples = final.callPackage ./generic.nix { };
};
in
extension
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let
cmake
addOpenGLRunpath
];
buildInputs = [cudatoolkit];
buildInputs = [ cudatoolkit ];
postFixup = ''
for exe in $out/bin/*; do
addOpenGLRunpath $exe
Expand All @@ -36,7 +36,7 @@ let
cuSPARSE, cuSOLVER, cuFFT, cuRAND, NPP and nvJPEG.
'';
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [obsidian-systems-maintenance] ++ lib.teams.cuda.members;
maintainers = with lib.maintainers; [ obsidian-systems-maintenance ] ++ lib.teams.cuda.members;
};
};
in
Expand Down Expand Up @@ -69,9 +69,9 @@ in

src = "${src}/cuTENSOR";

buildInputs = [cutensor];
buildInputs = [ cutensor ];

cmakeFlags = ["-DCUTENSOR_EXAMPLE_BINARY_INSTALL_DIR=${builtins.placeholder "out"}/bin"];
cmakeFlags = [ "-DCUTENSOR_EXAMPLE_BINARY_INSTALL_DIR=${builtins.placeholder "out"}/bin" ];

# CUTENSOR_ROOT is double escaped
postPatch = ''
Expand Down
98 changes: 48 additions & 50 deletions pkgs/development/cuda-modules/cuda-samples/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,65 +15,63 @@
let
inherit (lib) lists strings;
in
backendStdenv.mkDerivation (
finalAttrs: {
strictDeps = true;
backendStdenv.mkDerivation (finalAttrs: {
strictDeps = true;

pname = "cuda-samples";
version = cudaVersion;
pname = "cuda-samples";
version = cudaVersion;

src = fetchFromGitHub {
owner = "NVIDIA";
repo = finalAttrs.pname;
rev = "v${finalAttrs.version}";
inherit hash;
};
src = fetchFromGitHub {
owner = "NVIDIA";
repo = finalAttrs.pname;
rev = "v${finalAttrs.version}";
inherit hash;
};

nativeBuildInputs =
[
autoAddDriverRunpath
pkg-config
]
# CMake has to run as a native, build-time dependency for libNVVM samples.
# However, it's not the primary build tool -- that's still make.
# As such, we disable CMake's build system.
++ lists.optionals (strings.versionAtLeast finalAttrs.version "12.2") [cmake];
nativeBuildInputs =
[
autoAddDriverRunpath
pkg-config
]
# CMake has to run as a native, build-time dependency for libNVVM samples.
# However, it's not the primary build tool -- that's still make.
# As such, we disable CMake's build system.
++ lists.optionals (strings.versionAtLeast finalAttrs.version "12.2") [ cmake ];

dontUseCmakeConfigure = true;
dontUseCmakeConfigure = true;

buildInputs = [
cudatoolkit
freeimage
glfw3
];
buildInputs = [
cudatoolkit
freeimage
glfw3
];

# See https://github.com/NVIDIA/cuda-samples/issues/75.
patches = lib.optionals (finalAttrs.version == "11.3") [
(fetchpatch {
url = "https://github.com/NVIDIA/cuda-samples/commit/5c3ec60faeb7a3c4ad9372c99114d7bb922fda8d.patch";
hash = "sha256-0XxdmNK9MPpHwv8+qECJTvXGlFxc+fIbta4ynYprfpU=";
})
];
# See https://github.com/NVIDIA/cuda-samples/issues/75.
patches = lib.optionals (finalAttrs.version == "11.3") [
(fetchpatch {
url = "https://github.com/NVIDIA/cuda-samples/commit/5c3ec60faeb7a3c4ad9372c99114d7bb922fda8d.patch";
hash = "sha256-0XxdmNK9MPpHwv8+qECJTvXGlFxc+fIbta4ynYprfpU=";
})
];

enableParallelBuilding = true;
enableParallelBuilding = true;

preConfigure = ''
export CUDA_PATH=${cudatoolkit}
'';
preConfigure = ''
export CUDA_PATH=${cudatoolkit}
'';

installPhase = ''
runHook preInstall
installPhase = ''
runHook preInstall
install -Dm755 -t $out/bin bin/${backendStdenv.hostPlatform.parsed.cpu.name}/${backendStdenv.hostPlatform.parsed.kernel.name}/release/*
install -Dm755 -t $out/bin bin/${backendStdenv.hostPlatform.parsed.cpu.name}/${backendStdenv.hostPlatform.parsed.kernel.name}/release/*
runHook postInstall
'';
runHook postInstall
'';

meta = {
description = "Samples for CUDA Developers which demonstrates features in CUDA Toolkit";
# CUDA itself is proprietary, but these sample apps are not.
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [obsidian-systems-maintenance] ++ lib.teams.cuda.members;
};
}
)
meta = {
description = "Samples for CUDA Developers which demonstrates features in CUDA Toolkit";
# CUDA itself is proprietary, but these sample apps are not.
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ obsidian-systems-maintenance ] ++ lib.teams.cuda.members;
};
})
34 changes: 16 additions & 18 deletions pkgs/development/cuda-modules/cuda/extension.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{cudaVersion, lib}:
{ cudaVersion, lib }:
let
inherit (lib) attrsets modules trivial;
redistName = "cuda";
Expand Down Expand Up @@ -63,23 +63,21 @@ let
featureRelease
;
}).overrideAttrs
(
prevAttrs: {
# Add the package-specific license.
meta = prevAttrs.meta // {
license =
let
licensePath =
if redistribRelease.license_path != null then
redistribRelease.license_path
else
"${pname}/LICENSE.txt";
url = "https://developer.download.nvidia.com/compute/cuda/redist/${licensePath}";
in
lib.licenses.nvidiaCudaRedist // {inherit url;};
};
}
);
(prevAttrs: {
# Add the package-specific license.
meta = prevAttrs.meta // {
license =
let
licensePath =
if redistribRelease.license_path != null then
redistribRelease.license_path
else
"${pname}/LICENSE.txt";
url = "https://developer.download.nvidia.com/compute/cuda/redist/${licensePath}";
in
lib.licenses.nvidiaCudaRedist // { inherit url; };
};
});
in
drv;

Expand Down
Loading

0 comments on commit 93b08a7

Please sign in to comment.