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

82 lines
2.1 KiB
Nix
Raw Normal View History

2018-11-01 00:21:02 +00:00
{stdenv
, removeReferencesTo
, lib
2020-07-15 13:05:37 +01:00
, fetchurl
2018-11-01 00:21:02 +00:00
, utillinux
2020-07-15 13:05:37 +01:00
, gpgme
2018-11-01 00:21:02 +00:00
, openssl
2020-07-15 13:05:37 +01:00
, libuuid
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
2020-07-15 13:05:37 +01:00
, cryptsetup
2017-11-07 03:47:20 +00:00
, 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 {
pname = "singularity";
2020-07-15 13:05:37 +01:00
version = "3.6.1";
2018-11-01 00:21:02 +00:00
2020-07-15 13:05:37 +01:00
src = fetchurl {
url = "https://github.com/hpcng/singularity/releases/download/v${version}/singularity-${version}.tar.gz";
sha256 = "070jj6kbiw23sd2p4xhvmyb8gd83imwgisdf18ahkwp7dq85db3c";
2018-11-01 00:21:02 +00:00
};
goPackagePath = "github.com/sylabs/singularity";
goDeps = ./deps.nix;
2020-07-15 13:05:37 +01:00
buildInputs = [ gpgme openssl libuuid ];
nativeBuildInputs = [ removeReferencesTo utillinux which makeWrapper cryptsetup ];
2018-11-01 00:21:02 +00:00
propagatedBuildInputs = [ coreutils squashfsTools ];
2017-11-07 03:47:20 +00:00
2020-07-15 13:05:37 +01:00
postPatch = ''
substituteInPlace internal/pkg/build/files/copy.go \
--replace /bin/cp ${coreutils}/bin/cp
'';
2018-11-01 00:21:02 +00:00
postConfigure = ''
cd go/src/github.com/sylabs/singularity
2017-11-07 03:47:20 +00:00
patchShebangs .
2019-06-18 03:05:42 +01:00
sed -i 's|defaultPath := "[^"]*"|defaultPath := "${stdenv.lib.makeBinPath propagatedBuildInputs}"|' cmd/internal/cli/actions.go
2018-11-01 00:21:02 +00:00
./mconfig -V ${version} -p $out --localstatedir=/var
2018-11-01 00:21:02 +00:00
# Don't install SUID binaries
sed -i 's/-m 4755/-m 755/g' builddir/Makefile
2017-11-07 03:47:20 +00:00
'';
2018-11-01 00:21:02 +00:00
buildPhase = ''
2020-07-15 13:05:37 +01:00
runHook preBuild
2018-11-01 00:21:02 +00:00
make -C builddir
2020-07-15 13:05:37 +01:00
runHook postBuild
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 = ''
2020-07-15 13:05:37 +01:00
runHook preInstall
make -C builddir install LOCALSTATEDIR=$out/var
chmod 755 $out/libexec/singularity/bin/starter-suid
2020-07-15 13:05:37 +01:00
# Explicitly configure paths in the config file
sed -i 's|^# mksquashfs path =.*$|mksquashfs path = ${stdenv.lib.makeBinPath [squashfsTools]}/mksquashfs|' $out/etc/singularity/singularity.conf
sed -i 's|^# cryptsetup path =.*$|cryptsetup path = ${stdenv.lib.makeBinPath [cryptsetup]}/cryptsetup|' $out/etc/singularity/singularity.conf
runHook postInstall
2018-11-01 00:21:02 +00:00
'';
postFixup = ''
find $out/libexec/ -type f -executable -exec remove-references-to -t ${go} '{}' + || true
2018-11-01 00:21:02 +00:00
'';
2016-11-14 01:26:59 +00:00
meta = with stdenv.lib; {
homepage = "http://www.sylabs.io/";
2018-11-01 00:21:02 +00:00
description = "Application containers for linux";
license = licenses.bsd3;
2016-11-14 01:26:59 +00:00
platforms = platforms.linux;
maintainers = [ maintainers.jbedo ];
};
}