localPackages.nvhpc: allow multiple versions

This commit is contained in:
陈浩南 2024-02-20 18:54:51 +08:00
parent 81ed72bf92
commit 128b83a7c6
2 changed files with 44 additions and 36 deletions

View File

@ -51,5 +51,5 @@
slate = callPackage ./slate { src = topInputs.slate; };
nvhpc = callPackage ./nvhpc {};
lmod = callPackage ./lmod { src = topInputs.lmod; };
vasp-gpu = callPackage ./vasp-gpu { inherit nvhpc lmod;};
vasp-gpu = callPackage ./vasp-gpu { inherit lmod; nvhpc = nvhpc."24.1"; };
}

View File

@ -3,40 +3,48 @@
gcc, gfortran, autoPatchelfHook,
flock, glibc, coreutils, util-linux, iconv
}:
stdenvNoCC.mkDerivation rec
{
pname = "nvhpc";
version = "24.1";
src = let versions = builtins.splitVersion version; in fetchurl
let
versions =
{
url = "https://developer.download.nvidia.com/hpc-sdk/${version}/"
+ "nvhpc_20${builtins.elemAt versions 0}_${builtins.concatStringsSep "" versions}"
+ "_Linux_x86_64_cuda_multi.tar.gz";
sha256 = "1n0x1x7ywvr3623ylvrjagayn44mbvfas3c3062p7y3asmgjx697";
"24.1" = "1n0x1x7ywvr3623ylvrjagayn44mbvfas3c3062p7y3asmgjx697";
"23.1" = "1xg933f4n1bw39y1x1vrjrbzpx36sbmjgvi332hfck3dbx0n982m";
};
BuildInputs = [ gfortran gfortran.cc gcc ];
propagatedBuildInputs = BuildInputs;
nativeBuildInputs =
[
autoPatchelfHook flock
glibc.bin # ldconfig
coreutils # chmod
util-linux # rev
];
postUnpack = ''patchShebangs .'';
dontBuild = true;
dontStrip = true;
NVHPC_SILENT = "true";
NVHPC_INSTALL_TYPE = "single";
installPhase =
''
export NVHPC_INSTALL_DIR=$out/share/nvhpc
ldconfig -C $NIX_BUILD_TOP/ld.so.cache
sed -i 's|/bin/chmod|chmod|g' install_components/install
sed -i 's|/sbin/ldconfig|ldconfig -C $NIX_BUILD_TOP/ld.so.cache|g' install_components/install
sed -i 's|/usr/lib/x86_64-linux-gnu|${iconv.out}/lib|g' \
install_components/Linux_x86_64/${version}/compilers/bin/makelocalrc
./install
'';
autoPatchelfIgnoreMissingDeps = [ "*" ];
}
mkNvhpc = { version, sha256 }: stdenvNoCC.mkDerivation rec
{
pname = "nvhpc";
inherit version;
src = let versions = builtins.splitVersion version; in fetchurl
{
url = "https://developer.download.nvidia.com/hpc-sdk/${version}/"
+ "nvhpc_20${builtins.elemAt versions 0}_${builtins.concatStringsSep "" versions}"
+ "_Linux_x86_64_cuda_multi.tar.gz";
inherit sha256;
};
BuildInputs = [ gfortran gfortran.cc gcc ];
propagatedBuildInputs = BuildInputs;
nativeBuildInputs =
[
autoPatchelfHook flock
glibc.bin # ldconfig
coreutils # chmod
util-linux # rev
];
postUnpack = ''patchShebangs .'';
dontBuild = true;
dontStrip = true;
NVHPC_SILENT = "true";
NVHPC_INSTALL_TYPE = "single";
installPhase =
''
export NVHPC_INSTALL_DIR=$out/share/nvhpc
ldconfig -C $NIX_BUILD_TOP/ld.so.cache
sed -i 's|/bin/chmod|chmod|g' install_components/install
sed -i 's|/sbin/ldconfig|ldconfig -C $NIX_BUILD_TOP/ld.so.cache|g' install_components/install
sed -i 's|/usr/lib/x86_64-linux-gnu|${iconv.out}/lib|g' \
install_components/Linux_x86_64/${version}/compilers/bin/makelocalrc
./install
'';
autoPatchelfIgnoreMissingDeps = [ "*" ];
};
in
builtins.mapAttrs (version: sha256: mkNvhpc { inherit version sha256; }) versions