feat: refactored impermanence to be enableable for users on a system

This commit is contained in:
Leyla Becker 2025-10-13 09:36:48 -05:00
parent 337f03b4e7
commit 6d5a07e08f
31 changed files with 61 additions and 56 deletions

View file

@ -1,10 +1,9 @@
{
lib,
config,
osConfig,
...
}: {
config = lib.mkIf osConfig.host.impermanence.enable {
config = lib.mkIf (config.impermanence.enable) {
home.persistence."/persist/home/leyla" = {
directories = [
"desktop"

View file

@ -5,6 +5,7 @@
./user.nix
./flipperzero.nix
./i18n.nix
./impermanence.nix
./openssh.nix
./gnome.nix
./programs

View file

@ -0,0 +1,31 @@
{
config,
lib,
osConfig,
...
}: let
cfg = config.impermanence;
in {
options.impermanence = {
enable = lib.mkEnableOption "impermanence for home directory";
};
config = lib.mkMerge [
(lib.mkIf config.impermanence.enable {
assertions = [
{
assertion = osConfig.impermanence.enable;
message = "impermanence can not be enabled for a user when it is not enabled for a configuration";
}
];
})
(lib.mkIf osConfig.host.impermanence.enable {
# If impermanence is not enabled for this user but system impermanence is enabled,
# persist the entire home directory as fallback
home.persistence."/persist/home/${config.home.username}" = lib.mkIf (!cfg.enable) {
directories = ["."];
allowOther = true;
};
})
];
}

View file

@ -95,7 +95,7 @@
);
}
)
(lib.mkIf osConfig.host.impermanence.enable {
(lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
files = lib.lists.flatten (
builtins.map (hostKey: [".ssh/${hostKey.path}" ".ssh/${hostKey.path}.pub"]) config.programs.openssh.hostKeys

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.bitwarden = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/Bitwarden"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.bruno = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/bruno/"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.calibre = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/calibre"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.davinci-resolve = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.dataHome}/DaVinciResolve"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.dbeaver-bin = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.dataHome}/DBeaverData/"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.discord = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/discord/"

View file

@ -1,7 +1,6 @@
{
lib,
config,
osConfig,
...
}: let
buildProfilePersistence = profile: {
@ -26,7 +25,7 @@
allowOther = true;
};
in {
config = lib.mkIf (config.programs.firefox.enable && osConfig.host.impermanence.enable) {
config = lib.mkIf (config.programs.firefox.enable && config.impermanence.enable) {
home.persistence."/persist${config.home.homeDirectory}" = lib.mkMerge (
(
lib.attrsets.mapAttrsToList

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.freecad = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/FreeCAD"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.gimp = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/GIMP"

View file

@ -16,7 +16,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
# configuration

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.inkscape = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/inkscape"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.krita = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/kritarc"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.libreoffice = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/libreoffice"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.makemkv = {
@ -30,7 +29,7 @@
home.file.".MakeMKV/settings.conf".source = config.lib.file.mkOutOfStoreSymlink config.sops.templates."MakeMKV.settings.conf".path;
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
".MakeMKV"

View file

@ -1,12 +1,11 @@
{
lib,
config,
osConfig,
...
}: {
config = lib.mkIf config.programs.obs-studio.enable (lib.mkMerge [
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
# TODO: map impermanence for obs
}
)

View file

@ -1,12 +1,11 @@
{
lib,
config,
osConfig,
...
}: {
config = lib.mkIf config.programs.obsidian.enable (lib.mkMerge [
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/obsidian"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.picard = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/MusicBrainz"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.polycule = {
@ -17,7 +16,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
# TODO: check that these are actually the correct folders
# directories = [

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.prostudiomasters = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/ProStudioMasters"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.protonvpn-gui = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/protonvpn"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.qbittorrent = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/qBittorrent"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.qflipper = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/qFlipper"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.signal-desktop-bin = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/Signal"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.steam = {
@ -18,7 +17,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
{

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.tor-browser = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.dataHome}/torbrowser"

View file

@ -2,7 +2,6 @@
lib,
pkgs,
config,
osConfig,
...
}: {
options.programs.ungoogled-chromium = {
@ -16,7 +15,7 @@
];
}
(
lib.mkIf osConfig.host.impermanence.enable {
lib.mkIf config.impermanence.enable {
home.persistence."/persist${config.home.homeDirectory}" = {
directories = [
"${config.xdg.configHome}/chromium"

View file

@ -1,10 +1,9 @@
{
lib,
config,
osConfig,
...
}: {
config = lib.mkIf (config.services.panoramax.enable && osConfig.host.impermanence.enable) {
config = lib.mkIf (config.services.panoramax.enable && config.host.impermanence.enable) {
# TODO: configure impermanence for panoramax data
# This would typically include directories like:
# - /var/lib/panoramax