2024-07-08 15:07:24 +05:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
2024-07-18 15:49:05 +05:00
|
|
|
bonPkgs,
|
2024-07-08 15:07:24 +05:00
|
|
|
...
|
2024-07-18 15:49:05 +05:00
|
|
|
}: {
|
2024-07-08 15:07:24 +05:00
|
|
|
system.stateVersion = "23.11";
|
|
|
|
|
|
|
|
imports = [
|
|
|
|
./hardware.nix
|
|
|
|
./users.nix
|
|
|
|
# ./services/papermc.nix # disabled
|
|
|
|
./services/gitea.nix
|
2024-08-09 11:40:10 +05:00
|
|
|
./services/radio.nix
|
2024-10-09 22:40:40 +05:00
|
|
|
./services/matrix.nix
|
2024-10-10 12:43:33 +05:00
|
|
|
./services/metrics.nix
|
2024-07-08 15:07:24 +05:00
|
|
|
];
|
|
|
|
|
|
|
|
# Nix settings
|
|
|
|
nix = {
|
|
|
|
settings = {
|
|
|
|
experimental-features = ["nix-command" "flakes"];
|
|
|
|
trusted-users = ["l-nafaryus"];
|
2024-07-08 16:24:14 +05:00
|
|
|
allowed-users = ["l-nafaryus" "hydra" "hydra-www"];
|
|
|
|
substituters = [
|
2024-07-18 15:49:05 +05:00
|
|
|
"https://cache.elnafo.ru"
|
2024-07-08 16:24:14 +05:00
|
|
|
"https://bonfire.cachix.org"
|
|
|
|
"https://nix-community.cachix.org"
|
|
|
|
];
|
2024-07-08 15:07:24 +05:00
|
|
|
trusted-public-keys = [
|
2024-07-18 15:49:05 +05:00
|
|
|
"cache.elnafo.ru:j3VD+Hn+is2Qk3lPXDSdPwHJQSatizk7V82iJ2RP1yo="
|
2024-07-08 16:24:14 +05:00
|
|
|
"bonfire.cachix.org-1:mzAGBy/Crdf8NhKail5ciK7ZrGRbPJJobW6TwFb7WYM="
|
2024-07-08 15:07:24 +05:00
|
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
|
|
|
];
|
|
|
|
auto-optimise-store = true;
|
|
|
|
allowed-uris = [
|
|
|
|
"github:"
|
|
|
|
"git+https://github.com/"
|
|
|
|
"git+ssh://github.com/"
|
|
|
|
"git+https://vcs.elnafo.ru/"
|
|
|
|
"git+ssh://vcs.elnafo.ru/"
|
|
|
|
];
|
2024-01-06 18:06:02 +05:00
|
|
|
};
|
2024-07-08 15:07:24 +05:00
|
|
|
gc = {
|
|
|
|
automatic = lib.mkDefault true;
|
|
|
|
dates = lib.mkDefault "weekly";
|
2024-07-08 16:24:14 +05:00
|
|
|
options = lib.mkDefault "--delete-older-than 28d";
|
2024-01-06 18:06:02 +05:00
|
|
|
};
|
2024-07-08 15:07:24 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
# Nix packages
|
|
|
|
nixpkgs = {
|
|
|
|
hostPlatform = lib.mkDefault "x86_64-linux";
|
|
|
|
config.allowUnfree = true;
|
|
|
|
config.cudaSupport = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Services
|
|
|
|
services.printing.enable = true;
|
|
|
|
|
|
|
|
services.pipewire = {
|
|
|
|
enable = true;
|
|
|
|
alsa.enable = true;
|
|
|
|
alsa.support32Bit = true;
|
|
|
|
pulse.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
startWhenNeeded = true;
|
|
|
|
settings.PasswordAuthentication = false;
|
|
|
|
settings.KbdInteractiveAuthentication = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.blueman.enable = true;
|
|
|
|
|
|
|
|
services.fail2ban = {
|
|
|
|
enable = true;
|
|
|
|
maxretry = 12;
|
|
|
|
ignoreIP = [
|
|
|
|
"192.168.0.0/16"
|
|
|
|
];
|
|
|
|
bantime = "3h";
|
|
|
|
bantime-increment = {
|
|
|
|
enable = true;
|
|
|
|
multipliers = "1 2 4 8 16 32 64";
|
|
|
|
maxtime = "168h";
|
|
|
|
overalljails = true;
|
2024-01-06 18:06:02 +05:00
|
|
|
};
|
2024-07-08 15:07:24 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
bonfire.withSecrets = true;
|
|
|
|
sops = config.bonfire.secrets.catarina.sops;
|
|
|
|
|
|
|
|
security.acme = {
|
|
|
|
acceptTerms = true;
|
|
|
|
defaults.email = "l.nafaryus@elnafo.ru";
|
|
|
|
defaults.group = "nginx";
|
|
|
|
|
|
|
|
certs = {
|
|
|
|
"elnafo.ru" = {
|
|
|
|
extraDomainNames = ["*.elnafo.ru"];
|
|
|
|
dnsProvider = "webnames";
|
|
|
|
credentialsFile = config.sops.secrets."dns".path;
|
|
|
|
webroot = null;
|
|
|
|
};
|
2024-01-16 01:43:51 +05:00
|
|
|
};
|
2024-07-08 15:07:24 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
package = pkgs.nginx.override {withMail = true;};
|
|
|
|
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedTlsSettings = true;
|
|
|
|
|
|
|
|
clientMaxBodySize = "5G";
|
|
|
|
|
|
|
|
virtualHosts = {
|
|
|
|
"elnafo.ru" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
root = "/var/www";
|
|
|
|
};
|
|
|
|
|
2024-07-12 15:30:50 +05:00
|
|
|
"*.elnafo.ru" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "elnafo.ru";
|
|
|
|
globalRedirect = "elnafo.ru";
|
|
|
|
};
|
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
"www.elnafo.ru" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "elnafo.ru";
|
|
|
|
globalRedirect = "elnafo.ru";
|
|
|
|
};
|
|
|
|
|
|
|
|
"bonfire.elnafo.ru" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "elnafo.ru";
|
2024-07-18 15:49:05 +05:00
|
|
|
locations."/".root = "${bonPkgs.bonfire-docs}";
|
2024-07-08 15:07:24 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
"hydra.elnafo.ru" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "elnafo.ru";
|
|
|
|
locations."/".proxyPass = "http://127.0.0.1:3000";
|
|
|
|
};
|
2024-07-12 15:30:50 +05:00
|
|
|
|
|
|
|
"cache.elnafo.ru" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "elnafo.ru";
|
|
|
|
locations."/".proxyPass = "http://${config.services.nix-serve.bindAddress}:${toString config.services.nix-serve.port}";
|
|
|
|
};
|
2024-01-16 01:43:51 +05:00
|
|
|
};
|
2024-07-08 15:07:24 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
mailserver = {
|
|
|
|
enable = true;
|
|
|
|
fqdn = "elnafo.ru";
|
|
|
|
domains = ["elnafo.ru"];
|
|
|
|
|
|
|
|
certificateScheme = "acme-nginx";
|
|
|
|
enableImapSsl = true;
|
|
|
|
openFirewall = true;
|
|
|
|
localDnsResolver = true;
|
|
|
|
|
|
|
|
loginAccounts = config.bonfire.secrets.catarina.mailAccounts;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.spoofdpi.enable = true;
|
|
|
|
|
|
|
|
services.btrfs.autoScrub = {
|
|
|
|
enable = true;
|
|
|
|
interval = "monthly";
|
|
|
|
fileSystems = ["/"];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.btrbk = {
|
|
|
|
instances."catarina" = {
|
|
|
|
onCalendar = "daily";
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
snapshot_preserve_min = "2d";
|
|
|
|
snapshot_preserve = "14d";
|
|
|
|
snapshot_dir = "/media/btrbk-snapshots";
|
|
|
|
target_preserve_min = "no";
|
|
|
|
target_preserve = "14d 8w *m";
|
|
|
|
|
|
|
|
volume."/" = {
|
|
|
|
target = "/media/btrbk-backups";
|
|
|
|
subvolume = {
|
|
|
|
"var/lib/gitea" = {};
|
|
|
|
"var/lib/postgresql" = {};
|
|
|
|
"var/lib/postfix" = {};
|
|
|
|
"var/vmail" = {};
|
|
|
|
};
|
2024-01-16 01:43:51 +05:00
|
|
|
};
|
2024-07-08 15:07:24 +05:00
|
|
|
};
|
2024-01-16 12:58:07 +05:00
|
|
|
};
|
2024-07-08 15:07:24 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
services.transmission = {
|
|
|
|
enable = true;
|
|
|
|
openRPCPort = true;
|
|
|
|
settings = {
|
|
|
|
rpc-bind-address = "0.0.0.0";
|
|
|
|
rpc-whitelist = "127.0.0.1,192.168.156.101";
|
|
|
|
download-dir = "/media/storage/downloads";
|
|
|
|
incomplete-dir = "/media/storage/downloads/incomplete";
|
2024-01-19 19:59:45 +05:00
|
|
|
};
|
2024-07-08 15:07:24 +05:00
|
|
|
};
|
2024-01-19 19:59:45 +05:00
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
services.oscuro = {
|
|
|
|
enable = true;
|
|
|
|
discordTokenFile = config.sops.secrets.discordToken.path;
|
|
|
|
};
|
2024-01-06 18:06:02 +05:00
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
virtualisation = {
|
|
|
|
containers.enable = true;
|
2024-03-22 23:21:25 +05:00
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
podman = {
|
|
|
|
enable = true;
|
|
|
|
dockerCompat = true;
|
|
|
|
defaultNetwork.settings.dns_enabled = true;
|
2024-04-03 22:24:18 +05:00
|
|
|
};
|
2024-07-08 15:07:24 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
services.hydra = {
|
|
|
|
enable = true;
|
|
|
|
listenHost = "127.0.0.1";
|
|
|
|
port = 3000;
|
|
|
|
hydraURL = "http://127.0.0.1:3000";
|
|
|
|
smtpHost = "elnafo.ru";
|
|
|
|
useSubstitutes = true;
|
|
|
|
notificationSender = "hydra@elnafo.ru";
|
|
|
|
buildMachinesFiles = [];
|
|
|
|
};
|
|
|
|
|
2024-07-12 15:30:50 +05:00
|
|
|
services.nix-serve = {
|
|
|
|
enable = true;
|
|
|
|
secretKeyFile = config.sops.secrets."nix-store/cache-key".path;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users."nix-serve" = {
|
|
|
|
description = "Nix-Serve Service";
|
|
|
|
createHome = false;
|
|
|
|
group = "nix-serve";
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
|
|
|
users.groups."nix-serve" = {};
|
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
# Packages
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
wget
|
|
|
|
|
|
|
|
ntfs3g
|
|
|
|
sshfs
|
|
|
|
exfat
|
|
|
|
btrfs-progs
|
|
|
|
btrbk
|
|
|
|
|
|
|
|
lm_sensors
|
|
|
|
|
|
|
|
git
|
|
|
|
ripgrep
|
|
|
|
fd
|
|
|
|
lazygit
|
|
|
|
unzip
|
|
|
|
|
|
|
|
gnumake
|
|
|
|
|
|
|
|
fishPlugins.fzf-fish
|
|
|
|
fishPlugins.tide
|
|
|
|
fishPlugins.grc
|
|
|
|
fishPlugins.hydro
|
|
|
|
|
|
|
|
nnn
|
|
|
|
fzf
|
|
|
|
grc
|
|
|
|
|
|
|
|
cachix
|
|
|
|
|
|
|
|
gnupg
|
|
|
|
nnn
|
|
|
|
htop
|
|
|
|
];
|
|
|
|
|
|
|
|
programs = {
|
|
|
|
fish.enable = true;
|
|
|
|
|
|
|
|
neovim = {
|
|
|
|
enable = true;
|
|
|
|
defaultEditor = true;
|
2024-01-06 18:06:02 +05:00
|
|
|
};
|
2024-07-08 15:07:24 +05:00
|
|
|
};
|
2024-01-06 18:06:02 +05:00
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
programs.ssh.extraConfig = ''
|
|
|
|
Host astora
|
|
|
|
HostName 192.168.156.101
|
|
|
|
Port 22
|
|
|
|
User l-nafaryus
|
2024-01-10 22:32:33 +05:00
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
Host catarina
|
|
|
|
HostName 192.168.156.102
|
|
|
|
Port 22
|
|
|
|
User l-nafaryus
|
|
|
|
'';
|
2024-01-10 22:32:33 +05:00
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
programs.direnv.enable = true;
|
2024-01-06 18:06:02 +05:00
|
|
|
}
|