Commit Graph

2712 Commits

Author SHA1 Message Date
Will Fancher
208e953381 systemd-stage-1: Fully merge /bin and /sbin
In #327506, we stopped using `/sbin` in the `pathsToLink` of `initrdBinEnv`. This inadvertantly stopped including the `sbin` directory of the `initrdBin` packages, which meant that things like `mdadm`'s udev rules, which referred to binaries by their `sbin` paths, stopped working.

The purpose of #327506 was to fix the fact that `mount` was not calling mount helpers like `mount.ext4` unless they happened to be in `/sbin`. But this raised some questions for me, because I thought we set `managerEnvironment.PATH` to help util-linux find helpers for both `mount` and `fsck`. So I decided to look at how this works in stage 2 to figure it out, and it's a little cursed.

---

What I already knew is that we have [this](696a4e3758/nixos/modules/system/boot/systemd.nix (L624-L625))

```
        # util-linux is needed for the main fsck utility wrapping the fs-specific ones
        PATH = lib.makeBinPath (config.system.fsPackages ++ [cfg.package.util-linux]);
```

And I thought this was how `mount` finds the mount helpers. But if that were true, then `mount` should be finding helpers in stage 1 because of [this](696a4e3758/nixos/modules/system/boot/systemd/initrd.nix (L411))

```
      managerEnvironment.PATH = "/bin";
```

Turns out, `mount` _actually_ finds helpers with [this configure flag](696a4e3758/pkgs/os-specific/linux/util-linux/default.nix (L59))

```
    "--enable-fs-paths-default=/run/wrappers/bin:/run/current-system/sw/bin:/sbin"
```

Ok... so then why do we need the PATH? Because `fsck` has [this](a75c7a102e/disk-utils/fsck.c (L1659))

```
	fsck_path = xstrdup(path && *path ? path : FSCK_DEFAULT_PATH);
```

(`path` is `getenv("PATH")`)

So, tl;dr, `mount` and `fsck` have completely unrelated search paths for their helper programs

For `mount`, we have to use a configure flag to point to `/run/current-system`, and for `fsck` we can just set PATH

---

So, for systemd stage 1, we *do* want to include packages' `sbin` paths, because of the `mdadm` problem. But for `mount`, we need helpers to be on the search path, and right now that means putting it somewhere in `/run/wrappers/bin:/run/current-system/sw/bin:/sbin`.
2024-08-12 23:35:01 -04:00
Will Fancher
d74d182991 Revert "systemd-stage-1: Use common bin for /sbin"
This reverts commit b4b4751e97.
2024-08-12 23:35:01 -04:00
nikstur
fa12935a32
Merge pull request #333006 from nikstur/static-mtab
nixos/systemd-tmpfiles: create /etc/mtab via environmemt.etc instead of tmpfiles
2024-08-08 12:00:07 +02:00
nikstur
9e720a5881 nixos/systemd-tmpfiles: create /etc/mtab via environmemt.etc instead of tmpfiles
This enables an immutable /etc via `system.etc.overlay.mutable = false`.
2024-08-07 16:12:37 +02:00
Franz Pletz
481d7272d1
Merge pull request #201202 from m-bdf/sdboot-infinite-timeout 2024-08-06 16:25:25 +02:00
Franz Pletz
97ebf11501
Merge pull request #319422 from jmbaur/systemd-boot-devicetree 2024-08-06 13:39:29 +02:00
Florian Klink
a9f1cb6e2f
Merge pull request #253260 from thblt/systemd-bitlocker
Create boot.loader.systemd-boot.rebootForBitlocker option
2024-08-05 17:03:13 +03:00
Florian Klink
a5265503e6
Merge pull request #327506 from ElvishJerricco/systemd-initrd-merge-sbin
systemd-stage-1: Use common bin for /sbin
2024-08-05 14:18:51 +03:00
Thibault Polge
a68b81c429 nixos/systemd-boot: Add reboot-for-bitlocker support
Windows with BitLocker and TPM enabled doesn't support boot chaining.
This option activates a special experimental mode in systemd-boot that
tries to detect such systems and, if detected and selected by the user
at the boot menu, set the BootNext EFI variable to it before resetting.
2024-08-05 13:17:25 +03:00
Maëlys Bras de fer
7ae6219163 nixos/systemd-boot: fix infinite timeout 2024-08-05 08:48:54 +00:00
František Hanzlík
8b4cd01f90
nixos/networkd: allow specifying FirewallMark mask 2024-08-01 22:22:01 +02:00
Jared Baur
fca8ee915d
nixos/systemd-boot: add support for devicetree entry
The [Boot Loader Specification](https://uapi-group.org/specifications/specs/boot_loader_specification/)
allows for using a key called "devicetree" for specifying which
devicetree the bootloader should use during boot. With regards to
systemd-boot, this key is used to specify which file should be picked up
from the ESP to install to the EFI DTB Configuration Table. Linux then uses
this Configuration Table to setup the machine. This change is similar to
the one done in https://github.com/NixOS/nixpkgs/pull/295096, where that
change was for adding DTB support to systemd-stub, and this is for
systemd-boot.
2024-08-01 11:15:15 -07:00
Arian van Putten
45e041902f nixos/systemd: drop support for legacy cgroup hierachy 2024-07-31 13:49:58 +02:00
Masum Reza
cb27644348
Merge pull request #310661 from somasis/boot.plymouth.font
nixos/boot.plymouth.font: escape font path
2024-07-31 00:39:11 +05:30
Vladimír Čunát
a5b2fe7374
Merge #328673: staging-next 2024-07-20 2024-07-28 13:45:55 +02:00
Robert Hensing
4ca52fdf5f
Merge pull request #323613 from CyberShadow/fix-nix-path-without-channels-v2
nix-channel: do not set empty nix-path when disabling channels
2024-07-28 13:31:10 +02:00
K900
24076029d2 Merge remote-tracking branch 'origin/master' into staging-next 2024-07-28 01:04:35 +03:00
Julien Malka
64edc7f00f nixos/systemd-boot: init boot counting
Update nixos/modules/system/boot/loader/systemd-boot/boot-counting.md

Co-authored-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>
2024-07-26 20:04:37 +02:00
github-actions[bot]
2567b049bd
Merge master into staging-next 2024-07-25 18:00:59 +00:00
Anton Mosich
bc1c51d6d0
nixos/system: fix grammatical error in docs 2024-07-25 18:19:35 +02:00
Artturin
60e9cffe2c Merge branch 'master' into staging-next 2024-07-22 22:53:31 +03:00
nikstur
be0df72dfa
Merge pull request #328926 from nikstur/sysusers-only-for-sysusers
Sysusers only for sysusers
2024-07-22 20:55:58 +02:00
Marcus Ramberg
585a077fd2
Merge pull request #327665 from bolives-hax/add-qemu-s390x-binfmt
added s390x option type via magic attributes
2024-07-21 23:12:55 +02:00
bl0v3
e83fc89111 nixos/binfmt: added s390x option type via magic attributes 2024-07-21 20:17:16 +02:00
nikstur
2ca04530c9 nixos/systemd-sysusers: assert against password and hashedPassword
Regardless of mutable or immutable users, systemd-sysupdate never
updates existing user records and thus will for example never change
passwords for you.

It only support initial passwords and now actively asserts agains other
paswords.
2024-07-21 16:23:11 +02:00
nikstur
2710a49adb nixos/systemd-sysusers: stop creating users statically
On Linux we cannot feasbibly generate users statically because we need
to take care to not change or re-use UIDs over the lifetime of a machine
(i.e. over multiple generations). This means we need the context of the
running machine.

Thus, stop creating users statically and instead generate them at
runtime irrespective of mutableUsers.

When /etc is immutable, the password files (e.g. /etc/passwd etc.) are
created in a separate directory (/var/lib/nixos/etc). /etc will be
pre-populated with symlinks to this separate directory.

Immutable users are now implemented by bind-mounting the password files
read-only onto themselves and only briefly re-mounting them writable to
re-execute sysusers. The biggest limitation of this design is that you
now need to manually unmount this bind mount to change passwords because
sysusers cannot change passwords for you. This shouldn't be too much of
an issue because system users should only rarely need to change their
passwords.
2024-07-21 16:23:11 +02:00
nikstur
d43e323b4a nixos/systemd-sysusers: only create systemusers
systemd-sysusers cannot create normal users (i.e. with a UID > 1000).
Thus we stop trying an explitily only use systemd-sysusers when there
are no normal users on the system (e.g. appliances).
2024-07-21 16:22:01 +02:00
Will Fancher
6f959a9e96 nixos/make-initrd-ng: dlopen ELF notes 2024-07-21 06:31:42 -04:00
Will Fancher
e6c544270c nixos/make-initrd-ng: Pass contents as JSON 2024-07-21 06:31:42 -04:00
nikstur
d4a80b6d0c systemd: 255.6 -> 256.2 2024-07-21 06:31:37 -04:00
Jörg Thalheim
054c2d71f7
Merge pull request #328221 from nikstur/fix-overlay-etc
nixos/etc: handle mountpoints on top of /etc when switching
2024-07-18 21:59:30 +02:00
nikstur
6abbe725ca nixos/etc: handle mountpoints on top of /etc when switching
The activation script that remounts the /etc overlay now handles other
mount points on top of /etc by bind mounting them to the new temporary
/etc overlay and then atomically revealing it.
2024-07-18 21:28:53 +02:00
Sandro
fa5abfe559
Merge pull request #317623 from jmbaur/stc-ng-followup 2024-07-18 11:33:59 +02:00
Robert Hensing
1022da85ab nixos/activation-script: Add lib.sh with warn() 2024-07-16 20:42:06 +02:00
Sandro Jäckel
0e5342f48a
nixos/systemd-boot: give systemdBootBuilder a better name
Before it had twice a store hash which made nix store diff-closures
kinda ugly.
2024-07-16 19:53:57 +02:00
Will Fancher
b4b4751e97 systemd-stage-1: Use common bin for /sbin
util-linux's mount command was only looking in /sbin for mount
helpers, which wasn't working.
2024-07-15 05:03:52 -04:00
turtton
be20b91547 nixos/systemd-boot-builder: fix installed_match regex
Fix regular expression used to get bootloader versions from bootctl status.
This avoids problems that occur in minor environments like mine.

References:  #296563
2024-07-13 09:20:13 +02:00
Florian Klink
68767b54d3
Merge pull request #321935 from Ma27/nspawn-cgroupsv2
nixos/nspawn: cgroupsv2 by default
2024-07-12 18:06:08 +03:00
Julien Malka
6701c2c867
Merge pull request #323421 from Mic92/systemd-boot-builder 2024-07-07 19:36:09 +02:00
Mitchell Skaggs
5e1481ccc7
nixos/systemd-boot: fix invalid escape sequences
This was inadvertently introduced in https://github.com/NixOS/nixpkgs/pull/281639, but was not a loud warning until Python 3.12 made invalid escape sequences a `SyntaxWarning` instead of a `DeprecationWarning` in https://github.com/python/cpython/issues/98401.
2024-07-07 05:37:08 -05:00
Franz Pletz
aa8c9e6f2d
Merge pull request #317642 from melvyn2/systemd-networkd-network-options 2024-07-04 20:21:37 +02:00
Franz Pletz
a1ecdd6b1a
Merge pull request #276135 from nbdd0121/netdev 2024-07-04 18:35:15 +02:00
Robert Hensing
7b1af67486 nixos/journald: Link to journald manpage
This creates a link to https://www.freedesktop.org/software/systemd/man/latest/journald.conf.html,
thanks to `doc/manpage-urls.json`.
2024-07-02 12:09:07 +02:00
r-vdp
d1e0f30cb2
Fix SSH in scripted initrd
Co-authored-by: Emily <vcs@emily.moe>
2024-07-01 15:35:55 +02:00
r-vdp
79d8116671
Fix ssh in initrd for systemd-initrd
Broken in https://github.com/NixOS/nixpkgs/pull/323753
2024-07-01 15:35:55 +02:00
Jörg Thalheim
ebfee308fc systemd-boot-builder: use type literals 2024-06-29 19:09:38 +02:00
Jörg Thalheim
6d0be2bec1 systemd-boot-builder: allow exceptions from python naming scheme 2024-06-29 19:09:28 +02:00
Jörg Thalheim
1ae4daa608 systemd-boot-builder: use safe run wrapper
we have a zoo of ways to call subprocesses.
Let's just replace this with one function that has reasonable defaults.
i.e. I catched instances where commands where run in a shell.
2024-06-29 19:09:06 +02:00
Jörg Thalheim
5cbf195292 systemd-boot-builder: use regex strings 2024-06-29 19:09:04 +02:00
Jörg Thalheim
f339bdf84c systemd-boot-builder: simplify conditions 2024-06-29 19:09:02 +02:00