2022-12-17 10:02:37 +00:00
|
|
|
{ version, hash }:
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv
|
2020-08-20 17:08:02 +00:00
|
|
|
, fetchurl
|
2021-02-05 17:12:51 +00:00
|
|
|
, pkg-config
|
2022-04-27 09:35:20 +00:00
|
|
|
, coreutils
|
2020-08-20 17:08:02 +00:00
|
|
|
, libuuid
|
2021-08-22 07:53:02 +00:00
|
|
|
, libaio
|
2022-04-27 09:35:20 +00:00
|
|
|
, substituteAll
|
2020-08-20 17:08:02 +00:00
|
|
|
, enableCmdlib ? false
|
|
|
|
, enableDmeventd ? false
|
2022-04-27 09:35:20 +00:00
|
|
|
, udevSupport ? !stdenv.hostPlatform.isStatic, udev
|
2022-03-30 09:31:56 +00:00
|
|
|
, onlyLib ? stdenv.hostPlatform.isStatic
|
2022-04-27 09:35:20 +00:00
|
|
|
# Otherwise we have a infinity recursion during static compilation
|
|
|
|
, enableUtilLinux ? !stdenv.hostPlatform.isStatic, util-linux
|
|
|
|
, enableVDO ? false, vdo
|
|
|
|
, enableMdadm ? false, mdadm
|
|
|
|
, enableMultipath ? false, multipath-tools
|
2020-08-20 17:08:02 +00:00
|
|
|
, nixosTests
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
# configure: error: --enable-dmeventd requires --enable-cmdlib to be used as well
|
|
|
|
assert enableDmeventd -> enableCmdlib;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2022-04-15 01:41:22 +00:00
|
|
|
pname = "lvm2" + lib.optionalString enableDmeventd "-with-dmeventd" + lib.optionalString enableVDO "-with-vdo";
|
2021-12-06 16:07:01 +00:00
|
|
|
inherit version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
src = fetchurl {
|
2022-12-17 10:02:37 +00:00
|
|
|
urls = [
|
|
|
|
"https://mirrors.kernel.org/sourceware/lvm2/LVM2.${version}.tgz"
|
|
|
|
"ftp://sourceware.org/pub/lvm2/LVM2.${version}.tgz"
|
|
|
|
];
|
|
|
|
inherit hash;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2022-01-26 04:04:25 +00:00
|
|
|
buildInputs = [
|
|
|
|
libaio
|
|
|
|
] ++ lib.optionals udevSupport [
|
|
|
|
udev
|
|
|
|
] ++ lib.optionals (!onlyLib) [
|
|
|
|
libuuid
|
2022-04-15 01:41:22 +00:00
|
|
|
] ++ lib.optionals enableVDO [
|
|
|
|
vdo
|
2022-01-26 04:04:25 +00:00
|
|
|
];
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
configureFlags = [
|
|
|
|
"--disable-readline"
|
|
|
|
"--enable-pkgconfig"
|
2020-08-20 17:08:02 +00:00
|
|
|
"--with-default-locking-dir=/run/lock/lvm"
|
|
|
|
"--with-default-run-dir=/run/lvm"
|
|
|
|
"--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
|
2023-03-15 16:39:30 +00:00
|
|
|
"--with-systemd-run=/run/current-system/systemd/bin/systemd-run"
|
2021-02-05 17:12:51 +00:00
|
|
|
] ++ lib.optionals (!enableCmdlib) [
|
2020-08-20 17:08:02 +00:00
|
|
|
"--bindir=${placeholder "bin"}/bin"
|
|
|
|
"--sbindir=${placeholder "bin"}/bin"
|
|
|
|
"--libdir=${placeholder "lib"}/lib"
|
2022-12-17 10:02:37 +00:00
|
|
|
"--with-libexecdir=${placeholder "lib"}/libexec"
|
2021-02-05 17:12:51 +00:00
|
|
|
] ++ lib.optional enableCmdlib "--enable-cmdlib"
|
|
|
|
++ lib.optionals enableDmeventd [
|
2020-08-20 17:08:02 +00:00
|
|
|
"--enable-dmeventd"
|
|
|
|
"--with-dmeventd-pidfile=/run/dmeventd/pid"
|
|
|
|
"--with-default-dm-run-dir=/run/dmeventd"
|
2021-02-05 17:12:51 +00:00
|
|
|
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
2020-04-24 23:36:52 +00:00
|
|
|
"ac_cv_func_malloc_0_nonnull=yes"
|
|
|
|
"ac_cv_func_realloc_0_nonnull=yes"
|
2022-01-26 04:04:25 +00:00
|
|
|
] ++ lib.optionals udevSupport [
|
2020-08-20 17:08:02 +00:00
|
|
|
"--enable-udev_rules"
|
|
|
|
"--enable-udev_sync"
|
2023-03-15 16:39:30 +00:00
|
|
|
] ++ lib.optionals enableVDO [
|
|
|
|
"--enable-vdo"
|
2022-03-30 09:31:56 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isStatic [
|
2022-01-26 04:04:25 +00:00
|
|
|
"--enable-static_link"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
preConfigure = ''
|
|
|
|
sed -i /DEFAULT_SYS_DIR/d Makefile.in
|
|
|
|
sed -i /DEFAULT_PROFILE_DIR/d conf/Makefile.in
|
2023-03-15 16:39:30 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
substituteInPlace make.tmpl.in --replace "@systemdsystemunitdir@" "$out/lib/systemd/system"
|
|
|
|
substituteInPlace libdm/make.tmpl.in --replace "@systemdsystemunitdir@" "$out/lib/systemd/system"
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
substituteInPlace scripts/blk_availability_systemd_red_hat.service.in \
|
|
|
|
--replace '/usr/bin/true' '${coreutils}/bin/true'
|
2020-08-20 17:08:02 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postConfigure = ''
|
|
|
|
sed -i 's|^#define LVM_CONFIGURE_LINE.*$|#define LVM_CONFIGURE_LINE "<removed>"|g' ./include/configure.h
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
patches = [
|
2022-04-27 09:35:20 +00:00
|
|
|
# fixes paths to and checks for tools
|
|
|
|
(substituteAll (let
|
|
|
|
optionalTool = cond: pkg: if cond then pkg else "/run/current-system/sw";
|
|
|
|
in {
|
|
|
|
src = ./fix-blkdeactivate.patch;
|
|
|
|
inherit coreutils;
|
|
|
|
util_linux = optionalTool enableUtilLinux util-linux;
|
|
|
|
mdadm = optionalTool enableMdadm mdadm;
|
|
|
|
multipath_tools = optionalTool enableMultipath multipath-tools;
|
|
|
|
vdo = optionalTool enableVDO vdo;
|
|
|
|
}))
|
2023-03-15 16:39:30 +00:00
|
|
|
# Musl fix from Alpine
|
2021-09-18 10:52:07 +00:00
|
|
|
./fix-stdio-usage.patch
|
2024-01-25 14:12:00 +00:00
|
|
|
# https://gitlab.com/lvmteam/lvm2/-/merge_requests/8
|
|
|
|
./fix-static.patch
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
doCheck = false; # requires root
|
|
|
|
|
2022-01-26 04:04:25 +00:00
|
|
|
makeFlags = lib.optionals udevSupport [
|
2023-03-15 16:39:30 +00:00
|
|
|
"SYSTEMD_GENERATOR_DIR=${placeholder "out"}/lib/systemd/system-generators"
|
2022-01-26 04:04:25 +00:00
|
|
|
] ++ lib.optionals onlyLib [
|
|
|
|
"libdm.device-mapper"
|
2020-08-20 17:08:02 +00:00
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# To prevent make install from failing.
|
|
|
|
installFlags = [ "OWNER=" "GROUP=" "confdir=$(out)/etc" ];
|
|
|
|
|
|
|
|
# Install systemd stuff.
|
2022-01-26 04:04:25 +00:00
|
|
|
installTargets = [ "install" ] ++ lib.optionals udevSupport [
|
2020-08-20 17:08:02 +00:00
|
|
|
"install_systemd_generators"
|
|
|
|
"install_systemd_units"
|
|
|
|
"install_tmpfiles_configuration"
|
|
|
|
];
|
|
|
|
|
2022-01-26 04:04:25 +00:00
|
|
|
installPhase = lib.optionalString onlyLib ''
|
2022-03-30 09:31:56 +00:00
|
|
|
install -D -t $out/lib libdm/ioctl/libdevmapper.${if stdenv.hostPlatform.isStatic then "a" else "so"}
|
2022-01-26 04:04:25 +00:00
|
|
|
make -C libdm install_include
|
|
|
|
make -C libdm install_pkgconfig
|
|
|
|
'';
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
# only split bin and lib out from out if cmdlib isn't enabled
|
|
|
|
outputs = [
|
|
|
|
"out"
|
2022-01-26 04:04:25 +00:00
|
|
|
] ++ lib.optionals (!onlyLib) [
|
2020-08-20 17:08:02 +00:00
|
|
|
"dev"
|
|
|
|
"man"
|
2022-01-26 04:04:25 +00:00
|
|
|
] ++ lib.optionals (!onlyLib && !enableCmdlib) [
|
2020-08-20 17:08:02 +00:00
|
|
|
"bin"
|
|
|
|
"lib"
|
|
|
|
];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
postInstall = lib.optionalString (enableCmdlib != true) ''
|
2020-08-20 17:08:02 +00:00
|
|
|
moveToOutput lib/libdevmapper.so $lib
|
|
|
|
'';
|
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
passthru.tests = {
|
|
|
|
installer = nixosTests.installer.lvm;
|
|
|
|
lvm2 = nixosTests.lvm2;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "http://sourceware.org/lvm2/";
|
|
|
|
description = "Tools to support Logical Volume Management (LVM) on Linux";
|
|
|
|
platforms = platforms.linux;
|
|
|
|
license = with licenses; [ gpl2 bsd2 lgpl21 ];
|
2024-04-21 15:54:59 +00:00
|
|
|
maintainers = with maintainers; [ raskin ajs124 ] ++ teams.helsinki-systems.members;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|