2025-12-26 11:55:31 -06:00
|
|
|
|
{
|
|
|
|
|
|
config,
|
|
|
|
|
|
pkgs,
|
|
|
|
|
|
meta,
|
|
|
|
|
|
...
|
|
|
|
|
|
}:
|
2025-04-19 20:31:26 -05:00
|
|
|
|
{
|
2025-04-09 15:26:07 -05:00
|
|
|
|
imports = [ ];
|
2025-04-09 13:54:31 -05:00
|
|
|
|
|
2025-12-26 11:55:31 -06:00
|
|
|
|
nix.settings.experimental-features = [
|
|
|
|
|
|
"nix-command"
|
|
|
|
|
|
"flakes"
|
|
|
|
|
|
];
|
2025-04-09 15:55:54 -05:00
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
|
|
|
2025-04-16 10:57:36 -05:00
|
|
|
|
# Secret Management
|
|
|
|
|
|
sops = {
|
2025-04-29 09:10:16 -05:00
|
|
|
|
# make sure that the age key is generated from the persisted host key
|
|
|
|
|
|
age = {
|
|
|
|
|
|
sshKeyPaths = [ "/persist/etc/ssh/ssh_host_ed25519_key" ];
|
|
|
|
|
|
keyFile = "/persist/var/lib/sops-nix/key.txt";
|
|
|
|
|
|
generateKey = true;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
# I prefer to use json format for the secrets
|
2025-04-16 10:57:36 -05:00
|
|
|
|
defaultSopsFormat = "json";
|
|
|
|
|
|
|
2025-04-29 21:37:31 -05:00
|
|
|
|
# Define file and key for each secret
|
2025-04-23 15:13:07 -05:00
|
|
|
|
secrets = {
|
2025-04-24 22:53:32 -05:00
|
|
|
|
"cloudflare-api-email" = {
|
2025-04-23 15:13:07 -05:00
|
|
|
|
sopsFile = ./secrets/cloudflare.json;
|
2025-04-24 22:53:32 -05:00
|
|
|
|
key = "CF_API_EMAIL";
|
2026-06-20 16:34:54 -05:00
|
|
|
|
owner = "acme";
|
|
|
|
|
|
group = "acme";
|
2025-04-24 22:53:32 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
"cloudflare-api-key" = {
|
|
|
|
|
|
sopsFile = ./secrets/cloudflare.json;
|
|
|
|
|
|
key = "CF_API_KEY";
|
2026-06-20 16:34:54 -05:00
|
|
|
|
owner = "acme";
|
|
|
|
|
|
group = "acme";
|
2025-04-23 15:13:07 -05:00
|
|
|
|
};
|
2025-06-12 15:56:47 -05:00
|
|
|
|
|
2025-11-15 23:46:57 -06:00
|
|
|
|
"postgresql-credentials" = {
|
|
|
|
|
|
sopsFile = ./secrets/psql.yaml;
|
|
|
|
|
|
key = "credentials";
|
|
|
|
|
|
format = "yaml";
|
2026-06-20 16:34:54 -05:00
|
|
|
|
owner = "postgres";
|
|
|
|
|
|
group = "postgres";
|
2025-11-15 23:46:57 -06:00
|
|
|
|
};
|
2026-08-24 15:38:30 -05:00
|
|
|
|
|
|
|
|
|
|
"gitea-credentials" = {
|
|
|
|
|
|
sopsFile = ./secrets/gitea.yaml;
|
|
|
|
|
|
key = "credentials";
|
|
|
|
|
|
format = "yaml";
|
|
|
|
|
|
owner = "root";
|
|
|
|
|
|
group = "root";
|
|
|
|
|
|
};
|
2025-04-23 15:13:07 -05:00
|
|
|
|
};
|
2025-04-16 10:57:36 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-04-29 21:37:31 -05:00
|
|
|
|
systemd.user.services.mbsync.unitConfig.After = [ "sops-nix.service" ];
|
2025-05-03 19:30:28 -05:00
|
|
|
|
fileSystems."/persist".neededForBoot = true;
|
|
|
|
|
|
|
2025-05-30 00:35:34 -05:00
|
|
|
|
# Set up https certs via cloudflare/acme
|
2025-04-23 15:13:07 -05:00
|
|
|
|
security.acme = {
|
|
|
|
|
|
acceptTerms = true;
|
|
|
|
|
|
defaults = {
|
2025-08-23 22:24:53 -05:00
|
|
|
|
# use staging for testing
|
2026-09-14 01:23:45 -05:00
|
|
|
|
# server = "https://acme-staging-v02.api.letsencrypt.org/directory";
|
2025-08-23 22:04:42 -05:00
|
|
|
|
# use prod for deploy
|
2026-09-14 01:23:45 -05:00
|
|
|
|
server = "https://acme-v02.api.letsencrypt.org/directory";
|
2025-04-23 15:13:07 -05:00
|
|
|
|
email = "roydumblauskas@gmail.com";
|
|
|
|
|
|
dnsProvider = "cloudflare";
|
2025-08-26 23:23:15 -05:00
|
|
|
|
# When the service CHECKS to see if certs are near expiry (< 30 days)
|
|
|
|
|
|
renewInterval = "daily";
|
2025-04-24 22:53:32 -05:00
|
|
|
|
credentialFiles = {
|
2025-04-25 00:28:28 -05:00
|
|
|
|
CF_API_EMAIL_FILE = config.sops.secrets."cloudflare-api-email".path;
|
|
|
|
|
|
CF_API_KEY_FILE = config.sops.secrets."cloudflare-api-key".path;
|
2025-04-24 22:53:32 -05:00
|
|
|
|
};
|
2025-12-26 11:55:31 -06:00
|
|
|
|
};
|
2026-06-20 18:18:01 -05:00
|
|
|
|
|
2025-08-23 21:06:20 -05:00
|
|
|
|
certs = {
|
2026-05-24 23:04:19 -05:00
|
|
|
|
"roypository.com" = {
|
2026-08-24 17:59:03 -05:00
|
|
|
|
domain = "roypository.com";
|
|
|
|
|
|
extraDomainNames = [ "*.roypository.com" ];
|
2026-05-24 22:49:16 -05:00
|
|
|
|
group = "nginx";
|
|
|
|
|
|
};
|
2025-04-23 15:13:07 -05:00
|
|
|
|
};
|
2026-08-24 17:59:03 -05:00
|
|
|
|
|
2025-04-23 15:13:07 -05:00
|
|
|
|
};
|
2025-04-24 22:53:32 -05:00
|
|
|
|
|
2026-05-31 23:26:46 -05:00
|
|
|
|
# This deploys to the k3s cluster declared below
|
2026-05-27 00:42:53 -05:00
|
|
|
|
services.nimh-static = {
|
|
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
|
|
|
|
default-nginx = {
|
|
|
|
|
|
enable = true;
|
|
|
|
|
|
hostname = "nimh.roypository.com";
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-19 22:31:52 -05:00
|
|
|
|
# ================================ #
|
|
|
|
|
|
# K3S SERVICE #
|
|
|
|
|
|
# ================================ #
|
|
|
|
|
|
|
|
|
|
|
|
services.k3s = {
|
|
|
|
|
|
enable = true;
|
2026-06-20 18:39:15 -05:00
|
|
|
|
disable = [ "traefik" ];
|
2026-05-19 22:31:52 -05:00
|
|
|
|
role = "server";
|
2026-08-24 15:38:30 -05:00
|
|
|
|
|
2026-09-12 16:43:53 -05:00
|
|
|
|
# only enable the service on k3s when roughly finalized
|
|
|
|
|
|
# Until then use a vm, as k3s is persisted
|
2026-08-24 15:38:30 -05:00
|
|
|
|
extraFlags = [
|
2026-09-12 17:03:10 -05:00
|
|
|
|
"--data-dir=/persist/var/lib/rancher/k3s"
|
2026-09-12 17:58:19 -05:00
|
|
|
|
"--cluster-cidr=10.42.0.0/20"
|
2026-08-24 15:38:30 -05:00
|
|
|
|
];
|
2026-05-19 22:31:52 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-08-24 15:38:30 -05:00
|
|
|
|
# ================================ #
|
|
|
|
|
|
# GITEA SERVICE #
|
|
|
|
|
|
# ================================ #
|
2026-05-19 22:31:52 -05:00
|
|
|
|
|
2026-08-24 15:45:49 -05:00
|
|
|
|
services.hl-gitea = {
|
2026-08-24 16:00:55 -05:00
|
|
|
|
enable = true;
|
2026-08-24 16:03:34 -05:00
|
|
|
|
credentialsFile = config.sops.secrets."gitea-credentials".path;
|
2026-08-24 16:40:53 -05:00
|
|
|
|
database-hostname = "${config.ipAddrs.${meta.hostname}}:5432"; # whatever port I host psql on below
|
2026-08-24 15:38:30 -05:00
|
|
|
|
|
|
|
|
|
|
default-nginx = {
|
|
|
|
|
|
enable = true;
|
|
|
|
|
|
hostname = "roypository.com";
|
|
|
|
|
|
};
|
|
|
|
|
|
};
|
2026-09-03 22:07:14 -05:00
|
|
|
|
|
2026-05-19 22:15:37 -05:00
|
|
|
|
# ================================ #
|
|
|
|
|
|
# BLOG SERVICE #
|
|
|
|
|
|
# ================================ #
|
|
|
|
|
|
|
2026-09-12 16:43:53 -05:00
|
|
|
|
# fullstack code. Dev hosted via VMs (incus)
|
2026-05-19 22:15:37 -05:00
|
|
|
|
|
2026-09-12 16:43:53 -05:00
|
|
|
|
# ================================ #
|
|
|
|
|
|
# PSQL SERVICE #
|
|
|
|
|
|
# ================================ #
|
2025-06-12 15:56:47 -05:00
|
|
|
|
|
2026-05-20 00:00:37 -05:00
|
|
|
|
# Postgresql/postgrest for row storage (not on k3s)
|
2025-11-15 23:46:57 -06:00
|
|
|
|
services.postgresql-db = {
|
|
|
|
|
|
enable = true;
|
2026-09-12 17:03:10 -05:00
|
|
|
|
dataDir = "/persist/var/lib/postgresql";
|
2026-05-20 00:00:37 -05:00
|
|
|
|
port = 5432;
|
2025-11-15 23:46:57 -06:00
|
|
|
|
credentialsFile = config.sops.secrets."postgresql-credentials".path;
|
2026-08-23 14:14:22 -05:00
|
|
|
|
databases = [
|
|
|
|
|
|
"gitea"
|
|
|
|
|
|
];
|
2026-09-12 15:02:09 -05:00
|
|
|
|
ipMasks = [
|
2026-09-12 16:43:53 -05:00
|
|
|
|
"10.42.0.0/20" # k3s pod mask
|
2026-09-12 15:02:09 -05:00
|
|
|
|
];
|
2025-11-15 23:46:57 -06:00
|
|
|
|
};
|
2025-11-12 08:22:31 -06:00
|
|
|
|
|
2025-06-21 11:54:12 -05:00
|
|
|
|
# ================================ #
|
|
|
|
|
|
# MINECRAFT #
|
|
|
|
|
|
# ================================ #
|
2025-06-21 15:45:34 -05:00
|
|
|
|
|
|
|
|
|
|
services.mc-service = {
|
|
|
|
|
|
enable = true;
|
|
|
|
|
|
storeDir = "/persist/srv/minecraft";
|
|
|
|
|
|
};
|
2025-12-26 11:55:31 -06:00
|
|
|
|
|
2025-04-09 13:54:31 -05:00
|
|
|
|
# Grub Boot Loader Setup
|
2026-05-19 00:49:40 -05:00
|
|
|
|
boot.loader.grub = {
|
|
|
|
|
|
enable = true;
|
|
|
|
|
|
zfsSupport = true;
|
|
|
|
|
|
efiSupport = true;
|
|
|
|
|
|
efiInstallAsRemovable = true;
|
|
|
|
|
|
configurationLimit = 25;
|
|
|
|
|
|
mirroredBoots = [
|
|
|
|
|
|
{
|
|
|
|
|
|
devices = [ "nodev" ];
|
|
|
|
|
|
path = "/boot";
|
|
|
|
|
|
}
|
|
|
|
|
|
];
|
2025-04-09 13:54:31 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-06-20 16:42:58 -05:00
|
|
|
|
boot.zfs.forceImportRoot = false;
|
2025-12-26 11:55:31 -06:00
|
|
|
|
|
2026-06-20 16:42:58 -05:00
|
|
|
|
# Delete root on reboot
|
|
|
|
|
|
boot.initrd.systemd.services = {
|
|
|
|
|
|
rollback = {
|
|
|
|
|
|
description = "Rollback root zfs dataset to blank snapshot";
|
|
|
|
|
|
wantedBy = [ "initrd.target" ];
|
|
|
|
|
|
before = [ "sysroot.mount" ];
|
|
|
|
|
|
after = [ "zfs-import-zroot.service" ];
|
|
|
|
|
|
path = [ pkgs.zfs ];
|
|
|
|
|
|
|
|
|
|
|
|
unitConfig.DefaultDependencies = "no";
|
|
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
|
|
|
|
|
|
|
|
script = ''
|
|
|
|
|
|
zfs rollback -r zroot/root@blank
|
|
|
|
|
|
echo "blank rollback complete" > /dev/kmsg
|
|
|
|
|
|
'';
|
|
|
|
|
|
};
|
|
|
|
|
|
};
|
2026-06-20 16:58:15 -05:00
|
|
|
|
|
2026-09-12 16:43:53 -05:00
|
|
|
|
# Setup Incus daemon on boot
|
|
|
|
|
|
# Init with `incus admin init --minimal`
|
|
|
|
|
|
virtualisation.incus.enable = true;
|
|
|
|
|
|
|
2025-05-05 12:41:46 -05:00
|
|
|
|
networking = {
|
|
|
|
|
|
hostName = meta.hostname;
|
|
|
|
|
|
hostId = meta.hostId;
|
2026-07-14 00:28:52 -05:00
|
|
|
|
defaultGateway = "192.168.8.1";
|
2025-12-26 11:55:31 -06:00
|
|
|
|
nameservers = [
|
|
|
|
|
|
"1.1.1.1"
|
|
|
|
|
|
"1.0.0.1"
|
|
|
|
|
|
];
|
2026-09-12 16:43:53 -05:00
|
|
|
|
nftables.enable = true;
|
2025-04-27 16:05:18 -05:00
|
|
|
|
|
2025-05-05 12:41:46 -05:00
|
|
|
|
firewall = {
|
|
|
|
|
|
enable = true;
|
2025-12-26 11:55:31 -06:00
|
|
|
|
allowedTCPPorts = [
|
|
|
|
|
|
22
|
|
|
|
|
|
80
|
|
|
|
|
|
443
|
2026-05-19 22:31:52 -05:00
|
|
|
|
6443 # k3s
|
2025-12-26 11:55:31 -06:00
|
|
|
|
];
|
2026-09-12 16:43:53 -05:00
|
|
|
|
|
|
|
|
|
|
# Trust all incusVMs (on this network interface)
|
|
|
|
|
|
trustedInterfaces = [ "incusbr0" ];
|
2025-05-05 12:41:46 -05:00
|
|
|
|
};
|
2025-04-09 13:54:31 -05:00
|
|
|
|
|
2025-05-05 12:41:46 -05:00
|
|
|
|
interfaces.eth0.ipv4.addresses = [
|
|
|
|
|
|
{
|
2025-06-02 10:43:30 -05:00
|
|
|
|
address = config.ipAddrs.${meta.hostname};
|
2025-05-05 12:41:46 -05:00
|
|
|
|
prefixLength = 24;
|
|
|
|
|
|
}
|
|
|
|
|
|
];
|
2025-04-19 20:31:26 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-04-09 13:54:31 -05:00
|
|
|
|
# Set your time zone.
|
|
|
|
|
|
time.timeZone = "America/Chicago";
|
|
|
|
|
|
|
|
|
|
|
|
# Enable CUPS to print documents.
|
|
|
|
|
|
services.printing.enable = true;
|
|
|
|
|
|
|
|
|
|
|
|
# Define a user account. Don't forget to set a password with ‘passwd’.
|
2025-08-22 22:10:22 -05:00
|
|
|
|
users.users.roy = {
|
|
|
|
|
|
isNormalUser = true;
|
2026-09-12 16:43:53 -05:00
|
|
|
|
extraGroups = [
|
|
|
|
|
|
"wheel"
|
|
|
|
|
|
"incus-admin"
|
|
|
|
|
|
];
|
2026-05-18 17:45:53 -05:00
|
|
|
|
hashedPassword = "$y$j9T$qHYfvijvytC69cjEWTHYA/$YF6ig1hNvkTQi0UffZP1dpilS.8O28qEY4bfdvRTXYA";
|
|
|
|
|
|
# laptop and desktop
|
2025-08-23 01:43:06 -05:00
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFEQyjykrRpkgMFpNAR2G1rbofqbtcuLwIYzgqH85QCn roydumblauskas@gmail.com"
|
2026-05-18 17:45:53 -05:00
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPERQEHVwrtsWOpu1BgT7b1WNe4ShCy4bXWoGWvYENBw roydumblauskas@gmail.com"
|
2025-08-23 01:43:06 -05:00
|
|
|
|
];
|
2025-08-22 22:46:03 -05:00
|
|
|
|
shell = pkgs.fish;
|
2025-08-22 22:10:22 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-06-12 16:18:51 -05:00
|
|
|
|
users.users.root = {
|
2026-05-18 17:45:53 -05:00
|
|
|
|
# laptop and desktop
|
2025-06-12 16:18:51 -05:00
|
|
|
|
openssh.authorizedKeys.keys = [
|
2025-08-23 01:43:06 -05:00
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFEQyjykrRpkgMFpNAR2G1rbofqbtcuLwIYzgqH85QCn roydumblauskas@gmail.com"
|
2026-05-18 17:45:53 -05:00
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPERQEHVwrtsWOpu1BgT7b1WNe4ShCy4bXWoGWvYENBw roydumblauskas@gmail.com"
|
2025-04-09 13:54:31 -05:00
|
|
|
|
];
|
|
|
|
|
|
};
|
2025-05-20 17:48:38 -05:00
|
|
|
|
|
|
|
|
|
|
# Symlink the user directories that need to be persisted (ssh key/repository folder)
|
2025-06-05 12:00:56 -05:00
|
|
|
|
environment.persistence."/persist" = {
|
2025-06-05 12:38:48 -05:00
|
|
|
|
directories = [
|
|
|
|
|
|
"/root/.ssh"
|
2025-06-07 17:38:16 -05:00
|
|
|
|
"/var/lib/nixos"
|
2025-07-02 17:48:26 -05:00
|
|
|
|
"/var/db/sudo/lectured"
|
2026-09-12 19:04:41 -05:00
|
|
|
|
"/var/lib/acme"
|
2025-06-05 12:38:48 -05:00
|
|
|
|
];
|
2025-06-05 12:00:56 -05:00
|
|
|
|
};
|
2025-04-09 15:55:54 -05:00
|
|
|
|
|
2026-09-12 16:43:53 -05:00
|
|
|
|
# List packages installed in system profile
|
2025-04-09 13:54:31 -05:00
|
|
|
|
environment.systemPackages = with pkgs; [
|
2025-04-09 15:26:07 -05:00
|
|
|
|
curl
|
2025-04-27 22:01:25 -05:00
|
|
|
|
kitty
|
2025-08-23 14:33:41 -05:00
|
|
|
|
nginx
|
2025-06-21 22:45:52 -05:00
|
|
|
|
tmux
|
2025-04-15 21:03:43 -05:00
|
|
|
|
vim
|
2025-04-09 13:54:31 -05:00
|
|
|
|
wget
|
|
|
|
|
|
];
|
|
|
|
|
|
|
2025-08-22 22:10:22 -05:00
|
|
|
|
fonts.packages = with pkgs; [
|
|
|
|
|
|
nerd-fonts.mononoki
|
|
|
|
|
|
nerd-fonts.ubuntu-mono
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
programs = {
|
|
|
|
|
|
hyprland = {
|
|
|
|
|
|
enable = true;
|
|
|
|
|
|
xwayland.enable = true;
|
|
|
|
|
|
};
|
|
|
|
|
|
waybar.enable = true;
|
|
|
|
|
|
fish.enable = true;
|
|
|
|
|
|
fuse.userAllowOther = true;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
environment.variables = {
|
|
|
|
|
|
EDITOR = "nvim";
|
|
|
|
|
|
};
|
2025-04-09 13:54:31 -05:00
|
|
|
|
|
|
|
|
|
|
# List services that you want to enable:
|
2025-04-27 23:07:22 -05:00
|
|
|
|
services.openssh = {
|
|
|
|
|
|
enable = true;
|
|
|
|
|
|
hostKeys = [
|
|
|
|
|
|
{
|
|
|
|
|
|
type = "ed25519";
|
|
|
|
|
|
path = "/persist/etc/ssh/ssh_host_ed25519_key";
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
|
|
|
|
|
type = "rsa";
|
|
|
|
|
|
bits = 4096;
|
|
|
|
|
|
path = "/persist/etc/ssh/ssh_host_rsa_key";
|
|
|
|
|
|
}
|
|
|
|
|
|
];
|
|
|
|
|
|
};
|
2025-04-09 13:54:31 -05:00
|
|
|
|
|
|
|
|
|
|
# INITIAL system version
|
|
|
|
|
|
system.stateVersion = "24.11";
|
|
|
|
|
|
|
|
|
|
|
|
}
|