{ lib, pkgs, ... }: { system.stateVersion = "26.05"; nixpkgs.hostPlatform = "x86_64-linux"; boot = { loader = { efi.canTouchEfiVariables = true; systemd-boot.enable = true; }; initrd = { availableKernelModules = [ "nvme" "sd_mod" "thunderbolt" "uas" "usb_storage" "xhci_pci" ]; luks.devices.soil = { device = "/dev/disk/by-uuid/69a2344e-9c66-46a5-ac81-8ecdce8f0c8e"; # Enable TRIM support. allowDiscards = true; crypttabExtraOpts = [ "fido2-device=auto" ]; }; systemd.services.wipe-ephemeral-root = { unitConfig.DefaultDependencies = false; after = [ "systemd-cryptsetup@soil.service" ]; requires = [ "systemd-cryptsetup@soil.service" ]; wantedBy = [ "initrd.target" ]; before = [ "sysroot.mount" ]; serviceConfig.Type = "oneshot"; path = with pkgs; [ btrfs-progs util-linux ]; script = '' mount --mkdir /dev/mapper/soil /soil btrfs subvolume delete --recursive /soil/ephemeral-root btrfs subvolume create /soil/ephemeral-root umount /soil ''; }; }; kernelModules = [ "kvm-amd" ]; kernelPackages = pkgs.linuxPackages_latest; }; hardware.cpu.amd.updateMicrocode = true; swapDevices = [ { device = "/var/lib/swapfile"; size = 32 * 1024; } ]; fileSystems = { "/boot" = { device = "/dev/disk/by-uuid/A478-356B"; fsType = "vfat"; options = [ "fmask=0077" "dmask=0077" ]; }; "/" = { device = "/dev/mapper/soil"; fsType = "btrfs"; options = [ "subvol=/ephemeral-root" ]; }; "/nix" = { device = "/dev/mapper/soil"; fsType = "btrfs"; options = [ "subvol=/machine-state/nix" ]; }; "/mnt/machine-state" = { device = "/dev/mapper/soil"; fsType = "btrfs"; options = [ "subvol=/machine-state" ]; neededForBoot = true; }; "/mnt/persistent-data" = { device = "/dev/mapper/soil"; fsType = "btrfs"; options = [ "subvol=/persistent-data" ]; neededForBoot = true; }; }; users = { users = { # As of 2026-08-03 we need to use this path directly because this gets read before any # impermanence mounts happen. In fact, these are systemd mount units, and NixOS accounts are # provisioned before systemd itself is even started. rei.hashedPasswordFile = "/mnt/persistent-data/etc/nixos/assets/password-ruysch-rei"; garage = { isSystemUser = true; group = "garage"; }; }; groups.garage = {}; }; networking = { hostName = "ruysch"; networkmanager.enable = true; }; environment = { systemPackages = with pkgs; [ claude-code ]; persistence."/mnt/persistent-data".directories = [ # For TandemDrive config. "/usr/local/etc" "/var/lib/postgresql" ]; }; services = { tzupdate = { # Triggers malware detection at TandemDrive office, therefore disabled. # enable = true; # timer.enable = true; }; beesd.filesystems.soil = { spec = "UUID=33bee671-ce7b-4747-a922-95ef885f0172"; workDir = "/machine-state/var/lib/bees"; extraOptions = [ "--thread-count" "2" ]; }; postgresql = { enable = true; package = pkgs.postgresql_18; ensureUsers = [ { name = "rei"; ensureClauses.superuser = true; } ]; ensureDatabases = [ "rei" ]; authentication = '' local all all trust host all all ::1/128 trust host all all 127.0.0.1/32 trust ''; }; garage = { enable = true; package = pkgs.garage_2; settings = { replication_factor = 1; rpc_bind_addr = "[::]:3901"; rpc_secret_file = "/etc/nixos/assets/ruysch-garage-rpc-secret"; s3_api.s3_region = "garage"; }; }; redis = { package = pkgs.valkey; servers."" = { enable = true; unixSocketPerm = 666; }; }; }; programs = { # We have physical cores, so enable this. htop.settings.show_cpu_frequency = true; ssh.extraConfig = '' Host git.service.d11n.nl Port 258 ''; direnv = { enable = true; nix-direnv.enable = true; }; }; systemd.services = { # We need a named user so that the RPC key file can be owned by it. garage.serviceConfig = { DynamicUser = lib.mkForce false; User = "garage"; Group = "garage"; }; redis.serviceConfig.RuntimeDirectoryMode = lib.mkForce "0755"; }; systemd.tmpfiles.rules = [ "L+ /tmp/.s.PGSQL.5432 - - - - /run/postgresql/.s.PGSQL.5432" ]; security.pam = { u2f.enable = true; # TODO: Get Yubikey for sudo to work. }; # Temporary until we figure out how to reliably block tzupdate on TandemDrive network. time.timeZone = "Europe/Amsterdam"; }