···11-From d4ea219a35a09fe02bc9e47e8530644cb4fc4146 Mon Sep 17 00:00:00 2001
11+From 93b2d29de784c68d1b4d70d7f214b19432aec6a8 Mon Sep 17 00:00:00 2001
22From: Eelco Dolstra <eelco.dolstra@logicblox.com>
33Date: Tue, 8 Jan 2013 15:46:30 +0100
44-Subject: [PATCH 01/21] Start device units for uninitialised encrypted devices
44+Subject: [PATCH 01/19] Start device units for uninitialised encrypted devices
5566This is necessary because the NixOS service that initialises the
77filesystem depends on the appearance of the device unit. Also, this
···2828 SUBSYSTEM=="block", ENV{ID_PART_GPT_AUTO_ROOT}=="1", ENV{ID_FS_TYPE}!="crypto_LUKS", SYMLINK+="gpt-auto-root"
2929 SUBSYSTEM=="block", ENV{ID_PART_GPT_AUTO_ROOT}=="1", ENV{ID_FS_TYPE}=="crypto_LUKS", SYMLINK+="gpt-auto-root-luks"
3030--
3131-2.33.0
3131+2.33.1
3232
···11-From c06abdb631527f56a626b739340d1b275349612c Mon Sep 17 00:00:00 2001
11+From b39b8871bcaa07280d6b0cf2226b1a3be31232b8 Mon Sep 17 00:00:00 2001
22From: Eelco Dolstra <eelco.dolstra@logicblox.com>
33Date: Mon, 11 May 2015 15:39:38 +0200
44-Subject: [PATCH 06/21] Get rid of a useless message in user sessions
44+Subject: [PATCH 06/19] Get rid of a useless message in user sessions
5566Namely lots of variants of
77···2727 /* If stopping a unit fails continuously we might enter a stop loop here, hence stop acting on the
2828 * service being unnecessary after a while. */
2929--
3030-2.33.0
3030+2.33.1
3131
···11-From 75d12cf65073458f091899d673c613dfc43f60c0 Mon Sep 17 00:00:00 2001
11+From f4e9304560ad42eeb8d42be583cc55eb2e5b4bb1 Mon Sep 17 00:00:00 2001
22From: Imuli <i@imu.li>
33Date: Wed, 19 Oct 2016 08:46:47 -0400
44-Subject: [PATCH 10/21] localectl: use /etc/X11/xkb for list-x11-*
44+Subject: [PATCH 10/19] localectl: use /etc/X11/xkb for list-x11-*
5566NixOS has an option to link the xkb data files to /etc/X11, but not to
77/usr/share/X11.
···2323 return log_error_errno(errno, "Failed to open keyboard mapping list. %m");
24242525--
2626-2.33.0
2626+2.33.1
2727
···11-From e7c960789b0ca97b24a66e9eeaa56ea645d9c66b Mon Sep 17 00:00:00 2001
11+From 1d623def80a3532ac1445499c9d4673e21ae8195 Mon Sep 17 00:00:00 2001
22From: Nikolay Amiantov <ab@fmap.me>
33Date: Thu, 25 Jul 2019 20:45:55 +0300
44-Subject: [PATCH 14/21] systemd-shutdown: execute scripts in
44+Subject: [PATCH 14/19] systemd-shutdown: execute scripts in
55 /etc/systemd/system-shutdown
6677This is needed for NixOS to use such scripts as systemd directory is immutable.
···2323 /* The log target defaults to console, but the original systemd process will pass its log target in through a
2424 * command line argument, which will override this default. Also, ensure we'll never log to the journal or
2525--
2626-2.33.0
2626+2.33.1
2727
···11-From 2d9fcfcfa38667ada306e095599944f941576e53 Mon Sep 17 00:00:00 2001
22-From: Jan Janssen <medhefgo@web.de>
33-Date: Wed, 11 Aug 2021 14:59:46 +0200
44-Subject: [PATCH 21/21] sd-boot: Rework console input handling
55-66-Fixes: #15847
77-Probably fixes: #19191
88-99-(cherry picked from commit e98d271e57f3d0356e444b6ea2d48836ee2769b0)
1010----
1111- src/boot/efi/boot.c | 55 +++++++---------------
1212- src/boot/efi/console.c | 102 +++++++++++++++++++++++++++++------------
1313- src/boot/efi/console.h | 2 +-
1414- 3 files changed, 91 insertions(+), 68 deletions(-)
1515-1616-diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
1717-index 54d704f0d1..b4f3b9605a 100644
1818---- a/src/boot/efi/boot.c
1919-+++ b/src/boot/efi/boot.c
2020-@@ -134,7 +134,7 @@ static BOOLEAN line_edit(
2121- uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, print);
2222- uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, cursor, y_pos);
2323-2424-- err = console_key_read(&key, TRUE);
2525-+ err = console_key_read(&key, 0);
2626- if (EFI_ERROR(err))
2727- continue;
2828-2929-@@ -387,7 +387,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
3030- Print(L"OsIndicationsSupported: %d\n", indvar);
3131-3232- Print(L"\n--- press key ---\n\n");
3333-- console_key_read(&key, TRUE);
3434-+ console_key_read(&key, 0);
3535-3636- Print(L"timeout: %u\n", config->timeout_sec);
3737- if (config->timeout_sec_efivar >= 0)
3838-@@ -432,7 +432,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
3939- Print(L"LoaderEntryDefault: %s\n", defaultstr);
4040-4141- Print(L"\n--- press key ---\n\n");
4242-- console_key_read(&key, TRUE);
4343-+ console_key_read(&key, 0);
4444-4545- for (UINTN i = 0; i < config->entry_count; i++) {
4646- ConfigEntry *entry;
4747-@@ -482,7 +482,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
4848- entry->path, entry->next_name);
4949-5050- Print(L"\n--- press key ---\n\n");
5151-- console_key_read(&key, TRUE);
5252-+ console_key_read(&key, 0);
5353- }
5454-5555- uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut);
5656-@@ -509,11 +509,10 @@ static BOOLEAN menu_run(
5757- UINTN y_max;
5858- CHAR16 *status;
5959- CHAR16 *clearline;
6060-- INTN timeout_remain;
6161-+ UINTN timeout_remain = config->timeout_sec;
6262- INT16 idx;
6363- BOOLEAN exit = FALSE;
6464- BOOLEAN run = TRUE;
6565-- BOOLEAN wait = FALSE;
6666-6767- graphics_mode(FALSE);
6868- uefi_call_wrapper(ST->ConIn->Reset, 2, ST->ConIn, FALSE);
6969-@@ -538,12 +537,6 @@ static BOOLEAN menu_run(
7070- y_max = 25;
7171- }
7272-7373-- /* we check 10 times per second for a keystroke */
7474-- if (config->timeout_sec > 0)
7575-- timeout_remain = config->timeout_sec * 10;
7676-- else
7777-- timeout_remain = -1;
7878--
7979- idx_highlight = config->idx_default;
8080- idx_highlight_prev = 0;
8181-8282-@@ -643,7 +636,7 @@ static BOOLEAN menu_run(
8383-8484- if (timeout_remain > 0) {
8585- FreePool(status);
8686-- status = PoolPrint(L"Boot in %d sec.", (timeout_remain + 5) / 10);
8787-+ status = PoolPrint(L"Boot in %d s.", timeout_remain);
8888- }
8989-9090- /* print status at last line of screen */
9191-@@ -664,27 +657,18 @@ static BOOLEAN menu_run(
9292- uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, clearline+1 + x + len);
9393- }
9494-9595-- err = console_key_read(&key, wait);
9696-- if (EFI_ERROR(err)) {
9797-- /* timeout reached */
9898-+ err = console_key_read(&key, timeout_remain > 0 ? 1000 * 1000 : 0);
9999-+ if (err == EFI_TIMEOUT) {
100100-+ timeout_remain--;
101101- if (timeout_remain == 0) {
102102- exit = TRUE;
103103- break;
104104- }
105105-106106-- /* sleep and update status */
107107-- if (timeout_remain > 0) {
108108-- uefi_call_wrapper(BS->Stall, 1, 100 * 1000);
109109-- timeout_remain--;
110110-- continue;
111111-- }
112112--
113113-- /* timeout disabled, wait for next key */
114114-- wait = TRUE;
115115-+ /* update status */
116116- continue;
117117-- }
118118--
119119-- timeout_remain = -1;
120120-+ } else
121121-+ timeout_remain = 0;
122122-123123- /* clear status after keystroke */
124124- if (status) {
125125-@@ -787,7 +771,7 @@ static BOOLEAN menu_run(
126126- config->timeout_sec_efivar,
127127- EFI_VARIABLE_NON_VOLATILE);
128128- if (config->timeout_sec_efivar > 0)
129129-- status = PoolPrint(L"Menu timeout set to %d sec.", config->timeout_sec_efivar);
130130-+ status = PoolPrint(L"Menu timeout set to %d s.", config->timeout_sec_efivar);
131131- else
132132- status = StrDuplicate(L"Menu disabled. Hold down key at bootup to show menu.");
133133- } else if (config->timeout_sec_efivar <= 0){
134134-@@ -795,7 +779,7 @@ static BOOLEAN menu_run(
135135- efivar_set(
136136- LOADER_GUID, L"LoaderConfigTimeout", NULL, EFI_VARIABLE_NON_VOLATILE);
137137- if (config->timeout_sec_config > 0)
138138-- status = PoolPrint(L"Menu timeout of %d sec is defined by configuration file.",
139139-+ status = PoolPrint(L"Menu timeout of %d s is defined by configuration file.",
140140- config->timeout_sec_config);
141141- else
142142- status = StrDuplicate(L"Menu disabled. Hold down key at bootup to show menu.");
143143-@@ -813,7 +797,7 @@ static BOOLEAN menu_run(
144144- config->timeout_sec_efivar,
145145- EFI_VARIABLE_NON_VOLATILE);
146146- if (config->timeout_sec_efivar > 0)
147147-- status = PoolPrint(L"Menu timeout set to %d sec.",
148148-+ status = PoolPrint(L"Menu timeout set to %d s.",
149149- config->timeout_sec_efivar);
150150- else
151151- status = StrDuplicate(L"Menu disabled. Hold down key at bootup to show menu.");
152152-@@ -2369,13 +2353,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
153153- else {
154154- UINT64 key;
155155-156156-- err = console_key_read(&key, FALSE);
157157--
158158-- if (err == EFI_NOT_READY) {
159159-- uefi_call_wrapper(BS->Stall, 1, 100 * 1000);
160160-- err = console_key_read(&key, FALSE);
161161-- }
162162--
163163-+ /* Block up to 100ms to give firmware time to get input working. */
164164-+ err = console_key_read(&key, 100 * 1000);
165165- if (!EFI_ERROR(err)) {
166166- INT16 idx;
167167-168168-diff --git a/src/boot/efi/console.c b/src/boot/efi/console.c
169169-index 83619d2147..369c549daf 100644
170170---- a/src/boot/efi/console.c
171171-+++ b/src/boot/efi/console.c
172172-@@ -11,61 +11,105 @@
173173-174174- #define EFI_SIMPLE_TEXT_INPUT_EX_GUID &(EFI_GUID) EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID
175175-176176--EFI_STATUS console_key_read(UINT64 *key, BOOLEAN wait) {
177177-+static inline void EventClosep(EFI_EVENT *event) {
178178-+ if (!*event)
179179-+ return;
180180-+
181181-+ uefi_call_wrapper(BS->CloseEvent, 1, *event);
182182-+}
183183-+
184184-+/*
185185-+ * Reading input from the console sounds like an easy task to do, but thanks to broken
186186-+ * firmware it is actually a nightmare.
187187-+ *
188188-+ * There is a ConIn and TextInputEx API for this. Ideally we want to use TextInputEx,
189189-+ * because that gives us Ctrl/Alt/Shift key state information. Unfortunately, it is not
190190-+ * always available and sometimes just non-functional.
191191-+ *
192192-+ * On the other hand we have ConIn, where some firmware likes to just freeze on us
193193-+ * if we call ReadKeyStroke on it.
194194-+ *
195195-+ * Therefore, we use WaitForEvent on both ConIn and TextInputEx (if available) along
196196-+ * with a timer event. The timer ensures there is no need to call into functions
197197-+ * that might freeze on us, while still allowing us to show a timeout counter.
198198-+ */
199199-+EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec) {
200200- static EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInputEx;
201201- static BOOLEAN checked;
202202- UINTN index;
203203- EFI_INPUT_KEY k;
204204- EFI_STATUS err;
205205-+ _cleanup_(EventClosep) EFI_EVENT timer = NULL;
206206-+ EFI_EVENT events[3] = { ST->ConIn->WaitForKey };
207207-+ UINTN n_events = 1;
208208-209209- if (!checked) {
210210- err = LibLocateProtocol(EFI_SIMPLE_TEXT_INPUT_EX_GUID, (VOID **)&TextInputEx);
211211-- if (EFI_ERROR(err))
212212-+ if (EFI_ERROR(err) ||
213213-+ uefi_call_wrapper(BS->CheckEvent, 1, TextInputEx->WaitForKeyEx) == EFI_INVALID_PARAMETER)
214214-+ /* If WaitForKeyEx fails here, the firmware pretends it talks this
215215-+ * protocol, but it really doesn't. */
216216- TextInputEx = NULL;
217217-+ else
218218-+ events[n_events++] = TextInputEx->WaitForKeyEx;
219219-220220- checked = TRUE;
221221- }
222222-223223-- /* wait until key is pressed */
224224-- if (wait)
225225-- uefi_call_wrapper(BS->WaitForEvent, 3, 1, &ST->ConIn->WaitForKey, &index);
226226-+ if (timeout_usec > 0) {
227227-+ err = uefi_call_wrapper(BS->CreateEvent, 5, EVT_TIMER, 0, NULL, NULL, &timer);
228228-+ if (EFI_ERROR(err))
229229-+ return log_error_status_stall(err, L"Error creating timer event: %r", err);
230230-+
231231-+ /* SetTimer expects 100ns units for some reason. */
232232-+ err = uefi_call_wrapper(BS->SetTimer, 3, timer, TimerRelative, timeout_usec * 10);
233233-+ if (EFI_ERROR(err))
234234-+ return log_error_status_stall(err, L"Error arming timer event: %r", err);
235235-236236-- if (TextInputEx) {
237237-+ events[n_events++] = timer;
238238-+ }
239239-+
240240-+ err = uefi_call_wrapper(BS->WaitForEvent, 3, n_events, events, &index);
241241-+ if (EFI_ERROR(err))
242242-+ return log_error_status_stall(err, L"Error waiting for events: %r", err);
243243-+
244244-+ if (timeout_usec > 0 && timer == events[index])
245245-+ return EFI_TIMEOUT;
246246-+
247247-+ /* TextInputEx might be ready too even if ConIn got to signal first. */
248248-+ if (TextInputEx && !EFI_ERROR(uefi_call_wrapper(BS->CheckEvent, 1, TextInputEx->WaitForKeyEx))) {
249249- EFI_KEY_DATA keydata;
250250- UINT64 keypress;
251251-+ UINT32 shift = 0;
252252-253253- err = uefi_call_wrapper(TextInputEx->ReadKeyStrokeEx, 2, TextInputEx, &keydata);
254254-- if (!EFI_ERROR(err)) {
255255-- UINT32 shift = 0;
256256--
257257-- /* do not distinguish between left and right keys */
258258-- if (keydata.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) {
259259-- if (keydata.KeyState.KeyShiftState & (EFI_RIGHT_CONTROL_PRESSED|EFI_LEFT_CONTROL_PRESSED))
260260-- shift |= EFI_CONTROL_PRESSED;
261261-- if (keydata.KeyState.KeyShiftState & (EFI_RIGHT_ALT_PRESSED|EFI_LEFT_ALT_PRESSED))
262262-- shift |= EFI_ALT_PRESSED;
263263-- };
264264--
265265-- /* 32 bit modifier keys + 16 bit scan code + 16 bit unicode */
266266-- keypress = KEYPRESS(shift, keydata.Key.ScanCode, keydata.Key.UnicodeChar);
267267-- if (keypress > 0) {
268268-- *key = keypress;
269269-- return 0;
270270-- }
271271-+ if (EFI_ERROR(err))
272272-+ return err;
273273-+
274274-+ /* do not distinguish between left and right keys */
275275-+ if (keydata.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) {
276276-+ if (keydata.KeyState.KeyShiftState & (EFI_RIGHT_CONTROL_PRESSED|EFI_LEFT_CONTROL_PRESSED))
277277-+ shift |= EFI_CONTROL_PRESSED;
278278-+ if (keydata.KeyState.KeyShiftState & (EFI_RIGHT_ALT_PRESSED|EFI_LEFT_ALT_PRESSED))
279279-+ shift |= EFI_ALT_PRESSED;
280280-+ };
281281-+
282282-+ /* 32 bit modifier keys + 16 bit scan code + 16 bit unicode */
283283-+ keypress = KEYPRESS(shift, keydata.Key.ScanCode, keydata.Key.UnicodeChar);
284284-+ if (keypress > 0) {
285285-+ *key = keypress;
286286-+ return EFI_SUCCESS;
287287- }
288288-+
289289-+ return EFI_NOT_READY;
290290- }
291291-292292-- /* fallback for firmware which does not support SimpleTextInputExProtocol
293293-- *
294294-- * This is also called in case ReadKeyStrokeEx did not return a key, because
295295-- * some broken firmwares offer SimpleTextInputExProtocol, but never actually
296296-- * handle any key. */
297297- err = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &k);
298298- if (EFI_ERROR(err))
299299- return err;
300300-301301- *key = KEYPRESS(0, k.ScanCode, k.UnicodeChar);
302302-- return 0;
303303-+ return EFI_SUCCESS;
304304- }
305305-306306- static EFI_STATUS change_mode(UINTN mode) {
307307-diff --git a/src/boot/efi/console.h b/src/boot/efi/console.h
308308-index 2c69af552a..23848a9c58 100644
309309---- a/src/boot/efi/console.h
310310-+++ b/src/boot/efi/console.h
311311-@@ -16,5 +16,5 @@ enum console_mode_change_type {
312312- CONSOLE_MODE_MAX,
313313- };
314314-315315--EFI_STATUS console_key_read(UINT64 *key, BOOLEAN wait);
316316-+EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec);
317317- EFI_STATUS console_set_mode(UINTN *mode, enum console_mode_change_type how);
318318---
319319-2.33.0
320320-
+3-16
pkgs/os-specific/linux/systemd/default.nix
···122122assert withCryptsetup -> (cryptsetup != null);
123123let
124124 wantCurl = withRemote || withImportd;
125125- version = "249.5";
125125+ version = "249.7";
126126in
127127stdenv.mkDerivation {
128128 inherit pname version;
···133133 owner = "systemd";
134134 repo = "systemd-stable";
135135 rev = "v${version}";
136136- sha256 = "0bir2syy20rdi59sv8xp8nw1c92zl9z0wmv7ggsll8dca7niqwbp";
136136+ sha256 = "sha256-y33/BvvI+JyhsvuT1Cbm6J2Z72j71oXgLw6X9NwCMPE=";
137137 };
138138139139 # If these need to be regenerated, `git am path/to/00*.patch` them into a
···165165 # systemd. With the below patch we mitigate that effect by special casing
166166 # all our root unit dirs if they are symlinks. This does exactly what we
167167 # need (AFAICT).
168168+ # See https://github.com/systemd/systemd/pull/20479 for upsteam discussion.
168169 ./0019-core-handle-lookup-paths-being-symlinks.patch
169169-170170- # In v248 compiler weirdness and refactoring lead to the bootloader
171171- # erroring out handling keyboard input on some systems. See
172172- # https://github.com/systemd/systemd/issues/19191
173173- # This should be redundant in v249.6 when it offically gets tagged in
174174- # systemd-stable
175175- ./0020-sd-boot-Unify-error-handling.patch
176176- ./0021-sd-boot-Rework-console-input-handling.patch
177170 ] ++ lib.optional stdenv.hostPlatform.isMusl (let
178171 oe-core = fetchzip {
179172 url = "https://git.openembedded.org/openembedded-core/snapshot/openembedded-core-14c6e5a4b72d0e4665279158a0740dd1dc21f72f.tar.bz2";
···583576 '';
584577585578 postInstall = ''
586586- # sysinit.target: Don't depend on
587587- # systemd-tmpfiles-setup.service. This interferes with NixOps's
588588- # send-keys feature (since sshd.service depends indirectly on
589589- # sysinit.target).
590590- mv $out/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup-dev.service $out/lib/systemd/system/multi-user.target.wants/
591591-592579 mkdir -p $out/example/systemd
593580 mv $out/lib/{modules-load.d,binfmt.d,sysctl.d,tmpfiles.d} $out/example
594581 mv $out/lib/systemd/{system,user} $out/example/systemd