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