2023-10-09 19:29:22 +00:00
|
|
|
{ lib, stdenv, fetchurl, pkg-config, zlib, shadow
|
2023-07-15 17:15:38 +00:00
|
|
|
, capabilitiesSupport ? stdenv.isLinux
|
2022-06-16 17:23:12 +00:00
|
|
|
, libcap_ng
|
2022-10-30 15:09:59 +00:00
|
|
|
, libxcrypt
|
2022-04-15 01:41:22 +00:00
|
|
|
, ncursesSupport ? true
|
2022-06-16 17:23:12 +00:00
|
|
|
, ncurses
|
|
|
|
, pamSupport ? true
|
|
|
|
, pam
|
2023-02-02 18:25:31 +00:00
|
|
|
, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd
|
2022-04-15 01:41:22 +00:00
|
|
|
, systemd
|
2021-12-06 16:07:01 +00:00
|
|
|
, nlsSupport ? true
|
2022-08-12 12:06:08 +00:00
|
|
|
, translateManpages ? true
|
|
|
|
, po4a
|
2023-03-04 12:14:45 +00:00
|
|
|
, installShellFiles
|
2023-07-15 17:15:38 +00:00
|
|
|
, writeSupport ? stdenv.isLinux
|
|
|
|
, shadowSupport ? stdenv.isLinux
|
|
|
|
, memstreamHook
|
2023-10-09 19:29:22 +00:00
|
|
|
, gitUpdater
|
2021-12-06 16:07:01 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2022-04-15 01:41:22 +00:00
|
|
|
pname = "util-linux" + lib.optionalString (!nlsSupport && !ncursesSupport && !systemdSupport) "-minimal";
|
2023-10-09 19:29:22 +00:00
|
|
|
version = "2.39.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2022-04-15 01:41:22 +00:00
|
|
|
url = "mirror://kernel/linux/utils/util-linux/v${lib.versions.majorMinor version}/util-linux-${version}.tar.xz";
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = "sha256-h6vfqo5JD4vm3el298gLm1/58wHhtn44meHwWlmhUx8=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./rtcwake-search-PATH-for-shutdown.patch
|
2023-11-16 04:20:00 +00:00
|
|
|
./bcachefs-patch-set.patch
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
# We separate some of the utilities into their own outputs. This
|
|
|
|
# allows putting together smaller systems depending on only part of
|
|
|
|
# the greater util-linux toolset.
|
|
|
|
# Compatibility is maintained by symlinking the binaries from the
|
|
|
|
# smaller outputs in the bin output.
|
2023-08-04 22:07:22 +00:00
|
|
|
outputs = [ "bin" "dev" "out" "lib" "man" ] ++ lib.optionals stdenv.isLinux [ "mount" ] ++ [ "login" ] ++ lib.optionals stdenv.isLinux [ "swap" ];
|
2022-01-13 20:06:32 +00:00
|
|
|
separateDebugInfo = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs tests/run.sh
|
|
|
|
|
|
|
|
substituteInPlace sys-utils/eject.c \
|
|
|
|
--replace "/bin/umount" "$bin/bin/umount"
|
2023-07-15 17:15:38 +00:00
|
|
|
'' + lib.optionalString shadowSupport ''
|
|
|
|
substituteInPlace include/pathnames.h \
|
|
|
|
--replace "/bin/login" "${shadow}/bin/login"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# !!! It would be better to obtain the path to the mount helpers
|
|
|
|
# (/sbin/mount.*) through an environment variable, but that's
|
|
|
|
# somewhat risky because we have to consider that mount can setuid
|
|
|
|
# root...
|
|
|
|
configureFlags = [
|
2021-12-06 16:07:01 +00:00
|
|
|
"--localstatedir=/var"
|
2020-04-24 23:36:52 +00:00
|
|
|
"--disable-use-tty-group"
|
|
|
|
"--enable-fs-paths-default=/run/wrappers/bin:/run/current-system/sw/bin:/sbin"
|
|
|
|
"--disable-makeinstall-setuid" "--disable-makeinstall-chown"
|
|
|
|
"--disable-su" # provided by shadow
|
2023-07-15 17:15:38 +00:00
|
|
|
(lib.enableFeature writeSupport "write")
|
2021-12-06 16:07:01 +00:00
|
|
|
(lib.enableFeature nlsSupport "nls")
|
2022-04-15 01:41:22 +00:00
|
|
|
(lib.withFeature ncursesSupport "ncursesw")
|
|
|
|
(lib.withFeature systemdSupport "systemd")
|
|
|
|
(lib.withFeatureAs systemdSupport
|
2020-04-24 23:36:52 +00:00
|
|
|
"systemdsystemunitdir" "${placeholder "bin"}/lib/systemd/system/")
|
2022-08-12 12:06:08 +00:00
|
|
|
(lib.enableFeature translateManpages "poman")
|
2021-12-06 16:07:01 +00:00
|
|
|
"SYSCONFSTATICDIR=${placeholder "lib"}/lib"
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform)
|
|
|
|
"scanf_cv_type_modifier=ms"
|
|
|
|
;
|
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
"usrbin_execdir=${placeholder "bin"}/bin"
|
2021-12-06 16:07:01 +00:00
|
|
|
"usrlib_execdir=${placeholder "lib"}/lib"
|
2020-04-24 23:36:52 +00:00
|
|
|
"usrsbin_execdir=${placeholder "bin"}/sbin"
|
|
|
|
];
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
nativeBuildInputs = [ pkg-config installShellFiles ]
|
2022-08-12 12:06:08 +00:00
|
|
|
++ lib.optionals translateManpages [ po4a ];
|
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
buildInputs = [ zlib libxcrypt ]
|
2022-06-16 17:23:12 +00:00
|
|
|
++ lib.optionals pamSupport [ pam ]
|
|
|
|
++ lib.optionals capabilitiesSupport [ libcap_ng ]
|
2022-04-15 01:41:22 +00:00
|
|
|
++ lib.optionals ncursesSupport [ ncurses ]
|
2023-07-15 17:15:38 +00:00
|
|
|
++ lib.optionals systemdSupport [ systemd ]
|
|
|
|
++ lib.optionals (stdenv.system == "x86_64-darwin") [ memstreamHook ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
doCheck = false; # "For development purpose only. Don't execute on production system!"
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
postInstall = lib.optionalString stdenv.isLinux ''
|
2023-07-15 17:15:38 +00:00
|
|
|
moveToOutput bin/mount "$mount"
|
|
|
|
moveToOutput bin/umount "$mount"
|
|
|
|
ln -svf "$mount/bin/"* $bin/bin/
|
2023-08-04 22:07:22 +00:00
|
|
|
'' + ''
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
moveToOutput sbin/nologin "$login"
|
|
|
|
moveToOutput sbin/sulogin "$login"
|
|
|
|
prefix=$login _moveSbin
|
|
|
|
ln -svf "$login/bin/"* $bin/bin/
|
2023-08-04 22:07:22 +00:00
|
|
|
'' + lib.optionalString stdenv.isLinux ''
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
moveToOutput sbin/swapon "$swap"
|
|
|
|
moveToOutput sbin/swapoff "$swap"
|
|
|
|
prefix=$swap _moveSbin
|
|
|
|
ln -svf "$swap/bin/"* $bin/bin/
|
2023-08-04 22:07:22 +00:00
|
|
|
'' + ''
|
2023-07-15 17:15:38 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
installShellCompletion --bash bash-completion/*
|
|
|
|
'';
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = gitUpdater {
|
|
|
|
# No nicer place to find latest release.
|
|
|
|
url = "https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git";
|
|
|
|
rev-prefix = "v";
|
|
|
|
ignoredVersions = "(-rc).*";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://www.kernel.org/pub/linux/utils/util-linux/";
|
|
|
|
description = "A set of system utilities for Linux";
|
2021-04-26 19:14:03 +00:00
|
|
|
changelog = "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v${lib.versions.majorMinor version}/v${version}-ReleaseNotes";
|
|
|
|
# https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/README.licensing
|
|
|
|
license = with licenses; [ gpl2Only gpl2Plus gpl3Plus lgpl21Plus bsd3 bsdOriginalUC publicDomain ];
|
2023-07-15 17:15:38 +00:00
|
|
|
platforms = platforms.unix;
|
2023-08-10 07:59:29 +00:00
|
|
|
pkgConfigModules = [
|
|
|
|
"blkid"
|
|
|
|
"fdisk"
|
|
|
|
"mount"
|
|
|
|
"smartcols"
|
|
|
|
"uuid"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
priority = 6; # lower priority than coreutils ("kill") and shadow ("login" etc.) packages
|
|
|
|
};
|
|
|
|
}
|