2021-04-26 19:14:03 +00:00
|
|
|
{ lib, stdenv, fetchurl, pkg-config, zlib, shadow, libcap_ng
|
2022-04-15 01:41:22 +00:00
|
|
|
, ncursesSupport ? true
|
|
|
|
, ncurses, pam
|
2022-05-18 14:49:53 +00:00
|
|
|
, systemdSupport ? stdenv.isLinux && !stdenv.hostPlatform.isStatic
|
2022-04-15 01:41:22 +00:00
|
|
|
, systemd
|
2021-12-06 16:07:01 +00:00
|
|
|
, nlsSupport ? true
|
|
|
|
}:
|
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";
|
2022-03-30 09:31:56 +00:00
|
|
|
version = "2.37.4";
|
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";
|
2022-03-30 09:31:56 +00:00
|
|
|
sha256 = "sha256-Y05pFq2RM2bDU2tkaOeER2lUm5mnsr+AMU3nirVlW4M=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./rtcwake-search-PATH-for-shutdown.patch
|
|
|
|
];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
outputs = [ "bin" "dev" "out" "lib" "man" ];
|
2022-01-13 20:06:32 +00:00
|
|
|
separateDebugInfo = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs tests/run.sh
|
|
|
|
|
|
|
|
substituteInPlace include/pathnames.h \
|
|
|
|
--replace "/bin/login" "${shadow}/bin/login"
|
|
|
|
substituteInPlace sys-utils/eject.c \
|
|
|
|
--replace "/bin/umount" "$bin/bin/umount"
|
|
|
|
'';
|
|
|
|
|
|
|
|
# !!! 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
|
|
|
"--enable-write"
|
|
|
|
"--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
|
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/")
|
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"
|
|
|
|
];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2022-04-15 01:41:22 +00:00
|
|
|
buildInputs = [ zlib pam libcap_ng ]
|
|
|
|
++ lib.optionals ncursesSupport [ ncurses ]
|
|
|
|
++ lib.optionals systemdSupport [ systemd ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
doCheck = false; # "For development purpose only. Don't execute on production system!"
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
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 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
priority = 6; # lower priority than coreutils ("kill") and shadow ("login" etc.) packages
|
|
|
|
};
|
|
|
|
}
|