go-musicfox: 4.5.7 -> 4.6.0 (#364326)
[NixPkgs.git] / pkgs / os-specific / linux / systemd / 0013-inherit-systemd-environment-when-calling-generators.patch
blobe17d281a610116c6c457e71b93012e4a0dbe8d3d
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Yuriy Taraday <yorik.sar@gmail.com>
3 Date: Fri, 17 Jun 2022 12:45:10 +0000
4 Subject: [PATCH] inherit systemd environment when calling generators.
6 Systemd generators need access to the environment configured in
7 stage-2-init.sh since it schedules fsck and mkfs executions based on
8 being able to find an appropriate binary for the target filesystem.
10 With this commit I am altering the systemd behaviour since upstream
11 tries to gather environments with that they call
12 "environment-generators" and then seems to pass that on to all the other
13 executables that are being called from managers.
14 ---
15 src/core/manager.c | 8 ++++++++
16 1 file changed, 8 insertions(+)
18 diff --git a/src/core/manager.c b/src/core/manager.c
19 index e26c6c5cfd..6cc1642684 100644
20 --- a/src/core/manager.c
21 +++ b/src/core/manager.c
22 @@ -4035,9 +4035,17 @@ static int build_generator_environment(Manager *m, char ***ret) {
23 * adjust generated units to that. Let's pass down some bits of information that are easy for us to
24 * determine (but a bit harder for generator scripts to determine), as environment variables. */
26 + // On NixOS we must propagate PATH to generators so they are
27 + // able to find binaries such as `fsck.${fstype}` and
28 + // `mkfs.${fstype}`. That is why we ignore transient_environment that
29 + // overrides the PATH variable. This propagates systemd's
30 + // environment (e.g. PATH) that was setup
31 + // before calling systemd from stage-2-init.sh.
32 +#if 0
33 nl = strv_copy(m->transient_environment);
34 if (!nl)
35 return -ENOMEM;
36 +#endif
38 r = strv_env_assign(&nl, "SYSTEMD_SCOPE", runtime_scope_to_string(m->runtime_scope));
39 if (r < 0)