Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd: 243.7 -> 245 #85334

Merged
merged 13 commits into from
Apr 19, 2020
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From a6c9317a905ef478b8e0d3dad263990feb5d11cb Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <eelco.dolstra@logicblox.com>
Date: Tue, 8 Jan 2013 15:46:30 +0100
Subject: [PATCH 01/27] Start device units for uninitialised encrypted devices

This is necessary because the NixOS service that initialises the
filesystem depends on the appearance of the device unit. Also, this
makes more sense to me: the device is ready; it's the filesystem
that's not, but taking care of that is the responsibility of the mount
unit. (However, this ignores the fsck unit, so it's not perfect...)
---
rules.d/99-systemd.rules.in | 4 ----
1 file changed, 4 deletions(-)

diff --git a/rules.d/99-systemd.rules.in b/rules.d/99-systemd.rules.in
index c34b606216..3ab8c1c3fe 100644
--- a/rules.d/99-systemd.rules.in
+++ b/rules.d/99-systemd.rules.in
@@ -17,10 +17,6 @@ SUBSYSTEM=="ubi", TAG+="systemd"
SUBSYSTEM=="block", TAG+="systemd"
SUBSYSTEM=="block", ACTION=="add", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", ENV{SYSTEMD_READY}="0"

-# Ignore encrypted devices with no identified superblock on it, since
-# we are probably still calling mke2fs or mkswap on it.
-SUBSYSTEM=="block", ENV{DM_UUID}=="CRYPT-*", ENV{ID_PART_TABLE_TYPE}=="", ENV{ID_FS_USAGE}=="", ENV{SYSTEMD_READY}="0"
-
# add symlink to GPT root disk
SUBSYSTEM=="block", ENV{ID_PART_GPT_AUTO_ROOT}=="1", ENV{ID_FS_TYPE}!="crypto_LUKS", SYMLINK+="gpt-auto-root"
SUBSYSTEM=="block", ENV{ID_PART_GPT_AUTO_ROOT}=="1", ENV{ID_FS_TYPE}=="crypto_LUKS", SYMLINK+="gpt-auto-root-luks"
--
2.24.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
From fd9c882581877eef8ba1b34a9502a1ff546b3833 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <eelco.dolstra@logicblox.com>
Date: Fri, 12 Apr 2013 13:16:57 +0200
Subject: [PATCH 03/27] Don't try to unmount /nix or /nix/store

They'll still be remounted read-only.

https://github.com/NixOS/nixos/issues/126
---
src/core/mount.c | 4 +++-
src/shutdown/umount.c | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/core/mount.c b/src/core/mount.c
index a0dfa6a1a7..4ca6adcdc6 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -414,6 +414,8 @@ static bool mount_is_extrinsic(Mount *m) {

if (PATH_IN_SET(m->where, /* Don't bother with the OS data itself */
"/", /* (strictly speaking redundant: should already be covered by the perpetual flag check above) */
+ "/nix",
+ "/nix/store",
"/usr",
"/etc"))
return true;
diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c
index 2d07d3d6c1..8b112f464e 100644
--- a/src/shutdown/umount.c
+++ b/src/shutdown/umount.c
@@ -373,6 +373,8 @@ static int delete_dm(dev_t devnum) {

static bool nonunmountable_path(const char *path) {
return path_equal(path, "/")
+ || path_equal(path, "/nix")
+ || path_equal(path, "/nix/store")
#if ! HAVE_SPLIT_USR
|| path_equal(path, "/usr")
#endif
--
2.25.1

34 changes: 34 additions & 0 deletions pkgs/os-specific/linux/systemd/0004-Fix-NixOS-containers.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 58c4a7b4e9d9c34b92deded6aea814738821059d Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <eelco.dolstra@logicblox.com>
Date: Wed, 16 Apr 2014 10:59:28 +0200
Subject: [PATCH 04/27] Fix NixOS containers

In NixOS containers, the init script is bind-mounted into the
container, so checking early whether it exists will fail.
---
src/nspawn/nspawn.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 5d9290b1cf..26615901c3 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -4924,6 +4924,7 @@ static int run(int argc, char *argv[]) {
goto finish;
}
} else {
+#if 0
const char *p, *q;

if (arg_pivot_root_new)
@@ -4938,6 +4939,7 @@ static int run(int argc, char *argv[]) {
r = -EINVAL;
goto finish;
}
+#endif
}

} else {
--
2.24.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From c841ffab8fb6174b51382b9d4334f78c74018730 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <eelco.dolstra@logicblox.com>
Date: Thu, 1 May 2014 14:10:10 +0200
Subject: [PATCH 06/27] Look for fsck in the right place

---
src/fsck/fsck.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index 55e6544d31..3626aadda7 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -371,7 +371,7 @@ static int run(int argc, char *argv[]) {
} else
dash_c[0] = 0;

- cmdline[i++] = "/sbin/fsck";
+ cmdline[i++] = "/run/current-system/sw/bin/fsck";
cmdline[i++] = arg_repair;
cmdline[i++] = "-T";

--
2.24.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
From 8c0be07ccbad35d0c1106015057996aa55b9a1f9 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <eelco.dolstra@logicblox.com>
Date: Fri, 19 Dec 2014 14:46:17 +0100
Subject: [PATCH 07/27] Add some NixOS-specific unit directories

Look in /nix/var/nix/profiles/default/lib/systemd for units provided
by packages in the default (system-wide) profile, and in
/etc/systemd-mutable/system for persistent, mutable units (not
recommended).

flokli marked this conversation as resolved.
Show resolved Hide resolved
Also, remove /usr and /lib as these don't exist on NixOS.
---
src/core/systemd.pc.in | 4 ++--
src/shared/path-lookup.c | 18 +++++-------------
2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/src/core/systemd.pc.in b/src/core/systemd.pc.in
index 5d1ddd7620..21b977d6fc 100644
--- a/src/core/systemd.pc.in
+++ b/src/core/systemd.pc.in
@@ -17,8 +17,8 @@ systemduserunitdir=${prefix}/lib/systemd/user
systemduserpresetdir=${prefix}/lib/systemd/user-preset
systemdsystemconfdir=${sysconfdir}/systemd/system
systemduserconfdir=${sysconfdir}/systemd/user
-systemdsystemunitpath=${systemdsystemconfdir}:/etc/systemd/system:/run/systemd/system:/usr/local/lib/systemd/system:${systemdsystemunitdir}:/usr/lib/systemd/system:/lib/systemd/system
-systemduserunitpath=${systemduserconfdir}:/etc/systemd/user:/run/systemd/user:/usr/local/lib/systemd/user:/usr/local/share/systemd/user:${systemduserunitdir}:/usr/lib/systemd/user:/usr/share/systemd/user
+systemdsystemunitpath=${systemdsystemconfdir}:/etc/systemd/system:/etc/systemd-mutable/system:/nix/var/nix/profiles/default/lib/systemd/user:/run/systemd/system:${systemdsystemunitdir}
+systemduserunitpath=${systemduserconfdir}:/etc/systemd/user:/etc/systemd-mutable/user:/nix/var/nix/profiles/default/lib/systemd/system:/run/systemd/user:${systemduserunitdir}
systemdsystemgeneratordir=${rootprefix}/lib/systemd/system-generators
systemdusergeneratordir=${prefix}/lib/systemd/user-generators
systemdsleepdir=${rootprefix}/lib/systemd/system-sleep
diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c
index 6bf0ff0316..2b6324ad8c 100644
--- a/src/shared/path-lookup.c
+++ b/src/shared/path-lookup.c
@@ -99,17 +99,14 @@ int xdg_user_data_dir(char **ret, const char *suffix) {
}

static const char* const user_data_unit_paths[] = {
- "/usr/local/lib/systemd/user",
- "/usr/local/share/systemd/user",
USER_DATA_UNIT_PATH,
- "/usr/lib/systemd/user",
- "/usr/share/systemd/user",
NULL
};

static const char* const user_config_unit_paths[] = {
USER_CONFIG_UNIT_PATH,
"/etc/systemd/user",
+ "/etc/systemd-mutable/user",
NULL
};

@@ -604,15 +601,14 @@ int lookup_paths_init(
persistent_config,
SYSTEM_CONFIG_UNIT_PATH,
"/etc/systemd/system",
+ "/etc/systemd-mutable/system",
+ "/nix/var/nix/profiles/default/lib/systemd/system",
STRV_IFNOTNULL(persistent_attached),
runtime_config,
"/run/systemd/system",
STRV_IFNOTNULL(runtime_attached),
STRV_IFNOTNULL(generator),
- "/usr/local/lib/systemd/system",
SYSTEM_DATA_UNIT_PATH,
- "/usr/lib/systemd/system",
- STRV_IFNOTNULL(flags & LOOKUP_PATHS_SPLIT_USR ? "/lib/systemd/system" : NULL),
STRV_IFNOTNULL(generator_late));
break;

@@ -628,14 +624,12 @@ int lookup_paths_init(
persistent_config,
USER_CONFIG_UNIT_PATH,
"/etc/systemd/user",
+ "/etc/systemd-mutable/user",
+ "/nix/var/nix/profiles/default/lib/systemd/user",
runtime_config,
"/run/systemd/user",
STRV_IFNOTNULL(generator),
- "/usr/local/share/systemd/user",
- "/usr/share/systemd/user",
- "/usr/local/lib/systemd/user",
USER_DATA_UNIT_PATH,
- "/usr/lib/systemd/user",
STRV_IFNOTNULL(generator_late));
break;

@@ -824,14 +818,12 @@ char **generator_binary_paths(UnitFileScope scope) {
case UNIT_FILE_SYSTEM:
return strv_new("/run/systemd/system-generators",
"/etc/systemd/system-generators",
- "/usr/local/lib/systemd/system-generators",
SYSTEM_GENERATOR_PATH);

case UNIT_FILE_GLOBAL:
case UNIT_FILE_USER:
return strv_new("/run/systemd/user-generators",
"/etc/systemd/user-generators",
- "/usr/local/lib/systemd/user-generators",
USER_GENERATOR_PATH);

default:
--
2.24.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From 99c86daa5244d45a19f75f6ce92bd4255edef420 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <eelco.dolstra@logicblox.com>
Date: Mon, 11 May 2015 15:39:38 +0200
Subject: [PATCH 09/27] Get rid of a useless message in user sessions

Namely lots of variants of

Unit nix-var-nix-db.mount is bound to inactive unit dev-disk-by\x2dlabel-nixos.device. Stopping, too.

in containers.
---
src/core/unit.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/core/unit.c b/src/core/unit.c
index a1dc76aa6a..07670af8e2 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2045,7 +2045,8 @@ static void unit_check_binds_to(Unit *u) {
}

assert(other);
- log_unit_info(u, "Unit is bound to inactive unit %s. Stopping, too.", other->id);
+ if (u->type != UNIT_MOUNT || detect_container() <= 0)
+ log_unit_info(u, "Unit is bound to inactive unit %s. Stopping, too.", other->id);

/* A unit we need to run is gone. Sniff. Let's stop this. */
r = manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, NULL, &error, NULL);
--
2.24.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
From cec1430f72edfedb951fe34e87765ef422ea9843 Mon Sep 17 00:00:00 2001
From: Gabriel Ebner <gebner@gebner.org>
Date: Sun, 6 Dec 2015 14:26:36 +0100
Subject: [PATCH 10/27] hostnamed, localed, timedated: disable methods that
change system settings.

---
src/hostname/hostnamed.c | 9 +++++++++
src/locale/localed.c | 9 +++++++++
src/timedate/timedated.c | 10 ++++++++++
3 files changed, 28 insertions(+)

diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index 9e4f4fb59e..141b8acc08 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -423,6 +423,9 @@ static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error *
if (r < 0)
return r;

+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
+ "Changing system settings via systemd is not supported on NixOS.");
+
if (isempty(name))
name = c->data[PROP_STATIC_HOSTNAME];

@@ -479,6 +482,9 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_
if (r < 0)
return r;

+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
+ "Changing system settings via systemd is not supported on NixOS.");
+
name = empty_to_null(name);

if (streq_ptr(name, c->data[PROP_STATIC_HOSTNAME]))
@@ -536,6 +542,9 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess
if (r < 0)
return r;

+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
+ "Changing system settings via systemd is not supported on NixOS.");
+
name = empty_to_null(name);

if (streq_ptr(name, c->data[prop]))
diff --git a/src/locale/localed.c b/src/locale/localed.c
index 8d0eec96a5..0b1c1d664e 100644
--- a/src/locale/localed.c
+++ b/src/locale/localed.c
@@ -276,6 +276,9 @@ static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *er
if (r < 0)
return r;

+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
+ "Changing system settings via systemd is not supported on NixOS.");
+
/* If single locale without variable name is provided, then we assume it is LANG=. */
if (strv_length(l) == 1 && !strchr(*l, '=')) {
if (!locale_is_valid(*l))
@@ -411,6 +414,9 @@ static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_erro
if (r < 0)
return r;

+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
+ "Changing system settings via systemd is not supported on NixOS.");
+
keymap = empty_to_null(keymap);
keymap_toggle = empty_to_null(keymap_toggle);

@@ -587,6 +593,9 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err
if (r < 0)
return r;

+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
+ "Changing system settings via systemd is not supported on NixOS.");
+
layout = empty_to_null(layout);
model = empty_to_null(model);
variant = empty_to_null(variant);
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 6c94b23de4..fa20d22cde 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -653,6 +653,10 @@ static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error *
if (r < 0)
return r;

+ if (getenv("NIXOS_STATIC_TIMEZONE"))
+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
+ "Changing timezone via systemd is not supported when it is set in NixOS configuration.");
+
if (!timezone_is_valid(z, LOG_DEBUG))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid or not installed time zone '%s'", z);

@@ -732,6 +736,9 @@ static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error
if (r < 0)
return r;

+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
+ "Changing system settings via systemd is not supported on NixOS.");
+
if (lrtc == c->local_rtc)
return sd_bus_reply_method_return(m, NULL);

@@ -924,6 +931,9 @@ static int method_set_ntp(sd_bus_message *m, void *userdata, sd_bus_error *error
if (r < 0)
return r;

+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
+ "Changing system settings via systemd is not supported on NixOS.");
+
r = context_update_ntp_status(c, bus, m);
if (r < 0)
return r;
--
2.24.1

Loading