fucking minecraft 😭

This commit is contained in:
2025-10-10 02:06:54 -05:00
parent 1e8039d1c1
commit dd896748ab
24 changed files with 629 additions and 10 deletions

View File

@@ -50,6 +50,9 @@ in
sonarr.enable = true;
uptime-kuma.enable = true;
};
gameservers = {
minecraft_recpro.enable = true;
};
};
# configure users & groups
@@ -108,14 +111,6 @@ in
curl
fzf
fd
rustc
python3
nixfmt
nixd
lua
pyright
rustup
rustfmt
tree
vim
lf

View File

@@ -0,0 +1,105 @@
{ pkgs, config, lib, ... }:
let
service = "minecraft_recpro";
cfg = config.modules.gameservers.${service};
sec = config.sops.secrets;
servers = {
velocity = { data_dir = "/var/lib/gameserver/minecraft_recpro/velocity"; ram = "2G"; };
smp = { data_dir = "/var/lib/gameserver/minecraft_recpro/smp"; ram = "12G"; };
superflat = { data_dir = "/var/lib/gameserver/minecraft_recpro/superflat"; ram = "4G"; };
bento = { data_dir = "/var/lib/gameserver/minecraft_recpro"; ram = "2G"; };
};
in
{
options.modules.gameservers.${service} = {
enable = lib.mkEnableOption "enables ${service}";
url = lib.mkOption {
type = lib.types.str;
default = "mc.recoil.pro";
description = "set domain for ${service}";
};
data_dir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/gameservers/${service}";
description = "set data directory for ${service}";
};
ids = lib.mkOption {
type = lib.types.int;
default = 25565;
description = "set uid and pid of ${service} user (matches port by default)";
};
backup = lib.mkOption {
type = lib.types.bool;
default = false;
description = "enable backups for ${service}";
};
};
config = lib.mkIf cfg.enable {
# declare ${service} group
users.groups.minecraft = { gid = lib.mkForce cfg.ids; };
# declare ${service} user
users.users.minecraft = {
description = "minecraft server user";
uid = lib.mkForce cfg.ids;
isSystemUser = true;
group = "minecraft";
extraGroups = [];
};
systemd.tmpfiles.rules = lib.concatStringsSep "\n" (mapAttrsToList (name: cfg:
"d ${cfg.data_dir} 0755 minecraft minecraft -") servers);
# Create a systemd service per server running in tmux
systemd.services = lib.attrsets.mapAttrs (name: srv: {
description = "minecraft_recpro: ${name}";
after = [ "network.target" ];
wants = [ "network.target" ];
serviceConfig = {
User = "minecraft";
WorkingDirectory = srv.data_dir;
ExecStart = "${pkgs.tmux}/bin/tmux new-session -d -s ${name} '${pkgs.openjdk21}/bin/java -Xmx${srv.ram} -jar ${srv.data_dir}/server.jar nogui'";
ExecStop = "${pkgs.tmux}/bin/tmux send-keys -t ${name} C-c"; # stop server by sending Ctrl+C to tmux session
Restart = "on-failure";
KillMode = "process";
};
wantedBy = [ "multi-user.target" ];
UMask = "0007";
}) servers;
# open firewall
networking.firewall.allowedTCPPorts = [ 25777 25565 25566 25567 ];
# # internal reverse proxy entry
# services.nginx.virtualHosts."${cfg.url}" = {
# forceSSL = true;
# sslCertificate = sec."ssl_blakedheld_crt".path;
# sslCertificateKey = sec."ssl_blakedheld_key".path;
# locations."/" = {
# proxyPass = "http://127.0.0.1:${toString cfg.port}";
# };
# };
# # external reverse proxy entry
# services.nginx.virtualHosts."${service}.blakedheld.xyz" = {
# forceSSL = true;
# sslCertificate = sec."ssl_blakedheld_crt".path;
# sslCertificateKey = sec."ssl_blakedheld_key".path;
# locations."/" = {
# proxyPass = "http://127.0.0.1:${toString cfg.port}";
# };
# };
#
# sops.secrets = {
# "${service}_" = {
# owner = "${service}";
# group = "${service}";
# };
# };
# add to backups
modules.system.backups.paths = lib.mkIf cfg.backup [ cfg.data_dir ];
};
}

