Impermanence and hibernation

Hi there,

I’ve installed NixOS + Impermanence (using btrfs snapshots) on my main desktop and after initial setup it works pretty much flawlessly.

I’m now in the planning stages of moving my laptop to basically the same setup and one question came up regarding Impermanence + hibernation. During the week I like to hibernate my laptop and only do one update + full reboot at the end of the week. The way I understand the setup for resetting the root filesystem that is suggested in the Impermanence repo it will reset root also when resuming from hibernation, correct?

}: {
  imports = [

  boot.initrd.postDeviceCommands = lib.mkAfter ''
    mkdir /btrfs_tmp
    mount /dev/mapper/cryptroot /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"

    delete_subvolume_recursively() {
        for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
            delete_subvolume_recursively "/btrfs_tmp/$i"
        btrfs subvolume delete "$1"

    for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
        delete_subvolume_recursively "$i"

    btrfs subvolume create /btrfs_tmp/root
    umount /btrfs_tmp

Assuming my understanding is correct I would like to avoid the reset on resume to prevent any weird issues for running applications with open files. Still assuming my understanding is correct what would be an alternative way to reset on reboot but not an resume?

Thanks :slight_smile: