Giter VIP home page Giter VIP logo

nix-minecraft's Introduction

Hello, I am Infinidoge!

Original posts for profile picture artwork, by blushpumpkin: Pixiv, FurAffinity, DeviantArt

Statistics:

infinidoge

 infinidoge

nix-minecraft's People

Contributors

gabriel-doriath-dohler avatar h7x4 avatar hxr404 avatar infinidoge avatar jackwilsdon avatar leo60228 avatar misterio77 avatar silveere avatar silverdev2482 avatar soupglasses avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nix-minecraft's Issues

[Support] Configuration issues

I am not sure if I am doing something wrong here or this is an issue with the flake but I am getting this error
I also have a normal nixpkgs minecraft server running on this pc but I don't think it is causing this issue
Is this user error or a problem with the flake?

[root@Server:/etc/nixos]# ./update.sh 
warning: Git tree '/etc/nixos' is dirty
error:
       … while calling the 'seq' builtin

         at /nix/store/rj6pqzx66pliiwdfk2wjnnlk40rm3mpd-source/lib/modules.nix:320:18:

          319|         options = checked options;
          320|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          321|         _module = checked (config._module);

       … while evaluating a branch condition

         at /nix/store/rj6pqzx66pliiwdfk2wjnnlk40rm3mpd-source/lib/modules.nix:261:9:

          260|       checkUnmatched =
          261|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |         ^
          262|           let

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: infinite recursion encountered

       at /nix/store/rj6pqzx66pliiwdfk2wjnnlk40rm3mpd-source/lib/modules.nix:506:28:

          505|         builtins.addErrorContext (context name)
          506|           (args.${name} or config._module.args.${name})
             |                            ^
          507|       ) (lib.functionArgs f);

Here is the full log, abridged configuration.nix, and flake.nix
log.txt

