1
0
Fork 0
nix-configuration/hosts/Haven/default.nix

170 lines
5.1 KiB
Nix
Raw Normal View History

{
pkgs,
home-manager,
lib,
config,
...
}:
2024-02-29 09:53:34 -05:00
let
start-haven = pkgs.writeShellScriptBin "start-haven" (builtins.readFile ./start-haven.sh);
services-root = "/storage/services";
2024-05-23 23:50:42 -04:00
subdomains = [
config.secrets.services.airsonic.url
2024-05-24 17:33:37 -04:00
config.secrets.services.cache.url
2024-05-23 23:50:42 -04:00
config.secrets.services.forgejo.url
2024-05-24 11:56:23 -04:00
config.secrets.services.gremlin-lab.url
];
2024-02-29 09:53:34 -05:00
in
{
imports = [ ./hardware-configuration.nix ];
system.stateVersion = "24.05";
2024-02-29 09:53:34 -05:00
aux.system = {
apps.tmux.enable = true;
2024-06-24 18:19:27 -04:00
# Configure the bootloader.
bootloader = {
enable = true;
secureboot.enable = true;
tpm2.enable = true;
};
# Change the default text editor. Options are "emacs", "nano", or "vim".
editor = "nano";
2024-06-24 13:08:18 -04:00
gpu.amd.enable = true;
2024-06-24 18:19:27 -04:00
2024-06-24 12:24:21 -04:00
packages = [ start-haven ];
2024-06-24 18:19:27 -04:00
# Keep old generations for one month.
retentionPeriod = "monthly";
services = {
2024-05-20 20:52:57 -04:00
acme = {
enable = true;
2024-05-20 20:56:48 -04:00
defaultEmail = config.secrets.users.aires.email;
2024-05-20 20:52:57 -04:00
certs = {
"${config.secrets.networking.primaryDomain}" = {
dnsProvider = "namecheap";
extraDomainNames = subdomains;
webroot = null; # Required in order to prevent a failed assertion
credentialFiles = {
"NAMECHEAP_API_USER_FILE" = "${pkgs.writeText "namecheap-api-user" ''
${config.secrets.networking.namecheap.api.user}
''}";
"NAMECHEAP_API_KEY_FILE" = "${pkgs.writeText "namecheap-api-key" ''
${config.secrets.networking.namecheap.api.key}
''}";
};
};
"${config.secrets.networking.blogDomain}" = {
dnsProvider = "namecheap";
webroot = null; # Required in order to prevent a failed assertion
credentialFiles = {
"NAMECHEAP_API_USER_FILE" = "${pkgs.writeText "namecheap-api-user" ''
${config.secrets.networking.namecheap.api.user}
''}";
"NAMECHEAP_API_KEY_FILE" = "${pkgs.writeText "namecheap-api-key" ''
${config.secrets.networking.namecheap.api.key}
''}";
};
};
2024-05-20 20:52:57 -04:00
};
};
apcupsd = {
enable = true;
configText = builtins.readFile ./etc/apcupsd.conf;
};
airsonic = {
enable = true;
home = "${services-root}/airsonic-advanced";
};
2024-06-24 12:24:21 -04:00
autoUpgrade = {
2024-06-24 18:19:27 -04:00
enable = false; # Don't update the system...
pushUpdates = true; # ...but do push updates remotely.
2024-06-24 12:24:21 -04:00
configDir = config.secrets.nixConfigFolder;
onCalendar = "daily";
user = config.users.users.aires.name;
};
2024-05-20 20:52:57 -04:00
boinc.enable = true;
2024-05-24 17:33:37 -04:00
cache = {
enable = false; # Disable for now
secretKeyFile = "${services-root}/nix-cache/cache-priv-key.pem";
2024-05-24 17:33:37 -04:00
};
duplicacy-web = {
enable = true;
autostart = false;
environment = "/storage/backups/settings/Haven";
};
forgejo = {
enable = true;
home = "${services-root}/forgejo";
2024-06-04 14:18:45 -04:00
actions = {
enable = true;
token = config.secrets.services.forgejo.runner-token;
};
};
msmtp.enable = true;
2024-05-20 20:52:57 -04:00
nginx = {
enable = true;
autostart = false;
virtualHosts = {
"${config.secrets.networking.primaryDomain}" = {
default = true;
enableACME = true; # Enable Let's Encrypt
locations."/" = {
# Catchall vhost, will redirect users to Forgejo
return = "301 https://${config.secrets.services.forgejo.url}";
2024-05-20 20:52:57 -04:00
};
};
"${config.secrets.networking.blogDomain}" = {
useACMEHost = config.secrets.networking.blogDomain;
forceSSL = true;
2024-06-19 14:26:32 -04:00
root = "${services-root}/nginx/sites/${config.secrets.networking.blogDomain}";
};
2024-05-24 11:56:23 -04:00
"${config.secrets.services.gremlin-lab.url}" = {
useACMEHost = config.secrets.networking.primaryDomain;
forceSSL = true;
locations."/" = {
proxyPass = "http://${config.secrets.services.gremlin-lab.ip}";
proxyWebsockets = true;
extraConfig = "proxy_ssl_server_name on;";
};
};
2024-06-04 14:18:45 -04:00
"${config.secrets.services.forgejo.url}" = {
useACMEHost = config.secrets.networking.primaryDomain;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:3000";
proxyWebsockets = true;
extraConfig = "proxy_ssl_server_name on;"; # required when the target is also TLS server with multiple hosts
};
};
2024-05-20 20:52:57 -04:00
};
};
ssh = {
enable = true;
ports = [ config.secrets.hosts.haven.ssh.port ];
};
2024-05-22 16:47:55 -04:00
virtualization = {
enable = true;
user = "aires";
};
};
users.aires = {
enable = true;
services.syncthing = {
enable = true;
autostart = false;
};
};
};
2024-02-29 09:53:34 -05:00
2024-05-20 20:52:57 -04:00
# TODO: VPN (Check out Wireguard)
# Allow Haven to be a build target for other architectures (mainly ARM64)
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
}