Recently, I’ve been intending to get back into the swing of things when it comes to roleplaying games, specifically the pen & paper kind. In preparation for this, I’ve decided to dust off Dungeondraft which was and remains my mapmaking software of choice, but ran into some issues. This is partially due to my recent switch to NixOS which is lacking a FHS environment that Dungeondraft expects.

Now, I could have simply used steam-run for this, which is a tool that creates a FHS environment, but for some reason that just didn’t feel right or… clean? so I decided to create a private package for this. I managed to get it mostly working on my own, which was nice to see, but there was a slight problem: none of the dialogs for things like saving or loading previous maps would open. This was a bit of an odd thing to try to debug, since even when ran through the terminal there was no error output indicating what the issue was. Luckily though, after some frustration, I found out someone else had tried packaging Dungeondraft before me, though it was an outdated version and it never ended up getting merged into nixpkgs; it did, however, include the thing I had missed out on myself: zenity. After some finagling, I ended up with a package that looks like this:

{ stdenv, lib, requireFile, autoPatchelfHook, unzip, makeWrapper,
libxcursor, libxinerama, libxext, libxrandr, libxrender, libx11, libxi, libglvnd, libz, krb5, systemd, alsa-lib, zenity
}:
stdenv.mkDerivation rec {
	name = "Dungeondraft";
	binaryName = "${name}.x86_64";
	pname = "dungeondraft";
	version = "1.2.0.1";

	buildInputs = [ libxcursor libxinerama libxext libxrandr libxrender libx11 libxi libglvnd libz krb5 ];
	nativeBuildInputs = [ autoPatchelfHook unzip makeWrapper ];
	runtimeDependencies = [ systemd alsa-lib zenity ];

	src = requireFile {
		name = "Dungeondraft-${version}-Linux64.zip";
		url = "https://dungeondraft.net";
		hash = "sha256-SMNQ7XWSca2G4pieWFV97NMLv2Plqzu2bQlRC5MUwCY=";
	};

	dontBuild = true;
	sourceRoot = ".";

	installPhase = ''
		runHook preInstall
		mkdir -p $out/opt/${name} $out/share/applications $out/bin
		mv ${name}.desktop $out/share/applications
		mv * $out/opt/${name}
		chmod +x $out/opt/${name}/${binaryName}
		substituteInPlace $out/share/applications/${name}.desktop \
			--replace-fail Exec=/opt/${name}/${binaryName} Exec=${pname} \
			--replace-fail /opt/ $out/opt/
		makeWrapper $out/opt/${name}/${binaryName} $out/bin/${pname} \
			--prefix PATH : "${lib.makeBinPath [ zenity ]}" \
			--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath (buildInputs ++ runtimeDependencies)}"
		runHook postInstall
	'';
}

Now, I would imagine someone better versed in the intricacies of the nix-language might find the code on display abhorrent, but on a personal note I’m just happy to have gotten it functioning in a reproducible manner. Due to the proprietary nature of the software, I do need to manually add it into the store prior to installation, since I don’t want to figure out some sort of private distribution method for the zip, but that is a manageable inconvenience.

As for the next issue, it was a bit more annoying to track down. Turns out, there seems to be a bug in the Linux-version of Dungeondraft, where when initially creating thumbnails for larger asset packs, it can just hang. The work-around for this is running it single-core for the thumbnail generation, and once those are cached you can start making use of all of your cores again, so this was a simple taskset -c 0 dungeondraft and load the assets for me, but figuring out why it was happening was annoying; I first thought there was something wrong with the asset packs themselves, since disabling some seemed to work sometimes.

All of that work done, it has been quite nice getting back into mapmaking, I don’t think I quite realized how much I missed that creative outlet. I’ve started on simply building out a random map I generated and it’s fun to take a look at the different corridors and rooms that such a tool spits out and try to figure out a meaning for them. The pre-assigned meanings and descriptions can be quite, well, random, so it has been fun to take it as a base and try to figure out a deeper meaning and theme to the whole thing and try to create something coherent out of it. I’m still only starting out, but it’s been fun so far; though I am also feeling the itch to just create something form scratch, so we’ll see what ends up happening first. Luckily (or unluckily) I’m in no real hurry to get any of this done since I don’t have a game at the moment to use any of it for, but just the process of creating is fun so that doesn’t matter that much (though naturally it would be nice to have a game to play these places out in). Hopefully it doesn’t take too long before one of those materializes as well, but until then I’ll have fun building out these places.