1{ stdenv, fetchurl, zlib, ncurses ? null, perl ? null, pam, systemd ? null
2, pkgconfig
3}:
4
5stdenv.mkDerivation rec {
6 name = "util-linux-2.27.1";
7
8 src = fetchurl {
9 url = "mirror://kernel/linux/utils/util-linux/v2.27/${name}.tar.xz";
10 sha256 = "1452hz5zx56a3mad8yrg5wb0vy5zi19mpjp6zx1yr6p9xp6qz08a";
11 };
12
13 outputs = [ "out" "man" ];
14
15 patches = [
16 ./rtcwake-search-PATH-for-shutdown.patch
17 ];
18
19 #FIXME: make it also work on non-nixos?
20 postPatch = ''
21 # Substituting store paths would create a circular dependency on systemd
22 substituteInPlace include/pathnames.h \
23 --replace "/bin/login" "/run/current-system/sw/bin/login" \
24 --replace "/sbin/shutdown" "/run/current-system/sw/bin/shutdown"
25 '';
26
27 crossAttrs = {
28 # Work around use of `AC_RUN_IFELSE'.
29 preConfigure = "export scanf_cv_type_modifier=ms";
30 };
31
32 # !!! It would be better to obtain the path to the mount helpers
33 # (/sbin/mount.*) through an environment variable, but that's
34 # somewhat risky because we have to consider that mount can setuid
35 # root...
36 configureFlags = ''
37 --enable-write
38 --enable-last
39 --enable-mesg
40 --disable-use-tty-group
41 --enable-fs-paths-default=/var/setuid-wrappers:/var/run/current-system/sw/bin:/sbin
42 ${if ncurses == null then "--without-ncurses" else ""}
43 ${if systemd == null then "" else ''
44 --with-systemd
45 --with-systemdsystemunitdir=$out/lib/systemd/system/
46 ''}
47 '';
48
49 buildInputs =
50 [ zlib pam ]
51 ++ stdenv.lib.optional (ncurses != null) ncurses
52 ++ stdenv.lib.optional (systemd != null) [ systemd pkgconfig ]
53 ++ stdenv.lib.optional (perl != null) perl;
54
55 postInstall = ''
56 rm $out/bin/su # su should be supplied by the su package (shadow)
57 '';
58
59 enableParallelBuilding = true;
60
61 meta = {
62 homepage = http://www.kernel.org/pub/linux/utils/util-linux/;
63 description = "A set of system utilities for Linux";
64 platforms = stdenv.lib.platforms.linux;
65 priority = 6; # lower priority than coreutils ("kill") and shadow ("login" etc.) packages
66 };
67}