@ -16,211 +16,207 @@ assert stdenv.isLinux;
let
pythonLxmlEnv = python3Packages . python . withPackages ( ps : with ps ; [ python3Packages . lxml ] ) ;
in
stdenv . mkDerivation rec {
version = " 2 3 7 " ;
name = " s y s t e m d - ${ version } " ;
src = fetchFromGitHub {
owner = " N i x O S " ;
repo = " s y s t e m d " ;
rev = " 1 e 8 8 3 0 d f a 7 7 a 7 d c 6 9 7 6 5 0 9 f 4 a 6 e d b 7 e 0 1 2 c 5 0 7 9 2 " ;
sha256 = " 1 c w 1 k 0 i 6 8 a z m z p q z i 3 r 8 j m 6 m b i 2 w q l q l 7 8 f h c g 0 v v n v 1 l y 8 b f 7 v q " ;
} ;
outputs = [ " o u t " " l i b " " m a n " " d e v " ] ;
nativeBuildInputs =
[ pkgconfig intltool gperf libxslt gettext docbook_xsl docbook_xml_dtd_42 docbook_xml_dtd_45
ninja meson
coreutils # meson calls date, stat etc.
pythonLxmlEnv glibcLocales
patchelf getent
] ;
buildInputs =
[ linuxHeaders libcap kmod xz pam acl
/* c r y p t s e t u p */ libuuid m4 glib libgcrypt libgpgerror libidn2
libmicrohttpd kexectools libseccomp libffi audit lz4 bzip2 libapparmor
iptables gnu-efi
] ;
#dontAddPrefix = true;
mesonFlags = [
" - D l o a d k e y s - p a t h = ${ kbd } / b i n / l o a d k e y s "
" - D s e t f o n t - p a t h = ${ kbd } / b i n / s e t f o n t "
" - D t t y - g i d = 3 " # tty in NixOS has gid 3
# "-Dtests=" # TODO
" - D l z 4 = t r u e "
" - D h o s t n a m e d = t r u e "
" - D n e t w o r k d = t r u e "
" - D s y s u s e r s = f a l s e "
" - D t i m e d a t e d = t r u e "
" - D t i m e s y n c d = t r u e "
" - D f i r s t b o o t = f a l s e "
" - D l o c a l e d = t r u e "
" - D r e s o l v e = t r u e "
" - D s p l i t - u s r = f a l s e "
" - D l i b c u r l = f a l s e "
" - D l i b i d n = f a l s e "
" - D l i b i d n 2 = t r u e "
" - D q u o t a c h e c k = f a l s e "
" - D l d c o n f i g = f a l s e "
" - D s m a c k = t r u e "
" - D s y s t e m - u i d - m a x = 4 9 9 " #TODO: debug why awking around in /etc/login.defs doesn't work
" - D s y s t e m - g i d - m a x = 4 9 9 "
# "-Dtime-epoch=1"
( if stdenv . isArm || ! hostPlatform . isEfi then " - D g n u - e f i = f a l s e " else " - D g n u - e f i = t r u e " )
" - D e f i - l i b d i r = ${ toString gnu-efi } / l i b "
" - D e f i - i n c l u d e d i r = ${ toString gnu-efi } / i n c l u d e / e f i "
" - D e f i - l d s d i r = ${ toString gnu-efi } / l i b "
" - D s y s v i n i t - p a t h = "
" - D s y s v r c n d - p a t h = "
] ;
preConfigure =
''
mesonFlagsArray + = ( - Dntp-servers = " 0 . n i x o s . p o o l . n t p . o r g 1 . n i x o s . p o o l . n t p . o r g 2 . n i x o s . p o o l . n t p . o r g 3 . n i x o s . p o o l . n t p . o r g " )
mesonFlagsArray + = ( - Ddbuspolicydir = $ out/etc/dbus-1/system.d )
mesonFlagsArray + = ( - Ddbussessionservicedir = $ out/share/dbus-1/services )
mesonFlagsArray + = ( - Ddbussystemservicedir = $ out/share/dbus-1/system-services )
mesonFlagsArray + = ( - Dpamconfdir = $ out/etc/pam.d )
mesonFlagsArray + = ( - Dsysconfdir = $ out/etc )
mesonFlagsArray + = ( - Drootprefix = $ out )
mesonFlagsArray + = ( - Dlibdir = $ lib/lib )
mesonFlagsArray + = ( - Drootlibdir = $ lib/lib )
mesonFlagsArray + = ( - Dmandir = $ man/lib )
mesonFlagsArray + = ( - Dincludedir = $ dev/include )
mesonFlagsArray + = ( - Dpkgconfiglibdir = $ dev/lib/pkgconfig )
mesonFlagsArray + = ( - Dpkgconfigdatadir = $ dev/share/pkgconfig )
# FIXME: Why aren't includedir and libdir picked up from mesonFlags while other options are?
substituteInPlace meson . build \
- - replace " i n c l u d e d i r = j o i n _ p a t h s ( p r e f i x d i r , g e t _ o p t i o n ( ' i n c l u d e d i r ' ) ) " \
" i n c l u d e d i r = ' $ d e v / i n c l u d e ' " \
- - replace " l i b d i r = j o i n _ p a t h s ( p r e f i x d i r , g e t _ o p t i o n ( ' l i b d i r ' ) ) " \
" l i b d i r = ' $ l i b / l i b ' "
export LC_ALL = " e n _ U S . U T F - 8 " ;
# FIXME: patch this in systemd properly (and send upstream).
# already fixed in f00929ad622c978f8ad83590a15a765b4beecac9: (u)mount
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
test - e $ i
substituteInPlace $ i \
- - replace /usr/bin/getent $ { getent } /bin/getent \
- - replace /sbin/swapon $ { utillinux . bin } /sbin/swapon \
- - replace /sbin/swapoff $ { utillinux . bin } /sbin/swapoff \
- - replace /sbin/fsck $ { utillinux . bin } /sbin/fsck \
- - replace /bin/echo $ { coreutils } /bin/echo \
- - replace /bin/cat $ { coreutils } /bin/cat \
- - replace /sbin/sulogin $ { utillinux . bin } /sbin/sulogin \
- - replace /usr/lib/systemd/systemd-fsck $ out/lib/systemd/systemd-fsck \
- - replace /bin/plymouth /run/current-system/sw/bin/plymouth # To avoid dependency
done
for i in tools/xml_helper.py tools/make-directive-index.py tools/make-man-index.py test/sys-script.py ; do
substituteInPlace $ i \
- - replace " # ! / u s r / b i n / e n v p y t h o n " " # ! ${ pythonLxmlEnv } / b i n / p y t h o n "
done
for i in src/basic/generate-gperfs.py src/resolve/generate-dns_type-gperf.py src/test/generate-sym-test.py ; do
substituteInPlace $ i \
- - replace " # ! / u s r / b i n / e n v p y t h o n " " # ! ${ python3Packages . python } / b i n / p y t h o n "
done
substituteInPlace src/journal/catalog.c \
- - replace /usr/lib/systemd/catalog / $ out/lib/systemd/catalog /
'' ;
# These defines are overridden by CFLAGS and would trigger annoying
# warning messages
postConfigure = ''
substituteInPlace config . h \
- - replace " P O L K I T _ A G E N T _ B I N A R Y _ P A T H " " _ P O L K I T _ A G E N T _ B I N A R Y _ P A T H " \
- - replace " S Y S T E M D _ B I N A R Y _ P A T H " " _ S Y S T E M D _ B I N A R Y _ P A T H " \
- - replace " S Y S T E M D _ C G R O U P _ A G E N T _ P A T H " " _ S Y S T E M D _ C G R O U P _ A G E N T _ P A T H "
'' ;
hardeningDisable = [ " s t a c k p r o t e c t o r " ] ;
NIX_CFLAGS_COMPILE =
[ # Can't say ${polkit.bin}/bin/pkttyagent here because that would
# lead to a cyclic dependency.
" - U P O L K I T _ A G E N T _ B I N A R Y _ P A T H " " - D P O L K I T _ A G E N T _ B I N A R Y _ P A T H = \" / r u n / c u r r e n t - s y s t e m / s w / b i n / p k t t y a g e n t \" "
# Set the release_agent on /sys/fs/cgroup/systemd to the
# currently running systemd (/run/current-system/systemd) so
# that we don't use an obsolete/garbage-collected release agent.
" - U S Y S T E M D _ C G R O U P _ A G E N T _ P A T H " " - D S Y S T E M D _ C G R O U P _ A G E N T _ P A T H = \" / r u n / c u r r e n t - s y s t e m / s y s t e m d / l i b / s y s t e m d / s y s t e m d - c g r o u p s - a g e n t \" "
" - U S Y S T E M D _ B I N A R Y _ P A T H " " - D S Y S T E M D _ B I N A R Y _ P A T H = \" / r u n / c u r r e n t - s y s t e m / s y s t e m d / l i b / s y s t e m d / s y s t e m d \" "
] ;
postInstall =
''
# sysinit.target: Don't depend on
# systemd-tmpfiles-setup.service. This interferes with NixOps's
# send-keys feature (since sshd.service depends indirectly on
# sysinit.target).
mv $ out/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup-dev.service $ out/lib/systemd/system/multi-user.target.wants /
mkdir - p $ out/example/systemd
mv $ out/lib / { modules-load . d , binfmt . d , sysctl . d , tmpfiles . d } $ out/example
mv $ out/lib/systemd / { system , user } $ out/example/systemd
rm - rf $ out/etc/systemd/system
# Install SysV compatibility commands.
mkdir - p $ out/sbin
ln - s $ out/lib/systemd/systemd $ out/sbin/telinit
for i in init halt poweroff runlevel reboot shutdown ; do
ln - s $ out/bin/systemctl $ out/sbin / $ i
done
# Fix reference to /bin/false in the D-Bus services.
for i in $ out/share/dbus-1/system-services /* . s e r v i c e ; d o
substituteInPlace $ i - - replace /bin/false $ { coreutils } /bin/false
done
rm - rf $ out/etc/rpm
# "kernel-install" shouldn't be used on NixOS.
find $ out - name " * k e r n e l - i n s t a l l * " - exec rm { } \ ;
# Keep only libudev and libsystemd in the lib output.
mkdir - p $ out/lib
mv $ lib/lib/security $ lib/lib/libnss * $ out/lib /
'' ; # * /
enableParallelBuilding = true ;
# The rpath to the shared systemd library is not added by meson. The
# functionality was removed by a nixpkgs patch because it would overwrite
# the existing rpath.
postFixup = ''
sharedLib = libsystemd-shared- $ { version } . so
for prog in ` find $ out - type f - executable ` ; do
( patchelf - - print-needed $ prog | grep $ sharedLib > /dev/null ) && (
patchelf - - set-rpath ` patchelf - - print-rpath $ prog ` : " $ o u t / l i b / s y s t e m d " $ prog
) || true
done
'' ;
# The interface version prevents NixOS from switching to an
# incompatible systemd at runtime. (Switching across reboots is
# fine, of course.) It should be increased whenever systemd changes
# in a backwards-incompatible way. If the interface version of two
# systemd builds is the same, then we can switch between them at
# runtime; otherwise we can't and we need to reboot.
passthru . interfaceVersion = 2 ;
meta = {
homepage = http://www.freedesktop.org/wiki/Software/systemd ;
description = " A s y s t e m a n d s e r v i c e m a n a g e r f o r L i n u x " ;
platforms = stdenv . lib . platforms . linux ;
maintainers = [ stdenv . lib . maintainers . eelco ] ;
} ;
in stdenv . mkDerivation rec {
version = " 2 3 7 " ;
name = " s y s t e m d - ${ version } " ;
src = fetchFromGitHub {
owner = " N i x O S " ;
repo = " s y s t e m d " ;
rev = " 1 e 8 8 3 0 d f a 7 7 a 7 d c 6 9 7 6 5 0 9 f 4 a 6 e d b 7 e 0 1 2 c 5 0 7 9 2 " ;
sha256 = " 1 c w 1 k 0 i 6 8 a z m z p q z i 3 r 8 j m 6 m b i 2 w q l q l 7 8 f h c g 0 v v n v 1 l y 8 b f 7 v q " ;
} ;
outputs = [ " o u t " " l i b " " m a n " " d e v " ] ;
nativeBuildInputs =
[ pkgconfig intltool gperf libxslt gettext docbook_xsl docbook_xml_dtd_42 docbook_xml_dtd_45
ninja meson
coreutils # meson calls date, stat etc.
pythonLxmlEnv glibcLocales
patchelf getent
] ;
buildInputs =
[ linuxHeaders libcap kmod xz pam acl
/* c r y p t s e t u p */ libuuid m4 glib libgcrypt libgpgerror libidn2
libmicrohttpd kexectools libseccomp libffi audit lz4 bzip2 libapparmor
iptables gnu-efi
] ;
#dontAddPrefix = true;
mesonFlags = [
" - D l o a d k e y s - p a t h = ${ kbd } / b i n / l o a d k e y s "
" - D s e t f o n t - p a t h = ${ kbd } / b i n / s e t f o n t "
" - D t t y - g i d = 3 " # tty in NixOS has gid 3
# "-Dtests=" # TODO
" - D l z 4 = t r u e "
" - D h o s t n a m e d = t r u e "
" - D n e t w o r k d = t r u e "
" - D s y s u s e r s = f a l s e "
" - D t i m e d a t e d = t r u e "
" - D t i m e s y n c d = t r u e "
" - D f i r s t b o o t = f a l s e "
" - D l o c a l e d = t r u e "
" - D r e s o l v e = t r u e "
" - D s p l i t - u s r = f a l s e "
" - D l i b c u r l = f a l s e "
" - D l i b i d n = f a l s e "
" - D l i b i d n 2 = t r u e "
" - D q u o t a c h e c k = f a l s e "
" - D l d c o n f i g = f a l s e "
" - D s m a c k = t r u e "
" - D s y s t e m - u i d - m a x = 4 9 9 " #TODO: debug why awking around in /etc/login.defs doesn't work
" - D s y s t e m - g i d - m a x = 4 9 9 "
# "-Dtime-epoch=1"
( if stdenv . isArm || ! hostPlatform . isEfi then " - D g n u - e f i = f a l s e " else " - D g n u - e f i = t r u e " )
" - D e f i - l i b d i r = ${ toString gnu-efi } / l i b "
" - D e f i - i n c l u d e d i r = ${ toString gnu-efi } / i n c l u d e / e f i "
" - D e f i - l d s d i r = ${ toString gnu-efi } / l i b "
" - D s y s v i n i t - p a t h = "
" - D s y s v r c n d - p a t h = "
] ;
preConfigure = ''
mesonFlagsArray + = ( - Dntp-servers = " 0 . n i x o s . p o o l . n t p . o r g 1 . n i x o s . p o o l . n t p . o r g 2 . n i x o s . p o o l . n t p . o r g 3 . n i x o s . p o o l . n t p . o r g " )
mesonFlagsArray + = ( - Ddbuspolicydir = $ out/etc/dbus-1/system.d )
mesonFlagsArray + = ( - Ddbussessionservicedir = $ out/share/dbus-1/services )
mesonFlagsArray + = ( - Ddbussystemservicedir = $ out/share/dbus-1/system-services )
mesonFlagsArray + = ( - Dpamconfdir = $ out/etc/pam.d )
mesonFlagsArray + = ( - Dsysconfdir = $ out/etc )
mesonFlagsArray + = ( - Drootprefix = $ out )
mesonFlagsArray + = ( - Dlibdir = $ lib/lib )
mesonFlagsArray + = ( - Drootlibdir = $ lib/lib )
mesonFlagsArray + = ( - Dmandir = $ man/lib )
mesonFlagsArray + = ( - Dincludedir = $ dev/include )
mesonFlagsArray + = ( - Dpkgconfiglibdir = $ dev/lib/pkgconfig )
mesonFlagsArray + = ( - Dpkgconfigdatadir = $ dev/share/pkgconfig )
# FIXME: Why aren't includedir and libdir picked up from mesonFlags while other options are?
substituteInPlace meson . build \
- - replace " i n c l u d e d i r = j o i n _ p a t h s ( p r e f i x d i r , g e t _ o p t i o n ( ' i n c l u d e d i r ' ) ) " \
" i n c l u d e d i r = ' $ d e v / i n c l u d e ' " \
- - replace " l i b d i r = j o i n _ p a t h s ( p r e f i x d i r , g e t _ o p t i o n ( ' l i b d i r ' ) ) " \
" l i b d i r = ' $ l i b / l i b ' "
export LC_ALL = " e n _ U S . U T F - 8 " ;
# FIXME: patch this in systemd properly (and send upstream).
# already fixed in f00929ad622c978f8ad83590a15a765b4beecac9: (u)mount
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
test - e $ i
substituteInPlace $ i \
- - replace /usr/bin/getent $ { getent } /bin/getent \
- - replace /sbin/swapon $ { utillinux . bin } /sbin/swapon \
- - replace /sbin/swapoff $ { utillinux . bin } /sbin/swapoff \
- - replace /sbin/fsck $ { utillinux . bin } /sbin/fsck \
- - replace /bin/echo $ { coreutils } /bin/echo \
- - replace /bin/cat $ { coreutils } /bin/cat \
- - replace /sbin/sulogin $ { utillinux . bin } /sbin/sulogin \
- - replace /usr/lib/systemd/systemd-fsck $ out/lib/systemd/systemd-fsck \
- - replace /bin/plymouth /run/current-system/sw/bin/plymouth # To avoid dependency
done
for i in tools/xml_helper.py tools/make-directive-index.py tools/make-man-index.py test/sys-script.py ; do
substituteInPlace $ i \
- - replace " # ! / u s r / b i n / e n v p y t h o n " " # ! ${ pythonLxmlEnv } / b i n / p y t h o n "
done
for i in src/basic/generate-gperfs.py src/resolve/generate-dns_type-gperf.py src/test/generate-sym-test.py ; do
substituteInPlace $ i \
- - replace " # ! / u s r / b i n / e n v p y t h o n " " # ! ${ python3Packages . python } / b i n / p y t h o n "
done
substituteInPlace src/journal/catalog.c \
- - replace /usr/lib/systemd/catalog / $ out/lib/systemd/catalog /
'' ;
# These defines are overridden by CFLAGS and would trigger annoying
# warning messages
postConfigure = ''
substituteInPlace config . h \
- - replace " P O L K I T _ A G E N T _ B I N A R Y _ P A T H " " _ P O L K I T _ A G E N T _ B I N A R Y _ P A T H " \
- - replace " S Y S T E M D _ B I N A R Y _ P A T H " " _ S Y S T E M D _ B I N A R Y _ P A T H " \
- - replace " S Y S T E M D _ C G R O U P _ A G E N T _ P A T H " " _ S Y S T E M D _ C G R O U P _ A G E N T _ P A T H "
'' ;
hardeningDisable = [ " s t a c k p r o t e c t o r " ] ;
NIX_CFLAGS_COMPILE =
[ # Can't say ${polkit.bin}/bin/pkttyagent here because that would
# lead to a cyclic dependency.
" - U P O L K I T _ A G E N T _ B I N A R Y _ P A T H " " - D P O L K I T _ A G E N T _ B I N A R Y _ P A T H = \" / r u n / c u r r e n t - s y s t e m / s w / b i n / p k t t y a g e n t \" "
# Set the release_agent on /sys/fs/cgroup/systemd to the
# currently running systemd (/run/current-system/systemd) so
# that we don't use an obsolete/garbage-collected release agent.
" - U S Y S T E M D _ C G R O U P _ A G E N T _ P A T H " " - D S Y S T E M D _ C G R O U P _ A G E N T _ P A T H = \" / r u n / c u r r e n t - s y s t e m / s y s t e m d / l i b / s y s t e m d / s y s t e m d - c g r o u p s - a g e n t \" "
" - U S Y S T E M D _ B I N A R Y _ P A T H " " - D S Y S T E M D _ B I N A R Y _ P A T H = \" / r u n / c u r r e n t - s y s t e m / s y s t e m d / l i b / s y s t e m d / s y s t e m d \" "
] ;
postInstall = ''
# sysinit.target: Don't depend on
# systemd-tmpfiles-setup.service. This interferes with NixOps's
# send-keys feature (since sshd.service depends indirectly on
# sysinit.target).
mv $ out/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup-dev.service $ out/lib/systemd/system/multi-user.target.wants /
mkdir - p $ out/example/systemd
mv $ out/lib / { modules-load . d , binfmt . d , sysctl . d , tmpfiles . d } $ out/example
mv $ out/lib/systemd / { system , user } $ out/example/systemd
rm - rf $ out/etc/systemd/system
# Install SysV compatibility commands.
mkdir - p $ out/sbin
ln - s $ out/lib/systemd/systemd $ out/sbin/telinit
for i in init halt poweroff runlevel reboot shutdown ; do
ln - s $ out/bin/systemctl $ out/sbin / $ i
done
# Fix reference to /bin/false in the D-Bus services.
for i in $ out/share/dbus-1/system-services /* . s e r v i c e ; d o
substituteInPlace $ i - - replace /bin/false $ { coreutils } /bin/false
done
rm - rf $ out/etc/rpm
# "kernel-install" shouldn't be used on NixOS.
find $ out - name " * k e r n e l - i n s t a l l * " - exec rm { } \ ;
# Keep only libudev and libsystemd in the lib output.
mkdir - p $ out/lib
mv $ lib/lib/security $ lib/lib/libnss * $ out/lib /
'' ; # * /
enableParallelBuilding = true ;
# The rpath to the shared systemd library is not added by meson. The
# functionality was removed by a nixpkgs patch because it would overwrite
# the existing rpath.
postFixup = ''
sharedLib = libsystemd-shared- $ { version } . so
for prog in ` find $ out - type f - executable ` ; do
( patchelf - - print-needed $ prog | grep $ sharedLib > /dev/null ) && (
patchelf - - set-rpath ` patchelf - - print-rpath $ prog ` : " $ o u t / l i b / s y s t e m d " $ prog
) || true
done
'' ;
# The interface version prevents NixOS from switching to an
# incompatible systemd at runtime. (Switching across reboots is
# fine, of course.) It should be increased whenever systemd changes
# in a backwards-incompatible way. If the interface version of two
# systemd builds is the same, then we can switch between them at
# runtime; otherwise we can't and we need to reboot.
passthru . interfaceVersion = 2 ;
meta = {
homepage = http://www.freedesktop.org/wiki/Software/systemd ;
description = " A s y s t e m a n d s e r v i c e m a n a g e r f o r L i n u x " ;
platforms = stdenv . lib . platforms . linux ;
maintainers = [ stdenv . lib . maintainers . eelco ] ;
} ;
}