diff --git a/home/adrielus/features/desktop/common/discord.nix b/home/adrielus/features/desktop/common/discord.nix index 43ec9a7..6dabc23 100644 --- a/home/adrielus/features/desktop/common/discord.nix +++ b/home/adrielus/features/desktop/common/discord.nix @@ -1,11 +1,11 @@ -{ +{ config, ... }: { programs.discord = { enable = true; disableUpdateCheck = true; enableDevtools = true; }; - home.persistence."/persist/home/adrielus".directories = [ - ".config/discord" # Why tf does discord store it's state here 💀 + satellite.persistence.at.state.apps.Discord.directories = [ + "${config.xdg.configHome}/discord" # Why tf does discord store it's state here 💀 ]; } diff --git a/home/adrielus/features/desktop/common/qbittorrent.nix b/home/adrielus/features/desktop/common/qbittorrent.nix index 8521dc9..bf38e3d 100644 --- a/home/adrielus/features/desktop/common/qbittorrent.nix +++ b/home/adrielus/features/desktop/common/qbittorrent.nix @@ -3,9 +3,12 @@ pkgs.qbittorrent ]; - home.persistence."/persist/home/adrielus".directories = [ - ".config/qBittorrent" # Config options + satellite.persistence.at.state.apps.QBittorrent.directories = [ + "${config.xdg.configHome}/qBittorrent" # Config options + ]; + + satellite.persistence.at.cache.apps.QBittorrent.directories = [ # TODO: investigate which subdirectories/files I actually want to keep - ".local/share/qBittorrent" # Torrent files, logs, etc + "${config.xdg.dataHome}/qBittorrent" # Torrent files, logs, etc ]; } diff --git a/home/adrielus/features/desktop/common/signal.nix b/home/adrielus/features/desktop/common/signal.nix index 2429e80..f60a50e 100644 --- a/home/adrielus/features/desktop/common/signal.nix +++ b/home/adrielus/features/desktop/common/signal.nix @@ -1,9 +1,9 @@ -{ pkgs, ... }: { +{ pkgs, config, ... }: { home.packages = [ pkgs.signal-desktop # Signal client ]; - home.persistence."/persist/home/adrielus".directories = [ - ".config/Signal" # Why tf does signal store it's state here 💀 + satellite.persistence.at.state.apps.Signal.directories = [ + "${config.xdg.configHome}/Signal" # Why tf does signal store it's state here 💀 ]; } diff --git a/home/adrielus/features/games/lutris.nix b/home/adrielus/features/games/lutris.nix index ed36a2e..97328f7 100644 --- a/home/adrielus/features/games/lutris.nix +++ b/home/adrielus/features/games/lutris.nix @@ -1,10 +1,11 @@ -{ pkgs, config, ... }: { +{ pkgs, config, ... }: +{ home.packages = [ pkgs.lutris ]; home.persistence."/persist/home/adrielus".directories = [ - ".config/lutris" # General config data + ("Lutris/.config/lutris") # General config data ".cache/lutris/banners" # Game banners ".cache/lutris/coverart" # Game cover art diff --git a/home/adrielus/tethys.nix b/home/adrielus/tethys.nix index 7a766b2..bf12717 100644 --- a/home/adrielus/tethys.nix +++ b/home/adrielus/tethys.nix @@ -31,10 +31,29 @@ ]; home.sessionVariables.QT_SCREEN_SCALE_FACTORS = 1.4; # Bigger text in qt apps - satellite.dev.enable = true; # Simlink some stuff outside the store + + satellite = { + # Simlink some commonly modified dotfiles outside the store + dev.enable = true; + + # Set up my custom imperanence wrapper + persistence = { + enable = true; + + # Actual data/media (eg: projects, images, videos, etc) + at.data.path = "/persist/data"; + + # App state I want to keep + at.state.path = "/persist/state"; + + # App state which I should be able to delete at any point + at.cache.path = "/persist/cache"; + }; + }; + # Temp stuff - xsession.initExtra = '' + xsession.initExtra = '' command -v dbus-update-activation-environment >/dev/null 2>&1 && dbus-update-activation-environment --systemd XDG_SESSION_CLASS XDG_CONFIG_DIRS XDG_DATA_DIRS XDG_SESSION_DESKTOP XDG_CURRENT_DESKTOP XDG_SESSION_TYPE DCONF_PROFILE XDG_DESKTOP_PORTAL_DIR DISPLAY WAYLAND_DISPLAY SWAYSOCK XMODIFIERS XCURSOR_SIZE XCURSOR_THEME GDK_PIXBUF_MODULE_FILE GIO_EXTRA_MODULES GTK_IM_MODULE QT_PLUGIN_PATH QT_QPA_PLATFORMTHEME QT_STYLE_OVERRIDE QT_IM_MODULE NIXOS_OZONE_WL || systemctl --user import-environment XDG_SESSION_CLASS XDG_CONFIG_DIRS XDG_DATA_DIRS XDG_SESSION_DESKTOP XDG_CURRENT_DESKTOP XDG_SESSION_TYPE DCONF_PROFILE XDG_DESKTOP_PORTAL_DIR DISPLAY WAYLAND_DISPLAY SWAYSOCK XMODIFIERS XCURSOR_SIZE XCURSOR_THEME GDK_PIXBUF_MODULE_FILE GIO_EXTRA_MODULES GTK_IM_MODULE QT_PLUGIN_PATH QT_QPA_PLATFORMTHEME QT_STYLE_OVERRIDE QT_IM_MODULE NIXOS_OZONE_WL ''; } diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index cdfc3f0..2dc6578 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -5,4 +5,5 @@ discord = import ./discord.nix; firefox = import ./firefox; satellite-dev = import ./satellite-dev.nix; + satellite-persistence = import ./persistence.nix; } diff --git a/modules/home-manager/persistence.nix b/modules/home-manager/persistence.nix new file mode 100644 index 0000000..be2e2c4 --- /dev/null +++ b/modules/home-manager/persistence.nix @@ -0,0 +1,84 @@ +# My own module with nicer syntax for impernanence +{ lib, config, ... }: +let cfg = config.satellite.persistence; +in +{ + options.satellite.persistence = { + enable = lib.mkEnableOption (lib.mkDoc "satellite persitence"); + + at = lib.mkOption { + default = { }; + description = "Record of persistent locations (eg: /persist)"; + type = lib.types.attrsOf (lib.types.submodule (_: { + options = { + path = lib.mkOption { + type = lib.types.str; + example = "/persist"; + default = null; + description = "The location to store the files described in this record"; + }; + + apps = lib.mkOption { + default = { }; + description = "The apps to be stores in this persistent location"; + type = lib.types.attrsOf (lib.types.submodule (_: { + options = { + directories = lib.mkOption { + default = [ ]; + description = "Modified version of home.persistence.*.directories which takes in absolute paths"; + type = lib.types.listOf (lib.types.either lib.types.str (lib.types.submodule { + options = { + directory = lib.mkOption { + type = lib.types.str; + default = null; + description = "The directory path to be linked."; + }; + + method = lib.mkOption { + type = lib.types.enum [ "bindfs" "symlink" ]; + default = "bindfs"; + description = '' + The linking method that should be used for this + directory. bindfs is the default and works for most use + cases, however some programs may behave better with + symlinks. + ''; + }; + }; + })); + }; + }; + })); + }; + }; + })); + }; + }; + + config = + let + makeLocation = location: + let + processPath = appName: value: + "${appName}/${lib.strings.removePrefix config.home.homeDirectory (builtins.toString value)}"; + + mkDirectory = appName: directory: + if builtins.isAttrs directory then { + method = directory.method; + directory = processPath appName directory.directory; + } + else processPath appName directory; + + mkAppDirectory = appName: app: builtins.map (mkDirectory appName) app.directories; + in + lib.attrsets.nameValuePair (location.path + config.home.homeDirectory) { + removePrefixDirectory = true; + allowOther = true; + directories = lib.lists.flatten + (lib.attrsets.mapAttrsToList mkAppDirectory location.apps); + }; + in + lib.mkIf cfg.enable { + home.persistence = lib.attrsets.mapAttrs' (_: makeLocation) cfg.at; + }; +}