2024-03-30 14:52:58 +01:00
|
|
|
{
|
|
|
|
inputs',
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
rollbackStart = pkgs.writeText "rollback-start" ''
|
|
|
|
${pkgs.rolling_datasets}/bin/roll_dataset "heater-ssd/ephemeral/home" "10"
|
|
|
|
${pkgs.rolling_datasets}/bin/roll_dataset "heater-ssd/ephemeral/root" "10"
|
|
|
|
${pkgs.rolling_datasets}/bin/roll_dataset "heater-ssd/ephemeral/nix-tmp" "10"
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
inputs'.self.overlays.show-files-to-be-deleted
|
|
|
|
inputs'.self.overlays.rolling_datasets
|
|
|
|
];
|
|
|
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
pkgs.show-files-to-be-deleted
|
|
|
|
];
|
|
|
|
|
|
|
|
environment.persistence."/nix/persist" = {
|
|
|
|
hideMounts = true;
|
|
|
|
|
|
|
|
directories = [
|
|
|
|
"/var/log"
|
|
|
|
"/var/lib/nixos"
|
|
|
|
"/var/lib/systemd/coredump"
|
2024-04-13 19:38:04 +02:00
|
|
|
"/var/lib/arma3"
|
2024-03-30 14:52:58 +01:00
|
|
|
];
|
|
|
|
files = [
|
|
|
|
"/etc/machine-id"
|
|
|
|
"/etc/ssh/ssh_host_rsa_key"
|
|
|
|
"/etc/ssh/ssh_host_rsa_key.pub"
|
|
|
|
"/etc/ssh/ssh_host_ed25519_key"
|
|
|
|
"/etc/ssh/ssh_host_ed25519_key.pub"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
boot.initrd.systemd.storePaths = with pkgs; [
|
|
|
|
zfs
|
|
|
|
busybox
|
|
|
|
rolling_datasets
|
|
|
|
rollbackStart
|
|
|
|
];
|
|
|
|
boot.initrd.systemd.services.rollback = {
|
|
|
|
description = "Rollback ZFS datasets to a pristine state";
|
|
|
|
wantedBy = [
|
|
|
|
"initrd.target"
|
|
|
|
];
|
|
|
|
after = [
|
|
|
|
"zfs-import-heater-ssd.service"
|
|
|
|
];
|
|
|
|
before = [
|
|
|
|
"sysroot.mount"
|
|
|
|
];
|
|
|
|
path = with pkgs; [
|
|
|
|
zfs
|
|
|
|
busybox
|
|
|
|
];
|
|
|
|
unitConfig.DefaultDependencies = "no";
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
serviceConfig.ExecStart = "/bin/sh ${rollbackStart}";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services."mount-old-datasets" = {
|
|
|
|
description = "Mount old versions of datasets";
|
|
|
|
|
|
|
|
wantedBy = ["local-fs.target"];
|
|
|
|
after = ["local-fs.target"];
|
|
|
|
|
|
|
|
script = ''
|
|
|
|
${pkgs.rolling_datasets}/bin/mount_datasets "heater-ssd/ephemeral/home" "/home/.old"
|
|
|
|
${pkgs.rolling_datasets}/bin/mount_datasets "heater-ssd/ephemeral/root" "/root/.old"
|
|
|
|
${pkgs.rolling_datasets}/bin/mount_datasets "heater-ssd/ephemeral/nix-tmp" "/nix/tmp/.old"
|
|
|
|
'';
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
TimeoutStartSec = "5m";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|