Following vtrlx’s tutorial about writing GNOME apps with Lua
This one: https://www.vtrlx.ca/posts/2025/howto-complete-lua-gnome-app/
I’m on Mint.
Background
I’m a developery type but I would describe myself as a “casual Linux user”. My software background is Java (largely minecraft) and web stuff. I know a little about sysadmin, but not that much.
I’ve used a little bit of Lua, mainly to write a Pandoc filter (and some totally dead NotITG projects).
I’ve never worked with flatpak before. I’m coming in with a somewhat negative opinion of it (due to its sandboxing breaking a program I wanted to use, in a mysterious and hard-to-debug way) but I am interested in learning more.
What does she have me installing
I popped open Software Sources and checked “Source code repositories”. Dunno if I actually needed to do that! Can’t hurt.
- Lua 5.4 is the latest lua at the moment. It seems like 5.5 is on the horizon (but it probably won’t get packaged in mint for a while).
- “luarocks” is a lua package manager.
libgirepositoryis a library for something called “GObject Introspection” I think? It allows writing nice foreign-function interfaces to GNOME apis (such as that LuaGObject library vtrlx maintains)- TODO: Learn a little more about GNOME, glib, GObject etc
flatpak-builderis a build system for Flatpak-managed programs- BIG TODO: Find out what this does. Why does the flatpak world need something custom?
I’m already in version hell lmao
I installed lua5.4. I have a lua5.4 command. Okay.
I already somehow installed a mystery /usr/bin/lua which is actually 5.1, and I have a lua5.1 command.
I ask doctor how to find which package installed a program. Doctor says dpkg-query -S is in town. But Doctor,
quat@moon:~$ dpkg-query -S /usr/bin/lua
dpkg-query: no path found matching pattern /usr/bin/lua
quat@moon:~$ /usr/bin/lua
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
Whatever man!!!
I think the reason I have this in the first place is that whoever packaged luarocks for Debian made it depend on lua5.1 | lua5.2 | lua5.3, but not lua5.4 (and/or they’re packaging a version that doesn’t work on 5.4).
Okay, there is an update-alternatives system, I’m familiar with this from Java. I think this is the right way to do it:
quat@moon:~$ sudo update-alternatives --set lua-interpreter /usr/bin/lua5.4
update-alternatives: using /usr/bin/lua5.4 to provide /usr/bin/lua (lua-interpreter) in manual mode
quat@moon:~$ sudo update-alternatives --set lua-compiler /usr/bin/luac5.4
update-alternatives: using /usr/bin/luac5.4 to provide /usr/bin/luac (lua-compiler) in manual mode
I found these through update-alternatives --get-selections | grep lua. Idk if there’s a better way to find these.
And then remember to use luarocks-5.4 instead of just luarocks so it also uses the right version, beacuse the unadorned command uses the fucking Lua 5.1. Why is there no update-alternatives for the luarocks?
Also where do the packages go!! I’m curious!! I guess they call it a “rocks tree”?
This is my hangup:
- When I use something like Gradle in Java, I specify a complete set of the dependencies I want for this specific project. The files get downloaded into some global cache directory, but I don’t need to care what’s inside, and Gradle only tells the JVM about the locations of the specific files I asked for.
- When I use luarocks, first I do
luarocks install luagobjectand then through some other apparently-unrelated mechanism I can use it from every lua program withrequire "LuaGObject". It’s stateful.
Lua has some bonkers require semantics I’ll need to figure out, I guess.
I can’t luarocks-5.4 install luagobject because of
Error: Failed finding Lua header files. You may need to install them or configure LUA_INCDIR.
- When I run the fucked up
luarocks-5.1without any subcommand, it reportsLUA_INCDIRis/usr/include/lua5.1in the debug printout stuff at the bottom. - I didn’t have a corresponding folder for lua 5.4.
- I ran
apt install liblua5.4-devand now I do!
Okay, now I can luarocks-5.4 install luagobject. (It seemed to invoke gcc and make so I imagine if this isn’t working build-essential would be a good package to install.)
getting my flatpak bearings
I know Mint ships with “flatpak support” – not sure exactly what that entails but I didn’t think I’d need to manually configure Flathub as a remote. Sure enough, flatpak remotes --columns=name,url mentions a flathub remote already, same URL, good to go :)
Let’s get sidetracked looking through flatpak list.
- Some programs I recognize installing thru Software Manager like Flatseal and Krita.
- Some “VAAPI drivers” and codecs. Interesting that these are packaged through flatpak?
Mint-Y-Red Gtk Theme. This matches my system theme thru the “Themes” application.- Changing the theme and rerunning
flatpak listdidn’t change anything but maybe it would if I bothered to relog or reboot.
- Changing the theme and rerunning
- “GNOME Application Platform version 49”.
- Maybe preinstalled or maybe pulled in as a Flatseal dep (which is a gnome application)
I saw mention of a user-specific flatpak (as opposed to a system-wide flatpak) available thru flatpak --user, but flatpak --user list and flatpak --user remotes list nothing so I don’t think I’ve installed any of those yet.
But I do need to get the “gnome sdk” which is different than the Platform. From what little Flatpak-documentation I’ve read so far, flatpak-builder wants to build your things “in a separate environment”. I guess this is related to when people build their shit in a docker container? Because the Gnome SDK exists, I didn’t have to install packages like libgirepository system-wide to compile my stuff, it’d (presumably) be part of the SDK if I built and ran the program “through Flatpak”.
Okay let’s actually do it
At this point I was able to successfully write require "LuaGObject" and run it
I just followed the first bit of tutorial as-written and have an empty window with titlebar I can drag around, maximize, and close. Hurrah. If I put my computer in 🤮dark theme🤮 the background even turns black.
Well this is downright pleasant, compared to my experience with the Windows api. Lol.
Haven’t touched anything flatpakky yet.