Fix restoring snapshot on boot
This commit is contained in:
parent
9a25143a9b
commit
0544defe93
7 changed files with 24 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
config = lib.mkIf config.chvp.base.zfs.enable {
|
||||
|
@ -8,9 +8,21 @@
|
|||
boot = {
|
||||
supportedFilesystems = [ "zfs" ];
|
||||
zfs.requestEncryptionCredentials = config.chvp.base.zfs.encrypted;
|
||||
initrd.postDeviceCommands = lib.mkAfter ''
|
||||
zfs rollback -r ${config.chvp.base.zfs.rootDataset}@blank
|
||||
'';
|
||||
initrd.systemd = {
|
||||
enable = true;
|
||||
services.rollback = {
|
||||
description = "Rollback root filesystem to a pristine state on boot";
|
||||
wantedBy = [ "initrd.target" ];
|
||||
after = [ "zfs-import-${config.chvp.base.zfs.rootPool}.service" ];
|
||||
before = [ "sysroot.mount" ];
|
||||
path = with pkgs; [ zfs ];
|
||||
unitConfig.DefaultDependencies = "no";
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = ''
|
||||
zfs rollback -r ${config.chvp.base.zfs.rootDataset}@blank && echo " >> >> rollback complete << <<"
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue