2024-01-30 20:55:34 +01:00
{ stdenv , lib , fetchurl , kernel , flex , coccinelle , python3 }:
stdenv . mkDerivation rec {
name = " d r b d - ${ version } - ${ kernel . version } " ;
2024-04-20 10:26:25 +02:00
version = " 9 . 2 . 8 " ;
2024-01-30 20:55:34 +01:00
src = fetchurl {
url = " h t t p s : / / p k g . l i n b i t . c o m / / d o w n l o a d s / d r b d / 9 / d r b d - ${ version } . t a r . g z " ;
2024-04-20 10:26:25 +02:00
hash = " s h a 2 5 6 - L q K 1 l P u c a b 7 w K v c B 4 V K G d v B I q + K 9 X t u O 2 m 0 D P 5 X t K 3 M = " ;
2024-01-30 20:55:34 +01:00
} ;
hardeningDisable = [ " p i c " ] ;
nativeBuildInputs = [
kernel . moduleBuildDependencies
flex
coccinelle
python3
] ;
makeFlags = [
" K D I R = ${ kernel . dev } / l i b / m o d u l e s / ${ kernel . modDirVersion } / b u i l d "
" S P A A S = f a l s e "
] ;
# 6.4 and newer provide a in-tree version of the handshake module https://www.kernel.org/doc/html/v6.4/networking/tls-handshake.html
installPhase = ''
runHook preInstall
2024-04-29 16:44:10 +02:00
install - D drbd/drbd.ko - t $ out/lib/modules / $ { kernel . modDirVersion } /kernel/drivers/block/drbd9
install - D drbd/drbd_transport_tcp.ko - t $ out/lib/modules / $ { kernel . modDirVersion } /kernel/drivers/block/drbd9
install - D drbd/drbd_transport_lb-tcp.ko - t $ out/lib/modules / $ { kernel . modDirVersion } /kernel/drivers/block/drbd9
install - D drbd/drbd_transport_rdma.ko - t $ out/lib/modules / $ { kernel . modDirVersion } /kernel/drivers/block/drbd9
2024-01-30 20:55:34 +01:00
$ { lib . optionalString ( lib . versionOlder kernel . version " 6 . 4 " ) ''
2024-04-29 16:44:10 +02:00
install - D drbd/drbd-kernel-compat/handshake/handshake.ko - t $ out/lib/modules / $ { kernel . modDirVersion } /kernel/drivers/block/drbd9
2024-01-30 20:55:34 +01:00
'' }
runHook postInstall
'' ;
postPatch = ''
patchShebangs .
substituteInPlace Makefile - - replace ' SHELL = /bin/bash ' ' SHELL = $ { builtins . getEnv " S H E L L " } '
'' ;
2024-04-29 16:44:10 +02:00
# builder.pl had complained about the same file (drbd.ko.xz) provided by two different packages
# builder.pl also had complained about different permissions between the files from the two packages
# The compression is required because the kernel has the CONFIG_MODULE_COMPRESS_XZ option enabled
2024-04-20 10:26:25 +02:00
postFixup = ''
2024-04-29 16:44:10 +02:00
for ko in $ out/lib/modules / $ { kernel . modDirVersion } /kernel/drivers/block/drbd9 /* . k o ; d o
2024-04-20 10:26:25 +02:00
xz - - compress -6 - - threads = 0 $ ko
2024-04-29 16:44:10 +02:00
chmod 0444 $ ko . xz
2024-04-20 10:26:25 +02:00
done
'' ;
2024-01-30 20:55:34 +01:00
enableParallelBuilding = true ;
meta = with lib ; {
homepage = " h t t p s : / / g i t h u b . c o m / L I N B I T / d r b d " ;
description = " L I N B I T D R B D k e r n e l m o d u l e " ;
license = licenses . gpl2Plus ;
platforms = platforms . linux ;
maintainers = with maintainers ; [ birkb ] ;
longDescription = ''
DRBD is a software-based , shared-nothing , replicated storage solution
mirroring the content of block devices ( hard disks , partitions , logical volumes , and so on ) between hosts .
'' ;
2024-04-20 10:26:25 +02:00
broken = lib . versionAtLeast kernel . version " 6 . 8 " ; # wait until next DRBD release for 6.8 support https://github.com/LINBIT/drbd/issues/87#issuecomment-2059323084
2024-01-30 20:55:34 +01:00
} ;
}