Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repack Module Machenism #39

Merged
merged 18 commits into from
Sep 22, 2024
9 changes: 6 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,12 @@
nixosModules =
let
shadowedModules = [ "sundial" ];
modules = extraLibs.genFilteredDirAttrsV2 ./modules shadowedModules (
n: import (./modules + "/${n}.nix")
);
modules =
let
genModule =
dir: extraLibs.genFilteredDirAttrsV2 dir shadowedModules (n: import (dir + "/${n}.nix"));
in
(genModule ./modules) // { repack = ./repack; };

default =
{ ... }:
Expand Down
1 change: 0 additions & 1 deletion hosts/abhoth/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ withSystem "x86_64-linux" (
user = "elen";
};
modules = lib.sharedModules ++ [
../../srv
../sysvars.nix
./hardware.nix
./network.nix
Expand Down
32 changes: 15 additions & 17 deletions hosts/abhoth/spec.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,29 @@
"nyaw.key"
];

srv = {
repack = {
openssh.enable = true;
fail2ban.enable = true;
dnsproxy = {
enable = true;
override = {
settings = {
bootstrap = [
"1.1.1.1"
"8.8.8.8"
];
listen-addrs = [ "0.0.0.0" ];
listen-ports = [ 53 ];
upstream-mode = "load_balance";
upstream = [
"1.1.1.1"
"8.8.8.8"
"https://dns.google/dns-query"
];
};
};
};
# rustypaste.enable = true;
};
services = {
dnsproxy.settings = lib.mkForce {
bootstrap = [
"1.1.1.1"
"8.8.8.8"
];
listen-addrs = [ "0.0.0.0" ];
listen-ports = [ 53 ];
upstream-mode = "load_balance";
upstream = [
"1.1.1.1"
"8.8.8.8"
"https://dns.google/dns-query"
];
};
metrics.enable = true;
trojan-server.enable = true;
hysteria.instances = [
Expand Down
1 change: 0 additions & 1 deletion hosts/azasos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ withSystem "x86_64-linux" (
user = "elen";
};
modules = lib.sharedModules ++ [
../../srv
inputs.disko.nixosModules.default
./hardware.nix
./network.nix
Expand Down
2 changes: 1 addition & 1 deletion hosts/azasos/spec.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
supportedFilesystems = [ "tcp_bbr" ];
inherit ((import ../sysctl.nix { inherit lib; }).boot) kernel;
};
srv = {
repack = {
openssh.enable = true;
fail2ban.enable = true;
dae.enable = false;
Expand Down
1 change: 0 additions & 1 deletion hosts/colour/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ withSystem "x86_64-linux" (
user = "elen";
};
modules = lib.sharedModules ++ [
../../srv
./hardware.nix
./network.nix
./rekey.nix
Expand Down
1 change: 0 additions & 1 deletion hosts/eihort/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ withSystem "x86_64-linux" (
./spec.nix
./sysctl.nix
../persist.nix
../../srv
../../age.nix
../../packages.nix
../../misc.nix
Expand Down
2 changes: 1 addition & 1 deletion hosts/eihort/spec.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
supportedFilesystems = [ "tcp_bbr" ];
};
# environment.systemPackages = with pkgs;[ zfs ];
srv = {
repack = {
openssh.enable = true;
fail2ban.enable = true;
phantomsocks.enable = true;
Expand Down
5 changes: 1 addition & 4 deletions hosts/hastur/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,12 @@ withSystem "x86_64-linux" (
modules =
lib.sharedModules
++ [
../../srv
./hardware.nix
./network.nix
./rekey.nix
./spec.nix
./caddy.nix
# ./nginx.nix
# ../graphBase.nix
./restic.nix

../persist.nix
../secureboot.nix
Expand All @@ -69,7 +67,6 @@ withSystem "x86_64-linux" (
inputs.niri.nixosModules.niri
../../users.nix

./misskey.nix
../dev.nix
]
++ (with inputs; [
Expand Down
2 changes: 1 addition & 1 deletion hosts/hastur/nginx.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"nyaw.key"
];

srv.nginx.enable = true;
repack.nginx.enable = true;
}
63 changes: 63 additions & 0 deletions hosts/hastur/restic.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{ config, lib, ... }:
{
systemd.services = lib.listToAttrs (
map (name: {
name = "restic-backups-${name}";
value = {
serviceConfig.Environment = [ "GOGC=20" ];
};
}) (lib.attrNames config.services.restic.backups)
);

services.restic = {
backups = {
# solid = {
# passwordFile = config.age.secrets.wg.path;
# repositoryFile = config.age.secrets.restic-repo.path;
# environmentFile = config.age.secrets.restic-envs.path;
# paths = [
# "/persist"
# "/var"
# ];
# extraBackupArgs = [
# "--one-file-system"
# "--exclude-caches"
# "--no-scan"
# "--retry-lock 2h"
# ];
# timerConfig = {
# OnCalendar = "daily";
# RandomizedDelaySec = "4h";
# FixedRandomDelay = true;
# Persistent = true;
# };
# };
critic = {
#### CLOUDFLARE R2 but connectivity bad
# passwordFile = config.age.secrets.wg.path;
# repositoryFile = config.age.secrets.restic-repo-crit.path;
# environmentFile = config.age.secrets.restic-envs-crit.path;
passwordFile = config.age.secrets.wg.path;
repository = "s3:http://10.0.1.3:3900/crit";
environmentFile = config.age.secrets.restic-envs-dc3.path;
####
paths = [
"/var/.snapshots/latest/lib/backup"
"/var/.snapshots/latest/lib/private/matrix-conduit"
];
extraBackupArgs = [
"--exclude-caches"
"--no-scan"
"--retry-lock 2h"
];
pruneOpts = [ "--keep-daily 3" ];
timerConfig = {
OnCalendar = "daily";
RandomizedDelaySec = "4h";
FixedRandomDelay = true;
Persistent = true;
};
};
};
};
}
101 changes: 3 additions & 98 deletions hosts/hastur/spec.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,7 @@
${pkgs.openssh}/bin/ssh-add ${config.age.secrets.id.path}
'';
systemd = {
services = {
alertmanager.serviceConfig.LoadCredential = [
"notifychan:${config.age.secrets.notifychan.path}"
];

atuin.serviceConfig.Environment = [ "RUST_LOG=debug" ];

prometheus.serviceConfig.LoadCredential = (map (lib.genCredPath config)) [
"prom"
];
};

enableEmergencyMode = false;

watchdog = {
runtimeTime = "20s";
rebootTime = "30s";
Expand All @@ -65,7 +52,7 @@
] ++ [ config.services.photoprism.port ];

services.smartd.notifications.systembus-notify.enable = true;
srv = {
repack = {
openssh.enable = true;
fail2ban.enable = true;
dae.enable = true;
Expand All @@ -80,44 +67,12 @@
vaultwarden.enable = true;
matrix-conduit.enable = true;
# coredns.enable = true;
misskey.enable = true;
dnsproxy.enable = true;
srs.enable = true;
grafana.enable = true;
meilisearch.enable = true;
radicle.enable = true;

phantomsocks = {
enable = false;
override = {
settings.interfaces = [
{
device = "bond0";
dns = "tcp://208.67.220.220:5353";
hint = "w-seq,https,w-md5";
name = "default";
}
{
device = "bond0";
dns = "tcp://208.67.220.220:443";
hint = "ipv6,w-seq,w-md5";
name = "v6";
}
{
device = "bond0";
dns = "tcp://208.67.220.220:443";
hint = "df";
name = "df";
}
{
device = "bond0";
dns = "tcp://208.67.220.220:5353";
hint = "http,ttl";
name = "http";
ttl = 15;
}
];
};
};
};
services = {
# ktistec.enable = true;
Expand Down Expand Up @@ -174,57 +129,7 @@
};

sing-box.enable = true;
restic = {
backups = {
# solid = {
# passwordFile = config.age.secrets.wg.path;
# repositoryFile = config.age.secrets.restic-repo.path;
# environmentFile = config.age.secrets.restic-envs.path;
# paths = [
# "/persist"
# "/var"
# ];
# extraBackupArgs = [
# "--one-file-system"
# "--exclude-caches"
# "--no-scan"
# "--retry-lock 2h"
# ];
# timerConfig = {
# OnCalendar = "daily";
# RandomizedDelaySec = "4h";
# FixedRandomDelay = true;
# Persistent = true;
# };
# };
critic = {
#### CLOUDFLARE R2 but connectivity bad
# passwordFile = config.age.secrets.wg.path;
# repositoryFile = config.age.secrets.restic-repo-crit.path;
# environmentFile = config.age.secrets.restic-envs-crit.path;
passwordFile = config.age.secrets.wg.path;
repository = "s3:http://10.0.1.3:3900/crit";
environmentFile = config.age.secrets.restic-envs-dc3.path;
####
paths = [
"/var/.snapshots/latest/lib/backup"
"/var/.snapshots/latest/lib/private/matrix-conduit"
];
extraBackupArgs = [
"--exclude-caches"
"--no-scan"
"--retry-lock 2h"
];
pruneOpts = [ "--keep-daily 3" ];
timerConfig = {
OnCalendar = "daily";
RandomizedDelaySec = "4h";
FixedRandomDelay = true;
Persistent = true;
};
};
};
};

hysteria.instances = [
{
name = "nodens";
Expand Down
2 changes: 1 addition & 1 deletion hosts/kaambl/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ withSystem "x86_64-linux" (
user = "elen";
};
modules = lib.sharedModules ++ [
../../srv
./hardware.nix
./network.nix
./rekey.nix
./spec.nix
../persist.nix
../secureboot.nix
./restic.nix
# inputs.home-manager.nixosModules.default
# ../../home
../sysctl.nix
Expand Down
29 changes: 29 additions & 0 deletions hosts/kaambl/restic.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ config, ... }:
{
restic = {
backups = {
# critic = {
# passwordFile = config.age.secrets.wg.path;
# repository = "rclone:sec:crit";
# rcloneConfigFile = config.age.secrets.rclone-conf.path;
# paths = map (n: "/home/${user}/${n}") [
# "Books"
# "Pictures"
# "Music"
# ];
# extraBackupArgs = [
# "--exclude-caches"
# "--no-scan"
# "--retry-lock 2h"
# ];
# pruneOpts = [ "--keep-daily 3" ];
# timerConfig = {
# OnCalendar = "daily";
# RandomizedDelaySec = "4h";
# FixedRandomDelay = true;
# Persistent = true;
# };
# };
};
};
}
Loading