Commit Graph

1751 Commits

Author SHA1 Message Date
github-actions[bot]
de642acb2e
Merge staging-next into staging 2022-03-21 12:10:50 +00:00
Florian Klink
9427a17ccb
Merge pull request #164016 from bobvanderlinden/pr-refactor-systemd-module
nixos: systemd: split module up into multiple files
2022-03-21 13:03:55 +01:00
Bob van der Linden
397b8257a0
nixos: systemd-user: fix additionalUpstreamUserUnits description
Co-authored-by: Martin Weinelt <mweinelt@users.noreply.github.com>
2022-03-21 12:30:37 +01:00
Bob van der Linden
92af44e04d
nixos: systemd: remove unhelpful comments in additionalUpstreamSystemUnits
Co-authored-by: Janne Heß <janne@hess.ooo>
2022-03-20 16:14:13 +01:00
Janne Heß
85874efcb0
nixos/switch-to-configuration: Make perlcritic happy 2022-03-20 13:04:23 +01:00
Janne Heß
9c494b5773
nixos/switch-to-configuration: Snake-case all variables
Also add a lot of comments and reorder some assignments
2022-03-20 13:03:39 +01:00
Janne Heß
67f84b4b87
nixos/switch-to-configuration: Snake-case all subroutines and add comments 2022-03-20 13:03:19 +01:00
Janne Heß
23ea9965bb
nixos/switch-to-configuration: Enforce consistent quoting 2022-03-20 13:01:11 +01:00
Janne Heß
bdcd558812
nixos/switch-to-configuration: Get rid of all postfixes and unlesses 2022-03-20 13:01:11 +01:00
Bob van der Linden
6514bb4620
nixos: systemd-user: make additionalUpstreamUserUnits internal 2022-03-19 12:06:56 +01:00
Bob van der Linden
66759cea7d
nixos: systemd-user: expand on additionalUpstreamUserUnits description 2022-03-19 12:06:43 +01:00
Bob van der Linden
753b911708
nixos: systemd-tmpfiles: use cfg shorthand 2022-03-17 23:16:38 +01:00
Bob van der Linden
38d043de9c
nixos: systemd: split off systemd-tmpfiles into separate module 2022-03-17 23:16:37 +01:00
Bob van der Linden
0e665d1815
nixos: systemd-user: allow additional upstream user units
Currently it is only possible to add upstream _system_ units. The option
systemd.additionalUpstreamSystemUnits can be used for this.

However, this was not yet possible for systemd.user. In a similar
fashion this was added to systemd-user.nix.

This is intended to have other modules add upstream units.
2022-03-17 23:16:37 +01:00
Bob van der Linden
b6d50528dd
nixos: systemd-user: use cfg shorthand 2022-03-17 23:16:37 +01:00
Bob van der Linden
022b4209a3
nixos: systemd: split off systemd-user into separate module 2022-03-17 23:16:37 +01:00
Bob van der Linden
cae8ef1232
nixos: systemd-coredump: use cfg shorthand 2022-03-17 23:16:30 +01:00
Bob van der Linden
ccfcb78a50
nixos: systemd: split off coredump into separate module 2022-03-17 23:15:49 +01:00
Bob van der Linden
7adc8ecac3
nixos: systemd-journald: use cfg shorthand 2022-03-17 23:13:36 +01:00
Bob van der Linden
fee1e24b3b
nixos: systemd: split off journald into separate module 2022-03-17 23:13:36 +01:00
Bob van der Linden
e2cb8903da
nixos: systemd-logind: use cfg shorthand 2022-03-17 23:13:27 +01:00
Bob van der Linden
c647002a94
nixos: systemd: split off logind into separate module 2022-03-17 23:12:00 +01:00
Bob van der Linden
0c94a512dd
nixos: systemd: avoid using "with systemdUtils.lib" 2022-03-17 21:52:54 +01:00
Bob van der Linden
3420dba80a
nixos: systemd: move systemd-nspawn to systemd/nspawn 2022-03-17 21:52:37 +01:00
github-actions[bot]
739cf04cb7
Merge staging-next into staging 2022-03-17 18:02:05 +00:00
Luflosi
47b699fe6c
Revert "nixos/modprobe: add boot.initrd.extraModprobeConfig option"
This reverts commit 1c58cdbeed, since this change was made redundant by 3dc6fab5c9 and in https://github.com/NixOS/nixpkgs/pull/145013 we decided to revert this commit.
2022-03-17 12:56:02 +01:00
github-actions[bot]
2eac3106df
Merge staging-next into staging 2022-03-17 00:02:45 +00:00
Robert Hensing
0395086d0c
Merge pull request #162271 from Infinisil/warn-no-type
Throw an error for options without a type
2022-03-16 22:58:45 +01:00
Bob van der Linden
9bc093b30a
nixos: systemd: split off helper functions into systemd-lib 2022-03-15 21:52:13 +01:00
Alyssa Ross
d7e181ff83
Merge remote-tracking branch 'nixpkgs/staging-next' into staging
Conflicts:
	pkgs/development/compilers/ocaml/4.12.nix
	pkgs/development/python-modules/oci/default.nix
	pkgs/tools/admin/bubblewrap/default.nix
