nixos/whale2: Add Valheim server 😳
This commit is contained in:
parent
9750bc5052
commit
ca8ad4c043
@ -198,6 +198,8 @@ rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pubDomain = "nul.ie";
|
pubDomain = "nul.ie";
|
||||||
|
dockerNetAssignment =
|
||||||
|
assignments: name: with assignments."${name}".internal; "ip=${ipv4.address},ip=${ipv6.address}";
|
||||||
colony = rec {
|
colony = rec {
|
||||||
domain = "fra1.int.${pubDomain}";
|
domain = "fra1.int.${pubDomain}";
|
||||||
start = {
|
start = {
|
||||||
|
@ -192,6 +192,17 @@
|
|||||||
port = 8448;
|
port = 8448;
|
||||||
dst = allAssignments.middleman.internal.ipv4.address + ":8448";
|
dst = allAssignments.middleman.internal.ipv4.address + ":8448";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
port = 2456;
|
||||||
|
dst = allAssignments.valheim-oci.internal.ipv4.address + ":2456";
|
||||||
|
proto = "udp";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
port = 2457;
|
||||||
|
dst = allAssignments.valheim-oci.internal.ipv4.address + ":2457";
|
||||||
|
proto = "udp";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
extraRules =
|
extraRules =
|
||||||
@ -209,6 +220,7 @@
|
|||||||
tcp dport ssh accept
|
tcp dport ssh accept
|
||||||
|
|
||||||
${matchInet "tcp dport { http, https, 8448 } accept" "middleman"}
|
${matchInet "tcp dport { http, https, 8448 } accept" "middleman"}
|
||||||
|
${matchInet "udp dport { 2456-2457 } accept" "valheim-oci"}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -203,9 +203,13 @@ in
|
|||||||
ns IN ALIAS ${config.networking.fqdn}.
|
ns IN ALIAS ${config.networking.fqdn}.
|
||||||
|
|
||||||
@ IN ALIAS ${config.networking.fqdn}.
|
@ IN ALIAS ${config.networking.fqdn}.
|
||||||
|
|
||||||
http IN A ${assignments.internal.ipv4.address}
|
http IN A ${assignments.internal.ipv4.address}
|
||||||
http IN AAAA ${allAssignments.middleman.internal.ipv6.address}
|
http IN AAAA ${allAssignments.middleman.internal.ipv6.address}
|
||||||
|
|
||||||
|
valheim IN A ${assignments.internal.ipv4.address}
|
||||||
|
valheim IN AAAA ${allAssignments.valheim-oci.internal.ipv6.address}
|
||||||
|
|
||||||
$TTL 3
|
$TTL 3
|
||||||
_acme-challenge IN LUA TXT @@FILE@@
|
_acme-challenge IN LUA TXT @@FILE@@
|
||||||
|
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
{ lib, ... }: {
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (builtins) mapAttrs;
|
||||||
|
in
|
||||||
|
{
|
||||||
nixos.systems.whale2 = {
|
nixos.systems.whale2 = {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
nixpkgs = "mine";
|
nixpkgs = "mine";
|
||||||
@ -25,9 +29,20 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extraAssignments = mapAttrs (n: i: {
|
||||||
|
internal = {
|
||||||
|
name = n;
|
||||||
|
domain = lib.my.colony.domain;
|
||||||
|
ipv4.address = "${lib.my.colony.start.oci.v4}${toString i}";
|
||||||
|
ipv6.address = "${lib.my.colony.start.oci.v6}${toString i}";
|
||||||
|
};
|
||||||
|
}) {
|
||||||
|
valheim-oci = 2;
|
||||||
|
};
|
||||||
|
|
||||||
configuration = { lib, pkgs, modulesPath, config, assignments, allAssignments, ... }:
|
configuration = { lib, pkgs, modulesPath, config, assignments, allAssignments, ... }:
|
||||||
let
|
let
|
||||||
inherit (builtins) mapAttrs toJSON;
|
inherit (builtins) toJSON;
|
||||||
inherit (lib) mkIf mkMerge mkForce;
|
inherit (lib) mkIf mkMerge mkForce;
|
||||||
inherit (lib.my) networkdAssignment;
|
inherit (lib.my) networkdAssignment;
|
||||||
in
|
in
|
||||||
@ -35,7 +50,7 @@
|
|||||||
imports = [
|
imports = [
|
||||||
"${modulesPath}/profiles/qemu-guest.nix"
|
"${modulesPath}/profiles/qemu-guest.nix"
|
||||||
|
|
||||||
|
./valheim.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
@ -75,6 +90,9 @@
|
|||||||
podman = {
|
podman = {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
|
oci-containers = {
|
||||||
|
backend = "podman";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
|
38
nixos/boxes/colony/vms/whale2/valheim.nix
Normal file
38
nixos/boxes/colony/vms/whale2/valheim.nix
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{ lib, config, allAssignments, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib.my) dockerNetAssignment;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
virtualisation.oci-containers.containers = {
|
||||||
|
valheim = {
|
||||||
|
image = "lloesche/valheim-server@sha256:8d910b15e3ab645a31c85799338d3dc043cabe891a34b43cbd574a1453837205";
|
||||||
|
|
||||||
|
environment = {
|
||||||
|
SERVER_NAME = "amogus sus";
|
||||||
|
SERVER_PUBLIC = "true";
|
||||||
|
WORLD_NAME = "simpland2";
|
||||||
|
ADMINLIST_IDS = "76561198049818986";
|
||||||
|
TZ = "Europe/Dublin";
|
||||||
|
};
|
||||||
|
environmentFiles = [ config.age.secrets."whale2/valheim.env".path ];
|
||||||
|
|
||||||
|
volumes = [
|
||||||
|
"data:/config"
|
||||||
|
"server:/opt/valheim"
|
||||||
|
];
|
||||||
|
|
||||||
|
extraOptions = [
|
||||||
|
''--network=colony:${dockerNetAssignment allAssignments "valheim-oci"}''
|
||||||
|
"--cap-add=SYS_NICE"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
my = {
|
||||||
|
secrets.files = {
|
||||||
|
"whale2/valheim.env" = {};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@ -2,13 +2,13 @@
|
|||||||
let
|
let
|
||||||
inherit (builtins) attrValues mapAttrs;
|
inherit (builtins) attrValues mapAttrs;
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
substring flatten optional optionals mkIf mkDefault mkForce mkOption mkOptionType;
|
substring flatten optional optionals mkIf mkDefault mkForce mkOption mkOptionType foldAttrs mapAttrsToList;
|
||||||
inherit (lib.my)
|
inherit (lib.my)
|
||||||
naiveIPv4Gateway homeStateVersion mkOpt' mkBoolOpt' mkDefault' commonOpts inlineModule' applyAssertions duplicates;
|
naiveIPv4Gateway homeStateVersion mkOpt' mkBoolOpt' mkDefault' commonOpts inlineModule' applyAssertions duplicates;
|
||||||
|
|
||||||
cfg = config.nixos;
|
cfg = config.nixos;
|
||||||
|
|
||||||
allAssignments = mapAttrs (_: c: c.assignments) cfg.systems;
|
allAssignments = (mapAttrs (_: c: c.assignments) cfg.systems) // (foldAttrs (c: all: all // c) { } (mapAttrsToList (_: c: c.extraAssignments) cfg.systems));
|
||||||
|
|
||||||
mkSystem =
|
mkSystem =
|
||||||
{
|
{
|
||||||
@ -131,6 +131,8 @@ let
|
|||||||
assignments = mkOpt' (attrsOf (submoduleWith {
|
assignments = mkOpt' (attrsOf (submoduleWith {
|
||||||
modules = [ assignmentOpts { _module.args.name = mkForce name; } ];
|
modules = [ assignmentOpts { _module.args.name = mkForce name; } ];
|
||||||
})) { } "Network assignments.";
|
})) { } "Network assignments.";
|
||||||
|
# TODO: Getting the default name for the extra assignment is currently fucked for the same reason as above
|
||||||
|
extraAssignments = mkOpt' (attrsOf (attrsOf (submodule assignmentOpts))) { } "Extra network assignments.";
|
||||||
|
|
||||||
configuration = mkOption {
|
configuration = mkOption {
|
||||||
description = "NixOS configuration module.";
|
description = "NixOS configuration module.";
|
||||||
|
10
secrets/whale2/valheim.env.age
Normal file
10
secrets/whale2/valheim.env.age
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
age-encryption.org/v1
|
||||||
|
-> ssh-ed25519 /EJXvg b3pIwQhBXVof+e+HdCC16M5tc0VuUvvKF+Fj2pytlEE
|
||||||
|
NwnBuKXpj9eP1k7D+U2J7Ms7q5kbB4E2zpH34Sx7MzY
|
||||||
|
-> X25519 w3Wk4YORf+FrC94zpv8TqrwEWDJpuC8IE2YWn6TWRns
|
||||||
|
xWF9B4SfS2Gun3xMJodwU0WRtd1GmC3NpyW0xb/K2Sw
|
||||||
|
-> IuQD#-grease gEpQSQM`
|
||||||
|
fjTI1cPFEs0gIqaF5NDOQcqNmfLDStGXaBUjEYa/JjAV7MCTRjpdUU/5DtkH33av
|
||||||
|
Ji1k8hfgxQ
|
||||||
|
--- UTwjr4FXUeSfijgp5VAZIIGmV/lsfxGwHFUHkC9jHrg
|
||||||
|
•=!‹béó&W\0Op([ÙË[ÏŸÔ]_4¹J8¾ö‹A‡Œi9’‰ì3®@°»<C2B0>~I÷§–‰5
|
Loading…
Reference in New Issue
Block a user