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