This commit is contained in:
Tristan 2024-02-26 18:26:21 +00:00
parent 7fc3164ab8
commit a8b581f499
12 changed files with 81 additions and 64 deletions

View file

@ -57,6 +57,15 @@
alpine = mkConf [ alpine = mkConf [
./hardware/alpine.nix ./hardware/alpine.nix
./nixos/services/anki.nix
./nixos/services/forgejo.nix
./nixos/services/vaultwarden.nix
./nixos/services/jellyfin.nix
./nixos/services/mpd.nix
./nixos/services/prometheus.nix
./nixos/services/grafana.nix
./nixos/services/synapse.nix
./nixos/services/nextcloud.nix
] []; ] [];
vm-sway = vm-sway =

View file

@ -9,17 +9,10 @@
in { in {
imports = [ imports = [
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
../nixos/services/anki.nix
../nixos/services/forgejo.nix
../nixos/services/vaultwarden.nix
../nixos/services/jellyfin.nix
../nixos/services/mpd.nix
../nixos/services/prometheus.nix
../nixos/services/grafana.nix
../nixos/services/synapse.nix
../nixos/services/nextcloud.nix
]; ];
networking.domain = "tristans.cloud";
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "sd_mod"]; boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "sd_mod"];
boot.initrd.kernelModules = []; boot.initrd.kernelModules = [];
boot.kernelModules = []; boot.kernelModules = [];
@ -185,11 +178,6 @@ in {
}; };
services.grafana.settings.server = { services.grafana.settings.server = {
domain = "monitor.tristans.cloud";
http_port = 3001; # forgejo and grafana default to 3000 http_port = 3001; # forgejo and grafana default to 3000
}; };
services.nextcloud.hostName = "files.tristans.cloud";
services.forgejo.settings.server.DOMAIN = "git.tristans.cloud";
} }

View file

@ -4,8 +4,7 @@
user, user,
userFullname, userFullname,
... ...
}: modules: home-modules: }: modules: home-modules: let
let
inherit (inputs) home-manager nixpkgs hyprland sops-nix; inherit (inputs) home-manager nixpkgs hyprland sops-nix;
in in
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {

View file

@ -113,6 +113,6 @@ in {
services.prometheus.exporters.node = { services.prometheus.exporters.node = {
enable = true; enable = true;
enabledCollectors = [ "systemd" ]; enabledCollectors = ["systemd"];
}; };
} }

View file

