infrastructure/ruysch.nix

263 lines
6.3 KiB
Nix
Raw Normal View History

2026-09-23 12:14:46 +02:00
{ lib, pkgs, pkgs-unstable, ... }:
2026-09-03 11:54:20 +02:00
{
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/secrets/password-ruysch-rei";
2026-09-03 11:54:20 +02:00
garage = {
isSystemUser = true;
group = "garage";
};
};
groups.garage = {};
};
networking = {
hostName = "ruysch";
networkmanager.enable = true;
};
2026-09-29 11:45:31 +02:00
2026-09-03 11:54:20 +02:00
environment = {
systemPackages = with pkgs; [
minio-client
2026-09-15 14:13:23 +02:00
python3
2026-09-23 12:14:46 +02:00
pkgs-unstable.claude-code
];
2026-09-03 11:54:20 +02:00
persistence."/mnt/persistent-data".directories = [
# For TandemDrive config.
"/usr/local/etc"
2026-09-08 12:24:03 +02:00
"/var/lib/garage"
2026-09-03 11:54:20 +02:00
"/var/lib/postgresql"
];
etc."claude/settings.json".source = (pkgs.formats.json {}).generate "claude-config" {
# Required by TandemDrive security policy.
permissions = {
deny = [
"Read(.env)"
"Read(.env.*)"
"Read(~/.ssh/**)"
"Read(~/.gnupg/**)"
"Read(~/.config/**)"
"Read(~/Documents/**)"
"Bash(* | bash)"
"Bash(* | sh)"
"Bash(sudo *)"
"Bash(ssh *)"
"Bash(git push *)"
"Bash(git commit *)"
];
ask = [
"Bash(git push *)"
"Bash(git commit *)"
];
disableBypassPermissionsMode = "disable";
};
# Personal config.
disableAutoMode = "disable";
env = {
CLAUDE_CODE_ENABLE_AWAY_SUMMARY = 0;
CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION = "false";
};
modelSettings.claude-opus-5-5.effortLevel = "high";
2026-09-23 13:44:07 +02:00
# Default is dark.
theme = "auto";
};
2026-09-03 11:54:20 +02:00
};
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/secrets/ruysch-garage-rpc-secret";
2026-09-08 12:24:39 +02:00
s3_api = {
api_bind_addr = "[::]:3900";
s3_region = "garage";
};
2026-09-03 11:54:20 +02:00
};
};
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
# TODO: Check if we can specify this in an actual config item.
VerifyHostKeyDNS yes
ForwardAgent no
2026-09-03 11:54:20 +02:00
'';
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.user.tmpfiles.rules = [
# TODO: Don't persist entire .claude directory.
"L /home/rei/.claude/settings.json - - - - /etc/claude/settings.json"
];
2026-09-03 11:54:20 +02:00
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";
}