Support persisting data separately from config

This commit is contained in:
ItsDrike 2024-06-26 22:51:51 +02:00
parent 4a10a3536a
commit 507f364e5b
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
3 changed files with 63 additions and 11 deletions

View file

@ -25,5 +25,18 @@ in {
# Docker, etc. Requires NixOS configuration programs.fuse.userAllowOther = true;
allowOther = true;
};
home.persistence."${cfg.persistentDataMountPoint}" = {
directories = [
] ++ cfg.extraDataDirectories;
files = [
] ++ cfg.extraDataFiles;
# See comment for this above
allowOther = true;
};
};
}

View file

@ -53,14 +53,6 @@
enable = true;
persistentMountPoint = "/persist/home";
extraDirectories = [
# Nixos flake
"dots"
# Personal data
"Downloads"
"Personal"
"Media"
# Browsers
".mozilla"
".mullvad"
@ -95,6 +87,20 @@
".config/pcmanfm-qt/default/recent-files.conf"
".config/qalculate/qalculate-gtk.cfg"
];
persistentDataMountPoint = "/data/Data";
extraDataDirectories = [
# Nixos flake
"dots"
# XDG user dirs
"Downloads"
"Media"
# Other personal data
"Personal"
];
extraDataFiles = [];
};
# Configure automatic root subvolume wiping on boot from initrd

View file

@ -60,7 +60,7 @@ in
extraDirectories = mkOption {
default = [];
type = types.listOf types.str;
example = literalExpression ''["Downloads"]'';
example = literalExpression ''[".config/chromium"]'';
description = ''
Additional directories in home to link to persistent storage.
'';
@ -70,13 +70,46 @@ in
default = "/persist/home";
description = ''
Path to a persistent directory (usually a mount point to a
standalone partition / subvolume), which will hold the persistent
standalone partition or subvolume), which will hold the persistent
system state files.
This does not expect any subdirectories, all of the persistent home files
This does not create any subdirectories, all of the persistent home files
will be put directly in here. The user should be the owner of this direcotry.
'';
};
persistentDataMountPoint = mkOption {
default = "/persist/home";
description = ''
Path to a persistent directory (usually a mount point to a
standalone partition or subvolume), which will hold the persistent
data files.
This does not create any subdirectories, all of the persistent home files
fill be put directly in here. The user should be the owner of this directory.
If you don't wish to distinguish between data and system / configuration files,
you can point this to the same location.
'';
};
extraDataFiles = mkOption {
default = [];
type = types.listOf types.str;
example = literalExpression ''["notes.txt"]'';
description = ''
Additional files in home to link to persistent data storage.
'';
};
extraDataDirectories = mkOption {
default = [];
type = types.listOf types.str;
example = literalExpression ''["Downloads"]'';
description = ''
Additional directories in home to link to persistent data storage.
'';
};
};
autoWipeBtrfs = let