@ -1,8 +1,7 @@
{config, ...}: {config, ...}: let
let
anki = config.services.anki-sync-server; anki = config.services.anki-sync-server;
secrets = config.sops.secrets; secrets = config.sops.secrets;
domain = "tristans.cloud"; domain = config.networking.domain;
in { in {
sops.secrets."anki/password" = { sops.secrets."anki/password" = {
owner = "anki"; owner = "anki";
@ -21,11 +20,14 @@ in {
services.nginx.virtualHosts."anki.${domain}" = { services.nginx.virtualHosts."anki.${domain}" = {
forceSSL = true; forceSSL = true;
enableACME = true; enableACME = true;
locations."~".proxyPass = "http://localhost:${toString anki.port}"; locations."~".proxyPass = "http://localhost:${toString anki.port}";
}; };
# TODO: this really ought to be part of the nixpkgs anki-sync-server module # TODO: this really ought to be part of the nixpkgs anki-sync-server module
users.users.anki = { group = "anki"; isSystemUser = true; }; users.users.anki = {
group = "anki";
isSystemUser = true;
};
users.groups.anki = {}; users.groups.anki = {};
systemd.services.anki-sync-server.serviceConfig.User = "anki"; systemd.services.anki-sync-server.serviceConfig.User = "anki";
} }

View file

@ -8,6 +8,7 @@ in {
settings = { settings = {
server = { server = {
ROOT_URL = "https://${cfg.settings.server.DOMAIN}"; ROOT_URL = "https://${cfg.settings.server.DOMAIN}";
DOMAIN = "git.${config.networking.domain}";
}; };
service = { service = {
DISABLE_REGISTRATION = true; DISABLE_REGISTRATION = true;

View file

@ -10,6 +10,7 @@ in {
settings = { settings = {
server = { server = {
root_url = "https://${cfg.settings.server.domain}"; root_url = "https://${cfg.settings.server.domain}";
domain = "monitor.${config.networking.domain}";
}; };
"auth.generic_oauth" = { "auth.generic_oauth" = {
enabled = true; enabled = true;
@ -21,8 +22,7 @@ in {
token_url = "https://auth.tristans.cloud/application/o/token/"; token_url = "https://auth.tristans.cloud/application/o/token/";
api_url = "https://auth.tristans.cloud/application/o/userinfo/"; api_url = "https://auth.tristans.cloud/application/o/userinfo/";
redirect_url = "https://auth.tristans.cloud/application/o/grafana/end-session/"; redirect_url = "https://auth.tristans.cloud/application/o/grafana/end-session/";
role_attribute_path = role_attribute_path = "contains(groups[*], 'Grafana Admins') && 'Admin' || contains(groups[*], 'Grafana Editors') && 'Editor' || 'Viewer'";
"contains(groups[*], 'Grafana Admins') && 'Admin' || contains(groups[*], 'Grafana Editors') && 'Editor' || 'Viewer'";
}; };
}; };
}; };

View file

@ -1,5 +1,8 @@
{config, pkgs, ...}: {
let config,
pkgs,
...
}: let
nextcloud = config.services.nextcloud; nextcloud = config.services.nextcloud;
secrets = config.sops.secrets; secrets = config.sops.secrets;
sops = config.sops; sops = config.sops;
@ -19,11 +22,12 @@ in {
}; };
}; };
environment.systemPackages = with pkgs; [ ffmpeg ]; environment.systemPackages = with pkgs; [ffmpeg];
services.nextcloud = { services.nextcloud = {
enable = true; enable = true;
https = true; https = true;
hostName = "files.${config.networking.domain}";
configureRedis = true; configureRedis = true;
config = { config = {
adminpassFile = secrets."nextcloud/admin_password".path; adminpassFile = secrets."nextcloud/admin_password".path;

View file

@ -1,21 +1,21 @@
{config, ...}: {config, ...}: let
let inherit (config.services) prometheus;
inherit ( config.services ) prometheus;
nodes = [ nodes = [
"100.65.29.110" "100.65.29.110"
"100.106.241.122" "100.106.241.122"
]; ];
addPort = ip: "${ip}:${toString prometheus.exporters.node.port}"; addPort = ip: "${ip}:${toString prometheus.exporters.node.port}";
in in {
{
services.prometheus = { services.prometheus = {
enable = true; enable = true;
scrapeConfigs = [ scrapeConfigs = [
{ {
job_name = "nodes"; job_name = "nodes";
static_configs = [{ static_configs = [
targets = builtins.map addPort nodes; {
}]; targets = builtins.map addPort nodes;
}
];
} }
]; ];
}; };

View file

@ -1,5 +1,9 @@
{pkgs, config, lib, ...}: {
let pkgs,
config,
lib,
...
}: let
fqdn = "${hostname}.${domain}"; fqdn = "${hostname}.${domain}";
domain = "tristans.cloud"; domain = "tristans.cloud";
hostname = "matrix"; hostname = "matrix";
@ -12,7 +16,6 @@ let
inherit (config) sops; inherit (config) sops;
inherit (config.services) matrix-synapse; inherit (config.services) matrix-synapse;
inherit (sops) secrets templates; inherit (sops) secrets templates;
in { in {
services.postgresql.enable = true; services.postgresql.enable = true;
services.postgresql.initialScript = pkgs.writeText "synapse-init.sql" '' services.postgresql.initialScript = pkgs.writeText "synapse-init.sql" ''
@ -32,21 +35,23 @@ in {
"synapse/secrets.yaml" = { "synapse/secrets.yaml" = {
owner = "matrix-synapse"; owner = "matrix-synapse";
content = builtins.toJSON { content = builtins.toJSON {
oidc_providers = [{ oidc_providers = [
idp_id = "authentik"; {
idp_name = "authentik"; idp_id = "authentik";
discover = true; idp_name = "authentik";
issuer = "https://auth.tristans.cloud/application/o/chat/"; discover = true;
client_id = "fdad520e8c57f228aaa658aa74d5e00ba9b164a3"; issuer = "https://auth.tristans.cloud/application/o/chat/";
client_secret = sops.placeholder."synapse/oidc_client_secret"; client_id = "fdad520e8c57f228aaa658aa74d5e00ba9b164a3";
scopes = ["openid" "profile" "email"]; client_secret = sops.placeholder."synapse/oidc_client_secret";
user_mapping_provider = { scopes = ["openid" "profile" "email"];
config = { user_mapping_provider = {
localpart_template= "{{ user.preferred_username }}"; config = {
display_name_template= "{{ user.name|capitalize }}"; localpart_template = "{{ user.preferred_username }}";
display_name_template = "{{ user.name|capitalize }}";
};
}; };
}; }
}]; ];
}; };
}; };
"synapse/sliding_sync_env".content = '' "synapse/sliding_sync_env".content = ''
@ -62,17 +67,21 @@ in {
server_name = domain; server_name = domain;
baseurl = "https://${domain}"; baseurl = "https://${domain}";
oidc_providers = []; oidc_providers = [];
settings.listeners = [ { settings.listeners = [
inherit port; {
bind_addresses = [ "localhost" ]; inherit port;
type = "http"; bind_addresses = ["localhost"];
tls = false; type = "http";
x_forwarded = true; tls = false;
resources = [ { x_forwarded = true;
names = [ "client" "federation" ]; resources = [
compress = true; {
} ]; names = ["client" "federation"];
} ]; compress = true;
}
];
}
];
}; };
}; };

View file

@ -1,6 +1,6 @@
{config, ...}: let {config, ...}: let
cfg = config.services.vaultwarden; cfg = config.services.vaultwarden;
domain = "vault.tristans.cloud"; domain = "vault.${config.networking.domain}";
in { in {
services.vaultwarden = { services.vaultwarden = {
enable = true; enable = true;

View file

@ -0,0 +1,5 @@
{
services.mautrix-whatsapp = {
enable = true;
};
}