refactor: moved modules to legacy-modules
This commit is contained in:
parent
d646b954ac
commit
db7ac35613
233 changed files with 5 additions and 5 deletions
43
legacy-modules/home-manager-modules/impermanence.nix
Normal file
43
legacy-modules/home-manager-modules/impermanence.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
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