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-04-28 12:57:48 +02:00
|
|
|
{ ... }:
|
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-04-27 22:43:52 +02:00
|
|
|
disko.devices = {
|
|
|
|
disk = {
|
|
|
|
root = {
|
|
|
|
type = "disk";
|
|
|
|
device = "/dev/nvme0n1";
|
|
|
|
content = {
|
|
|
|
type = "table";
|
|
|
|
format = "gpt";
|
|
|
|
partitions = [
|
|
|
|
{
|
|
|
|
name = "ESP";
|
|
|
|
start = "0";
|
|
|
|
end = "500MiB";
|
|
|
|
bootable = true;
|
|
|
|
content = {
|
|
|
|
type = "filesystem";
|
|
|
|
format = "vfat";
|
|
|
|
mountpoint = "/boot";
|
|
|
|
mountOptions = [
|
|
|
|
"defaults"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "zfs";
|
|
|
|
start = "500MiB";
|
|
|
|
end = "100%";
|
|
|
|
content = {
|
|
|
|
type = "luks";
|
|
|
|
name = "root";
|
2023-04-28 23:30:11 +02:00
|
|
|
#keyFile = "/root/password"; # keyFile contains the key for encryption, not the passphrase to unlock the key
|
2023-04-27 22:43:52 +02:00
|
|
|
content = {
|
|
|
|
type = "zfs";
|
|
|
|
pool = "zroot";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2023-04-28 12:57:48 +02:00
|
|
|
} // builtins.mapAttrs
|
|
|
|
(name: device_path: {
|
|
|
|
type = "disk";
|
|
|
|
device = device_path;
|
|
|
|
content = {
|
|
|
|
type = "table";
|
|
|
|
format = "gpt";
|
|
|
|
partitions = [
|
|
|
|
{
|
|
|
|
name = "zfs";
|
|
|
|
start = "0";
|
|
|
|
end = "100%";
|
|
|
|
content = {
|
|
|
|
type = "luks";
|
|
|
|
name = "raid_${name}";
|
2023-04-28 23:30:11 +02:00
|
|
|
#keyFile = "/root/password"; # keyFile contains the key for encryption, not the passphrase to unlock the key
|
2023-04-28 12:57:48 +02:00
|
|
|
content = {
|
|
|
|
type = "zfs";
|
|
|
|
pool = "zraid";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
2023-04-27 22:43:52 +02:00
|
|
|
)
|
|
|
|
raid_disks;
|
|
|
|
|
|
|
|
zpool = {
|
|
|
|
|
|
|
|
zroot = {
|
|
|
|
type = "zpool";
|
2023-04-30 09:58:49 +02:00
|
|
|
rootFsOptions = {
|
|
|
|
mountpoint = "none";
|
|
|
|
canmount = "off";
|
|
|
|
};
|
2023-04-27 22:43:52 +02:00
|
|
|
datasets = {
|
|
|
|
"root" = {
|
|
|
|
type = "zfs_fs";
|
|
|
|
mountpoint = "/";
|
2023-04-30 00:47:46 +02:00
|
|
|
options = {
|
2023-04-30 09:58:49 +02:00
|
|
|
mountpoint = "legacy";
|
2023-04-30 00:47:46 +02:00
|
|
|
compression = "lz4";
|
|
|
|
};
|
2023-04-27 22:43:52 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-28 23:30:11 +02:00
|
|
|
# use boot.zfs.extraPools = [ "zraid" ] to mount this pool during boot time.
|
2023-04-29 23:29:05 +02:00
|
|
|
# or `zpool import -f zraid` once on the first boot and reboot
|
2023-05-01 15:35:56 +02:00
|
|
|
# you have to run `zpool import -f zraid` every time you rename your networking.{hostname,hostId}
|
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 = {
|
2023-04-30 09:58:49 +02:00
|
|
|
mountpoint = "legacy";
|
2023-04-30 00:47:46 +02:00
|
|
|
compression = "lz4";
|
|
|
|
};
|
2023-04-27 22:43:52 +02:00
|
|
|
};
|
2023-04-30 00:47:46 +02:00
|
|
|
"nextcloud" = {
|
2023-04-27 22:43:52 +02:00
|
|
|
type = "zfs_fs";
|
2023-04-30 00:47:46 +02:00
|
|
|
mountpoint = "/nextcloud";
|
2023-04-27 22:43:52 +02:00
|
|
|
options = {
|
2023-04-30 09:58:49 +02:00
|
|
|
mountpoint = "legacy";
|
2023-04-28 12:57:48 +02:00
|
|
|
compression = "lz4";
|
2023-04-27 22:43:52 +02:00
|
|
|
"com.sun:auto-snapshot" = "false";
|
2023-04-28 16:18:30 +02:00
|
|
|
"com.sun:auto-snapshot:daily" = "true,keep=32";
|
|
|
|
"com.sun:auto-snapshot:montly" = "true,keep=48";
|
2023-04-27 22:43:52 +02:00
|
|
|
};
|
|
|
|
};
|
2023-04-30 00:47:46 +02:00
|
|
|
"borg" = {
|
|
|
|
type = "zfs_fs";
|
|
|
|
mountpoint = "/borg";
|
|
|
|
options = {
|
2023-04-30 09:58:49 +02:00
|
|
|
mountpoint = "legacy";
|
2023-04-30 00:47:46 +02:00
|
|
|
compression = "lz4";
|
|
|
|
"com.sun:auto-snapshot" = "false";
|
|
|
|
"com.sun:auto-snapshot:daily" = "true,keep=32";
|
|
|
|
};
|
|
|
|
};
|
2023-05-02 12:55:17 +02:00
|
|
|
"services" = {
|
|
|
|
type = "zfs_fs";
|
|
|
|
mountpoint = "/srv";
|
|
|
|
options = {
|
|
|
|
mountpoint = "legacy";
|
|
|
|
compression = "lz4";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
"services/gitea" = {
|
|
|
|
type = "zfs_fs";
|
|
|
|
mountpoint = "/srv/gitea";
|
|
|
|
options = {
|
|
|
|
mountpoint = "legacy";
|
|
|
|
compression = "lz4";
|
|
|
|
};
|
|
|
|
};
|
2023-04-27 22:43:52 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|