diff --git a/machines/akhaten/default.nix b/machines/akhaten/default.nix index e9a5944..08af3d9 100644 --- a/machines/akhaten/default.nix +++ b/machines/akhaten/default.nix @@ -1,4 +1,4 @@ -{ inputs, ... }: +{ inputs, config, ... }: { imports = [ ./hardware.nix @@ -18,9 +18,27 @@ }; deployment.tags = [ "server" ]; + deployment.targetHost = config.machine.meta.ips.public.ipv4; disko = import ./disko.nix; + environment.persistence."/persistent" = { + hideMounts = true; + directories = [ + "/var/lib" + "/var/log" + "/srv" + ]; + files = [ + "/etc/machine-id" + "/etc/ssh/ssh_host_ed25519_key" + "/etc/ssh/ssh_host_ed25519_key.pub" + ]; + }; + + fileSystems."/srv".neededForBoot = true; + fileSystems."/persistent".neededForBoot = true; + services.fail2ban.enable = true; networking.useNetworkd = true; diff --git a/machines/akhaten/disko.nix b/machines/akhaten/disko.nix index 5c32172..464ebef 100644 --- a/machines/akhaten/disko.nix +++ b/machines/akhaten/disko.nix @@ -9,7 +9,7 @@ partitions = { boot = { size = "1M"; - type = "EF02"; # for grub MBR + type = "EF02"; }; ESP = { size = "512M"; @@ -20,17 +20,60 @@ mountpoint = "/boot"; }; }; + swap = { + size = "16G"; + content = { + type = "swap"; + discardPolicy = "both"; + }; + }; root = { size = "100%"; content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; + type = "lvm_pv"; + vg = "mainpool"; }; }; }; }; }; }; + lvm_vg = { + mainpool = { + type = "lvm_vg"; + lvs = { + root = { + size = "100G"; + pool = "mainpool"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + mountOptions = [ "defaults" ]; + }; + }; + persistent = { + size = "100G"; + pool = "mainpool"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/persistent"; + mountOptions = [ "defaults" ]; + }; + }; + + store = { + size = "600G"; + pool = "mainpool"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/nix"; + }; + }; + }; + }; + }; }; } diff --git a/machines/akhaten/hardware.nix b/machines/akhaten/hardware.nix index fb11274..924b82f 100644 --- a/machines/akhaten/hardware.nix +++ b/machines/akhaten/hardware.nix @@ -2,18 +2,24 @@ config, lib, modulesPath, + pkgs, ... }: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + boot.loader.grub.enable = true; boot.initrd.availableKernelModules = [ "ahci" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - swapDevices = [ { device = "/dev/disk/by-uuid/b2563fcf-18af-43da-b2d2-3e7b84f72421"; } ]; + boot.initrd.postDeviceCommands = '' + lvm lvremove --force /dev/mainpool/root || : + yes | lvm lvcreate --size 100G --name root mainpool + ${pkgs.e2fsprogs}/bin/mkfs.ext4 /dev/mainpool/root + ''; networking.useDHCP = lib.mkDefault true;