2022-03-14 12:33:16 +00:00
Naïm Favier
9bdd2f852c
nixos/switch-to-configuration: fix installBootLoader escaping
Use a quoted heredoc to inject installBootLoader safely into the script,
and restore the previous invocation of `system` with a single argument so
that shell commands keep working.
2022-03-14 02:12:52 +01:00
Janne Heß
3148b3d365
Merge pull request #163069 from helsinki-systems/feat/minor-stc-improvements
nixos/switch-to-configuration: Few minor/medium improvements
2022-03-13 17:50:36 +01:00
Luke Granger-Brown
5f81753d1b
Merge pull request #162252 from sternenseemann/systemd-boot-builder-fix-errors
sdboot-builder: fix crash in exception handling
2022-03-13 14:19:54 +00:00
Maëlys Bras de fer
529b09a729 sdboot-builder: fix crash in exception handling 2022-03-13 14:38:01 +01:00
Luke Granger-Brown
c30918d419 nixos/networkd: add support for more WireGuard options (introduced in systemd v250)
As of systemd/systemd@e908434458,
systemd-networkd now automatically configures routes to addresses
specified in AllowedIPs unless explicitly disabled with
"RouteTable=off".
2022-03-13 04:13:03 +00:00
Janne Heß
461c1c9e86
nixos/switch-to-configuration: Use parenthesis on all calls 2022-03-11 14:05:20 +01:00
Janne Heß
bc58430068
nixos/switch-to-configuration: Fix reloading of stopped services 2022-03-11 14:05:19 +01:00
Janne Heß
3052d3aa50
nixos/switch-to-configuration: Fix restarting by activation script
This bug is so obscure and unlikely that I was honestly not able to
properly write a test for it. What happens is that we are calling
handleModifiedUnit() with $unitsToStart=\%unitsToRestart. We do this to
make sure that the unit is stopped before it's started again which is
not possible by regular means because the stop phase is already done
when calling the activation script.

recordUnit() still gets $startListFile, however which is the wrong file.
The bug would be triggered if an activation script requests a service
restart for a service that has `stopIfChanged = true` and
switch-to-configuration is killed before the restart phase was run. If
the script is run again, but the activation script is not requesting
more restarts, the unit would be started instead of restarted.
2022-03-11 13:30:03 +01:00
Janne Heß
c96180c53f
nixos/switch-to-configuration: Ignore some unit keys
Some unit keys don't need to restart the service to make them effective.
Reduce the amount of service restarts by ignoring these keys
2022-03-11 13:30:03 +01:00
github-actions[bot]
f6b4a4048a
Merge staging-next into staging 2022-03-09 12:01:59 +00:00
Peter Hoeg
d44916d12f nixos/activation: allowed quoted values in /etc/os-release 2022-03-09 17:07:48 +08:00
Andreas Rammhold
d67caf3c89 nixos/timesyncd: initialize clock file with current time
When initializing a system (e.g. first boot / livecd) we have no good
reference source for time. systemd-timesyncd however would revert back
to its configured fallback time (in our case 01.01.1980). Since we
probably don't want to hardcode a specific date as fallback we are now
using the current system time (wherever that might have come from) to
initialize the reference clock file.

