systemd in initrd for workstation
This commit is contained in:
parent
f0b88e8778
commit
21f1a37b57
@ -1,4 +1,4 @@
|
|||||||
{ pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
zfs_arc_max = toString (6 * 1024 * 1024 * 1024);
|
zfs_arc_max = toString (6 * 1024 * 1024 * 1024);
|
||||||
in {
|
in {
|
||||||
@ -10,11 +10,9 @@ in {
|
|||||||
supportedFilesystems = [ "zfs" ];
|
supportedFilesystems = [ "zfs" ];
|
||||||
luks.devices = {
|
luks.devices = {
|
||||||
"cryptroot" = {
|
"cryptroot" = {
|
||||||
preLVM = true;
|
|
||||||
keyFile = "/keyfile0.bin";
|
keyFile = "/keyfile0.bin";
|
||||||
allowDiscards = true;
|
allowDiscards = true;
|
||||||
bypassWorkqueues = true;
|
bypassWorkqueues = true;
|
||||||
fallbackToPassword = true;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
secrets = {
|
secrets = {
|
||||||
@ -70,8 +68,19 @@ in {
|
|||||||
|
|
||||||
fileSystems."/home".neededForBoot = true;
|
fileSystems."/home".neededForBoot = true;
|
||||||
fileSystems."/persist".neededForBoot = true;
|
fileSystems."/persist".neededForBoot = true;
|
||||||
boot.initrd.postDeviceCommands = lib.mkAfter ''
|
|
||||||
zfs rollback -r rpool/nixos/root@empty
|
boot.initrd.systemd.enable = true;
|
||||||
zfs rollback -r rpool/user/home@empty
|
boot.initrd.systemd.services.rollback = {
|
||||||
|
description = "Rollback zfs to a pristine state on boot";
|
||||||
|
wantedBy = [ "initrd.target" ];
|
||||||
|
after = [ "zfs-import-rpool.service" ];
|
||||||
|
before = [ "sysroot.mount" ];
|
||||||
|
path = [ config.boot.zfs.package ];
|
||||||
|
unitConfig.DefaultDependencies = "no";
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = ''
|
||||||
|
zfs rollback -r rpool/nixos/root@empty && echo " >>> rollback root <<<"
|
||||||
|
zfs rollback -r rpool/user/home@empty && echo " >>> rollback home <<<"
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user