Add murk and impermanence

This commit is contained in:
muon 2025-07-31 00:34:46 +00:00
parent a8668c1a44
commit b4f998d455
17 changed files with 354 additions and 6 deletions

View file

@ -8,6 +8,7 @@ in {
./sops
./xdg.nix
./impermanence.nix
];
# Let Home Manager install and manage itself

View file

@ -3,7 +3,6 @@
lib.mkEnableOption "enables gui development tools";
config = lib.mkIf config.mods.desktop.development.enable {
home.packages = with pkgs; [ godot ];
programs.qutebrowser = {
enable = true;

View file

@ -0,0 +1,50 @@
{ 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
OLD_TRANSID=$(sudo btrfs subvolume find-new /mnt/root-blank 9999999)
OLD_TRANSID=${OLD_TRANSID}
sudo mkdir /mnt
sudo mount -o subvol=/ /dev/mapper/crypted /mnt
sudo btrfs subvolume find-new "/mnt/root" "$OLD_TRANSID" |
sed \'$d\' |
cut -f17- -d' ' |
sort |
uniq |
while read 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 /mnt
'';
};
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"
];
};
};
}

View file

@ -2,7 +2,10 @@
let
cfg = config.mods.terminal;
aliases = { la = "ls -lah"; };
aliases = with lib; {
la = "ls -lah";
xc = "${getExe pkgs.xclip} -selection clipboard";
};
in {
options.mods.terminal = { zsh.enable = lib.mkEnableOption "enables zsh"; };

View file

@ -28,6 +28,7 @@ in with lib; {
"bottom"
"htop"
"vifm"
"rbw"
]);
home.packages = with pkgs; [
@ -40,10 +41,14 @@ in with lib; {
dua
fdupes
vifm
# programs
fend
unzip
# security
pinentry-tty
# utilities
fend
xclip
];
};
}

View file

@ -11,10 +11,11 @@
timeout = 2;
efi.canTouchEfiVariables = true;
grub = {
enable = true;
enable = lib.mkDefault true;
zfsSupport = true;
efiSupport = true;
device = "nodev";
} // lib.optionalAttrs (config.mods.monitors != { }) {
gfxmodeEfi = config.mods.monitors.primary.config.mode;
};
};

View file

@ -7,6 +7,8 @@
./server
./sops
./impermanence.nix
# </3
./unfree
];

View file

@ -0,0 +1,41 @@
{ pkgs, lib, config, ... }:
with lib; {
options.mods.impermanence.enable = mkEnableOption "enables impermanence";
config = mkIf config.mods.impermanence.enable {
environment.persistence."/persistent" = {
directories = [
"/var/lib/bluetooth"
"/var/lib/nixos"
"/var/lib/systemd/coredump"
"/etc/NetworkManager/system-connections"
];
files = [ "/etc/machine-id" ];
};
boot.initrd.postResumeCommands = lib.mkAfter ''
mkdir /btrfs_tmp
mount /dev/mapper/crypted /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
'';
};
}