View File

@@ -22,6 +22,8 @@ vaultwarden_admin_token: ENC[AES256_GCM,data:G1v3N064ci0Fw5EtTzaryailWpsv6f4w6eo
gitea_database_password: ENC[AES256_GCM,data:nhFn0/G7gW5rk996OZzlcTt7T9KMbP8MNM+ReFC8w1H9ZqBSJUbs3K+n68uQVrkOVSXE0cKpOR1VbQ+i+46z3g==,iv:bT4GRZZ83v47/EmeV2KaUFo+4qTT4T2AktFUpPiZdF4=,tag:OC9TInkAr1egM+xnBDizxw==,type:str]
#ENC[AES256_GCM,data:nbB5Cd7i/KTMCjCzcX8o1sxREZQ/gLAG,iv:iyuO2erxdJM08WHJBjKuNIXYxVhH7rfyOLTcGCcGqNQ=,tag:UeDszimXv8kQUmDetLeFqg==,type:comment]
mosquitto_password_file: ENC[AES256_GCM,data:7ifs2hGnFQSgJOAKpN0usfiaqLjj7Rjb7zn1/qBDbqEi5hV0JfUncZGorBivR/+kjXHQO6nxaHcKqYvPedNdJ7Qy4/uil/xwgwSmzcbisdVYkhd2pf/N34EQFxmqohud0aTH9V47QbgTdrUPfvsiL+ljLvLu4w==,iv:z7YPIfJHHaLOJrDVnMQhgcMzYAPordFR11kHRAzZqYU=,tag:LRddczdvy01YTm2DFDgSJQ==,type:str]
#ENC[AES256_GCM,data:HJ81OxRD2xtNZKv+8oDqiT8mYpv45JMvjxU5pdmEKzl64SK3lQ==,iv:wStoC6XaZlvRPfbqti2CUbPrOOTt4KktaUp2ecVrggU=,tag:isOwKfNdQZAM+E8YQXBSFA==,type:comment]
velocity_forwarding: ENC[AES256_GCM,data:MUNhW3q0/klK51k3,iv:dGT5N+IrZfBxMIwa0mUrIKF2HJvx/uZ5o/ps6bgDNOE=,tag:KNY2LKwmmnCdWqRnxSKctw==,type:str]
sops:
age:
- recipient: age14gfh682a7m7jfp3qrulql03x5rs7yedwmxwksxrrmgjsunstyuksqx93pz
@@ -33,7 +35,7 @@ sops:
U0tmdFBuZnJES3piOTZNV0VKQmQ0eVUKCWRQ/flLzmpC64WyLoipklZBmrkpYiUg
PRu+itNolpPTHm96pe+P93g2iP0wgekG0cX21wkiU2xaLF3dY2FEIA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2025-10-09T23:59:55Z"
mac: ENC[AES256_GCM,data:Zdn1teUi8epB0WJZrpwdOxsnZ4XtJN7dPefGROPUpt0mMFDI5pP9NJpczNLj6ZddCka75Bca8Z3ixcpKasZAJhlQNNKTCe6NRhuh6ergSepzerYGTN1fUwKm+goLY40d33moZFurHkHjmdsNXgb6T9JsIz9bzjLrzqiK9P/gPoM=,iv:AQKQuW1zR9hiaBx3KxfwftM9GnwsOSfsmTN/nEJh5qA=,tag:qxODcuuzTh6ifwMNKR/6lg==,type:str]
lastmodified: "2025-10-10T06:58:16Z"
mac: ENC[AES256_GCM,data:esDQXPJSwUpChIVfcXJe5MVFI3ZJD2APDbOcfw5amo/PYB1QbbNS3W63heEmyVK8CW/UXSeeepfzlnk0kyneDX+v1ANP6B5+LLlpuEbjb4vKxZvo7C1xb5dGqzG7aizXjs83k/vZTwXw9/4AgQUQq9gL9ZI1Bmgk3yNvzctLU4U=,iv:IMO35FHjrhFoLu1TE1f/3PJOVGhe8Hwcr0CzsoJMHiM=,tag:L1ibIfAfYE9K+lKiTxsofQ==,type:str]
unencrypted_suffix: _unencrypted
version: 3.11.0

View File

@@ -0,0 +1,34 @@
-- base/base.lua
-- Shorten vim.opt for ease of use
local o = vim.opt
-- General settings
o.number = true -- Show line numbers
o.relativenumber = true -- Relative line numbers
o.expandtab = true -- Use spaces instead of tabs
o.tabstop = 4 -- Number of spaces per tab
o.shiftwidth = 4 -- Number of spaces for indentation
o.smartindent = true -- Enable smart indentation
o.autoindent = true -- Enable auto indentation
o.wrap = false -- Disable line wrapping
o.scrolloff = 8 -- Keep 8 lines visible above and below the cursor
-- Search settings
o.ignorecase = true -- Ignore case in searches
o.smartcase = true -- Enable smart case search
-- Backups and undo
o.swapfile = false -- Disable swap file
o.undofile = true -- Enable persistent undo
-- Clipboard
o.clipboard = "unnamedplus" -- Use system clipboard
-- Cursor line and column
o.cursorline = true -- Highlight the current line
o.cursorcolumn = true -- Highlight the current column
-- Command line height
o.cmdheight = 2 -- Set command-line height

View File

@@ -0,0 +1,56 @@
-- Remap leader key to comma
vim.g.mapleader = " "
local keymap = vim.keymap.set
-- General keymaps
keymap('n', '<leader>w', ':w<CR>', { desc = 'Save file' })
keymap('n', '<leader>q', ':q<CR>', { desc = 'Quit' })
keymap('n', '<leader>qq', ':q!<CR>', { desc = 'Force quit' })
-- Split navigation
keymap('n', '<leader>vs', ':vsplit<CR>', { desc = 'Vertical Split' })
keymap('n', '<leader>hs', ':split<CR>', { desc = 'Horizontal Split' })
-- File searching
keymap('n', '<leader>ff', ':Telescope find_files<CR>', { desc = 'Find Files' })
keymap('n', '<leader>fg', ':Telescope live_grep<CR>', { desc = 'Live Grep' })
keymap('n', '<leader>fb', ':Telescope buffers<CR>', { desc = 'Buffers' })
-- Buffer management
keymap('n', '<leader>bd', ':bd<CR>', { desc = 'Delete Buffer' })
-- ╭───────────────────────────────╮
-- │ LSP Keymaps (Attach Hook) │
-- ╰───────────────────────────────╯
local M = {}
function M.on_attach(_, bufnr)
local opts = { noremap = true, silent = true, buffer = bufnr }
local keymap = vim.keymap.set
-- LSP: Go to
keymap('n', 'gd', vim.lsp.buf.definition, opts)
keymap('n', 'gD', vim.lsp.buf.declaration, opts)
keymap('n', 'gi', vim.lsp.buf.implementation, opts)
keymap('n', 'gr', vim.lsp.buf.references, opts)
keymap('n', 'K', vim.lsp.buf.hover, opts)
-- LSP: Actions
keymap('n', '<leader>rn', vim.lsp.buf.rename, opts)
keymap({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, opts)
-- LSP: Diagnostics
keymap('n', '[d', vim.diagnostic.goto_prev, opts)
keymap('n', ']d', vim.diagnostic.goto_next, opts)
keymap('n', '<leader>e', vim.diagnostic.open_float, opts)
keymap('n', '<leader>q', vim.diagnostic.setloclist, opts)
-- LSP: Formatting
keymap('n', '<leader>f', function()
vim.lsp.buf.format({ async = true })
end, opts)
end
return M

View File

@@ -0,0 +1,9 @@
local lazypath = vim.fn.stdpath('data') .. '/site/pack/packer/start/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', lazypath
})
end
vim.opt.runtimepath:prepend(lazypath)
require("lazy").setup("plugins")

