NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.46k stars 12.95k forks source link

Package request: NetRadiant #306160

Open NateEag opened 2 months ago

NateEag commented 2 months ago

Project description

Level editor for the open-source arena FPS Xonotic.

Metadata


Add a :+1: reaction to issues you find important.

5225225 commented 1 month ago

In case it's helpful, I have 80% of a package.nix written for netradiant. It still needs a bit of work to not hardcode the extra-urls.txt (and probably to fetch not just the xonotic game pack (and also to package the mapping support files)), but this seems to indeed work, and is enough to get it running.

{ 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
  '';
NateEag commented 1 month ago

cool, thanks @5225225 ! Much appreciated!