singularity: init 2.2
This commit is contained in:
parent
7f71b89454
commit
04121437be
|
@ -198,6 +198,7 @@
|
||||||
jagajaga = "Arseniy Seroka <ars.seroka@gmail.com>";
|
jagajaga = "Arseniy Seroka <ars.seroka@gmail.com>";
|
||||||
javaguirre = "Javier Aguirre <contacto@javaguirre.net>";
|
javaguirre = "Javier Aguirre <contacto@javaguirre.net>";
|
||||||
jb55 = "William Casarin <bill@casarin.me>";
|
jb55 = "William Casarin <bill@casarin.me>";
|
||||||
|
jbedo = "Justin Bedő <cu@cua0.org>";
|
||||||
jcumming = "Jack Cummings <jack@mudshark.org>";
|
jcumming = "Jack Cummings <jack@mudshark.org>";
|
||||||
jefdaj = "Jeffrey David Johnson <jefdaj@gmail.com>";
|
jefdaj = "Jeffrey David Johnson <jefdaj@gmail.com>";
|
||||||
jfb = "James Felix Black <james@yamtime.com>";
|
jfb = "James Felix Black <james@yamtime.com>";
|
||||||
|
|
25
pkgs/applications/virtualization/singularity/default.nix
Normal file
25
pkgs/applications/virtualization/singularity/default.nix
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{ stdenv
|
||||||
|
, fetchFromGitHub
|
||||||
|
, autoreconfHook }:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
name = "singularity-${version}";
|
||||||
|
version = "2.2";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "singularityware";
|
||||||
|
repo = "singularity";
|
||||||
|
rev = version;
|
||||||
|
sha256 = "19g43gfdy5s8y4252474cp39d6ypn5dd37wp0s21fgd13vqy26px";
|
||||||
|
};
|
||||||
|
|
||||||
|
buildInputs = [ autoreconfHook ];
|
||||||
|
|
||||||
|
meta = with stdenv.lib; {
|
||||||
|
homepage = http://singularity.lbl.gov/;
|
||||||
|
description = "Designed around the notion of extreme mobility of compute and reproducible science, Singularity enables users to have full control of their operating system environment";
|
||||||
|
license = "BSD license with 2 modifications";
|
||||||
|
platforms = platforms.linux;
|
||||||
|
maintainers = [ maintainers.jbedo ];
|
||||||
|
};
|
||||||
|
}
|
100
pkgs/build-support/singularity-tools/default.nix
Normal file
100
pkgs/build-support/singularity-tools/default.nix
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
{ runCommand
|
||||||
|
, stdenv
|
||||||
|
, storeDir ? builtins.storeDir
|
||||||
|
, writeScript
|
||||||
|
, singularity
|
||||||
|
, writeReferencesToFile
|
||||||
|
, bash
|
||||||
|
, vmTools
|
||||||
|
, gawk
|
||||||
|
, utillinux
|
||||||
|
, e2fsprogs
|
||||||
|
, squashfsTools }:
|
||||||
|
|
||||||
|
rec {
|
||||||
|
shellScript = name: text:
|
||||||
|
writeScript name ''
|
||||||
|
#!${stdenv.shell}
|
||||||
|
set -e
|
||||||
|
${text}
|
||||||
|
'';
|
||||||
|
|
||||||
|
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,
|
||||||
|
extraSpace ? 0
|
||||||
|
}:
|
||||||
|
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 utillinux gawk ];
|
||||||
|
layerClosure = writeReferencesToFile layer;
|
||||||
|
preVM = vmTools.createEmptyImage {
|
||||||
|
size = diskSize;
|
||||||
|
fullName = "singularity-run-disk";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
''
|
||||||
|
rm -rf $out
|
||||||
|
mkdir disk
|
||||||
|
mkfs -t ext3 -b 4096 /dev/${vmTools.hd}
|
||||||
|
mount /dev/${vmTools.hd} disk
|
||||||
|
cd disk
|
||||||
|
|
||||||
|
# Run root script
|
||||||
|
${stdenv.lib.optionalString (runAsRoot != null) ''
|
||||||
|
mkdir -p ./${storeDir}
|
||||||
|
mount --rbind ${storeDir} ./${storeDir}
|
||||||
|
unshare -imnpuf --mount-proc chroot ./ ${runAsRootFile}
|
||||||
|
umount -R ./${storeDir}
|
||||||
|
''}
|
||||||
|
|
||||||
|
# Build /bin and copy across closure
|
||||||
|
mkdir -p bin nix/store
|
||||||
|
for f in $(cat $layerClosure) ; do
|
||||||
|
cp -ar $f ./$f
|
||||||
|
for f in $f/bin/* ; do
|
||||||
|
if [ ! -e bin/$(basename $f) ] ; then
|
||||||
|
ln -s $f bin/
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
# Create runScript
|
||||||
|
ln -s ${runScriptFile} singularity
|
||||||
|
|
||||||
|
# Size calculation
|
||||||
|
cd ..
|
||||||
|
umount disk
|
||||||
|
size=$(resize2fs -P /dev/${vmTools.hd} | awk '{print $NF}')
|
||||||
|
mount /dev/${vmTools.hd} disk
|
||||||
|
cd disk
|
||||||
|
|
||||||
|
export PATH=$PATH:${e2fsprogs}/bin/
|
||||||
|
singularity create -s $((1 + size * 4 / 1024 + ${toString extraSpace})) $out
|
||||||
|
tar -c . | singularity import $out
|
||||||
|
'');
|
||||||
|
|
||||||
|
in result;
|
||||||
|
}
|
|
@ -282,6 +282,8 @@ in
|
||||||
|
|
||||||
pathsFromGraph = ../build-support/kernel/paths-from-graph.pl;
|
pathsFromGraph = ../build-support/kernel/paths-from-graph.pl;
|
||||||
|
|
||||||
|
singularity-tools = callPackage ../build-support/singularity-tools { };
|
||||||
|
|
||||||
srcOnly = args: callPackage ../build-support/src-only args;
|
srcOnly = args: callPackage ../build-support/src-only args;
|
||||||
|
|
||||||
substituteAll = callPackage ../build-support/substitute/substitute-all.nix { };
|
substituteAll = callPackage ../build-support/substitute/substitute-all.nix { };
|
||||||
|
@ -13253,6 +13255,8 @@ in
|
||||||
|
|
||||||
slack = callPackage ../applications/networking/instant-messengers/slack { };
|
slack = callPackage ../applications/networking/instant-messengers/slack { };
|
||||||
|
|
||||||
|
singularity = callPackage ../applications/virtualization/singularity { };
|
||||||
|
|
||||||
spectrwm = callPackage ../applications/window-managers/spectrwm { };
|
spectrwm = callPackage ../applications/window-managers/spectrwm { };
|
||||||
|
|
||||||
wlc = callPackage ../development/libraries/wlc { };
|
wlc = callPackage ../development/libraries/wlc { };
|
||||||
|
|
Loading…
Reference in a new issue