From 17398e4ff31415b0cefb3273325ed08bddec5a68 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 1 Sep 2023 10:41:02 +0200 Subject: systemd: suggest using `--runtime` on `systemctl edit` `systemctl edit foobar.service` attempts to write into `/etc/systemd/system`. This is impossible on purpose, for such a configuration change the `configuration.nix(8)` should be modified. However, sometimes it's still a handy feature, for instance when debugging a broken service. For such a purpose, `systemctl edit --runtime` is still working on NixOS and an even better solution because it only overrides the unit temporarily by placing the override config into `/run` rather than `/etc`. Unfortunately, this flag isn't well-known in my experience. So inspired by PEP668[1], RaitoBezarius nerd-sniped me into implementing a similar warning: $ ./result/bin/systemctl edit libvirtd.service The unit-directory '/etc/systemd/system' is read-only on NixOS, so it's not possible to edit system-units directly. Use 'systemctl edit --runtime' instead. This only applies to system-level units. Overrides for user-units are written into `$XDG_CONFIG_HOME/systemd/user` which is not managed by NixOS (even when using home-manager it's possible to write into that directory). [1] https://peps.python.org/pep-0668/ --- pkgs/os-specific/linux/systemd/default.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'pkgs/os-specific/linux/systemd/default.nix') diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index d7f0245b3a1..82dd87446b8 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -201,6 +201,7 @@ stdenv.mkDerivation (finalAttrs: { ./0016-inherit-systemd-environment-when-calling-generators.patch ./0017-core-don-t-taint-on-unmerged-usr.patch ./0018-tpm2_context_init-fix-driver-name-checking.patch + ./0019-systemctl-edit-suggest-systemdctl-edit-runtime-on-sy.patch ] ++ lib.optional stdenv.hostPlatform.isMusl ( let oe-core = fetchzip { -- cgit 1.4.1 From 7646ffb8bde3fd14ce823aea38bfd2c26d6aec26 Mon Sep 17 00:00:00 2001 From: misuzu Date: Sun, 1 Oct 2023 14:01:25 +0300 Subject: systemd: fix RuntimeError issue when building for armv7l and riscv64 --- pkgs/os-specific/linux/systemd/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pkgs/os-specific/linux/systemd/default.nix') diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index a9110e37433..bc1e9bef60b 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -202,6 +202,14 @@ stdenv.mkDerivation (finalAttrs: { ./0017-core-don-t-taint-on-unmerged-usr.patch ./0018-tpm2_context_init-fix-driver-name-checking.patch ./0019-systemctl-edit-suggest-systemdctl-edit-runtime-on-sy.patch + + # Fix for `RuntimeError: ELF .dynamic section is missing.` + # https://github.com/systemd/systemd/issues/29381 + # https://github.com/systemd/systemd/pull/29392 + (fetchpatch { + url = "https://github.com/systemd/systemd/commit/cecbb162a3134b43d2ca160e13198c73ff34c3ef.patch"; + hash = "sha256-hWpUosTDA18mYm5nIb9KnjwOlnzbEHgzha/WpyHoC54="; + }) ] ++ lib.optional stdenv.hostPlatform.isMusl ( let oe-core = fetchzip { -- cgit 1.4.1 From 79f60450063eb3a2270cca8066c353fc3c0facf7 Mon Sep 17 00:00:00 2001 From: Julian Stecklina Date: Wed, 18 Oct 2023 11:44:18 +0200 Subject: systemd: allow building only the libraries systemdMinimal is used to break the dependency cycle of libraries required by systemd on itself. The problem is that this means that every system closure will have two sets of systemd binaries in the closure. This wastes around 10 MiB in every system closure. Add the option to systemd to only ship libudev and libsystemd instead of a whole systemd installation. --- pkgs/os-specific/linux/systemd/default.nix | 12 ++++++++---- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'pkgs/os-specific/linux/systemd/default.nix') diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index b13db4a3427..3d28eae7025 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -134,6 +134,8 @@ , withUtmp ? !stdenv.hostPlatform.isMusl # tests assume too much system access for them to be feasible for us right now , withTests ? false + # build only libudev and libsystemd +, buildLibsOnly ? false # name argument , pname ? "systemd" @@ -380,7 +382,7 @@ stdenv.mkDerivation (finalAttrs: { patchShebangs tools test src/!(rpm|kernel-install|ukify) src/kernel-install/test-kernel-install.sh ''; - outputs = [ "out" "man" "dev" ]; + outputs = [ "out" "dev" ] ++ (lib.optional (!buildLibsOnly) "man"); nativeBuildInputs = [ @@ -444,7 +446,7 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optional withUkify (python3Packages.python.withPackages (ps: with ps; [ pefile ])) ; - #dontAddPrefix = true; + mesonBuildType = "release"; mesonFlags = [ "-Dversion-tag=${version}" @@ -705,7 +707,9 @@ stdenv.mkDerivation (finalAttrs: { export DESTDIR=/ ''; - postInstall = '' + mesonInstallTags = lib.optionals buildLibsOnly [ "devel" "libudev" "libsystemd" ]; + + postInstall = lib.optionalString (!buildLibsOnly) '' mkdir -p $out/example/systemd mv $out/lib/{binfmt.d,sysctl.d,tmpfiles.d} $out/example mv $out/lib/systemd/{system,user} $out/example/systemd @@ -723,7 +727,7 @@ stdenv.mkDerivation (finalAttrs: { find $out -name "*kernel-install*" -exec rm {} \; '' + lib.optionalString (!withDocumentation) '' rm -rf $out/share/doc - '' + lib.optionalString withKmod '' + '' + lib.optionalString (withKmod && !buildLibsOnly) '' mv $out/lib/modules-load.d $out/example ''; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6e8ae9d5d3e..7c71add0322 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -28837,9 +28837,9 @@ with pkgs; withUserDb = false; withUkify = false; withBootloader = false; + onlyLibs = true; }; - udev = if (with stdenv.hostPlatform; isLinux && isStatic) then libudev-zero else systemd; # TODO: change to systemdMinimal -- cgit 1.4.1