2021-12-16 06:38:55 +01:00
|
|
|
{ depot, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2021-12-25 00:44:36 +01:00
|
|
|
inherit (depot.users) wpcarro;
|
2021-12-30 06:15:27 +01:00
|
|
|
name = "diogenes";
|
|
|
|
domainName = "billandhiscomputer.com";
|
|
|
|
in
|
|
|
|
wpcarro.terraform.googleCloudVM {
|
|
|
|
project = "wpcarros-infrastructure";
|
|
|
|
name = "diogenes";
|
|
|
|
region = "us-central1";
|
|
|
|
zone = "us-central1-a";
|
|
|
|
|
|
|
|
# DNS configuration
|
|
|
|
extraConfig = {
|
2022-01-04 21:41:22 +01:00
|
|
|
# billandhiscomputer.com
|
2021-12-30 06:15:27 +01:00
|
|
|
resource.google_dns_managed_zone."${name}" = {
|
|
|
|
inherit name;
|
|
|
|
dns_name = "${domainName}.";
|
|
|
|
};
|
2021-12-16 06:38:55 +01:00
|
|
|
|
2021-12-30 06:15:27 +01:00
|
|
|
resource.google_dns_record_set."${name}" = {
|
2021-12-30 15:20:02 +01:00
|
|
|
name = "${domainName}.";
|
2021-12-30 06:15:27 +01:00
|
|
|
type = "A";
|
|
|
|
ttl = 300; # 5m
|
|
|
|
managed_zone = "\${google_dns_managed_zone.${name}.name}";
|
|
|
|
rrdatas = [ "\${google_compute_instance.${name}.network_interface[0].access_config[0].nat_ip}" ];
|
|
|
|
};
|
2021-12-30 20:27:20 +01:00
|
|
|
|
|
|
|
resource.google_compute_instance."${name}" = {
|
|
|
|
network_interface.access_config = {
|
2021-12-30 20:49:58 +01:00
|
|
|
public_ptr_domain_name = "${domainName}.";
|
2021-12-30 20:27:20 +01:00
|
|
|
};
|
|
|
|
};
|
2021-12-17 01:12:13 +01:00
|
|
|
};
|
2021-12-17 00:29:59 +01:00
|
|
|
|
2021-12-30 06:15:27 +01:00
|
|
|
configuration = {
|
|
|
|
imports = [
|
2022-05-26 14:47:30 +02:00
|
|
|
(depot.path.origSrc + "/ops/modules/quassel.nix")
|
2021-12-30 06:15:27 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
firewall.allowedTCPPorts = [
|
|
|
|
22 # ssh
|
|
|
|
80 # http
|
|
|
|
443 # https
|
|
|
|
6698 # quassel
|
|
|
|
];
|
|
|
|
firewall.allowedUDPPortRanges = [
|
|
|
|
{ from = 60000; to = 61000; } # mosh
|
|
|
|
];
|
|
|
|
};
|
2021-12-16 06:38:55 +01:00
|
|
|
|
2021-12-30 06:15:27 +01:00
|
|
|
# Use the TVL binary cache
|
|
|
|
tvl.cache.enable = true;
|
2021-12-16 06:38:55 +01:00
|
|
|
|
|
|
|
users = {
|
2021-12-30 06:15:27 +01:00
|
|
|
mutableUsers = true;
|
|
|
|
users = {
|
|
|
|
root = {
|
|
|
|
openssh.authorizedKeys.keys = wpcarro.keys.all;
|
|
|
|
};
|
|
|
|
wpcarro = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "wheel" "quassel" ];
|
|
|
|
openssh.authorizedKeys.keys = wpcarro.keys.all;
|
|
|
|
shell = pkgs.fish;
|
|
|
|
};
|
2021-12-30 20:26:23 +01:00
|
|
|
# This is required so that quasselcore can read the ACME cert in
|
|
|
|
# /var/lib/acme, which is only available to user=acme or group=nginx.
|
|
|
|
quassel.extraGroups = [ "nginx" ];
|
2021-12-16 06:38:55 +01:00
|
|
|
};
|
|
|
|
};
|
2021-12-22 00:24:27 +01:00
|
|
|
|
2021-12-30 06:15:27 +01:00
|
|
|
security = {
|
|
|
|
acme = {
|
|
|
|
acceptTerms = true;
|
2022-01-12 14:43:15 +01:00
|
|
|
defaults.email = "wpcarro@gmail.com";
|
2021-12-30 06:15:27 +01:00
|
|
|
};
|
2021-12-16 06:38:55 +01:00
|
|
|
|
2021-12-30 06:15:27 +01:00
|
|
|
sudo.wheelNeedsPassword = false;
|
2021-12-24 18:56:27 +01:00
|
|
|
};
|
|
|
|
|
2021-12-30 06:15:27 +01:00
|
|
|
programs = wpcarro.common.programs // {
|
|
|
|
mosh.enable = true;
|
2021-12-17 01:49:23 +01:00
|
|
|
};
|
|
|
|
|
2021-12-30 06:15:27 +01:00
|
|
|
# I won't have an Emacs server running on diogenes, and I'll likely be in an
|
|
|
|
# SSH session from within vterm. As such, Vim is one of the few editors that
|
|
|
|
# I tolerably navigate this way.
|
|
|
|
environment.variables = {
|
|
|
|
EDITOR = "vim";
|
2021-12-17 01:12:13 +01:00
|
|
|
};
|
|
|
|
|
2021-12-30 06:15:27 +01:00
|
|
|
environment.systemPackages = wpcarro.common.shell-utils;
|
|
|
|
|
|
|
|
services = wpcarro.common.services // {
|
|
|
|
# TODO(wpcarro): Re-enable this when rebuild-system better supports
|
|
|
|
# terraform deployments.
|
|
|
|
# depot.auto-deploy = {
|
|
|
|
# enable = true;
|
|
|
|
# interval = "1h";
|
|
|
|
# };
|
|
|
|
|
|
|
|
# TODO(wpcarro): Re-enable this after debugging ACME and NXDOMAIN.
|
2021-12-30 15:20:02 +01:00
|
|
|
depot.quassel = {
|
|
|
|
enable = true;
|
|
|
|
acmeHost = domainName;
|
|
|
|
bindAddresses = [
|
|
|
|
"0.0.0.0"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
journaldriver = {
|
|
|
|
enable = true;
|
|
|
|
logStream = "home";
|
|
|
|
googleCloudProject = "wpcarros-infrastructure";
|
|
|
|
applicationCredentials = "/etc/gcp/key.json";
|
|
|
|
};
|
|
|
|
|
|
|
|
nginx = {
|
|
|
|
enable = true;
|
|
|
|
enableReload = true;
|
|
|
|
|
|
|
|
recommendedTlsSettings = true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
|
|
|
|
# for journaldriver
|
|
|
|
commonHttpConfig = ''
|
|
|
|
log_format json_combined escape=json
|
|
|
|
'{'
|
|
|
|
'"remote_addr":"$remote_addr",'
|
|
|
|
'"method":"$request_method",'
|
|
|
|
'"host":"$host",'
|
|
|
|
'"uri":"$request_uri",'
|
|
|
|
'"status":$status,'
|
|
|
|
'"request_size":$request_length,'
|
|
|
|
'"response_size":$body_bytes_sent,'
|
|
|
|
'"response_time":$request_time,'
|
|
|
|
'"referrer":"$http_referer",'
|
|
|
|
'"user_agent":"$http_user_agent"'
|
|
|
|
'}';
|
|
|
|
|
|
|
|
access_log syslog:server=unix:/dev/log,nohostname json_combined;
|
|
|
|
'';
|
|
|
|
|
|
|
|
virtualHosts = {
|
|
|
|
"${domainName}" = {
|
|
|
|
addSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
root = wpcarro.website.root;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2021-12-17 01:12:13 +01:00
|
|
|
};
|
2021-12-16 06:38:55 +01:00
|
|
|
|
2021-12-30 06:15:27 +01:00
|
|
|
system.stateVersion = "21.11";
|
|
|
|
};
|
2021-12-16 06:38:55 +01:00
|
|
|
}
|