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,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