···
{ stdenv, fetchFromGitHub, fetchpatch, pkgconfig, intltool, gperf, libcap, kmod
, 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
3
+
, glib, kbd, libxslt, coreutils, libgcrypt, libgpgerror, libidn2, libapparmor
4
+
, audit, lz4, bzip2, kexectools, libmicrohttpd
5
+
, linuxHeaders ? stdenv.cc.libc.linuxHeaders
6
+
, libseccomp, iptables, gnu-efi
, autoreconfHook, gettext, docbook_xsl, docbook_xml_dtd_42, docbook_xml_dtd_45
8
+
, ninja, meson, python3Packages, glibcLocales
11
-
stdenv.mkDerivation rec {
13
-
name = "systemd-${version}";
14
+
let pythonLxmlEnv = python3Packages.python.withPackages ( ps: with ps; [ python3Packages.lxml ]);
15
-
src = fetchFromGitHub {
18
-
rev = "eef5613fda5";
19
-
sha256 = "0wgh5y319v56hcs82mhs58ipb100cz4x41vz3kh4bq1n7sx88cdz";
22
-
outputs = [ "out" "lib" "man" "dev" ];
18
+
stdenv.mkDerivation rec {
20
+
name = "systemd-${version}";
25
-
[ pkgconfig intltool gperf libxslt
26
-
/* FIXME: we may be able to prevent the following dependencies
27
-
by generating an autoconf'd tarball, but that's probably not
29
-
autoreconfHook gettext docbook_xsl docbook_xml_dtd_42 docbook_xml_dtd_45
32
-
[ linuxHeaders libcap kmod xz pam acl
33
-
/* cryptsetup */ libuuid m4 glib libgcrypt libgpgerror
34
-
libmicrohttpd kexectools libseccomp libffi audit lz4 libapparmor
22
+
src = fetchFromGitHub {
25
+
rev = "1e8830dfa77a7dc6976509f4a6edb7e012c50792";
26
+
sha256 = "1cw1k0i68azmzpqzi3r8jm6mbi2wqlql78fhcg0vvnv1ly8bf7vq";
39
-
[ "--localstatedir=/var"
41
-
"--with-rootprefix=$(out)"
42
-
"--with-kbd-loadkeys=${kbd}/bin/loadkeys"
43
-
"--with-kbd-setfont=${kbd}/bin/setfont"
44
-
"--with-rootprefix=$(out)"
45
-
"--with-dbuspolicydir=$(out)/etc/dbus-1/system.d"
46
-
"--with-dbussystemservicedir=$(out)/share/dbus-1/system-services"
47
-
"--with-dbussessionservicedir=$(out)/share/dbus-1/services"
48
-
"--with-tty-gid=3" # tty in NixOS has gid 3
29
+
outputs = [ "out" "lib" "man" "dev" ];
52
-
"--enable-hostnamed"
54
-
"--disable-sysusers"
55
-
"--enable-timedated"
56
-
"--enable-timesyncd"
57
-
"--disable-firstboot"
60
-
"--disable-split-usr"
63
-
"--disable-quotacheck"
64
-
"--disable-ldconfig"
32
+
[ pkgconfig intltool gperf libxslt gettext docbook_xsl docbook_xml_dtd_42 docbook_xml_dtd_45
34
+
coreutils # meson calls date, stat etc.
35
+
pythonLxmlEnv glibcLocales
39
+
[ linuxHeaders libcap kmod xz pam acl
40
+
/* cryptsetup */ libuuid m4 glib libgcrypt libgpgerror libidn2
41
+
libmicrohttpd kexectools libseccomp libffi audit lz4 bzip2 libapparmor
67
-
(if stdenv.isArm then "--disable-gnuefi" else "--enable-gnuefi")
68
-
"--with-efi-libdir=${gnu-efi}/lib"
69
-
"--with-efi-includedir=${gnu-efi}/include"
70
-
"--with-efi-ldsdir=${gnu-efi}/lib"
45
+
#dontAddPrefix = true;
48
+
"-Dloadkeys-path=${kbd}/bin/loadkeys"
49
+
"-Dsetfont-path=${kbd}/bin/setfont"
50
+
"-Dtty-gid=3" # tty in NixOS has gid 3
65
+
"-Dquotacheck=false"
68
+
"-Dsystem-uid-max=499" #TODO: debug why awking around in /etc/login.defs doesn't work
69
+
"-Dsystem-gid-max=499"
72
+
(if stdenv.isArm then "-Dgnu-efi=false" else "-Dgnu-efi=true")
73
+
"-Defi-libdir=${gnu-efi}/lib"
74
+
"-Defi-includedir=${gnu-efi}/include/efi"
75
+
"-Defi-ldsdir=${gnu-efi}/lib"
72
-
"--with-sysvinit-path="
73
-
"--with-sysvrcnd-path="
74
-
"--with-rc-local-script-path-stop=/etc/halt.local"
77
-
hardeningDisable = [ "stackprotector" ];
83
+
mesonFlagsArray+=(-Dntp-servers="0.nixos.pool.ntp.org 1.nixos.pool.ntp.org 2.nixos.pool.ntp.org 3.nixos.pool.ntp.org")
84
+
mesonFlagsArray+=(-Ddbuspolicydir=$out/etc/dbus-1/system.d)
85
+
mesonFlagsArray+=(-Ddbussessionservicedir=$out/share/dbus-1/services)
86
+
mesonFlagsArray+=(-Ddbussystemservicedir=$out/share/dbus-1/system-services)
87
+
mesonFlagsArray+=(-Dpamconfdir=$out/etc/pam.d)
88
+
mesonFlagsArray+=(-Dsysconfdir=$out/etc)
89
+
mesonFlagsArray+=(-Drootprefix=$out)
90
+
mesonFlagsArray+=(-Dlibdir=$lib/lib)
91
+
mesonFlagsArray+=(-Drootlibdir=$lib/lib)
92
+
mesonFlagsArray+=(-Dmandir=$man/lib)
93
+
mesonFlagsArray+=(-Dincludedir=$dev/include)
94
+
mesonFlagsArray+=(-Dpkgconfiglibdir=$dev/lib/pkgconfig)
95
+
mesonFlagsArray+=(-Dpkgconfigdatadir=$dev/share/pkgconfig)
80
-
# TODO: Remove this patch when we have a systemd version
81
-
# with https://github.com/systemd/systemd/pull/6678
83
-
url = "https://github.com/systemd/systemd/commit/58a78ae77063eddfcd23ea272bd2e0ddc9ea3ff7.patch";
84
-
sha256 = "0g3pvqigs69mciw6lj3zg12dmxnhwxndwxdjg78af52xrp0djfg8";
97
+
# FIXME: Why aren't includedir and libdir picked up from mesonFlags while other options are?
98
+
substituteInPlace meson.build \
99
+
--replace "includedir = join_paths(prefixdir, get_option('includedir'))" \
100
+
"includedir = '$dev/include'" \
101
+
--replace "libdir = join_paths(prefixdir, get_option('libdir'))" \
102
+
"libdir = '$lib/lib'"
104
+
export LC_ALL="en_US.UTF-8";
105
+
# FIXME: patch this in systemd properly (and send upstream).
106
+
# already fixed in f00929ad622c978f8ad83590a15a765b4beecac9: (u)mount
107
+
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
109
+
substituteInPlace $i \
110
+
--replace /usr/bin/getent ${stdenv.glibc.bin}/bin/getent \
111
+
--replace /sbin/swapon ${utillinux.bin}/sbin/swapon \
112
+
--replace /sbin/swapoff ${utillinux.bin}/sbin/swapoff \
113
+
--replace /sbin/fsck ${utillinux.bin}/sbin/fsck \
114
+
--replace /bin/echo ${coreutils}/bin/echo \
115
+
--replace /bin/cat ${coreutils}/bin/cat \
116
+
--replace /sbin/sulogin ${utillinux.bin}/sbin/sulogin \
117
+
--replace /usr/lib/systemd/systemd-fsck $out/lib/systemd/systemd-fsck \
118
+
--replace /bin/plymouth /run/current-system/sw/bin/plymouth # To avoid dependency
121
+
for i in tools/xml_helper.py tools/make-directive-index.py tools/make-man-index.py test/sys-script.py; do
122
+
substituteInPlace $i \
123
+
--replace "#!/usr/bin/env python" "#!${pythonLxmlEnv}/bin/python"
94
-
# FIXME: patch this in systemd properly (and send upstream).
95
-
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
97
-
substituteInPlace $i \
98
-
--replace /usr/bin/getent ${stdenv.glibc.bin}/bin/getent \
99
-
--replace /bin/mount ${utillinux.bin}/bin/mount \
100
-
--replace /bin/umount ${utillinux.bin}/bin/umount \
101
-
--replace /sbin/swapon ${utillinux.bin}/sbin/swapon \
102
-
--replace /sbin/swapoff ${utillinux.bin}/sbin/swapoff \
103
-
--replace /sbin/fsck ${utillinux.bin}/sbin/fsck \
104
-
--replace /bin/echo ${coreutils}/bin/echo \
105
-
--replace /bin/cat ${coreutils}/bin/cat \
106
-
--replace /sbin/sulogin ${utillinux.bin}/sbin/sulogin \
107
-
--replace /usr/lib/systemd/systemd-fsck $out/lib/systemd/systemd-fsck \
108
-
--replace /bin/plymouth /run/current-system/sw/bin/plymouth # To avoid dependency
126
+
for i in src/basic/generate-gperfs.py src/resolve/generate-dns_type-gperf.py src/test/generate-sym-test.py ; do
127
+
substituteInPlace $i \
128
+
--replace "#!/usr/bin/env python" "#!${python3Packages.python}/bin/python"
111
-
substituteInPlace src/journal/catalog.c \
112
-
--replace /usr/lib/systemd/catalog/ $out/lib/systemd/catalog/
131
+
substituteInPlace src/journal/catalog.c \
132
+
--replace /usr/lib/systemd/catalog/ $out/lib/systemd/catalog/
114
-
configureFlagsArray+=("--with-ntp-servers=0.nixos.pool.ntp.org 1.nixos.pool.ntp.org 2.nixos.pool.ntp.org 3.nixos.pool.ntp.org")
135
+
# These defines are overridden by CFLAGS and would trigger annoying
138
+
substituteInPlace config.h \
139
+
--replace "POLKIT_AGENT_BINARY_PATH" "_POLKIT_AGENT_BINARY_PATH" \
140
+
--replace "SYSTEMD_BINARY_PATH" "_SYSTEMD_BINARY_PATH" \
141
+
--replace "SYSTEMD_CGROUP_AGENT_PATH" "_SYSTEMD_CGROUP_AGENT_PATH"
117
-
PYTHON_BINARY = "${coreutils}/bin/env python"; # don't want a build time dependency on Python
144
+
hardeningDisable = [ "stackprotector" ];
119
-
NIX_CFLAGS_COMPILE =
120
-
[ # Can't say ${polkit.bin}/bin/pkttyagent here because that would
121
-
# lead to a cyclic dependency.
122
-
"-UPOLKIT_AGENT_BINARY_PATH" "-DPOLKIT_AGENT_BINARY_PATH=\"/run/current-system/sw/bin/pkttyagent\""
123
-
"-fno-stack-protector"
146
+
NIX_CFLAGS_COMPILE =
147
+
[ # Can't say ${polkit.bin}/bin/pkttyagent here because that would
148
+
# lead to a cyclic dependency.
149
+
"-UPOLKIT_AGENT_BINARY_PATH" "-DPOLKIT_AGENT_BINARY_PATH=\"/run/current-system/sw/bin/pkttyagent\""
125
-
# Set the release_agent on /sys/fs/cgroup/systemd to the
126
-
# currently running systemd (/run/current-system/systemd) so
127
-
# that we don't use an obsolete/garbage-collected release agent.
128
-
"-USYSTEMD_CGROUP_AGENT_PATH" "-DSYSTEMD_CGROUP_AGENT_PATH=\"/run/current-system/systemd/lib/systemd/systemd-cgroups-agent\""
151
+
# Set the release_agent on /sys/fs/cgroup/systemd to the
152
+
# currently running systemd (/run/current-system/systemd) so
153
+
# that we don't use an obsolete/garbage-collected release agent.
154
+
"-USYSTEMD_CGROUP_AGENT_PATH" "-DSYSTEMD_CGROUP_AGENT_PATH=\"/run/current-system/systemd/lib/systemd/systemd-cgroups-agent\""
130
-
"-USYSTEMD_BINARY_PATH" "-DSYSTEMD_BINARY_PATH=\"/run/current-system/systemd/lib/systemd/systemd\""
156
+
"-USYSTEMD_BINARY_PATH" "-DSYSTEMD_BINARY_PATH=\"/run/current-system/systemd/lib/systemd/systemd\""
134
-
[ "localstatedir=$(TMPDIR)/var"
135
-
"sysconfdir=$(out)/etc"
136
-
"sysvinitdir=$(TMPDIR)/etc/init.d"
137
-
"pamconfdir=$(out)/etc/pam.d"
161
+
# sysinit.target: Don't depend on
162
+
# systemd-tmpfiles-setup.service. This interferes with NixOps's
163
+
# send-keys feature (since sshd.service depends indirectly on
165
+
mv $out/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup-dev.service $out/lib/systemd/system/multi-user.target.wants/
142
-
# sysinit.target: Don't depend on
143
-
# systemd-tmpfiles-setup.service. This interferes with NixOps's
144
-
# send-keys feature (since sshd.service depends indirectly on
146
-
mv $out/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup-dev.service $out/lib/systemd/system/multi-user.target.wants/
167
+
mkdir -p $out/example/systemd
168
+
mv $out/lib/{modules-load.d,binfmt.d,sysctl.d,tmpfiles.d} $out/example
169
+
mv $out/lib/systemd/{system,user} $out/example/systemd
148
-
mkdir -p $out/example/systemd
149
-
mv $out/lib/{modules-load.d,binfmt.d,sysctl.d,tmpfiles.d} $out/example
150
-
mv $out/lib/systemd/{system,user} $out/example/systemd
171
+
rm -rf $out/etc/systemd/system
152
-
rm -rf $out/etc/systemd/system
154
-
# Install SysV compatibility commands.
156
-
ln -s $out/lib/systemd/systemd $out/sbin/telinit
157
-
for i in init halt poweroff runlevel reboot shutdown; do
158
-
ln -s $out/bin/systemctl $out/sbin/$i
173
+
# Install SysV compatibility commands.
175
+
ln -s $out/lib/systemd/systemd $out/sbin/telinit
176
+
for i in init halt poweroff runlevel reboot shutdown; do
177
+
ln -s $out/bin/systemctl $out/sbin/$i
161
-
# Fix reference to /bin/false in the D-Bus services.
162
-
for i in $out/share/dbus-1/system-services/*.service; do
163
-
substituteInPlace $i --replace /bin/false ${coreutils}/bin/false
180
+
# Fix reference to /bin/false in the D-Bus services.
181
+
for i in $out/share/dbus-1/system-services/*.service; do
182
+
substituteInPlace $i --replace /bin/false ${coreutils}/bin/false
166
-
rm -rf $out/etc/rpm
185
+
rm -rf $out/etc/rpm
187
+
# "kernel-install" shouldn't be used on NixOS.
188
+
find $out -name "*kernel-install*" -exec rm {} \;
170
-
# "kernel-install" shouldn't be used on NixOS.
171
-
find $out -name "*kernel-install*" -exec rm {} \;
190
+
# Keep only libudev and libsystemd in the lib output.
192
+
mv $lib/lib/security $lib/lib/libnss* $out/lib/
173
-
# Keep only libudev and libsystemd in the lib output.
175
-
mv $lib/lib/security $lib/lib/libnss* $out/lib/
195
+
enableParallelBuilding = true;
178
-
enableParallelBuilding = true;
197
+
# The rpath to the shared systemd library is not added by meson. The
198
+
# functionality was removed by a nixpkgs patch because it would overwrite
199
+
# the existing rpath.
201
+
sharedLib=libsystemd-shared-${version}.so
202
+
for prog in `find $out -type f -executable`; do
203
+
(patchelf --print-needed $prog | grep $sharedLib > /dev/null) && (
204
+
patchelf --set-rpath `patchelf --print-rpath $prog`:"$out/lib/systemd" $prog
180
-
# The interface version prevents NixOS from switching to an
181
-
# incompatible systemd at runtime. (Switching across reboots is
182
-
# fine, of course.) It should be increased whenever systemd changes
183
-
# in a backwards-incompatible way. If the interface version of two
184
-
# systemd builds is the same, then we can switch between them at
185
-
# runtime; otherwise we can't and we need to reboot.
186
-
passthru.interfaceVersion = 2;
209
+
# The interface version prevents NixOS from switching to an
210
+
# incompatible systemd at runtime. (Switching across reboots is
211
+
# fine, of course.) It should be increased whenever systemd changes
212
+
# in a backwards-incompatible way. If the interface version of two
213
+
# systemd builds is the same, then we can switch between them at
214
+
# runtime; otherwise we can't and we need to reboot.
215
+
passthru.interfaceVersion = 2;
189
-
homepage = http://www.freedesktop.org/wiki/Software/systemd;
190
-
description = "A system and service manager for Linux";
191
-
platforms = stdenv.lib.platforms.linux;
192
-
maintainers = [ stdenv.lib.maintainers.eelco ];
218
+
homepage = http://www.freedesktop.org/wiki/Software/systemd;
219
+
description = "A system and service manager for Linux";
220
+
platforms = stdenv.lib.platforms.linux;
221
+
maintainers = [ stdenv.lib.maintainers.eelco ];