add backups + fix appservice-irc media proxy
This commit is contained in:
parent
d672a1d1ee
commit
8129b26c4c
14 changed files with 214 additions and 8 deletions
7
hive.nix
7
hive.nix
|
@ -17,7 +17,6 @@ let
|
||||||
nodeNixpkgs = {
|
nodeNixpkgs = {
|
||||||
# FIXME discourse est cassé en unstable
|
# FIXME discourse est cassé en unstable
|
||||||
pendragon = nixpkgs2411;
|
pendragon = nixpkgs2411;
|
||||||
martagon = nixpkgs2411;
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -31,10 +30,11 @@ in
|
||||||
# FIXME
|
# FIXME
|
||||||
nixpkgs.config.permittedInsecurePackage = [ "olm-3.2.16" ];
|
nixpkgs.config.permittedInsecurePackage = [ "olm-3.2.16" ];
|
||||||
|
|
||||||
defaults = { pkgs, lib, ... }: {
|
defaults = { name, pkgs, lib, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
./profiles/sysadmin.nix
|
./profiles/sysadmin.nix
|
||||||
./profiles/infra.nix
|
./profiles/infra.nix
|
||||||
|
./profiles/backups.nix
|
||||||
./profiles/prometheus-node-exporter.nix
|
./profiles/prometheus-node-exporter.nix
|
||||||
#./profiles/ldap.nix
|
#./profiles/ldap.nix
|
||||||
"${src.agenix}/modules/age.nix"
|
"${src.agenix}/modules/age.nix"
|
||||||
|
@ -52,6 +52,7 @@ in
|
||||||
networking.nftables.enable = true;
|
networking.nftables.enable = true;
|
||||||
|
|
||||||
infra.enabled = true;
|
infra.enabled = true;
|
||||||
|
backups.enable = true;
|
||||||
|
|
||||||
# Enable system diffs.
|
# Enable system diffs.
|
||||||
system.activationScripts.system-diff = {
|
system.activationScripts.system-diff = {
|
||||||
|
@ -69,7 +70,7 @@ in
|
||||||
time.timeZone = "Europe/Paris";
|
time.timeZone = "Europe/Paris";
|
||||||
};
|
};
|
||||||
|
|
||||||
vogon = { ... }: {
|
vogon = { pkgs, ... }: {
|
||||||
deployment.tags = [ "hypervisor" ];
|
deployment.tags = [ "hypervisor" ];
|
||||||
networking.hostId = "1751e2a7";
|
networking.hostId = "1751e2a7";
|
||||||
|
|
||||||
|
|
152
profiles/backups.nix
Normal file
152
profiles/backups.nix
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
{ pkgs, config, lib, name, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.backups;
|
||||||
|
secrets = config.age.secrets;
|
||||||
|
postgresql = config.services.postgresql.package;
|
||||||
|
additionalPackages = [
|
||||||
|
pkgs.coreutils
|
||||||
|
postgresql
|
||||||
|
pkgs.sudo
|
||||||
|
pkgs.sqlite
|
||||||
|
];
|
||||||
|
remotes = {
|
||||||
|
memoragon = {
|
||||||
|
host = "memoragon.infra.federez.net";
|
||||||
|
user = "borgmatic";
|
||||||
|
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINdqX4I1JyvhC6dySHLnW1IioYk1ZqltFlbDCygozrWx";
|
||||||
|
path = "./${name}";
|
||||||
|
};
|
||||||
|
harpagon = {
|
||||||
|
host = "harpagon.infra.federez.net";
|
||||||
|
user = "borgmatic";
|
||||||
|
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH1qDEAEJZ0qDRUq4yeHar5LKFTtsvHJIt2a54TBB/Lz";
|
||||||
|
path = "./${name}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.backups = lib.mkOption {
|
||||||
|
type = lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = lib.mkEnableOption "Sauvegardes";
|
||||||
|
directories = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.path;
|
||||||
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
Répertoires à sauvegarder.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
# FIXME add user ?
|
||||||
|
postgresqlDatabases = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
Nom des bases de données PostgreSQL à sauvegarder.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
sqliteDatabases = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf lib.types.path;
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
Chemins des bases de données SQLite à sauvegarder.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Configuration des sauvegardes.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
age.secrets.borgmatic-passphrase = {
|
||||||
|
file = ../secrets/borgmatic-passphrase.age;
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.borgmatic = {
|
||||||
|
path = additionalPackages;
|
||||||
|
serviceConfig = {
|
||||||
|
LoadCredential = "pass:${secrets.borgmatic-passphrase.path}";
|
||||||
|
ExecStartPre = ''
|
||||||
|
${lib.getExe' pkgs.borgmatic "borgmatic"} init --encryption repokey
|
||||||
|
'';
|
||||||
|
# TODO Remove once all hosts are usign NixOS 25.05+
|
||||||
|
NoNewPrivileges = false;
|
||||||
|
CapabilityBoundingSet = "CAP_DAC_READ_SEARCH CAP_NET_RAW CAP_SETUID CAP_SETGID";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.systemPackages =
|
||||||
|
let
|
||||||
|
# KillMode=process is required to allow the background SSH session
|
||||||
|
# to persist when FUSE mounting a remote repository
|
||||||
|
binPath = lib.makeBinPath additionalPackages;
|
||||||
|
borgmaticWithCreds = pkgs.writeScriptBin "borgmatic-with-creds" ''
|
||||||
|
#!${pkgs.runtimeShell}
|
||||||
|
systemd-run --quiet --wait --collect --pipe --pty \
|
||||||
|
--service-type=exec \
|
||||||
|
--uid=root --gid=root \
|
||||||
|
--property=KillMode=none \
|
||||||
|
--property=LoadCredential=pass:${secrets.borgmatic-passphrase.path} \
|
||||||
|
--property=Environment=${binPath} \
|
||||||
|
-- \
|
||||||
|
${lib.getExe' pkgs.borgmatic "borgmatic"} "$@"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
[ borgmaticWithCreds ];
|
||||||
|
|
||||||
|
services.openssh.knownHosts = lib.mapAttrs
|
||||||
|
(_: remote: {
|
||||||
|
hostNames = [ remote.host ];
|
||||||
|
publicKey = remote.publicKey;
|
||||||
|
})
|
||||||
|
remotes;
|
||||||
|
|
||||||
|
services.borgmatic = let
|
||||||
|
version = pkgs.borgmatic.version;
|
||||||
|
hasCredSupport = builtins.compareVersions version "1.9.10" >= 0;
|
||||||
|
encryption = if hasCredSupport then
|
||||||
|
{ encryption_passphrase = "{credential systemd pass}"; }
|
||||||
|
else
|
||||||
|
{ encryption_passcommand = "cat \${CREDENTIALS_DIRECTORY}/pass"; };
|
||||||
|
pgCommand = exe: "${lib.getExe' pkgs.sudo "sudo"} -u postgres ${lib.getExe' postgresql exe}";
|
||||||
|
in {
|
||||||
|
enable = true;
|
||||||
|
# $CREDENTIALS_DIRECTORY does not exist when the config check is run
|
||||||
|
enableConfigCheck = hasCredSupport;
|
||||||
|
settings = {
|
||||||
|
source_directories = cfg.directories;
|
||||||
|
repositories = lib.mapAttrsToList
|
||||||
|
(name: remote: {
|
||||||
|
label = name;
|
||||||
|
path = "ssh://${remote.user}@${remote.host}/${remote.path}";
|
||||||
|
})
|
||||||
|
remotes;
|
||||||
|
# Required for databases hooks
|
||||||
|
read_special = true;
|
||||||
|
# FIXME pertinent de réutiliser celle-là ?
|
||||||
|
ssh_command = "ssh -i /etc/ssh/ssh_host_ed25519_key";
|
||||||
|
keep_daily = 26;
|
||||||
|
keep_weekly = 20;
|
||||||
|
keep_monthly = 12;
|
||||||
|
# add checks
|
||||||
|
postgresql_databases = map
|
||||||
|
(name: {
|
||||||
|
inherit name;
|
||||||
|
username = "postgres";
|
||||||
|
pg_dump_command = if name == "all" then
|
||||||
|
pgCommand "pg_dumpall"
|
||||||
|
else
|
||||||
|
pgCommand "pg_dump";
|
||||||
|
pg_restore_command = pgCommand "pg_restore";
|
||||||
|
psql_command = pgCommand "psql";
|
||||||
|
})
|
||||||
|
cfg.postgresqlDatabases;
|
||||||
|
sqlite_databases = lib.mapAttrsToList
|
||||||
|
(name: path: { inherit name path; })
|
||||||
|
cfg.sqliteDatabases;
|
||||||
|
} // encryption;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
|
cfg = config.services.discourse;
|
||||||
discourse-shared-edits = pkgs.discourse.mkDiscoursePlugin {
|
discourse-shared-edits = pkgs.discourse.mkDiscoursePlugin {
|
||||||
name = "discourse-shared-edits";
|
name = "discourse-shared-edits";
|
||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchFromGitHub {
|
||||||
|
@ -24,6 +25,11 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
backups = {
|
||||||
|
directories = [ "/var/lib/discourse" ];
|
||||||
|
postgresqlDatabases = [ cfg.database.name ];
|
||||||
|
};
|
||||||
|
|
||||||
services.postgresql.package = pkgs.postgresql_13;
|
services.postgresql.package = pkgs.postgresql_13;
|
||||||
|
|
||||||
services.discourse = {
|
services.discourse = {
|
||||||
|
|
|
@ -17,6 +17,11 @@ in
|
||||||
gitlab-ldap-password = ../secrets/gitlab-ldap-password.age;
|
gitlab-ldap-password = ../secrets/gitlab-ldap-password.age;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
backups = {
|
||||||
|
directories = [ cfg.statePath ];
|
||||||
|
postgresqlDatabases = [ cfg.databaseName ];
|
||||||
|
};
|
||||||
|
|
||||||
services.gitlab = {
|
services.gitlab = {
|
||||||
enable = true;
|
enable = true;
|
||||||
databasePasswordFile = secrets.gitlab-db-password.path;
|
databasePasswordFile = secrets.gitlab-db-password.path;
|
||||||
|
|
|
@ -51,6 +51,11 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
backups = {
|
||||||
|
directories = [ cfg.dataDir ];
|
||||||
|
sqliteDatabases.grafana = cfg.settings.database.path;
|
||||||
|
};
|
||||||
|
|
||||||
services.grafana = {
|
services.grafana = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.indico;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../modules/indico.nix
|
../modules/indico.nix
|
||||||
|
@ -26,6 +30,11 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
backups = {
|
||||||
|
directories = [ cfg.stateDir ];
|
||||||
|
postgresqlDatabases = [ cfg.user ];
|
||||||
|
};
|
||||||
|
|
||||||
services.indico = {
|
services.indico = {
|
||||||
enable = true;
|
enable = true;
|
||||||
nginx.domain = "events.federez.net";
|
nginx.domain = "events.federez.net";
|
||||||
|
|
|
@ -4,6 +4,8 @@ let
|
||||||
bindPort = cfg.settings.ircService.mediaProxy.bindPort;
|
bindPort = cfg.settings.ircService.mediaProxy.bindPort;
|
||||||
upstreamUrl = "127.0.0.1:${toString bindPort}";
|
upstreamUrl = "127.0.0.1:${toString bindPort}";
|
||||||
in {
|
in {
|
||||||
|
backups.directories = [ "/var/lib/matrix-appservice-irc" ];
|
||||||
|
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
recommendedProxySettings = true;
|
recommendedProxySettings = true;
|
||||||
|
@ -26,7 +28,10 @@ in {
|
||||||
homeserver.url = "https://matrix.federez.net";
|
homeserver.url = "https://matrix.federez.net";
|
||||||
homeserver.domain = "federez.net";
|
homeserver.domain = "federez.net";
|
||||||
|
|
||||||
ircService.mediaProxy.publicUrl = "https://matrix-irc.federez.net/media";
|
ircService.mediaProxy = {
|
||||||
|
publicUrl = "https://matrix-irc.federez.net/";
|
||||||
|
ttlSeconds = 3153600000; # 100 ans
|
||||||
|
};
|
||||||
|
|
||||||
ircService.servers."irc.rezosup.org" = {
|
ircService.servers."irc.rezosup.org" = {
|
||||||
name = "RezoSup";
|
name = "RezoSup";
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{ pkgs, lib, config, ... }:
|
{ pkgs, lib, config, ... }:
|
||||||
let
|
let
|
||||||
|
cfg = config.services.matrix-synapse;
|
||||||
fqdn = "matrix.federez.net";
|
fqdn = "matrix.federez.net";
|
||||||
baseUrl = "https://${fqdn}";
|
baseUrl = "https://${fqdn}";
|
||||||
in {
|
in {
|
||||||
|
@ -14,6 +15,11 @@ in {
|
||||||
LC_CTYPE = "C";
|
LC_CTYPE = "C";
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
backups = {
|
||||||
|
directories = [ cfg.dataDir ];
|
||||||
|
postgresqlDatabases = [ "matrix-synapse" ];
|
||||||
|
};
|
||||||
|
|
||||||
# Surgical operations for various databases.
|
# Surgical operations for various databases.
|
||||||
environment.systemPackages = [ pkgs.matrix-synapse pkgs.sqlite ];
|
environment.systemPackages = [ pkgs.matrix-synapse pkgs.sqlite ];
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{ lib, config, infra, ... }:
|
{ lib, config, network, ... }:
|
||||||
let
|
let
|
||||||
|
cfg = config.services.victoriametrics;
|
||||||
mkScrapeConfig = name: path: port: targets: {
|
mkScrapeConfig = name: path: port: targets: {
|
||||||
job_name = name;
|
job_name = name;
|
||||||
metrics_path = path;
|
metrics_path = path;
|
||||||
|
@ -17,7 +18,7 @@ let
|
||||||
nodePort = 9100;
|
nodePort = 9100;
|
||||||
vmPort = 8428;
|
vmPort = 8428;
|
||||||
nodesConfig = mkScrapeConfig "node" "/metrics" nodePort
|
nodesConfig = mkScrapeConfig "node" "/metrics" nodePort
|
||||||
(lib.attrsets.mapAttrsToList (n: _: n) infra.nodes);
|
(lib.attrsets.mapAttrsToList (n: _: n) network.infra.nodes);
|
||||||
critical = { severity = "critical"; };
|
critical = { severity = "critical"; };
|
||||||
warning = { severity = "warning"; };
|
warning = { severity = "warning"; };
|
||||||
importRules = path: let
|
importRules = path: let
|
||||||
|
@ -32,6 +33,8 @@ in {
|
||||||
file = ../../secrets/alertbot-matrix-password.age;
|
file = ../../secrets/alertbot-matrix-password.age;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
backups.directories = [ "/var/lib/${cfg.stateDir}" ];
|
||||||
|
|
||||||
services.alertbot = {
|
services.alertbot = {
|
||||||
enable = true;
|
enable = true;
|
||||||
listenPort = 8081;
|
listenPort = 8081;
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
../pubkeys/jeltz.keys
|
../pubkeys/jeltz.keys
|
||||||
];
|
];
|
||||||
|
|
||||||
|
backups.directories = [ "/root" ];
|
||||||
|
|
||||||
nix.package = lib.mkDefault pkgs.lix;
|
nix.package = lib.mkDefault pkgs.lix;
|
||||||
|
|
||||||
users.motd = (builtins.readFile ./federez.motd);
|
users.motd = (builtins.readFile ./federez.motd);
|
||||||
|
@ -49,7 +51,6 @@
|
||||||
"net.ipv4.tcp_fastopen" = 3;
|
"net.ipv4.tcp_fastopen" = 3;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
pkgs.htop
|
pkgs.htop
|
||||||
pkgs.kitty.terminfo
|
pkgs.kitty.terminfo
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
{ config, lib, ... }: {
|
{ config, lib, ... }: {
|
||||||
|
backups.sqliteDatabases = {
|
||||||
|
mautrix-telegram = "/var/lib/mautrix-telegram/mautrix-telegram.db";
|
||||||
|
};
|
||||||
|
|
||||||
systemd.services.mautrix-telegram.serviceConfig.WorkingDirectory = lib.mkForce "/var/lib/mautrix-telegram";
|
systemd.services.mautrix-telegram.serviceConfig.WorkingDirectory = lib.mkForce "/var/lib/mautrix-telegram";
|
||||||
age.secrets.mautrix-telegram.file = ../secrets/mautrix-telegram.age;
|
age.secrets.mautrix-telegram.file = ../secrets/mautrix-telegram.age;
|
||||||
services.mautrix-telegram = {
|
services.mautrix-telegram = {
|
||||||
|
@ -16,7 +20,7 @@
|
||||||
domain = "federez.net";
|
domain = "federez.net";
|
||||||
};
|
};
|
||||||
bridge = {
|
bridge = {
|
||||||
bridge_notices.exceptions = [ "@klingon:federez.net" ];
|
bridge_notices.exceptions = [ "@alertbot:federez.net" ];
|
||||||
relay_user_distinguishers = [ "🔴" "🟠" "🟡" "🟢" "🔵" "🟣" "🟤" "⚫" "⚪" "🟧" "🟨" "🟩" "🟦" "🟪" "🟫" "⬜" "🔶" "🔷" ];
|
relay_user_distinguishers = [ "🔴" "🟠" "🟡" "🟢" "🔵" "🟣" "🟤" "⚫" "⚪" "🟧" "🟨" "🟩" "🟦" "🟪" "🟫" "⬜" "🔶" "🔷" ];
|
||||||
displayname_preference = [
|
displayname_preference = [
|
||||||
"username"
|
"username"
|
||||||
|
|
|
@ -2,6 +2,13 @@
|
||||||
age.secrets.vaultwarden-secrets.file = ../secrets/vaultwarden-secrets.age;
|
age.secrets.vaultwarden-secrets.file = ../secrets/vaultwarden-secrets.age;
|
||||||
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
||||||
|
|
||||||
|
backups = {
|
||||||
|
directories = [ "/var/lib/bitwarden_rs" ];
|
||||||
|
sqliteDatabases = {
|
||||||
|
vaultwarden = "/var/lib/bitwarden_rs/db.sqlite3";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
recommendedTlsSettings = true;
|
recommendedTlsSettings = true;
|
||||||
|
|
BIN
secrets/borgmatic-passphrase.age
Normal file
BIN
secrets/borgmatic-passphrase.age
Normal file
Binary file not shown.
|
@ -27,6 +27,7 @@ let
|
||||||
grafana-admins = active-admins;
|
grafana-admins = active-admins;
|
||||||
alertbot-admins = active-admins;
|
alertbot-admins = active-admins;
|
||||||
gitlab-admins = active-admins;
|
gitlab-admins = active-admins;
|
||||||
|
backups-admins = active-admins;
|
||||||
servers = [
|
servers = [
|
||||||
estragon
|
estragon
|
||||||
wagon
|
wagon
|
||||||
|
@ -62,4 +63,5 @@ in
|
||||||
"gitlab-db-password.age".publicKeys = [ aragon ] ++ gitlab-admins;
|
"gitlab-db-password.age".publicKeys = [ aragon ] ++ gitlab-admins;
|
||||||
"gitlab-initial-root-password.age".publicKeys = [ aragon ] ++ gitlab-admins;
|
"gitlab-initial-root-password.age".publicKeys = [ aragon ] ++ gitlab-admins;
|
||||||
"gitlab-ldap-password.age".publicKeys = [ aragon ] ++ gitlab-admins;
|
"gitlab-ldap-password.age".publicKeys = [ aragon ] ++ gitlab-admins;
|
||||||
|
"borgmatic-passphrase.age".publicKeys = servers ++ backups-admins;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue