2023-07-15 17:15:38 +00:00
|
|
|
{ lib, stdenv, fetchurl, fetchpatch, pkg-config, zlib, shadow
|
|
|
|
, 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
|
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-07-15 17:15:38 +00:00
|
|
|
version = "2.39";
|
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-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-MrMKM2zakDGC7WH+s+m5CLdipeZv4U5D77iNNxYgdcs=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./rtcwake-search-PATH-for-shutdown.patch
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
# FIXME: backport mount fixes for older kernels, remove in next release
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/util-linux/util-linux/commit/f94a7760ed7ce81389a6059f020238981627a70d.diff";
|
|
|
|
hash = "sha256-UorqDeECK8pBePkmpo2x90p/jP3rCMshyPCyijSX1wo=";
|
|
|
|
})
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/util-linux/util-linux/commit/1bd85b64632280d6bf0e86b4ff29da8b19321c5f.diff";
|
|
|
|
hash = "sha256-dgu4de5ul/si7Vzwe8lr9NvsdI1CWfDQKuqvARaY6sE=";
|
|
|
|
})
|
|
|
|
|
|
|
|
# FIXME: backport bcache detection fixes, remove in next release
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/util-linux/util-linux/commit/158639a2a4c6e646fd4fa0acb5f4743e65daa415.diff";
|
|
|
|
hash = "sha256-9F1OQFxKuI383u6MVy/UM15B6B+tkZFRwuDbgoZrWME=";
|
|
|
|
})
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/util-linux/util-linux/commit/00a19fb8cdfeeae30a6688ac6b490e80371b2257.diff";
|
|
|
|
hash = "sha256-w1S6IKSoL6JhVew9t6EemNRc/nrJQ5oMqFekcx0kno8=";
|
|
|
|
})
|
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/*
|
|
|
|
'';
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
}
|