added disko module, common-config, cleanup, etc.

This commit is contained in:
eyjhb 2024-08-08 19:02:02 +02:00
parent 8ad126aa99
commit 52af8fc06e
Signed by: eyjhb
GPG key ID: 609F508E3239F920
9 changed files with 314 additions and 156 deletions

View file

@ -4,13 +4,7 @@ let
sources = import ./../shared/sources/sources.nix;
in {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
(modulesPath + "/profiles/qemu-guest.nix")
(sources.disko + "/module.nix")
./../shared/modules
./../shared/platforms/hetzner.nix
./gerd/disk-zfs.nix
./../shared
./../shared/applications/server/nginx.nix
./../shared/applications/state/ssh.nix
@ -22,41 +16,29 @@ in {
networking.hostName = "gerd";
networking.hostId = "e1166ac9";
boot.loader.grub = {
# no need to set devices, disko will add all devices that have a EF02 partition to the list already
# devices = [ ];
efiSupport = true;
efiInstallAsRemovable = true;
};
services.openssh.enable = true;
mine = {
state.enable = true;
disks = {
disk = "/dev/sda";
pools.rpool.datasets = {
"safe/svcs/forgejo" = { mountpoint = "/srv/forgejo"; extra.options.quota = "5G"; };
};
};
ssh-on-boot.enable = true;
platforms.hetzner.network.address = [
"65.108.221.240/32"
"2a01:4f9:c012:743e::1/64"
];
};
services.teeworlds = {
platforms.hetzner = {
enable = true;
openPorts = true;
network.address = [
"65.108.221.240/32"
"2a01:4f9:c012:743e::1/64"
];
};
};
boot.initrd.postDeviceCommands = lib.mkAfter ''
zfs rollback -r rpool/root@blank
'';
environment.systemPackages = with pkgs; [
vim
jq
];
users.users.root.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPuma8g+U8Wh+4mLvZoV9V+ngPqxjuIG4zhsbaTeXq65 eyjhb@chronos"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGee4uz+HDOj4Y4ANOhWJhoc4mMLP1gz6rpKoMueQF2J rendal@popper"
];
system.stateVersion = "24.05";
}

View file

@ -1,85 +0,0 @@
{ lib, ... }:
let
makeZFSDatasets = datasets: (lib.mapAttrs' (n: v: lib.nameValuePair v.dataset ({
type = "zfs_fs";
mountpoint = n;
options.mountpoint = "legacy";
} // (if v ? extra then v.extra else {}))) datasets);
in {
disko.devices = {
disk.disk1 = {
type = "disk";
device = lib.mkDefault "/dev/sda";
content = {
type = "gpt";
partitions = {
boot = {
name = "boot";
size = "1M";
type = "EF02";
};
esp = {
name = "ESP";
size = "500M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
luks = {
size = "100%";
content = {
type = "luks";
name = "cryptroot";
settings.allowDiscards = true;
# passwordFile = "/tmp/luks.pass";
content = {
type = "zfs";
pool = "rpool";
};
};
};
};
};
};
zpool = {
rpool = {
type = "zpool";
# rootFsOptions.compression = "zstd";
rootFsOptions = {
compression = "on";
atime = "off";
acltype = "posixacl";
xattr = "sa";
# test
# "com.sun:auto-snapshot" = "false";
# "com.klarasystems:vdev_zaps_v2" = "false";
};
datasets = let
baseDatasets = {
"/" = { dataset = "root"; extra = { postCreateHook = "zfs snapshot rpool/root@blank"; }; };
"/nix".dataset = "local/nix";
"/state/stash".dataset = "local/stash";
"/state/home".dataset = "safe/home";
"/state/root".dataset = "safe/persistent";
# extra datasets
"/srv/forgejo" = { dataset = "safe/svcs/forgejo"; extra.options.quota = "5G"; };
};
in (makeZFSDatasets baseDatasets);
};
};
};
fileSystems."/state/root".neededForBoot = true;
fileSystems."/state/home".neededForBoot = true;
fileSystems."/state/stash".neededForBoot = true;
}

View file

@ -1,35 +0,0 @@
{
services.zrepl = {
enable = true;
settings.jobs = [
{
type = "push";
name = "safesnapshots";
filesystems = [
"rpool/safe<"
];
snapshotting = {
type = "periodic";
interval = "5m";
prefix = "zrepl_";
};
pruning = {
keep_sender = [
{
type = "grid";
regex = "^zrepl_.*";
# 1. keep all snapshots for 30 minutes
# 2. keep one every 15 minutes for 2 hours
# 3. keep one every hour for 1 day
grid = "1x30m(keep=all) | 8x15m | 14x1d";
}
];
};
}
];
};
}