config-perso/machines/kat-orchid/configuration.nix

208 lines
4.8 KiB
Nix
Raw Normal View History

{
config,
lib,
pkgs,
kat-path,
ssh-keys,
sources,
self-version,
...
}:
{
deployment = {
targetHost = "orchid.kat";
tags = [ "kat-vms" ];
};
imports = [
./hardware-configuration.nix
./disks.nix
];
boot = {
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
kernelParams = [ "console=ttyS0" ];
};
kat = {
fqdn = "orchid.katvayor.net";
proxies = {
ip = "192.168.122.6";
aliases = [
"simply-wise.fr"
"www.simply-wise.fr"
];
open-tcp = [
{
internal = 22;
external = 22042;
}
];
};
};
systemd.network.enable = lib.mkForce false;
networking = {
useNetworkd = lib.mkForce false;
firewall.allowedTCPPorts = [
80
443
];
interfaces."enp1s0" = {
useDHCP = false;
ipv4.addresses = [
{
address = "192.168.122.6";
prefixLength = 24;
}
];
ipv6.addresses = [
{
address = "fe80::6";
prefixLength = 64;
}
];
};
defaultGateway = "192.168.122.1";
defaultGateway6 = {
address = "fe80::1";
interface = "enp1s0";
};
nameservers = [
"192.168.122.1"
"fe80::1%enp1s0"
];
};
nixpkgs.config.allowUnfree = true;
security.acme = {
acceptTerms = true;
defaults.email = "root@katvayor.net";
certs."orchid.katvayor.net".extraDomainNames = [
"simply-wise.fr"
"www.simply-wise.fr"
];
};
services = {
openssh.enable = true;
qemuGuest.enable = true;
getty.autologinUser = "root";
nginx = {
enable = true;
virtualHosts = {
"orchid.katvayor.net" = {
enableACME = true;
forceSSL = true;
locations = {
"/static/".alias = "/srv/orchid/";
"/" = {
recommendedProxySettings = true;
proxyPass = "https://192.168.123.2/";
};
};
};
"simply-wise.fr" = {
useACMEHost = "orchid.katvayor.net";
forceSSL = true;
serverAliases = [ "www.simply-wise.fr" ];
locations."/" = {
root = pkgs.runCommand "building" { } ''
mkdir -p $out
ln -nsf ${./building.html} $out/building.html
'';
extraConfig = ''
internal;
error_page 404 =503 /building.html;
'';
};
};
};
};
};
containers.wordpress =
let
inherit (config.security.acme) certs;
in
{
privateNetwork = true;
bindMounts.certs = {
hostPath = certs."orchid.katvayor.net".directory;
mountPoint = certs."orchid.katvayor.net".directory;
isReadOnly = true;
};
hostAddress = "192.168.123.1";
localAddress = "192.168.123.2";
autoStart = true;
specialArgs = {
inherit kat-path ssh-keys sources self-version;
};
config = {
imports = [ kat-path ];
kat.addArgs = false;
boot.kernel.enable = false;
systemd.network.enable = lib.mkForce false;
networking.firewall.allowedTCPPorts = [
80
443
];
services = {
nginx = {
enable = true;
virtualHosts."orchid.katvayor.net" = {
addSSL = true;
sslCertificate = "${certs."orchid.katvayor.net".directory}/fullchain.pem";
sslCertificateKey = "${certs."orchid.katvayor.net".directory}/key.pem";
sslTrustedCertificate = "${certs."orchid.katvayor.net".directory}/chain.pem";
};
};
openssh.enable = true;
wordpress = {
webserver = "nginx";
sites."orchid.katvayor.net" = {
themes = {
inherit (pkgs.wordpressPackages.themes) twentytwentythree;
};
};
};
};
environment.systemPackages = [ pkgs.wp-cli ];
system.stateVersion = "24.11";
};
};
fileSystems."/home/orchid/content/www" = {
device = "/srv/orchid";
options = [ "bind" ];
};
systemd = {
tmpfiles.settings."10-srv-orchid"."/srv/orchid" = {
d = {
group = "users";
user = "orchid";
};
Z = {
group = "users";
user = "orchid";
mode = "0755";
};
};
timers.srv-tmpfiles = {
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = "*-*-* *:*:07..57/10";
};
services.srv-tmpfiles = {
path = [ pkgs.systemd ];
script = ''
systemd-tmpfiles --create --prefix=/srv
'';
};
};
users.users.orchid.isNormalUser = true;
home-manager.users.orchid = { };
system.stateVersion = "23.11";
}