| name | minecraft-mods |
| description | Minecraft Mod Management for NixOS (Packwiz) |
Minecraft Mod Management for NixOS (Packwiz)
Overview
This skill helps manage Minecraft server mods in the NixOS configuration using packwiz as the source of truth. The minecraft-server.nix module automatically parses packwiz .pw.toml files to build the server modpack.
File Locations
- Server Module:
/home/curtbushko/workspace/github.com/curtbushko/nixos-config/modules/nixos/services/minecraft/minecraft-server.nix
- Packwiz Modpack:
/home/curtbushko/workspace/github.com/curtbushko/nixos-config/modules/nixos/services/minecraft/modpack/
pack.toml - Modpack metadata (Minecraft version, Fabric version)
index.toml - Auto-generated index of all mods (managed by packwiz)
mods/*.pw.toml - Individual mod metadata files with URLs and hashes
- Update Script:
/home/curtbushko/workspace/github.com/curtbushko/nixos-config/modules/nixos/services/minecraft/packwiz-update.sh
- README:
/home/curtbushko/workspace/github.com/curtbushko/nixos-config/modules/nixos/services/minecraft/README.md
How It Works
Architecture
The minecraft-server.nix module uses a functional approach to build the modpack:
- Parsing .pw.toml files: The
parseModToml function reads each mod's .pw.toml file
- Server-side filtering: Only includes mods where
side = "both" or side = "server"
- Hash verification: Supports sha256, sha512, and sha1 hash formats
- Automatic building: Creates a
linkFarmFromDrvs with all server mods
# Key components from minecraft-server.nix
parseModToml = tomlFile: let
tomlContent = builtins.fromTOML (builtins.readFile tomlFile);
isServerMod = tomlContent.side == "both" || tomlContent.side == "server";
# ... hash handling ...
in
if isServerMod
then pkgs.fetchurl { url = ...; sha512 = ...; name = ...; }
else null;
# All server mods automatically loaded
serverMods = builtins.filter (mod: mod != null) (
map (file: parseModToml (modpackPath + "/mods/${file}"))
(builtins.filter (file: lib.hasSuffix ".pw.toml" file) modFiles)
);
Packwiz Workflow
Packwiz manages mod metadata in .pw.toml files. Each file contains:
- Download URL (typically Modrinth CDN)
- Filename
- Hash (for verification)
- Side (client, server, or both)
- Update information
Common Operations
Prerequisites
All packwiz commands should be run in the modpack directory:
cd /home/curtbushko/workspace/github.com/curtbushko/nixos-config/modules/nixos/services/minecraft/modpack
You can run packwiz via nix-shell:
nix-shell -p packwiz --run "packwiz <command>"
nix-shell -p packwiz
Adding a Mod
packwiz modrinth add <mod-slug>
packwiz modrinth add sodium
packwiz modrinth add -y sodium
packwiz curseforge add <mod-name>
Packwiz will:
- Download mod metadata
- Create a
.pw.toml file in mods/
- Update
index.toml automatically
- Prompt for required dependencies (unless using
-y)
Removing a Mod
packwiz remove <mod-name>
packwiz remove sodium
Updating Mods
Update all mods:
packwiz update --all
cd /home/curtbushko/workspace/github.com/curtbushko/nixos-config/modules/nixos/services/minecraft
./packwiz-update.sh
Update a specific mod:
packwiz update <mod-name>
The packwiz-update.sh script:
Listing Mods
packwiz list
packwiz list | wc -l
Refreshing Index
After manually editing .pw.toml files:
packwiz refresh
Changing Minecraft Version
To upgrade to a new Minecraft version (e.g., 1.20.1 → 1.21.1):
1. Update pack.toml:
cd modpack
nano pack.toml
2. Update all mods for new version:
packwiz refresh
cd ..
./packwiz-update.sh
3. Update server package in minecraft-server.nix:
# Change from:
package = pkgs.fabricServers.fabric-1_20_1;
# To:
package = pkgs.fabricServers.fabric-1_21_1;
# Note: Use underscores, not dots!
4. Check for mods without 1.21.1 versions:
The packwiz-update.sh script will report mods stuck on older versions. You may need to:
- Find alternative mods
- Wait for mod updates
- Use compatibility layers (e.g., Sinytra Connector for NeoForge mods)
Understanding .pw.toml Files
Example mod file (mods/sodium.pw.toml):
name = "Sodium"
filename = "sodium-fabric-0.6.5+mc1.21.1.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/AANobbMI/versions/abc123/sodium-fabric-0.6.5+mc1.21.1.jar"
hash-format = "sha512"
hash = "abc123..."
[update]
[update.modrinth]
mod-id = "AANobbMI"
version = "abc123"
Key fields:
side - Determines if mod loads on server: "both", "server", or "client"
download.url - Direct download URL (usually Modrinth CDN)
download.hash-format - Hash type (sha256, sha512, or sha1)
download.hash - Hash for verification
update.modrinth.mod-id - Used by packwiz to check for updates
Client Modpack
The packwiz modpack can be shared with clients:
Option 1: Packwiz Installer (Recommended)
Clients run packwiz-installer in their .minecraft directory to auto-download all client-compatible mods.
Option 2: Export to modpack format
cd modpack
packwiz modrinth export
packwiz curseforge export
Troubleshooting
Mod not found for Minecraft version
Some mods may not support the target version yet:
packwiz modrinth search <name>
Dependencies
Packwiz prompts for dependencies automatically:
Mod X requires dependency Y. Install? [Y/n]
Use -y flag to auto-accept: packwiz modrinth add -y <mod>
Side Configuration
If a mod should be server-only but packwiz marks it as "both":
- Edit the
.pw.toml file manually
- Change
side = "both" to side = "server"
- Run
packwiz refresh
NixOS Build Integration
When you rebuild NixOS:
- The module reads all
.pw.toml files in modpack/mods/
- Filters for server-compatible mods (
side = "both" or side = "server")
- Downloads and verifies each mod using hashes
- Creates symlink farm for the Minecraft server
No manual hash management needed - packwiz handles all hashes automatically!
Resource Packs and Datapacks
These are still manually configured in minecraft-server.nix:
Resource packs (lines 54-115):
resourcepacks = pkgs.linkFarmFromDrvs "resourcepacks" [
(pkgs.fetchurl { url = "..."; sha512 = "..."; name = "..."; })
];
Datapacks (lines 118-125):
datapacks = pkgs.linkFarmFromDrvs "datapacks" [
(pkgs.fetchurl { url = "..."; sha512 = "..."; name = "..."; })
];
These can be found on Modrinth but aren't managed by packwiz in this configuration.
Critical Checklist
When working with Minecraft server mods:
- ✓ Always work in the
modpack/ directory for packwiz commands
- ✓ Use
packwiz modrinth add to add mods (not manual editing)
- ✓ Use
packwiz-update.sh for bulk updates with progress tracking
- ✓ Check
side field in .pw.toml - client-only mods won't load on server
- ✓ Update
pack.toml Minecraft version before migrating versions
- ✓ Update server package in minecraft-server.nix to match Minecraft version
- ✓ Let packwiz handle all dependencies automatically
- ✓ Don't manually edit index.toml (auto-generated)
- ✓ NixOS rebuild will automatically pick up packwiz changes
Quick Reference
cd /home/curtbushko/.../nixos-config/modules/nixos/services/minecraft/modpack
nix-shell -p packwiz --run "packwiz modrinth add <slug>"
nix-shell -p packwiz --run "packwiz remove <name>"
cd .. && ./packwiz-update.sh
nix-shell -p packwiz --run "packwiz list"
Resources