@@ -1,5 +1,6 @@
1−{ stdenv, fetchFromGitHub, libxslt, libaio, systemd, perl, perlPackages
2−, docbook_xsl }:
1+{ stdenv, lib, fetchFromGitHub, libxslt, libaio, systemd, perl, perlPackages
2+, docbook_xsl, coreutils, lsof, rdma-core, makeWrapper, sg3_utils, utillinux
3+}:
34
45stdenv.mkDerivation rec {
56 pname = "tgt";
@@ -12,7 +13,9 @@ stdenv.mkDerivation rec {
1213 sha256 = "18bp7fcpv7879q3ppdxlqj7ayqmlh5zwrkz8gch6rq9lkmmrklrf";
1314 };
1415
15− buildInputs = [ libxslt systemd libaio docbook_xsl ];
16+ nativeBuildInputs = [ libxslt docbook_xsl makeWrapper ];
17+
18+ buildInputs = [ systemd libaio ];
1619
1720 makeFlags = [
1821 "PREFIX=${placeholder "out"}"
@@ -31,14 +34,26 @@ stdenv.mkDerivation rec {
3134 '';
3235
3336 postInstall = ''
34− sed -i 's|#!/usr/bin/perl|#! ${perl}/bin/perl -I${perlPackages.ConfigGeneral}/${perl.libPrefix}|' $out/sbin/tgt-admin
37+ substituteInPlace $out/sbin/tgt-admin \
38+ --replace "#!/usr/bin/perl" "#! ${perl}/bin/perl -I${perlPackages.ConfigGeneral}/${perl.libPrefix}"
39+ wrapProgram $out/sbin/tgt-admin --prefix PATH : \
40+ ${lib.makeBinPath [ lsof sg3_utils (placeholder "out") ]}
41+
42+ install -D scripts/tgtd.service $out/etc/systemd/system/tgtd.service
43+ substituteInPlace $out/etc/systemd/system/tgtd.service \
44+ --replace "/usr/sbin/tgt" "$out/bin/tgt"
45+
46+ # See https://bugzilla.redhat.com/show_bug.cgi?id=848942
47+ sed -i '/ExecStart=/a ExecStartPost=${coreutils}/bin/sleep 5' $out/etc/systemd/system/tgtd.service
3548 '';
3649
3750 enableParallelBuilding = true;
3851
39− meta = {
40− description = "iSCSI Target daemon with rdma support";
41− license = stdenv.lib.licenses.gpl2;
42− platforms = stdenv.lib.platforms.linux;
52+ meta = with stdenv.lib; {
53+ description = "iSCSI Target daemon with RDMA support";
54+ homepage = "http://stgt.sourceforge.net/";
55+ license = licenses.gpl2;
56+ platforms = platforms.linux;
57+ maintainers = with maintainers; [ johnazoidberg ];
4358 };
4459}