Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 211 lines 5.4 kB view raw
1{ version, hash }: 2 3{ 4 lib, 5 stdenv, 6 fetchurl, 7 pkg-config, 8 coreutils, 9 libuuid, 10 libaio, 11 replaceVars, 12 enableCmdlib ? false, 13 enableDmeventd ? false, 14 udevSupport ? !stdenv.hostPlatform.isStatic, 15 udev, 16 udevCheckHook, 17 onlyLib ? stdenv.hostPlatform.isStatic, 18 # Otherwise we have a infinity recursion during static compilation 19 enableUtilLinux ? !stdenv.hostPlatform.isStatic, 20 util-linux, 21 enableVDO ? false, 22 vdo, 23 enableMdadm ? false, 24 mdadm, 25 enableMultipath ? false, 26 multipath-tools, 27 nixosTests, 28 buildFHSEnv, 29 recurseIntoAttrs, 30}: 31 32# configure: error: --enable-dmeventd requires --enable-cmdlib to be used as well 33assert enableDmeventd -> enableCmdlib; 34 35stdenv.mkDerivation rec { 36 pname = 37 "lvm2" 38 + lib.optionalString enableDmeventd "-with-dmeventd" 39 + lib.optionalString enableVDO "-with-vdo"; 40 inherit version; 41 42 src = fetchurl { 43 urls = [ 44 "https://mirrors.kernel.org/sourceware/lvm2/LVM2.${version}.tgz" 45 "ftp://sourceware.org/pub/lvm2/LVM2.${version}.tgz" 46 ]; 47 inherit hash; 48 }; 49 50 nativeBuildInputs = [ pkg-config ] ++ lib.optionals udevSupport [ udevCheckHook ]; 51 buildInputs = [ 52 libaio 53 ] 54 ++ lib.optionals udevSupport [ 55 udev 56 ] 57 ++ lib.optionals (!onlyLib) [ 58 libuuid 59 ] 60 ++ lib.optionals enableVDO [ 61 vdo 62 ]; 63 64 configureFlags = [ 65 "--disable-readline" 66 "--enable-pkgconfig" 67 "--with-default-locking-dir=/run/lock/lvm" 68 "--with-default-run-dir=/run/lvm" 69 "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system" 70 "--with-systemd-run=/run/current-system/systemd/bin/systemd-run" 71 "--with-default-profile-subdir=profile.d" 72 ] 73 ++ lib.optionals (!enableCmdlib && !onlyLib) [ 74 "--bindir=${placeholder "bin"}/bin" 75 "--sbindir=${placeholder "bin"}/bin" 76 "--libdir=${placeholder "lib"}/lib" 77 "--with-libexecdir=${placeholder "lib"}/libexec" 78 ] 79 ++ lib.optional enableCmdlib "--enable-cmdlib" 80 ++ lib.optionals enableDmeventd [ 81 "--enable-dmeventd" 82 "--with-dmeventd-pidfile=/run/dmeventd/pid" 83 "--with-default-dm-run-dir=/run/dmeventd" 84 ] 85 ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 86 "ac_cv_func_malloc_0_nonnull=yes" 87 "ac_cv_func_realloc_0_nonnull=yes" 88 ] 89 ++ lib.optionals udevSupport [ 90 "--enable-udev_rules" 91 "--enable-udev_sync" 92 ] 93 ++ lib.optionals enableVDO [ 94 "--enable-vdo" 95 ] 96 ++ lib.optionals stdenv.hostPlatform.isStatic [ 97 "--enable-static_link" 98 ]; 99 100 preConfigure = '' 101 sed -i /DEFAULT_SYS_DIR/d Makefile.in 102 sed -i /DEFAULT_PROFILE_DIR/d conf/Makefile.in 103 104 substituteInPlace make.tmpl.in --replace "@systemdsystemunitdir@" "$out/lib/systemd/system" 105 substituteInPlace libdm/make.tmpl.in --replace "@systemdsystemunitdir@" "$out/lib/systemd/system" 106 107 substituteInPlace scripts/blk_availability_systemd_red_hat.service.in \ 108 --replace '/usr/bin/true' '${coreutils}/bin/true' 109 ''; 110 111 postConfigure = '' 112 sed -i 's|^#define LVM_CONFIGURE_LINE.*$|#define LVM_CONFIGURE_LINE "<removed>"|g' ./include/configure.h 113 ''; 114 115 patches = [ 116 # fixes paths to and checks for tools 117 (replaceVars ./fix-blkdeactivate.patch ( 118 let 119 optionalTool = cond: pkg: if cond then pkg else "/run/current-system/sw"; 120 in 121 { 122 inherit coreutils; 123 util_linux = optionalTool enableUtilLinux util-linux; 124 mdadm = optionalTool enableMdadm mdadm; 125 multipath_tools = optionalTool enableMultipath multipath-tools; 126 vdo = optionalTool enableVDO vdo; 127 SBINDIR = null; # part of original source code in the patch's context 128 } 129 )) 130 ./fix-stdio-usage.patch 131 ]; 132 133 doCheck = false; # requires root 134 doInstallCheck = true; 135 136 makeFlags = 137 lib.optionals udevSupport [ 138 "SYSTEMD_GENERATOR_DIR=${placeholder "out"}/lib/systemd/system-generators" 139 ] 140 ++ lib.optionals onlyLib [ 141 "libdm.device-mapper" 142 ]; 143 144 enableParallelBuilding = true; 145 146 # To prevent make install from failing. 147 installFlags = [ 148 "OWNER=" 149 "GROUP=" 150 "confdir=$(out)/etc" 151 ]; 152 153 # Install systemd stuff. 154 installTargets = [ 155 "install" 156 ] 157 ++ lib.optionals udevSupport [ 158 "install_systemd_generators" 159 "install_systemd_units" 160 "install_tmpfiles_configuration" 161 ]; 162 163 installPhase = lib.optionalString onlyLib '' 164 make -C libdm install_${if stdenv.hostPlatform.isStatic then "static" else "dynamic"} 165 make -C libdm install_include 166 make -C libdm install_pkgconfig 167 ''; 168 169 # only split bin and lib out from out if cmdlib isn't enabled 170 outputs = [ 171 "out" 172 ] 173 ++ lib.optionals (!onlyLib) [ 174 "dev" 175 "man" 176 ] 177 ++ lib.optionals (!onlyLib && !enableCmdlib) [ 178 "bin" 179 "lib" 180 ]; 181 182 postInstall = lib.optionalString (enableCmdlib != true) '' 183 moveToOutput lib/libdevmapper.so $lib 184 ''; 185 186 passthru.tests = { 187 installer = nixosTests.installer.lvm; 188 lvm2 = recurseIntoAttrs nixosTests.lvm2; 189 190 # https://github.com/NixOS/nixpkgs/issues/369732 191 lvm2-fhs-env = buildFHSEnv { 192 name = "lvm2-fhs-env-test"; 193 targetPkgs = p: [ p.lvm2 ]; 194 }; 195 }; 196 197 meta = with lib; { 198 homepage = "http://sourceware.org/lvm2/"; 199 description = "Tools to support Logical Volume Management (LVM) on Linux"; 200 platforms = platforms.linux; 201 license = with licenses; [ 202 gpl2Only 203 bsd2 204 lgpl21 205 ]; 206 maintainers = with maintainers; [ 207 raskin 208 ajs124 209 ]; 210 }; 211}