From ebc05b991158bc96a542ac255715bda6b20238b2 Mon Sep 17 00:00:00 2001 From: Haonan Chen Date: Sat, 3 Jan 2026 15:57:18 +0800 Subject: [PATCH] flake.lib.buildNixpkgsConfig: enable lsf support for openmpi --- flake/lib/buildNixpkgsConfig/default.nix | 5 ++ flake/src.nix | 9 +++ packages/default.nix | 1 + packages/lsf.nix | 18 ++++++ packages/vasp/intel/default.nix | 82 ++++++++++++------------ 5 files changed, 75 insertions(+), 40 deletions(-) create mode 100644 packages/lsf.nix diff --git a/flake/lib/buildNixpkgsConfig/default.nix b/flake/lib/buildNixpkgsConfig/default.nix index 8093cdf0..b598266d 100644 --- a/flake/lib/buildNixpkgsConfig/default.nix +++ b/flake/lib/buildNixpkgsConfig/default.nix @@ -73,6 +73,11 @@ in platformConfig // { commandLineArgs = prev.commandLineArgs or "" + " --disable-features=GlobalShortcutsPortal"; }); xray = prev.xray.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./xray.patch ]; }); btop = prev.btop.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./btop.patch ]; }); + prrte = prev.prrte.overrideAttrs (prev: + { + configureFlags = prev.configureFlags or [] ++ [ "--with-lsf" ]; + buildInputs = prev.buildInputs or [] ++ [ final.localPackages.lsf final.libnsl ]; + }); } // ( let diff --git a/flake/src.nix b/flake/src.nix index 3d73f6be..1096cb42 100644 --- a/flake/src.nix +++ b/flake/src.nix @@ -211,4 +211,13 @@ structuredExtraConfig = { BTRFS_ALLOCATOR_HINTS = lib.kernel.yes; BTRFS_READ_POLICIES = lib.kernel.yes; }; }; }; + # download include from /opt/ibm/lsfsuite/lsf/10.1/include into lsf/include + # download lib from /opt/ibm/lsfsuite/lsf/10.1/linux2.6-glibc2.3-x86_64/lib into lsf/lib and only preserve .so + lsf = pkgs.requireFile + { + name = "lsf"; + sha256 = "0rij4xx705yj1vr5jd31hb8izmb35vkrdql0850qc5cn30jnkf4l"; + hashMode = "recursive"; + message = "lsf not found."; + }; } diff --git a/packages/default.nix b/packages/default.nix index 39086cb3..f57a45cb 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -147,6 +147,7 @@ inputs: rec missgram = inputs.pkgs.callPackage ./missgram { inherit biu sqlgen; stdenv = inputs.pkgs.clang18Stdenv; }; sqlgen = inputs.pkgs.callPackage ./sqlgen.nix { src = inputs.topInputs.sqlgen; inherit reflectcpp; }; reflectcpp = inputs.pkgs.callPackage ./reflectcpp.nix { src = inputs.topInputs.reflectcpp; }; + lsf = inputs.pkgs.callPackage ./lsf.nix { src = inputs.topInputs.self.src.lsf; }; fromYaml = content: builtins.fromJSON (builtins.readFile (inputs.pkgs.runCommand "toJSON" {} diff --git a/packages/lsf.nix b/packages/lsf.nix new file mode 100644 index 00000000..7ccfb37c --- /dev/null +++ b/packages/lsf.nix @@ -0,0 +1,18 @@ +{ stdenv, src, autoPatchelfHook, libz }: stdenv.mkDerivation rec +{ + name = "lsf"; + inherit src; + dontConfigure = true; + dontBuild = true; + buildInputs = [ stdenv.cc.cc libz ]; + nativeBuildInputs = [ autoPatchelfHook ]; + autoPatchelfIgnoreMissingDeps = [ "libnvidia-ml.so.1" ]; + installPhase = + '' + runHook preInstall + mkdir -p $out + cp -r * $out + rm $out/lib/{hwloc_nvml,sec_ego_kerberos,sec_ego_gsskrb,sec_ego_pam_default}.so + runHook postInstall + ''; +} diff --git a/packages/vasp/intel/default.nix b/packages/vasp/intel/default.nix index 0bc30068..fb920958 100644 --- a/packages/vasp/intel/default.nix +++ b/packages/vasp/intel/default.nix @@ -1,44 +1,46 @@ { stdenv, src, writeShellScriptBin, lib, rsync, which, wannier90, hdf5, mpi, mkl }: -let vasp = stdenv.mkDerivation -{ - name = "vasp-intel"; - src = src.vasp; - patches = [ ../vtst.patch ]; - configurePhase = +let + vasp = stdenv.mkDerivation + { + name = "vasp-intel"; + src = src.vasp; + patches = [ ../vtst.patch ]; + configurePhase = + '' + cp ${./makefile.include} makefile.include + chmod +w makefile.include + cp ${../constr_cell_relax.F} src/constr_cell_relax.F + cp -r ${src.vtst.patch}/vtstcode6.4.3/* src + chmod -R +w src + ''; + buildInputs = [ hdf5 wannier90 mkl ]; + nativeBuildInputs = [ rsync which mpi ]; + installPhase = + '' + mkdir -p $out/bin + for i in std gam ncl; do cp bin/vasp_$i $out/bin/vasp-$i; done + ''; + # NIX_DEBUG = "7"; + enableParallelBuilding = true; + env = { DEPS = "1"; MKLROOT = mkl; OMPI_F90 = "ifx"; }; + }; + wrapper = writeShellScriptBin "vasp-intel" '' - cp ${./makefile.include} makefile.include - chmod +w makefile.include - cp ${../constr_cell_relax.F} src/constr_cell_relax.F - cp -r ${src.vtst.patch}/vtstcode6.4.3/* src - chmod -R +w src - ''; - buildInputs = [ hdf5 wannier90 mkl ]; - nativeBuildInputs = [ rsync which mpi ]; - installPhase = - '' - mkdir -p $out/bin - for i in std gam ncl; do cp bin/vasp_$i $out/bin/vasp-$i; done - ''; - # NIX_DEBUG = "7"; - enableParallelBuilding = true; - env = { DEPS = "1"; MKLROOT = mkl; OMPI_F90 = "ifx"; }; -}; -in writeShellScriptBin "vasp-intel" -'' - export PATH=${vasp}/bin:${mpi}/bin''${PATH:+:$PATH} + export PATH=${vasp}/bin:${mpi}/bin''${PATH:+:$PATH} - # set OMP_NUM_THREADS if SLURM_CPUS_PER_TASK is set - if [ -z "$OMP_NUM_THREADS" ] && [ -n "$SLURM_CPUS_PER_TASK" ]; then - export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK - fi - # set OMP_NUM_THREADS to 1 if not set - if [ -z "$OMP_NUM_THREADS" ]; then - export OMP_NUM_THREADS=1 - fi - # set OMP_STACKSIZE to 512M if not set - if [ -z "$OMP_STACKSIZE" ]; then - export OMP_STACKSIZE=512m - fi + # set OMP_NUM_THREADS if SLURM_CPUS_PER_TASK is set + if [ -z "$OMP_NUM_THREADS" ] && [ -n "$SLURM_CPUS_PER_TASK" ]; then + export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK + fi + # set OMP_NUM_THREADS to 1 if not set + if [ -z "$OMP_NUM_THREADS" ]; then + export OMP_NUM_THREADS=1 + fi + # set OMP_STACKSIZE to 512M if not set + if [ -z "$OMP_STACKSIZE" ]; then + export OMP_STACKSIZE=512m + fi - exec "$@" -'' + exec "$@" + ''; +in wrapper // { passthru = wrapper.passthru // { inherit mpi; }; }