Subject:

Getting started mapping with netradiant


Date: Message-Id: https://www.5snb.club/posts/2024/getting-started-mapping/

This is not a tutorial, since I barely know how to do this myself. Just a fun little thing. I’m planning to make funny little defrag maps after playing defrag for at least 5 years.

Also a package.nix for netradiant, since it’s not packaged currently. (Someone should go clean this up and upstream it into nixpkgs :3).

me in xonotic standing on some cubes in a test map i made

a ramp you can jump off to reach the finish on top of a sphere. the ramp has a light blue light under it

If you really want, you can download the source, but it’s not packaged and I have no idea if it uses textures that aren’t in the base game. Figure it out yourself, I guess :)

Lastly: the package.nix. This is definitely not the best way to do this, but it builds a functioning netradiant. The starting point for this was the upstream flake.nix in netradiant.

{ stdenv, fetchFromGitLab, fetchurl, pkgs }:

let
  xonoticGamepack = fetchFromGitLab {
    owner = "xonotic";
    repo = "netradiant-xonoticpack";
    rev = "6f897a4dd5faa85014bfc841cd78df11a9934996";
    hash = "sha256-w9RSzyDxv5QU4RXP82/acJjCgsVqY8Ct/pyHOvz1mmE=";
    name = "netradiant-xonoticpack";
  };

  # HACK: we really ought to be reading extra-urls here. this works for now thought.
  xonoticGamepackEntities = fetchurl {
    url = "https://gitlab.com/xonotic/xonotic-maps.pk3dir/-/raw/master/scripts/entities.ent";
    hash = "sha256-onqcEyji3tzaSvjuX8M3KC/IZJU2edCF92rlo8lgA/8=";
  };

  netRadiant = fetchFromGitLab {
    owner = "xonotic";
    repo = "netradiant";
    rev = "757a17fb340bc80cbf8a3ee576e75f56fc7a55c8";
    hash = "sha256-A6y1mFYmalR25pMP/IVicjfPyADJ7VyKR2BTDQB5wJg=";
    fetchSubmodules = true; # needed for BUILD_CRUNCH=ON
    name = "netradiant";
  };
in
stdenv.mkDerivation {
  name = "netradiant";

  srcs = [ xonoticGamepack netRadiant ];
  sourceRoot = "netradiant";

  cmakeFlags = [
    "-DGIT_VERSION=nix" # meh
      "-DDOWNLOAD_GAMEPACKS=OFF"
      "-DBUNDLE_LIBRARIES=OFF" # doesn't work for some reason
      "-DBUILD_CRUNCH=ON"
      "-DBUILD_RADIANT=ON"
      "-DBUILD_TOOLS=ON"
      "-DFHS_INSTALL=ON"
  ];

  postUnpack = ''
    mkdir -p netradiant/build/download
    cp -r --no-preserve=mode netradiant-xonoticpack netradiant/build/download/XonoticPack
    cp ${xonoticGamepackEntities} netradiant/build/download/XonoticPack/xonotic.game/data/entities.ent

    bash netradiant/gamepack-manager --name Xonotic --install -dd netradiant/build/download -id netradiant/build
  '';

  buildInputs = with pkgs; [
    pkg-config gtk2 glib libwebp libxml2 minizip
  ];

  nativeBuildInputs = with pkgs; [
    cmake subversion unzip
      python3 python311Packages.pyyaml pcre2 libGL gnome2.gtkglext
  ];

  postFixup = ''
    mkdir -p $out/share/netradiant/gamepacks
    cp -r games $out/share/netradiant/gamepacks/
    cp -r xonotic.game $out/share/netradiant/gamepacks
  '';
}

You’ll need to go find the engine path manually. That could probably be fixed by making netradiant take a dependency on xonotic, but that feels a bit weird. 🤷.