Commit graph

80 commits

Author SHA1 Message Date
Jörg Thalheim
51ecd58047 system.etc.overlay: build erofs also locally
images in etc tends to be small in size (mostly contains symlinks)
so it's not worth it to reach out to a remote builder for that.
2025-05-30 18:52:30 +02:00
isabel
00b6b1ffcc
nixos/etc-overlay: mark EROFS_FS kernel configuration option as required (#365450) 2025-05-29 09:42:43 +01:00
nikstur
3f4a4ffa18
nixos/etc-overlay: mount etc with nodev,nosuid (#406397) 2025-05-17 20:32:38 +02:00
r-vdp
a2f3516c24
nixos/etc-overlay: mount etc with nodev,nosuid 2025-05-12 10:35:18 +02:00
Sandro Jäckel
484b00be20
nixos/etc: remove rogue continue 2025-04-19 03:01:40 +02:00
Silvan Mosberger
374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
nikstur
2442d7afa9 nioxs/etc: improve docs for file ownership 2025-02-01 22:37:46 +01:00
github-actions[bot]
44e4abfaf6
Merge master into staging-next 2025-01-14 18:04:33 +00:00
r-vdp
e5b0c411a4
nixos/etc-overlay: fix chmod call in activation script
Fixes #373691
2025-01-14 13:55:35 +01:00
github-actions[bot]
507f7fe91e
Merge master into staging-next 2025-01-12 12:05:15 +00:00
Ramses
d24ca4701f
nixos/etc-overlay: make the etc overlay compatible with nixos-enter and nixos-install (#364239) 2025-01-12 09:05:57 +01:00
github-actions[bot]
3588b4d239
Merge staging-next into staging 2024-12-31 18:04:49 +00:00
Wolfgang Walther
255012c708
nixosTests.etc: fix with structuredAttrs
The NIX_ATTRS_SH_FILE needs to be available visible inside the
fakechroot environment, so that we can load it for structuredAttrs
support.
2024-12-29 18:36:48 +01:00
r-vdp
df7c405f32
nixos/etc-overlay: always create the metadata mountpoints in /run
This avoids the dependence on the presence of /tmp, which causes issues
with nixos-install
2024-12-17 00:18:43 +01:00
r-vdp
2187d1970e
nixos/etc-overlay: make the etc overlay compatible with nixos-enter and nixos-install
When using nixos-enter (and so also nixos-install) on a system with etc-overlay enabled,
he activation script gets called directly, and there is no systemd running.
This violates a couple of assumptions in the etc-overlay activation script which
assumed that it only ever ran when switching into a new generation and that
the very first /etc would always have been set up by the systemd initrd.

As more and more things are being moved into systemd components (initrd services,
mount units, tmpfiles, etc), I think that it is going to become increasingly
difficult to stay compatible with these tools, but at least for now there is
no real alternative and so we probably want to be able to install systems
with etc-overlay enabled.
2024-12-17 00:18:43 +01:00
andre4ik3
250359a4d5
nixos/etc-overlay: mark EROFS_FS kernel configuration option as required 2024-12-16 02:20:02 +04:00
Moritz Sanft
bf2f6de39d
nixos/etc-activation: only assert for 6.6 kernel in switchable systems
The assertion is based on the availability of `move-mount-beneath`, which is only used in re-activation logic for switchable systems. Systems that have `system.switch.enable == false` should be allowed to user older kernels.
2024-12-13 12:13:34 +01:00
Silvan Mosberger
667d42c00d treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev 57b193d8dd
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:27:17 +01:00
Silvan Mosberger
4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00
r-vdp
7d6602e7de
etc-overlay: mount the metadata image read-only
On recent kernels (> 6.12 ?) we get the following warning otherwise:
`mount: /tmp/nixos-etc-metadata.aHpRhO5sC4: WARNING: source write-protected, mounted read-only.`
2024-12-01 13:44:55 +01:00
Will Fancher
f065a81ab4 nixos/systemd-stage-1: Use chroot-realpath 2024-11-11 05:52:18 -05: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
Jörg Thalheim
15f80d9120
Improve assertions for etc.overlay and systemd-sysusers (#332516) 2024-09-23 17:01:30 +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
nikstur
4620067d79 nixos/userborn: init 2024-08-26 12:45:33 +02:00
nikstur
7845b89e24 nixos/etc: unmount old /etc hierarchy lazily
This should fix errors where /etc is reported to be busy and thus cannot
be unmounted.

Another solution we can consider if this doesn't work out as we expect
is to forcefully unmount /etc.
2024-08-22 12:17:20 +02:00
nikstur
d820fe987e nixos/etc: wantedBy -> requiredBy for mounting overlay etc
I've observed that sometimes the overlay mount unit does not get started
when using wantedBy. requiredBy makes this relationship stricter and if
necessary will restart the initrd-fs.target and thus ensure that when
this target is reached /etc has alredy been mounted. This is in line
with the description of initrd-fs.target in systemd.special:

> Thus, once this target is reached the /sysroot/ hierarchy is fully set up
2024-08-22 12:12:18 +02:00
nikstur
b87850d1d5 nixos/etc: remove assertion 2024-08-02 15:02:59 +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
Jared Baur
560cd874a3
nixos/etc: fix using etc overlay on cross-compiled systems
We need to run tooling from the build platform when generating the EROFS.
2024-06-26 19:50:24 -07:00
Jörg Thalheim
04efc006a4 etc.overlay: fix cross-build 2024-06-23 17:31:03 +02:00
ivan770
1b288bca00
nixos/etc: support direct symlinks with etc overlay 2024-05-25 08:41:24 -04:00
stuebinm
6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00
nikstur
5df8caced4 nixos/etc: make re-mounting /etc overlay idempotent 2024-02-21 22:54:00 +01:00
Dominik Xaver Hörl
97d6166176 nixos/etc: fix payload in build-composefs-dump for the file case 2024-02-19 23:27:34 +01:00
nikstur
a9161ceb5a nixos/etc: remove leading slash from target paths in build-composefs-dump.py
This is necessary so that duplicates in the composefs dump are avoided.
2024-01-28 13:37:23 +01:00
nikstur
92b98478a8 nixos/etc: fix type checking of build-composefs-dump.py 2024-01-28 01:58:56 +01:00
nikstur
60f529fc82 nixos/etc: optionally mount etc as an overlay 2024-01-22 00:54:13 +01:00
Sandro Jäckel
fadc824f20
nixos/etc: keep directories in derivation name
This changes eg. etc-timesyncd.conf to etc-systemd-timesyncd.conf which
better reflects the actual location of the config file.
2023-06-07 00:08:43 +02:00
Naïm Favier
37e42d01a0
nixos/etc: skip resolv.conf in nixos-enter chroot
nixos-enter sets up /etc/resolv.conf as a bind mount from the host
system, so trying to activate a system that sets
`environment.etc."resolv.conf"` (e.g. with systemd-resolved enabled)
results in an unhelpful warning.

Skip linking /etc/resolv.conf if we're in a nixos-enter environment, as
determined by the IN_NIXOS_ENTER environment variable.

Make the warnings more helpful, indicating which file we failed to link.

Unlink temporary files in case of failure.
2023-01-02 01:41:29 +01:00
Scott Bronson
4db7061162
Sort the /etc/.clean file
Without sorting, the contents of /etc/.clean are likely to change on
every nixos-rebuild due to Perl's nondeterministic hash key ordering.
2022-10-03 14:11:17 -07:00
pennae
860a0449ce nixos/system: invariant option docs MD conversions 2022-07-24 13:01:47 +02:00
Robert Hensing
9809e1575b nixos/etc.nix: Make independent
(cherry picked from commit 56c283e5c8)
2022-01-30 09:01:27 +01:00
Taeer Bar-Yam
0bef0c38f7 lib.modules: add mkDerivedConfig
mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b

Create config definitions with the same priority as the definition of another option.
This should be used for option definitions where one option sets the value of another as a convenience.
For instance a config file could be set with a `text` or `source` option, where text translates to a `source`
value using `mkDerivedConfig options.text (pkgs.writeText "filename.conf")`.

It takes care of setting the right priority using `mkOverride`.
2021-11-15 07:03:41 -05:00
Taeer Bar-Yam
0e590c91d2 etc module: make .text and .source the same priority
Before this change, one could set environment.etc.*.text and .source.
.source would always take precedence, regardless of the priorities set.
This change means that if, for instance, .text is set with mkForce but
.source is set normally, the .text content will be the one to take
effect. If they are set with the same priority they will conflict.
2021-11-14 18:47:09 -05:00
Maciej Krüger
f37f1b2d01
Merge pull request #130388 from oxalica/fix/etc-nixos-tag-in-activation 2021-11-04 15:26:17 +01:00
Naïm Favier
2ddc335e6f
nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00