nixos/local/pkgs/vasp-gpu/default.nix

63 lines
1.6 KiB
Nix
Raw Normal View History

2024-02-21 16:14:39 +08:00
{
buildFHSEnv, writeScript, stdenvNoCC, requireFile, substituteAll,
config, cudaCapabilities ? config.cudaCapabilities, nvhpcArch ? config.nvhpcArch or "px",
nvhpc, lmod
}:
2024-02-21 15:27:39 +08:00
let
env = buildFHSEnv
2024-02-20 18:22:38 +08:00
{
2024-02-21 15:27:39 +08:00
name = "env";
targetPkgs = pkgs: with pkgs; [ nvhpc gfortran zlib which rsync mkl lmod ];
2024-02-20 18:22:38 +08:00
};
2024-02-21 15:27:39 +08:00
buildScript = writeScript "build"
2024-02-20 18:22:38 +08:00
''
2024-02-21 15:27:39 +08:00
. /usr/share/lmod/lmod/init/bash
module use /usr/share/nvhpc/modulefiles
2024-02-20 18:22:38 +08:00
module load nvhpc
mkdir -p bin
2024-02-21 15:27:39 +08:00
export MKLROOT=/usr
make DEPS=1 -j$NIX_BUILD_CORES
2024-02-20 18:22:38 +08:00
'';
2024-02-21 16:14:39 +08:00
include = substituteAll
{
src = ./makefile.include;
cudaCapabilities = builtins.concatStringsSep "," (builtins.map
(cap: "cc${builtins.replaceStrings ["."] [""] cap}")
cudaCapabilities);
inherit nvhpcArch;
};
2024-02-21 15:27:39 +08:00
vasp = stdenvNoCC.mkDerivation rec
{
pname = "vasp";
version = "6.4.0";
# nix-store --query --hash $(nix store add-path ./vasp-6.4.0)
src = requireFile
{
name = "${pname}-${version}";
sha256 = "189i1l5q33ynmps93p2mwqf5fx7p4l50sls1krqlv8ls14s3m71f";
hashMode = "recursive";
message = "Source file not found.";
};
2024-02-21 16:14:39 +08:00
configurePhase = "cp ${include} makefile.include";
2024-02-21 15:27:39 +08:00
enableParallelBuilding = true;
buildPhase = "${env}/bin/env ${buildScript}";
installPhase =
''
mkdir -p $out
cp -r bin $out
'';
};
2024-02-21 16:14:39 +08:00
startScript = writeScript "start"
''
. /usr/share/lmod/lmod/init/bash
module use /usr/share/nvhpc/modulefiles
module load nvhpc
exec $@
'';
2024-02-21 15:27:39 +08:00
in buildFHSEnv
{
name = "vasp-gpu";
targetPkgs = pkgs: with pkgs; [ nvhpc gfortran zlib mkl lmod vasp ];
2024-02-21 16:14:39 +08:00
runScript = startScript;
2024-02-20 18:22:38 +08:00
}