[NonPersistence] add neededForBoot to /persist and /var/log, and verify that they exist

This commit is contained in:
Antoine Viallon 2022-01-25 12:05:14 +01:00
parent f4c1a39c8c
commit b358a3d72d
Signed by: aviallon
GPG key ID: 186FC35EDEB25716

View file

@ -8,10 +8,32 @@ in
enable = mkEnableOption "non-persitent root";
};
config = mkIf cfg.enable {
assertions = [
{ assertion = hasAttr "/persist" config.fileSystems;
message = "A /persist partition is needed for non-persistence";
}
{ assertion = hasAttr "/var/log" config.fileSystems;
message = "A /var/log separate parition is needed to avoid missing early logs.";
}
];
environment.etc = {
nixos.source = "/persist/etc/nixos";
NIXOS.source = "/persist/etc/NIXOS";
machine-id.source = "/persist/etc/machine-id";
};
fileSystems = {
"/var/log" = {
neededForBoot = true;
autoFormat = true;
label = "nixos-persistent-logs";
};
"/persist" = {
neededForBoot = true;
label = "nixos-persistent-data";
};
};
};
}