Change lithium to ZFS+impermanence
This commit is contained in:
parent
80b3e52c0c
commit
ae425fcd72
4 changed files with 117 additions and 46 deletions
80
disko/luks-zfs-impermanence.nix
Normal file
80
disko/luks-zfs-impermanence.nix
Normal 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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,28 +7,38 @@ 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 {
|
||||
custom = {
|
||||
hardware = {
|
||||
keychron.enable = true;
|
||||
onlykey.enable = true;
|
||||
trackball.enable = true;
|
||||
config =
|
||||
(lib.mkIf cfg.enable {
|
||||
custom = {
|
||||
hardware = {
|
||||
keychron.enable = true;
|
||||
onlykey.enable = true;
|
||||
trackball.enable = true;
|
||||
};
|
||||
programs = {
|
||||
bitwarden.enable = true;
|
||||
communication.enable = true;
|
||||
firefox.enable = true;
|
||||
i3.enable = true;
|
||||
moonlight.enable = true;
|
||||
redshift.enable = true;
|
||||
usbAutoMount.enable = true;
|
||||
};
|
||||
};
|
||||
programs = {
|
||||
bitwarden.enable = true;
|
||||
communication.enable = true;
|
||||
firefox.enable = true;
|
||||
i3.enable = true;
|
||||
moonlight.enable = true;
|
||||
redshift.enable = true;
|
||||
usbAutoMount.enable = true;
|
||||
};
|
||||
};
|
||||
system.autoUpgrade.allowReboot = lib.mkForce false;
|
||||
};
|
||||
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=";
|
||||
}
|
||||
];
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue