dotfiles

My PC Dotfiles & Website
commit 32f2d8f41cbfdd2bbcfa036f3db11355fc3bcba5
parent 766a68fcf594b76f94ca9788a0fbe666af1adb90
Author: maydayv7 <maydayv7@gmail.com>
Date:   Sun, 14 Jan 2024 11:46:00 +0530

fix: Actually persist `./local/share/Trash`

The FreeDesktop Specification prevents this directory from being a symlink,
so it's functionality was previously rendered useless

Diffstat:

Mmodules/gui/desktop/xfce.nix | 2++
Mmodules/hardware/filesystem.nix | 52++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/modules/gui/desktop/xfce.nix b/modules/gui/desktop/xfce.nix @@ -81,6 +81,7 @@ in { environment.variables.GTK_THEME = theme.theme.name; services = { bamf.enable = true; + blueman.enable = true; touchegg.enable = true; gnome.gnome-keyring.enable = true; xserver.displayManager.lightdm.greeters.gtk = theme; @@ -110,6 +111,7 @@ in { orage xarchiver mate.atril + transmission-gtk xfce4-clipman-plugin xfce4-eyes-plugin xfce4-notes-plugin diff --git a/modules/hardware/filesystem.nix b/modules/hardware/filesystem.nix @@ -158,13 +158,6 @@ in { }; # Persisted Files - system.activationScripts.dotfiles = let - dir = with files.path; "${persist}/${system}"; - in '' - chown root:keys ${dir} - chmod 774 -R ${dir} - ''; - environment.persistence = { "${files.path.persist}" = { files = ["/etc/machine-id"]; @@ -192,7 +185,6 @@ in { "Projects" "Public" "Videos" - ".local/share/Trash" { directory = ".local/share/keyrings"; mode = "0700"; @@ -204,6 +196,50 @@ in { }; }; + system.activationScripts.dotfiles = let + dir = with files.path; "${persist}/${system}"; + in '' + chown root:keys ${dir} + chmod 774 -R ${dir} + ''; + + user.homeConfig.systemd.user.services.persist-trash = { + Unit.Description = "Persist Trash Folder"; + Install.WantedBy = ["default.target"]; + Service = let + dir = '' + LOCAL="$HOME/.local/share/Trash" + PERSIST="/data/home/$USER/Trash" + mkdir -p "$LOCAL" + ''; + in { + Type = "oneshot"; + RemainAfterExit = true; + StandardOutput = "journal"; + ExecStart = "${pkgs.writeShellApplication { + name = "retrieve"; + runtimeInputs = [pkgs.coreutils]; + text = '' + ${dir} + if [ -d "$PERSIST" ] + then + cp -r "$PERSIST"/. "$LOCAL" + rm -rf "$PERSIST" + fi + ''; + }}/bin/retrieve"; + ExecStop = "${pkgs.writeShellApplication { + name = "migrate"; + runtimeInputs = [pkgs.coreutils]; + text = '' + ${dir} + mkdir -p "$PERSIST" + cp -r "$LOCAL"/. "$PERSIST" + ''; + }}/bin/migrate"; + }; + }; + # Maintainence services.zfs = { trim.enable = true;