mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +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
|
runCommand,
|
||||||
, stdenv
|
lib,
|
||||||
, storeDir ? builtins.storeDir
|
stdenv,
|
||||||
, writeScript
|
storeDir ? builtins.storeDir,
|
||||||
, singularity
|
writeScript,
|
||||||
, writeClosure
|
singularity,
|
||||||
, bash
|
writeClosure,
|
||||||
, vmTools
|
bash,
|
||||||
, gawk
|
vmTools,
|
||||||
, util-linux
|
gawk,
|
||||||
, runtimeShell
|
util-linux,
|
||||||
, e2fsprogs
|
runtimeShell,
|
||||||
|
e2fsprogs,
|
||||||
}:
|
}:
|
||||||
rec {
|
rec {
|
||||||
shellScript = name: text:
|
shellScript =
|
||||||
|
name: text:
|
||||||
writeScript name ''
|
writeScript name ''
|
||||||
#!${runtimeShell}
|
#!${runtimeShell}
|
||||||
set -e
|
set -e
|
||||||
@ -21,15 +23,13 @@ rec {
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
mkLayer =
|
mkLayer =
|
||||||
{ name
|
{
|
||||||
, contents ? [ ]
|
name,
|
||||||
|
contents ? [ ],
|
||||||
# May be "apptainer" instead of "singularity"
|
# May be "apptainer" instead of "singularity"
|
||||||
, projectName ? (singularity.projectName or "singularity")
|
projectName ? (singularity.projectName or "singularity"),
|
||||||
}:
|
}:
|
||||||
runCommand "${projectName}-layer-${name}"
|
runCommand "${projectName}-layer-${name}" { inherit contents; } ''
|
||||||
{
|
|
||||||
inherit contents;
|
|
||||||
} ''
|
|
||||||
mkdir $out
|
mkdir $out
|
||||||
for f in $contents ; do
|
for f in $contents ; do
|
||||||
cp -ra $f $out/
|
cp -ra $f $out/
|
||||||
@ -40,13 +40,14 @@ rec {
|
|||||||
let
|
let
|
||||||
defaultSingularity = singularity;
|
defaultSingularity = singularity;
|
||||||
in
|
in
|
||||||
{ name
|
{
|
||||||
, contents ? [ ]
|
name,
|
||||||
, diskSize ? 1024
|
contents ? [ ],
|
||||||
, runScript ? "#!${stdenv.shell}\nexec /bin/sh"
|
diskSize ? 1024,
|
||||||
, runAsRoot ? null
|
runScript ? "#!${stdenv.shell}\nexec /bin/sh",
|
||||||
, memSize ? 1024
|
runAsRoot ? null,
|
||||||
, singularity ? defaultSingularity
|
memSize ? 1024,
|
||||||
|
singularity ? defaultSingularity,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
projectName = singularity.projectName or "singularity";
|
projectName = singularity.projectName or "singularity";
|
||||||
@ -55,7 +56,12 @@ rec {
|
|||||||
result = vmTools.runInLinuxVM (
|
result = vmTools.runInLinuxVM (
|
||||||
runCommand "${projectName}-image-${name}.img"
|
runCommand "${projectName}-image-${name}.img"
|
||||||
{
|
{
|
||||||
buildInputs = [ singularity e2fsprogs util-linux gawk ];
|
buildInputs = [
|
||||||
|
singularity
|
||||||
|
e2fsprogs
|
||||||
|
util-linux
|
||||||
|
gawk
|
||||||
|
];
|
||||||
layerClosure = writeClosure contents;
|
layerClosure = writeClosure contents;
|
||||||
preVM = vmTools.createEmptyImage {
|
preVM = vmTools.createEmptyImage {
|
||||||
size = diskSize;
|
size = diskSize;
|
||||||
@ -110,7 +116,8 @@ rec {
|
|||||||
echo "root:x:0:0:System administrator:/root:/bin/sh" > /etc/passwd
|
echo "root:x:0:0:System administrator:/root:/bin/sh" > /etc/passwd
|
||||||
echo > /etc/resolv.conf
|
echo > /etc/resolv.conf
|
||||||
TMPDIR=$(pwd -P) ${projectName} build $out ./img
|
TMPDIR=$(pwd -P) ${projectName} build $out ./img
|
||||||
'');
|
''
|
||||||
|
);
|
||||||
|
|
||||||
in
|
in
|
||||||
result;
|
result;
|
||||||
|
Loading…
Reference in New Issue
Block a user