cuda-modules: don't use *Platform attributes from pkgs

For more information about *why* this is desirable, see
https://github.com/NixOS/nixpkgs/pull/45717
and
https://github.com/NixOS/nixpkgs/issues/27069
This commit is contained in:
Connor Baker 2024-04-03 16:32:02 +00:00
parent 2639fa16b9
commit 14635b4092
7 changed files with 33 additions and 8 deletions

View File

@ -1,5 +1,12 @@
{ hostPlatform, lib }:
{
lib,
# NOTE: We would use backendStdenv to get the hostPlatform, but it's not available in the callPackage context
# we're using to call this file.
stdenv,
}:
let
inherit (stdenv) hostPlatform;
# Samples are built around the CUDA Toolkit, which is not available for
# aarch64. Check for both CUDA version and platform.
platformIsSupported = hostPlatform.isx86_64 && hostPlatform.isLinux;

View File

@ -1,7 +1,9 @@
{
cudaVersion,
hostPlatform,
lib,
# NOTE: We would use backendStdenv to get the hostPlatform, but it's not available in the callPackage context
# we're using to call this file.
stdenv,
}:
let
cudaVersionToHash = {
@ -23,6 +25,8 @@ let
"12.3" = "sha256-fjVp0G6uRCWxsfe+gOwWTN+esZfk0O5uxS623u0REAk=";
};
inherit (stdenv) hostPlatform;
# Samples are built around the CUDA Toolkit, which is not available for
# aarch64. Check for both CUDA version and platform.
cudaVersionIsSupported = cudaVersionToHash ? ${cudaVersion};

View File

@ -15,9 +15,11 @@
{
cudaVersion,
flags,
hostPlatform,
lib,
mkVersionedPackageName,
# NOTE: We would use backendStdenv to get the hostPlatform, but it's not available in the callPackage context
# we're using to call this file.
stdenv,
}:
let
inherit (lib)
@ -29,6 +31,8 @@ let
trivial
;
inherit (stdenv) hostPlatform;
redistName = "cutensor";
pname = "libcutensor";

View File

@ -7,7 +7,9 @@
cudaForwardCompat ? (config.cudaForwardCompat or true),
lib,
cudaVersion,
hostPlatform,
# NOTE: We cannot refer to backendStdenv as flags exists outside the fixed-point;
# otherwise, we would use that to get the hostPlatform.
stdenv,
# gpus :: List Gpu
gpus,
}:
@ -20,6 +22,8 @@ let
trivial
;
inherit (stdenv) hostPlatform;
# Flags are determined based on your CUDA toolkit by default. You may benefit
# from improved performance, reduced file size, or greater hardware support by
# passing a configuration based on your specific GPU environment.

View File

@ -10,7 +10,6 @@
markForCudatoolkitRootHook,
flags,
stdenv,
hostPlatform,
# Builder-specific arguments
# Short package name (e.g., "cuda_cccl")
# pname : String
@ -40,6 +39,8 @@ let
sourceTypes
;
inherit (backendStdenv) hostPlatform;
# Get the redist architectures for which package provides distributables.
# These are used by meta.platforms.
supportedRedistArchs = builtins.attrNames featureRelease;
@ -48,7 +49,7 @@ let
# It is `"unsupported"` if the redistributable is not supported on the target platform.
redistArch = flags.getRedistArch hostPlatform.system;
sourceMatchesHost = flags.getNixSystem redistArch == stdenv.hostPlatform.system;
sourceMatchesHost = flags.getNixSystem redistArch == hostPlatform.system;
in
backendStdenv.mkDerivation (finalAttrs: {
# NOTE: Even though there's no actual buildPhase going on here, the derivations of the

View File

@ -3,7 +3,9 @@
lib,
cudaVersion,
flags,
hostPlatform,
# NOTE: We would use backendStdenv to get the hostPlatform, but it's not available in the callPackage context
# we're using to call this file (cudaPackages.callPackage).
stdenv,
# Expected to be passed by the caller
mkVersionedPackageName,
# pname :: String
@ -40,6 +42,8 @@ let
strings
;
inherit (stdenv) hostPlatform;
evaluatedModules = modules.evalModules {
modules = [
../modules

View File

@ -1,7 +1,7 @@
{
backendStdenv,
cudaVersion,
final,
hostPlatform,
lib,
mkVersionedPackageName,
package,
@ -17,6 +17,7 @@ let
strings
versions
;
inherit (backendStdenv) hostPlatform;
# targetArch :: String
targetArch = attrsets.attrByPath [ hostPlatform.system ] "unsupported" {
x86_64-linux = "x86_64-linux-gnu";