nixpkgs-suyu/pkgs/tools/networking/tgt/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

59 lines
1.8 KiB
Nix

{ stdenv, lib, fetchFromGitHub, libxslt, libaio, systemd, perl, perlPackages
, docbook_xsl, coreutils, lsof, rdma-core, makeWrapper, sg3_utils, util-linux
}:
stdenv.mkDerivation rec {
pname = "tgt";
version = "1.0.79";
src = fetchFromGitHub {
owner = "fujita";
repo = pname;
rev = "v${version}";
sha256 = "18bp7fcpv7879q3ppdxlqj7ayqmlh5zwrkz8gch6rq9lkmmrklrf";
};
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}/bin/perl -I${perlPackages.ConfigGeneral}/${perl.libPrefix}"
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 ];
};
}