Migrate mc server to nix-minecraft flake

This commit is contained in:
William 2023-06-28 17:44:55 -03:00
parent f06979ac1d
commit 92f1c6f3fa
6 changed files with 114 additions and 41 deletions

76
flake.lock generated
View file

@ -132,10 +132,44 @@
"type": "github"
}
},
"flake-compat_3": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
@ -251,6 +285,28 @@
"type": "github"
}
},
"nix-minecraft": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1687917420,
"narHash": "sha256-56L07MZrKOxBz18H+UI4ltDAbEYCc15bvkPZ7+AXkcQ=",
"owner": "Infinidoge",
"repo": "nix-minecraft",
"rev": "2021eee2668afd94517eec3e1d2cfcc8aaca8fdf",
"type": "github"
},
"original": {
"owner": "Infinidoge",
"repo": "nix-minecraft",
"type": "github"
}
},
"nixlib": {
"locked": {
"lastModified": 1685840432,
@ -353,8 +409,8 @@
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils",
"flake-compat": "flake-compat_3",
"flake-utils": "flake-utils_2",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
@ -384,6 +440,7 @@
"home-manager": "home-manager_2",
"homepage": "homepage",
"kmonad": "kmonad",
"nix-minecraft": "nix-minecraft",
"nixos-generators": "nixos-generators",
"nixpkgs": "nixpkgs_2",
"nixpkgs-stable": "nixpkgs-stable",
@ -405,6 +462,21 @@
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1667395993,

View file

@ -46,11 +46,16 @@
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-minecraft = {
url = "github:Infinidoge/nix-minecraft";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nixpkgs, home-manager, baduhai-nur, kmonad
, nixpkgs-stable, deploy-rs, agenix, nixos-generators, homepage, dotfiles
, pre-commit-hooks, ... }: {
, pre-commit-hooks, nix-minecraft, ... }: {
nixosConfigurations = {
rotterdam = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
@ -93,7 +98,12 @@
unstable = nixpkgs.legacyPackages.x86_64-linux;
};
in {
nixpkgs.overlays = [ unstable-overlay agenix.overlays.default ];
nixpkgs.overlays = [
unstable-overlay
agenix.overlays.default
nix-minecraft.overlay
];
imports = [ nix-minecraft.nixosModules.minecraft-servers ];
})
];
};

View file

@ -20,7 +20,7 @@
networking = {
hostName = "alexandria";
firewall = {
allowedTCPPorts = [ 80 443 8010 9666 25565 ];
allowedTCPPorts = [ 80 443 8010 9666 ];
allowedUDPPorts = [ 24454 ];
};
};

View file

@ -9,7 +9,7 @@
./hardware-configuration.nix
./jellyfin.nix
./librespeed.nix
# ./minecraft.nix
./minecraft.nix
./nginx.nix
./paperless.nix
./searx.nix
@ -20,6 +20,5 @@
./users.nix
./variables.nix
./vaultwarden.nix
# ./whoogle.nix
];
}

View file

@ -1,19 +1,33 @@
{ inputs, config, pkgs, lib, ... }:
{
services.minecraft-server = {
let
modpack = pkgs.fetchPackwizModpack {
url =
"https://raw.githubusercontent.com/baduhai/FFS/06d253f0cd262b8d4a178d4db8e1a7188051e8d0/pack.toml";
packHash = "sha256-";
};
mcVersion = modpack.manifest.versions.minecraft;
fabricVersion = modpack.manifest.versions.fabric;
serverVersion =
lib.replaceStrings [ "." ] [ "_" ] "fabric-${mcVersion}-${fabricVersion}";
in {
services.minecraft-servers = {
enable = true;
eula = true;
declarative = true;
openFirewall = true;
package = pkgs.papermc;
serverProperties = {
motd = "Bem-vindo a Alexandria";
difficulty = "hard";
gamemode = "survival";
online-mode = "false";
spawn-protection = "0";
};
dataDir = "/data/minecraft";
servers."alexandria" = {
enable = true;
package = pkgs.fabricServers.${serverVersion};
openFirewall = true;
serverProperties = {
difficulty = "hard";
gamemode = "survival";
motd = "O Seridor";
online-mode = false;
spawn-protection = false;
};
symlink."mods" = "${modpack}/mods";
};
};
}

View file

@ -1,22 +0,0 @@
{ inputs, config, pkgs, lib, ... }:
{
virtualisation.oci-containers.containers."whoogle" = {
image = "benbusby/whoogle-search:latest";
environment = {
HTTPS_ONLY = "1";
WHOOGLE_CONFIG_LANGUAGE = "lang_en";
WHOOGLE_CONFIG_THEME = "system";
WHOOGLE_CONFIG_VIEW_IMAGE = "1";
};
ports = [ "${config.ports.whoogle}:5000" ];
extraOptions = [ "--pull=always" ];
};
services.nginx.virtualHosts."whoogle.baduhai.me" = {
useACMEHost = "baduhai.me";
forceSSL = true;
kTLS = true;
locations."/".proxyPass = "http://127.0.0.1:${config.ports.whoogle}";
};
}