ext + raidz

This commit is contained in:
Snorre Ettrup Altschul 2025-02-28 23:40:54 +01:00
parent 8c47a51a41
commit 2693402afd
3 changed files with 53 additions and 60 deletions

View file

@ -47,7 +47,8 @@
users.users."enis" = {
isNormalUser = true;
hashedPasswordFile = "./password";
# hashedPasswordFile = "./password";
initialPassword = "1234";
extraGroups = [
"networkmanager"
"audio"

104
disko.nix
View file

@ -1,7 +1,8 @@
{ lib
, root-disk ? "Expected a mf disk brother"
, raid-disks ? "Expected disks for raid"
, ...
{
lib,
root-disk ? "Expected a mf disk brother",
raid-disks ? "Expected disks for raid",
...
}: {
disko.devices = {
disk =
@ -12,34 +13,55 @@
content = {
type = "gpt";
partitions = {
ESP = {
boot = {
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
mountOptions = ["umask=0077"];
};
};
zfs = {
root = {
size = "100%";
content = {
type = "zfs";
pool = "zroot";
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
};
# disk2 = {
# type = "disk";
# device = "/dev/my-disk2";
# content = {
# type = "gpt";
# partitions = {
# boot = {
# size = "1M";
# type = "EF02"; # for grub MBR
# };
# mdadm = {
# size = "100%";
# content = {
# type = "mdraid";
# name = "raid1";
# };
# };
# };
# };
# };
}
// lib.attrsets.genAttrs raid-disks (
name: {
device = "/dev/" + name;
content = {
type = "gpt";
partitions.raid-pool = {
// lib.attrsets.genAttrs raid-disks (name: {
type = "disk";
device = "/dev" + name;
content = {
type = "gpt";
partitions = {
zfs = {
size = "100%";
content = {
type = "zfs";
@ -47,59 +69,25 @@
};
};
};
}
);
zpool = {
zroot = {
type = "zpool";
rootFsOptions = {
mountpoint = "none";
compression = "zstd";
acltype = "posixacl";
xattr = "sa";
"com.sun:auto-snapshot" = "false";
};
options = {
ashift = "12";
};
datasets = {
"root" = {
type = "zfs_fs";
options = {
# encryption = "aes-256-gcm";
# keyformat = "passphrase";
# keylocation = "prompt";
};
mountpoint = "/";
};
});
"root/nix" = {
type = "zfs_fs";
options.mountpoint = "/nix";
mountpoint = "/nix";
};
};
};
zraid = lib.mkIf (builtins.length raid-disks > 0) {
zpool = lib.mkIf (builtins.length raid-disks > 0) {
zraid = {
type = "zpool";
mode = "raidz";
options = {
ashift = "12";
autotrim = "on";
autoexpand = "on";
};
# TODO: Cache-ing
rootFsOptions = {
compression = "zstd";
mountpoint = "none";
"com.sun:auto-snapshot" = "false";
};
datasets = {
"var" = {
var = {
type = "zfs_fs";
mountpoint = "/var";
};
"home" = {
home = {
type = "zfs_fs";
mountpoint = "/home";
};

View file

@ -33,7 +33,11 @@
(import ./disko.nix {
lib = pkgs.lib;
root-disk = "/dev/vda";
raid-disks = [];
raid-disks = [
"vdb"
"vdc"
"vdd"
];
})
inputs.home-manager.nixosModules.default