at 17.09-beta 182 lines 7.0 kB view raw
1{ stdenv, fetchFromGitHub, fetchpatch, pkgconfig, intltool, gperf, libcap, kmod 2, zlib, xz, pam, acl, cryptsetup, libuuid, m4, utillinux, libffi 3, glib, kbd, libxslt, coreutils, libgcrypt, libgpgerror, libapparmor, audit, lz4 4, kexectools, libmicrohttpd, linuxHeaders ? stdenv.cc.libc.linuxHeaders, libseccomp 5, iptables, gnu-efi 6, autoreconfHook, gettext, docbook_xsl, docbook_xml_dtd_42, docbook_xml_dtd_45 7}: 8 9assert stdenv.isLinux; 10 11stdenv.mkDerivation rec { 12 version = "234"; 13 name = "systemd-${version}"; 14 15 src = fetchFromGitHub { 16 owner = "nixos"; 17 repo = "systemd"; 18 rev = "ba777535a890c2a2b7677dfacc63e12c578b9b3f"; 19 sha256 = "1vb45fbqkrgczfwkb0y07ldnwhjqk2sh446hzfkdn8hrwl1lifg5"; 20 }; 21 22 outputs = [ "out" "lib" "man" "dev" ]; 23 24 buildInputs = 25 [ linuxHeaders pkgconfig intltool gperf libcap kmod xz pam acl 26 /* cryptsetup */ libuuid m4 glib libxslt libgcrypt libgpgerror 27 libmicrohttpd kexectools libseccomp libffi audit lz4 libapparmor 28 iptables gnu-efi 29 /* FIXME: we may be able to prevent the following dependencies 30 by generating an autoconf'd tarball, but that's probably not 31 worth it. */ 32 autoreconfHook gettext docbook_xsl docbook_xml_dtd_42 docbook_xml_dtd_45 33 ]; 34 35 configureFlags = 36 [ "--localstatedir=/var" 37 "--sysconfdir=/etc" 38 "--with-rootprefix=$(out)" 39 "--with-kbd-loadkeys=${kbd}/bin/loadkeys" 40 "--with-kbd-setfont=${kbd}/bin/setfont" 41 "--with-rootprefix=$(out)" 42 "--with-dbuspolicydir=$(out)/etc/dbus-1/system.d" 43 "--with-dbussystemservicedir=$(out)/share/dbus-1/system-services" 44 "--with-dbussessionservicedir=$(out)/share/dbus-1/services" 45 "--with-tty-gid=3" # tty in NixOS has gid 3 46 "--disable-tests" 47 48 "--enable-lz4" 49 "--enable-hostnamed" 50 "--enable-networkd" 51 "--disable-sysusers" 52 "--enable-timedated" 53 "--enable-timesyncd" 54 "--disable-firstboot" 55 "--enable-localed" 56 "--enable-resolved" 57 "--disable-split-usr" 58 "--disable-libcurl" 59 "--disable-libidn" 60 "--disable-quotacheck" 61 "--disable-ldconfig" 62 "--disable-smack" 63 64 (if stdenv.isArm then "--disable-gnuefi" else "--enable-gnuefi") 65 "--with-efi-libdir=${gnu-efi}/lib" 66 "--with-efi-includedir=${gnu-efi}/include" 67 "--with-efi-ldsdir=${gnu-efi}/lib" 68 69 "--with-sysvinit-path=" 70 "--with-sysvrcnd-path=" 71 "--with-rc-local-script-path-stop=/etc/halt.local" 72 ]; 73 74 hardeningDisable = [ "stackprotector" ]; 75 76 preConfigure = 77 '' 78 unset RANLIB 79 80 ./autogen.sh 81 82 # FIXME: patch this in systemd properly (and send upstream). 83 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 src/shared/generator.c; do 84 test -e $i 85 substituteInPlace $i \ 86 --replace /usr/bin/getent ${stdenv.glibc.bin}/bin/getent \ 87 --replace /bin/mount ${utillinux.bin}/bin/mount \ 88 --replace /bin/umount ${utillinux.bin}/bin/umount \ 89 --replace /sbin/swapon ${utillinux.bin}/sbin/swapon \ 90 --replace /sbin/swapoff ${utillinux.bin}/sbin/swapoff \ 91 --replace /sbin/fsck ${utillinux.bin}/sbin/fsck \ 92 --replace /bin/echo ${coreutils}/bin/echo \ 93 --replace /bin/cat ${coreutils}/bin/cat \ 94 --replace /sbin/sulogin ${utillinux.bin}/sbin/sulogin \ 95 --replace /usr/lib/systemd/systemd-fsck $out/lib/systemd/systemd-fsck \ 96 --replace /bin/plymouth /run/current-system/sw/bin/plymouth # To avoid dependency 97 done 98 99 substituteInPlace src/journal/catalog.c \ 100 --replace /usr/lib/systemd/catalog/ $out/lib/systemd/catalog/ 101 102 configureFlagsArray+=("--with-ntp-servers=0.nixos.pool.ntp.org 1.nixos.pool.ntp.org 2.nixos.pool.ntp.org 3.nixos.pool.ntp.org") 103 ''; 104 105 PYTHON_BINARY = "${coreutils}/bin/env python"; # don't want a build time dependency on Python 106 107 NIX_CFLAGS_COMPILE = 108 [ # Can't say ${polkit.bin}/bin/pkttyagent here because that would 109 # lead to a cyclic dependency. 110 "-UPOLKIT_AGENT_BINARY_PATH" "-DPOLKIT_AGENT_BINARY_PATH=\"/run/current-system/sw/bin/pkttyagent\"" 111 "-fno-stack-protector" 112 113 # Set the release_agent on /sys/fs/cgroup/systemd to the 114 # currently running systemd (/run/current-system/systemd) so 115 # that we don't use an obsolete/garbage-collected release agent. 116 "-USYSTEMD_CGROUP_AGENT_PATH" "-DSYSTEMD_CGROUP_AGENT_PATH=\"/run/current-system/systemd/lib/systemd/systemd-cgroups-agent\"" 117 118 "-USYSTEMD_BINARY_PATH" "-DSYSTEMD_BINARY_PATH=\"/run/current-system/systemd/lib/systemd/systemd\"" 119 ]; 120 121 installFlags = 122 [ "localstatedir=$(TMPDIR)/var" 123 "sysconfdir=$(out)/etc" 124 "sysvinitdir=$(TMPDIR)/etc/init.d" 125 "pamconfdir=$(out)/etc/pam.d" 126 ]; 127 128 postInstall = 129 '' 130 # sysinit.target: Don't depend on 131 # systemd-tmpfiles-setup.service. This interferes with NixOps's 132 # send-keys feature (since sshd.service depends indirectly on 133 # sysinit.target). 134 mv $out/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup-dev.service $out/lib/systemd/system/multi-user.target.wants/ 135 136 mkdir -p $out/example/systemd 137 mv $out/lib/{modules-load.d,binfmt.d,sysctl.d,tmpfiles.d} $out/example 138 mv $out/lib/systemd/{system,user} $out/example/systemd 139 140 rm -rf $out/etc/systemd/system 141 142 # Install SysV compatibility commands. 143 mkdir -p $out/sbin 144 ln -s $out/lib/systemd/systemd $out/sbin/telinit 145 for i in init halt poweroff runlevel reboot shutdown; do 146 ln -s $out/bin/systemctl $out/sbin/$i 147 done 148 149 # Fix reference to /bin/false in the D-Bus services. 150 for i in $out/share/dbus-1/system-services/*.service; do 151 substituteInPlace $i --replace /bin/false ${coreutils}/bin/false 152 done 153 154 rm -rf $out/etc/rpm 155 156 rm $lib/lib/*.la 157 158 # "kernel-install" shouldn't be used on NixOS. 159 find $out -name "*kernel-install*" -exec rm {} \; 160 161 # Keep only libudev and libsystemd in the lib output. 162 mkdir -p $out/lib 163 mv $lib/lib/security $lib/lib/libnss* $out/lib/ 164 ''; # */ 165 166 enableParallelBuilding = true; 167 168 # The interface version prevents NixOS from switching to an 169 # incompatible systemd at runtime. (Switching across reboots is 170 # fine, of course.) It should be increased whenever systemd changes 171 # in a backwards-incompatible way. If the interface version of two 172 # systemd builds is the same, then we can switch between them at 173 # runtime; otherwise we can't and we need to reboot. 174 passthru.interfaceVersion = 2; 175 176 meta = { 177 homepage = http://www.freedesktop.org/wiki/Software/systemd; 178 description = "A system and service manager for Linux"; 179 platforms = stdenv.lib.platforms.linux; 180 maintainers = [ stdenv.lib.maintainers.eelco ]; 181 }; 182}