Change lithium to ZFS+impermanence

This commit is contained in:
Vili Sinervä 2025-07-18 00:33:26 +03:00
parent 80b3e52c0c
commit ae425fcd72
Signed by: Vili Sinervä
SSH key fingerprint: SHA256:FladqYjaE4scJY3Hi+gnShZ6ygnTJgixy0I6BAoHyos
4 changed files with 117 additions and 46 deletions

View file

@ -0,0 +1,80 @@
{
disko.devices = {
disk = {
main = {
device = "/dev/sda";
type = "disk";
content = {
type = "gpt";
partitions = {
ESP = {
name = "boot";
type = "EF00";
size = "512M";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
swap = {
size = "4G";
content = {
type = "swap";
discardPolicy = "both";
randomEncryption = true;
};
};
luks = {
size = "100%";
content = {
type = "luks";
name = "crypted";
settings = {
bypassWorkqueues = true;
allowDiscards = true;
};
extraFormatArgs = [ "-i 5000" ];
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
};
};
zpool = {
zroot = {
type = "zpool";
rootFsOptions = {
canmount = "off";
compression = "zstd";
};
datasets = {
nix = {
type = "zfs_fs";
mountpoint = "/nix";
options.mountpoint = "legacy";
};
persist = {
type = "zfs_fs";
options = {
mountpoint = "legacy";
"com.sun:auto-snapshot" = "true";
};
mountpoint = "/persist";
};
root = {
type = "zfs_fs";
mountpoint = "/";
options.mountpoint = "legacy";
postCreateHook = "zfs snapshot zroot/root@blank";
};
};
};
};
};
}

View file

@ -1,5 +1,7 @@
{ ... }:
{
imports = [ ../../disko/luks-zfs-impermanence.nix ];
custom = {
roles = {
desktop.enable = true;
@ -19,31 +21,13 @@
};
};
hardware.intelLaptop.enable = true;
platform.hibernate.enable = true;
services = {
syncthing.enable = true;
nixCacheClient = {
enable = true;
remoteBuilds.additional = true;
};
};
};
system.stateVersion = "24.05";
boot.kernelParams = [ "resume_offset=39292928" ];
fileSystems."/" = {
device = "/dev/disk/by-uuid/b43fe465-80e9-48d4-a4be-1113c917330e";
fsType = "ext4";
};
boot.initrd.luks.devices."nixos".device = "/dev/disk/by-uuid/4dc2fd8c-71da-4b95-91d5-7a118387172b";
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/D8BB-B91A";
fsType = "vfat";
options = [
"fmask=0077"
"dmask=0077"
];
};
networking.hostId = "ca94a90c";
system.stateVersion = "25.05";
}

View file

@ -3,10 +3,7 @@ let
cfg = config.custom.platform.impermanence;
in
{
options.custom.platform.impermanence.enable = lib.mkOption {
type = lib.types.bool;
default = false;
};
options.custom.platform.impermanence.enable = lib.mkEnableOption "custom impermanence setup";
config = lib.mkIf cfg.enable {
# Default set of directories we always want to persist

View file

@ -7,12 +7,11 @@ let
cfg = config.custom.roles.personalMachine;
in
{
options.custom.roles.personalMachine.enable = lib.mkOption {
type = lib.types.bool;
default = false;
};
options.custom.roles.personalMachine.enable =
lib.mkEnableOption "role for personal machines (desktop/laptop)";
config = lib.mkIf cfg.enable {
config =
(lib.mkIf cfg.enable {
custom = {
hardware = {
keychron.enable = true;
@ -30,5 +29,16 @@ in
};
};
system.autoUpgrade.allowReboot = lib.mkForce false;
};
})
// (lib.mkIf config.custom.platform.impermanence.enable {
# TODO Remove this temporary impermanence setup in favor of a more detailed one
environment.persistence."/persist".directories = [
{
directory = config.users.users.vili.home;
user = config.users.users.vili.name;
group = config.users.users.vili.group;
mode = "u=rwx,g=,o=";
}
];
});
}