Commit Graph

2385 Commits

Author SHA1 Message Date
Petr Hodina
a9f77c2fb0 systemd-boot: Add option for consoleMode to support SteamDeck 2024-09-08 22:48:21 +02:00
Aleksana
3be36da2d2
unl0kr: remove tomfitzhenry@ as maintainer (#333616) 2024-09-06 12:50:55 +08:00
Will Fancher
a96e54fe52
initrd: use the new tmpfiles options to create tmpfiles config (#339503) 2024-09-05 17:02:30 -04:00
Will Fancher
5a575e88b6
Revert "nixos: support dm-verity" 2024-09-05 15:56:49 -04:00
Tom Fitzhenry
752afd12e7 unl0kr: remove tomfitzhenry@ as maintainer 2024-09-05 18:10:59 +10:00
r-vdp
6ccc6bf4d2
initrd: emit a warning when tmpfiles config is created manually 2024-09-05 09:55:29 +02:00
Moritz Sanft
d0213a75e0
nixos: support dm-verity 2024-09-05 08:42:53 +02:00
r-vdp
d558554243
initrd: use the new tmpfiles options to create tmpfiles config
Otherwise we get a clash when generating the initrd since the initrd tmpfiles
options create a symlink at /etc/tmpfiles.d/ and any subsequent writes inside
this directory because of initrd.systemd.contents will cause a permission denied
error.
2024-09-04 14:39:03 +02:00
datafoo
24e08d0e9b nixos/timesyncd: allow NTP servers advertised by DHCP to be used
- add option `fallbackServers` with default to `networking.timeServers`
- option `servers` now default to null

Fix #335050
2024-09-04 12:17:39 +02:00
datafoo
b4cd57870d nixos/timesyncd: allow null for option servers
This gives the ability to not write `NTP=` to the `timesyncd.conf` file
(servers = null) as opposed to writing `NTP=` (servers = []) which is
interpreted slightly differently by systemd:

> When the empty string is assigned, the list of NTP servers is reset,
and all prior assignments will have no effect.
2024-09-04 12:14:24 +02:00
datafoo
34efcf8aef nixos/timesyncd: minor refactoring 2024-09-04 12:14:24 +02:00
datafoo
45c0d04735 nixos/timesyncd: minor refactoring 2024-09-04 12:14:24 +02:00
Jörg Thalheim
a9034a9c35
nixos/grub: fix value precedence with optional -> mkIf (#338773) 2024-09-03 08:29:25 +02:00
zimbatm
1ea32d4f69 nixos/grub: fix value precendence with optional -> mkIf
When using `lib.optionals`, the return value of both branches of the
condition get set as a value to the option.

When using `lib.mkIf`, only the positive condition gets set as a value
to the option.

This small distinction is important when dealing with precedence. For
example here, we wanted to set a boot.grub.devices default value with
lib.mkDefault, and that was getting overridden with the empty value of
`lib.optional (cfg.device != "") cfg.device`.

See https://github.com/nix-community/srvos/pull/491#discussion_r1738827651

The general conclusion is that using `lib.mkIf` is preferable to
`lib.optional` or `lib.optionals` when setting values in the NixOS
module system.
2024-09-01 12:13:15 +02:00
Felix Buehler
f3dd1a8bd5 nixos/services.logind: remove with lib; 2024-08-30 23:01:45 +02:00
Felix Buehler
69ca7aa56f nixos/services.journald: remove with lib; 2024-08-30 23:01:42 +02:00
Will Fancher
bf19362974
nixos/systemd-boot: use unique path for devicetree blob (#336263) 2024-08-28 12:36:20 -04:00
Jörg Thalheim
82ac9a1580
Merge pull request #337054 from Mic92/sysusers
sysuser: slightly better assertions message
2024-08-25 09:44:58 +02:00
Franz Pletz
83cd05ff59
Merge pull request #335976 from poscat0x04/nixos-networkd-ipv6ra 2024-08-25 01:51:36 +02:00
Jared Baur
05aefd6f05
nixos/systemd-boot: remove semicolon 2024-08-24 12:50:26 -07:00
Jared Baur
6327b07b25
nixos/systemd-boot: use unique path for devicetree blob
Use the store directory for the devicetree package containing the
desired DTB when installing to the ESP. This allows for more than one
NixOS generation containing differing DTBs to coexist on the same ESP
(similar to how we can have multiple kernels & initrds). This change
removes the assumption that the filepath passed to `copy_from_file` is a
file that lives at the toplevel of a nix output path (which prior to the
systemd-boot DTB support was the case for the kernel and initrd
derivations).
2024-08-24 12:50:24 -07:00
Jörg Thalheim
7211a81060 sysuser: slightly better assertions message 2024-08-24 19:20:28 +02:00
Felix Stupp
4b998d179f
nixos/systemd.network: add support for UseDomains= in [Network] sections
Those options were also added with systemd 256, but sadly were missed out in #307068.

These options are documented in:
- [systemd 256 changelog](https://github.com/systemd/systemd/releases/tag/v256) (search for `UseDomains=`)
- [networkd.conf(5)](https://www.freedesktop.org/software/systemd/man/256/networkd.conf.html#UseDomains=)
- [systemd.network(5)](https://www.freedesktop.org/software/systemd/man/256/systemd.network.html#UseDomains=)
2024-08-21 19:48:29 +00:00
poscat
712e039585
nixos/networkd: add IPv6SendRA options added in systemd 255 2024-08-21 15:59:33 +08:00
Florian Klink
cce9aef6fd
Merge pull request #334337 from eduarrrd/eaccess-null
nixos/systemd/initrd: Fix emergencyAccess to work with `null`.
2024-08-19 14:44:25 +03:00
nikstur
0a810476ad
Merge pull request #307528 from WilliButz/systemd-initrd/tmpfiles-settings
nixos/systemd-tmpfiles: add initrd support
2024-08-19 11:54:42 +02:00
Will Fancher
f84991dc2b
Merge pull request #334288 from ElvishJerricco/systemd-initrd-fully-merge-sbin
Systemd initrd fully merge sbin
2024-08-18 22:41:53 -04:00
Eduard Bachmakov
b33bf6b99a nixos/systemd/initrd: Fix emergencyAccess to work with null.
Implementation is now compatible with the option's .type already defined.

This allows us to pass `config.users.users.<user>.hashedPassword` even if this is null (the default).

Before:
true  => access
false => no access
hash  => access via password
null  => eval error

After:
true  => access
false => no access
hash  => access via password
null  => no access
2024-08-14 10:26:15 +02:00
Will Fancher
0637303ca8 Revert "Merge pull request #330017 from Mic92/boot-counting"
This reverts commit 3d3c0f4d34, reversing
changes made to 47f7e25a77.
2024-08-13 23:11:18 -04:00
Will Fancher
b78bd2f912 Revert "Merge pull request #333952 from r-vdp/specialisation-name-regex"
This reverts commit fc35704bc8, reversing
changes made to c67d90d517.
2024-08-13 21:33:15 -04:00
WilliButz
8dd369f524
nixos/systemd-tmpfiles: add initrd support
This adds support for declaring tmpfiles rules exclusively for the
systemd initrd. Configuration is possible through the new option
`boot.initrd.systemd.tmpfiles.settings` that shares the same interface as
`systemd.tmpfiles.settings`.

I did intentionally not replicate the `rules` interface here, given that
the settings attribute set is more versatile than the list of strings
used for `rules`. This should also make it unnecessary to implement the
workaround from 1a68e21d47 again.

A self-contained `tmpfiles.d` directory is generated from the new initrd
settings and it is added to the initrd as a content path at
`/etc/tmpfiles.d`.

The stage-1 `systemd-tmpfiles-setup.service` is now altered to no longer
operate under the `/sysroot` prefix, because the `/sysroot` hierarchy
cannot be expected to be available when the default upstream service is
started.

To handle files under `/sysroot` a slightly altered version of the
upstream default service is introduced. This new unit
`systemd-tmpfiles-setup-sysroot.service` operates only under the
`/sysroot` prefix and it is ordered between `initrd-fs.target` and the
nixos activation.

Config related to tmpfiles was moved from initrd.nix to tmpfiles.nix.
2024-08-13 13:02:21 +02:00
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
Will Fancher
bcd1d9cf54
Merge pull request #312755 from tomfitzhenry/systemd-dhcp108
nixos/networkd: allow IPv6OnlyPreferredSec in networkd.conf
2024-08-12 19:19:34 -04:00
Florian Klink
fc35704bc8
Merge pull request #333952 from r-vdp/specialisation-name-regex
specialisation: limit the allowed characters in specialisation names
2024-08-12 13:30:54 +03:00
r-vdp
d38257b024
systemd-boot-builder: allow underscores in the specialisation name 2024-08-11 23:33:18 +02:00
Pol Dellaiera
71daf1a037
Merge pull request #333643 from eduarrrd/initrd-ids
nixos/systemd/initrd: Set /etc/hostname in the initrd.
2024-08-11 20:32:20 +02:00
Eduard Bachmakov
7cc66df3ec nixos/systemd/initrd: Set /etc/hostname in the initrd.
With the the Systemd-based initrd, systemd-journald is doing the logging.
One of Journald's Trusted Journal Fields is `_HOSTNAME` (systemd.journal-fields(7)).
Without explicitly setting the hostname via this file or the kernel cmdline, `localhost` is used and captured in the journal.
As a result, a boot's log references multiple hostnames.
With centralized log collection this breaks filtering (more so when logs from multiple Systemd-based initrds are streaming in simultaneously.

Fixes #318907.
2024-08-10 11:16:25 +02: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