diff --git a/pkgs/build-support/singularity-tools/default.nix b/pkgs/build-support/singularity-tools/default.nix index cd10a9960421b..c1dc1a00df040 100644 --- a/pkgs/build-support/singularity-tools/default.nix +++ b/pkgs/build-support/singularity-tools/default.nix @@ -1,19 +1,24 @@ -{ runCommand -, lib -, stdenv -, storeDir ? builtins.storeDir -, writeScript -, singularity -, writeClosure -, bash -, vmTools -, gawk -, util-linux -, runtimeShell -, e2fsprogs +{ + lib, + # Build helpers + stdenv, + runCommand, + vmTools, + writeClosure, + writeScript, + # Native build inputs + e2fsprogs, + gawk, + util-linux, + # Build inputs + bash, + runtimeShell, + singularity, + storeDir ? builtins.storeDir, }: rec { - shellScript = name: text: + shellScript = + name: text: writeScript name '' #!${runtimeShell} set -e @@ -21,15 +26,13 @@ rec { ''; mkLayer = - { name - , contents ? [ ] + { + name, + contents ? [ ], # May be "apptainer" instead of "singularity" - , projectName ? (singularity.projectName or "singularity") + projectName ? (singularity.projectName or "singularity"), }: - runCommand "${projectName}-layer-${name}" - { - inherit contents; - } '' + runCommand "${projectName}-layer-${name}" { inherit contents; } '' mkdir $out for f in $contents ; do cp -ra $f $out/ @@ -40,13 +43,14 @@ rec { let defaultSingularity = singularity; in - { name - , contents ? [ ] - , diskSize ? 1024 - , runScript ? "#!${stdenv.shell}\nexec /bin/sh" - , runAsRoot ? null - , memSize ? 1024 - , singularity ? defaultSingularity + { + name, + contents ? [ ], + diskSize ? 1024, + memSize ? 1024, + runAsRoot ? null, + runScript ? "#!${stdenv.shell}\nexec /bin/sh", + singularity ? defaultSingularity, }: let projectName = singularity.projectName or "singularity"; @@ -55,7 +59,12 @@ rec { result = vmTools.runInLinuxVM ( runCommand "${projectName}-image-${name}.img" { - buildInputs = [ singularity e2fsprogs util-linux gawk ]; + buildInputs = [ + singularity + e2fsprogs + util-linux + gawk + ]; layerClosure = writeClosure contents; preVM = vmTools.createEmptyImage { size = diskSize; @@ -110,7 +119,8 @@ rec { echo "root:x:0:0:System administrator:/root:/bin/sh" > /etc/passwd echo > /etc/resolv.conf TMPDIR=$(pwd -P) ${projectName} build $out ./img - ''); + '' + ); in result;