From 8d7af1285b3b69171d9cda413f8d5e90f936494c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20R=C3=B6ger?= Date: Fri, 27 Mar 2026 00:46:09 +0100 Subject: [PATCH] System Gen143 @ 2026-03-19-20:01:56 by jonas@monolith --- flake.lock | 56 ++++++++++++++++++- flake.nix | 17 +++++- modules/default.nix | 1 + modules/services/minecraft-server/default.nix | 39 +++++++++++++ .../minecraft-server/loadCurseForge.nix | 36 ++++++++++++ 5 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 modules/services/minecraft-server/default.nix create mode 100644 modules/services/minecraft-server/loadCurseForge.nix diff --git a/flake.lock b/flake.lock index b5d162c..7b2a0a5 100644 --- a/flake.lock +++ b/flake.lock @@ -158,6 +158,22 @@ } }, "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { "flake": false, "locked": { "lastModified": 1746162366, @@ -635,12 +651,34 @@ "type": "github" } }, - "nixos-cosmic": { + "nix-minecraft": { "inputs": { "flake-compat": "flake-compat_2", "nixpkgs": [ "nixpkgs" ], + "systems": "systems_2" + }, + "locked": { + "lastModified": 1774407052, + "narHash": "sha256-rUkn7Bo3PAlpcZl8+0FDsTwFyDwvS4xwMT9+RJ+XJoE=", + "owner": "Infinidoge", + "repo": "nix-minecraft", + "rev": "70daf1f48885f0b4a70797076cd2ff5d9139b46e", + "type": "github" + }, + "original": { + "owner": "Infinidoge", + "repo": "nix-minecraft", + "type": "github" + } + }, + "nixos-cosmic": { + "inputs": { + "flake-compat": "flake-compat_3", + "nixpkgs": [ + "nixpkgs" + ], "nixpkgs-stable": "nixpkgs-stable", "rust-overlay": "rust-overlay_2" }, @@ -777,6 +815,7 @@ "home-manager": "home-manager", "hyprland": "hyprland", "hyprland-plugins": "hyprland-plugins", + "nix-minecraft": "nix-minecraft", "nixos-cosmic": "nixos-cosmic", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", @@ -880,6 +919,21 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "xdph": { "inputs": { "hyprland-protocols": [ diff --git a/flake.nix b/flake.nix index 768cb34..4865558 100644 --- a/flake.nix +++ b/flake.nix @@ -44,13 +44,14 @@ url = "github:polygon/audio.nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + nix-minecraft.url = "github:Infinidoge/nix-minecraft"; + nix-minecraft.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nixpkgs, nixpkgs-unstable, - disko, nixos-hardware, home-manager, nixos-cosmic, @@ -77,6 +78,8 @@ ({...}: {nixpkgs.config.allowUnfree = true;}) nixos-hardware.nixosModules.msi-b550-a-pro inputs.sops-nix.nixosModules.sops + inputs.nix-minecraft.overlay + inputs.nix-minecraft.nixosModules.minecraft-servers ./modules ./hosts/comfy-station/configuration.nix ]; @@ -93,6 +96,7 @@ overlay-unstable self.overlays.default audio.overlays.default + inputs.nix-minecraft.overlay ]; }) ({...}: { @@ -108,6 +112,7 @@ nixos-hardware.nixosModules.lenovo-thinkpad-t14-amd-gen1 inputs.sops-nix.nixosModules.sops nixos-cosmic.nixosModules.default + inputs.nix-minecraft.nixosModules.minecraft-servers ./fixes/plasma-fix.nix ./modules ./hosts/monolith/configuration.nix @@ -120,10 +125,18 @@ isHM = false; }; modules = [ - ({...}: {nixpkgs.overlays = [overlay-unstable self.overlays.default audio.overlays.default];}) + ({...}: { + nixpkgs.overlays = [ + overlay-unstable + self.overlays.default + audio.overlays.default + inputs.nix-minecraft.overlay + ]; + }) ({...}: {nixpkgs.config.allowUnfree = true;}) inputs.sops-nix.nixosModules.sops inputs.disko.nixosModules.disko + inputs.nix-minecraft.nixosModules.minecraft-servers ./modules ./hosts/harbor/configuration.nix ]; diff --git a/modules/default.nix b/modules/default.nix index 0e787dd..f1453c7 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -31,6 +31,7 @@ ./services/gitea-instance.nix ./services/gotify-instance.nix ./services/kdeconnect.nix + ./services/minecraft-server ./services/nextcloud-instance.nix ./services/virt-manager.nix ] diff --git a/modules/services/minecraft-server/default.nix b/modules/services/minecraft-server/default.nix new file mode 100644 index 0000000..6bcf04c --- /dev/null +++ b/modules/services/minecraft-server/default.nix @@ -0,0 +1,39 @@ +{ + config, + pkgs, + lib, + ... +}: let + cfg = config.hive.services.minecraft-server; + + modpack = pkgs.callPackage ./loadCurseForge.nix { + url = "https://mediafilez.forgecdn.net/files/7765/203/BMC3_Server_Pack_v44.zip"; + hash = ""; + }; + + mcVersion = modpack.variables.MINECRAFT_VERSION; + loader = lib.toLower modpack.variables.MODLOADER; + loaderVersion = modpack.variables.MODLOADER_VERSION; + serverVersion = lib.replaceStrings ["."] ["_"] "${loader}-${mcVersion}"; +in { + options.hive.services.minecraft-server = { + enable = lib.mkEnableOption "Enable BMC3 server"; + }; + + config = lib.mkIf cfg.enable { + services.minecraft-servers.servers.bmc3 = + { + enable = true; + eula = true; + } + # Prevent download of modpack if not enabled + // (lib.optionalAttrs cfg.enable { + package = pkgs."${loader}Servers".${serverVersion}.override {inherit loaderVersion;}; + jvmOpts = modpack.variables.JAVA_ARGS; + symlinks = { + "mods" = modpack.mods; + "config" = modpack.config; + }; + }); + }; +} diff --git a/modules/services/minecraft-server/loadCurseForge.nix b/modules/services/minecraft-server/loadCurseForge.nix new file mode 100644 index 0000000..32ba046 --- /dev/null +++ b/modules/services/minecraft-server/loadCurseForge.nix @@ -0,0 +1,36 @@ +{ + url ? null, + hash ? null, + pkgs, + lib, + ... +}: let + modpack = pkgs.fetchzip { + inherit url hash; + stripRoot = false; + }; + + variablesStr = builtins.readFile "${modpack}/variables.txt"; + variableLines = + builtins.filter (l: l != "" && (lib.strings.elemAt (lib.stringToCharacters l) 0) != "#") + (lib.strings.splitString "\n" variablesStr); + + stripQuotes = s: + if builtins.match "^\".*\"$" s != null + then builtins.substring 1 (builtins.stringLength s - 2) s + else s; + + parseLine = line: let + parts = lib.strings.splitString "=" line; + in { + name = builtins.elemAt parts 0; + value = stripQuotes (builtins.concatStringsSep "=" (builtins.tail parts)); + }; + + variables = builtins.listToAttrs (map parseLine variableLines); +in { + inherit variables; + root = modpack; + mods = "${modpack}/mods"; + config = "${modpack}/config"; +}