{ config, pkgs, lib, inputs, ... }:
{
  imports = [ inputs.nix-minecraft.nixosModules.minecraft-servers ];
  nixpkgs.overlays = [ inputs.nix-minecraft.overlay ];
  services.minecraft-servers.survival-mods =
    let
      modpack = pkgs.fetchPackwizModpack {
        url = "https://github.com/Silverdev2482/Survival-mods";
        packHash = "1ml91nibaizymhiak7fwhb74wgn6x3j16fnqfarhh2nar9c62c53";
      };
      mcVersion = modpack.manifest.versions.minecraft;
      fabricVersion = modpack.manifest.versions.fabric;
      serverVersion = lib.replaceStrings [ "." ] [ "_" ] "fabric-${mcVersion}";
    in
    {
      enable = true;
      package = pkgs.fabricServers.${serverVersion}.override { loaderVersion = fabricVersion; };
      symlinks = {
        "mods" = "$modpack}/mods";
      };
    };
}
{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    nix-minecraft.url = "github:Infinidoge/nix-minecraft";
  };

  outputs =
    { self
    , nixpkgs
    , ...
    }@inputs:
    let
      system = "x86_64-linux";
    in
    {
      formatter.${system} = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
      nixosConfigurations = {
        Server = nixpkgs.lib.nixosSystem {
          inherit system;
          specialArgs = inputs;
          modules = [
            ./hardware-configuration.nix
            ./configuration.nix
          ];
        };
      };
    };
}```

Add examples

Add examples of how to create a server and start it

Code from nix-minecraft-servers

Hi there! I've deprecated my flake nix-minecraft-servers as I no longer want to continue maintaining it. I'm wondering if you'd like to take any code from it? I can see you already have most server packages, but there are a few proxies like Velocity and Waterfall that you are welcome to have.

Currently shipping broken fabric server derivations

Current broken fabric servers that i have found are all due to missing vanilla variants.

  • All combat versions.
  • All experimental-snapshot versions.
  • All deep-dark-expermimental-snapshot versions.

I would say we should look into seeing if whitelisting known minecraft versions for fabric in the update.py file. For example, i can currently find the pre, rc, oneblockatatime, Pre-Release, infinite in vanillaServers from a quick look over.

Forge support

Hello, is there any plan to support the Forge loader?
Link: https://files.minecraftforge.net/net/minecraftforge/forge/

I am currently trying to fetch the libraries for the Forge loader to potentially add it to this repo. I have this simple script based on the fabric/update.py one.

Source of update.py
#!/usr/bin/env nix-shell
#!nix-shell -i python3.10 -p python310Packages.requests

import json
import subprocess
import requests
from pathlib import Path


def versiontuple(v):
    return tuple(map(int, (v.partition("+")[0].split("."))))


ENDPOINT = "https://raw.githubusercontent.com/PrismLauncher/meta-upstream/master/forge"


def get_versions():
    print("Fetching all versions")
    data = requests.get(f"{ENDPOINT}/promotions_slim.json").json()
    versions = []
    for key, loader_version in data["promos"].items():
        mc = key.split("-")[0]
        versions.append((mc, loader_version))
    return versions


def fetch_version(game_version, loader_version):
    """
    Return the server json for a given game and loader version
    """

    print(f"Fetch {ENDPOINT}/version_manifests/{game_version}-{loader_version}.json")
    return requests.get(
        f"{ENDPOINT}/version_manifests/{game_version}-{loader_version}.json"
    ).json()


def gen_locks(version, libraries):
    """
    Return the lock information for a given server json, returned in the format
    {
        "mainClass": string,
        "libraries": [
            {"name": string, "url": string, "sha256": string},
            ...
        ]
    }
    """
    print(version)
    ret = {"mainClass": version["mainClass"], "libraries": []}

    for library in version["libraries"]:
        name, url = library["name"], library["downloads"]["artifact"]["url"]

        if not name in libraries or any(not v for k, v in libraries[name].items()):
            print(f"- - - Fetching library {name}")
            ldir, lname, lversion = name.split(":")
            lfilename = f"{lname}-{lversion}.zip"
            # lurl = f"{url}{ldir.replace('.', '/')}/{lname}/{lversion}/{lname}-{lversion}.jar"
            if url == "":
                url = f"https://maven.minecraftforge.net/{ldir.replace('.','/')}/{lname}/{lversion}/{lname}-{lversion}.jar"

            lhash = subprocess.run(
                ["nix-prefetch-url", url], capture_output=True, encoding="UTF-8"
            ).stdout.rstrip("\n")

            libraries[name] = {"name": lfilename, "url": url, "sha256": lhash}
        else:
            pass
            # print(f"- - - Using cached library {name}")

        ret["libraries"].append(name)

    return ret


def main(versions, libraries, locks, lib_locks):
    """
    Fetch the relevant information and update the lockfiles.
    `versions` and `libraries` are data from the existing files, while
    `locks` and `lib_locks` are file objects to be written to
    """
    all_versions = get_versions()

    print("Starting fetch")
    try:
        for (game_version, loader_version) in all_versions:
            print(f"- Loader: {loader_version}")
            print(f"- - Game: {game_version}")
            if not versions.get(loader_version, None):
                versions[loader_version] = {}

            if not versions[loader_version].get(game_version, None):
                data = {}
                try:
                    data = fetch_version(game_version, loader_version)
                except json.JSONDecodeError:
                    versions.pop(loader_version, None)
                    continue
                versions[loader_version][game_version] = gen_locks(data, libraries)
            else:
                print(f"- - Game: {game_version}: Already locked")

    except KeyboardInterrupt:
        print("Cancelled fetching, writing and exiting")

    json.dump(versions, locks, indent=2)
    json.dump(libraries, lib_locks, indent=2)
    locks.write("\n")
    lib_locks.write("\n")


if __name__ == "__main__":
    folder = Path(__file__).parent
    lo = folder / "locks.json"
    li = folder / "libraries.json"
    lo.touch()
    li.touch()

    with (
        open(lo, "r") as locks,
        open(li, "r") as lib_locks,
    ):
        versions = {} if lo.stat().st_size == 0 else json.load(locks)
        libraries = {} if li.stat().st_size == 0 else json.load(lib_locks)

    with (
        open(lo, "w") as locks,
        open(li, "w") as lib_locks,
    ):
        main(versions, libraries, locks, lib_locks)

What I got with running it, after tweaking the loader.nix to change Main-Class, is this:

Error: Could not find or load main class net.minecraftforge.server.ServerMain
Caused by: java.lang.ClassNotFoundException: net.minecraftforge.server.ServerMain

Looking furthermore, it looks like forge doesn't expose the "base" library containing the boot code for the server.

I can try continuing, but I am no Java/Minecraft expert, so I will gladly take any help or a working solution!

Only one tmux socket is accessible at a time

When running 2+ servers, only the most recently started server will have its associated tmux socket file work - the other will just say that there are no sessions:

$ doas systemctl restart minecraft-server-dark-firepit

$ doas tmux -S /run/minecraft/gbj.sock attach
no sessions

$ doas systemctl restart minecraft-server-gbj

$ doas tmux -S /run/minecraft/gbj.sock attach
<works perfectly fine>

Move away from using digga

While digga is a nice all-whistles-included library, its absolutely huge. It is designed for managing your own NixOS dotfiles ant not so much for creating importable flake modules. So when you are creating a flake that is designed to be imported, you are indirectly putting this huge library on everyone who will import your library.

The non-digga solution would be to use nix flake's native outputs section to create a nixosModules and packages parts. If i get some time i may try to PR in this change myself.

This change would remove a whole 16 inputs
• Added input 'nix-minecraft':
    'github:Infinidoge/nix-minecraft/67d394fba0b7d4e04f12389bcff99abd51fa2b00' (2022-07-12)
• Added input 'nix-minecraft/digga':
    'github:divnix/digga/e2bb8ea28c5bbc7bb46ac91df3ac846ce9a3964c' (2022-04-06)
• Added input 'nix-minecraft/digga/blank':
    'github:divnix/blank/5a5d2684073d9f563072ed07c871d577a6c614a8' (2021-07-06)
• Added input 'nix-minecraft/digga/deploy':
    'github:serokell/deploy-rs/9a02de4373e0ec272d08a417b269a28ac8b961b4' (2021-09-28)
• Added input 'nix-minecraft/digga/deploy/flake-compat':
    'github:edolstra/flake-compat/12c64ca55c1014cdc1b16ed5a804aa8576601ff2' (2021-08-02)
• Added input 'nix-minecraft/digga/deploy/nixpkgs':
    follows 'nix-minecraft/digga/latest'
• Added input 'nix-minecraft/digga/deploy/utils':
    'github:numtide/flake-utils/74f7e4319258e287b0f9cb95426c9853b282730b' (2021-11-28)
• Added input 'nix-minecraft/digga/devshell':
    'github:numtide/devshell/0e56ef21ba1a717169953122c7415fa6a8cd2618' (2021-11-22)
• Added input 'nix-minecraft/digga/flake-compat':
    'github:edolstra/flake-compat/b7547d3eed6f32d06102ead8991ec52ab0a4f1a7' (2022-01-03)
• Added input 'nix-minecraft/digga/flake-utils-plus':
    'github:gytis-ivaskevicius/flake-utils-plus/be1be083af014720c14f3b574f57b6173b4915d0' (2021-12-13)
• Added input 'nix-minecraft/digga/flake-utils-plus/flake-utils':
    'github:numtide/flake-utils/74f7e4319258e287b0f9cb95426c9853b282730b' (2021-11-28)
• Added input 'nix-minecraft/digga/home-manager':
    'github:nix-community/home-manager/4daff26495ca9ac67476cba8cf15c3e36d91ab18' (2021-11-26)
• Added input 'nix-minecraft/digga/home-manager/nixpkgs':
    follows 'nix-minecraft/digga/nixlib'
• Added input 'nix-minecraft/digga/latest':
    'github:nixos/nixpkgs/8a308775674e178495767df90c419425474582a1' (2021-11-29)
• Added input 'nix-minecraft/digga/nixlib':
    follows 'nix-minecraft/nixpkgs'
• Added input 'nix-minecraft/digga/nixpkgs':
    follows 'nix-minecraft/nixpkgs'
• Added input 'nix-minecraft/nixpkgs':
    follows 'nixpkgs'
• Added input 'nix-minecraft/packwiz':
    'github:packwiz/packwiz/0d8c1762a373f9da9b14cb4b8156082bbbe14de8' (2022-06-20)

Fabric 1.20.4 not working

Hey, I tried running a 1.20.4 fabric server and it doesn't seem to be working. I am getting this error:

Failed at step CHDIR spawning /nix/store/fxpm0mf2fj696b6b2p3i5qmlrx9gl27v-unit-script-minecraft-server-datapacktests-post-stop/bin/minecraft-server-datapacktests-post-stop

It seems this file is owned by root:root, which is why it says it doesn't exist.

Is anyone able to run a 1.20.4 fabric server? or is the issue only for me?

nix flake show report error

$ nix flake show github:Infinidoge/nix-minecraft
github:Infinidoge/nix-minecraft/359e2a68e288fb467b38c0318236093411ee47f4
├───legacyPackages
│   ├───aarch64-darwin omitted (use '--legacy' to show)
│   ├───aarch64-linux omitted (use '--legacy' to show)
│   ├───i686-linux omitted (use '--legacy' to show)
│   ├───x86_64-darwin omitted (use '--legacy' to show)
│   └───x86_64-linux omitted (use '--legacy' to show)
├───lib: unknown
├───nixosModules
│   └───minecraft-servers: NixOS module
├───overlay: Nixpkgs overlay
└───packages
├───aarch64-darwin
trace: warning: `VelocityServers` from the `packages` flake output is deprecated. Please use the `legacyPackages` flake output instead.
error: attribute 'VelocityServers' missing

at /nix/store/a8axbx9xgz21cglwjwdx5jcmsf8i5dgp-source/flake.nix:68:12:

67|           )
68|           {
|            ^
69|             inherit (legacyPackages)
Did you mean velocityServers?

Feature Request: BTA (Betterthanadventure) & BTW (Betterthanwolves) Support

What are these?

BTA and BTW are both total conversion mods with the intention of going into a different direction than vanilla minecraft with many changes and different mechanics.

Actual Request:

I and my others would love the addition of BTA and BTW in the nix-minecraft project. Sadly, I don’t know much about nix packaging; therefore, this will be only a git issue.

Cannot launch server in safe mode

Since the server is currently launched through a script, which passes all of the arguments to Java instead of Minecraft, it is currently impossible to launch the game in safe mode.

Feature Request: Using the module without Tmux

Hi. First things first, thanks for your (and all the contributors') amazing work on this! I spent far too much time packaging various servers & proxies myself, and this project is going to make my life much easier. ❤️

I'd also love to migrate my ad-hoc solution to the provided module, but I don't really like the fact that it runs the server in a tmux session. I love Tmux as a terminal multiplexer, but using it for services has some really annoying problems that I don't think can be solved in any elegant way:

  • Logs don't end up in the system journal—this is probably the biggest one. This means that when something goes wrong and the service crashes, I am left without any information whatsoever unless it ends up in the server logs (which, e.g., startup script failures won't.). It also means I can't process the logs automatically via Loki, fail2ban, and other such tools.
  • The server can't be nicely automated from the outside. I really don't want to blindly pipe random keys into tmux and pray that they end up in the command prompt, not mixed with some other rubbish.
  • Connecting to the socket remotely is unnecessarily complicated.
  • Although not strictly forced by using tmux, I dislike having to run all servers under the same user. Ideally, I'd use systemd's DynamicUser for every server. Supporting this with Tmux would be fairly complicated.

A solution that I use currently, which has none of these problems, is to just run the server process directly, controlling it via RCON. It's not perfect, particularly because none of the RCON clients I could find are very nice, but I find it to be a much cleaner approach.

I'd love to add support for this workflow to the provided module, but I'm not sure whether such a PR would be accepted. If so, how do you think it should work? A global toggle? A per-server one? Something else? I'm open to all suggestions.

Thanks in advance!

EDIT: I just noticed #52, which addresses most of these issues. I guess I'll use the fork from there for now, and add support for multiple users after it lands.

Feature Request: Allow adding to server PATH

I ran across a mod called Fastback which I want to use to make backups on my server. According to the developer it finds git in the $PATH, but I assume, probably because nixos trying to keep things pure it prevents certian applications from accessing the path, but I could be wrong. It uses git and native git is faster that the java implementation of it. in certain operations git is 35 times faster. Because of this I believe there should be a way for mods to use native programs. I also wonder if there should be a way for mods to use native libraries or can take advantage of them, I do not know if any mods do this however nor do I have examples. I have a few 3 ideas for solutions but I'm not sure if they would work.

  1. Simply have an option where mods can access the path. I assume this isn't pure and this seems like a hack but it would work.
  2. Have an option to install packages that would be accessible to the mods but other programs wouldn't be accessible to the mods. Seems like a good option but It doesn't solve libraries
  3. Have a method of packaging mods for nix. This doesn't seem like a good option for various reasons but if a few mods that require native libraries exist they could be packaged like this

Personally I would say do 1 or 2 and if mods that do require native libraries exist do 3, although that requires a lot of work.

Datapack Management not possible with Current Symlink Implementation

Problem: The folder for datapacks resides in /world/datapacks. Since the links created by with servers.<name>.symlinks results is defined to be the name of a variation and it is impossible to include special characters in the name of a derivation. My first immediate workaround trying create a symlink in the entire /worlds folder being a read only symbolic link to the nix store, thus making it impossible for the server to generate the world.

Fix: It would be nice to have a system for directly managing datapacks, or a modification to the current method of defining symlinks to get this to work. :)

Add a LICENCE file

Currently this repo is under an "All rights reserved" status where the distribution and use of this repo is disallowed due to copyright. Until this is addressed, technically nobody by law can use this code without your explicit written permission to do so.

I would recommend licensing this project under MIT or ISC, as this is what nixpkgs themselves uses.

Indescriptive error on port overlap assertion

There is an assertion set to prevent two servers from using the same port. However, a message is not set, producing a confusing error when the assertion is triggered:

error: attribute 'message' missing

       at /nix/store/369wr4laqdqzh5brq1g7nfc1pbfh23sn-source/nixos/modules/system/activation/top-level.nix:122:30:

          121|
          122|   failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions);
             |                              ^
          123|
(use '--show-trace' to show detailed location information)

Tmux socket not accessible by members of the Minecraft group

After a relatively recent tmux update, it is no longer sufficient for the tmux socket to have rw permissions granted to the Minecraft group for access.

It seems like this will necessitate figuring out how to generate the relevant server-access command.

This seems to require searching through and finding all of the users of the group, checking if they're a member of the minecraft group, and including them?

Relevant tmux issue: tmux/tmux#3220

I suppose the module could instead be written to take in a list of users to be given the respective access permissions, but that feels weird.

Upstream to nixpkgs

What do you think about upstreaming this work to nixpkgs?
It would make it easier to discover this work, which isn't very visible currently.

Packwiz support

Packwiz support would be greatly appreciated, as manually fetching every mod through fetchModrinth isn't the best - I'd really like being able to point it at a pack.toml URL and have it download the bootstrapper, run it, etc. all on its own.

Is this solely a packages repository?

Or are there plans to include an abstract (moddable) minecraft module where one can configure server properties, mods, datapacks and the likes?

As of now, the scope seems to only include the derivations themselves and nothing else.

Quilt issue: quilt_loader missing

There seem to be an issue with the Quilt loader. Here is my config: https://github.com/sweenu/nixfiles/blob/d6fba43e8177dd67d9ba7ddb769fa934d8ebb4a2/hosts/najdorf/minecraft/default.nix
And here is the crash report: crash-2024-03-20_24.14.02.7060-quilt_loader.txt

I thought at first that it might be the modpack even though I have no problem using it client side. But then I tried removing all mods and keeping only the Quilt API mod and the error persisted. So I'm thinking that it might be an issue with the package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.