The only systems that might be remotely affected by this change are
machines that have highly unreliable RTCs or those where the battery
that backs the RTC is running empty.

Historically these systems always had a tough time with anything time
related and likely required manual intervention.

For stateless systems (those that wipe / between reboots or our
installer CDs) this has the consequence that time will always be reset
to whatever the system comes up with on boot. This is likely the correct
time coming from an RTC. No harm done here the situation is likely
unchanged for them.

For stateful systems (those that retain the / partition across reboots)
there shouldn't be a change at all. They'll provide an initial clock
value once on their lifetime (during first boot / after installation).
From then onwards systemd-timesyncd will update the file with the newer
fallback time (that will be picked up on the next boot).
2022-03-05 21:27:45 +01:00
Alyssa Ross
c010a19a56
Merge remote-tracking branch 'nixpkgs/staging-next' into staging
Conflicts:
	pkgs/development/python-modules/hypothesmith/default.nix
2022-03-04 14:53:05 +00:00
Janne Heß
1def557525
nixos/switch-to-configuration: Document and test socket-activated services 2022-03-03 20:49:20 +01:00
Silvan Mosberger
b2d803ca57 nixos/treewide: Add last missing option types
Co-Authored-By: Janne Heß <janne@hess.ooo>
2022-02-28 22:50:06 +01:00
Maximilian Bosch
1077a6e040
nixos/stage-1: typo fixes 2022-02-27 14:07:31 +01:00
Maximilian Bosch
da905d4cf9
nixos/stage-1: fix modprobe in initial ramdisk on systems w/glibc-2.34
This effectively fixes the majority of all VM tests which were broken
because `/dev/vda` (or any other block device) wasn't mountable:

      machine # mounting /dev/vda on /...
      machine # mount: mounting /dev/vda on /mnt-root/ failed: No such device[    2.820976] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
      machine # [    2.821757] CPU: 0 PID: 1 Comm: init Not tainted 5.10.72 #1-NixOS
      machine # [    2.821757] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
      machine # [    2.821757] Call Trace:
      machine # [    2.821757]  dump_stack+0x6b/0x83
      machine # [    2.821757]  panic+0x101/0x2c8
      machine # [    2.821757]  do_exit.cold+0x14/0xb3
      machine # [    2.821757]  do_group_exit+0x33/0xa0
      machine # [    2.821757]  __x64_sys_exit_group+0x14/0x20
      machine # [    2.821757]  do_syscall_64+0x33/0x40
      machine # [    2.821757]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      machine # [    2.821757] RIP: 0033:0x7f67ec2800f6
      machine # [    2.821757] Code: 00 4c 8b 0d 2c 5d 11 00 eb 19 66 2e 0f 1f 84 00 00 00 00 00 89 d7 89 f0 0f 05 48 3d 00 f0 ff ff 77 22 f4 89 d7 44 89 c0 0f 05 <48> 3d 00 f0 ff ff 76 e2 f7 d8 64 41 89 01 eb da 66 2e 0f 1f 84 00
      machine # [    2.821757] RSP: 002b:00007fff8f5a71d8 EFLAGS: 00000202 ORIG_RAX: 00000000000000e7
      machine # [    2.821757] RAX: ffffffffffffffda RBX: 0000000000699704 RCX: 00007f67ec2800f6
      machine # [    2.821757] RDX: 0000000000000001 RSI: 000000000000003c RDI: 0000000000000001
      machine # [    2.821757] RBP: 0000000000000004 R08: 00000000000000e7 R09: ffffffffffffff80
      machine # [    2.821757] R10: 00007f67ec33f3e0 R11: 0000000000000202 R12: 000000000000000b
      machine # [    2.821757] R13: 00007fff8f5a75a8 R14: 0000000000000000 R15: 00000000004fc198
      machine # [    2.821757] Kernel Offset: 0x31e00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
      machine # [    2.821757] Rebooting in 1 seconds..

This happened because the kernel failed to load modules such as `ext4`
from `boot.initrd.availableKernelModules`[1] on e.g. a `mount(2)` syscall.

The problem is that `kmod` isn't linked against `libpthread.so.0`
anymore because it got merged into `libc.so.6` (however, the .so still
exists), but still needs it:

      machine # newfstatat(AT_FDCWD, "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.34-36/lib/x86_64", 0x7ffd951114c0, 0) = -1 ENOENT (No such file or directory)
      machine # openat(AT_FDCWD, "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.34-36/lib/x86_64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
      machine # newfstatat(AT_FDCWD, "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.34-36/lib/x86_64", 0x7ffd951114c0, 0) = -1 ENOENT (No such file or directory)
      machine # openat(AT_FDCWD, "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.34-36/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
      machine # newfstatat(AT_FDCWD, "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.34-36/lib", 0x7ffd951114c0, 0) = -1 ENOENT (No such file or directory)
      machine # openat(AT_FDCWD, "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.34-36/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
      machine # writev(2, [{iov_base="/nix/store/kdc9n48ksdc1a8y8w512w"..., iov_len=69}, {iov_base=": ", iov_len=2}, {iov_base="error while loading shared libra"..., iov_len=36}, {iov_base=": ", iov_len=2}, {iov_base="libpthread.so.0", iov_len=15}, {iov_base=": ", iov_len=2}, {iov_base="cy
      machine # ) = 184
      machine # exit_group(127)                         = ?
      machine # +++ exited with 127 +++
      machine # mount: mounting /dev/vda on /mnt-root/ failed: No such device
      machine # [   19.167180] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
      machine # [   19.167711] CPU: 0 PID: 1 Comm: init Not tainted 5.10.72 #1-NixOS

This is not a problem

* inside stage-1 because `LD_LIBRARY_PATH` points to `$out/lib` of
  extra-utils where `libpthread.so.6` also exists.
* on a running system because `${pkgs.glibc}/lib` is part of kmod's
  rpath.

However this is a problem inside the kernel which calls `modprobe` (in
our case `kmod`) to load modules and doesn't know about
`LD_LIBRARY_PATH`. Also, the rpath-reference was nuked.

To work around this, the kernel's `modprobe`
(i.e. `/proc/sys/kernel/modprobe`) now points to a wrapper which
explicitly declares `LD_LIBRARY_PATH`. We can't use `makeWrapper` here
because `modprobe` itself must not be renamed. Otherwise, `kmod` (which
is the link-target of `modprobe`) won't work because it expects
`argv[0] == "modprobe"` to perform modprobe's tasks.

[1] https://nixos.org/manual/nixos/stable/options.html#opt-boot.initrd.availableKernelModules
2022-02-27 10:26:51 +01:00
Dominique Martinet
0dadec45d8 logrotate/systemd: add 'minsize = 1M' to wtmp/btmp rotation
align with upstream logrotate which added the minsize rule at some point.
This avoids needlessly rotating the files too often as brought up in
https://github.com/NixOS/nixpkgs/pull/159187#issuecomment-1052426774
2022-02-27 07:20:26 +09:00
Janne Heß
e5823f77b3
Merge pull request #159187 from martinetd/logrotate
logrotate service enhancements
2022-02-23 11:24:17 +01:00
Martin Weinelt
c2147ab6a8
modprobe: install systemd's modprobe options
Shipped by systemd to combat kmod default options that interfere with
the netdev setup, when those drivers are initially loaded.
2022-02-22 17:22:57 +01:00