Commit b33d6407 authored by Yueh-Shun Li's avatar Yueh-Shun Li
Browse files

singularity-tool: format expression

parent 2f04861c
Loading
Loading
Loading
Loading
+31 −26
Original line number Diff line number Diff line
@@ -10,8 +10,8 @@
, gawk
, util-linux
, runtimeShell
, e2fsprogs }:

, e2fsprogs
}:
rec {
  shellScript = name: text:
    writeScript name ''
@@ -20,11 +20,13 @@ rec {
      ${text}
    '';

  mkLayer = {
    name,
    contents ? [],
  mkLayer =
    { name
    , contents ? [ ]
    ,
    }:
    runCommand "singularity-layer-${name}" {
    runCommand "singularity-layer-${name}"
      {
        inherit contents;
      } ''
      mkdir $out
@@ -33,22 +35,24 @@ rec {
      done
    '';

  buildImage = {
    name,
    contents ? [],
    diskSize ? 1024,
    runScript ? "#!${stdenv.shell}\nexec /bin/sh",
    runAsRoot ? null,
    memSize ? 512
  buildImage =
    { name
    , contents ? [ ]
    , diskSize ? 1024
    , runScript ? "#!${stdenv.shell}\nexec /bin/sh"
    , runAsRoot ? null
    , memSize ? 512
    }:
    let layer = mkLayer {
    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" {
        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;
}