dotfiles/nix/nixos-modules/erase-my-darlings.nix
Magic_RB d3e46e5413
Complete module rework
Signed-off-by: Magic_RB <magic_rb@redalder.org>
2021-08-19 18:24:36 +02:00

25 lines
590 B
Nix

{ config, lib, ... }:
with lib;
let
cfg = config.magic_rb.erase-my-darlings;
in
# Send love to https://grahamc.com/blog/erase-your-darlings
{
options = {
magic_rb.erase-my-darlings = {
enable = mkEnableOption "Erase the root filesystem using ZFS snapshots on boot.";
snapshot = mkOption {
type = types.str;
description = "Which snapshot to rollback to, also specifies which dataset to rollback.";
};
};
};
config = mkIf cfg.enable {
boot.initrd.postDeviceCommands = lib.mkAfter ''
zfs rollback -r ${cfg.snapshot}
'';
};
}