View File

@@ -0,0 +1,72 @@
return {
'neovim/nvim-lspconfig',
dependencies = {
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
},
config = function()
-- Setup Mason
require('mason').setup()
require('mason-lspconfig').setup {
ensure_installed = { 'nixd', 'rust_analyzer', 'lua_ls', 'pyright' },
automatic_installation = true,
}
-- Nix
lspconfig.nixd.setup {
on_attach = on_attach,
settings = {
nixd = {
nixpkgs = {
expr = 'import <nixpkgs> {}',
},
formatting = {
command = { 'nixpkgs-fmt' },
},
},
},
}
-- Rust
lspconfig.rust_analyzer.setup {
on_attach = on_attach,
settings = {
['rust-analyzer'] = {
cargo = { allFeatures = true },
checkOnSave = { command = 'clippy' },
},
},
}
-- Lua
lspconfig.lua_ls.setup {
on_attach = on_attach,
settings = {
Lua = {
diagnostics = { globals = { 'vim' } },
workspace = {
library = vim.api.nvim_get_runtime_file('', true),
checkThirdParty = false,
},
telemetry = { enable = false },
},
},
}
-- Python
lspconfig.pyright.setup {
on_attach = on_attach,
}
-- Global diagnostic config
vim.diagnostic.config({
virtual_text = false,
signs = true,
update_in_insert = false,
underline = true,
severity_sort = true,
float = { border = 'rounded' },
})
end,
}

