Home Explore Blog CI



nixpkgs

nixos/doc/manual/development/etc-overlay.section.md
63cb63c2d732dea243ac0c18f9ff161855958e009f44e7ab00000003000004bd
# `/etc` via overlay filesystem {#sec-etc-overlay}

::: {.note}
This is experimental and requires a kernel version >= 6.6 because it uses
new overlay features and relies on the new mount API.
:::

Instead of using a custom perl script to activate `/etc`, you activate it via an
overlay filesystem:

```nix
{
  system.etc.overlay.enable = true;
}
```

Using an overlay has two benefits:

1. it removes a dependency on perl
2. it makes activation faster (up to a few seconds)

By default, the `/etc` overlay is mounted writable (i.e. there is a writable
upper layer). However, you can also mount `/etc` immutably (i.e. read-only) by
setting:

```nix
{
  system.etc.overlay.mutable = false;
}
```

The overlay is atomically replaced during system switch. However, files that
have been modified will NOT be overwritten. This is the biggest change compared
to the perl-based system.

If you manually make changes to `/etc` on your system and then switch to a new
configuration where `system.etc.overlay.mutable = false;`, you will not be able
to see the previously made changes in `/etc` anymore. However the changes are
not completely gone, they are still in the upperdir of the previous overlay in
`/.rw-etc/upper`.

Chunks
ed9f6c28 (1st chunk of `nixos/doc/manual/development/etc-overlay.section.md`)
Title: Using /etc via Overlay Filesystem
Summary
This section describes how to activate `/etc` using an overlay filesystem, which offers benefits such as removing a dependency on Perl and faster activation. The overlay can be mounted writable or read-only. Importantly, modified files in `/etc` will not be overwritten during system switches, and changes made before setting `system.etc.overlay.mutable = false` can be found in `/.rw-etc/upper`.