diff --git a/configuration.nix b/configuration.nix index 227c7dd..e6b831a 100644 --- a/configuration.nix +++ b/configuration.nix @@ -27,11 +27,11 @@ services.openssh.enable = true; - networking.firewall.allowedTCPPorts = [22 80 443]; - # networking.firewall.allowedUDPPorts = [ ... ]; + nixpkgs.config.allowUnfree = true; nix = { settings.experimental-features = ["nix-command" "flakes"]; + settings.trusted-public-keys = ["prin:qLlCk6ouH2mKQoiX3UmPX+x8VyEvI7tDYCvEh6+bq0Q="]; optimise.automatic = true; gc = { automatic = true; diff --git a/flake.lock b/flake.lock index 17e0d5a..0d7bb48 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -23,7 +39,7 @@ }, "flake-utils": { "inputs": { - "systems": "systems" + "systems": "systems_2" }, "locked": { "lastModified": 1731533236, @@ -46,11 +62,11 @@ ] }, "locked": { - "lastModified": 1774559029, - "narHash": "sha256-deix7yg3j6AhjMPnFDCmWB3f83LsajaaULP5HH2j34k=", + "lastModified": 1779506708, + "narHash": "sha256-QOD/CNm196nCJRheux/URi4/HE66fthdOMqCJoPP1Y0=", "owner": "nix-community", "repo": "home-manager", - "rev": "a0bb0d11514f92b639514220114ac8063c72d0a3", + "rev": "3ee51fbdac8c8bdfe1e7e1fcaba6520a563f394f", "type": "github" }, "original": { @@ -88,13 +104,49 @@ "type": "github" } }, + "nix-minecraft": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": "nixpkgs", + "systems": "systems" + }, + "locked": { + "lastModified": 1784777515, + "narHash": "sha256-hBzD1XzM/2cYWfgLvbiGDLDebE1SXHO+O6N4YOT0+W4=", + "owner": "Infinidoge", + "repo": "nix-minecraft", + "rev": "3fc7a8a5d4640a5e6bf614e17e5c4c971edfc90a", + "type": "github" + }, + "original": { + "owner": "Infinidoge", + "repo": "nix-minecraft", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1774388614, - "narHash": "sha256-tFwzTI0DdDzovdE9+Ras6CUss0yn8P9XV4Ja6RjA+nU=", + "lastModified": 1769461804, + "narHash": "sha256-msG8SU5WsBUfVVa/9RPLaymvi5bI8edTavbIq3vRlhI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "bfc1b8a4574108ceef22f02bafcf6611380c100d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1782847189, + "narHash": "sha256-twXPFqFsrrY5r28Zh7Homgcp2gUMBgQ6WDS98Q/3xFI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1073dad219cb244572b74da2b20c7fe39cb3fa9e", + "rev": "b6018f87da91d19d0ab4cf979885689b469cdd41", "type": "github" }, "original": { @@ -111,14 +163,14 @@ "nixpkgs" ], "nuschtosSearch": "nuschtosSearch", - "systems": "systems_2" + "systems": "systems_3" }, "locked": { - "lastModified": 1769049374, - "narHash": "sha256-h0Os2qqNyycDY1FyZgtbn28VF1ySP74/n0f+LDd8j+w=", + "lastModified": 1780865908, + "narHash": "sha256-UMwL+pE2I49q6qOV8w6pnuF3utb1qQuofmprBAhOU6A=", "owner": "nix-community", "repo": "nixvim", - "rev": "b8f76bf5751835647538ef8784e4e6ee8deb8f95", + "rev": "68e314303bc60b8a58cdd2f361013809620b2473", "type": "github" }, "original": { @@ -154,7 +206,8 @@ "root": { "inputs": { "home-manager": "home-manager", - "nixpkgs": "nixpkgs", + "nix-minecraft": "nix-minecraft", + "nixpkgs": "nixpkgs_2", "nixvim": "nixvim" } }, @@ -187,6 +240,21 @@ "repo": "default", "type": "github" } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index fbc9951..3bcb487 100644 --- a/flake.nix +++ b/flake.nix @@ -14,22 +14,29 @@ # If using a stable channel you can use `url = "github:nix-community/nixvim/nixos-"` inputs.nixpkgs.follows = "nixpkgs"; }; + + nix-minecraft.url = "github:Infinidoge/nix-minecraft"; }; - outputs = { + outputs = inputs @ { nixpkgs, home-manager, nixvim, + nix-minecraft, ... }: { nixosConfigurations."prever" = nixpkgs.lib.nixosSystem { modules = [ home-manager.nixosModules.default nixvim.nixosModules.nixvim + nix-minecraft.nixosModules.minecraft-servers ./hardware-configuration.nix ./configuration.nix ./modules + { + nixpkgs.overlays = [inputs.nix-minecraft.overlay]; + } ]; }; }; diff --git a/modules/default.nix b/modules/default.nix index 09f2ba5..f02871c 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -4,5 +4,8 @@ ./nginx.nix ./tmux.nix ./nvim.nix + ./networking.nix + ./forgejo.nix + ./minecraft.nix ]; } diff --git a/modules/forgejo.nix b/modules/forgejo.nix new file mode 100644 index 0000000..c26b025 --- /dev/null +++ b/modules/forgejo.nix @@ -0,0 +1,29 @@ +{config, ...}: let + cfg = config.services.forgejo; + srv = cfg.settings.server; +in { + services.nginx = { + virtualHosts.${cfg.settings.server.DOMAIN} = { + forceSSL = true; + enableACME = true; + locations."/".proxyPass = "http://localhost:${toString srv.HTTP_PORT}"; + }; + }; + + services.forgejo = { + enable = true; + database.type = "postgres"; + lfs.enable = true; + stateDir = "/var/git"; + + settings = { + server = { + DOMAIN = "git.yelbakri.dev"; + ROOT_URL = "https://${srv.DOMAIN}/"; + HTTP_PORT = 3000; + }; + + service.DISABLE_REGISTRATION = true; + }; + }; +} diff --git a/modules/minecraft.nix b/modules/minecraft.nix index ea8f50d..e8ba2ed 100644 --- a/modules/minecraft.nix +++ b/modules/minecraft.nix @@ -1,2 +1,110 @@ -{...}: { +{pkgs, ...}: { + services.nginx = { + recommendedProxySettings = true; + + virtualHosts."mc.yelbakri.dev" = { + enableACME = true; + forceSSL = true; + + locations."/" = { + proxyPass = "http://localhost:8100"; + proxyWebsockets = true; + }; + }; + }; + + services.minecraft-servers = { + enable = true; + eula = true; + openFirewall = true; + # managementSystem.systemd-socket.enable = true; + + servers.purpur = { + enable = true; + autoStart = true; + openFirewall = true; + enableReload = true; + + jvmOpts = "-Xmx6G -Xms4G"; + + package = pkgs.purpurServers.purpur-26_2.override { + jre = pkgs.openjdk25; + }; + + operators = { + bruh_prin = "0da45413-80b8-4e48-a220-5340f5be4122"; + }; + + whitelist = { + Quimii = "78e09ea0-7b13-4eee-8203-c8dad929a738"; + Keir3 = "4872ed2a-50cb-4636-b879-02215c1d4023"; + bruh_prin = "0da45413-80b8-4e48-a220-5340f5be4122"; + Aegns445 = "4fd4d160-dad9-4136-b49c-aa44ee1d3ab1"; + roro_u22 = "3631cba2-5808-43f2-b5dc-1357f274c03a"; + FeedBackJr = "b9a4d8ae-3c2c-42df-b63b-0ee5874bf250"; + Killax = "79862daf-f239-45d2-bf08-1b80961bf656"; + }; + + files."plugins/bluemap.jar" = pkgs.fetchurl { + url = "https://hangarcdn.papermc.io/plugins/Blue/BlueMap/versions/5.20/PAPER/bluemap-5.20-paper.jar"; + sha256 = "yTnJi3KKpwiaBLesoaaXnpKjfyUkcfarrWZ0nt6AYzk="; + }; + + serverProperties = { + accepts-transfers = false; + allow-flight = false; + broadcast-console-to-ops = true; + broadcast-rcon-to-ops = true; + difficulty = "hard"; + enable-code-of-conduct = false; + enable-jmx-monitoring = false; + enable-query = false; + enable-rcon = false; + enable-status = true; + enforce-secure-profile = true; + enforce-whitelist = true; + entity-broadcast-range-percentage = 100; + force-gamemode = false; + function-permission-level = 2; + gamemode = "survival"; + generate-structures = true; + hardcore = false; + hide-online-players = false; + initial-enabled-packs = "vanilla"; + level-name = "testing"; + level-type = "minecraft\\:normal"; + log-ips = true; + management-server-enabled = false; + management-server-host = "localhost"; + management-server-port = 0; + management-server-secret = "UYSVZK8WKzvWscxgQgvQONRKpyeyl7VyfBc8hGPl"; + management-server-tls-enabled = true; + max-chained-neighbor-updates = 1000000; + max-players = 7; + max-tick-time = 60000; + max-world-size = 29999984; + motd = "SIGMA SERVER"; + network-compression-threshold = 256; + online-mode = true; + op-permission-level = 4; + pause-when-empty-seconds = 60; + player-idle-timeout = 0; + prevent-proxy-connections = false; + "query.port" = 25565; + rate-limit = 0; + "rcon.password" = "hahaha"; + "rcon.port" = 25575; + region-file-compression = "deflate"; + require-resource-pack = false; + server-port = 25565; + simulation-distance = 10; + spawn-protection = 16; + status-heartbeat-interval = 0; + sync-chunk-writes = true; + use-native-transport = true; + view-distance = 16; + white-list = true; + }; + }; + }; } diff --git a/modules/networking.nix b/modules/networking.nix new file mode 100644 index 0000000..a437e1e --- /dev/null +++ b/modules/networking.nix @@ -0,0 +1,8 @@ +{...}: let +in { + networking.firewall = { + enable = true; # disable default firewall + allowedTCPPorts = [22 80 443 25565]; + allowedUDPPorts = [22 80 443 25565]; + }; +} diff --git a/modules/nginx.nix b/modules/nginx.nix index 67948ba..2266b26 100644 --- a/modules/nginx.nix +++ b/modules/nginx.nix @@ -8,6 +8,7 @@ addSSL = true; enableACME = true; root = "/var/www"; + default = true; }; }; diff --git a/modules/nvim.nix b/modules/nvim.nix index 0d6a5e2..589a512 100644 --- a/modules/nvim.nix +++ b/modules/nvim.nix @@ -1,4 +1,4 @@ -{pkgs, ...}: { +{...}: { programs.nixvim = { enable = true; globals.mapleader = " "; @@ -8,36 +8,5 @@ }; colorschemes.ayu.enable = true; - - autoCmd = [ - { - event = "BufWritePre"; - pattern = "*.nix"; - callback = { - __raw = "function(args) require('conform').format({ bufnr = args.buf }) end"; - }; - } - ]; - - plugins.nix.enable = true; - plugins.treesitter.enable = true; - plugins.lspconfig.enable = true; - plugins.blink-cmp.enable = true; - plugins.telescope.enable = true; - - plugins.conform-nvim = { - enable = true; - - settings = { - formatters_by_ft = { - nix = ["alejandra"]; - }; - }; - }; - lsp.servers.nil_ls.enable = true; }; - - users.users.prever.packages = [ - pkgs.alejandra - ]; } diff --git a/secrets/default.nix b/secrets/default.nix new file mode 100644 index 0000000..ceb385b --- /dev/null +++ b/secrets/default.nix @@ -0,0 +1,5 @@ +{...}: let + key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP7vhngCJL3jcyNGbSC0ke1CwW9/gn/bcTe0kGc1lbIu prin@nixos"; +in { + "forgejo-admin.age".publicKeys = [key]; +}