From b33d6407cc37c9f4fe112692fb0b74a45fc7e7a3 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li <44064051+ShamrockLee@users.noreply.github.com> Date: Sun, 29 Jan 2023 01:02:47 +0800 Subject: [PATCH] singularity-tool: format expression --- .../singularity-tools/default.nix | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/pkgs/build-support/singularity-tools/default.nix b/pkgs/build-support/singularity-tools/default.nix index 46df792bdf6c..bf542e307008 100644 --- a/pkgs/build-support/singularity-tools/default.nix +++ b/pkgs/build-support/singularity-tools/default.nix @@ -10,8 +10,8 @@ , gawk , util-linux , runtimeShell -, e2fsprogs }: - +, e2fsprogs +}: rec { shellScript = name: text: writeScript name '' @@ -20,35 +20,39 @@ rec { ${text} ''; - mkLayer = { - name, - contents ? [], - }: - runCommand "singularity-layer-${name}" { - inherit contents; - } '' + mkLayer = + { name + , contents ? [ ] + , + }: + runCommand "singularity-layer-${name}" + { + inherit contents; + } '' mkdir $out for f in $contents ; do cp -ra $f $out/ done ''; - buildImage = { - name, - contents ? [], - diskSize ? 1024, - runScript ? "#!${stdenv.shell}\nexec /bin/sh", - runAsRoot ? null, - memSize ? 512 - }: - let layer = mkLayer { - inherit name; - contents = contents ++ [ bash runScriptFile ]; - }; - runAsRootFile = shellScript "run-as-root.sh" runAsRoot; - runScriptFile = shellScript "run-script.sh" runScript; - result = vmTools.runInLinuxVM ( - runCommand "singularity-image-${name}.img" { + buildImage = + { name + , contents ? [ ] + , diskSize ? 1024 + , runScript ? "#!${stdenv.shell}\nexec /bin/sh" + , runAsRoot ? null + , memSize ? 512 + }: + let + layer = mkLayer { + inherit name; + contents = contents ++ [ bash runScriptFile ]; + }; + runAsRootFile = shellScript "run-as-root.sh" runAsRoot; + runScriptFile = shellScript "run-script.sh" runScript; + result = vmTools.runInLinuxVM ( + runCommand "singularity-image-${name}.img" + { buildInputs = [ singularity e2fsprogs util-linux gawk ]; layerClosure = writeReferencesToFile layer; preVM = vmTools.createEmptyImage { @@ -106,5 +110,6 @@ rec { TMPDIR=$(pwd -P) singularity build $out ./img ''); - in result; + in + result; }