aboutsummaryrefslogtreecommitdiff
path: root/lib/slurm.nix
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2019-05-16 21:18:27 +1000
committerJustin Bedo <cu@cua0.org>2019-05-16 21:46:02 +1000
commitd5fd734513671d957c20a66655c98d325bb1760f (patch)
treedf0ab9cf8b9806f939723cb2e0827aa047185948 /lib/slurm.nix
parentfa35a2634108bd179de0c7dd21ca5355f6918a9b (diff)
slurm: renamed from sbatch
Diffstat (limited to 'lib/slurm.nix')
-rw-r--r--lib/slurm.nix28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/slurm.nix b/lib/slurm.nix
new file mode 100644
index 0000000..daca4af
--- /dev/null
+++ b/lib/slurm.nix
@@ -0,0 +1,28 @@
+{stdenv, lib, writeScript, coreutils}:
+
+with lib;
+
+{ ppn, mem, walltime, partition ? null, slurmFlags ? null, salloc ? "/usr/bin/salloc" }:
+drv:
+ let ppnReified = if drv.multicore then ppn else 1;
+ in lib.overrideDerivation drv ({ args, builder, name, ... }: {
+ builder = stdenv.shell;
+ args = let
+ script = writeScript "slurm-script" ''
+ #!${stdenv.shell}
+ ${builder} ${lib.escapeShellArgs args}
+ '';
+
+ slurm = writeScript "slurm" ''
+ #!${stdenv.shell}
+ NIX_BUILD_CORES=${toString ppnReified}
+
+ ${salloc} -c $NIX_BUILD_CORES --mem=${toString mem}G -t ${walltime} \
+ -J "${name}" \
+ ${optionalString (partition != null) "-p ${partition}"} \
+ ${optionalString (slurmFlags != null) slurmFlags} \
+ ${script}
+ '';
+
+ in [ "-c" slurm ];
+ })