rename
This commit is contained in:
parent
67fa0955ae
commit
892b42a206
2 changed files with 3 additions and 3 deletions
52
modules/base/eraseYourDarlings.nix
Normal file
52
modules/base/eraseYourDarlings.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
inputs,
|
||||
outputs,
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkIf mkOption types;
|
||||
cfg = config.horseman.base.eraseYourDarlings;
|
||||
in {
|
||||
options = {
|
||||
horseman.base.eraseYourDarlings = {
|
||||
enable = mkEnableOption "If set, assumes the machine has been set up as a Erase Your Darlings device";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.etc = {
|
||||
nixos.source = "/persist/etc/nixos";
|
||||
machine-id.source = "/persist/etc/machine-id";
|
||||
"ssh/ssh_host_ed25519_key".source = "/persist/etc/ssh/ssh_host_ed25519_key";
|
||||
"ssh/ssh_host_ed25519_key.pub".source = "/persist/etc/ssh/ssh_host_ed25519_key.pub";
|
||||
};
|
||||
|
||||
security.sudo.extraConfig = ''
|
||||
Defaults lecture = never
|
||||
'';
|
||||
|
||||
users.mutableUsers = false;
|
||||
|
||||
boot.initrd.postDeviceCommands = pkgs.lib.mkBefore ''
|
||||
mkdir -p /mnt
|
||||
|
||||
mount -o subvol=/ /dev/disk/by-label/ROOT /mnt
|
||||
|
||||
btrfs subvolume list -o /mnt/root |
|
||||
cut -f9 -d' ' |
|
||||
while read subvolume; do
|
||||
echo "deleting /$subvolume subvolume..."
|
||||
btrfs subvolume delete "/mnt/$subvolume"
|
||||
done &&
|
||||
echo "deleting /root subvolume..." &&
|
||||
btrfs subvolume delete /mnt/root
|
||||
|
||||
echo "restoring blank /root subvolume..."
|
||||
btrfs subvolume snapshot /mnt/root-blank /mnt/root
|
||||
|
||||
umount /mnt
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue