@ -123,7 +123,14 @@ assert withHomed -> withCryptsetup;
assert withCryptsetup -> ( cryptsetup != null ) ;
let
wantCurl = withRemote || withImportd ;
version = " 2 4 9 . 7 " ;
wantGcrypt = withResolved || withImportd ;
version = " 2 5 0 . 3 " ;
# Bump this variable on every (major) version change. See below (in the meson options list) for why.
# command:
# $ curl -s https://api.github.com/repos/systemd/systemd/releases/latest | \
# jq '.created_at|strptime("%Y-%m-%dT%H:%M:%SZ")|mktime'
releaseTimestamp = " 1 6 4 0 2 9 0 1 8 0 " ;
in
stdenv . mkDerivation {
inherit pname version ;
@ -134,12 +141,12 @@ stdenv.mkDerivation {
owner = " s y s t e m d " ;
repo = " s y s t e m d - s t a b l e " ;
rev = " v ${ version } " ;
sha256 = " s h a 2 5 6 - y 3 3 / B v v I + J y h s v u T 1 C b m 6 J 2 Z 7 2 j 7 1 o X g L w 6 X 9 N w C M P E = " ;
sha256 = " s h a 2 5 6 - O 1 X E 0 B h I u D A l F V X 7 W I y 0 2 M 9 Y T I x L X 0 Q 8 a t J A Y s U g Q D Q = " ;
} ;
# If these need to be regenerated, `git am path/to/00*.patch` them into a
# systemd worktree, rebase to the more recent systemd version, and export the
# patches again via `git -c format.signoff=false format-patch v${version}`.
# On major changes, or when otherwise required, you *must* reformat the patches,
# `git am path/to/00*.patch` them into a systemd worktree, rebase to the more recent
# systemd version, and export the patches again via `git -c format.signoff=false format-patch v${version}`.
# Use `find . -name "*.patch" | sort` to get an up-to-date listing of all patches
patches = [
./0001-Start-device-units-for-uninitialised-encrypted-devic.patch
@ -168,14 +175,6 @@ stdenv.mkDerivation {
# need (AFAICT).
# See https://github.com/systemd/systemd/pull/20479 for upsteam discussion.
./0019-core-handle-lookup-paths-being-symlinks.patch
# In v248 compiler weirdness and refactoring lead to the bootloader
# erroring out handling keyboard input on some systems. See
# https://github.com/systemd/systemd/issues/19191
# This should be redundant in v249.6 when it offically gets tagged in
# systemd-stable
./0020-sd-boot-Unify-error-handling.patch
./0021-sd-boot-Rework-console-input-handling.patch
] ++ lib . optional stdenv . hostPlatform . isMusl (
let
oe-core = fetchzip {
@ -287,6 +286,10 @@ stdenv.mkDerivation {
{ name = " l i b t s s 2 - m u . s o . 0 " ; pkg = opt withTpm2Tss tpm2-tss ; }
{ name = " l i b t s s 2 - t c t i - " ; pkg = opt withTpm2Tss tpm2-tss ; }
{ name = " l i b f i d o 2 . s o . 1 " ; pkg = opt withFido2 libfido2 ; }
# inspect-elf support
{ name = " l i b e l f . s o . 1 " ; pkg = opt withCoredump elfutils ; }
{ name = " l i b d w . s o . 1 " ; pkg = opt withCoredump elfutils ; }
] ;
patchDlOpen = dl :
@ -446,7 +449,12 @@ stdenv.mkDerivation {
" - D s m a c k = t r u e "
" - D b _ p i e = t r u e "
" - D i n s t a l l - s y s c o n f d i r = f a l s e "
" - D e f i - l d = ${ stdenv . cc . bintools . targetPrefix } l d "
" - D e f i - l d = g o l d "
" - D s b a t - d i s t r o = n i x o s "
" - D s b a t - d i s t r o - s u m m a r y = N i x O S "
" - D s b a t - d i s t r o - u r l = h t t p s : / / n i x o s . o r g / "
" - D s b a t - d i s t r o - p k g n a m e = ${ pname } "
" - D s b a t - d i s t r o - v e r s i o n = ${ version } "
/*
As of now , systemd doesn't allow runtime configuration of these values . So
the settings in /etc/login.defs have no effect on it . Many people think this
@ -498,57 +506,112 @@ stdenv.mkDerivation {
" - D u t m p = f a l s e "
" - D i d n = f a l s e "
] ;
preConfigure =
let
# A list of all the runtime binaries that the systemd exectuables, tests and libraries are referencing in their source code, scripts and unit files.
# As soon as a dependency isn't required anymore we should remove it from the list. The `where` attribute for each of the replacement patterns must be exhaustive. If another (unhandled) case is found in the source code the build fails with an error message.
binaryReplacements = [
{ search = " / u s r / b i n / g e t e n t " ; replacement = " ${ getent } / b i n / g e t e n t " ; where = [ " s r c / n s p a w n / n s p a w n - s e t u i d . c " ] ; }
{
search = " / s b i n / m k s w a p " ;
replacement = " ${ lib . getBin util-linux } / s b i n / m k s w a p " ;
where = [
" m a n / s y s t e m d - m a k e f s @ . s e r v i c e . x m l "
] ;
}
{ search = " / s b i n / s w a p o n " ; replacement = " ${ lib . getBin util-linux } / s b i n / s w a p o n " ; where = [ " s r c / c o r e / s w a p . c " " s r c / b a s i c / u n i t - d e f . h " ] ; }
{ search = " / s b i n / s w a p o f f " ; replacement = " ${ lib . getBin util-linux } / s b i n / s w a p o f f " ; where = [ " s r c / c o r e / s w a p . c " ] ; }
{
search = " / b i n / e c h o " ;
replacement = " ${ coreutils } / b i n / e c h o " ;
where = [
" m a n / s y s t e m d - a n a l y z e . x m l "
" m a n / s y s t e m d . s e r v i c e . x m l "
" s r c / a n a l y z e / t e s t - v e r i f y . c "
" s r c / t e s t / t e s t - e n v - f i l e . c "
" s r c / t e s t / t e s t - f i l e i o . c "
" t e s t / t e s t - e x e c u t e / e x e c - s y s t e m c a l l f i l t e r - f a i l i n g 2 . s e r v i c e "
" t e s t / t e s t - e x e c u t e / e x e c - s y s t e m c a l l f i l t e r - f a i l i n g 3 . s e r v i c e "
" t e s t / t e s t - e x e c u t e / e x e c - s y s t e m c a l l f i l t e r - f a i l i n g . s e r v i c e "
" t e s t / t e s t s u i t e - 0 6 . u n i t s / h o l a . s e r v i c e "
" t e s t / u d e v - t e s t . p l "
" t e s t / u n i t s / h e l l o . s e r v i c e "
" t e s t / u n i t s / t e s t s u i t e - 0 7 . s h "
" t e s t / u n i t s / t e s t s u i t e - 1 5 . s h "
" t e s t / u n i t s / t e s t s u i t e - 1 7 . 0 5 . s h "
" t e s t / u n i t s / t e s t s u i t e - 4 0 . s h "
" t e s t / u n i t s / u n s t o p p a b l e . s e r v i c e "
] ;
}
{
search = " / b i n / c a t " ;
replacement = " ${ coreutils } / b i n / c a t " ;
where = [ " t e s t / c r e a t e - b u s y b o x - c o n t a i n e r " " t e s t / t e s t - e x e c u t e / e x e c - n o e x e c p a t h s - s i m p l e . s e r v i c e " " s r c / j o u r n a l / c a t . c " ] ;
}
{ search = " / s b i n / m o d p r o b e " ; replacement = " ${ lib . getBin kmod } / s b i n / m o d p r o b e " ; where = [ " u n i t s / m o d p r o b e @ . s e r v i c e " ] ; }
{
search = " / u s r / l i b / s y s t e m d / s y s t e m d - f s c k " ;
replacement = " $ o u t / l i b / s y s t e m d / s y s t e m d - f s c k " ;
where = [
" m a n / s y s t e m d - f s c k @ . s e r v i c e . x m l "
" t e s t / t e s t - f s t a b - g e n e r a t o r . s h "
" t e s t / t e s t - f s t a b - g e n e r a t o r / t e s t - 1 2 - d e v - s d x . e x p e c t e d / s y s t e m d - f s c k - r o o t . s e r v i c e "
" t e s t / t e s t - f s t a b - g e n e r a t o r / t e s t - 1 3 - l a b e l . e x p e c t e d / s y s t e m d - f s c k - r o o t . s e r v i c e "
" t e s t / t e s t - f s t a b - g e n e r a t o r / t e s t - 1 4 - u u i d . e x p e c t e d / s y s t e m d - f s c k - r o o t . s e r v i c e "
" t e s t / t e s t - f s t a b - g e n e r a t o r / t e s t - 1 5 - p a r t u u i d . e x p e c t e d / s y s t e m d - f s c k - r o o t . s e r v i c e "
] ;
}
] ++ lib . optionals withImportd [
{
search = " \" g p g \" " ;
replacement = " \\ \" ${ gnupg } / b i n / g p g \\ \" " ;
where = [ " s r c / i m p o r t / p u l l - c o m m o n . c " ] ;
}
{
search = " \" t a r \" " ;
replacement = " \\ \" ${ gnutar } / b i n / t a r \\ \" " ;
where = [
" s r c / i m p o r t / e x p o r t - t a r . c "
" s r c / i m p o r t / e x p o r t . c "
" s r c / i m p o r t / i m p o r t - c o m m o n . c "
" s r c / i m p o r t / i m p o r t - t a r . c "
" s r c / i m p o r t / i m p o r t . c "
" s r c / i m p o r t / i m p o r t d . c "
" s r c / i m p o r t / p u l l - t a r . c "
" s r c / i m p o r t / p u l l . c "
] ;
}
] ;
# { replacement, search, where } -> List[str]
mkSubstitute = { replacement , search , where }:
map ( path : " s u b s t i t u t e I n P l a c e ${ path } - - r e p l a c e ' ${ search } ' \" ${ replacement } \" " ) where ;
mkEnsureSubstituted = { replacement , search , where }:
''
if [ [ $ ( grep - r ' $ { search } ' | grep - v " ${ replacement } " | grep - v NEWS | wc - l ) - gt 0 ] ] ; then
echo " N o t a l l r e f e r e n c e s t o ' ${ search } ' h a v e b e e n r e p l a c e . F o u n d t h e f o l l o w i n g m a t c h e s : "
grep ' $ { search } ' - r | grep - v " ${ replacement } " | grep - v NEWS
exit 1
fi
'' ;
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 " )
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/core/mount.c \
src/core/swap.c \
src/cryptsetup/cryptsetup-generator.c \
src/journal/cat.c \
src/nspawn/nspawn.c \
src/remount-fs/remount-fs.c \
src/shared/generator.c \
src/shutdown/shutdown.c \
units/emergency.service.in \
units/modprobe @ . service \
units/rescue.service.in \
units/systemd-logind.service.in \
units/systemd-nspawn @ . service . in ; \
do
test - e $ i
substituteInPlace $ i \
- - replace /usr/bin/getent $ { getent } /bin/getent \
- - replace /sbin/mkswap $ { lib . getBin util-linux } /sbin/mkswap \
- - replace /sbin/swapon $ { lib . getBin util-linux } /sbin/swapon \
- - replace /sbin/swapoff $ { lib . getBin util-linux } /sbin/swapoff \
- - replace /bin/echo $ { coreutils } /bin/echo \
- - replace /bin/cat $ { coreutils } /bin/cat \
- - replace /sbin/sulogin $ { lib . getBin util-linux } /sbin/sulogin \
- - replace /sbin/modprobe $ { lib . getBin kmod } /sbin/modprobe \
- - replace /usr/lib/systemd/systemd-fsck $ out/lib/systemd/systemd-fsck \
- - replace /bin/plymouth /run/current-system/sw/bin/plymouth # To avoid dependency
done
in
''
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 " )
export LC_ALL = " e n _ U S . U T F - 8 " ;
for dir in tools src/resolve test src/test src/shared ; do
patchShebangs $ dir
done
$ { lib . concatStringsSep " \n " ( lib . flatten ( map mkSubstitute binaryReplacements ) ) }
$ { lib . concatMapStringsSep " \n " mkEnsureSubstituted binaryReplacements }
# absolute paths to gpg & tar
substituteInPlace src/import/pull-common.c \
- - replace ' " g p g " ' ' " ${ gnupg } / b i n / g p g " '
for file in src/import / { { export , import , pull } - tar , import-common } . c ; do
substituteInPlace $ file \
- - replace ' " t a r " ' ' " ${ gnutar } / b i n / t a r " '
done
for dir in tools src/resolve test src/test src/shared ; do
patchShebangs $ dir
done
substituteInPlace src/libsystemd/sd-journal/catalog.c \
- - replace /usr/lib/systemd/catalog / $ out/lib/systemd/catalog /
'' ;
substituteInPlace src/libsystemd/sd-journal/catalog.c \
- - replace /usr/lib/systemd/catalog / $ out/lib/systemd/catalog /
'' ;
# These defines are overridden by CFLAGS and would trigger annoying
# warning messages
@ -556,7 +619,7 @@ stdenv.mkDerivation {
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 "
- - replace " S Y S T E M D _ C G R O U P _ A G E N T S _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 "
'' ;
NIX_CFLAGS_COMPILE = toString ( [
@ -568,8 +631,8 @@ stdenv.mkDerivation {
# 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 _ C G R O U P _ A G E N T S _P A T H "
" - D S Y S T E M D _ C G R O U P _ A G E N T S _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 \" "