flake/modules/home/impermanence.nix
2025-07-31 18:57:30 +00:00

51 lines
1.3 KiB
Nix

{ pkgs, lib, config, osConfig, ... }:
let
fs-diff = with pkgs;
writeShellApplication {
name = "fs-diff";
runtimeInputs = [ flameshot curl xsel ];
text = ''
#!/usr/bin/env bash
# fs-diff.sh
set -euo pipefail
sudo mkdir /btrfs_tmp
sudo mount -o subvol=/ /dev/mapper/crypted /btrfs_tmp
OLD_TRANSID=$(sudo btrfs subvolume find-new /btrfs_tmp/root-blank 9999999)
OLD_TRANSID=''${OLD_TRANSID#transid marker was }
sudo btrfs subvolume find-new "/btrfs_tmp/root" "$OLD_TRANSID" |
sed '$d' |
cut -f17- -d' ' |
sort |
uniq |
while read -r path; do
path="/$path"
if [ -L "$path" ]; then
: # The path is a symbolic link, so is probably handled by NixOS already
elif [ -d "$path" ]; then
: # The path is a directory, ignore
else
echo "$path"
fi
done
sudo umount /btrfs_tmp
'';
};
in with lib; {
config = mkIf osConfig.mods.impermanence.enable {
home.packages = [ fs-diff ];
# home.persistence."/persistent/home/muon" = {
# directories = [
# "documents"
# "downloads"
# "src"
# ".gnupg"
# ".ssh"
# ".config/sops"
# ".local/share/direnv"
# ];
# };
};
}