2023-12-17 13:06:57 +01:00
|
|
|
# nix run github:nix-community/disko -- --mode zap_create_mount ./disko-config.nix
|
|
|
|
# nixos-generate-config --no-filesystems --root /mnt
|
|
|
|
{ config, lib, ... }:
|
|
|
|
{
|
|
|
|
|
2023-12-17 19:17:59 +01:00
|
|
|
boot.loader.systemd-boot.enable = true;
|
|
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
|
|
|
boot.tmp.useTmpfs = true; # make /tmp a tmpfs (performance!)
|
|
|
|
|
|
|
|
# ZFS stuff
|
|
|
|
# ---------
|
2023-12-17 16:17:28 +01:00
|
|
|
boot.supportedFilesystems = [ "zfs" ];
|
|
|
|
# head -c4 /dev/urandom | od -A none -t x4
|
|
|
|
networking.hostId = "59e38471";
|
|
|
|
services.zfs.autoSnapshot.enable = true;
|
2023-12-17 13:06:57 +01: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-12-17 19:17:59 +01:00
|
|
|
# disko configuration
|
|
|
|
# -------------------
|
2023-12-17 13:06:57 +01: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-12-17 16:17:28 +01:00
|
|
|
settings.allowDiscards = true;
|
|
|
|
passwordFile = "/tmp/secret.key";
|
2023-12-17 13:06:57 +01:00
|
|
|
content = {
|
|
|
|
type = "zfs";
|
|
|
|
pool = "zroot";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
zpool = {
|
|
|
|
zroot = {
|
|
|
|
type = "zpool";
|
|
|
|
rootFsOptions = {
|
|
|
|
mountpoint = "none";
|
|
|
|
canmount = "off";
|
|
|
|
compression = "lz4";
|
|
|
|
};
|
|
|
|
datasets = {
|
|
|
|
"root" = {
|
|
|
|
type = "zfs_fs";
|
|
|
|
mountpoint = "/";
|
|
|
|
options = {
|
|
|
|
mountpoint = "legacy";
|
|
|
|
compression = "lz4";
|
|
|
|
};
|
|
|
|
};
|
2023-12-17 16:17:28 +01:00
|
|
|
"store" = {
|
|
|
|
type = "zfs_fs";
|
|
|
|
mountpoint = "/nix/store";
|
|
|
|
options = {
|
|
|
|
mountpoint = "legacy";
|
|
|
|
compression = "lz4";
|
|
|
|
};
|
|
|
|
};
|
2023-12-17 13:06:57 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|