systemd: add musl patches

Fixes build of pkgsMusl.systemdMinimal (and pkgsMusl.systemd if combined with
other fixes).
These patches are applied conditionally on purpose: They are not checked to
be properly guarded. They should not block future systemd upgrades.
Also see the original RFC section around musl systemd:
https://github.com/NixOS/rfcs/blob/master/rfcs/0023-musl-libc.md#systemd

Yureka 6ac494fe a49e6b19

+64 -9
+52 -9
pkgs/os-specific/linux/systemd/default.nix
··· 4 , lib 5 , fetchFromGitHub 6 , fetchpatch 7 , buildPackages 8 , ninja 9 , meson ··· 75 , withHomed ? false 76 , withHostnamed ? true 77 , withHwdb ? true 78 - , withImportd ? true 79 , withLibBPF ? false # currently fails while generating BPF objects 80 , withLocaled ? true 81 , withLogind ? true 82 , withMachined ? true 83 , withNetworkd ? true 84 - , withNss ? true 85 , withOomd ? false 86 , withPCRE2 ? true 87 , withPolkit ? true 88 , withPortabled ? false 89 - , withRemote ? true 90 , withResolved ? true 91 , withShellCompletions ? true 92 , withTimedated ? true 93 , withTimesyncd ? true 94 - , withTpm2Tss ? true 95 - , withUserDb ? true 96 , libfido2 97 , p11-kit 98 ··· 163 # all our root unit dirs if they are symlinks. This does exactly what we 164 # need (AFAICT). 165 ./0019-core-handle-lookup-paths-being-symlinks.patch 166 - ]; 167 168 postPatch = '' 169 substituteInPlace src/basic/path-util.h --replace "@defaultPathNormal@" "${placeholder "out"}/bin/" ··· 443 "-Dnss-systemd=false" 444 ] ++ lib.optionals withLibBPF [ 445 "-Dbpf-framework=true" 446 - ] ++ lib.optional withTpm2Tss "-Dtpm2=true"; 447 448 preConfigure = '' 449 mesonFlagsArray+=(-Dntp-servers="0.nixos.pool.ntp.org 1.nixos.pool.ntp.org 2.nixos.pool.ntp.org 3.nixos.pool.ntp.org") ··· 505 --replace "SYSTEMD_CGROUP_AGENT_PATH" "_SYSTEMD_CGROUP_AGENT_PATH" 506 ''; 507 508 - NIX_CFLAGS_COMPILE = toString [ 509 # Can't say ${polkit.bin}/bin/pkttyagent here because that would 510 # lead to a cyclic dependency. 511 "-UPOLKIT_AGENT_BINARY_PATH" ··· 519 520 "-USYSTEMD_BINARY_PATH" 521 "-DSYSTEMD_BINARY_PATH=\"/run/current-system/systemd/lib/systemd/systemd\"" 522 - ]; 523 524 doCheck = false; # fails a bunch of tests 525
··· 4 , lib 5 , fetchFromGitHub 6 , fetchpatch 7 + , fetchzip 8 , buildPackages 9 , ninja 10 , meson ··· 76 , withHomed ? false 77 , withHostnamed ? true 78 , withHwdb ? true 79 + , withImportd ? !stdenv.hostPlatform.isMusl 80 , withLibBPF ? false # currently fails while generating BPF objects 81 , withLocaled ? true 82 , withLogind ? true 83 , withMachined ? true 84 , withNetworkd ? true 85 + , withNss ? !stdenv.hostPlatform.isMusl 86 , withOomd ? false 87 , withPCRE2 ? true 88 , withPolkit ? true 89 , withPortabled ? false 90 + , withRemote ? !stdenv.hostPlatform.isMusl 91 , withResolved ? true 92 , withShellCompletions ? true 93 , withTimedated ? true 94 , withTimesyncd ? true 95 + , withTpm2Tss ? !stdenv.hostPlatform.isMusl 96 + , withUserDb ? !stdenv.hostPlatform.isMusl 97 , libfido2 98 , p11-kit 99 ··· 164 # all our root unit dirs if they are symlinks. This does exactly what we 165 # need (AFAICT). 166 ./0019-core-handle-lookup-paths-being-symlinks.patch 167 + ] ++ lib.optional stdenv.hostPlatform.isMusl (let 168 + oe-core = fetchzip { 169 + url = "https://git.openembedded.org/openembedded-core/snapshot/openembedded-core-14c6e5a4b72d0e4665279158a0740dd1dc21f72f.tar.bz2"; 170 + sha256 = "1jixya4czkr5p5rdcw3d6ips8zzr82dvnanvzvgjh67730scflya"; 171 + }; 172 + musl-patches = oe-core + "/meta/recipes-core/systemd/systemd"; 173 + in [ 174 + (musl-patches + "/0002-don-t-use-glibc-specific-qsort_r.patch") 175 + (musl-patches + "/0003-missing_type.h-add-__compare_fn_t-and-comparison_fn_.patch") 176 + (musl-patches + "/0004-add-fallback-parse_printf_format-implementation.patch") 177 + (musl-patches + "/0005-src-basic-missing.h-check-for-missing-strndupa.patch") 178 + (musl-patches + "/0006-Include-netinet-if_ether.h.patch") 179 + (musl-patches + "/0007-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not-.patch") 180 + (musl-patches + "/0008-add-missing-FTW_-macros-for-musl.patch") 181 + (musl-patches + "/0009-fix-missing-of-__register_atfork-for-non-glibc-build.patch") 182 + (musl-patches + "/0010-Use-uintmax_t-for-handling-rlim_t.patch") 183 + (musl-patches + "/0011-test-sizeof.c-Disable-tests-for-missing-typedefs-in-.patch") 184 + (musl-patches + "/0012-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat.patch") 185 + (musl-patches + "/0013-Define-glibc-compatible-basename-for-non-glibc-syste.patch") 186 + (musl-patches + "/0014-Do-not-disable-buffering-when-writing-to-oom_score_a.patch") 187 + (musl-patches + "/0015-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch") 188 + (musl-patches + "/0016-Hide-__start_BUS_ERROR_MAP-and-__stop_BUS_ERROR_MAP.patch") 189 + (musl-patches + "/0017-missing_type.h-add-__compar_d_fn_t-definition.patch") 190 + (musl-patches + "/0018-avoid-redefinition-of-prctl_mm_map-structure.patch") 191 + (musl-patches + "/0019-Handle-missing-LOCK_EX.patch") 192 + (musl-patches + "/0021-test-json.c-define-M_PIl.patch") 193 + (musl-patches + "/0022-do-not-disable-buffer-in-writing-files.patch") 194 + (musl-patches + "/0025-Handle-__cpu_mask-usage.patch") 195 + (musl-patches + "/0026-Handle-missing-gshadow.patch") 196 + (musl-patches + "/0028-missing_syscall.h-Define-MIPS-ABI-defines-for-musl.patch") 197 + 198 + # Being discussed upstream: https://lists.openembedded.org/g/openembedded-core/topic/86411771#157056 199 + ./musl.diff 200 + ]); 201 202 postPatch = '' 203 substituteInPlace src/basic/path-util.h --replace "@defaultPathNormal@" "${placeholder "out"}/bin/" ··· 477 "-Dnss-systemd=false" 478 ] ++ lib.optionals withLibBPF [ 479 "-Dbpf-framework=true" 480 + ] ++ lib.optionals withTpm2Tss [ 481 + "-Dtpm2=true" 482 + ] ++ lib.optionals stdenv.hostPlatform.isMusl [ 483 + "-Dgshadow=false" 484 + "-Dutmp=false" 485 + "-Didn=false" 486 + ]; 487 488 preConfigure = '' 489 mesonFlagsArray+=(-Dntp-servers="0.nixos.pool.ntp.org 1.nixos.pool.ntp.org 2.nixos.pool.ntp.org 3.nixos.pool.ntp.org") ··· 545 --replace "SYSTEMD_CGROUP_AGENT_PATH" "_SYSTEMD_CGROUP_AGENT_PATH" 546 ''; 547 548 + NIX_CFLAGS_COMPILE = toString ([ 549 # Can't say ${polkit.bin}/bin/pkttyagent here because that would 550 # lead to a cyclic dependency. 551 "-UPOLKIT_AGENT_BINARY_PATH" ··· 559 560 "-USYSTEMD_BINARY_PATH" 561 "-DSYSTEMD_BINARY_PATH=\"/run/current-system/systemd/lib/systemd/systemd\"" 562 + 563 + ] ++ lib.optionals stdenv.hostPlatform.isMusl [ 564 + "-D__UAPI_DEF_ETHHDR=0" 565 + ]); 566 567 doCheck = false; # fails a bunch of tests 568
+12
pkgs/os-specific/linux/systemd/musl.diff
···
··· 1 + diff --git a/src/shared/mount-setup.c b/src/shared/mount-setup.c 2 + index ef3527e..cc1ba23 100644 3 + --- a/src/shared/mount-setup.c 4 + +++ b/src/shared/mount-setup.c 5 + @@ -32,6 +32,7 @@ 6 + #include "strv.h" 7 + #include "user-util.h" 8 + #include "virt.h" 9 + +#include "missing_type.h" 10 + 11 + typedef enum MountMode { 12 + MNT_NONE = 0,