1
Fork 0

Custom wrapper around imperanence

This commit is contained in:
Matei Adriel 2023-04-30 04:30:15 +02:00
parent a6f886da07
commit 886d86f95c
No known key found for this signature in database
7 changed files with 121 additions and 13 deletions

View file

@ -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 💀
];
}

View file

@ -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
];
}

View file

@ -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 💀
];
}

View file

@ -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

View file

@ -31,7 +31,26 @@
];
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 = ''

View file

@ -5,4 +5,5 @@
discord = import ./discord.nix;
firefox = import ./firefox;
satellite-dev = import ./satellite-dev.nix;
satellite-persistence = import ./persistence.nix;
}

View file

@ -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;
};
}