diff options
| author | Alexander Kassouni <alex@kassouni.net> | 2026-09-25 19:52:09 -0700 |
|---|---|---|
| committer | Alexander Kassouni <alex@kassouni.net> | 2026-09-25 19:52:09 -0700 |
| commit | c8a0c5d7bc29b0bb16256ae9ab40b8bb344c6be9 (patch) | |
| tree | 58da4fd02c50e73272e069af61168a021019aff1 | |
init
| -rw-r--r-- | configuration.nix | 33 | ||||
| -rw-r--r-- | flake.lock | 24 | ||||
| -rw-r--r-- | flake.nix | 19 | ||||
| -rw-r--r-- | hardware-configuration.nix | 30 | ||||
| -rw-r--r-- | justfile | 8 | ||||
| -rw-r--r-- | minecraft.nix | 40 |
6 files changed, 154 insertions, 0 deletions
diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..8335278 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,33 @@ +{config, lib, pkgs, ...}: { + imports = [ + ./hardware-configuration.nix + ./minecraft.nix + ]; + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.networkmanager.enable = true; + + services.fail2ban.enable = true; + + services.openssh = { + enable = true; + settings = { + PasswordAuthentication = false; + PermitRootLogin = "no"; + AllowUsers = [ "kassouni" ]; + KbdInteractiveAuthentication = false; + PubkeyAuthentication = true; + }; + }; + + users.users.kassouni = { + extraGroups = [ "wheel" ]; + isNormalUser = true; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBmhTnNG0ym84RJzbIcDCwGmPFVaFPkSYiUtNQrrnV6" + ]; + }; + + system.stateVersion = "26.05"; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..698d13e --- /dev/null +++ b/flake.lock @@ -0,0 +1,24 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1790055231, + "narHash": "sha256-wQZif6Lyrg1IDl8k68Gwa3OK9PermeRsjdKgso4K1VA=", + "rev": "b6c98e9e6633ee64753b594ff4a5febf0367fc00", + "type": "tarball", + "url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1078010.b6c98e9e6633/nixexprs.tar.zst" + }, + "original": { + "type": "tarball", + "url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.zst" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..47e0172 --- /dev/null +++ b/flake.nix @@ -0,0 +1,19 @@ +{ + description = "kassouni.net server"; + + inputs = { + nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.zst"; + }; + + outputs = inputs: { + nixosConfigurations.kassouni-net = inputs.nixpkgs.lib.nixosSystem { + modules = [ ./configuration.nix ]; + }; + + devShells = builtins.mapAttrs (system: pkgs: { + default = pkgs.mkShell { + packages = [ pkgs.just ]; + }; + }) inputs.nixpkgs.legacyPackages; + }; +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..321c3d1 --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,30 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/39d32404-1fa3-42ef-9eb4-a2a41b532258"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/1129-26CF"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + swapDevices = [ ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} diff --git a/justfile b/justfile new file mode 100644 index 0000000..96c2c25 --- /dev/null +++ b/justfile @@ -0,0 +1,8 @@ +host := "kassouni@5.78.230.100" +config := "kassouni-net" + +deploy: + nixos-rebuild switch --flake .#{{config}} --target-host {{host}} --build-host {{host}} --sudo --ask-sudo-password + +ssh: + ssh {{host}} diff --git a/minecraft.nix b/minecraft.nix new file mode 100644 index 0000000..d40d80a --- /dev/null +++ b/minecraft.nix @@ -0,0 +1,40 @@ +{lib, ...}:{ + # The Mojang server jar is unfreeRedistributable, so it has to be allowed by name. + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "minecraft-server" + ]; + + services.minecraft-server = { + enable = true; + eula = true; + openFirewall = true; # Opens the port the server is running on (25565) + declarative = true; + whitelist = { + # This is a mapping of Minecraft usernames to to the players' UUIDs + mr_5aturn = "2b811fad-e419-401e-9185-70ab279219b5"; + }; + serverProperties = { + server-port = 25565; + difficulty = "normal"; + gamemode = "survival"; + max-players = 5; + motd = "NixOS Minecraft server!"; + white-list = true; + }; + jvmOpts = "-Xms4096M -Xmx4096M"; + }; + + systemd.services.minecraft-server = { + startLimitBurst = 5; + startLimitIntervalSec = 300; + serviceConfig = { + NoNewPrivileges = true; + + ProtectSystem = "full"; + + MemoryMax = "6G"; + TasksMax = 512; + RestartSec = "10s"; + }; + }; +} |
