core/pkgs/by-name/ut/util-linux/default.nix

140 lines
4.8 KiB
Nix
Raw Normal View History

2024-05-02 00:46:19 +00:00
{ lib, stdenv, fetchurl, pkg-config, zlib, shadow
2024-05-13 21:24:10 +00:00
, capabilitiesSupport ? stdenv.isLinux, libcap_ng, libxcrypt
, ncursesSupport ? true, ncurses, pamSupport ? true, pam
, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
, nlsSupport ? true, translateManpages ? true, po4a, installShellFiles
, writeSupport ? stdenv.isLinux, shadowSupport ? stdenv.isLinux, memstreamHook
2024-05-02 00:46:19 +00:00
# for passthru
# , gitUpdater
}:
stdenv.mkDerivation rec {
2024-05-13 21:24:10 +00:00
pname = "util-linux"
+ lib.optionalString (!nlsSupport && !ncursesSupport && !systemdSupport)
"-minimal";
2024-05-02 00:46:19 +00:00
version = "2.39.3";
src = fetchurl {
2024-05-13 21:24:10 +00:00
url = "mirror://kernel/linux/utils/util-linux/v${
lib.versions.majorMinor version
}/util-linux-${version}.tar.xz";
2024-05-02 00:46:19 +00:00
hash = "sha256-e2YF5I0aSfQ8xLTPxZ8xPQ3VQC+kC5aBC9Vy4Wff7Q8=";
};
2024-05-13 21:24:10 +00:00
patches = [ ./rtcwake-search-PATH-for-shutdown.patch ];
2024-05-02 00:46:19 +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.
2024-05-13 21:24:10 +00:00
outputs = [ "bin" "dev" "out" "lib" "man" ]
++ lib.optionals stdenv.isLinux [ "mount" ] ++ [ "login" ]
++ lib.optionals stdenv.isLinux [ "swap" ];
2024-05-02 00:46:19 +00:00
separateDebugInfo = true;
postPatch = ''
patchShebangs tests/run.sh
substituteInPlace sys-utils/eject.c \
--replace "/bin/umount" "$bin/bin/umount"
'' + lib.optionalString shadowSupport ''
substituteInPlace include/pathnames.h \
--replace "/bin/login" "${shadow}/bin/login"
'';
# !!! 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 = [
"--localstatedir=/var"
"--disable-use-tty-group"
"--enable-fs-paths-default=/run/wrappers/bin:/run/current-system/sw/bin:/sbin"
2024-05-13 21:24:10 +00:00
"--disable-makeinstall-setuid"
"--disable-makeinstall-chown"
2024-05-02 00:46:19 +00:00
"--disable-su" # provided by shadow
(lib.enableFeature writeSupport "write")
(lib.enableFeature nlsSupport "nls")
(lib.withFeature ncursesSupport "ncursesw")
(lib.withFeature systemdSupport "systemd")
2024-05-13 21:24:10 +00:00
(lib.withFeatureAs systemdSupport "systemdsystemunitdir"
"${placeholder "bin"}/lib/systemd/system/")
2024-05-02 00:46:19 +00:00
(lib.enableFeature translateManpages "poman")
"SYSCONFSTATICDIR=${placeholder "lib"}/lib"
] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform)
2024-05-13 21:24:10 +00:00
"scanf_cv_type_modifier=ms";
2024-05-02 00:46:19 +00:00
makeFlags = [
"usrbin_execdir=${placeholder "bin"}/bin"
"usrlib_execdir=${placeholder "lib"}/lib"
"usrsbin_execdir=${placeholder "bin"}/sbin"
];
nativeBuildInputs = [ pkg-config installShellFiles ]
++ lib.optionals translateManpages [ po4a ];
2024-05-13 21:24:10 +00:00
buildInputs = [ zlib libxcrypt ] ++ lib.optionals pamSupport [ pam ]
2024-05-02 00:46:19 +00:00
++ lib.optionals capabilitiesSupport [ libcap_ng ]
++ lib.optionals ncursesSupport [ ncurses ]
++ lib.optionals systemdSupport [ systemd ]
++ lib.optionals (stdenv.system == "x86_64-darwin") [ memstreamHook ];
2024-05-13 21:24:10 +00:00
doCheck =
false; # "For development purpose only. Don't execute on production system!"
2024-05-02 00:46:19 +00:00
enableParallelBuilding = true;
postInstall = lib.optionalString stdenv.isLinux ''
moveToOutput bin/mount "$mount"
moveToOutput bin/umount "$mount"
ln -svf "$mount/bin/"* $bin/bin/
2024-05-13 21:24:10 +00:00
'' + ''
2024-05-02 00:46:19 +00:00
moveToOutput sbin/nologin "$login"
moveToOutput sbin/sulogin "$login"
prefix=$login _moveSbin
ln -svf "$login/bin/"* $bin/bin/
2024-05-13 21:24:10 +00:00
'' + lib.optionalString stdenv.isLinux ''
2024-05-02 00:46:19 +00:00
moveToOutput sbin/swapon "$swap"
moveToOutput sbin/swapoff "$swap"
prefix=$swap _moveSbin
ln -svf "$swap/bin/"* $bin/bin/
2024-05-13 21:24:10 +00:00
'' + ''
2024-05-02 00:46:19 +00:00
installShellCompletion --bash bash-completion/*
'';
# 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).*";
# };
# };
meta = with lib; {
homepage = "https://www.kernel.org/pub/linux/utils/util-linux/";
description = "A set of system utilities for Linux";
2024-05-13 21:24:10 +00:00
changelog = "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v${
lib.versions.majorMinor version
}/v${version}-ReleaseNotes";
2024-05-02 00:46:19 +00:00
# https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/README.licensing
2024-05-13 21:24:10 +00:00
license = with licenses; [
gpl2Only
gpl2Plus
gpl3Plus
lgpl21Plus
bsd3
bsdOriginalUC
publicDomain
2024-05-02 00:46:19 +00:00
];
2024-05-13 21:24:10 +00:00
platforms = platforms.unix;
pkgConfigModules = [ "blkid" "fdisk" "mount" "smartcols" "uuid" ];
priority =
6; # lower priority than coreutils ("kill") and shadow ("login" etc.) packages
2024-05-02 00:46:19 +00:00
};
}