From f19eca3df68b9ded6bb7c24bbba487d3a36a08d4 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 24 Feb 2025 19:45:52 +0100 Subject: [PATCH] feat: adding the minecraft server configuration --- flake.nix | 6 +++++- hosts/fix/configuration.nix | 17 ++++++++++++++++- hosts/global.nix | 2 +- modules/games/global.nix | 21 ++++++++++++++++++++ modules/games/lutris.nix | 15 +++++++++++++++ services/games.nix | 21 ++++++++++++++++++++ services/games/minecraft.nix | 37 ++++++++++++++++++++++++++++++++++++ 7 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 modules/games/global.nix create mode 100644 modules/games/lutris.nix create mode 100644 services/games.nix create mode 100644 services/games/minecraft.nix diff --git a/flake.nix b/flake.nix index a29ca36..f75b9a5 100644 --- a/flake.nix +++ b/flake.nix @@ -7,10 +7,11 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + minecraft.url = "github:Infinidoge/nix-minecraft"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = { self, nixpkgs, flake-utils, home-manager,... }@inputs: + outputs = { self, nixpkgs, flake-utils, ... }@inputs: let pkgs = import nixpkgs { config.allowUnfree = true; @@ -21,6 +22,9 @@ modules = [ ./hosts/fix/configuration.nix ]; + specialArgs = { + inherit inputs; + }; }; nixosConfigurations."nixos-asahi" = nixpkgs.lib.nixosSystem { system = "aarch64-linux"; diff --git a/hosts/fix/configuration.nix b/hosts/fix/configuration.nix index 6c12368..6ed1bad 100644 --- a/hosts/fix/configuration.nix +++ b/hosts/fix/configuration.nix @@ -1,13 +1,21 @@ -{ config, pkgs, lib, ... }: +{ inputs, config, pkgs, lib, ... }: { imports = [ ../global.nix ./hardware-configuration.nix + ../../modules/games/global.nix ../../services/discord.nix + ../../services/games.nix ]; + games = { + lutris = true; + }; service = { + minecraft = { + enium-pv = true; + }; bot_discord = { master = true; music = true; @@ -24,6 +32,13 @@ efi.canTouchEfiVariables = true; }; + environment.systemPackages = with pkgs; [ + wine-staging + lutris + dxvk + vkd3d + ]; + networking = { hostName = "nixos-fix"; firewall.enable = false; diff --git a/hosts/global.nix b/hosts/global.nix index 1095cea..1fb1fe9 100644 --- a/hosts/global.nix +++ b/hosts/global.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: { documentation = { diff --git a/modules/games/global.nix b/modules/games/global.nix new file mode 100644 index 0000000..719ac92 --- /dev/null +++ b/modules/games/global.nix @@ -0,0 +1,21 @@ +{ config, pkgs, lib, ... }: + +let + lutris = import ./lutris.nix { + inherit config pkgs lib; + }; + cfg = config.games; +in +{ + imports = [ + lutris + ]; + + options.games = { + lutris = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable lutris"; + }; + }; +} diff --git a/modules/games/lutris.nix b/modules/games/lutris.nix new file mode 100644 index 0000000..76ec516 --- /dev/null +++ b/modules/games/lutris.nix @@ -0,0 +1,15 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.games.lutris; +in +{ + config = lib.mkIf cfg { + environment.systemPackages = with pkgs; [ + wine-staging + lutris + dxvk + vkd3d + ]; + }; +} diff --git a/services/games.nix b/services/games.nix new file mode 100644 index 0000000..0fc6769 --- /dev/null +++ b/services/games.nix @@ -0,0 +1,21 @@ +{ inputs, config, pkgs, lib, ... }: + +let + enium-pv = import ./games/minecraft.nix { + inherit inputs config pkgs lib; + }; + cfg = config.service.minecraft; +in +{ + imports = [ + enium-pv + ]; + + options.service.minecraft = { + enium-pv = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable enium private minecraft server"; + }; + }; +} diff --git a/services/games/minecraft.nix b/services/games/minecraft.nix new file mode 100644 index 0000000..d1f1619 --- /dev/null +++ b/services/games/minecraft.nix @@ -0,0 +1,37 @@ +{ inputs, config, pkgs, lib, ... }: + +let + cfg = config.service.minecraft.enium-pv; +in +{ + imports = [ + inputs.minecraft.nixosModules.minecraft-servers + ]; + + + config = lib.mkIf cfg { + nixpkgs.overlays = [ + inputs.minecraft.overlay + ]; + services.minecraft-servers = { + enable = true; + eula = true; + + servers.enium-pv = { + enable = true; + package = pkgs.fabricServers.fabric-1_20_1; + jvmOpts = "-Xms4092M -Xmx4092M"; + serverProperties = { + difficulty = 3; + gamemode = 0; + max-players = 42; + motd = "§l §3 Enium Survival§r\n§l §b Whitelisted Server"; + server-port = 64421; + spawn-protection=16; + white-list = true; + }; + restart = "no"; + }; + }; + }; +}