I made a nix flake to package the playdate sdk

the repo

Its normally very irritating to get playdate-sdk running on NixOS. This is because NixOS expects every binary to be packaged, and any dynamic linking must be done through the nix language. I took the example I gave in the previous thread and completely automated the process with a flake. If you have nix installed you can now install the playdate sdk using

nix shell github:RegularTetragon/playdate-sdk-flake#default

this will temporarily install the playdate-sdk in an ephemeral shell, giving you access to pdc, pdutil, and PlaydateSimulator. It does this by locally downloading https://download.panic.com/playdate_sdk/Linux/PlaydateSDK-2.5.0.tar.gz, unzipping it, telling nix what dynamic dependencies it requires, and outputting the binaries, nix shell then inserts those binaries into your $PATH.

There is an example project as well, which is the Hello World example from the sdk being built with CMake. Even if you don't have the SDK currently installed anywhere on your computer, nix allows you to do this:

git clone https://github.com/RegularTetragon/playdate-sdk-flake
cd playdate-sdk-flake/example
nix run

this will download the sdk, build the example project, and start the hello world project inside PlaydateSimulator

Caveats

The Playdate Simulator really wants to write to the directory its installed in. This means the default Launcher.pdx refuses to open if you run PlaydateSimulator with no arguments as Its impossible to write to installation locations in NixOS. Also, if your game tries to write any files it may fail. I've begun work on a wrapper for playdate simulator called, creatively, pdwrapper. The intention behind this is to either convince PlaydateSimulator that its actually running from a subdirectory called .PlaydateSDK, or to convince it that it can write to the nix store but instead have those changes apply to some overlayfs. It would be very nice if you could set a different disk on PlaydateSimulator (maybe I should make a feature request), but I'm not gonna hold my breath, NixOS is a niche of a niche so I understand if that change would be too difficult.

License Notes

Note: This script automatically downloads the binaries from the playdate website, it doesn't republish them anywhere, all it does is automate the steps of a normal install of the PlaydateSDK and package it to be suitable for NixOS. I believe that's within the Playdate SDK license. The code in the example is under BSD Zero Clause, and the code of the flake itself is MIT licensed. These should be permissive enough for you to do whatever you want with the nix scripts, but not with the Playdate SDK itself. Don't use this flake if you don't agree to follow The Playdate SDK License. Based on the previous thread I believe I'm in the clear but if there are any issues with licensing I'll try to modify my flake to stay within the sdk license.