refactor: moved darwin, home-manager, and system configurations to dendrite pattern
This commit is contained in:
parent
0ea11e0236
commit
149f4f151f
193 changed files with 3284 additions and 3095 deletions
45
modules/home-manager/impermanence.nix
Normal file
45
modules/home-manager/impermanence.nix
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{...}: {
|
||||
flake.homeModules.home-manager-impermanence = {
|
||||
config,
|
||||
lib,
|
||||
osConfig,
|
||||
...
|
||||
}: let
|
||||
cfg = config.impermanence;
|
||||
in {
|
||||
options.impermanence = {
|
||||
enable = lib.mkEnableOption "impermanence for home directory";
|
||||
fallbackPersistence.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
};
|
||||
persistencePath = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default =
|
||||
if osConfig.storage.generateBase
|
||||
then "/persist/replicate/home"
|
||||
else "/persist";
|
||||
description = "The base path for user home persistence. The impermanence module will automatically append the user's home directory path. Automatically adapts based on whether the system uses the new dataset layout or the legacy one.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf config.impermanence.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = osConfig.storage.impermanence.enable;
|
||||
message = "impermanence can not be enabled for a user when it is not enabled for the system";
|
||||
}
|
||||
];
|
||||
})
|
||||
# If impermanence is not enabled for this user but system impermanence is enabled,
|
||||
# persist the entire home directory as fallback
|
||||
(lib.mkIf (osConfig.storage.impermanence.enable && !cfg.enable && cfg.fallbackPersistence.enable) {
|
||||
home.persistence."${cfg.persistencePath}" = {
|
||||
directories = ["."];
|
||||
allowOther = true;
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue