init minecraft server configs!
This commit is contained in:
commit
64820d502a
23 changed files with 24719 additions and 0 deletions
67
flake.nix
Normal file
67
flake.nix
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
description = "compsigh Minecraft server";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
disko = {
|
||||
url = "github:nix-community/disko";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
agenix = {
|
||||
url = "github:ryantm/agenix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, disko, ... }@inputs:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
serverHost = "root@compsigh-minecraft";
|
||||
|
||||
deploy = pkgs.writeShellScriptBin "nhs" ''
|
||||
nh os switch --hostname compsigh-minecraft --target-host root@compsigh-minecraft path:. "$@"
|
||||
'';
|
||||
mcWhitelist = pkgs.writeShellScriptBin "mc-whitelist" ''
|
||||
ssh ${serverHost} "docker exec minecraft rcon-cli whitelist add $1"
|
||||
'';
|
||||
mcCmd = pkgs.writeShellScriptBin "mc-cmd" ''
|
||||
ssh ${serverHost} "docker exec minecraft rcon-cli $*"
|
||||
'';
|
||||
mcLogs = pkgs.writeShellScriptBin "mc-logs" ''
|
||||
ssh ${serverHost} "docker logs --tail ''${1:-100} -f minecraft"
|
||||
'';
|
||||
in
|
||||
{
|
||||
nixosConfigurations.compsigh-minecraft = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
specialArgs = { inherit inputs; };
|
||||
modules = [
|
||||
disko.nixosModules.disko
|
||||
inputs.agenix.nixosModules.default
|
||||
./disk-config.nix
|
||||
./configuration.nix
|
||||
];
|
||||
};
|
||||
|
||||
devShells.${system}.default = pkgs.mkShell {
|
||||
packages = [
|
||||
deploy
|
||||
mcWhitelist
|
||||
mcCmd
|
||||
mcLogs
|
||||
pkgs.nh
|
||||
inputs.agenix.packages.${system}.default
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
echo "compsigh minecraft server"
|
||||
echo " nhs — deploy to server"
|
||||
echo " mc-whitelist — add a player (mc-whitelist PlayerName)"
|
||||
echo " mc-cmd — run rcon command (mc-cmd whitelist list)"
|
||||
echo " mc-logs — tail server logs"
|
||||
echo " agenix — manage secrets"
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue