at 15.09-beta 168 lines 6.6 kB view raw
1{ stdenv, fetchurl, pkgconfig, intltool, gperf, libcap, dbus, kmod 2, xz, pam, acl, cryptsetup, libuuid, m4, utillinux 3, glib, kbd, libxslt, coreutils, libgcrypt 4, kexectools, libmicrohttpd, linuxHeaders 5, pythonPackages ? null, pythonSupport ? false 6}: 7 8assert stdenv.isLinux; 9 10assert pythonSupport -> pythonPackages != null; 11 12stdenv.mkDerivation rec { 13 version = "217"; 14 name = "systemd-${version}"; 15 16 src = fetchurl { 17 url = "http://www.freedesktop.org/software/systemd/${name}.tar.xz"; 18 sha256 = "163l1y4p2a564d4ynfq3k3xf53j2v5s81blb6cvpn1y7rpxyccd0"; 19 }; 20 21 patches = 22 [ # These are all changes between upstream and 23 # https://github.com/NixOS/systemd/tree/nixos-v217. 24 ./fixes.patch 25 ]; 26 27 buildInputs = 28 [ pkgconfig intltool gperf libcap kmod xz pam acl 29 /* cryptsetup */ libuuid m4 glib libxslt libgcrypt 30 libmicrohttpd linuxHeaders 31 ] ++ stdenv.lib.optionals pythonSupport [pythonPackages.python pythonPackages.lxml]; 32 33 configureFlags = 34 [ "--localstatedir=/var" 35 "--sysconfdir=/etc" 36 "--with-rootprefix=$(out)" 37 "--with-kbd-loadkeys=${kbd}/bin/loadkeys" 38 "--with-kbd-setfont=${kbd}/bin/setfont" 39 "--with-rootprefix=$(out)" 40 "--with-dbusinterfacedir=$(out)/share/dbus-1/interfaces" 41 "--with-dbuspolicydir=$(out)/etc/dbus-1/system.d" 42 "--with-dbussystemservicedir=$(out)/share/dbus-1/system-services" 43 "--with-dbussessionservicedir=$(out)/share/dbus-1/services" 44 "--with-firmware-path=/root/test-firmware:/run/current-system/firmware" 45 "--with-tty-gid=3" # tty in NixOS has gid 3 46 "--enable-compat-libs" # get rid of this eventually 47 "--disable-tests" 48 49 "--disable-hostnamed" 50 "--enable-networkd" 51 "--disable-sysusers" 52 "--disable-timedated" 53 "--enable-timesyncd" 54 "--disable-readahead" 55 "--disable-firstboot" 56 "--disable-localed" 57 "--enable-resolved" 58 "--disable-split-usr" 59 60 "--with-sysvinit-path=" 61 "--with-sysvrcnd-path=" 62 "--with-rc-local-script-path-stop=/etc/halt.local" 63 ]; 64 65 preConfigure = 66 '' 67 # FIXME: patch this in systemd properly (and send upstream). 68 # FIXME: use sulogin from util-linux once updated. 69 for i in src/remount-fs/remount-fs.c src/core/mount.c src/core/swap.c src/fsck/fsck.c units/emergency.service.in units/rescue.service.in src/journal/cat.c src/core/shutdown.c src/nspawn/nspawn.c; do 70 test -e $i 71 substituteInPlace $i \ 72 --replace /usr/bin/getent ${stdenv.glibc}/bin/getent \ 73 --replace /bin/mount ${utillinux}/bin/mount \ 74 --replace /bin/umount ${utillinux}/bin/umount \ 75 --replace /sbin/swapon ${utillinux}/sbin/swapon \ 76 --replace /sbin/swapoff ${utillinux}/sbin/swapoff \ 77 --replace /bin/echo ${coreutils}/bin/echo \ 78 --replace /bin/cat ${coreutils}/bin/cat \ 79 --replace /sbin/sulogin ${utillinux}/sbin/sulogin \ 80 --replace /sbin/kexec ${kexectools}/sbin/kexec 81 done 82 83 substituteInPlace src/journal/catalog.c \ 84 --replace /usr/lib/systemd/catalog/ $out/lib/systemd/catalog/ 85 86 configureFlagsArray+=("--with-ntp-servers=0.nixos.pool.ntp.org 1.nixos.pool.ntp.org 2.nixos.pool.ntp.org 3.nixos.pool.ntp.org") 87 ''; 88 89 # This is needed because systemd uses the gold linker, which doesn't 90 # yet have the wrapper script to add rpath flags automatically. 91 NIX_LDFLAGS = "-rpath ${pam}/lib -rpath ${libcap}/lib -rpath ${acl}/lib -rpath ${stdenv.cc.cc}/lib"; 92 93 PYTHON_BINARY = "${coreutils}/bin/env python"; # don't want a build time dependency on Python 94 95 NIX_CFLAGS_COMPILE = 96 [ # Can't say ${polkit}/bin/pkttyagent here because that would 97 # lead to a cyclic dependency. 98 "-UPOLKIT_AGENT_BINARY_PATH" "-DPOLKIT_AGENT_BINARY_PATH=\"/run/current-system/sw/bin/pkttyagent\"" 99 "-fno-stack-protector" 100 101 # Set the release_agent on /sys/fs/cgroup/systemd to the 102 # currently running systemd (/run/current-system/systemd) so 103 # that we don't use an obsolete/garbage-collected release agent. 104 "-USYSTEMD_CGROUP_AGENT_PATH" "-DSYSTEMD_CGROUP_AGENT_PATH=\"/run/current-system/systemd/lib/systemd/systemd-cgroups-agent\"" 105 106 "-USYSTEMD_BINARY_PATH" "-DSYSTEMD_BINARY_PATH=\"/run/current-system/systemd/lib/systemd/systemd\"" 107 ]; 108 109 # Use /var/lib/udev rather than /etc/udev for the generated hardware 110 # database. Upstream doesn't want this (see commit 111 # 1e1954f53386cb773e2a152748dd31c4d36aa2d8) because using /var is 112 # forbidden in early boot, but in NixOS the initrd guarantees that 113 # /var is mounted. 114 makeFlags = "hwdb_bin=/var/lib/udev/hwdb.bin"; 115 116 installFlags = 117 [ "localstatedir=$(TMPDIR)/var" 118 "sysconfdir=$(out)/etc" 119 "sysvinitdir=$(TMPDIR)/etc/init.d" 120 "pamconfdir=$(out)/etc/pam.d" 121 ]; 122 123 postInstall = 124 '' 125 # sysinit.target: Don't depend on 126 # systemd-tmpfiles-setup.service. This interferes with NixOps's 127 # send-keys feature (since sshd.service depends indirectly on 128 # sysinit.target). 129 mv $out/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup-dev.service $out/lib/systemd/system/multi-user.target.wants/ 130 131 mkdir -p $out/example/systemd 132 mv $out/lib/{modules-load.d,binfmt.d,sysctl.d,tmpfiles.d} $out/example 133 mv $out/lib/systemd/{system,user} $out/example/systemd 134 135 rm -rf $out/etc/systemd/system 136 137 # Install SysV compatibility commands. 138 mkdir -p $out/sbin 139 ln -s $out/lib/systemd/systemd $out/sbin/telinit 140 for i in init halt poweroff runlevel reboot shutdown; do 141 ln -s $out/bin/systemctl $out/sbin/$i 142 done 143 144 # Fix reference to /bin/false in the D-Bus services. 145 for i in $out/share/dbus-1/system-services/*.service; do 146 substituteInPlace $i --replace /bin/false ${coreutils}/bin/false 147 done 148 149 rm -rf $out/etc/rpm 150 ''; # */ 151 152 enableParallelBuilding = true; 153 154 # The interface version prevents NixOS from switching to an 155 # incompatible systemd at runtime. (Switching across reboots is 156 # fine, of course.) It should be increased whenever systemd changes 157 # in a backwards-incompatible way. If the interface version of two 158 # systemd builds is the same, then we can switch between them at 159 # runtime; otherwise we can't and we need to reboot. 160 passthru.interfaceVersion = 2; 161 162 meta = { 163 homepage = "http://www.freedesktop.org/wiki/Software/systemd"; 164 description = "A system and service manager for Linux"; 165 platforms = stdenv.lib.platforms.linux; 166 maintainers = [ stdenv.lib.maintainers.eelco stdenv.lib.maintainers.simons ]; 167 }; 168}