feat: updated user configs to better match original config

This commit is contained in:
Leyla Becker 2025-11-14 22:06:32 -06:00
parent 1eb66d1c31
commit f8edad75bf
3 changed files with 73 additions and 51 deletions

View file

@ -10,6 +10,16 @@
lib.mkIf config.storage.zfs.enable (lib.mkMerge [
{
storage.zfs.datasets = {
"persist" = {
type = "zfs_fs";
};
"persist/local" = {
type = "zfs_fs";
};
"persist/replicate" = {
type = "zfs_fs";
};
"persist/local/nix" = {
type = "zfs_fs";
mount = {
@ -22,6 +32,7 @@
atime = "off";
relatime = "off";
};
"persist/replicate/system/var/log" = {
type = "zfs_fs";
mount = {
@ -54,6 +65,9 @@
'';
storage.zfs.datasets = {
"ephemeral" = {
type = "zfs_fs";
};
"ephemeral/system/root" = {
type = "zfs_fs";
mount = {

View file

@ -73,11 +73,7 @@
snapshot = {
# This option should set this option flag
# "com.sun:auto-snapshot" = "false";
autoSnapshot = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable automatic snapshots for this dataset";
};
autoSnapshot = lib.mkEnableOption "Enable automatic snapshots for this dataset";
# Creates a blank snapshot in the post create hook for rollback purposes
blankSnapshot = lib.mkEnableOption "Should a blank snapshot be auto created in the post create hook";
};

View file

@ -399,13 +399,10 @@ in {
};
};
}
(lib.mkIf config.storage.impermanence.enable (lib.mkMerge [
(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 [
{
"persist/local/system/sops" = {
storage.zfs.datasets."persist/local/system/sops" = {
type = "zfs_fs";
mount = {
enable = true;
@ -415,7 +412,23 @@ in {
relatime = "off";
};
}
(lib.mkMerge (
(lib.mkIf (!config.storage.impermanence.enable) {
storage.zfs.datasets = lib.mkMerge (
builtins.map (user: {
"persist/replicate/home/${user.name}" = {
type = "zfs_fs";
mount = {
enable = true;
mountPoint = "/home/${user.name}";
};
snapshot.autoSnapshot = true;
};
})
normalUsers
);
})
(lib.mkIf config.storage.impermanence.enable {
storage.zfs.datasets = lib.mkMerge (
builtins.map (user: {
"ephemeral/home/${user.name}" = {
type = "zfs_fs";
@ -427,8 +440,7 @@ in {
};
})
normalUsers
))
];
);
# Post resume commands to rollback user home datasets to blank snapshots
boot.initrd.postResumeCommands = lib.mkAfter (
@ -436,16 +448,16 @@ in {
normalUsers)
);
# TODO: I don't think we need this anymore but I have not tested it
# Create persist home directories with proper permissions
systemd = {
tmpfiles.rules =
builtins.map (
user: "d /persist/replicate/home/${user.name} 700 ${user.name} ${user.name} -"
)
normalUsers;
};
}
]))
# systemd = {
# tmpfiles.rules =
# builtins.map (
# user: "d /persist/replicate/home/${user.name} 700 ${user.name} ${user.name} -"
# )
# normalUsers;
# };
})
]))
];
}