Commit graph

2898 commits

Author SHA1 Message Date
Peder Bergebakken Sundt bbb6e83f51 nixos/binfmt: add option addEmulatedSystemsToNixSandbox 2024-11-08 17:31:06 +01:00
Sandro 38ea21bd5d
Don't run hwclock if /etc/ is not writable (#353320) 2024-11-06 18:25:41 +01:00
nikstur 0c02b3076c
nixos/etc-overlay: clean up temporary directories (#339802) 2024-11-05 17:13:27 +01:00
Aleksana 81dacf0c91
nixos/systemd: fix enableStrictShellChecks description (#348513) 2024-11-05 23:03:19 +08:00
Will Fancher 5d9ac94606 nixos/activation-script: Make installBootLoader default a script
Fixes #344535
2024-11-04 04:12:52 -05:00
Samuel Tardieu 114ef67cbb Don't run hwclock if /etc/ is not writable 2024-11-03 10:42:21 +01:00
Matt Perlman 42ac7b2428 nixos/networkd: add dhcpServerConfig.PersistLeases option
PersistLeases was added to networkd version 256 (https://www.freedesktop.org/software/systemd/man/latest/systemd.network.html#PersistLeases=)
2024-11-02 13:55:14 -04:00
Will Fancher 37ee6ba681 Revert "NixOS apply script"
Reverts #344407

This has broken nixos-rebuild switch so that it no longer updates the profile, which has bad consequences including not updating the systemd-boot menu with new generations.
2024-11-01 20:18:09 -04:00
Christian Kögler 209e69f969
networkd: add missing option SendHostname and Hostname for dhcpV6Config (#348306) 2024-11-01 21:49:04 +01:00
Aleksana 2a3dc3d608
nixos/unl0kr: fix runaway example (#352516) 2024-10-31 16:06:36 +08:00
Sandro 61ee09bc5f
nixos/unl0kr: fix runaway example
We intend with 2 spaces
2024-10-31 02:52:33 +01:00
Yureka 0f216e2578 tree-wide: switch initrd generators back to gnu cpio
Originally, we switched to bsdtar from libarchive to solve a reproducibility issue related to hardlinks

As of gnu cpio 2.14 the --ignore-dirnlink option is introduced and now included in --reproducible, which solves this issue

By switching back, we are in turn solving an issue in libarchive >=3.7.5 erroring out with "Error reading archive -: (null)"

Change-Id: Ib6140d599b6547d8e941b0251ce996e303c41fa6
2024-10-31 01:21:59 +01:00
Robert Hensing 514ea18006 nixos: Update s-t-c and apply help text 2024-10-30 00:23:37 +01:00
Robert Hensing 7902cea1de nixos: Update documentation to refer to bin/apply 2024-10-30 00:21:21 +01:00
Robert Hensing 6427500989 nixos/toplevel: Add bin/apply 2024-10-30 00:21:20 +01:00
Emily 7f753fb746
nixos/systemd: Enable systemd-machine-id-commit.service (#351151) 2024-10-26 15:56:09 +01:00
Frédéric Christ 8f4b41cfd4 nixos/systemd: Enable systemd-machine-id-commit.service
Prior to this contribution, every boot with a default configuration was
considered `ConditionFirstBoot=true` by systemd, since /etc/machine-id
was not commited to disk.

This also extends the systemd with a check for subsequent boots not
being considered first boots.
2024-10-25 14:03:15 +02:00
Jared Baur 9bbef50e24
nixos/switchable-system: add evaluation warning when using perl stc 2024-10-24 08:50:51 -07:00
Jared Baur 81f92fbc29
nixos/switchable-system: nixfmt 2024-10-24 06:22:58 -07:00
K900 c42028339a nixos/systemd-boot: fix substituteAll usage
Missed this one :(
2024-10-20 21:45:57 +03:00
Will Fancher 594ac9011f
nixos/systemd-initrd: add missing kmod-blacklist src (#348505) 2024-10-17 15:46:51 -04:00
Paul Meyer 71c64f8ecc initrd: drop effectless modification of kmod-blacklist
The perl snippet as been added years ago. I assume the intention was to
remove the `## file: iwlwifi.conf` section up to the next `## file:`,
but as there is no file following, the snippet currently does nothing.
We should be fine to remove it.

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
2024-10-17 16:23:01 +02:00
r-vdp 0f786baf5d
etc: remove unneeded temporary directions after putting in place the new etc 2024-10-16 22:22:58 +02:00
r-vdp a2d4cea96e
etc: rename the temporary dirs so that they are recognisable
This makes it a lot easier to understand which dir is which
2024-10-16 22:22:58 +02:00
r-vdp 24bf6e9cb8
nixos/etc-overlay: avoid rebuilding the initrd every time the etc contents change
Before this change, the hash of the etc metadata image was included in
the mount unit that's responsible for mounting this metadata image in the
initrd.
And because this metadata image changes with every change to the etc
contents, the initrd would be rebuild every time as well.
This can lead to a lot of rebuilds (especially when revision info is
included in /etc/os-release) and all these initrd archives use up a lot of
space on the ESP.

With this change, we instead include a symlink to the metadata image in the
top-level directory, in the same way as we already do for things like init and
prepare-root, and we deduce the store path from the init= kernel parameter,
in the same way as we already do to find the path to init and prepare-root.

Doing so avoids rebuilding the initrd all the time.
2024-10-16 17:42:58 +02:00
r-vdp 763dc50b08
nixos/systemd-initrd: pull the logic to find the nixos closure into a separate service 2024-10-16 17:42:50 +02:00
Will Fancher a6e54f566a
nixos/networkd: support systemd-creds in WireGuard (#346964) 2024-10-15 14:31:27 -04:00
Sandro eafd968bfd
nixos/systemd: fix enableStrictShellChecks description 2024-10-14 13:17:29 +02:00
Paul Meyer 2f6e0c8de3 nixos/systemd-initrd: add missing kmod-blacklist src
Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
2024-10-14 11:34:27 +02:00
Christian Kögler 5082384e7d networkd: add missing option SendHostname and Hostname for dhcpV6Config 2024-10-13 18:44:25 +02:00
Atemu 12ef18d2e3
nixos/systemd-boot: Simpler windows dual booting (#344327) 2024-10-11 20:25:08 +02:00
Felix Uhl 73011ba96f nixos/systemd-boot: add windows option for easy dual-booting
When installing NixOS on a machine with Windows, the "easiest" solution
to dual-boot is re-using the existing EFI System Partition (ESP), which
allows systemd-boot to detect Windows automatically.

However, if there are multiple ESPs, maybe even on multiple disks,
systemd-boot is unable to detect the other OSes, and you either have to
use Grub and os-prober, or do a tedious manual configuration as
described in the wiki:
https://wiki.nixos.org/w/index.php?title=Dual_Booting_NixOS_and_Windows&redirect=no#EFI_with_multiple_disks

This commit automates and documents this properly so only a single line
like

    boot.loader.systemd-boot.windows."10".efiDeviceHandle = "HD0c2";

is required.

In the future, we might want to try automatically detecting this
during installation, but finding the correct device handle while the
kernel is running is tricky.
2024-10-11 10:56:02 +02:00
Felix Uhl f2e5b04c4e nixos/systemd-boot: add edk2-uefi-shell boot option
We already have a edk2-uefi-shell package in nixpkgs, but adding it to
systemd-boot was somewhat tedious. Now it's a single line of nix.
2024-10-11 10:53:42 +02:00
Felix Uhl 548206583d nixos/systemd-boot: autoformat 2024-10-11 10:53:38 +02:00
Arian van Putten a4008da2d4 nixos/systemd-boot: Don't write to /etc/machine-id
This reverts commit 4daccf208f

The reverted commit claims that bootctl fails if machine-id is not set.
I can not reproduce this. I think this has since been fixed now that
bootctl has support for arbtirary entry-tokens and not just machine-id.

In the case of NixOS the entry-token is the string "nixos"
2024-10-09 15:34:34 +02:00
r-vdp 2b224f0e3c
nixos/systemd: allow using writeShellApplication for systemd unit scripts 2024-10-08 12:01:48 +02:00
Florian Klink 9c13bad7ca
nixos/tmpfiles: only setup nix-related tmpfiles if nix is enabled (#343784) 2024-10-07 09:11:46 +03:00
James Atkins 42f5ecde9d nixos/networkd: support systemd-creds in WireGuard
systemd 256 supports network.wireguard.* credentials (https://github.com/systemd/systemd/pull/30826).
Check whether PrivateKey / PresharedKey starts with an @, if so it is a credential.
2024-10-06 18:38:40 -05:00
Will Fancher c00fc8bd1a
nixos/unl0kr: add settings to the unl0kr module (#339787) 2024-10-06 17:44:55 -04:00
Jared Baur c39781c558
nixos/activation-script: only setup nix tmpfiles if nix is enabled
If nix is not installed on the end system, the tmpfiles settings related
to it do not need to be setup.
2024-10-05 09:03:19 -07:00
Jared Baur 3d6e7d7b56
nixos/tmpfiles: only setup nix tmpfiles when nix is used
If nix is not installed on the end system, the tmpfiles settings related
to it do not need to be setup.
2024-10-05 09:01:55 -07:00
Will Fancher 3e90d5a2bc nixos/systemd-stage-1: Don't enable TPM2 on scripted stage 1 2024-10-04 19:50:46 -04:00
Sandro d44717c448
nixos/binfmt: Add option to use static emulators when available (#334859) 2024-10-02 15:51:30 +02:00
Florian Klink b66c0f2e99
nixos/systemd: let systemd setup /etc/machine-id (#327552) 2024-10-01 15:05:59 +03:00
Zhaofeng Li b8c1ef98e4 nixos/binfmt: Add option to use static emulators when available
The fixBinary flag will be enabled if a static emulator is in use.
2024-10-01 15:05:32 +09:00
h7x4 0d67767718
nixos/networkd: add DHCPv4 - IPv6OnlyMode toggle (#343605) 2024-10-01 01:33:24 +02:00
Jörg Thalheim 028b7d27a3
growpart: shellcheck fixes (#340490) 2024-09-28 09:50:11 +02:00
Jörg Thalheim 4f06ecd5a6
systemd/initrd: fix shellcheck issues (#340486) 2024-09-28 09:48:29 +02:00
Will Fancher ea2838e1ce
nixos/qemu-vm: Ensure 9pnet_virtio module is loaded for shared dirs (#343574) 2024-09-25 23:11:08 -04:00
Will Fancher 1f34534920
Systemd tpm fixes (#343307) 2024-09-25 17:17:57 -04:00
Hustler One 29449deaf7 Add more options to unl0kr 2024-09-25 18:01:10 +02:00
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00
Alois Wohlschlager 59ca239d1a replaceDirectDependencies: split off from replaceDependencies
This allows both swapping out and reusing the rewrite machinery.
2024-09-24 12:20:15 +02:00
Alois Wohlschlager 63d6a7037c nixos/top-level: wire up cutoffPackages for replaceDependencies
Move replaceRuntimeDependencies to the replaceDependencies namespace,
where the structure is more consistent with the replaceDependencies
function. This makes space for wiring up cutoffPackages as an option
too.

By default, the system's initrd is excluded. The replacement process does not
work properly anyway due to the structure of the initrd (the files being copied
into it, and it being compressed). In the worst case (which has been observed
to actually occur in practice), a store path makes it into the incompressible
parts of the archive, checksums are broken, and the system won't boot.
2024-09-24 12:20:15 +02:00
Alois Wohlschlager d3abae8dee nixos/top-level: improve replaceRuntimeDependencies
Instead of iterating over all replacements and applying them one by one,
use the newly introduced replaceDependencies function to apply them all
at once for replaceRuntimeDependencies. The advantages are twofold in
case there are multiple replacements:
* Performance is significantly improved, because there is only one pass
  over the closure to be made.
* Correctness is improved, because replaceDependencies also replaces
  dependencies of the replacements themselves if applicable.

Fixes: https://github.com/NixOS/nixpkgs/issues/4336
2024-09-24 12:20:15 +02:00
Jörg Thalheim 15f80d9120
Improve assertions for etc.overlay and systemd-sysusers (#332516) 2024-09-23 17:01:30 +02:00
Will Fancher f0d7076c6a nixos/systemd-stage-1: Include modprobe@.service 2024-09-21 16:37:47 -04:00
Tom Herbers 342a47f9bc
nixos/networkd: add DHCPv4 - IPv6OnlyMode toggle
The option was introduced in systemd version 255.

https://www.freedesktop.org/software/systemd/man/latest/systemd.network.html#IPv6OnlyMode=
2024-09-21 02:11:00 +02:00
Will Fancher a0165bd5af nixos/systemd/tpm2: Enable tpm2-setup and tpm2.target
tpm2.target was functionally useless without these services and this
generator. When systemd-cryptsetup-generator creates
systemd-cryptsetup@.service units, they are ordered after
systemd-tpm2-setup-early.service, not tpm2.target. These services are
themselves ordered after tpm2.target.

Note: The systemd-tpm2-setup(-early) services will serve no *function*
under a normal NixOS system at the moment. Because of their
ConditionSecurity=measured-uki, they will always be skipped, unless
you are building an appliance with the system.build.uki feature. Thus,
these are enabled solely for their systemd unit ordering properties.
2024-09-20 14:33:36 -04:00
Will Fancher 5034450095 nixos/systemd: Factor out tpm2 support into separate module 2024-09-20 14:33:35 -04:00
Moritz Sanft 5ee6467bd3
nixos: add support for dm-verity
Co-authored-by: nikstur <nikstur@outlook.com>
Co-authored-by: WilliButz <willibutz@posteo.de>
2024-09-20 13:03:10 +02:00
Jörg Thalheim d66f976cee
nixos/generic-extlinux-compatible: add mirroredBoots option (#335131) 2024-09-18 14:08:31 +02:00
Felix Buehler a83ffb43de nixos/boot.tmp: remove with lib; 2024-09-15 10:43:58 +02:00
Felix Buehler 2f7c0a170f nixos/boot.loader.efi: remove with lib; 2024-09-15 10:43:58 +02:00
Felix Buehler 0a51fdb520 nixos/systemd.enableEmergencyMode: remove with lib; 2024-09-15 10:43:57 +02:00
Felix Buehler 91cb7594d0 nixos/boot.initrd.clevis: remove with lib; 2024-09-15 10:43:57 +02:00
Jean-François Roche 251b0c958f nixos/systemd-boot: Fix regression in builder script
Avoid running Python scripts in the root of the package, as this
triggers `os.listdir` on the Nix store directory during import. This
operation can be time-consuming on large store directories
(see issue #283795 for more details).

The issue was initially fixed in #284153 but was reverted in #306339.

Co-authored-by: Sönke Hahn <soenkehahn@gmail.com>
2024-09-12 01:29:32 +02:00
Rick van Schijndel cbf48cea2d
activation: avoid error due to unset PATH variable (#340488) 2024-09-10 21:58:24 +02:00
Nicolas Mémeint 47177c0ec9 nixos/luksroot: Exit if EOF detected 2024-09-10 21:12:17 +02:00
Artturin 833c74afa4
kexec: fix shellcheck issues (#340487) 2024-09-09 23:38:36 +03:00
K900 a9c0a2e2a1
nixos/tests: don't include switch-to-configuration in DUT by default (#340445) 2024-09-09 16:20:41 +03:00
Petr Hodina a9f77c2fb0 systemd-boot: Add option for consoleMode to support SteamDeck 2024-09-08 22:48:21 +02:00
K900 7771e0b943 nixos/specialisation: add isSpecialisation option to know if we're a specialisation 2024-09-08 17:04:44 +03:00
r-vdp 7d664c0ac1
growpart: shellcheck fixes 2024-09-08 12:28:46 +02:00
r-vdp e2db383cb6
activation: avoid error due to unset PATH variable 2024-09-08 12:27:06 +02:00
r-vdp 955e3cd8fe
kexec: fix shellcheck issues 2024-09-08 12:26:22 +02:00
r-vdp a236941ad0
systemd/initrd: fix shellcheck issues 2024-09-08 12:25:17 +02:00
Emily 56dea6da87 nixos: switch to switch-to-configuration-ng by default
The Rust `switch-to-configuration-ng` rewrite was carefully written
to be compatible with the original Perl script, has been checked
against NixOS VM tests, and has been available on an opt‐in basis
for testing for the 24.05 release cycle.

The next step towards replacing the Perl script entirely is to
switch it on by default so that we can get real‐world testing from
a much greater number of users. Maintaining two implementations in
parallel is becoming a burden; we are having to adjust the systemd
service activation behaviour slightly to fix a long‐standing bug,
and backporting the changes to the Perl script is an unpleasant
process. We will do it anyway to ensure that the Rust and Perl
implementations keep parity with each other throughout the 24.11
release cycle, but we think the time has come to flip the switch.

Taking this step now will give us two to three months to test this in
the wild before the 24.11 release and gain confidence that there are
no regressions. If any non‐trivial problems arise before the final
release, we will revert to the Perl implementation by default. Doing
this switch ASAP will help to disentangle any problems that might
arise from the Rust implementation from problems that arise from the
systemd service activation changes, or the upcoming switch to using
systemd in stage 1 by default.

The main concern that was raised about replacing the Perl script in the
PR that added `switch-to-configuration-ng` was that it is currently
possible to run NixOS on systems that cannot natively host a Rust
compiler. This does not apply to any platforms that have official
support from NixOS, and as far as I know we do not know of any such
systems with users that are not cross‐compiling anyway.

My understanding is that these systems are already broken by default
anyway, as `systemd.shutdownRamfs.enable` is on by default and uses
`make-initrd-ng`, which is also written in Rust. Switching the default
while keeping the Perl implementation around will give us at least
an entire release cycle to find out if there are any users that will
be affected by this and decide what to do about it if so.

There is currently one known inconsistency between
the Perl and Rust implementations, as documented in
<https://github.com/NixOS/nixpkgs/issues/312297>; the Rust
implementation has more accurate handling of failed systemd units.

We slightly adjust the semantics of `system.switch.enable{,Ng}` to
not conflict with each other, so that `system.switch.enableNg` is
on by default, but turning off `system.switch.enable` still results
in no `switch-to-configuration` implementation being used. This
won’t break the configuration of anyone who already opted in to
`system.switch.enableNg` and is probably how the option should have
worked to begin with.
2024-09-06 08:35:43 +01: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
Luflosi 93fb96ecde
nixos/generic-extlinux-compatible: add mirroredBoots option
Analogous to `boot.loader.grub.mirroredBoots`.
This allows installing the configuration files to multiple locations.
2024-09-04 12:02:57 +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
Philip Taron 9916dc8728
treewide/nixos: remove with lib; part 2 (#335618) 2024-08-30 15:56:57 -07:00
Felix Buehler 10e8c2cecd nixos/environment.etc: remove with lib; 2024-08-30 23:01:45 +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
WilliButz c169763c30
userborn: init at 0.1.0 (#332719) 2024-08-30 12:22:54 +02:00
Will Fancher bf19362974
nixos/systemd-boot: use unique path for devicetree blob (#336263) 2024-08-28 12:36:20 -04:00
nikstur 4620067d79 nixos/userborn: init 2024-08-26 12:45:33 +02: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