nixos-config/nixos/machines/chungus/hardware-configuration/disko-config.nix

245 lines
7.3 KiB
Nix
Raw Normal View History

2023-04-28 23:30:11 +02:00
# nix run github:nix-community/disko -- --mode zap_create_mount ./disko-config.nix
# nixos-generate-config --no-filesystems --root /mnt
2023-04-27 22:43:52 +02:00
# vim /mnt/configuration.nix
2023-04-29 23:29:05 +02:00
# nixos-install
2023-08-23 10:02:42 +02:00
{ config, lib, ... }:
2023-04-28 09:02:11 +02:00
let
raid_disks = {
"TOSHIBA_1360A003FVGG" = "/dev/disk/by-id/ata-TOSHIBA_MG08ACA16TE_1360A003FVGG";
"TOSHIBA_1360A00BFVGG" = "/dev/disk/by-id/ata-TOSHIBA_MG08ACA16TE_1360A00BFVGG";
"TOSHIBA_1360A00VFVGG" = "/dev/disk/by-id/ata-TOSHIBA_MG08ACA16TE_1360A00VFVGG";
"TOSHIBA_41R0A0EBF57H" = "/dev/disk/by-id/ata-TOSHIBA_MG08ACA16TE_41R0A0EBF57H";
"TOSHIBA_5120A03WF57H" = "/dev/disk/by-id/ata-TOSHIBA_MG08ACA16TE_5120A03WF57H";
};
in
{
2023-08-23 10:02:42 +02:00
# ZFS already has its own scheduler. Without this my(@Artturin) computer froze for a second when i nix build something.
# copied from : https://github.com/numtide/srvos/blob/main/nixos/common/zfs.nix
services.udev.extraRules = lib.optionalString (config.boot.zfs.enabled) ''
ACTION=="add|change", KERNEL=="sd[a-z]*[0-9]*|mmcblk[0-9]*p[0-9]*|nvme[0-9]*n[0-9]*p[0-9]*", ENV{ID_FS_TYPE}=="zfs_member", ATTR{../queue/scheduler}="none"
'';
2023-04-27 22:43:52 +02:00
disko.devices = {
disk = {
root = {
type = "disk";
device = "/dev/nvme0n1";
content = {
2024-03-03 20:28:07 +01:00
type = "gpt";
partitions = {
boot = {
priority = 1;
size = "500M";
2023-04-27 22:43:52 +02:00
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"defaults"
];
};
2024-03-03 20:28:07 +01:00
};
root = {
priority = 100;
size = "100%";
2023-04-27 22:43:52 +02:00
content = {
type = "luks";
name = "root";
content = {
type = "zfs";
pool = "zroot";
};
};
2024-03-03 20:28:07 +01:00
};
};
2023-04-27 22:43:52 +02:00
};
};
2023-04-28 12:57:48 +02:00
} // builtins.mapAttrs
(name: device_path: {
type = "disk";
device = device_path;
content = {
2024-03-03 20:28:07 +01:00
type = "gpt";
partitions = {
zfs = {
size = "100%";
2023-04-28 12:57:48 +02:00
content = {
type = "luks";
name = "raid_${name}";
content = {
type = "zfs";
pool = "zraid";
};
};
2024-03-03 20:28:07 +01:00
};
};
2023-04-28 12:57:48 +02:00
};
}
2023-04-27 22:43:52 +02:00
)
raid_disks;
zpool = {
zroot = {
type = "zpool";
rootFsOptions = {
mountpoint = "none";
canmount = "off";
compression = "lz4";
};
2023-04-27 22:43:52 +02:00
datasets = {
"root" = {
type = "zfs_fs";
mountpoint = "/";
2023-04-30 00:47:46 +02:00
options = {
mountpoint = "legacy";
2023-04-30 00:47:46 +02:00
compression = "lz4";
};
2023-04-27 22:43:52 +02:00
};
"services2" = {
type = "zfs_fs";
mountpoint = "/srv2";
options = {
mountpoint = "legacy";
compression = "lz4";
2024-03-03 20:28:07 +01:00
"com.sun:auto-snapshot:daily" = toString true;
};
};
"paperless" = {
type = "zfs_fs";
mountpoint = "/var/lib/paperless";
options = {
mountpoint = "legacy";
compression = "lz4";
"com.sun:auto-snapshot:daily" = toString true;
};
};
"postgresql" = {
type = "zfs_fs";
mountpoint = "/var/lib/postgresql";
options = {
mountpoint = "legacy";
compression = "lz4";
"com.sun:auto-snapshot:daily" = toString true;
};
};
2023-04-27 22:43:52 +02:00
};
};
2023-05-02 19:22:17 +02:00
# `zpool import -f zraid` once on the first boot and reboot
2024-04-10 18:16:51 +02:00
# todo: rename to tank next time (this is the standard)
2023-04-27 22:43:52 +02:00
zraid = {
type = "zpool";
mode = "raidz2";
2023-04-30 00:47:46 +02:00
rootFsOptions = {
mountpoint = "none";
canmount = "off";
};
2023-04-27 22:43:52 +02:00
datasets = {
"media" = {
type = "zfs_fs";
mountpoint = "/media";
2023-04-30 00:47:46 +02:00
options = {
mountpoint = "legacy";
2023-04-30 00:47:46 +02:00
compression = "lz4";
2024-03-03 20:28:07 +01:00
"com.sun:auto-snapshot:daily" = toString true;
"com.sun:auto-snapshot:weekly" = toString true;
"com.sun:auto-snapshot:monthly" = toString true;
2023-04-30 00:47:46 +02:00
};
2023-04-27 22:43:52 +02:00
};
"legacy" = {
type = "zfs_fs";
mountpoint = "/legacy";
options = {
mountpoint = "legacy";
compression = "lz4";
2024-03-03 20:28:07 +01:00
"com.sun:auto-snapshot:monthly" = toString true;
};
};
2023-04-30 00:47:46 +02:00
"borg" = {
type = "zfs_fs";
mountpoint = "/borg";
options = {
mountpoint = "legacy";
2023-04-30 00:47:46 +02:00
compression = "lz4";
2024-03-03 20:28:07 +01:00
"com.sun:auto-snapshot:daily" = toString true;
"com.sun:auto-snapshot:weekly" = toString true;
"com.sun:auto-snapshot:monthly" = toString true;
2023-05-12 11:17:58 +02:00
};
};
"syncthing" = {
type = "zfs_fs";
mountpoint = "/syncthing";
options = {
mountpoint = "legacy";
compression = "lz4";
2024-03-03 20:28:07 +01:00
"com.sun:auto-snapshot:daily" = toString true;
"com.sun:auto-snapshot:weekly" = toString true;
"com.sun:auto-snapshot:monthly" = toString true;
2023-04-30 00:47:46 +02:00
};
};
2023-07-08 03:15:18 +02:00
"mirror" = {
2023-05-02 12:55:17 +02:00
type = "zfs_fs";
2023-07-08 03:15:18 +02:00
mountpoint = "/mirror";
2023-05-02 12:55:17 +02:00
options = {
mountpoint = "legacy";
compression = "lz4";
2024-03-03 20:28:07 +01:00
"com.sun:auto-snapshot:daily" = toString true;
"com.sun:auto-snapshot:weekly" = toString true;
"com.sun:auto-snapshot:montly" = toString true;
2023-05-02 12:55:17 +02:00
};
};
2023-07-08 03:15:18 +02:00
"services" = {
2023-05-02 12:55:17 +02:00
type = "zfs_fs";
2023-07-08 03:15:18 +02:00
mountpoint = "/srv";
2023-05-02 12:55:17 +02:00
options = {
mountpoint = "legacy";
compression = "lz4";
2024-03-03 20:28:07 +01:00
"com.sun:auto-snapshot:daily" = toString true;
"com.sun:auto-snapshot:weekly" = toString true;
"com.sun:auto-snapshot:montly" = toString true;
2023-05-02 12:55:17 +02:00
};
};
2023-05-05 09:49:58 +02:00
"container" = {
type = "zfs_fs";
mountpoint = "/var/lib/containers/storage"; # needed for podman
options = {
mountpoint = "legacy";
compression = "lz4";
acltype = "posixacl"; # needed for podman
};
};
2023-05-03 16:09:27 +02:00
"robi" = {
type = "zfs_fs";
mountpoint = "/robi";
options = {
mountpoint = "legacy";
compression = "lz4";
2024-03-03 20:28:07 +01:00
"com.sun:auto-snapshot:daily" = toString true;
"com.sun:auto-snapshot:weekly" = toString true;
2023-05-03 16:09:27 +02:00
};
};
"robi/media" = {
type = "zfs_fs";
mountpoint = "/robi/media";
options = {
mountpoint = "legacy";
compression = "lz4";
};
};
"robi/torrent" = {
type = "zfs_fs";
mountpoint = "/robi/torrent";
options = {
mountpoint = "legacy";
compression = "lz4";
};
};
2023-04-27 22:43:52 +02:00
};
};
};
};
}