Skip to content

Instantly share code, notes, and snippets.

@huantianad
Last active November 27, 2024 13:19
Show Gist options
  • Save huantianad/7c2fcd56d6f60c7a936ed37fbfb24ed6 to your computer and use it in GitHub Desktop.
Save huantianad/7c2fcd56d6f60c7a936ed37fbfb24ed6 to your computer and use it in GitHub Desktop.
Unity Editor and Jetbrains Rider on NixOS

Unity Editor and Jetbrains Rider on NixOS

Just a small guide kinda thing on how to develop for Unity on NixOS, at least my journey in this space. If you find anything else to add or any steps I missed here, please mention in the comments!

Rider

Rider needs access to MSBuild, .NET, and Mono in order to do code analysis. I found that manually setting the paths inside of Rider never worked correctly, so I instead wrapped Rider in a FHSUserEnv.

I have a workaround to allow rider to be detected by the Unity Rider plugin, which allows you to set Rider as the external editor in Unity, and now works with Rider's Advanced Unity Integration!

Unity Hub

Unity Hub downloads and manages Unity verisons and projects.

At time of writing, the Unity Hub in the nixpkgs repositories is out of date, my up to date version can be found here. As far as I can tell the hub itself is working fine.

Unity Editor

Unity Editors can be installed like normal from the Unity Hub, I haven't encountered any issues with licenses and such.

There is a big issue with Unity 2022.3.7 for me: the editor seems to crash whenever it tries to open a subwindow with a GTK related error. Likely due to NixOS, might be a similar issue to the Bug Reporter? Forum thread with the error, also mentioned in the github issue.

EDIT: This seems like not a NixOS specific issue, see the Unity bug report.

Unity Bug Reporter

This will seem to work until you click the "Preview" button or submit the report, at which time it will try to open a dialogue box and crash. This is because it uses bundled QT plugins instead of system ones, which have the proper NixOS OpenGL driver paths. You can fix this by creating a qt.conf file next to the bug reporter executable (found here Unity/Hub/Editor/2021.3.6f1/Editor/BugReporter/) containing correct paths:

[Paths]
# Replace /nix/store/2javgjyi0jj3irq2rk37c6j6hzqc0h4w-qt-full-5.15.5/ with ${pkgs.libsForQt5.full}
Plugins = /nix/store/2javgjyi0jj3irq2rk37c6j6hzqc0h4w-qt-full-5.15.5/lib/qt-5.15.5/plugins
QmlImports = /nix/store/2javgjyi0jj3irq2rk37c6j6hzqc0h4w-qt-full-5.15.5/lib/qt-5.15.5/qml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment