feat: filter out mounpoints from persistance list
This commit is contained in:
parent
07b12c6171
commit
7d5c459e59
@ -41,6 +41,16 @@ in
|
|||||||
{
|
{
|
||||||
options.ataraxia.filesystems.btrfs = {
|
options.ataraxia.filesystems.btrfs = {
|
||||||
enable = mkEnableOption "Root on btrfs";
|
enable = mkEnableOption "Root on btrfs";
|
||||||
|
mountpoints = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
A list of absolute paths to BTRFS subvolume mountpoints.
|
||||||
|
These paths will be automatically filtered out from the directories persisted through
|
||||||
|
persist module to prevent conflicts with BTRFS' native mount management. Any matching entries
|
||||||
|
in the persistence list will be removed.
|
||||||
|
'';
|
||||||
|
};
|
||||||
# Btrfs clean root
|
# Btrfs clean root
|
||||||
eraseOnBoot = {
|
eraseOnBoot = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
|
@ -17,6 +17,16 @@ in
|
|||||||
{
|
{
|
||||||
options.ataraxia.filesystems.zfs = {
|
options.ataraxia.filesystems.zfs = {
|
||||||
enable = mkEnableOption "Root on zfs";
|
enable = mkEnableOption "Root on zfs";
|
||||||
|
mountpoints = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
A list of absolute paths to ZFS dataset mountpoints.
|
||||||
|
These paths will be automatically filtered out from the directories persisted through
|
||||||
|
persist module to prevent conflicts with ZFS's native mount management. Any matching entries
|
||||||
|
in the persistence list will be removed.
|
||||||
|
'';
|
||||||
|
};
|
||||||
# Zfs clean root
|
# Zfs clean root
|
||||||
eraseOnBoot = {
|
eraseOnBoot = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
|
@ -16,11 +16,19 @@ let
|
|||||||
mkOption
|
mkOption
|
||||||
nameValuePair
|
nameValuePair
|
||||||
optionalAttrs
|
optionalAttrs
|
||||||
|
pipe
|
||||||
recursiveUpdate
|
recursiveUpdate
|
||||||
|
removePrefix
|
||||||
|
subtractLists
|
||||||
|
unique
|
||||||
;
|
;
|
||||||
inherit (lib.types) listOf path str;
|
inherit (lib.types) listOf path str;
|
||||||
inherit (builtins) concatMap;
|
inherit (builtins) concatMap;
|
||||||
cfg = config.persist;
|
cfg = config.persist;
|
||||||
|
|
||||||
|
btrfs = config.ataraxia.filesystems.btrfs.mountpoints;
|
||||||
|
zfs = config.ataraxia.filesystems.zfs.mountpoints;
|
||||||
|
mountpoints = unique (btrfs ++ zfs);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ inputs.impermanence.nixosModules.impermanence ];
|
imports = [ inputs.impermanence.nixosModules.impermanence ];
|
||||||
@ -79,6 +87,8 @@ in
|
|||||||
];
|
];
|
||||||
allFiles = takeAll "files" persists;
|
allFiles = takeAll "files" persists;
|
||||||
allDirectories = takeAll "directories" persists;
|
allDirectories = takeAll "directories" persists;
|
||||||
|
# Remove btrfs + zfs mountpoints from list of dirs to persist
|
||||||
|
filteredDirs = subtractLists mountpoints allDirectories;
|
||||||
|
|
||||||
userPersists = mapAttrs (_: cfg: cfg.persist) (
|
userPersists = mapAttrs (_: cfg: cfg.persist) (
|
||||||
{ } // optionalAttrs (builtins.hasAttr "home-manager" config) config.home-manager.users
|
{ } // optionalAttrs (builtins.hasAttr "home-manager" config) config.home-manager.users
|
||||||
@ -92,10 +102,17 @@ in
|
|||||||
];
|
];
|
||||||
allHomeFiles = takeAll "files" persists;
|
allHomeFiles = takeAll "files" persists;
|
||||||
allHomeDirectories = takeAll "directories" persists;
|
allHomeDirectories = takeAll "directories" persists;
|
||||||
|
# Remove btrfs + zfs mountpoints from list of dirs to persist
|
||||||
|
home = "/home/${name}";
|
||||||
|
filteredDirs = pipe allHomeDirectories [
|
||||||
|
(map (x: "${home}/${x}"))
|
||||||
|
(xs: subtractLists mountpoints xs)
|
||||||
|
(map (x: removePrefix home x))
|
||||||
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
home = "/home/${name}";
|
inherit home;
|
||||||
directories = allHomeDirectories;
|
directories = filteredDirs;
|
||||||
files = allHomeFiles;
|
files = allHomeFiles;
|
||||||
}
|
}
|
||||||
) userPersists;
|
) userPersists;
|
||||||
@ -103,7 +120,7 @@ in
|
|||||||
mkIf cfg.enable {
|
mkIf cfg.enable {
|
||||||
environment.persistence.${cfg.persistRoot} = {
|
environment.persistence.${cfg.persistRoot} = {
|
||||||
hideMounts = true;
|
hideMounts = true;
|
||||||
directories = allDirectories;
|
directories = filteredDirs;
|
||||||
files = allFiles;
|
files = allFiles;
|
||||||
users = usersFlatten;
|
users = usersFlatten;
|
||||||
};
|
};
|
||||||
@ -146,7 +163,6 @@ in
|
|||||||
];
|
];
|
||||||
|
|
||||||
fileSystems.${cfg.persistRoot}.neededForBoot = true;
|
fileSystems.${cfg.persistRoot}.neededForBoot = true;
|
||||||
# TODO: disable some dirs if using zfs
|
|
||||||
# Persist by default
|
# Persist by default
|
||||||
persist.cache.directories = [
|
persist.cache.directories = [
|
||||||
"/var/cache"
|
"/var/cache"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user