2024-07-01 09:48:29 -04:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
# Do not change this value! This tracks when NixOS was installed on your system.
|
|
|
|
stateVersion = "24.11";
|
2024-07-06 12:50:45 -04:00
|
|
|
hostName = "Dimaga";
|
2024-07-02 10:02:46 -04:00
|
|
|
|
2024-07-11 12:50:48 -04:00
|
|
|
start-services = pkgs.writeShellScriptBin "start-services" (builtins.readFile ./start-services.sh);
|
2024-07-02 10:02:46 -04:00
|
|
|
|
|
|
|
services-root = "/storage/services";
|
|
|
|
|
|
|
|
subdomains = [
|
|
|
|
config.secrets.services.airsonic.url
|
|
|
|
config.secrets.services.forgejo.url
|
|
|
|
config.secrets.services.gremlin-lab.url
|
2024-07-12 14:11:26 -04:00
|
|
|
config.secrets.services.jellyfin.url
|
2024-07-02 10:02:46 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
namecheapCredentials = {
|
|
|
|
"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-07-01 09:48:29 -04:00
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [ ./hardware-configuration.nix ];
|
|
|
|
|
|
|
|
system.stateVersion = stateVersion;
|
2024-07-06 12:50:45 -04:00
|
|
|
networking.hostName = hostName;
|
2024-07-01 09:48:29 -04:00
|
|
|
|
|
|
|
###*** Configure your system below this line. ***###
|
|
|
|
# Set your time zone.
|
|
|
|
# To see all available timezones, run `timedatectl list-timezones`.
|
|
|
|
time.timeZone = "America/New_York";
|
|
|
|
|
2024-07-02 15:12:17 -04:00
|
|
|
# Disable suspend
|
|
|
|
systemd.targets = {
|
|
|
|
sleep.enable = false;
|
|
|
|
suspend.enable = false;
|
|
|
|
hibernate.enable = false;
|
|
|
|
hybrid-sleep.enable = false;
|
|
|
|
};
|
|
|
|
|
2024-07-25 15:45:27 -04:00
|
|
|
# Enable support for building ARM64 packages
|
|
|
|
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
|
|
|
|
|
2024-07-25 14:33:47 -04:00
|
|
|
# Build Nix packages for other hosts.
|
|
|
|
# Runs every Saturday at 4 AM
|
|
|
|
systemd.services."build-hosts" = {
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
User = "root";
|
|
|
|
};
|
|
|
|
path = config.aux.system.corePackages;
|
|
|
|
script = ''
|
|
|
|
cd ${config.secrets.nixConfigFolder}
|
|
|
|
nh os build --hostname Khanda
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
systemd.timers."build-hosts" = {
|
|
|
|
wants = [ "network-online.target" ];
|
|
|
|
after = [ "network-online.target" ];
|
|
|
|
wantedBy = [ "timers.target" ];
|
|
|
|
timerConfig = {
|
|
|
|
OnCalendar = "Sat 04:00";
|
|
|
|
Persistent = true;
|
|
|
|
Unit = "build-hosts.service";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-01 09:48:29 -04:00
|
|
|
# Configure the system.
|
|
|
|
aux.system = {
|
|
|
|
# Enable to allow unfree (e.g. closed source) packages.
|
|
|
|
# Some settings may override this (e.g. enabling Nvidia GPU support).
|
|
|
|
# https://nixos.org/manual/nixpkgs/stable/#sec-allow-unfree
|
|
|
|
allowUnfree = true;
|
|
|
|
|
2024-07-10 10:43:34 -04:00
|
|
|
apps.tmux.enable = true;
|
2024-07-01 09:48:29 -04:00
|
|
|
|
|
|
|
# Enable Secure Boot support.
|
|
|
|
bootloader = {
|
|
|
|
enable = true;
|
2024-07-02 10:02:46 -04:00
|
|
|
secureboot.enable = true;
|
2024-07-01 09:48:29 -04:00
|
|
|
tpm2.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Change the default text editor. Options are "emacs", "nano", or "vim".
|
|
|
|
editor = "nano";
|
|
|
|
|
|
|
|
# Enable GPU support.
|
|
|
|
gpu = {
|
|
|
|
intel.enable = true;
|
|
|
|
nvidia = {
|
2024-07-01 15:51:05 -04:00
|
|
|
enable = true;
|
2024-07-01 09:48:29 -04:00
|
|
|
hybrid = {
|
2024-07-01 15:51:05 -04:00
|
|
|
enable = true;
|
|
|
|
busIDs.nvidia = "PCI:3:0:0";
|
|
|
|
busIDs.intel = "PCI:0:2:0";
|
2024-07-01 09:48:29 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-02 10:02:46 -04:00
|
|
|
packages = [
|
|
|
|
start-services
|
|
|
|
pkgs.htop
|
|
|
|
];
|
|
|
|
|
2024-07-01 09:48:29 -04:00
|
|
|
# Change how long old generations are kept for.
|
2024-07-02 10:02:46 -04:00
|
|
|
retentionPeriod = "monthly";
|
2024-07-01 09:48:29 -04:00
|
|
|
|
|
|
|
services = {
|
2024-07-02 10:02:46 -04:00
|
|
|
acme = {
|
2024-07-01 09:48:29 -04:00
|
|
|
enable = true;
|
2024-07-02 10:02:46 -04:00
|
|
|
defaultEmail = config.secrets.users.aires.email;
|
|
|
|
certs = {
|
|
|
|
"${config.secrets.networking.primaryDomain}" = {
|
|
|
|
dnsProvider = "namecheap";
|
|
|
|
extraDomainNames = subdomains;
|
|
|
|
webroot = null; # Required in order to prevent a failed assertion
|
|
|
|
credentialFiles = namecheapCredentials;
|
|
|
|
};
|
|
|
|
"${config.secrets.networking.blogDomain}" = {
|
|
|
|
dnsProvider = "namecheap";
|
|
|
|
webroot = null; # Required in order to prevent a failed assertion
|
|
|
|
credentialFiles = namecheapCredentials;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
apcupsd = {
|
|
|
|
enable = true;
|
2024-07-11 12:50:48 -04:00
|
|
|
configText = builtins.readFile ./etc/apcupsd.conf;
|
2024-07-02 10:02:46 -04:00
|
|
|
};
|
|
|
|
airsonic = {
|
|
|
|
enable = true;
|
2024-07-02 10:50:23 -04:00
|
|
|
autostart = false;
|
2024-07-02 10:02:46 -04:00
|
|
|
home = "${services-root}/airsonic-advanced";
|
|
|
|
domain = config.secrets.networking.primaryDomain;
|
|
|
|
url = config.secrets.services.airsonic.url;
|
|
|
|
};
|
2024-07-12 14:11:26 -04:00
|
|
|
jellyfin = {
|
|
|
|
enable = true;
|
|
|
|
autostart = false;
|
|
|
|
home = "${services-root}/jellyfin";
|
|
|
|
domain = config.secrets.networking.primaryDomain;
|
|
|
|
url = config.secrets.services.jellyfin.url;
|
|
|
|
};
|
2024-07-02 10:02:46 -04:00
|
|
|
autoUpgrade = {
|
2024-08-02 12:17:27 -04:00
|
|
|
enable = false; # Don't update the system...
|
|
|
|
pushUpdates = true; # ...but do push updates remotely.
|
2024-07-01 09:48:29 -04:00
|
|
|
configDir = config.secrets.nixConfigFolder;
|
|
|
|
onCalendar = "daily";
|
|
|
|
user = config.users.users.aires.name;
|
|
|
|
};
|
2024-07-02 10:02:46 -04:00
|
|
|
boinc.enable = true;
|
|
|
|
cache = {
|
|
|
|
enable = false; # Disable for now
|
|
|
|
secretKeyFile = "${services-root}/nix-cache/cache-priv-key.pem";
|
|
|
|
};
|
|
|
|
duplicacy-web = {
|
|
|
|
enable = true;
|
|
|
|
autostart = false;
|
|
|
|
environment = "/storage/backups/settings/Haven";
|
|
|
|
};
|
|
|
|
forgejo = {
|
|
|
|
enable = true;
|
2024-07-02 10:50:23 -04:00
|
|
|
autostart = false;
|
2024-07-02 10:02:46 -04:00
|
|
|
home = "${services-root}/forgejo";
|
|
|
|
domain = config.secrets.networking.primaryDomain;
|
|
|
|
url = config.secrets.services.forgejo.url;
|
|
|
|
actions = {
|
|
|
|
enable = true;
|
|
|
|
token = config.secrets.services.forgejo.runner-token;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
msmtp.enable = true;
|
|
|
|
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}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
"${config.secrets.networking.blogDomain}" = {
|
|
|
|
useACMEHost = config.secrets.networking.blogDomain;
|
|
|
|
forceSSL = true;
|
|
|
|
root = "${services-root}/nginx/sites/${config.secrets.networking.blogDomain}";
|
|
|
|
};
|
|
|
|
"${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;";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
ssh = {
|
|
|
|
enable = true;
|
2024-07-11 12:50:48 -04:00
|
|
|
ports = [ config.secrets.hosts.dimaga.ssh.port ];
|
2024-07-02 10:02:46 -04:00
|
|
|
};
|
|
|
|
virtualization = {
|
|
|
|
host = {
|
|
|
|
enable = true;
|
|
|
|
user = "aires";
|
|
|
|
vmBuilds = {
|
|
|
|
enable = true;
|
|
|
|
cores = 3;
|
2024-07-08 16:27:31 -04:00
|
|
|
ram = 3072;
|
2024-07-02 10:02:46 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-07-01 09:48:29 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
users.aires = {
|
|
|
|
enable = true;
|
|
|
|
services = {
|
|
|
|
syncthing = {
|
|
|
|
enable = true;
|
2024-07-02 10:02:46 -04:00
|
|
|
autostart = false;
|
2024-07-01 09:48:29 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|