mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-12-07 05:27:13 -06:00
test: forgejo microVM
This commit is contained in:
parent
1376cdbe77
commit
6011a900de
5 changed files with 97 additions and 11 deletions
|
|
@ -38,12 +38,12 @@ in
|
||||||
port0 = 3033;
|
port0 = 3033;
|
||||||
};
|
};
|
||||||
interface = {
|
interface = {
|
||||||
id = "${idPrefix}-${name}";
|
id = "${idPrefix}${name}";
|
||||||
mac = "02:00:00:00:00:50";
|
mac = "02:00:00:00:00:50";
|
||||||
idUser = "${userPrefix}-${name}";
|
idUser = "${userPrefix}${name}";
|
||||||
macUser = "02:00:00:00:00:02";
|
macUser = "02:00:00:00:00:02";
|
||||||
ip = "192.168.50.50";
|
ip = "192.168.50.50";
|
||||||
gate = "192.168.50.1";
|
gate = "192.168.50.2";
|
||||||
ssh = 2200;
|
ssh = 2200;
|
||||||
};
|
};
|
||||||
ssl = {
|
ssl = {
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,61 @@
|
||||||
imports = [
|
imports = [
|
||||||
flake.inputs.microvm.nixosModules.host
|
flake.inputs.microvm.nixosModules.host
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Enable systemd-networkd for microvm networking only
|
||||||
|
# NetworkManager handles the main network interface
|
||||||
|
systemd.network = {
|
||||||
|
enable = true;
|
||||||
|
wait-online.enable = false; # Don't wait for networkd interfaces
|
||||||
|
|
||||||
|
# Create a bridge for all microvms
|
||||||
|
netdevs = {
|
||||||
|
"20-br-vms" = {
|
||||||
|
netdevConfig = {
|
||||||
|
Name = "br-vms";
|
||||||
|
Kind = "bridge";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
networks = {
|
||||||
|
# Configure the bridge with an IP in your LAN
|
||||||
|
"20-br-vms" = {
|
||||||
|
matchConfig.Name = "br-vms";
|
||||||
|
address = [ "192.168.50.2/24" ];
|
||||||
|
networkConfig = {
|
||||||
|
ConfigureWithoutCarrier = true;
|
||||||
|
# VMs will use this as their gateway
|
||||||
|
};
|
||||||
|
linkConfig = {
|
||||||
|
RequiredForOnline = "no";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Tap interface for forgejo VM (handles both vm-forgejo and vm--forgejo)
|
||||||
|
"30-vm-forgejo" = {
|
||||||
|
matchConfig.Name = "vm-*forgejo";
|
||||||
|
networkConfig = {
|
||||||
|
Bridge = "br-vms";
|
||||||
|
ConfigureWithoutCarrier = true;
|
||||||
|
};
|
||||||
|
linkConfig = {
|
||||||
|
RequiredForOnline = "no";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Tap interface for vaultwarden VM (if you add it)
|
||||||
|
"30-vm-vaultwarden" = {
|
||||||
|
matchConfig.Name = "vm-*vaultwarden";
|
||||||
|
networkConfig = {
|
||||||
|
Bridge = "br-vms";
|
||||||
|
ConfigureWithoutCarrier = true;
|
||||||
|
};
|
||||||
|
linkConfig = {
|
||||||
|
RequiredForOnline = "no";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,6 @@ in
|
||||||
database.type = "postgres";
|
database.type = "postgres";
|
||||||
lfs.enable = true;
|
lfs.enable = true;
|
||||||
|
|
||||||
secrets = {
|
|
||||||
mailer.PASSWD = "${secrets}/${service.name}-smtp";
|
|
||||||
database.PASSWD = "${secrets}/${service.name}-database";
|
|
||||||
};
|
|
||||||
|
|
||||||
dump = {
|
dump = {
|
||||||
interval = "5:00";
|
interval = "5:00";
|
||||||
type = "zip";
|
type = "zip";
|
||||||
|
|
@ -91,8 +86,33 @@ in
|
||||||
systemd = {
|
systemd = {
|
||||||
tmpfiles.rules = [
|
tmpfiles.rules = [
|
||||||
"d ${secrets} 0755 ${service.name} ${service.name} -"
|
"d ${secrets} 0755 ${service.name} ${service.name} -"
|
||||||
|
"d /run/forgejo 0755 ${service.name} ${service.name} -"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
services.copy-forgejo-secrets = {
|
||||||
|
description = "Prepare Forgejo secrets environment file";
|
||||||
|
before = [ "forgejo.service" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = service.name;
|
||||||
|
Group = service.name;
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
cat > /run/forgejo/env << EOF
|
||||||
|
FORGEJO__database__PASSWD=$(cat /run/secrets/${service.name}-database)
|
||||||
|
FORGEJO__mailer__PASSWD=$(cat /run/secrets/${service.name}-smtp)
|
||||||
|
EOF
|
||||||
|
chmod 600 /run/forgejo/env
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
services.forgejo = {
|
||||||
|
serviceConfig = {
|
||||||
|
EnvironmentFile = "/run/forgejo/env";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
services.forgejo-dump = {
|
services.forgejo-dump = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStartPost = "${pkgs.nushell}/bin/nu -c 'ls ${service.varPaths.path0}/dump | where name =~ forgejo-backup and modified < ((date now) - 7day) | each { rm $in.name }'";
|
ExecStartPost = "${pkgs.nushell}/bin/nu -c 'ls ${service.varPaths.path0}/dump | where name =~ forgejo-backup and modified < ((date now) - 7day) | each { rm $in.name }'";
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,13 @@ in
|
||||||
{
|
{
|
||||||
networking = {
|
networking = {
|
||||||
hostName = ceres.name;
|
hostName = ceres.name;
|
||||||
networkmanager.enable = true;
|
networkmanager = {
|
||||||
|
enable = true;
|
||||||
|
unmanaged = [
|
||||||
|
"interface-name:br-vms"
|
||||||
|
"interface-name:vm-*"
|
||||||
|
];
|
||||||
|
};
|
||||||
nftables.enable = true;
|
nftables.enable = true;
|
||||||
useDHCP = lib.mkDefault true;
|
useDHCP = lib.mkDefault true;
|
||||||
firewall = {
|
firewall = {
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,11 @@ in
|
||||||
nat = {
|
nat = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableIPv6 = true;
|
enableIPv6 = true;
|
||||||
externalInterface = "eth0";
|
externalInterface = "enp10s0";
|
||||||
internalInterfaces = [ "wg0" ];
|
internalInterfaces = [
|
||||||
|
"wg0"
|
||||||
|
"br-vms"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
wireguard.interfaces = {
|
wireguard.interfaces = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue