at 24.11-pre 149 lines 5.3 kB view raw
1{ lib, stdenv, fetchurl, fetchpatch, autoreconfHook, gtk-doc, pkg-config 2, zlib, shadow 3, capabilitiesSupport ? stdenv.isLinux 4, libcap_ng 5, libxcrypt 6, sqlite 7, ncursesSupport ? true 8, ncurses 9, pamSupport ? true 10, pam 11, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd 12, systemd 13, nlsSupport ? true 14, translateManpages ? true 15, po4a 16, installShellFiles 17, writeSupport ? stdenv.isLinux 18, shadowSupport ? stdenv.isLinux 19, memstreamHook 20, gitUpdater 21}: 22let 23 # Temporarily avoid applying the patches on systems where already we have binaries 24 # (in particular x86_64-linux and aarch64-linux) as the package is a huge rebuild there. 25 avoidRebuild = with stdenv.hostPlatform; isLinux && is64bit && !isStatic; 26in 27stdenv.mkDerivation rec { 28 pname = "util-linux" + lib.optionalString (!nlsSupport && !ncursesSupport && !systemdSupport) "-minimal"; 29 version = if avoidRebuild then "2.40.1" else "2.39.4"; 30 31 src = fetchurl { 32 url = "mirror://kernel/linux/utils/util-linux/v${lib.versions.majorMinor version}/util-linux-${version}.tar.xz"; 33 hash = if avoidRebuild 34 then "sha256-WeZ2qlPMtEtsOfD/4BqPonSJHJG+8UdHUvrZJGHe8k8=" 35 else "sha256-bE+HI9r9QcOdk+y/FlCfyIwzzVvTJ3iArlodl6AU/Q4="; 36 }; 37 38 patches = [ 39 ./rtcwake-search-PATH-for-shutdown.patch 40 ]; 41 42 # We separate some of the utilities into their own outputs. This 43 # allows putting together smaller systems depending on only part of 44 # the greater util-linux toolset. 45 # Compatibility is maintained by symlinking the binaries from the 46 # smaller outputs in the bin output. 47 outputs = [ "bin" "dev" "out" "lib" "man" ] ++ lib.optionals stdenv.isLinux [ "mount" ] ++ [ "login" ] ++ lib.optionals stdenv.isLinux [ "swap" ]; 48 separateDebugInfo = true; 49 50 postPatch = '' 51 patchShebangs tests/run.sh tools/all_syscalls 52 53 substituteInPlace sys-utils/eject.c \ 54 --replace "/bin/umount" "$bin/bin/umount" 55 '' + lib.optionalString shadowSupport '' 56 substituteInPlace include/pathnames.h \ 57 --replace "/bin/login" "${shadow}/bin/login" 58 ''; 59 60 # !!! It would be better to obtain the path to the mount helpers 61 # (/sbin/mount.*) through an environment variable, but that's 62 # somewhat risky because we have to consider that mount can setuid 63 # root... 64 configureFlags = [ 65 "--localstatedir=/var" 66 "--disable-use-tty-group" 67 "--enable-fs-paths-default=/run/wrappers/bin:/run/current-system/sw/bin:/sbin" 68 "--disable-makeinstall-setuid" "--disable-makeinstall-chown" 69 "--disable-su" # provided by shadow 70 "--with-tmpfilesdir=${placeholder "out"}/lib/tmpfiles.d" 71 (lib.enableFeature writeSupport "write") 72 (lib.enableFeature nlsSupport "nls") 73 (lib.withFeature ncursesSupport "ncursesw") 74 (lib.withFeature systemdSupport "systemd") 75 (lib.withFeatureAs systemdSupport 76 "systemdsystemunitdir" "${placeholder "bin"}/lib/systemd/system/") 77 (lib.enableFeature translateManpages "poman") 78 "SYSCONFSTATICDIR=${placeholder "lib"}/lib" 79 ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) 80 "scanf_cv_type_modifier=ms" 81 ; 82 83 makeFlags = [ 84 "usrbin_execdir=${placeholder "bin"}/bin" 85 "usrlib_execdir=${placeholder "lib"}/lib" 86 "usrsbin_execdir=${placeholder "bin"}/sbin" 87 ]; 88 89 nativeBuildInputs = [ pkg-config installShellFiles ] 90 ++ lib.optionals translateManpages [ po4a ]; 91 92 buildInputs = [ zlib libxcrypt sqlite ] 93 ++ lib.optionals pamSupport [ pam ] 94 ++ lib.optionals capabilitiesSupport [ libcap_ng ] 95 ++ lib.optionals ncursesSupport [ ncurses ] 96 ++ lib.optionals systemdSupport [ systemd ] 97 ++ lib.optionals (stdenv.system == "x86_64-darwin") [ memstreamHook ]; 98 99 doCheck = false; # "For development purpose only. Don't execute on production system!" 100 101 enableParallelBuilding = true; 102 103 postInstall = lib.optionalString stdenv.isLinux '' 104 moveToOutput bin/mount "$mount" 105 moveToOutput bin/umount "$mount" 106 ln -svf "$mount/bin/"* $bin/bin/ 107 '' + '' 108 109 moveToOutput sbin/nologin "$login" 110 moveToOutput sbin/sulogin "$login" 111 prefix=$login _moveSbin 112 ln -svf "$login/bin/"* $bin/bin/ 113 '' + lib.optionalString stdenv.isLinux '' 114 115 moveToOutput sbin/swapon "$swap" 116 moveToOutput sbin/swapoff "$swap" 117 prefix=$swap _moveSbin 118 ln -svf "$swap/bin/"* $bin/bin/ 119 '' + '' 120 121 installShellCompletion --bash bash-completion/* 122 ''; 123 124 passthru = { 125 updateScript = gitUpdater { 126 # No nicer place to find latest release. 127 url = "https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git"; 128 rev-prefix = "v"; 129 ignoredVersions = "(-rc).*"; 130 }; 131 }; 132 133 meta = with lib; { 134 homepage = "https://www.kernel.org/pub/linux/utils/util-linux/"; 135 description = "A set of system utilities for Linux"; 136 changelog = "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v${lib.versions.majorMinor version}/v${version}-ReleaseNotes"; 137 # https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/README.licensing 138 license = with licenses; [ gpl2Only gpl2Plus gpl3Plus lgpl21Plus bsd3 bsdOriginalUC publicDomain ]; 139 platforms = platforms.unix; 140 pkgConfigModules = [ 141 "blkid" 142 "fdisk" 143 "mount" 144 "smartcols" 145 "uuid" 146 ]; 147 priority = 6; # lower priority than coreutils ("kill") and shadow ("login" etc.) packages 148 }; 149}