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