nixos/modules/base/impermanence.nix

34 lines
1.3 KiB
Nix
Raw Normal View History

2023-08-04 13:08:58 +02:00
{ impermanence, pkgs, ... }: {
2023-08-01 15:35:09 +02:00
# The impermanence module bind-mounts persistent files and directories, stored in /nix/persist, into the tmpfs root
# partition on startup. For example: /nix/persist/etc/machine-id is mounted to /etc/machine-id.
# https://github.com/nix-community/impermanence
# https://nixos.wiki/wiki/Impermanence
imports = [
impermanence.nixosModules.impermanence
];
# We *don't* want to use tmpfs for /tmp in case we have to put big files there. Instead, we mount it to the disk and
# instruct systemd to clean it on boot.
boot.tmp.cleanOnBoot = true;
environment.persistence."/nix/persist" = {
hideMounts = true;
directories = [
2023-08-01 16:16:34 +02:00
{ directory = "/etc/NetworkManager/system-connections"; user = "root"; group = "root"; mode = "0700"; }
2023-08-01 16:55:53 +02:00
{ directory = "/tmp"; user = "root"; group = "root"; mode = "1777"; } # see comment above
2023-08-01 15:35:09 +02:00
# With great power comes great responsibility, we get it
{ directory = "/var/db/sudo/lectured"; user = "root"; group = "root"; mode = "0700"; }
{ directory = "/var/log"; user = "root"; group = "root"; mode = "0755"; }
];
files = [
2023-08-01 16:55:53 +02:00
"/etc/machine-id" # needed for /var/log
2023-08-01 15:35:09 +02:00
];
users.caspervk = {
directories = [
2023-08-01 16:55:53 +02:00
"/" # entire home directory
2023-08-01 15:35:09 +02:00
];
};
};
}