dotfiles

My PC Dotfiles & Website
commit 186f09b58d4bbcc4e570cbf5bbc39ba504f3e9e6
parent fde0990123b94ea01c0fd1e38e9c6a55d0979d57
Author: maydayv7 <maydayv7@gmail.com>
Date:   Mon, 22 Jun 2026 23:55:11 +0530

feat: Script to update Minecraft Server Plugins

Also drop unused Wine configuration

Diffstat:
MCHANGELOG.md | 3+++
MREADME.md | 8+-------
Mflake.lock | 40+---------------------------------------
Mflake.nix | 6------
Mmodules/README.md | 4+---
Mmodules/apps/internet.nix | 2+-
Mmodules/apps/wine.nix | 73+++++++++++++++++++------------------------------------------------------
Mmodules/desktop/gnome/_settings/apps.nix | 2--
Mmodules/games/games.nix | 7++++---
Dmodules/games/mc-server.nix | 221-------------------------------------------------------------------------------
Amodules/games/mc-server/_mods.nix | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/games/mc-server/default.nix | 153+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/games/mc-server/update.sh | 2++
Mmodules/hosts/valkyrie/_dev.nix | 3++-
Mmodules/hosts/valkyrie/default.nix | 6++----
Mmodules/hosts/vortex.nix | 2--
Mpackages/_module.nix | 2--
Dpackages/wine/.keep | 0
Dpackages/wine/7zip.nix | 83-------------------------------------------------------------------------------
Dpackages/wine/notepad++.nix | 85-------------------------------------------------------------------------------
Ascripts/mods.sh | 122+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mscripts/nixos.nix | 2--
22 files changed, 409 insertions(+), 515 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -2,6 +2,9 @@ ### June +- Script to update Minecraft mods +- Drop manually-packaged `wine` applications +- Robust GitHub Actions CI - Auto-import Catppuccin targets for Hyprland (`gui._unmanaged`) - Add `valkyrie` Dev config - Use Hyprland's Scrolling layout diff --git a/README.md b/README.md @@ -107,7 +107,6 @@ It also builds and deploys my website to [maydayv7.cc](https://maydayv7.cc). - Support for `source` filters with [`nix-filter`](https://github.com/numtide/nix-filter) - Support for Base16 color theming using [`stylix`](https://github.com/danth/stylix) - Support for declaratively installing [Flatpak](./modules/apps/flatpak.nix) applications using [`nix-flatpak`](https://github.com/gmodena/nix-flatpak) -- Wrapped `wine` [Applications](./packages/wine) using Emmanuel's [Wrapper](https://github.com/emmanuelrosa/erosanix/tree/0dabea58d483e13d2de141517cb4ff1cb230b2aa/pkgs/mkwindowsapp) - Support for Android Virtualisation using [Waydroid](https://waydro.id/) - Support for VFIO PCI Device Passthrough along with [Looking Glass](https://looking-glass.io/) for high-performance VMs @@ -386,12 +385,7 @@ A `git` [hook](./files/git/hooks) is used to check the commit message to adhere <details> <summary><b>Known Limitations</b></summary> -### Manual Intervention - -- [Wine](./packages/wine) Applications have to be manually updated -- Minecraft [Server](./modules/apps/games/mc-server.nix) has to be manually updated -- Logseq Plugins have to be manually installed -- Cannot automatically hibernate on NVIDIA due to upstream [issue](https://forums.developer.nvidia.com/t/systemds-suspend-then-hibernate-not-working-in-nvidia-optimus-laptop/213690) +- [Logseq](./modules/apps/notes.nix) Plugins have to be manually installed </details> diff --git a/flake.lock b/flake.lock @@ -321,22 +321,6 @@ "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" } }, - "flake-compat_5": { - "flake": false, - "locked": { - "lastModified": 1777728799, - "narHash": "sha256-z7jjYQqhkFKab92VQ3duB7QVO7f7Y62qTFrJYXO/lyo=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "4b2287113c2f9a2331c04899b2e2e5ab92dea9c5", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -1787,8 +1771,7 @@ "systems": "systems_2", "unstable": "unstable", "utils": "utils_2", - "vscode": "vscode", - "windows": "windows" + "vscode": "vscode" } }, "rust-overlay": { @@ -2102,27 +2085,6 @@ "type": "github" } }, - "windows": { - "inputs": { - "flake-compat": "flake-compat_5", - "nixpkgs": [ - "unstable" - ] - }, - "locked": { - "lastModified": 1780842632, - "narHash": "sha256-/k7fIVU+pDqVlr+31XF62iQRcrv8IF7x7jeo+3kOcI4=", - "owner": "emmanuelrosa", - "repo": "erosanix", - "rev": "b74371ca0e945bc772d98c75111aa42d16666645", - "type": "github" - }, - "original": { - "owner": "emmanuelrosa", - "repo": "erosanix", - "type": "github" - } - }, "xdph": { "inputs": { "hyprland-protocols": [ diff --git a/flake.nix b/flake.nix @@ -152,12 +152,6 @@ }; }; - # Windows Apps Wrapper - windows = { - url = "github:emmanuelrosa/erosanix"; - inputs.nixpkgs.follows = "unstable"; - }; - ## Theming # Base16 Theming Module stylix = { diff --git a/modules/README.md b/modules/README.md @@ -125,9 +125,7 @@ The following are the custom configuration options exposed by the modules above: - `runner` - - `support`: Enable Support for `git` Runners - `null / "github" / "gitlab"` - `secret`: Path to Secret for `git` Runner - - `wine` - - - `utilities`: Install Utility Windows apps - `true / false` - - `package`: Package to use for `wine` - Ex. `pkgs.wineWow64Packages.stagingFull` + - `wine` - Package to use for `wine` - Ex. `pkgs.wineWow64Packages.stagingFull` - [`games`](./games) - - `mc-servers`: List of Minecraft Servers - diff --git a/modules/apps/internet.nix b/modules/apps/internet.nix @@ -35,7 +35,7 @@ in { }; home.packages = with pkgs; [ - karere + unstable.karere linux-wifi-hotspot openfortivpn teams-for-linux diff --git a/modules/apps/wine.nix b/modules/apps/wine.nix @@ -1,7 +1,5 @@ ## Wine Configuration ## -{config, ...}: let - inherit (config) util; -in { +_: { flake.modules = { nixos.wine = { config, @@ -9,23 +7,12 @@ in { pkgs, ... }: let - inherit (builtins) attrValues map; - inherit - (lib) - mkEnableOption - mkOption - optionals - types - ; - cfg = config.apps.wine; + pkg = config.apps.wine; in { - options.apps.wine = { - utilities = mkEnableOption "Install Utility Windows apps"; - package = mkOption { - description = "Package to use for 'wine'"; - type = types.package; - default = pkgs.wineWow64Packages.stagingFull; - }; + options.apps.wine = lib.mkOption { + description = "Package to use for 'wine'"; + type = lib.types.package; + default = pkgs.wineWow64Packages.stagingFull; }; config = { @@ -34,50 +21,28 @@ in { hardware.graphics.enable32Bit = true; environment.systemPackages = with pkgs.wine // pkgs; ( - map + builtins.map ( name: if (name.override.__functionArgs ? wine) - then name.override {wine = cfg.package;} + then name.override {wine = pkg;} else name ) - ( - [ - cfg.package - winetricks - mkwindowsapp-tools - playonlinux - ] - # Wrapped Packages - ++ optionals cfg.utilities ( - attrValues ( - util.map.modules ../../packages/wine ( - name: - callPackage name { - inherit lib pkgs; - wine = cfg.package; - build = winelib; - } - ) - ) - ) - ) + [ + pkg + winetricks + playonlinux + ] ); }; }; - homeManager.wine = { - config, - lib, - ... - }: { - home.persist.directories = - [ - ".wine" - ".cache/wine" - ".cache/winetricks" - ] - ++ lib.optionals (config.apps.wine.utilities or false) [".config/notepad++"]; + homeManager.wine = _: { + home.persist.directories = [ + ".wine" + ".cache/wine" + ".cache/winetricks" + ]; }; }; } diff --git a/modules/desktop/gnome/_settings/apps.nix b/modules/desktop/gnome/_settings/apps.nix @@ -239,10 +239,8 @@ lib.mkIf (osConfig != null) ( "org/gnome/desktop/app-folders/folders/1c3e59e4-a571-4ada-af1d-ed1ced384cfb" = { name = "Wine"; apps = [ - "7zip.desktop" "com.usebottles.bottles.desktop" "net.lutris.Lutris.desktop" - "Notepad++.desktop" "winetricks.desktop" "protontricks.desktop" ]; diff --git a/modules/games/games.nix b/modules/games/games.nix @@ -22,7 +22,8 @@ _: { }; # Game Mode - hardware.cpu.mode = lib.mkOverride 51 "performance"; # Use 'gamemoderun %command%' + # ? # Use 'gamemoderun <command>' + hardware.cpu.mode = lib.mkOverride 51 "performance"; programs.gamemode.enable = true; hardware.steam-hardware.enable = true; }; @@ -34,9 +35,9 @@ _: { }: { # Runner xdg.dataFile."lutris/runners/wine/wine-system" = - lib.mkIf (config.apps.wine.package or null != null) + lib.mkIf (config.apps.wine or null != null) { - source = config.apps.wine.package; + source = config.apps.wine; }; # Directories diff --git a/modules/games/mc-server.nix b/modules/games/mc-server.nix @@ -1,221 +0,0 @@ -## Minecraft Server Configuration ## -# ? # Run 'systemctl start minecraft-server-NAME' to start the server -# ? # Run 'echo COMMAND > /run/minecraft/NAME.stdin' to run commands -{inputs, ...}: { - flake.modules.nixos.mc-server = { - config, - lib, - pkgs, - ... - }: let - inherit - (builtins) - attrValues - listToAttrs - toString - ; - inherit - (lib) - concatMap - mkIf - mkMerge - mkOption - types - ; - inherit (pkgs) fetchurl fetchzip linkFarmFromDrvs; - - cfg = config.games.mc-servers; - dataDir = "/srv/minecraft"; - in { - imports = [inputs.minecraft.nixosModules.minecraft-servers]; - - options.games.mc-servers = mkOption { - description = "List of Minecraft Servers"; - default = []; - type = types.listOf ( - types.submodule ( - {config, ...}: { - options = { - name = mkOption { - description = "Unique server name"; - type = types.str; - default = config.type; - }; - - type = mkOption { - description = "Server Type"; - type = types.enum [ - "fabric" - "skyblock" - ]; - default = "fabric"; - }; - - memory = mkOption { - description = "Memory (GB) allocated to server"; - type = types.int; - default = 12; - }; - - config = mkOption { - description = "Server Properties"; - type = types.attrs; - default = {}; - }; - - port = mkOption { - description = "Main server TCP port"; - type = types.int; - default = 25565; - }; - - vc-port = mkOption { - description = "Port for Simple Voice Chat"; - type = with types; nullOr int; - default = null; - }; - }; - } - ) - ); - }; - - config = mkIf (cfg != []) { - system.fs.persist.directories = [dataDir]; - networking.firewall = { - allowedTCPPorts = map (srv: srv.port) cfg; - allowedUDPPorts = concatMap (srv: - if (srv.vc-port != null) - then [srv.vc-port] - else []) - cfg; - }; - - services.minecraft-servers = { - enable = true; - inherit dataDir; - eula = true; - openFirewall = true; - managementSystem = { - tmux.enable = false; - systemd-socket.enable = true; - }; - - servers = listToAttrs ( - map (srv: { - inherit (srv) name; - value = mkMerge [ - { - enable = true; - autoStart = false; - serverProperties = - srv.config - // { - server-port = srv.port; - }; - jvmOpts = let - mem = toString srv.memory; - in "-Xms${mem}G -Xmx${mem}G --add-modules=jdk.incubator.vector -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=50 -XX:G1HeapRegionSize=16M -XX:G1ReservePercent=15"; - } - - ## Fabric Server - (mkIf (srv.type == "fabric") { - package = pkgs.fabricServers.fabric-26_1_2; - symlinks.mods = linkFarmFromDrvs "mods" ( - attrValues ( - { - # Server - FabricAPI = fetchurl { - url = "https://cdn.modrinth.com/data/P7dR8mSH/versions/NqRnXk9x/fabric-api-0.152.1%2B26.1.2.jar"; - sha256 = "sha256-slrZJsj9EH0hs6l1Gpjat4dzZSOzmke8LMsEiWJoDXY="; - }; - Lithium = fetchurl { - url = "https://cdn.modrinth.com/data/gvQqBUqZ/versions/fQBdPR1m/lithium-fabric-0.24.6%2Bmc26.1.2.jar"; - sha256 = "sha256-UJ5/dwx9SL036VkpFzKdsnaORpXHKkPiLBnvZND5g58="; - }; - Krypton = fetchurl { - url = "https://cdn.modrinth.com/data/fQEb0iXm/versions/kYAGItyj/krypton-0.3.0.jar"; - sha256 = "sha256-dFsRFgQ0dC1EQFRqp+RF0U1ZuhJG5br5kdKTGQuplGM="; - }; - FerriteCore = fetchurl { - url = "https://cdn.modrinth.com/data/uXXizFIs/versions/d5ddUdiB/ferritecore-9.0.0-fabric.jar"; - sha256 = "sha256-ITlmxy7ZZ6zHOSvrKKhm+6MB/1a5l2wueAHC233mvyI="; - }; - ScalableLux = fetchurl { - url = "https://cdn.modrinth.com/data/Ps1zyz6x/versions/gYbHVCz8/ScalableLux-0.2.0%2Bfabric.2b63825-all.jar"; - sha256 = "sha256-bamBsryRWGU1zjuw+kGXWonMRgO5w6EG0kMaIUF7HfA="; - }; - C2ME = fetchurl { - url = "https://cdn.modrinth.com/data/VSNURh3q/versions/v1RNsfu7/c2me-fabric-mc26.1.2-0.4.0-alpha.0.17.jar"; - sha256 = "sha256-W6hKW/dASyp+A9yT85luhMTg9fF59GTeYoVdRLM6Dx8="; - }; - - PlayerRoles = fetchurl { - url = "https://cdn.modrinth.com/data/Rt1mrUHm/versions/sUiL9n9i/player-roles-1.9.0.jar"; - sha256 = "sha256-0q6WzsxFdOqrslFmH8C5Si9fADgOShnBhWa4SMcBY/8="; - }; - SkinRestorer = fetchurl { - url = "https://cdn.modrinth.com/data/ghrZDhGW/versions/rgcYRGDt/skinrestorer-2.8.1%2B26.1-fabric.jar"; - sha256 = "sha256-MazpunDTQeMBLN3Da1t5akwBBXH+ia733loqgA4Ft38="; - }; - Silk = fetchurl { - url = "https://cdn.modrinth.com/data/aTaCgKLW/versions/dm3Sfg3x/silk-all-1.11.8.jar"; - sha256 = "sha256-4+u68yBi4nom7b96+PCuJvwpAnQHgtgByjTxYaF5gpM="; - }; - FabricKotlin = fetchurl { - url = "https://cdn.modrinth.com/data/Ha28R6CL/versions/Pd0xrHCw/fabric-language-kotlin-1.13.12%2Bkotlin.2.4.0.jar"; - sha256 = "sha256-NsXdi3KONHDSiCrmMRm5OiBQD8Dqb1yUXBK/ZbWrGDI="; - }; - Veinminer = fetchurl { - url = "https://cdn.modrinth.com/data/OhduvhIc/versions/h4Z7xAL0/veinminer-fabric-2.10.3.jar"; - sha256 = "sha256-/Q4M4yr/kjAMtuSyBeVbgSBMmNoCWrB4tStHSUdUSVk="; - }; - VeinminerEnchant = fetchurl { - url = "https://cdn.modrinth.com/data/4sP0LXxp/versions/6zzsM770/veinminer-enchant-2.10.3.jar"; - sha256 = "sha256-/li1ve6r0w9Mha+9tPO0Vf5mWafQghUpFzZDSEVcivs="; - }; - - # Client and Server - Jade = fetchurl { - url = "https://cdn.modrinth.com/data/nvQzSEkH/versions/zu6GcgEW/Jade-mc26.1-Fabric-26.1.6.jar"; - sha256 = "sha256-X+1RyaOSVWNyLWRGTKSJErPRYci1XFJVdcbt/rsphS8="; - }; - } - // ( - if (srv.vc-port != null) - then { - SimpleVC = fetchurl { - url = "https://cdn.modrinth.com/data/9eGKb6K1/versions/xmAicr0J/voicechat-fabric-2.6.19%2B26.1.2.jar"; - sha256 = "sha256-JsPgZqSfRb70Z00m0FN2/noc8Tm4++ncOLt0r0Z0rdQ="; - }; - } - else {} - ) - ) - ); - }) - - ## Modded Skyblock Server - (mkIf (srv.type == "skyblock") ( - let - inherit (inputs.minecraft.lib) collectFilesAt; - - # Ozone Skyblock Reborn 2 - modpack = fetchzip { - url = "https://mediafilez.forgecdn.net/files/8061/293/OSR%201.5.4%20-%20Server.zip"; - sha256 = "sha256-L9bh+MbKgKeD+RezVkmUWSK7kFiUSZrDyPLp7MrPXAY="; - }; - in { - package = pkgs.neoforgeServers.neoforge-1_21_1; - files = (collectFilesAt modpack "config") // (collectFilesAt modpack "kubejs"); - symlinks = collectFilesAt modpack "mods"; - } - )) - ]; - }) - cfg - ); - }; - }; - }; -} diff --git a/modules/games/mc-server/_mods.nix b/modules/games/mc-server/_mods.nix @@ -0,0 +1,98 @@ +## Modrinth Server Mods +# name, id, url, hash - Attribute, Project ID/slug, Download URL, SRI hash +# require - Included only when the server option is set [Optional] +{ + fabric = { + version = "26.1.2"; + mods = [ + # Server + { + name = "FabricAPI"; + id = "P7dR8mSH"; + url = "https://cdn.modrinth.com/data/P7dR8mSH/versions/NqRnXk9x/fabric-api-0.152.1%2B26.1.2.jar"; + hash = "sha256-slrZJsj9EH0hs6l1Gpjat4dzZSOzmke8LMsEiWJoDXY="; + } + { + name = "Lithium"; + id = "gvQqBUqZ"; + url = "https://cdn.modrinth.com/data/gvQqBUqZ/versions/fQBdPR1m/lithium-fabric-0.24.6%2Bmc26.1.2.jar"; + hash = "sha256-UJ5/dwx9SL036VkpFzKdsnaORpXHKkPiLBnvZND5g58="; + } + { + name = "Krypton"; + id = "fQEb0iXm"; + url = "https://cdn.modrinth.com/data/fQEb0iXm/versions/kYAGItyj/krypton-0.3.0.jar"; + hash = "sha256-dFsRFgQ0dC1EQFRqp+RF0U1ZuhJG5br5kdKTGQuplGM="; + } + { + name = "FerriteCore"; + id = "uXXizFIs"; + url = "https://cdn.modrinth.com/data/uXXizFIs/versions/d5ddUdiB/ferritecore-9.0.0-fabric.jar"; + hash = "sha256-ITlmxy7ZZ6zHOSvrKKhm+6MB/1a5l2wueAHC233mvyI="; + } + { + name = "ScalableLux"; + id = "Ps1zyz6x"; + url = "https://cdn.modrinth.com/data/Ps1zyz6x/versions/gYbHVCz8/ScalableLux-0.2.0%2Bfabric.2b63825-all.jar"; + hash = "sha256-bamBsryRWGU1zjuw+kGXWonMRgO5w6EG0kMaIUF7HfA="; + } + { + name = "C2ME"; + id = "VSNURh3q"; + url = "https://cdn.modrinth.com/data/VSNURh3q/versions/v1RNsfu7/c2me-fabric-mc26.1.2-0.4.0-alpha.0.17.jar"; + hash = "sha256-W6hKW/dASyp+A9yT85luhMTg9fF59GTeYoVdRLM6Dx8="; + } + { + name = "PlayerRoles"; + id = "Rt1mrUHm"; + url = "https://cdn.modrinth.com/data/Rt1mrUHm/versions/sUiL9n9i/player-roles-1.9.0.jar"; + hash = "sha256-0q6WzsxFdOqrslFmH8C5Si9fADgOShnBhWa4SMcBY/8="; + } + { + name = "SkinRestorer"; + id = "ghrZDhGW"; + url = "https://cdn.modrinth.com/data/ghrZDhGW/versions/rgcYRGDt/skinrestorer-2.8.1%2B26.1-fabric.jar"; + hash = "sha256-MazpunDTQeMBLN3Da1t5akwBBXH+ia733loqgA4Ft38="; + } + { + name = "Silk"; + id = "aTaCgKLW"; + url = "https://cdn.modrinth.com/data/aTaCgKLW/versions/dm3Sfg3x/silk-all-1.11.8.jar"; + hash = "sha256-4+u68yBi4nom7b96+PCuJvwpAnQHgtgByjTxYaF5gpM="; + } + { + name = "FabricKotlin"; + id = "Ha28R6CL"; + url = "https://cdn.modrinth.com/data/Ha28R6CL/versions/Pd0xrHCw/fabric-language-kotlin-1.13.12%2Bkotlin.2.4.0.jar"; + hash = "sha256-NsXdi3KONHDSiCrmMRm5OiBQD8Dqb1yUXBK/ZbWrGDI="; + } + { + name = "Veinminer"; + id = "OhduvhIc"; + url = "https://cdn.modrinth.com/data/OhduvhIc/versions/h4Z7xAL0/veinminer-fabric-2.10.3.jar"; + hash = "sha256-/Q4M4yr/kjAMtuSyBeVbgSBMmNoCWrB4tStHSUdUSVk="; + } + { + name = "VeinminerEnchant"; + id = "4sP0LXxp"; + url = "https://cdn.modrinth.com/data/4sP0LXxp/versions/6zzsM770/veinminer-enchant-2.10.3.jar"; + hash = "sha256-/li1ve6r0w9Mha+9tPO0Vf5mWafQghUpFzZDSEVcivs="; + } + + # Client and Server + { + name = "Jade"; + id = "nvQzSEkH"; + url = "https://cdn.modrinth.com/data/nvQzSEkH/versions/zu6GcgEW/Jade-mc26.1-Fabric-26.1.6.jar"; + hash = "sha256-X+1RyaOSVWNyLWRGTKSJErPRYci1XFJVdcbt/rsphS8="; + } + { + name = "SimpleVC"; + id = "9eGKb6K1"; + url = "https://cdn.modrinth.com/data/9eGKb6K1/versions/xmAicr0J/voicechat-fabric-2.6.19%2B26.1.2.jar"; + hash = "sha256-JsPgZqSfRb70Z00m0FN2/noc8Tm4++ncOLt0r0Z0rdQ="; + require = "vc-port"; + } + ]; + }; +} diff --git a/modules/games/mc-server/default.nix b/modules/games/mc-server/default.nix @@ -0,0 +1,153 @@ +## Minecraft Server Configuration ## +# ? # Run 'systemctl start minecraft-server-NAME' to start the server +# ? # Run 'echo COMMAND > /run/minecraft/NAME.stdin' to run commands +{inputs, ...}: { + flake.modules.nixos.mc-server = { + config, + lib, + pkgs, + ... + }: let + inherit + (builtins) + listToAttrs + toString + ; + inherit + (lib) + concatMap + filter + mkIf + mkMerge + mkOption + types + ; + inherit (pkgs) fetchurl fetchzip linkFarmFromDrvs; + + cfg = config.games.mc-servers; + dataDir = "/srv/minecraft"; + + # Mods + modData = import ./_mods.nix; + mkMods = srv: loader: let + mods = filter (m: !(m ? require) || (m.require == "vc-port" && srv.vc-port != null)) loader.mods; + in + linkFarmFromDrvs "mods" (map (m: fetchurl {inherit (m) name url hash;}) mods); + in { + imports = [inputs.minecraft.nixosModules.minecraft-servers]; + + options.games.mc-servers = mkOption { + description = "List of Minecraft Servers"; + default = []; + type = types.listOf ( + types.submodule ( + {config, ...}: { + options = { + name = mkOption { + description = "Unique server name"; + type = types.str; + default = config.type; + }; + + type = mkOption { + description = "Server Type"; + type = types.enum [ + "fabric" + "skyblock" + ]; + default = "fabric"; + }; + + memory = mkOption { + description = "Memory (GB) allocated to server"; + type = types.int; + default = 12; + }; + + config = mkOption { + description = "Server Properties"; + type = types.attrs; + default = {}; + }; + + port = mkOption { + description = "Main server TCP port"; + type = types.int; + default = 25565; + }; + + vc-port = mkOption { + description = "Port for Simple Voice Chat"; + type = with types; nullOr int; + default = null; + }; + }; + } + ) + ); + }; + + config = mkIf (cfg != []) { + system.fs.persist.directories = [dataDir]; + networking.firewall = { + allowedTCPPorts = map (srv: srv.port) cfg; + allowedUDPPorts = concatMap (srv: + if (srv.vc-port != null) + then [srv.vc-port] + else []) + cfg; + }; + + services.minecraft-servers = { + enable = true; + inherit dataDir; + eula = true; + openFirewall = true; + managementSystem = { + tmux.enable = false; + systemd-socket.enable = true; + }; + + servers = listToAttrs ( + map (srv: { + inherit (srv) name; + value = mkMerge [ + { + enable = true; + autoStart = false; + serverProperties = srv.config // {server-port = srv.port;}; + jvmOpts = let + mem = toString srv.memory; + in "-Xms${mem}G -Xmx${mem}G --add-modules=jdk.incubator.vector -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=50 -XX:G1HeapRegionSize=16M -XX:G1ReservePercent=15"; + } + + ## Fabric Server + (mkIf (srv.type == "fabric") { + package = pkgs.fabricServers.fabric-26_1_2; + symlinks.mods = mkMods srv modData.fabric; + }) + + ## Modded Skyblock Server + (mkIf (srv.type == "skyblock") ( + let + inherit (inputs.minecraft.lib) collectFilesAt; + + # Ozone Skyblock Reborn 2 + modpack = fetchzip { + url = "https://mediafilez.forgecdn.net/files/8061/293/OSR%201.5.4%20-%20Server.zip"; + sha256 = "sha256-L9bh+MbKgKeD+RezVkmUWSK7kFiUSZrDyPLp7MrPXAY="; + }; + in { + package = pkgs.neoforgeServers.neoforge-1_21_1; + files = (collectFilesAt modpack "config") // (collectFilesAt modpack "kubejs"); + symlinks = collectFilesAt modpack "mods"; + } + )) + ]; + }) + cfg + ); + }; + }; + }; +} diff --git a/modules/games/mc-server/update.sh b/modules/games/mc-server/update.sh @@ -0,0 +1 @@ +../../../scripts/mods.sh +\ No newline at end of file diff --git a/modules/hosts/valkyrie/_dev.nix b/modules/hosts/valkyrie/_dev.nix @@ -34,7 +34,8 @@ _: { (oldAttrs.buildCommand or "") + '' wrapProgram $out/bin/mongodb-compass \ - --add-flags "--ignore-additional-command-line-flags --password-store=gnome-libsecret" + --add-flags "--ignore-additional-command-line-flags" \ + --add-flags "--password-store=gnome-libsecret" ''; })) diff --git a/modules/hosts/valkyrie/default.nix b/modules/hosts/valkyrie/default.nix @@ -44,8 +44,9 @@ "tools" "flatpak" "latex" - #"wine" + "wine" "games" + #"libvirt" "hyprland" ]; @@ -124,9 +125,6 @@ in { # ]; # }; - # Wine utilities - # apps.wine.utilities = true; - # Minecraft Server games.mc-servers = [ { diff --git a/modules/hosts/vortex.nix b/modules/hosts/vortex.nix @@ -82,8 +82,6 @@ in { fancy = true; }; - apps.wine.utilities = true; - users.users.v7 = { isNormalUser = true; description = "V 7"; diff --git a/packages/_module.nix b/packages/_module.nix @@ -36,8 +36,6 @@ in { config = nixpkgsConfig; }; - wine = windows.packages."${system}"; - winelib = windows.lib."${system}"; spicetify = spicetify.legacyPackages."${system}"; hyprworld = hyprland.packages."${system}" // hyprsplit.packages."${system}" // hyprcursors.packages."${system}"; }) diff --git a/packages/wine/.keep b/packages/wine/.keep diff --git a/packages/wine/7zip.nix b/packages/wine/7zip.nix @@ -1,83 +0,0 @@ -{ - lib, - build, - pkgs, - wine, - ... -}: let - inherit (pkgs) copyDesktopItems fetchurl makeDesktopItem; - inherit (build) copyDesktopIcons makeDesktopIcon mkWindowsApp; -in - mkWindowsApp rec { - inherit wine; - pname = "7zip"; - version = "2601"; - src = fetchurl { - url = "https://www.7-zip.org/a/7z${version}.exe"; - sha256 = "sha256-YVl2WY+ADHCCfFpH5owrDSsX0Ei5chugccivgl0kdr0="; - }; - - dontUnpack = true; - wineArch = "win32"; - fileMap = {}; - enableInstallNotification = false; - nativeBuildInputs = [ - copyDesktopItems - copyDesktopIcons - ]; - - winAppInstall = '' - $WINE start /unix ${src} /S - wineserver -w - ''; - - winAppRun = '' - $WINE start /unix "$WINEPREFIX/drive_c/Program Files/7-Zip/7zFM.exe" "$ARGS" - ''; - - installPhase = '' - runHook preInstall - ln -s $out/bin/.launcher $out/bin/${pname} - runHook postInstall - ''; - - desktopItems = [ - (makeDesktopItem { - name = pname; - exec = pname; - icon = pname; - desktopName = "7-Zip"; - genericName = "Archive Manager"; - categories = [ - "Office" - "Utility" - ]; - mimeTypes = builtins.map (n: "application/" + n) [ - "epub+zip" - "x-zip-compressed-fb2" - "x-cbt" - "x-cb7" - "x-7z-compressed" - "vnd.rar" - "x-tar" - "zip" - ]; - }) - ]; - - desktopIcon = makeDesktopIcon { - name = "7zip"; - src = fetchurl { - url = "https://www.7-zip.org/7ziplogo.png"; - sha256 = "1nkas4wy40ffsmcji1a3gq8a61d72zp4w65jjpmqjj9wyh0j5b7q"; - }; - }; - - meta = with lib; { - description = "File Archiver with a High Compression Ratio"; - homepage = "https://www.7-zip.org/"; - license = licenses.bsd3; - platforms = platforms.linux; - maintainers = ["maydayv7"]; - }; - } diff --git a/packages/wine/notepad++.nix b/packages/wine/notepad++.nix @@ -1,85 +0,0 @@ -{ - lib, - build, - pkgs, - wine, - ... -}: let - inherit (pkgs) copyDesktopItems fetchurl makeDesktopItem; - inherit (build) copyDesktopIcons makeDesktopIcon mkWindowsAppNoCC; -in - mkWindowsAppNoCC rec { - inherit wine; - pname = "notepad-plus-plus"; - version = "8.7.3"; - src = fetchurl { - url = "https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v${version}/npp.${version}.Installer.exe"; - sha256 = "0qb8x7fy2840wvc0ypmqk0zn806va3zrpdz6cdzrqwcyn76j3ymf"; - }; - - dontUnpack = true; - wineArch = "win32"; - - fileMap = { - "$HOME/.config/Notepad++" = "drive_c/users/$USER/AppData/Roaming/Notepad++"; - }; - - enableMonoBootPrompt = false; - nativeBuildInputs = [ - copyDesktopItems - copyDesktopIcons - ]; - - winAppInstall = '' - $WINE start /unix ${src} /S - wineserver -w - rm -f "$WINEPREFIX/drive_c/Program Files/Notepad++/uninstall.exe" - rm -fR "$WINEPREFIX/drive_c/Program Files/Notepad++/updater" - ''; - - winAppRun = '' - $WINE start /unix "$WINEPREFIX/drive_c/Program Files/Notepad++/notepad++.exe" "$ARGS" - ''; - - installPhase = '' - runHook preInstall - ln -s $out/bin/.launcher $out/bin/${pname} - runHook postInstall - ''; - - desktopItems = [ - (makeDesktopItem { - name = "Notepad++"; - exec = pname; - icon = pname; - desktopName = "Notepad++"; - genericName = "Text Editor"; - mimeTypes = ["text/plain"]; - categories = [ - "Utility" - "TextEditor" - ]; - }) - ]; - - desktopIcon = makeDesktopIcon { - name = pname; - icoIndex = 2; - src = fetchurl { - url = "https://notepad-plus-plus.org/favicon.ico"; - sha256 = "1av2m6m665ccfngnzqnbsnv2aky907p2c6ggvfxrwbp70szgj9vi"; - }; - }; - - meta = with lib; { - mainProgram = pname; - homepage = "https://notepad-plus-plus.org/"; - description = "A text and source code editor"; - license = licenses.gpl3Plus; - maintainers = ["maydayv7"]; - platforms = [ - "x86_64-linux" - "i686-linux" - ]; - }; - } diff --git a/scripts/mods.sh b/scripts/mods.sh @@ -0,0 +1,122 @@ +#! /usr/bin/env nix +#! nix shell nixpkgs#bash nixpkgs#cacert nixpkgs#coreutils nixpkgs#curl nixpkgs#jq nixpkgs#nix -c bash + +set -euo pipefail + +# Script to automatically update Minecraft Server Mods from Modrinth # + +API="https://api.modrinth.com/v2" +COMMIT_PREFIX="chore(mc-server): Update" + +# Locate mod metadata file +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +DATA="${MODS_FILE:-${SCRIPT_DIR}/../modules/games/mc-server/_mods.nix}" + +if [[ ! -f "${DATA}" ]] +then + echo "Mod metadata file not found: '${DATA}'" + exit 1 +fi + +export CURL_CA_BUNDLE="${CURL_CA_BUNDLE:-$(nix eval --raw nixpkgs#cacert)/etc/ssl/certs/ca-bundle.crt}" + +# Tracking +declare -a UNAVAILABLE=() +updated=0 +uptodate=0 + +# Fetch latest version metadata for a project, target loader and game version +latest() { + local id="${1}" loader="${2}" version="${3}" + curl -s -G "${API}/project/${id}/version" \ + --data-urlencode "loaders=[\"${loader}\"]" \ + --data-urlencode "game_versions=[\"${version}\"]" \ + | jq -r ' + (sort_by(.date_published) | reverse | .[0]) as $v + | if $v == null then empty + else (($v.files | map(select(.primary)) + .)[0]) as $f + | if $f == null then empty else "\($f.url)\t\($f.hashes.sha512)" end + end + ' 2>/dev/null || true +} + +# Update every mod of a loader +process_loader() { + local loader="${1}" json version count + json="$(nix eval --json -f "${DATA}" "${loader}" 2>/dev/null || true)" + + if [[ -z "${json}" || "${json}" == "null" ]] + then + return 0 + fi + + version="$(echo "${json}" | jq -r '.version')" + count="$(echo "${json}" | jq -r '.mods | length')" + + echo "==> Loader '${loader}' (Minecraft ${version}): ${count} mods" + + local i name id oldurl oldhash result newurl sha512 newhash + for ((i = 0; i < count; i++)) + do + name="$(echo "${json}" | jq -r ".mods[${i}].name")" + id="$(echo "${json}" | jq -r ".mods[${i}].id")" + oldurl="$(echo "${json}" | jq -r ".mods[${i}].url")" + oldhash="$(echo "${json}" | jq -r ".mods[${i}].hash")" + + result="$(latest "${id}" "${loader}" "${version}")" + newurl="$(echo "${result}" | cut -f1)" + sha512="$(echo "${result}" | cut -f2)" + + if [[ -z "${result}" || "${newurl}" == "null" || -z "${newurl}" || "${sha512}" == "null" ]] + then + echo " ✗ ${name}: no build for Minecraft ${version}" + UNAVAILABLE+=("${name} (${loader} ${version})") + continue + fi + + if [[ "${newurl}" == "${oldurl}" ]] + then + echo " = ${name}: up to date" + ((uptodate += 1)) || true + continue + fi + + newhash="$(nix hash convert --hash-algo sha512 --to sri "${sha512}")" + + sed -i "s|${oldurl}|${newurl}|" "${DATA}" + sed -i "s|${oldhash}|${newhash}|" "${DATA}" + + echo " ↑ ${name}: updated" + ((updated += 1)) || true + done + + # Commit per loader + if [[ "${COMMIT:-true}" == "true" ]] + then + git -C "$(dirname "${DATA}")" diff-index --quiet HEAD "${DATA}" 2>/dev/null || \ + git -C "$(dirname "${DATA}")" commit -q -n "${DATA}" \ + -m "${COMMIT_PREFIX} \`${loader}\` mods" || true + fi +} + +# Execution +echo "Checking for Mod Updates..." + +# Iterate over every defined loader +mapfile -t LOADERS < <(nix eval --json -f "${DATA}" 2>/dev/null | jq -r 'keys[]') +for loader in "${LOADERS[@]}" +do + process_loader "${loader}" +done + +# Summary +echo +echo "Summary: ${updated} updated, ${uptodate} up to date, ${#UNAVAILABLE[@]} unavailable" +if (( ${#UNAVAILABLE[@]} > 0 )) +then + echo "Could not update to the target Minecraft version:" + for m in "${UNAVAILABLE[@]}" + do + echo " - ${m}" + done +fi diff --git a/scripts/nixos.nix b/scripts/nixos.nix @@ -96,7 +96,6 @@ in tree gnupg sops - wine.mkwindowsapp-tools nixFlakes cachix @@ -242,7 +241,6 @@ in ;; "clean") echo "Running Garbage Collection..." - mkwindows-tools-gc nix-collect-garbage -d rm -rf /nix/var/nix/profiles/per-user/"$USER"/profile if [ "$EUID" -ne 0 ] && [ "$2" != "--all" ]