{ config, lib, pkgs, ... }:

with lib;
let

in {
  system.stateVersion = "21.05";

  boot = {
    initrd = {
      availableKernelModules = [
        "uhci_hcd"
        "ehci_pci"
        "ata_piix"
        "hpsa"
        "usb_storage"
        "usbhid"
        "sd_mod"
        "sr_mod"
      ];
      kernelModules = [ ];
    };

    kernelModules = [ "kvm-intel" ];
    supportedFilesystems = [ "zfs" ];

    loader.grub = {
      enable = true;
      version = 2;
      device = "/dev/disk/by-id/wwn-0x600508b1001cecf6b880f591f9b18b29";
    };
  };

  fileSystems = {
    "/boot" = {
      device = "/dev/disk/by-label/lambda-boot";
      fsType = "ext4";
      options = [ "noexec" "noatime" "nodiratime" ];
    };

    "/" = {
      device = "none";
      fsType = "tmpfs";
      options = [ "noexec" "mode=755" ];
    };

    "/nix" = {
      device = "lambda/transient/nix";
      fsType = "zfs";
      options = [ "noatime" "nodiratime" ];
    };

    "/var/log" = {
      device = "lambda/transient/logs";
      fsType = "zfs";
      neededForBoot = true;
      options = [ "noexec" "noatime" "nodiratime" ];
    };

    "/state" = {
      device = "lambda/persistent/state";
      fsType = "zfs";
      options = [ "noexec" "noatime" "nodiratime" ];
    };
  };

  swapDevices = [{ device = "/dev/disk/by-label/lambda-swap"; }];

  nix.maxJobs = lib.mkDefault 12;

  networking = {
    macvlans = {
      intif0 = {
        interface = "enp3s0f1";
        mode = "bridge";
      };
    };

    interfaces = {
      intif0 = {
        # output of: echo lambda-intif0|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/'
        macAddress = "02:f5:fe:8c:22:fe";
      };
    };
  };
}