tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
singularity-tool: format expression
Yueh-Shun Li
3 years ago
b33d6407
2f04861c
+31
-26
1 changed file
expand all
collapse all
unified
split
pkgs
build-support
singularity-tools
default.nix
+31
-26
pkgs/build-support/singularity-tools/default.nix
reviewed
···
10
10
, gawk
11
11
, util-linux
12
12
, runtimeShell
13
13
-
, e2fsprogs }:
14
14
-
13
13
+
, e2fsprogs
14
14
+
}:
15
15
rec {
16
16
shellScript = name: text:
17
17
writeScript name ''
···
20
20
${text}
21
21
'';
22
22
23
23
-
mkLayer = {
24
24
-
name,
25
25
-
contents ? [],
26
26
-
}:
27
27
-
runCommand "singularity-layer-${name}" {
28
28
-
inherit contents;
29
29
-
} ''
23
23
+
mkLayer =
24
24
+
{ name
25
25
+
, contents ? [ ]
26
26
+
,
27
27
+
}:
28
28
+
runCommand "singularity-layer-${name}"
29
29
+
{
30
30
+
inherit contents;
31
31
+
} ''
30
32
mkdir $out
31
33
for f in $contents ; do
32
34
cp -ra $f $out/
33
35
done
34
36
'';
35
37
36
36
-
buildImage = {
37
37
-
name,
38
38
-
contents ? [],
39
39
-
diskSize ? 1024,
40
40
-
runScript ? "#!${stdenv.shell}\nexec /bin/sh",
41
41
-
runAsRoot ? null,
42
42
-
memSize ? 512
43
43
-
}:
44
44
-
let layer = mkLayer {
45
45
-
inherit name;
46
46
-
contents = contents ++ [ bash runScriptFile ];
47
47
-
};
48
48
-
runAsRootFile = shellScript "run-as-root.sh" runAsRoot;
49
49
-
runScriptFile = shellScript "run-script.sh" runScript;
50
50
-
result = vmTools.runInLinuxVM (
51
51
-
runCommand "singularity-image-${name}.img" {
38
38
+
buildImage =
39
39
+
{ name
40
40
+
, contents ? [ ]
41
41
+
, diskSize ? 1024
42
42
+
, runScript ? "#!${stdenv.shell}\nexec /bin/sh"
43
43
+
, runAsRoot ? null
44
44
+
, memSize ? 512
45
45
+
}:
46
46
+
let
47
47
+
layer = mkLayer {
48
48
+
inherit name;
49
49
+
contents = contents ++ [ bash runScriptFile ];
50
50
+
};
51
51
+
runAsRootFile = shellScript "run-as-root.sh" runAsRoot;
52
52
+
runScriptFile = shellScript "run-script.sh" runScript;
53
53
+
result = vmTools.runInLinuxVM (
54
54
+
runCommand "singularity-image-${name}.img"
55
55
+
{
52
56
buildInputs = [ singularity e2fsprogs util-linux gawk ];
53
57
layerClosure = writeReferencesToFile layer;
54
58
preVM = vmTools.createEmptyImage {
···
106
110
TMPDIR=$(pwd -P) singularity build $out ./img
107
111
'');
108
112
109
109
-
in result;
113
113
+
in
114
114
+
result;
110
115
}