nixos_flake_config/magpie/configuration.nix

310 lines
8.1 KiB
Nix
Raw Normal View History

2023-10-01 16:03:02 +02:00
{
config,
pkgs,
lib,
project-cloud,
2024-01-21 14:05:17 +01:00
goatcounter,
2024-03-16 15:27:40 +01:00
nvim,
system,
2023-10-01 16:03:02 +02:00
...
}: {
2023-10-01 16:16:25 +02:00
imports = [];
2023-10-01 16:03:02 +02:00
nix.optimise.automatic = true;
nix.settings.experimental-features = ["nix-command" "flakes"];
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.configurationLimit = 2;
2023-10-01 16:03:02 +02:00
boot.loader.efi.canTouchEfiVariables = true;
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.kernel.sysctl = {
"net.core.default_qdisc" = "fq";
"net.ipv4.tcp_congestion_control" = "bbr";
};
2023-10-01 16:03:02 +02:00
# Set your time zone.
time.timeZone = "Europe/Berlin";
users.users.root.initialHashedPassword = "";
users.users.root.openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC0gyN7DzF7+sinneq7++fT93dNWe9ttKnLZJEb0LVs7UxPtz/ovlxnktAgEtSh7NUUGKPILGG6+YG/Jz3pb4cLuQHtavIQ2mIzIbiNl+c80gLNPulfOrC3KyCacYnlcEpoV+4yvMPLDf+5ySilYoF30CSIo8B7B4PSwO3/I20oXXY0zeVmYKs65BY8OrR8PDdtPpuqGcTdPpVSrooZQoykriFeejBb0Jn7qWO7vmsTyUZZIP4nKKUyqE6iFZ2zv+J3mYfuoglQKO1+kqcCYCef0sheLZGD4/QIIL8HJ9yNWb6OQhu7MEv1NowuHkviImwVO3actZ1/x4lrWt4mY+bGglVwA90u1KZUQ10qKQ2xCG2ZHE9DSxWxpI/Yq2P4pLA/XSkYFPpzmoD9c6cpv0WLAvmQrEVkqK0xXo+KszUlyGy5sVJl7/h1fZ8YhWsWUnU1XJFmKLaomUZflL3h7X6xJNVPzZmso8l1INdCvIBDu+G84kAp1/aFalSJMyjTgvCc1hxhAVYhmrc3msGH0Jk8CcPBwYa0BH4EryacdupOS/c5VxAbdyuizEgitP1ylRmydVVDEItPNXFvpWdyEehf/VmsUXqL48mBzfvi6feD5AzKjPaQNaATpxLs9Sl9CMxSy27ahHwEK6dek1wm7nkoSIDSRWfGhYKr3lUg0emAYQ=="
];
environment.systemPackages = with pkgs; [
curl
fd
file
fzf
fzy
git
2024-03-16 17:21:46 +01:00
goatcounter.packages.${system}.goatcounter
2024-03-17 19:33:03 +01:00
nvim.packages.${system}.nvim
2023-11-11 23:07:53 +01:00
htop-vim
2024-03-16 15:27:40 +01:00
nvim
pciutils
2023-10-01 16:03:02 +02:00
tig
tmux
2023-10-01 16:03:02 +02:00
unzip
usbutils
2023-10-01 16:03:02 +02:00
wget
zip
];
2023-10-20 21:41:23 +02:00
programs.mosh.enable = true;
2023-10-01 16:03:02 +02:00
mailserver = {
enable = true;
debug = false;
fqdn = "mail.project-cloud.net";
domains = ["project-cloud.net"];
2023-10-25 20:56:34 +02:00
enableSubmissionSsl = true;
2023-10-01 16:03:02 +02:00
enableImap = false;
2023-10-25 20:56:34 +02:00
enableImapSsl = true;
2023-10-01 16:03:02 +02:00
# A list of all login accounts. To create the password hashes, use
# nix-shell -p mkpasswd --run 'mkpasswd -sm bcrypt'
loginAccounts = {
"gitea@project-cloud.net" = {
2023-10-14 23:24:16 +02:00
hashedPasswordFile = config.sops.secrets."gitea_mail_pw_hash".path;
2023-10-01 16:03:02 +02:00
aliases = ["git@project-cloud.net"];
};
2023-10-20 21:10:56 +02:00
"asmir@project-cloud.net" = {
hashedPasswordFile = config.sops.secrets."asmir_mail_pw_hash".path;
aliases = ["asmir.abdulahovic@project-cloud.net"];
};
2023-10-01 16:03:02 +02:00
};
certificateScheme = "acme-nginx";
2023-10-01 16:03:02 +02:00
};
services.journald.extraConfig = ''SystemMaxUse=50M '';
services.logind.extraConfig = ''KillUserProcesses=yes '';
services.openssh.settings.PermitRootLogin = "prohibit-password";
services.openssh.enable = true;
services.opendkim.enable = true;
services.miniflux = {
2023-11-12 19:32:23 +01:00
enable = false;
2023-10-14 23:19:24 +02:00
adminCredentialsFile = config.sops.secrets."miniflux_env".path;
config = {
LISTEN_ADDR = "localhost:5001";
BASE_URL = "https://miniflux.project-cloud.net";
};
};
2024-01-21 14:05:17 +01:00
services.goatcounter = {
enable = true;
environmentFile = "/var/lib/goatcounter.env";
2024-03-17 19:33:03 +01:00
extraArgs = ["-listen='*:8002'" "-tls=proxy"];
2024-01-21 14:05:17 +01:00
database = {
backend = "sqlite";
name = "goatcounter";
user = "goatcounter";
automigrate = true;
};
};
2023-11-06 19:25:49 +01:00
services.nextcloud = {
2023-10-01 16:03:02 +02:00
enable = true;
package = pkgs.nextcloud27;
config.adminpassFile = config.sops.secrets."nextcloud_admin".path;
configureRedis = true;
hostName = "cloud.project-cloud.net";
2023-10-01 16:03:02 +02:00
https = true;
extraOptions = {
mail_smtpmode = "sendmail";
mail_sendmailmode = "pipe";
enabledPreviewProviders = [
"OC\\Preview\\BMP"
"OC\\Preview\\GIF"
"OC\\Preview\\HEIC"
"OC\\Preview\\JPEG"
"OC\\Preview\\Krita"
"OC\\Preview\\MarkDown"
"OC\\Preview\\MP3"
"OC\\Preview\\OpenDocument"
"OC\\Preview\\PNG"
"OC\\Preview\\TXT"
"OC\\Preview\\XBitmap"
];
2023-10-01 16:03:02 +02:00
};
2023-11-06 19:25:49 +01:00
phpOptions = {
"opcache.jit" = "tracing";
"opcache.jit_buffer_size" = "100M";
"opcache.interned_strings_buffer" = "16";
};
2023-10-01 16:03:02 +02:00
};
services.nginx = {
enable = true;
2023-10-05 18:59:43 +02:00
package = pkgs.nginxQuic;
2023-10-01 16:03:02 +02:00
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts."project-cloud.net" = {
quic = true;
forceSSL = true;
enableACME = true;
2024-03-16 17:21:46 +01:00
root = "${project-cloud.packages.${system}.default}/public";
};
2023-10-01 16:03:02 +02:00
virtualHosts.${config.services.nextcloud.hostName} = {
2023-10-05 18:59:43 +02:00
quic = true;
2023-10-01 16:03:02 +02:00
forceSSL = true;
enableACME = true;
};
virtualHosts."miniflux.project-cloud.net" = {
quic = true;
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://localhost:5001";
};
};
2023-10-05 19:04:23 +02:00
virtualHosts.${config.services.gitea.settings.server.DOMAIN} = {
2023-10-05 18:59:43 +02:00
quic = true;
2023-10-01 16:03:02 +02:00
forceSSL = true;
enableACME = true;
locations."/" = {
2023-10-05 19:04:23 +02:00
proxyPass = "http://localhost:${toString config.services.gitea.settings.server.HTTP_PORT}";
2023-10-01 16:03:02 +02:00
};
};
2024-01-21 14:05:17 +01:00
virtualHosts."stats.project-cloud.net" = {
quic = true;
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://localhost:8002/";
};
};
2023-10-01 16:03:02 +02:00
};
services.gitea = {
enable = true;
appName = "Project Cloud Gitea server";
database = {
2023-10-17 23:51:20 +02:00
type = "sqlite3";
passwordFile = config.sops.secrets."gitea_db".path;
2023-10-01 16:03:02 +02:00
};
settings.server = {
DOMAIN = "git.project-cloud.net";
ROOT_URL = "https://git.project-cloud.net";
DISABLE_SSH = true;
HTTP_PORT = 3001;
LANDING_PAGE = "explore";
};
settings.mailer = {
ENABLED = true;
FROM = "gitea@project-cloud.net";
PROTOCOL = "sendmail";
SENDMAIL_PATH = "/run/wrappers/bin/sendmail";
};
settings.service = {
DISABLE_REGISTRATION = true;
REGISTER_EMAIL_CONFIRM = true;
};
settings."markup.restructuredtext" = let
2023-10-01 16:03:02 +02:00
docutils =
pkgs.python3.withPackages (ps: with ps; [docutils pygments]);
in {
ENABLED = true;
FILE_EXTENSIONS = ".rst";
RENDER_COMMAND = "${docutils}/bin/rst2html.py";
IS_INPUT_FILE = false;
};
2023-10-01 16:03:02 +02:00
};
/*
needed for sendmail mail functionality
*/
users.users.gitea.extraGroups = ["postdrop"];
systemd.services.gitea.serviceConfig = {
RestrictAddressFamilies = ["AF_NETLINK"];
ProtectSystem = lib.mkForce false;
};
2024-03-17 19:33:03 +01:00
services._3proxy = {
enable = true;
services = [
{
type = "socks";
auth = ["strong"];
acl = [
{
rule = "allow";
users = ["3proxy_user"];
}
];
bindPort = 13128;
}
];
usersFile = config.sops.secrets."3proxy".path;
};
2023-10-01 16:03:02 +02:00
security.acme = {
acceptTerms = true;
defaults.email = "asmir.abdulahovic@gmail.com";
};
sops.age.sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"];
sops.secrets."miniflux_env" = {
2023-10-13 12:52:26 +02:00
sopsFile = ./secrets/miniflux.yaml;
};
2023-10-14 23:24:16 +02:00
sops.secrets."gitea_mail_pw_hash" = {
sopsFile = ./secrets/gitea_mail_pw_hash.yaml;
2023-10-14 23:19:24 +02:00
};
2023-10-20 21:38:28 +02:00
sops.secrets."asmir_mail_pw_hash" = {
sopsFile = ./secrets/asmir_mail_pw_hash.yaml;
};
2023-10-17 23:51:20 +02:00
sops.secrets."gitea_db" = {
sopsFile = ./secrets/gitea_db.yaml;
owner = config.users.users.gitea.name;
};
sops.secrets."nextcloud_admin" = {
sopsFile = ./secrets/nextcloud_admin.yaml;
owner = config.users.users.nextcloud.name;
};
2024-03-17 19:33:03 +01:00
sops.secrets."3proxy" = {
sopsFile = ./secrets/3proxy.yaml;
};
networking.firewall.enable = true;
2024-03-17 19:33:03 +01:00
networking.firewall.allowedTCPPorts = [80 443 587 13128];
2023-10-01 16:03:02 +02:00
networking.firewall.allowedUDPPorts = [];
networking.firewall.allowPing = true;
networking.firewall.logRefusedConnections = lib.mkDefault false;
networking.hostName = "magpie";
2023-10-01 16:03:02 +02:00
networking.networkmanager.enable = true;
networking.wireless.enable = false;
2023-10-01 16:03:02 +02:00
systemd = {
enableEmergencyMode = false;
watchdog = {
runtimeTime = "20s";
rebootTime = "30s";
};
sleep.extraConfig = ''
AllowSuspend=no
AllowHibernation=no
'';
};
2023-10-01 16:03:02 +02:00
system.stateVersion = "22.11";
}