Godot, Android, NixOS

by Tim

Exporting Android project from Godot was an interesting experience, as it covered a lot of the "essentials" in using NixOS day-to-day. Here's the general thought process I went through.

I didn't want to install the whole Android SDK simply to...not really use it and just export APKs. I'm not exactly sure if that would have made things easier or harder since I didn't even go down that path.

But I added:

to my home.packages in home.nix

home.packages = with pkgs; [
   # ... other software ...

   #Godot stuff
   android-tools
   sdkmanager
   godot_4
   openjdk17-bootstrap

   # ... other software ...
];

I then ran

sudo sdkmanager --sdk_root="android_sdk_path" "platform-tools" "build-tools;33.0.2" "platforms;android-33" "cmdline-tools;latest" "cmake;3.10.2.4988404" "ndk;23.2.8568313"

Yes, as root. Yes literally --sdk_root="android_sdk_path" I just copied it from the Godot website, I'm not even sure that half of that is needed or wanted?

sudo chown -R <username> /opt/android-sdk

More reckless sudo usage.

Then added

  programs.nix-ld.enable = true;
  programs.nix-ld.libraries = with pkgs; [
    # Add any missing dynamic libraries for unpackaged programs
    # here, NOT in environment.systemPackages
	aapt
    gradle
  ];

into my configuration.nix file

I had initially just added aapt, since that's what Godot was choking on during the export. I then added gradle. I'm not sure if I still need the aapt line, but I'm too lazy to delete that line. It works, and that's all that matters.