WIP: nixos: system: add persist
This is the module that takes care of configuring impermanence at the
system level.
WIP:
* address FIXMEs
* activate home-manager persistence?
* set `programs.fuse.userAllowOther = true;` ?
* point `age` to persisted paths [1] ?
* make sure all services and modules are persisted correctly...
[1]: b1d18d25b8
This commit is contained in:
parent
26495fc8b2
commit
5a0197922e
|
@ -9,6 +9,7 @@
|
||||||
./language
|
./language
|
||||||
./nix
|
./nix
|
||||||
./packages
|
./packages
|
||||||
|
./persist
|
||||||
./podman
|
./podman
|
||||||
./polkit
|
./polkit
|
||||||
./printing
|
./printing
|
||||||
|
|
65
modules/nixos/system/persist/default.nix
Normal file
65
modules/nixos/system/persist/default.nix
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
# Ephemeral root configuration
|
||||||
|
{ config, inputs, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.my.system.persist;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
inputs.impermanence.nixosModules.impermanence
|
||||||
|
];
|
||||||
|
|
||||||
|
options.my.system.persist = with lib; {
|
||||||
|
enable = mkEnableOption "stateless system configuration";
|
||||||
|
|
||||||
|
mountPoint = lib.mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "/persistent";
|
||||||
|
example = "/etc/nix/persist";
|
||||||
|
description = ''
|
||||||
|
Which mount point should be used to persist this system's files and
|
||||||
|
directories.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
files = lib.mkOption {
|
||||||
|
type = with types; listOf str;
|
||||||
|
default = [ ];
|
||||||
|
example = [
|
||||||
|
"/etc/nix/id_rsa"
|
||||||
|
];
|
||||||
|
description = ''
|
||||||
|
Additional files in the root to link to persistent storage.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
directories = lib.mkOption {
|
||||||
|
type = with types; listOf str;
|
||||||
|
default = [ ];
|
||||||
|
example = [
|
||||||
|
"/var/lib/libvirt"
|
||||||
|
];
|
||||||
|
description = ''
|
||||||
|
Additional directories in the root to link to persistent storage.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
environment.persistence."${cfg.mountPoint}" = {
|
||||||
|
files = [
|
||||||
|
"/etc/machine-id"
|
||||||
|
]
|
||||||
|
++ cfg.files
|
||||||
|
;
|
||||||
|
|
||||||
|
directories = [
|
||||||
|
"/etc/nixos"
|
||||||
|
"/var/log"
|
||||||
|
"/var/lib/nixos"
|
||||||
|
"/var/lib/systemd/coredump"
|
||||||
|
]
|
||||||
|
++ cfg.directories
|
||||||
|
;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue