From 2693402afdc410de956510def7719bfbda6a7bed Mon Sep 17 00:00:00 2001 From: Snorre Ettrup Altschul Date: Fri, 28 Feb 2025 23:40:54 +0100 Subject: [PATCH] ext + raidz --- configuration.nix | 3 +- disko.nix | 104 ++++++++++++++++++++-------------------------- flake.nix | 6 ++- 3 files changed, 53 insertions(+), 60 deletions(-) diff --git a/configuration.nix b/configuration.nix index 08de9dc..c5738cd 100644 --- a/configuration.nix +++ b/configuration.nix @@ -47,7 +47,8 @@ users.users."enis" = { isNormalUser = true; - hashedPasswordFile = "./password"; + # hashedPasswordFile = "./password"; + initialPassword = "1234"; extraGroups = [ "networkmanager" "audio" diff --git a/disko.nix b/disko.nix index 98f8568..7a6c1b8 100644 --- a/disko.nix +++ b/disko.nix @@ -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"; }; diff --git a/flake.nix b/flake.nix index b9b69b2..0a1449a 100644 --- a/flake.nix +++ b/flake.nix @@ -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