Commit Graph

125 Commits

Author SHA1 Message Date
Maximilian Bosch
a532cb052e nixos/containers: add boot.isNspawnContainer option
There are a bunch of components such as incus or LXC that also use
`boot.isContainer`, so we'd have to differentiate between "OS container"
and "actually nspawn".

This became necessary for the file-systems part where nspawn takes care
of setting up special filesystems like `/proc`, `/dev` etc., but others
don't.

To allow for a `boot.isContainer` being less overloaded, this introduces
`boot.isNspawnContainer` that is exclusively used for nspawn-specific
things. When `true`, `boot.isContainer = true;` is implied.
2025-09-21 13:26:23 +02:00
Nikita Uvarov
4de40fc8a8 nixos/filesystems: fix special file-systems for systemd-nspawn
This is a subset of aba55d1b960b4b1817bc2a32deeba447ae51f0a3 (#67336)[1]
that I (Ma27) am using for quite a while in my systemd-nspawn setup
(without `nixos-container`) to have unprivileged containers.

Recently, Linus reminded me that this isn't part of upstream NixOS and
their setup fails like this when activating config in an nspawn
instance (no shared store):

    stderr) activating the configuration...
    stdout) setting up /etc...
    stderr) mount: /dev: permission denied.
    stderr)        dmesg(1) may have more information after failed mount system call.
    stderr) mount: /dev/pts: permission denied.
    stderr)        dmesg(1) may have more information after failed mount system call.
    stderr) mount: /dev/shm: permission denied.
    stderr)        dmesg(1) may have more information after failed mount system call.
    stderr) mount: /run: permission denied.
    stderr)        dmesg(1) may have more information after failed mount system call.
    stdout) Activation script snippet 'specialfs' failed (32)

So I decided to submit this portion again.

[1] Hence I retained the original authorship.

Co-authored-by: Maximilian Bosch <maximilian@mbosch.me>
2025-09-21 13:26:23 +02:00
Colin
a3e64d8d08 nixos: Elaborate documentation for fileSystems.* options (#405043) 2025-08-15 19:01:06 +00:00
nikstur
0d9a5c2059 nixos/fuse: add enable option
Fuse is stil enabled by default so the default behaviour of NixOS
doesn't change. However, now it's possible to actively exclude fuse when
you don't need it.
2025-08-10 22:43:39 +02:00
nikstur
d5ae87bdeb Revert "nixos: allow more things to be disabled" 2025-08-10 22:22:08 +02:00
Arian van Putten
1bb040fae8 nixos: allow more things to be disabled (#429695) 2025-08-10 19:49:52 +02:00
nikstur
e9c71d971f nixos/filesystem: remove mount-pstore
Ever since fb49d81b25 we set
CONFIG_PSTORE=y in the config because we set CONIFG_ACPI_APEI=y in the
kernel. This means we always have pstore built right into the kernel.

systemd thus always mounts `/sys/fs/pstore` which makes our custom unit
superfluous and redudant.
2025-08-08 19:03:05 +02:00
nikstur
eca55074cb nixos/fuse: add enable option
Fuse is stil enabled by default so the default behaviour of NixOS
doesn't change. However, now it's possible to actively exclude fuse when
you don't need it.
2025-07-31 20:42:36 +02:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
K900
7e4f0fbf9d Merge remote-tracking branch 'origin/master' into staging-next 2025-06-06 21:50:43 +03:00
Johannes Kirschbauer
6e25d9885f nixos/filesystems: chore replace 'with' statements 2025-06-06 11:07:10 +02:00
Robert Hensing
3dd811c4b9 lib.types.attrNamesToTrue: unpublish temporarily
Thank you for making this change.
Unfortunately, and I take blame for this, this change to the module
system was not reviewed and approved by the module system maintainers.
I'm supportive of this change, but extending it on the staging-next
branch is not the right place.
This commit is also here to make sure that we don't run into conflicts
or other git trouble with the staging workflow.

Review:
It looks alright, but it didn't have tests yet, and it should be
considered in a broader context where the existence of this type
creates an incentive to be used in cases where the `<attr> = false;`
case is undesirable. I'd like to complement this with an type that
has `<attr> = {};` only.

My apologies for the lack of a timely and clear review. Often we
recommend to define the type outside the module system until
approved. This commit puts us back in that state.

attrNamesToTrue was introduced in 98652f9a90
2025-05-16 11:52:36 +02:00
Will Fancher
98652f9a90 nixos/kernel: Allow controlling modules with attrsets 2025-05-15 00:00:56 -04:00
Shelvacu
f886d71d7b nixos: Elaborate documentation for fileSystems.* options 2025-05-07 13:02:00 -07: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
Shawn8901
faadb5162c nixos/fileSystems: omit swap comment if there are no swapDevices 2025-02-23 23:23:32 +01:00
Sandro Jäckel
4a1cad4c46 nixos/filesystems: remove unused variable 2025-02-23 22:01:44 +01:00
Peder Bergebakken Sundt
15391ccd3e nixos/fileSystems: fix mount(8) manpage links 2025-01-27 01:03:14 +01:00
Peder Bergebakken Sundt
f259802ac7 nixos/fileSystems: link to mount(8) from fileSystems.*.options 2025-01-27 01:02:27 +01:00
Will Fancher
764082c095 nixos/fileSystems: add enable option (#301915) 2025-01-05 17:40:23 -05:00
r-vdp
b6dbf6deed nixos/filesystems: assert that the device and label options are consistent 2024-12-09 02:52:24 +03:00
r-vdp
9226d4e9ee nixos/filesystems: don't silently ignore label when device is set
Before this change, when both device and label were set, the label would
be silently ignored. This is especially problematic when the device is
set in another module, and it's not immediately obvious why the label is
not having any effect.

Additionally, some other modules use the device option to get the device
of a filesystem, but this option is not populated when only the label is
set, causing those modules to conclude that the filesystem does not have
a backing device.

With this change, we populate the device option using the label when the
label is set. This means that we get a clear error message when both the
device and label are set, and that the device is properly populated
whenever the label is used to specify the backing device.
2024-12-03 11:45:42 +01:00
Will Fancher
b7c5fd93f1 nixos: Support fileSystems.<name>.depends with fstab-generator 2024-08-30 15:18:35 -04:00
Jared Baur
43d8f47df3 nixos/fileSystems: add enable option
Add the ability to disable filesystems set in a nixos config (enabled by
default). This makes the submodules under `fileSystems` behave more like
submodules in other nixos modules.
2024-04-20 16:50:45 -07: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
Attila Oláh
ac4441fabd Add missing closing parens.
https://xkcd.com/859
2024-03-02 12:40:40 +01:00
pennae
258b935d70 nixos/filesystems: make supportedFilesystems an attrset
this lets us *dis*able filesystem explicitly, as is required by e.g. the
zfs-less installer images. currently that specifically is only easily
possible by adding an overlay that stubs out `zfs`, with the obvious
side-effect of also removing tooling that could run without the kernel
module loaded.
2024-02-19 11:46:52 +01:00
Philip Taron
9c505de9f4 nixos/filesystems: ensure correct ordering w.r.t. shutdown.target 2023-11-30 15:34:11 -08:00
Nick Cao
37cac5f032 nixos/stage-1-systemd: makeFstabEntries: drop rootPrefix parameter 2023-09-27 18:31:56 -04:00
Nick Cao
0fecd7edc8 nixos/stage-1-systemd: fix initrd-fstab generation for bind mounts, again
See https://github.com/NixOS/nixpkgs/pull/185089
2023-09-27 14:34:17 -04:00
Will Fancher
b497502357 nixos: Use systemd-growfs for autoResize 2023-06-04 22:57:22 -04:00
Will Fancher
5176a4f113 nixos: Use systemd-makefs for autoFormat 2023-06-04 22:57:20 -04:00
Matthias Berndt
92814241a8 improve stratis initrd support
it is now possible to supply a stratis pool uuid
for every filesystem, and if that filesystem
is required for boot, the relevant pool will be
started in the initramfs.
2023-05-16 22:48:36 -04:00
Felix Buehler
327b0cff7a treewide: use more lib.optionalString 2023-04-07 13:38:33 +02:00
Will Fancher
14b77582da systemd-stage-1: fsck 2023-02-08 00:43:10 -05:00
Will Fancher
1b39491326 systemd-stage-1: Use x-initrd.mount for better unit dependencies 2023-02-07 22:22:39 -05:00
Lily Foster
8b4fd74782 nixos/filesystems: require fstab options list be non-empty
When the option list is empty, the fstab generator does not
automatically add "defaults" and generates a non-working fstab (since it
just emits two spaces around where the options would have been which is
only technically one fstab separator).
2022-12-26 17:11:05 +01:00
Vladimír Čunát
cdad0ce127 nixos/filesystems: fix a typo in docs 2022-11-27 21:57:35 +01:00
Martin Weinelt
c021df5792 Merge pull request #197254 from Atemu/fstab-escape-options 2022-11-19 18:08:40 +01:00
Will Fancher
acecd1ec7b Revert "nixos: Fix fsck with systemd 251.6 and later"
This reverts commit d9b1bde390.
2022-11-15 17:45:38 -05:00
aszlig
d9b1bde390 nixos: Fix fsck with systemd 251.6 and later
Version 251.6 of systemd introduced a small change[1] that now checks
whether the fsck command is available in *addition* to the filesystem
specific fsck.$fsname executable.

When bumping systemd to version 251.7 on our side[2], we introduced that
change. This subsequently caused our "fsck" test to fail and it looks
like this was an oversight during the pull request[3] introducing the
bump.

Since the fsck wrapper binary is in util-linux, I decided to address
this by adding util-linux to fsPackages because util-linux is already
part of the closure of any NixOS system so the impact should be pretty
low.

[1]: 73db7d9932
[2]: 844a08cc06
[3]: https://github.com/NixOS/nixpkgs/pull/199618

Signed-off-by: aszlig <aszlig@nix.build>
2022-11-15 02:15:54 +01:00
Bjørn Forsman
3ec90ef87f nixos/filesystems: add nfs4 to fsToSkipCheck
This change fixes this system journal warning for
`fileSystems.<name>.fsType = "nfs4"` configurations:

  systemd-fstab-generator[714]: Checking was requested for "192.168.0.6:/data", but it is not a device.
2022-10-23 20:08:08 +02:00
Atemu
7e2aec079c nixos/filesystems: escape mount options in fstab
Some mount options might include path names and those often contain spaces and
therefore must be escaped. An example which prompted me to make this change is
the path of a btrfs subvolume.
2022-10-22 20:00:56 +02:00
pennae
9547123258 nixos/*: convert internal option descriptions to MD
we'll have to do it eventually, may as well be now.
2022-08-31 16:32:54 +02:00
Will Fancher
2239c5d55f Merge pull request #186163 from lilyinstarlight/feature/systemd-stage-1-fs-label
nixos/systemd-stage-1: unify initrd fstab generation logic with system fstab
2022-08-20 18:29:07 -04:00
pennae
6039648c50 nixos/*: automatically convert option docs 2022-08-19 22:40:58 +02:00
pennae
e4ed177f82 nixos/* eliminate inner whitespace in tags that was missed earlier
nix-doc-munge won't match tags that contain newlines anywhere. most of
these have already been removed, but a few obviously made it through.
2022-08-19 22:40:58 +02:00
Lily Foster
69d7943101 nixos/systemd-stage-1: unify initrd fstab generation logic with system fstab 2022-08-18 13:33:43 -04:00
Luflosi
dd80fa1e9b nixos/filesystems: skip fsck for more filesystems
This commit prevents warning messages like
```
systemd-fstab-generator: Checking was requested for "/path/to/device", but it is not a device.
```
in `dmesg` when one of the filesystems 9p, cifs, prl_fs or vmhgfs is added to the list of `fileSystems`.
This happens because the generated /etc/fstab entry contains a non-zero fsck pass number, which doesn't make sense for these filesystems.
2022-08-06 15:21:57 +02:00
pennae
2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00