Polish erase-home-darlings.clj

This commit is contained in:
Madeleine Sydney
2024-12-12 13:59:43 -07:00
parent 0350752a50
commit 684e78e936
6 changed files with 243 additions and 138 deletions

View File

@@ -14,45 +14,24 @@ in {
};
directories = mkOption {
description = "";
type = with types;
listOf (coercedTo str (d: { directory = d; }) userDir);
# type = with types;
# listOf (coercedTo str (d: { directory = d; }) userDir);
default = [];
};
files = mkOption {
description = "";
type = with types;
listOf (coercedTo str (f: { file = f; }) userFile);
# type = with types;
# listOf (coercedTo str (f: { file = f; }) userFile);
default = [];
};
};
};
config = mkIf cfg.enable {
systemd.services.erase-home-darlings =
let service = {
description = "Rollback home to a blank state on boot";
wantedBy = [
"multi-user.target"
];
after = [
"home.mount"
];
path = [ pkgs.zfs pkgs.babashka ];
# unitConfig.DefaultDependencies = "no";
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart =
let script = ./erase-home-darlings.clj;
in ''${pkgs.babashka}/bin/bb "${script}" 3'';
};
stopIfChanged = false;
restartIfChanged = false;
};
in if config.boot.initrd.systemd.enable
then service
else throw "sydnix.impermanence currently requires config.boot.initrd.systemd.enable'!";
home.persistence."/persist/home/${config.home.username}" = {
allowOther = true;
directories = cfg.directories;
files = cfg.files;
};
};
}