From 6922232ec5adfe517b74f8124fb407b0a01ccb9b Mon Sep 17 00:00:00 2001 From: Ranomier <> Date: Fri, 9 May 2025 19:38:05 +0200 Subject: [PATCH] feat: add luanti server --- hosts/game-luanti/boot.nix | 11 +++++++++++ hosts/game-luanti/default.nix | 9 +++++++-- modules/game/server/luanti/default.nix | 19 +++++++++++++++++-- modules/sec_auth/ssh-server.nix | 2 +- system_profiles/mini.nix | 2 +- system_profiles/server.nix | 18 ++++++++++++++++++ 6 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 hosts/game-luanti/boot.nix create mode 100644 system_profiles/server.nix diff --git a/hosts/game-luanti/boot.nix b/hosts/game-luanti/boot.nix new file mode 100644 index 0000000..82bde96 --- /dev/null +++ b/hosts/game-luanti/boot.nix @@ -0,0 +1,11 @@ +{ + # Use the GRUB 2 boot loader. + boot.loader.grub = { + enable = true; + # efiSupport = true; + # efiInstallAsRemovable = true; + # Define on which hard drive you want to install Grub. + device = "/dev/vda"; # or "nodev" for efi only + }; + # boot.loader.efi.efiSysMountPoint = "/boot/efi"; +} diff --git a/hosts/game-luanti/default.nix b/hosts/game-luanti/default.nix index 6876f9d..e00303b 100644 --- a/hosts/game-luanti/default.nix +++ b/hosts/game-luanti/default.nix @@ -1,16 +1,21 @@ { imports = [ + ./boot.nix ./hardware-configuration.nix ../../system_profiles/defaults.nix - ../../system_profiles/mini-container.nix + ../../system_profiles/mini.nix + ../../system_profiles/server.nix + + ../../modules/game/server/luanti + ../../modules/sec_auth/ssh-server.nix ]; users = let username = "root"; in { users."${username}".openssh.authorizedKeys.keyFiles = [ - /etc/nixos/ssh/authorized_keys.d/${username} + ../../certificates/id_ed25519_game-luanti.pub ]; }; } diff --git a/modules/game/server/luanti/default.nix b/modules/game/server/luanti/default.nix index 06628ea..c8025fe 100644 --- a/modules/game/server/luanti/default.nix +++ b/modules/game/server/luanti/default.nix @@ -1,5 +1,20 @@ -{...}: { - services.minetest = { +{pkgs, ...}: let + port = 10523; +in { + services.minetest-server = { enable = true; + + gameId = "asuna"; + port = port; }; + + # open port since luanti does not do it by itself + networking.firewall = { + allowedUDPPorts = [port]; + }; + + # install luanti seperatly so it is available through the command line + environment.systemPackages = with pkgs; [ + luanti + ]; } diff --git a/modules/sec_auth/ssh-server.nix b/modules/sec_auth/ssh-server.nix index b3b5c8b..5d575a8 100644 --- a/modules/sec_auth/ssh-server.nix +++ b/modules/sec_auth/ssh-server.nix @@ -2,7 +2,7 @@ services.openssh = { enable = true; - ports = lib.mkDefault [38742]; + ports = lib.mkDefault [10522]; settings = { PasswordAuthentication = false; diff --git a/system_profiles/mini.nix b/system_profiles/mini.nix index 1df7357..e50e14a 100644 --- a/system_profiles/mini.nix +++ b/system_profiles/mini.nix @@ -5,7 +5,7 @@ }: { imports = [ (modulesPath + "/profiles/minimal.nix") - (modulesPath + "/profiles/perlless.nix") + #(modulesPath + "/profiles/perlless.nix") { environment.defaultPackages = lib.mkDefault []; diff --git a/system_profiles/server.nix b/system_profiles/server.nix new file mode 100644 index 0000000..f39d030 --- /dev/null +++ b/system_profiles/server.nix @@ -0,0 +1,18 @@ +{ + imports = let + packages = {pkgs, ...}: { + environment.systemPackages = with pkgs; [ + tmux + wget + ]; + }; + in [ + ./defaults.nix + ./mini.nix + + ../modules/customisation.nix + ../modules/software/neovim.nix + + packages + ]; +}