Compare commits

..

3 commits

Author SHA1 Message Date
ada4538ac8 merge 2026-02-10 15:18:38 +01:00
8aab959e42 idk I fixed some stuff 2026-02-10 15:17:32 +01:00
4c66c514a3 runs on prod now :) 2026-02-10 01:07:35 +01:00
5 changed files with 98 additions and 88 deletions

View file

@ -1,4 +1,6 @@
{...}: { {config, ...}: let
username = config.horseman.username;
in {
imports = [ imports = [
../../modules ../../modules
]; ];
@ -6,6 +8,15 @@
config.horseman = { config.horseman = {
users.default.enable = true; users.default.enable = true;
containers = {
enable = true;
backupDir = "/home/${username}/backups";
nginx.enable = true;
vaultwarden.enable = true;
forgejo.enable = true;
};
base = { base = {
nix.enable = true; nix.enable = true;
locale.enable = true; locale.enable = true;

View file

@ -1,5 +1,10 @@
{lib, ...}: let {
inherit (lib) mkOption types; config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption mkOption types;
cfg = config.horseman.containers;
in { in {
imports = [ imports = [
./nginx.nix ./nginx.nix
@ -8,17 +13,20 @@ in {
]; ];
options = { options = {
horseman.containers = {
enable = mkEnableOption "Containers";
backupDir = mkOption { backupDir = mkOption {
type = types.str; type = types.str;
}; };
}; };
};
config = { config = mkIf cfg.enable {
networking.nat = { networking.nat = {
enable = true; enable = true;
# Use "ve-*" when using nftables instead of iptables # Use "ve-*" when using nftables instead of iptables
internalInterfaces = ["ve-+"]; internalInterfaces = ["ve-+"];
externalInterface = "eno1"; externalInterface = "enp2s0";
# Lazy IPv6 connectivity for the container # Lazy IPv6 connectivity for the container
enableIPv6 = true; enableIPv6 = true;
}; };

View file

@ -57,8 +57,8 @@ in {
containers.forgejoRunner = { containers.forgejoRunner = {
autoStart = true; autoStart = true;
privateNetwork = true; privateNetwork = true;
hostAddress = "172.16.0.2"; hostAddress = "172.168.100.2";
localAddress = "192.168.100.2"; localAddress = "192.168.100.102";
bindMounts = { bindMounts = {
"/var/lib/secrets" = { "/var/lib/secrets" = {
@ -91,7 +91,7 @@ in {
systemd.services.startup = { systemd.services.startup = {
script = '' script = ''
cd ${config.users.users.runner.home} cd ${config.users.users.runner.home}
${pkgs.forgejo-runner}/bin/forgejo-runner create-runner-file --instance http://192.168.100.3:3000 --secret $(cat /var/lib/secrets/secret) --name runner ${pkgs.forgejo-runner}/bin/forgejo-runner create-runner-file --instance ${cfg.url} --secret $(cat /var/lib/secrets/secret) --name runner
sleep 10 sleep 10
${pkgs.forgejo-runner}/bin/forgejo-runner daemon --config ${configFile} ${pkgs.forgejo-runner}/bin/forgejo-runner daemon --config ${configFile}
''; '';
@ -106,8 +106,8 @@ in {
containers.forgejo = { containers.forgejo = {
autoStart = true; autoStart = true;
privateNetwork = true; privateNetwork = true;
hostAddress = "172.16.0.3"; hostAddress = "192.168.100.3";
localAddress = "192.168.100.3"; localAddress = "192.168.100.103";
bindMounts = { bindMounts = {
"/var/lib/forgejo" = { "/var/lib/forgejo" = {
@ -127,6 +127,18 @@ in {
... ...
}: { }: {
environment.systemPackages = [pkgs.forgejo]; environment.systemPackages = [pkgs.forgejo];
services.openssh = {
enable = true;
ports = [cfg.sshPort];
settings = {
PermitRootLogin = "no";
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
# AllowUsers = ["git"];
};
};
services.forgejo = { services.forgejo = {
enable = true; enable = true;
@ -139,7 +151,7 @@ in {
ROOT_URL = cfg.url; ROOT_URL = cfg.url;
}; };
session = { session = {
COOKIE_SECURE = false; # TODO Set to true COOKIE_SECURE = true;
}; };
service = { service = {
DISABLE_REGISTRATION = true; DISABLE_REGISTRATION = true;

View file

@ -8,7 +8,6 @@
}: let }: let
inherit (lib) mkEnableOption mkIf mkOption types; inherit (lib) mkEnableOption mkIf mkOption types;
cfg = config.horseman.containers.nginx; cfg = config.horseman.containers.nginx;
osConfig = config;
in { in {
options = { options = {
horseman.containers.nginx = { horseman.containers.nginx = {
@ -27,32 +26,17 @@ in {
defaults.email = "koen.de.ruiter@hotmail.com"; defaults.email = "koen.de.ruiter@hotmail.com";
}; };
containers.nginx = { services.fail2ban.enable = true;
autoStart = true;
privateNetwork = true;
hostAddress = "172.16.0.1";
localAddress = "192.168.100.1";
bindMounts = {
"/var/www/portfolio" = {
hostPath = "/var/www/portfolio";
isReadOnly = true;
};
"/var/www/public" = {
hostPath = "/var/www/public";
isReadOnly = true;
};
};
config = {
config,
pkgs,
lib,
...
}: {
services.nginx = { services.nginx = {
enable = true; enable = true;
streamConfig = ''
server {
listen ${toString config.horseman.containers.forgejo.sshPort};
proxy_pass ${config.containers.forgejo.localAddress}:${toString config.horseman.containers.forgejo.sshPort};
}
'';
virtualHosts = { virtualHosts = {
"${cfg.domain}" = { "${cfg.domain}" = {
forceSSL = true; forceSSL = true;
@ -77,7 +61,7 @@ in {
enableACME = true; enableACME = true;
locations."/" = { locations."/" = {
proxyPass = "http://${osConfig.containers.forgejo.localAddress}:${toString osConfig.horseman.containers.forgejo.port}"; proxyPass = "http://${config.containers.forgejo.localAddress}:${toString config.horseman.containers.forgejo.port}";
}; };
}; };
@ -86,7 +70,7 @@ in {
enableACME = true; enableACME = true;
locations."/" = { locations."/" = {
proxyPass = "http://${osConfig.containers.vaultwarden.localAddress}:${toString osConfig.horseman.containers.vaultwarden.port}"; proxyPass = "http://${config.containers.vaultwarden.localAddress}:${toString config.horseman.containers.vaultwarden.port}";
}; };
}; };
}; };
@ -95,12 +79,7 @@ in {
networking = { networking = {
firewall = { firewall = {
enable = true; enable = true;
allowedTCPPorts = [80 443]; allowedTCPPorts = [80 443 config.horseman.containers.forgejo.sshPort];
};
useHostResolvConf = lib.mkForce false;
};
services.resolved.enable = true;
system.stateVersion = "23.11";
}; };
}; };
}; };

View file

@ -52,14 +52,14 @@ in {
containers.vaultwarden = { containers.vaultwarden = {
autoStart = true; autoStart = true;
privateNetwork = true; privateNetwork = true;
hostAddress = "172.16.0.4"; hostAddress = "192.168.100.4";
localAddress = "192.168.100.4"; localAddress = "192.168.100.104";
bindMounts = { bindMounts = {
"/var/lib/vaultwarden" = { "/var/lib/bitwarden_rs" = {
hostPath = DATA_DIR; hostPath = DATA_DIR;
isReadOnly = false; isReadOnly = false;
}; # TODO set correct };
}; };
config = { config = {