mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
singularity-tools: format with nixfmt-rfc-style (Nix RFC 166)
This commit is contained in:
parent
4197076f2b
commit
bcece72177
@ -1,19 +1,21 @@
|
||||
{ runCommand
|
||||
, lib
|
||||
, stdenv
|
||||
, storeDir ? builtins.storeDir
|
||||
, writeScript
|
||||
, singularity
|
||||
, writeClosure
|
||||
, bash
|
||||
, vmTools
|
||||
, gawk
|
||||
, util-linux
|
||||
, runtimeShell
|
||||
, e2fsprogs
|
||||
{
|
||||
runCommand,
|
||||
lib,
|
||||
stdenv,
|
||||
storeDir ? builtins.storeDir,
|
||||
writeScript,
|
||||
singularity,
|
||||
writeClosure,
|
||||
bash,
|
||||
vmTools,
|
||||
gawk,
|
||||
util-linux,
|
||||
runtimeShell,
|
||||
e2fsprogs,
|
||||
}:
|
||||
rec {
|
||||
shellScript = name: text:
|
||||
shellScript =
|
||||
name: text:
|
||||
writeScript name ''
|
||||
#!${runtimeShell}
|
||||
set -e
|
||||
@ -21,15 +23,13 @@ rec {
|
||||
'';
|
||||
|
||||
mkLayer =
|
||||
{ name
|
||||
, contents ? [ ]
|
||||
# May be "apptainer" instead of "singularity"
|
||||
, projectName ? (singularity.projectName or "singularity")
|
||||
}:
|
||||
runCommand "${projectName}-layer-${name}"
|
||||
{
|
||||
inherit contents;
|
||||
} ''
|
||||
name,
|
||||
contents ? [ ],
|
||||
# May be "apptainer" instead of "singularity"
|
||||
projectName ? (singularity.projectName or "singularity"),
|
||||
}:
|
||||
runCommand "${projectName}-layer-${name}" { inherit contents; } ''
|
||||
mkdir $out
|
||||
for f in $contents ; do
|
||||
cp -ra $f $out/
|
||||
@ -40,13 +40,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,
|
||||
runScript ? "#!${stdenv.shell}\nexec /bin/sh",
|
||||
runAsRoot ? null,
|
||||
memSize ? 1024,
|
||||
singularity ? defaultSingularity,
|
||||
}:
|
||||
let
|
||||
projectName = singularity.projectName or "singularity";
|
||||
@ -55,7 +56,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 +116,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;
|
||||
|
Loading…
Reference in New Issue
Block a user