feat: made impermanence create datasets for zfs and persistence
This commit is contained in:
parent
409fdb7276
commit
adc6b90c93
4 changed files with 188 additions and 43 deletions
73
modules/nixos-modules/storage/storage.nix
Normal file
73
modules/nixos-modules/storage/storage.nix
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
util,
|
||||
...
|
||||
}: {
|
||||
# TODO: create all of the datasets from option and home-manager datasets
|
||||
# TODO: set up datasets for systemd services that want a dataset created
|
||||
config = lib.mkMerge [
|
||||
(
|
||||
lib.mkIf config.storage.zfs.enable (lib.mkMerge [
|
||||
{
|
||||
storage.zfs.datasets = {
|
||||
"persist/system/nix" = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/nix";
|
||||
options = {
|
||||
atime = "off";
|
||||
relatime = "off";
|
||||
canmount = "on";
|
||||
"com.sun:auto-snapshot" = "false";
|
||||
};
|
||||
};
|
||||
"persist/system/var/log" = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/persist/system/var/log";
|
||||
options = {
|
||||
"com.sun:auto-snapshot" = "false";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
(util.mkUnless config.storage.impermanence.enable {
|
||||
# TODO: configure datasets for normal zfs
|
||||
# TODO: create datasets for systemd.services.<name>.storage.impermanence.datasets
|
||||
storage.zfs.datasets = {
|
||||
"persist/system/root" = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/";
|
||||
canmount = "on";
|
||||
};
|
||||
};
|
||||
})
|
||||
(lib.mkIf config.storage.impermanence.enable {
|
||||
storage.impermanence.datasets = {
|
||||
"persist/system/root" = {
|
||||
type = "zfs_fs";
|
||||
};
|
||||
};
|
||||
storage.zfs.datasets = {
|
||||
# TODO: is there a way that we can link these two folders in configs via storage.impermanence.datasets
|
||||
"local/system/root" = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/";
|
||||
options = {
|
||||
canmount = "on";
|
||||
};
|
||||
postCreateHook = ''
|
||||
zfs snapshot rpool/local/system/root@blank
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# TODO: home-manager.users.<user>.storage.impermanence.enable
|
||||
# is false then persist the entire directory of the user
|
||||
# if true persist home-manager.users.<user>.storage.impermanence.datasets
|
||||
# TODO: systemd.services.<name>.storage.datasets persists
|
||||
})
|
||||
])
|
||||
)
|
||||
# TODO: configure other needed storage modes here
|
||||
];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue