server-configs/shared/modules/state.nix

40 lines
888 B
Nix

{ config, lib, ... }:
with lib;
let
sources = import ./../sources/sources.nix;
in {
options.mine.state.enable = mkOption {
type = types.bool;
default = false;
};
imports = [
(sources.impermanence + "/nixos.nix")
];
config = mkIf config.mine.state.enable {
environment.persistence = {
root = {
persistentStoragePath = "/state/root";
files = [
"/etc/machine-id"
];
directories = [
"/var/lib/nixos"
"/var/log"
];
};
};
# fixes the following error, when trying to use impermanence
# in `/var/lib/private`, which is needed for DynamicUser.
# Error: Directory "/var/lib/private" already exists, but has mode 0755 that is too permissive (0700 was requested), refusing.
systemd.tmpfiles.rules = [
"d /var/lib/private 0700 root root - -"
];
};
}