Mineflake
Mineflake is a tool for creating and managing Minecraft servers declaratively. It is written in Rust and uses Nix for package management.
Source code: https://github.com/nix-community/mineflake
Quick start
Installation
Mineflake can be used with Nix or without it. To use Mineflake without Nix, you need to install Rust and Cargo. To do so, run:
If you want to use Mineflake with Nix, you need to install Nix. To do so, run:
bash <(curl -L https://nixos.org/nix/install) # (1)
nix run github:nix-community/mineflake --help # (2)
-
This command installs Nix. If you want to install it manually, you can find more information on Nix website.
-
This doesn't install Mineflake to your system, it just runs it. So if you want to execute
mineflake apply
command, you need to runnix run github:nix-community/mineflake apply
instead.
Faster builds (optional)
You can install Cachix to your system to significantly speed up builds:
And activate cache for Mineflake:
Note about usage with Nix
Mineflake uses flake feature of Nix (hence the name), so you need to enable flakes support. Wiki page about Flakes has more information about it.
Go to latest release page and download
the executable. Its name should be mineflake-linux-X.Y.A
where X.Y.A
- version. So, the script would be:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # (1)
cargo install mineflake # (2)
mineflake --help
-
This command installs Rust and Cargo. If you want to install it manually, you can find more information on Rust website.
-
This command installs Mineflake CLI to your system. It's usually located in
~/.cargo/bin
directory.
Which method I should use?
If you are familiar with Nix, you should use Nix. If you are not, you should use Cargo.
With Nix you get more control and simplier package management. Both methods have same package set and same features.
Windows support
Mineflake doesn't support Windows officially, but it can be used on Windows with some workarounds.
There 2 ways to use Mineflake on Windows:
- Use WSL2. It's the easiest way to use Mineflake on Windows, as it's the same as using it on Linux. WSL also has Nix support, so you can use Nix to install Mineflake.
- Install Rust and Cargo manually. You can find more information on Rust website.
Note about configuration diffrences between Nix and non-Nix versions
All examples in this documentation are written for non-Nix version of Mineflake, but they are also valid for Nix version, with some exceptions:
- All packages are Nix derivations.
- You can't use files that are not in your Nix store/flake directory. For example, if you want to use
server.properties
file, you need to add it to your flake directory and use./server.properties
path, instead of/path/to/server.properties
. - You can use functions and variables. For example, you can use
builtins.readFile
function to read file contents, ormineflake.mkMfConfig
to easily add config entry.
Example of config for non-Nix version:
Example of same config for Nix version:
-
Package is a derivation, so you need to use
mineflake.packagename
instead of{ type: local, path: /path/to/packagename }
. -
You can't use remote/repository packages. But for default repo all packages have derivations, so you can use them.
-
You can use functions.
mkMfConfig
is a function that creates config entry. It's easier and more readable than writing it manually.
Run a simple paper server
To run a simple paper server, you need to create a file named mineflake.yml
with the following content:
Mineflake can read json configurations too, but it's harder to write and read them.
And then run mineflake apply
command. It will download paper, luckperms and create a server.properties file with the specified content.
After that you can run mineflake run
to start the server.
You can find more information about mineflake.yml
file in Configuration section.