nix formating, sops secrets migration, vps-init auto update
This commit is contained in:
parent
db022df80b
commit
fcee389f8e
17 changed files with 950 additions and 818 deletions
|
|
@ -1,71 +1,98 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
{ config, pkgs, ... }: {
|
||||
boot.kernelParams = [ "consoleblank=60" ];
|
||||
imports = [ ../common.nix ./hardware.nix ./mods/web.nix ./mods/mail.nix ./mods/system.nix ];
|
||||
imports = [
|
||||
../common.nix
|
||||
./hardware.nix
|
||||
./mods/mail.nix
|
||||
./mods/system.nix
|
||||
./mods/web.nix
|
||||
];
|
||||
networking = {
|
||||
firewall = {
|
||||
allowedTCPPorts = [
|
||||
25
|
||||
443
|
||||
465
|
||||
80
|
||||
993
|
||||
];
|
||||
allowedUDPPorts = [ 443 ];
|
||||
};
|
||||
hostName = "nixos-server";
|
||||
networkmanager.ensureProfiles.profiles.home-wifi = {
|
||||
ipv4.addresses = "10.1.0.2/16";
|
||||
ipv6.addresses = "fc01::2/64";
|
||||
wifi-security.psk = "$BOGALE_2_4_PSK";
|
||||
wifi.ssid = "bogale_2.4";
|
||||
};
|
||||
wg-quick.interfaces.awg0 = {
|
||||
address = [
|
||||
"10.0.0.2/32"
|
||||
"fc00::2/128"
|
||||
];
|
||||
configFile = config.sops.templates.awg1-conf.path;
|
||||
};
|
||||
};
|
||||
security.acme = {
|
||||
acceptTerms = true;
|
||||
certs."bogaledev.ru" = {
|
||||
credentialFiles.CF_DNS_API_TOKEN_FILE = config.sops.secrets.cf-token.path;
|
||||
dnsProvider = "cloudflare";
|
||||
extraDomainNames = [ "*.bogaledev.ru" ];
|
||||
reloadServices = [
|
||||
"dovecot.service"
|
||||
"nginx.service"
|
||||
"postfix.service"
|
||||
];
|
||||
validMinDays = 3;
|
||||
};
|
||||
defaults.email = "letsencrypt@bogaledev.ru";
|
||||
};
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings.PasswordAuthentication = false;
|
||||
};
|
||||
sops = {
|
||||
secrets.awg1-spec = {};
|
||||
secrets = {
|
||||
awg1-spec = { };
|
||||
cf-token = { };
|
||||
};
|
||||
templates.awg1-conf.content = ''
|
||||
${config.sops.placeholder.awg-obf}
|
||||
${config.sops.placeholder.awg1-spec}
|
||||
'';
|
||||
};
|
||||
systemd.tmpfiles.rules = [
|
||||
"d /root/backup/server"
|
||||
"L /root/backup/server/http - - - - /srv/http"
|
||||
"L /root/backup/server/acme - - - - /var/lib/acme"
|
||||
"L /root/backup/server/mail - - - - /var/spool/mail"
|
||||
"L /root/backup/server/forgejo - - - - /var/lib/forgejo"
|
||||
"L /root/backup/server/http - - - - /srv/http"
|
||||
"L /root/backup/server/mail - - - - /var/spool/mail"
|
||||
"L /root/backup/server/postgresql - - - - /var/backup/postgresql"
|
||||
"d /root/backup/server"
|
||||
];
|
||||
security.acme = {
|
||||
acceptTerms = true;
|
||||
defaults.email = "letsencrypt@bogaledev.ru";
|
||||
certs."bogaledev.ru" = {
|
||||
validMinDays = 3;
|
||||
dnsProvider = "cloudflare";
|
||||
extraDomainNames = [ "*.bogaledev.ru" ];
|
||||
credentialFiles = { "CF_DNS_API_TOKEN_FILE" = "/secrets/cf-token"; };
|
||||
reloadServices = [ "nginx.service" "dovecot.service" "postfix.service" ];
|
||||
};
|
||||
};
|
||||
networking = {
|
||||
hostName = "nixos-server";
|
||||
firewall = {
|
||||
allowedUDPPorts = [ 443 ];
|
||||
allowedTCPPorts = [ 25 80 443 465 993 ];
|
||||
};
|
||||
wg-quick.interfaces.awg0 = {
|
||||
address = [ "10.0.0.2/32" "fc00::2/128" ];
|
||||
configFile = config.sops.templates.awg1-conf.path;
|
||||
};
|
||||
networkmanager.ensureProfiles.profiles.home-wifi = {
|
||||
wifi.ssid = "bogale_2.4";
|
||||
ipv6.addresses = "fc01::2/64";
|
||||
ipv4.addresses = "10.1.0.2/16";
|
||||
wifi-security.psk = "$BOGALE_2_4_PSK";
|
||||
};
|
||||
};
|
||||
users = {
|
||||
groups = {
|
||||
php.gid = 1568;
|
||||
vmail.gid = 1819;
|
||||
};
|
||||
users = {
|
||||
nginx.extraGroups = [ "php" "acme" "grafana" ];
|
||||
root.openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPTb4c1ISQSV34GN27GgaJ08jpiRM3Wul/iSWjQ6emTq" ];
|
||||
nginx.extraGroups = [
|
||||
"acme"
|
||||
"grafana"
|
||||
"php"
|
||||
];
|
||||
php = {
|
||||
uid = 1568;
|
||||
group = "php";
|
||||
isSystemUser = true;
|
||||
uid = 1568;
|
||||
};
|
||||
root.openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPTb4c1ISQSV34GN27GgaJ08jpiRM3Wul/iSWjQ6emTq"
|
||||
];
|
||||
vmail = {
|
||||
uid = 1819;
|
||||
group = "vmail";
|
||||
isSystemUser = true;
|
||||
uid = 1819;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,27 +1,41 @@
|
|||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
{
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
boot = {
|
||||
initrd = {
|
||||
availableKernelModules = [
|
||||
"ahci"
|
||||
"ehci_pci"
|
||||
"sd_mod"
|
||||
"sdhci_pci"
|
||||
"xhci_pci"
|
||||
];
|
||||
luks.devices.root.device = "/dev/disk/by-uuid/e0288e5e-87eb-453f-ab22-0d6e54576609";
|
||||
};
|
||||
kernelParams = [
|
||||
"memmap=0x4000%0xbfb76000-4"
|
||||
"memmap=0x4000%0xbfb7a000-4"
|
||||
];
|
||||
initrd = {
|
||||
availableKernelModules = [ "xhci_pci" "ahci" "ehci_pci" "sd_mod" "sdhci_pci" ];
|
||||
luks.devices.root.device = "/dev/disk/by-uuid/e0288e5e-87eb-453f-ab22-0d6e54576609";
|
||||
};
|
||||
};
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
fsType = "ext4";
|
||||
device = "/dev/mapper/root";
|
||||
fsType = "ext4";
|
||||
};
|
||||
"/boot" = {
|
||||
fsType = "vfat";
|
||||
device = "/dev/disk/by-uuid/86F4-A8F1";
|
||||
options = [ "fmask=0077" "dmask=0077" ];
|
||||
fsType = "vfat";
|
||||
options = [
|
||||
"dmask=0077"
|
||||
"fmask=0077"
|
||||
];
|
||||
};
|
||||
};
|
||||
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,87 +1,111 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, ... }:
|
||||
let
|
||||
postfixDir = "/var/spool/postfix";
|
||||
in {
|
||||
systemd.tmpfiles.rules = [ "d ${postfixDir} 0700 postfix postfix" ];
|
||||
services = let
|
||||
sslCertDir = config.security.acme.certs."bogaledev.ru".directory;
|
||||
in {
|
||||
redis.servers.rspamd = {
|
||||
enable = true;
|
||||
user = "rspamd";
|
||||
};
|
||||
rspamd = {
|
||||
enable = true;
|
||||
postfix.enable = true;
|
||||
locals = {
|
||||
"classifier-bayes.conf".text = "autolearn = true;";
|
||||
"redis.conf".text = ''servers = "${config.services.redis.servers.rspamd.unixSocket}";'';
|
||||
};
|
||||
};
|
||||
postfix = {
|
||||
enable = true;
|
||||
enableSubmissions = true;
|
||||
virtualMapType = "regexp";
|
||||
mapFiles.smtp_passwd = "/secrets/smtp_passwd";
|
||||
virtual = "/.*@bogaledev.ru/ mail@bogaledev.ru";
|
||||
submissionsOptions = {
|
||||
smtpd_sasl_type = "dovecot";
|
||||
smtpd_tls_wrappermode = true;
|
||||
smtpd_sasl_auth_enable = "yes";
|
||||
smtpd_sasl_path = "${postfixDir}/auth";
|
||||
milter_macro_daemon_name = "ORIGINATING";
|
||||
smtpd_client_restrictions = "permit_sasl_authenticated,reject";
|
||||
};
|
||||
settings.main = {
|
||||
smtp_tls_wrappermode = true;
|
||||
smtp_sasl_auth_enable = true;
|
||||
smtp_tls_security_level = "verify";
|
||||
smtpd_tls_security_level = "encrypt";
|
||||
relayhost = [ "smtp.resend.com:2465" ];
|
||||
virtual_mailbox_domains = "bogaledev.ru";
|
||||
smtp_sasl_tls_security_options = "noanonymous";
|
||||
virtual_transport = "lmtp:unix:${postfixDir}/lmtp";
|
||||
smtp_sasl_password_maps = "hash:/etc/postfix/smtp_passwd";
|
||||
smtpd_tls_chain_files = [ "${sslCertDir}/key.pem" "${sslCertDir}/fullchain.pem" ];
|
||||
};
|
||||
};
|
||||
dovecot2 = {
|
||||
enable = true;
|
||||
settings = let
|
||||
postfix-mode = {
|
||||
mode = "0600";
|
||||
user = "postfix";
|
||||
group = "postfix";
|
||||
};
|
||||
in {
|
||||
ssl = "required";
|
||||
mail_gid = "vmail";
|
||||
mail_uid = "vmail";
|
||||
mail_driver = "maildir";
|
||||
auth_mechanisms = [ "plain" ];
|
||||
protocols = [ "imap" "lmtp" ];
|
||||
dovecot_config_version = "2.4.5";
|
||||
dovecot_storage_version = "2.4.5";
|
||||
mail_path = "/var/spool/mail/vmail";
|
||||
ssl_server_key_file = "${sslCertDir}/key.pem";
|
||||
ssl_server_cert_file = "${sslCertDir}/fullchain.pem";
|
||||
"passdb passwd-file".passwd_file_path = "/secrets/dovecot-pw";
|
||||
"service auth"."unix_listener ${postfixDir}/auth" = postfix-mode;
|
||||
"service lmtp"."unix_listener ${postfixDir}/lmtp" = postfix-mode;
|
||||
"namespace inbox" = let
|
||||
mailbox = name: {
|
||||
auto = "subscribe";
|
||||
mailbox_special_use = "\\${name}";
|
||||
in
|
||||
{
|
||||
services =
|
||||
let
|
||||
sslCertDir = config.security.acme.certs."bogaledev.ru".directory;
|
||||
in
|
||||
{
|
||||
dovecot2 = {
|
||||
enable = true;
|
||||
settings =
|
||||
let
|
||||
postfix-mode = {
|
||||
group = "postfix";
|
||||
mode = "0600";
|
||||
user = "postfix";
|
||||
};
|
||||
in
|
||||
{
|
||||
"namespace inbox" =
|
||||
let
|
||||
mailbox = name: {
|
||||
auto = "subscribe";
|
||||
mailbox_special_use = "\\${name}";
|
||||
};
|
||||
in
|
||||
{
|
||||
"mailbox Archive" = mailbox "Archive";
|
||||
"mailbox Important" = mailbox "Flagged";
|
||||
"mailbox Sent" = mailbox "Sent";
|
||||
"mailbox Spam" = mailbox "Junk" // {
|
||||
mailbox_autoexpunge = "45d";
|
||||
};
|
||||
"mailbox Trash" = mailbox "Trash" // {
|
||||
mailbox_autoexpunge = "45d";
|
||||
};
|
||||
inbox = true;
|
||||
};
|
||||
"passdb passwd-file".passwd_file_path = config.sops.secrets.dovecot-pw.path;
|
||||
"service auth"."unix_listener ${postfixDir}/auth" = postfix-mode;
|
||||
"service lmtp"."unix_listener ${postfixDir}/lmtp" = postfix-mode;
|
||||
auth_mechanisms = [ "plain" ];
|
||||
dovecot_config_version = "2.4.5";
|
||||
dovecot_storage_version = "2.4.5";
|
||||
mail_driver = "maildir";
|
||||
mail_gid = "vmail";
|
||||
mail_path = "/var/spool/mail/vmail";
|
||||
mail_uid = "vmail";
|
||||
protocols = [
|
||||
"imap"
|
||||
"lmtp"
|
||||
];
|
||||
ssl = "required";
|
||||
ssl_server_cert_file = "${sslCertDir}/fullchain.pem";
|
||||
ssl_server_key_file = "${sslCertDir}/key.pem";
|
||||
};
|
||||
in {
|
||||
inbox = true;
|
||||
"mailbox Sent" = mailbox "Sent";
|
||||
"mailbox Archive" = mailbox "Archive";
|
||||
"mailbox Important" = mailbox "Flagged";
|
||||
"mailbox Spam" = mailbox "Junk" // { mailbox_autoexpunge = "45d"; };
|
||||
"mailbox Trash" = mailbox "Trash" // { mailbox_autoexpunge = "45d"; };
|
||||
};
|
||||
postfix = {
|
||||
enable = true;
|
||||
enableSubmissions = true;
|
||||
mapFiles.smtp-sasl = config.sops.secrets.smtp-sasl.path;
|
||||
settings.main = {
|
||||
relayhost = [ "smtp.resend.com:2465" ];
|
||||
smtp_sasl_auth_enable = true;
|
||||
smtp_sasl_password_maps = "hash:/etc/postfix/smtp-sasl";
|
||||
smtp_sasl_tls_security_options = "noanonymous";
|
||||
smtp_tls_security_level = "verify";
|
||||
smtp_tls_wrappermode = true;
|
||||
smtpd_tls_chain_files = [
|
||||
"${sslCertDir}/key.pem"
|
||||
"${sslCertDir}/fullchain.pem"
|
||||
];
|
||||
smtpd_tls_security_level = "encrypt";
|
||||
virtual_mailbox_domains = "bogaledev.ru";
|
||||
virtual_transport = "lmtp:unix:${postfixDir}/lmtp";
|
||||
};
|
||||
submissionsOptions = {
|
||||
milter_macro_daemon_name = "ORIGINATING";
|
||||
smtpd_client_restrictions = "permit_sasl_authenticated,reject";
|
||||
smtpd_sasl_auth_enable = "yes";
|
||||
smtpd_sasl_path = "${postfixDir}/auth";
|
||||
smtpd_sasl_type = "dovecot";
|
||||
smtpd_tls_wrappermode = true;
|
||||
};
|
||||
virtual = "/.*@bogaledev.ru/ mail@bogaledev.ru";
|
||||
virtualMapType = "regexp";
|
||||
};
|
||||
redis.servers.rspamd = {
|
||||
enable = true;
|
||||
user = "rspamd";
|
||||
};
|
||||
rspamd = {
|
||||
enable = true;
|
||||
locals = {
|
||||
"classifier-bayes.conf".text = "autolearn = true;";
|
||||
"redis.conf".text = ''servers = "${config.services.redis.servers.rspamd.unixSocket}";'';
|
||||
};
|
||||
postfix.enable = true;
|
||||
};
|
||||
};
|
||||
sops.secrets = {
|
||||
dovecot-pw = {
|
||||
group = "dovecot2";
|
||||
mode = "0440";
|
||||
};
|
||||
smtp-sasl = { };
|
||||
};
|
||||
systemd.tmpfiles.rules = [ "d ${postfixDir} 0700 postfix" ];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,69 +1,27 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
services = {
|
||||
prometheus = {
|
||||
enable = true;
|
||||
exporters.node.enable = true;
|
||||
scrapeConfigs = [ {
|
||||
{ config, pkgs, ... }: {
|
||||
services.prometheus = {
|
||||
enable = true;
|
||||
exporters.node.enable = true;
|
||||
scrapeConfigs = [
|
||||
{
|
||||
job_name = "node";
|
||||
static_configs = [ { targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ]; } ];
|
||||
} ];
|
||||
};
|
||||
grafana = {
|
||||
enable = true;
|
||||
settings = {
|
||||
security.secret_key = "$__file{/secrets/grafana-key}";
|
||||
database = {
|
||||
user = "grafana";
|
||||
type = "postgres";
|
||||
host = "/run/postgresql";
|
||||
};
|
||||
server = {
|
||||
enable_gzip = true;
|
||||
protocol = "socket";
|
||||
root_url = "https://bogaledev.ru/grafana";
|
||||
};
|
||||
};
|
||||
};
|
||||
static_configs = [
|
||||
{
|
||||
targets = [
|
||||
"localhost:${toString config.services.prometheus.exporters.node.port}"
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
sops.secrets.tgbot-env = { };
|
||||
systemd = {
|
||||
timers = {
|
||||
tgbot-send = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
Persistent = true;
|
||||
OnCalendar = "*-*-01 16:00";
|
||||
};
|
||||
};
|
||||
network-watchdog = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnBootSec = 30;
|
||||
AccuracySec = 1;
|
||||
OnUnitActiveSec = 10;
|
||||
};
|
||||
};
|
||||
};
|
||||
services = {
|
||||
tgbot-send = {
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = ''
|
||||
. /secrets/tgbot.env
|
||||
for msg in "''${MESSAGES[@]}"; do
|
||||
TEXT="''${msg#*:}"
|
||||
CHAT_ID="''${msg%%:*}"
|
||||
${pkgs.curl}/bin/curl -X POST "https://api.telegram.org/$BOT/sendMessage" -d "chat_id=$CHAT_ID" -d "text=$TEXT" 2> /dev/null | ${pkgs.jq}/bin/jq
|
||||
sleep 1
|
||||
done
|
||||
'';
|
||||
};
|
||||
network-watchdog = {
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
LogLevelMax = "warning";
|
||||
};
|
||||
script = ''
|
||||
if [ ! -e /run/network.failures ] || [ ! -e /run/network.limit ] || ${pkgs.curl}/bin/curl --head --max-time 3 https://www.google.com; then
|
||||
if [ ! -e /run/network.failures ] || [ ! -e /run/network.limit ] || \
|
||||
${pkgs.curl}/bin/curl --head --max-time 3 https://bogaledev.ru; then
|
||||
limit=3
|
||||
failures=0
|
||||
else
|
||||
|
|
@ -73,12 +31,48 @@
|
|||
if [ $failures -ge $limit ]; then
|
||||
echo "<4>restarting network"
|
||||
systemctl restart NetworkManager.service
|
||||
sleep 1
|
||||
systemctl restart wg-quick-awg0.service
|
||||
[ $limit -lt 360 ] && limit=$((2*$limit))
|
||||
failures=0
|
||||
fi
|
||||
echo $limit > /run/network.limit
|
||||
echo $failures > /run/network.failures
|
||||
'';
|
||||
serviceConfig = {
|
||||
LogLevelMax = "warning";
|
||||
Type = "oneshot";
|
||||
};
|
||||
};
|
||||
tgbot-send = {
|
||||
script = ''
|
||||
. ${config.sops.secrets.tgbot-env.path}
|
||||
for msg in "''${MESSAGES[@]}"; do
|
||||
CHAT_ID="''${msg%%:*}"
|
||||
TEXT="''${msg#*:}"
|
||||
${pkgs.curl}/bin/curl -X POST "https://api.telegram.org/$BOT/sendMessage" \
|
||||
-d "chat_id=$CHAT_ID" -d "text=$TEXT" 2> /dev/null | ${pkgs.jq}/bin/jq
|
||||
sleep 1
|
||||
done
|
||||
'';
|
||||
serviceConfig.Type = "oneshot";
|
||||
};
|
||||
};
|
||||
timers = {
|
||||
network-watchdog = {
|
||||
timerConfig = {
|
||||
AccuracySec = 1;
|
||||
OnBootSec = 30;
|
||||
OnUnitActiveSec = 10;
|
||||
};
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
tgbot-send = {
|
||||
timerConfig = {
|
||||
OnCalendar = "*-*-01 16:00";
|
||||
Persistent = true;
|
||||
};
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,141 +1,184 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
services = let
|
||||
sslCertDir = config.security.acme.certs."bogaledev.ru".directory;
|
||||
phpSettings = {
|
||||
"pm" = "ondemand";
|
||||
"pm.max_children" = 4;
|
||||
"listen.group" = "nginx";
|
||||
"listen.owner" = "nginx";
|
||||
};
|
||||
in {
|
||||
dnsmasq.settings.cname = "nextcloud-local,localhost";
|
||||
phpfpm.pools.php = {
|
||||
user = "php";
|
||||
group = "php";
|
||||
settings = phpSettings;
|
||||
};
|
||||
postgresqlBackup = {
|
||||
enable = true;
|
||||
startAt = "16:00";
|
||||
compression = "none";
|
||||
databases = [ "php" "forgejo" "grafana" "nextcloud" "vaultwarden" ];
|
||||
};
|
||||
postgresql = {
|
||||
enable = true;
|
||||
ensureDatabases = [ "php" "grafana" ];
|
||||
ensureUsers = let
|
||||
user = name: {
|
||||
inherit name;
|
||||
ensureDBOwnership = true;
|
||||
};
|
||||
in map user [ "php" "grafana" ];
|
||||
};
|
||||
nextcloud = {
|
||||
enable = true;
|
||||
poolSettings = phpSettings;
|
||||
hostName = "nextcloud-local";
|
||||
database.createLocally = true;
|
||||
config = {
|
||||
dbtype = "pgsql";
|
||||
adminpassFile = "/secrets/nextcloud-pw";
|
||||
{ config, pkgs, ... }: {
|
||||
services =
|
||||
let
|
||||
phpSettings = {
|
||||
"listen.group" = "nginx";
|
||||
"listen.owner" = "nginx";
|
||||
"pm" = "ondemand";
|
||||
"pm.max_children" = 4;
|
||||
};
|
||||
settings = {
|
||||
overwritewebroot = "/nextcloud";
|
||||
trusted_domains = [ "bogaledev.ru" "wl.bogaledev.ru" ];
|
||||
};
|
||||
};
|
||||
vaultwarden = {
|
||||
enable = true;
|
||||
configurePostgres = true;
|
||||
dbBackend = "postgresql";
|
||||
package = pkgs.vaultwarden-postgresql;
|
||||
environmentFile = "/secrets/vw-token.env";
|
||||
config = {
|
||||
ROCKET_PORT = 46151;
|
||||
SIGNUPS_ALLOWED = false;
|
||||
TRASH_AUTO_DELETE_DAYS = 90;
|
||||
PASSWORD_HINTS_ALLOWED = false;
|
||||
EMERGENCY_ACCESS_ALLOWED = false;
|
||||
DOMAIN = "https://bogaledev.ru/vaultwarden/";
|
||||
};
|
||||
};
|
||||
forgejo = {
|
||||
enable = true;
|
||||
database.type = "postgres";
|
||||
settings = {
|
||||
service = {
|
||||
ENABLE_CAPTCHA = true;
|
||||
REGISTER_EMAIL_CONFIRM = true;
|
||||
};
|
||||
mailer = {
|
||||
ENABLED = true;
|
||||
SMTP_PORT = 25;
|
||||
SMTP_ADDR = "localhost";
|
||||
FROM = "Forgejo <forgejo@bogaledev.ru>";
|
||||
};
|
||||
server = {
|
||||
SSH_PORT = 32831;
|
||||
PROTOCOL = "http+unix";
|
||||
ROOT_URL = "https://bogaledev.ru/git/";
|
||||
HTTP_ADDR = "/run/forgejo/forgejo.sock";
|
||||
};
|
||||
};
|
||||
};
|
||||
nginx = {
|
||||
enable = true;
|
||||
recommendedTlsSettings = true;
|
||||
recommendedGzipSettings = true;
|
||||
recommendedOptimisation = true;
|
||||
recommendedProxySettings = true;
|
||||
recommendedBrotliSettings = true;
|
||||
virtualHosts = {
|
||||
nextcloud-local.listen = [ {
|
||||
port = 45837;
|
||||
addr = "nextcloud-local";
|
||||
} ];
|
||||
main = let
|
||||
phpPool = ''
|
||||
index index.php index.html;
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass unix:${config.services.phpfpm.pools.php.socket};
|
||||
}
|
||||
'';
|
||||
localNetworks = ''
|
||||
allow fc00::/64;
|
||||
allow fc01::/96;
|
||||
allow 10.0.0.0/16;
|
||||
allow 10.1.0.0/24;
|
||||
deny all;
|
||||
'';
|
||||
in {
|
||||
quic = true;
|
||||
default = true;
|
||||
forceSSL = true;
|
||||
root = "/srv/http";
|
||||
useACMEHost = "bogaledev.ru";
|
||||
extraConfig = ''
|
||||
add_header Alt-Svc 'h3=":443"; ma=2592000' always;
|
||||
add_header X-Content-Type-Options 'nosniff' always;
|
||||
'';
|
||||
locations = {
|
||||
"/".extraConfig = phpPool;
|
||||
"/local/".extraConfig = "${phpPool} ${localNetworks}";
|
||||
"/nextcloud/".proxyPass = "http://nextcloud-local:45837/";
|
||||
"/git/".proxyPass = "http://unix:/run/forgejo/forgejo.sock:/";
|
||||
"/vaultwarden/" = {
|
||||
proxyWebsockets = true;
|
||||
extraConfig = localNetworks;
|
||||
proxyPass = "http://localhost:46151";
|
||||
};
|
||||
"/grafana/" = {
|
||||
proxyWebsockets = true;
|
||||
extraConfig = localNetworks;
|
||||
proxyPass = "http://unix:/run/grafana/grafana.sock:/";
|
||||
};
|
||||
sslCertDir = config.security.acme.certs."bogaledev.ru".directory;
|
||||
in
|
||||
{
|
||||
forgejo = {
|
||||
database.type = "postgres";
|
||||
enable = true;
|
||||
settings = {
|
||||
mailer = {
|
||||
ENABLED = true;
|
||||
FROM = "Forgejo <forgejo@bogaledev.ru>";
|
||||
SMTP_ADDR = "localhost";
|
||||
SMTP_PORT = 25;
|
||||
};
|
||||
server = {
|
||||
HTTP_ADDR = "/run/forgejo/forgejo.sock";
|
||||
PROTOCOL = "http+unix";
|
||||
ROOT_URL = "https://bogaledev.ru/git/";
|
||||
SSH_PORT = 32831;
|
||||
};
|
||||
service = {
|
||||
ENABLE_CAPTCHA = true;
|
||||
REGISTER_EMAIL_CONFIRM = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
grafana = {
|
||||
enable = true;
|
||||
settings = {
|
||||
database = {
|
||||
host = "/run/postgresql";
|
||||
type = "postgres";
|
||||
user = "grafana";
|
||||
};
|
||||
security.secret_key = "$__file{${config.sops.secrets.grafana-key.path}}";
|
||||
server = {
|
||||
enable_gzip = true;
|
||||
protocol = "socket";
|
||||
root_url = "https://bogaledev.ru/grafana";
|
||||
};
|
||||
};
|
||||
};
|
||||
nextcloud = {
|
||||
config = {
|
||||
adminpassFile = config.sops.secrets.nextcloud-pw.path;
|
||||
dbtype = "pgsql";
|
||||
};
|
||||
database.createLocally = true;
|
||||
enable = true;
|
||||
hostName = "nextcloud-local";
|
||||
poolSettings = phpSettings;
|
||||
settings = {
|
||||
htaccess.RewriteBase = "/nextcloud";
|
||||
overwritewebroot = "/nextcloud";
|
||||
trusted_domains = [
|
||||
"bogaledev.ru"
|
||||
"wl.bogaledev.ru"
|
||||
];
|
||||
};
|
||||
};
|
||||
nginx = {
|
||||
enable = true;
|
||||
recommendedBrotliSettings = true;
|
||||
recommendedGzipSettings = true;
|
||||
recommendedOptimisation = true;
|
||||
recommendedProxySettings = true;
|
||||
recommendedTlsSettings = true;
|
||||
virtualHosts = {
|
||||
nextcloud-local.listen = [
|
||||
{
|
||||
addr = "localhost";
|
||||
port = 45837;
|
||||
}
|
||||
];
|
||||
main =
|
||||
let
|
||||
localNetworks = ''
|
||||
allow 10.0.0.0/16;
|
||||
allow 10.1.0.0/24;
|
||||
allow fc00::/64;
|
||||
allow fc01::/96;
|
||||
deny all;
|
||||
'';
|
||||
phpPool = ''
|
||||
index index.php index.html;
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass unix:${config.services.phpfpm.pools.php.socket};
|
||||
}
|
||||
'';
|
||||
in
|
||||
{
|
||||
default = true;
|
||||
extraConfig = ''
|
||||
add_header Alt-Svc 'h3=":443"; ma=2592000' always;
|
||||
add_header X-Content-Type-Options 'nosniff' always;
|
||||
'';
|
||||
forceSSL = true;
|
||||
locations = {
|
||||
"/".extraConfig = phpPool;
|
||||
"/git/".proxyPass = "http://unix:/run/forgejo/forgejo.sock:/";
|
||||
"/grafana/" = {
|
||||
extraConfig = localNetworks;
|
||||
proxyPass = "http://unix:/run/grafana/grafana.sock:/";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
"/local/".extraConfig = "${phpPool} ${localNetworks}";
|
||||
"/nextcloud/".proxyPass = "http://localhost:45837/";
|
||||
"/vaultwarden/" = {
|
||||
extraConfig = localNetworks;
|
||||
proxyPass = "http://localhost:46151";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
quic = true;
|
||||
root = "/srv/http";
|
||||
useACMEHost = "bogaledev.ru";
|
||||
};
|
||||
};
|
||||
};
|
||||
phpfpm.pools.php = {
|
||||
group = "php";
|
||||
settings = phpSettings;
|
||||
user = "php";
|
||||
};
|
||||
postgresql = {
|
||||
enable = true;
|
||||
ensureDatabases = [
|
||||
"grafana"
|
||||
"php"
|
||||
];
|
||||
ensureUsers =
|
||||
let
|
||||
user = name: {
|
||||
ensureDBOwnership = true;
|
||||
inherit name;
|
||||
};
|
||||
in
|
||||
map user [
|
||||
"grafana"
|
||||
"php"
|
||||
];
|
||||
};
|
||||
postgresqlBackup = {
|
||||
compression = "none";
|
||||
databases = [
|
||||
"forgejo"
|
||||
"grafana"
|
||||
"nextcloud"
|
||||
"php"
|
||||
"vaultwarden"
|
||||
];
|
||||
enable = true;
|
||||
startAt = "16:00";
|
||||
};
|
||||
vaultwarden = {
|
||||
config = {
|
||||
DOMAIN = "https://bogaledev.ru/vaultwarden/";
|
||||
EMERGENCY_ACCESS_ALLOWED = false;
|
||||
PASSWORD_HINTS_ALLOWED = false;
|
||||
ROCKET_PORT = 46151;
|
||||
SIGNUPS_ALLOWED = false;
|
||||
TRASH_AUTO_DELETE_DAYS = 90;
|
||||
};
|
||||
configurePostgres = true;
|
||||
dbBackend = "postgresql";
|
||||
enable = true;
|
||||
environmentFile = config.sops.secrets.vaultwarden-env.path;
|
||||
package = pkgs.vaultwarden-postgresql;
|
||||
};
|
||||
};
|
||||
sops.secrets = {
|
||||
grafana-key = { };
|
||||
nextcloud-pw = { };
|
||||
vaultwarden-env = { };
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue