iac/nixos/flake.nix
Sergei Poljanski be68c5adef
nixos: describe both servers as NixOS systems
Start of the move from Ansible to NixOS. Services run as native NixOS
services where nixpkgs has a module and as Podman containers otherwise;
there is no Docker.

Shared: users with their Debian UIDs, SSH with the Ansible role's crypto
settings, nftables firewall, WireGuard (ops is the hub), sops-nix
secrets per host, the restic backup script with its schedule and
retention, mail on unit failure.

asxpio-services: Xray, SillyTavern, Minecraft (Paper) and the ACME
forwarder natively; XMPP stays in containers because the server is a
custom build.

asxpio-ops: Postgres, Garage and Forgejo natively. Roles, buckets, keys
and grants move here from the storage repo's init scripts.

Services that own data wait for /var/lib/.data-in-place, so an install
never creates empty state where a restore is about to land.
migration/*-data.sh move the Debian-era data into the new layout.

hosts/rehearsal turns the two hosts into a test pair with its own keys
and dummy secrets. Everything here ran there, Postgres, Garage, Forgejo,
Minecraft and SillyTavern on a restored copy of production data. Three
differences from the containers showed up and are handled: Garage
rejects a 0440 credential file, Geyser needs libcrypto and netlink,
SillyTavern ignores the module's listen flags.

Production is untouched: both servers still run Debian under Ansible.

Assisted-by: Claude:fable-5-2
2026-11-16 22:59:59 +04:00

75 lines
1.8 KiB
Nix

{
description = "asxp.io servers";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
# For the few packages 26.05 has older than what production runs
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
nixpkgs,
nixpkgs-unstable,
sops-nix,
...
}:
let
mkHost =
modules:
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs.unstable = nixpkgs-unstable.legacyPackages.x86_64-linux;
modules = [
sops-nix.nixosModules.sops
./modules/hetzner.nix
./modules/base.nix
./modules/podman.nix
./modules/wireguard.nix
./modules/alert.nix
./modules/backup.nix
]
++ modules;
};
in
{
# `nix develop ./nixos`: every tool the READMEs call
devShells.x86_64-linux.default =
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in
pkgs.mkShell {
packages = with pkgs; [
opentofu
hcloud
nixos-rebuild
sops
ssh-to-age
age
restic
rclone
jq
];
};
nixosConfigurations = {
asxpio-ops = mkHost [ ./hosts/asxpio-ops ];
asxpio-services = mkHost [ ./hosts/asxpio-services ];
# Both hosts on throwaway servers, with their own keys and
# addresses: everything is tried there first.
rehearsal-ops = mkHost [
./hosts/asxpio-ops
./hosts/rehearsal/ops.nix
];
rehearsal-services = mkHost [
./hosts/asxpio-services
./hosts/rehearsal/services.nix
];
};
};
}