NixOS-Config/hosts/jupiter/boot/default.nix

45 lines
1.2 KiB
Nix

{ config, pkgs, ... }:
{
boot = {
kernelPackages = pkgs.unstable.linuxPackages_latest;
kernel.sysctl."vm.max_map_count" = 2147483642;
kernelParams = [
"amd_iommu=on"
"iommu=pt"
"nested=1"
"transparent_hugepage=never"
];
initrd.systemd = {
enable = true;
services.root-reset = {
description = "Reset root and snapshot last boot";
wantedBy = [ "initrd.target" ];
before = [ "sysroot.mount" ];
after = [ "dev-${config.networking.hostName}-root.device" ];
unitConfig.DefaultDependencies = "no";
serviceConfig.Type = "oneshot";
script = ''
mkdir -p /mnt
mount /dev/${config.networking.hostName}/root /mnt
if [[ -e /mnt/prev ]]; then
btrfs subvolume delete /mnt/prev
fi
btrfs subvolume snapshot /mnt/root /mnt/prev
btrfs subvolume list -o /mnt/root | cut -f9 -d' ' | while read subvolume; do
btrfs subvolume delete "/mnt/$subvolume"
done
btrfs subvolume delete /mnt/root
btrfs subvolume create /mnt/root
umount /mnt
'';
};
};
};
}