View File

@@ -0,0 +1,12 @@
-- plugins/mason.lua
return {
"williamboman/mason.nvim", -- Mason plugin for managing LSP servers
config = function()
require('mason').setup()
require('mason-lspconfig').setup({
ensure_installed = { 'rust_analyzer', 'pyright', 'lua_ls', 'nixd', 'nixfmt' }
})
end
}

View File

@@ -0,0 +1,14 @@
-- plugins/telescope.lua
return {
"nvim-telescope/telescope.nvim", -- Telescope plugin
dependencies = { "nvim-lua/plenary.nvim" }, -- Telescope dependencies
config = function()
require('telescope').setup{
defaults = {
file_ignore_patterns = { "node_modules" }
}
}
end
}

View File

@@ -0,0 +1,5 @@
askdjfkl

View File

@@ -0,0 +1,14 @@
-- plugins/theme.lua
return {
"folke/tokyonight.nvim", -- Tokyo Night theme plugin
config = function()
require('tokyonight').setup({
style = "night", -- You can also use 'storm' or 'day' if you prefer those.
transparent = true,
terminal_colors = true,
})
vim.cmd('colorscheme tokyonight')
end
}

View File

@@ -0,0 +1,14 @@
-- plugins/vimwiki.lua
return {
"vimwiki/vimwiki", -- Vimwiki plugin
config = function()
vim.g.vimwiki_list = {{
path = '~/vimwiki',
syntax = 'markdown',
ext = '.md',
}}
vim.g.vimwiki_global_ext = 0 -- Global extension
end
}

View File

@@ -0,0 +1,9 @@
-- plugins/whichkey.lua
return {
"folke/which-key.nvim", -- Which-key plugin for keybinding hints
config = function()
require('which-key').setup{}
end
}

View File

@@ -0,0 +1,64 @@
-- blake's nvim config in lua
-- base.base
-- general nvim settings
-- define functions for settings
local g = vim.g
local o = vim.o
local opt = vim.opt
-- clipboard
o.clipboard = "unnamedplus"
-- enable filetype detection
vim.cmd('filetype indent plugin on')
vim.cmd('syntax on')
-- o.nocompatible = true
-- line numbers
o.number = true
o.numberwidth = 2
o.relativenumber = true
vim.cmd('highlight LineNr ctermfg=054')
-- tabs
o.tabstop = 2
o.shiftwidth = 2
o.softtabstop = -1 -- if negative uses shift width
o.expandtab = true
o.smarttab = true
o.autoindent = true
-- improve search
o.ignorecase = true
o.smartcase = true
-- backup files
o.backup = false
o.writebackup = false
o.undofile = true
o.swapfile = true
-- auto-read file changes
o.autoread = true
-- spell checker
o.spelllang = 'en_us'
o.spell = false
-- word wrapping
o.wrap = true
o.linebreak = true
o.breakindent = true
-- visual line movement
vim.keymap.set({'i'}, '<Up>', '<C-o>gk', {desc = 'Visual Line Up (Insert)'})
vim.keymap.set({'i'}, '<Down>', '<C-o>gj', {desc = 'Visual Line Down (Insert)'})
vim.keymap.set({'n', 'v'}, '<Up>', 'g<Up>', {desc = 'Visual Line Up'})
vim.keymap.set({'n', 'v'}, '<Down>', 'g<Down>', {desc = 'Visual Line Down'})
-- set leader
g.mapleader = " "
g.maplocalleader = " "

