From 9b4d0d6c2e4dafd3983dc2ded99504bc8fd6643b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 15 Aug 2023 13:29:21 +0200 Subject: [PATCH] add zfs example --- disk-configs/zfs.nix | 105 +++++++++++++++++++++++++++++++++++++++++++ flake.nix | 2 + 2 files changed, 107 insertions(+) create mode 100644 disk-configs/zfs.nix diff --git a/disk-configs/zfs.nix b/disk-configs/zfs.nix new file mode 100644 index 0000000..4827d69 --- /dev/null +++ b/disk-configs/zfs.nix @@ -0,0 +1,105 @@ +{ + networking.hostId = "8425e349"; # needed for ZFS + + disko.devices = { + disk = { + disk1 = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + boot = { + size = "1M"; + type = "EF02"; # for grub MBR + }; + ESP = { + size = "500M"; + type = "EF00"; + content = { + type = "mdraid"; + name = "boot"; + }; + }; + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "zroot"; + }; + }; + }; + }; + }; + disk2 = { + type = "disk"; + device = "/dev/nvme1n1"; + content = { + type = "gpt"; + partitions = { + boot = { + size = "1M"; + type = "EF02"; # for grub MBR + }; + ESP = { + size = "500M"; + type = "EF00"; + content = { + type = "mdraid"; + name = "boot"; + }; + }; + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "zroot"; + }; + }; + }; + }; + }; + }; + zpool = { + zroot = { + type = "zpool"; + mode = "mirror"; + rootFsOptions = { + compression = "lz4"; + "com.sun:auto-snapshot" = "true"; + }; + rootFsOptions = { + mountpoint = "none"; + }; + + datasets = { + "root" = { + type = "zfs_fs"; + mountpoint = null; + }; + "root/nixos" = { + type = "zfs_fs"; + mountpoint = "/"; + }; + "root/home" = { + type = "zfs_fs"; + mountpoint = "/home"; + }; + }; + }; + }; + + mdadm = { + boot = { + type = "mdadm"; + level = 1; + metadata = "1.0"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + }; + }; +} diff --git a/flake.nix b/flake.nix index b850cb2..24d40d7 100644 --- a/flake.nix +++ b/flake.nix @@ -21,11 +21,13 @@ (nixpkgs.outPath + "/nixos/modules/installer/scan/not-detected.nix") disko.nixosModules.disko ./disk-configs/simple-efi.nix # choose your favorite disk layout here + #./disk-configs/zfs.nix # choose your favorite disk layout here { boot.loader.grub = { efiSupport = true; efiInstallAsRemovable = true; }; + boot.swraid.enable = true; # Alternative to grub #boot.loader.systemd-boot.enable = true; # when installing toggle this