boron: migrate cache subvolume reset to systemd stage 1 service #1166
@@ -45,16 +45,31 @@
|
|||||||
".ssh/id_rsa"
|
".ssh/id_rsa"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
# TODO: migrate cache subvolume reset to a systemd service in initrd and drop this override.
|
boot.initrd.systemd.services.reset-cache-subvolumes = {
|
||||||
boot.initrd.systemd.enable = lib.mkForce false;
|
description = "Wipe /cache/{system,nix-builds} to empty snapshots before stage 2";
|
||||||
boot.initrd.postDeviceCommands = lib.mkAfter ''
|
wantedBy = [ "initrd.target" ];
|
||||||
btrfs subvolume delete /cache/system
|
after = [ "cryptsetup.target" ];
|
||||||
btrfs subvolume snapshot /cache/empty_snapshot /cache/system
|
requires = [ "cryptsetup.target" ];
|
||||||
|
before = [ "initrd-fs.target" ];
|
||||||
|
unitConfig.DefaultDependencies = "no";
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
mkdir -p /reset-cache
|
||||||
|
mount -t btrfs -o subvol=cache /dev/mapper/disk0-crypt /reset-cache
|
||||||
|
|
||||||
btrfs subvolume delete /cache/nix-builds
|
btrfs subvolume delete /reset-cache/system
|
||||||
btrfs subvolume snapshot /cache/empty_snapshot /cache/nix-builds
|
btrfs subvolume snapshot /reset-cache/empty_snapshot /reset-cache/system
|
||||||
chmod 0700 /cache/nix-builds
|
|
||||||
|
btrfs subvolume delete /reset-cache/nix-builds
|
||||||
|
btrfs subvolume snapshot /reset-cache/empty_snapshot /reset-cache/nix-builds
|
||||||
|
chmod 0700 /reset-cache/nix-builds
|
||||||
|
|
||||||
|
umount /reset-cache
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
nix = {
|
nix = {
|
||||||
distributedBuilds = true;
|
distributedBuilds = true;
|
||||||
settings = {
|
settings = {
|
||||||
|
|||||||
Reference in new issue
Block a user