Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions final/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
};

# if you get an error about postDeviceCommands no longer available (26.05 or
# unstable), read further
boot.initrd.postDeviceCommands = lib.mkAfter ''
mkdir /btrfs_tmp
mount /dev/root_vg/root /btrfs_tmp
Expand All @@ -43,6 +45,50 @@
btrfs subvolume create /btrfs_tmp/root
umount /btrfs_tmp
'';
# only uncomment this if you are on 26.05 or nixos-unstable, and remove the previous block
# boot.initrd.systemd = {
# initrdBin = with pkgs; [
# btrfs-progs
# coreutils
# util-linux
# findutils
# ];
#
# services.prune-subvolumes = {
# requiredBy = [ "initrd.target" ];
# before = [ "local-fs-pre.target" ];
# after = [
# "initrd-root-device.target"
# "systemd-hibernate-resume.service"
# ];
# unitConfig.DefaultDependencies = false;
# serviceConfig.Type = "oneshot";
# script = ''
# mkdir /btrfs_tmp
# mount /dev/mapper/root_vg-root /btrfs_tmp
# if [[ -e /btrfs_tmp/root ]]; then
# mkdir -p /btrfs_tmp/old_roots
# timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
# mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
# fi
#
# delete_subvolume_recursively() {
# IFS=$'\n'
# for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
# delete_subvolume_recursively "/btrfs_tmp/$i"
# done
# btrfs subvolume delete "$1"
# }
#
# for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
# delete_subvolume_recursively "$i"
# done
#
# btrfs subvolume create /btrfs_tmp/root
# umount /btrfs_tmp
# '';
# };
# };

fileSystems."/persist".neededForBoot = true;
environment.persistence."/persist/system" = {
Expand Down