nixpkgs/pkgs/applications/virtualization/singularity/default.nix

77 lines
2 KiB
Nix
Raw Normal View History

2018-11-01 00:21:02 +00:00
{stdenv
, removeReferencesTo
, lib
2016-11-14 01:26:59 +00:00
, fetchFromGitHub
2018-11-01 00:21:02 +00:00
, utillinux
, openssl
2017-11-07 03:47:20 +00:00
, coreutils
2018-11-01 00:21:02 +00:00
, go
, which
2017-11-07 03:47:20 +00:00
, makeWrapper
, squashfsTools
2018-11-01 00:21:02 +00:00
, buildGoPackage}:
with lib;
2016-11-14 01:26:59 +00:00
2018-11-01 00:21:02 +00:00
buildGoPackage rec {
2016-11-14 01:26:59 +00:00
name = "singularity-${version}";
2018-11-01 00:21:02 +00:00
version = "3.0.1";
src = fetchFromGitHub {
owner = "sylabs";
repo = "singularity";
rev = "v${version}";
sha256 = "1wpsd0il2ipa2n5cnbj8dzs095jycdryq2rx62kikbq7ahzz4fsi";
};
goPackagePath = "github.com/sylabs/singularity";
goDeps = ./deps.nix;
buildInputs = [ openssl ];
nativeBuildInputs = [ removeReferencesTo utillinux which makeWrapper ];
propagatedBuildInputs = [ coreutils squashfsTools ];
2017-11-07 03:47:20 +00:00
2018-11-01 00:21:02 +00:00
postConfigure = ''
find . -name vendor -type d -print0 | xargs -0 rm -rf
2017-11-07 03:47:20 +00:00
2018-11-01 00:21:02 +00:00
cd go/src/github.com/sylabs/singularity
2017-11-07 03:47:20 +00:00
patchShebangs .
2018-11-01 00:21:02 +00:00
sed -i 's|defaultEnv := "/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"|defaultEnv := "${stdenv.lib.makeBinPath propagatedBuildInputs}"|' src/cmd/singularity/cli/singularity.go
./mconfig -V ${version} -p $bin --localstatedir=/var
touch builddir/.dep-done
touch builddir/vendors-done
# Don't install SUID binaries
sed -i 's/-m 4755/-m 755/g' builddir/Makefile
# Point to base gopath
sed -i "s|^cni_vendor_GOPATH :=.*\$|cni_vendor_GOPATH := $NIX_BUILD_TOP/go/src/github.com/containernetworking/plugins/plugins|" builddir/Makefile
2017-11-07 03:47:20 +00:00
'';
2018-11-01 00:21:02 +00:00
buildPhase = ''
make -C builddir
2017-11-07 03:47:20 +00:00
'';
2016-11-14 01:26:59 +00:00
2018-11-01 00:21:02 +00:00
installPhase = ''
make -C builddir install LOCALSTATEDIR=$bin/var
chmod 755 $bin/libexec/singularity/bin/starter-suid
'';
postFixup = ''
find $bin/ -type f -executable -exec remove-references-to -t ${go} '{}' + || true
# These etc scripts shouldn't have their paths patched
cp etc/actions/* $bin/etc/singularity/actions/
'';
2016-11-14 01:26:59 +00:00
meta = with stdenv.lib; {
2018-11-01 00:21:02 +00:00
homepage = http://www.sylabs.io/;
description = "Application containers for linux";
license = licenses.bsd3;
2016-11-14 01:26:59 +00:00
platforms = platforms.linux;
maintainers = [ maintainers.jbedo ];
};
}