With flux you can build servers as packages with a simple interface and deploy them with the included module.
I set up servers for my friends all of the time, and I became frustrated at the amount of work it took change a vanilla minecraft server to a modded one. So I integrated mcman to make this easy, then I decided to make servers for steam and other random projects.
Installation is simple:
inputs.flux.url = "github:IogaMaster/flux";
nixpkgs.overlays = [ flux.overlays.default ];
flux.nixosModules.default
in your host config.
nixosConfigurations.host1 = lib.nixosSystem {
system = "x86_64-linux";
modules = [
./host1/configuration.nix
flux.nixosModules.default
];
};
flux = {
enable = true;
servers = {
vanilla-minecraft = {
package = pkgs.mkMinecraftServer {
name = "myminecraftserver";
src = ./mcmanconfig; # Path to a mcman config
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
proxy.enable = true;
};
};
};
You can create packages that run the server instead of using them in the module:
Example minecraft server:
{lib, pkgs, ... }:
pkgs.mkMinecraftServer {
name = "myminecraftserver";
src = ./mcmanconfig; # Path to a mcman config
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
}
Example generic server:
{
lib,
mkGenericServer,
fetchzip,
...
}:
mkGenericServer {
name = "myserver";
src = fetchzip {
url = "http://www.example.org/server.tar.gz";
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
nativeBuildInputs = [];
buildInputs = [];
buildPhase = ''
HOME=$TMPDIR
cd $src
cp -r . $out
'';
startCmd = "./start.sh";
}
Example steam server:
{lib, pkgs, ... }:
pkgs.mkSteamServer rec {
name = "mygameserver";
src = pkgs.fetchSteam {
inherit name;
appId = ""; # Dedicated server app id, can be found with https://steamdb.info/
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
startCmd = "./FactoryServer.sh";
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
}
There is still a lot to do.
Contributions are whole-heartedly welcome! Please feel free to suggest new features, implement additional builders, helpers, or generally assist if you'd like. We'd be happy to have you. There's more information in CONTRIBUTING.md.
Licensed under the MIT license (LICENSE or https://opensource.org/licenses/MIT). Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, shall be licensed as above, without any additional terms or conditions.