feat: migrated users over to new persistence structure
This commit is contained in:
parent
37f5e65bd6
commit
d06c25f33f
29 changed files with 57 additions and 99 deletions
|
|
@ -18,17 +18,16 @@ in {
|
|||
(lib.mkIf config.impermanence.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = osConfig.host.impermanence.enable;
|
||||
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.host.impermanence.enable && !cfg.enable && cfg.fallbackPersistence.enable) {
|
||||
(lib.mkIf (osConfig.storage.impermanence.enable && !cfg.enable && cfg.fallbackPersistence.enable) {
|
||||
home.persistence."/persist/home/${config.home.username}" = {
|
||||
directories = ["."];
|
||||
allowOther = true;
|
||||
};
|
||||
})
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
osConfig,
|
||||
...
|
||||
}: {
|
||||
config = lib.mkIf (config.programs.anki.enable && osConfig.host.impermanence.enable) {
|
||||
config = lib.mkIf (config.programs.anki.enable && config.impermanence.enable) {
|
||||
home.persistence."/persist${config.home.homeDirectory}" = {
|
||||
directories = [
|
||||
"${config.xdg.dataHome}/Anki2/"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/Bitwarden"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/bruno/"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/calibre"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
"${config.xdg.dataHome}/DaVinciResolve"
|
||||
"${config.xdg.configHome}/blackmagic"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.dataHome}/DBeaverData/"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/discord/"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
# Extension configuration
|
||||
".mozilla/firefox/${profile}/extension-settings.json"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
in {
|
||||
config = lib.mkIf (config.programs.firefox.enable && config.impermanence.enable) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/FreeCAD"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/GIMP"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/inkscape"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ in {
|
|||
"${config.xdg.configHome}/kdenliverc"
|
||||
"${config.xdg.dataHome}/kdenlive"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
"${config.xdg.configHome}/kritarc"
|
||||
"${config.xdg.dataHome}/krita"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/libreoffice"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ in {
|
|||
"${config.xdg.configHome}/mapillary-uploader"
|
||||
"${config.xdg.dataHome}/mapillary-uploader"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/obs-studio"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ in {
|
|||
"${config.xdg.configHome}/olympus"
|
||||
"${config.xdg.dataHome}/olympus"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/OpenRGB"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/MusicBrainz"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/qFlipper"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
method = "symlink";
|
||||
}
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.dataHome}/torbrowser"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
directories = [
|
||||
"${config.xdg.configHome}/chromium"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
"${config.xdg.configHome}/via"
|
||||
"${config.xdg.dataHome}/via"
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
method = "symlink";
|
||||
}
|
||||
];
|
||||
allowOther = true;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -400,74 +400,60 @@ in {
|
|||
};
|
||||
}
|
||||
(lib.mkIf config.storage.impermanence.enable (lib.mkMerge [
|
||||
(lib.mkIf config.storage.zfs.enable {
|
||||
storage.zfs.datasets."persist/system/sops" = {
|
||||
type = "zfs_fs";
|
||||
mount = {
|
||||
enable = true;
|
||||
mountPoint = SOPS_AGE_KEY_DIRECTORY;
|
||||
(lib.mkIf config.storage.zfs.enable (lib.mkMerge [
|
||||
{
|
||||
# sops age key needs to be available to pre persist for user generation
|
||||
storage.zfs.datasets = lib.mkMerge [
|
||||
{
|
||||
"local/system/sops" = {
|
||||
type = "zfs_fs";
|
||||
mount = {
|
||||
enable = true;
|
||||
mountPoint = SOPS_AGE_KEY_DIRECTORY;
|
||||
};
|
||||
atime = "off";
|
||||
relatime = "off";
|
||||
};
|
||||
}
|
||||
# Create ZFS datasets for each normal user
|
||||
(lib.mkMerge (
|
||||
builtins.map (user: {
|
||||
"local/home/${user.name}" = {
|
||||
type = "zfs_fs";
|
||||
mount = {
|
||||
enable = true;
|
||||
mountPoint = "/home/${user.name}";
|
||||
};
|
||||
snapshot.blankSnapshot = true;
|
||||
};
|
||||
"persist/home/${user.name}" = {
|
||||
type = "zfs_fs";
|
||||
mount = {
|
||||
enable = true;
|
||||
mountPoint = "/persist/home/${user.name}";
|
||||
};
|
||||
};
|
||||
})
|
||||
normalUsers
|
||||
))
|
||||
];
|
||||
|
||||
# Post resume commands to rollback user home datasets to blank snapshots
|
||||
boot.initrd.postResumeCommands = lib.mkAfter (
|
||||
lib.strings.concatLines (builtins.map (user: "zfs rollback -r rpool/local/home/${user.name}@blank")
|
||||
normalUsers)
|
||||
);
|
||||
|
||||
# Create persist home directories with proper permissions
|
||||
systemd = {
|
||||
tmpfiles.rules =
|
||||
builtins.map (
|
||||
user: "d /persist/home/${user.name} 700 ${user.name} ${user.name} -"
|
||||
)
|
||||
normalUsers;
|
||||
};
|
||||
atime = "off";
|
||||
relatime = "off";
|
||||
};
|
||||
})
|
||||
}
|
||||
]))
|
||||
]))
|
||||
# (lib.mkIf config.host.impermanence.enable {
|
||||
# boot.initrd.postResumeCommands = lib.mkAfter (
|
||||
# lib.strings.concatLines (builtins.map (user: "zfs rollback -r rpool/local/home/${user.name}@blank")
|
||||
# normalUsers)
|
||||
# );
|
||||
|
||||
# systemd = {
|
||||
# tmpfiles.rules =
|
||||
# builtins.map (
|
||||
# user: "d /persist/home/${user.name} 700 ${user.name} ${user.name} -"
|
||||
# )
|
||||
# normalUsers;
|
||||
# };
|
||||
|
||||
# fileSystems = lib.mkMerge [
|
||||
# (
|
||||
# builtins.listToAttrs (
|
||||
# builtins.map (user:
|
||||
# lib.attrsets.nameValuePair "/persist/home/${user.name}" {
|
||||
# neededForBoot = true;
|
||||
# })
|
||||
# normalUsers
|
||||
# )
|
||||
# )
|
||||
# (
|
||||
# builtins.listToAttrs (
|
||||
# builtins.map (user:
|
||||
# lib.attrsets.nameValuePair "/home/${user.name}" {
|
||||
# neededForBoot = true;
|
||||
# })
|
||||
# normalUsers
|
||||
# )
|
||||
# )
|
||||
# ];
|
||||
|
||||
# host.storage.pool.extraDatasets = lib.mkMerge (
|
||||
# (
|
||||
# builtins.map (user: {
|
||||
# "local/home/${user.name}" = {
|
||||
# type = "zfs_fs";
|
||||
# mountpoint = "/home/${user.name}";
|
||||
# options = {
|
||||
# canmount = "on";
|
||||
# };
|
||||
# postCreateHook = ''
|
||||
# zfs snapshot rpool/local/home/${user.name}@blank
|
||||
# '';
|
||||
# };
|
||||
# "persist/home/${user.name}" = {
|
||||
# type = "zfs_fs";
|
||||
# mountpoint = "/persist/home/${user.name}";
|
||||
# };
|
||||
# })
|
||||
# normalUsers
|
||||
# )
|
||||
# );
|
||||
# })
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue