mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-03 19:15:39 +00:00
61b7cab481
Since 03eaa48
added perl.withPackages, there is a canonical way to
create a perl interpreter from a list of libraries, for use in script
shebangs or generic build inputs. This method is declarative (what we
are doing is clear), produces short shebangs[1] and needs not to wrap
existing scripts.
Unfortunately there are a few exceptions that I've found:
1. Scripts that are calling perl with the -T switch. This makes perl
ignore PERL5LIB, which is what perl.withPackages is using to inform
the interpreter of the library paths.
2. Perl packages that depends on libraries in their own path. This
is not possible because perl.withPackages works at build time. The
workaround is to add `-I $out/${perl.libPrefix}` to the shebang.
In all other cases I propose to switch to perl.withPackages.
[1]: https://lwn.net/Articles/779997/
60 lines
1.8 KiB
Nix
60 lines
1.8 KiB
Nix
{ stdenv, lib, fetchFromGitHub, libxslt, libaio, systemd, perl
|
|
, docbook_xsl, coreutils, lsof, rdma-core, makeWrapper, sg3_utils, util-linux
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "tgt";
|
|
version = "1.0.80";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "fujita";
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
sha256 = "sha256-5qBqCHbkL6yw/iT2AtSumw8V0bV74TEyYMRgcPHW2lg=";
|
|
};
|
|
|
|
nativeBuildInputs = [ libxslt docbook_xsl makeWrapper ];
|
|
|
|
buildInputs = [ systemd libaio ];
|
|
|
|
makeFlags = [
|
|
"PREFIX=${placeholder "out"}"
|
|
"SD_NOTIFY=1"
|
|
];
|
|
|
|
installFlags = [
|
|
"sysconfdir=${placeholder "out"}/etc"
|
|
];
|
|
|
|
preConfigure = ''
|
|
sed -i 's|/usr/bin/||' doc/Makefile
|
|
sed -i 's|/usr/include/libaio.h|${libaio}/include/libaio.h|' usr/Makefile
|
|
sed -i 's|/usr/include/sys/|${stdenv.glibc.dev}/include/sys/|' usr/Makefile
|
|
sed -i 's|/usr/include/linux/|${stdenv.glibc.dev}/include/linux/|' usr/Makefile
|
|
'';
|
|
|
|
postInstall = ''
|
|
substituteInPlace $out/sbin/tgt-admin \
|
|
--replace "#!/usr/bin/perl" "#! ${perl.withPackages (p: [ p.ConfigGeneral ])}/bin/perl"
|
|
wrapProgram $out/sbin/tgt-admin --prefix PATH : \
|
|
${lib.makeBinPath [ lsof sg3_utils (placeholder "out") ]}
|
|
|
|
install -D scripts/tgtd.service $out/etc/systemd/system/tgtd.service
|
|
substituteInPlace $out/etc/systemd/system/tgtd.service \
|
|
--replace "/usr/sbin/tgt" "$out/bin/tgt"
|
|
|
|
# See https://bugzilla.redhat.com/show_bug.cgi?id=848942
|
|
sed -i '/ExecStart=/a ExecStartPost=${coreutils}/bin/sleep 5' $out/etc/systemd/system/tgtd.service
|
|
'';
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
meta = with lib; {
|
|
description = "iSCSI Target daemon with RDMA support";
|
|
homepage = "http://stgt.sourceforge.net/";
|
|
license = licenses.gpl2;
|
|
platforms = platforms.linux;
|
|
maintainers = with maintainers; [ johnazoidberg ];
|
|
};
|
|
}
|