summaryrefslogtreecommitdiff
path: root/nixos/modules/homelab/games/minecraft.nix
blob: 44c09fba764b4f7e31f0a61452abd45537fe8c18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{ config, lib, pkgs, inputs, ... }: let
  cfg = config.homelab.games.minecraft;
in {
  imports = [ inputs.nix-minecraft.nixosModules.minecraft-servers ];

  options.homelab.games.minecraft.enable = lib.mkEnableOption "minecraft servers";

  config = lib.mkIf cfg.enable {
    nixpkgs.overlays = [ inputs.nix-minecraft.overlay ];
    environment.systemPackages = [ pkgs.packwiz ];
    
    networking.firewall.allowedUDPPorts = [ /*svc*/ 24454 ];

    environment.shellAliases = {
      "serverconsole" = "${pkgs.tmux} -S /run/minecraft/outremonde.sock";
    };

    services.minecraft-servers = {
      
      enable = true;
      eula = true;
      openFirewall = true;
  
      servers = {
      
        vanilla-1_21_1 = {
          enable = false;
          package = pkgs.vanillaServers.vanilla-1_21_1;
          serverProperties = {
            server-port = 25566;
          };
        };

        fantasy = let
          modpack = pkgs.fetchPackwizModpack {
            url = "https://git.culsans.site/fantasy-minecraft-modpack.git/plain/pack.toml";
            packHash = "sha256-BP1pnXNOkw7jdK6fl2fAVybfO2bD2AyWeLRjrTTsYeI=";
          };
        in {
          enable = true;
          package = pkgs.fabricServers.fabric-1_20_1;
          symlinks = {
            "mods" = "${modpack}/mods";
            "config/additional-additions-config.json" = "${modpack}/config/additional-additions-config.json";
            "config/configurabledespawntimer.json5" = "${modpack}/config/configurabledespawntimer.json5";
            "config/fwaystones/config.json5" = "${modpack}/config/fwaystones/config.json5";
            "config/simplebackup.json5" = "${modpack}/config/simplebackup.json5";
          };
          jvmOpts = "-Xms6144M -Xmx6144M";
          serverProperties = {
            level-seed = "-5424614792051443123";
            allow-flight = true;
            spawn-protection = 0;
            max-players = 10;
            server-port = 25565;
            difficulty = "normal";
            motd = ''\u00a7f-------\u00a7d Fantasy\u00a7f ----------\u00a7r\n\u00a7f--\u00a7c Survival\u00a7f ---\u00a7b Multiplayer\u00a7f --'';
          };
        };
      };
    };
  };
}