View File

@@ -0,0 +1,41 @@
-- LSP Keymaps (applies when any LSP attaches)
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspKeymaps", { clear = true }),
callback = function(event)
local opts = { buffer = event.buf, silent = true, noremap = true }
-- 🧭 Navigation
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
-- 🧠 Info
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
-- 🛠️ Actions
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
-- 🧹 Formatting
vim.keymap.set("n", "<leader>f", function()
vim.lsp.buf.format({ async = false })
end, vim.tbl_extend("force", opts, { desc = "Format buffer with LSP" }))
-- 💡 Diagnostics
vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, opts)
-- 🧩 Inlay hints (toggle)
if vim.lsp.inlay_hint then
vim.keymap.set("n", "<leader>h", function()
local enabled = vim.lsp.inlay_hint.is_enabled(event.buf)
vim.lsp.inlay_hint.enable(not enabled, { bufnr = event.buf })
end, vim.tbl_extend("force", opts, { desc = "Toggle inlay hints" }))
end
end,
})

View File

@@ -0,0 +1,19 @@
-- bootstrap lazy
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- load plugins
require("lazy").setup("plugins")

View File

@@ -0,0 +1,60 @@
return {
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(), -- Trigger completion
["<C-e>"] = cmp.mapping.abort(), -- Close completion
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Confirm selection
-- **Navigation**
["<Down>"] = cmp.mapping.select_next_item(), -- Arrow down
["<Up>"] = cmp.mapping.select_prev_item(), -- Arrow up
["<C-n>"] = cmp.mapping.select_next_item(), -- Ctrl+n (alternative)
["<C-p>"] = cmp.mapping.select_prev_item(), -- Ctrl+p (alternative)
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
}),
})
end,
}

View File

@@ -0,0 +1,11 @@
-- return {
{
"willothy/nvim-cokeline",
dependencies = {
"nvim-lua/plenary.nvim", -- Required for v0.4.0+
"nvim-tree/nvim-web-devicons", -- If you want devicons
"stevearc/resession.nvim" -- Optional, for persistent history
},
config = true
}
}

View File

@@ -0,0 +1,3 @@
return {
'rafi/awesome-vim-colorschemes',
}

View File

@@ -0,0 +1,57 @@
return {
{
"3rd/image.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
require("image").setup({
backend = "kitty", -- or "ueberzug" or "sixel"
processor = "magick_cli", -- or "magick_rock"
integrations = {
markdown = {
enabled = true,
clear_in_insert_mode = false,
download_remote_images = true,
only_render_image_at_cursor = false,
only_render_image_at_cursor_mode = "popup", -- or "inline"
floating_windows = false, -- if true, images will be rendered in floating markdown windows
filetypes = { "markdown", "vimwiki" },
},
neorg = {
enabled = true,
filetypes = { "norg" },
},
typst = {
enabled = true,
filetypes = { "typst" },
},
html = { enabled = false },
css = { enabled = false },
},
max_width = nil,
max_height = nil,
max_width_window_percentage = nil,
max_height_window_percentage = 50,
scale_factor = 1.0,
window_overlap_clear_enabled = false,
window_overlap_clear_ft_ignore = {
"cmp_menu",
"cmp_docs",
"snacks_notif",
"scrollview",
"scrollview_sign",
},
editor_only_render_when_focused = false,
tmux_show_only_in_active_window = false,
hijack_file_patterns = {
"*.png",
"*.jpg",
"*.jpeg",
"*.gif",
"*.webp",
"*.avif",
},
})
end,
},
}

View File

@@ -0,0 +1,8 @@
return {
'EdenEast/nightfox.nvim',
opts = {
options = {
transparent = true,
}
}
}

View File

@@ -0,0 +1,15 @@
return {
'vimwiki/vimwiki',
init = function ()
vim.g.vimwiki_list = {
{
path = '~/holocron',
path_html = '~/holocron/html',
syntax = 'markdown',
ext = '.md',
diary_rel_path = 'journal/diary',
auto_diary_index = 1,
},
}
end
}