Skip to content

lua: iterate over elements deterministically#58

Merged
tesselslate merged 1 commit into
tesselslate:mainfrom
bmwiedemann:sort
May 5, 2026
Merged

lua: iterate over elements deterministically#58
tesselslate merged 1 commit into
tesselslate:mainfrom
bmwiedemann:sort

Conversation

@bmwiedemann
Copy link
Copy Markdown
Contributor

lua: iterate over elements deterministically
to allow for reproducible builds.
See https://reproducible-builds.org/ for why this is good.

Without this patch, /usr/bin/waywall had variations in the order of strings "load", "state"

This patch was done while working on reproducible builds for openSUSE.

Note: I don't know lua well and only tested that it builds and binary/string diffs look sane.

@tesselslate
Copy link
Copy Markdown
Owner

tesselslate commented May 2, 2026

I can replicate the non-deterministic output (at least the output of build/waywall/lua/api.h changing), but this patch doesn't fix it for me.

Can you confirm if this patch does?

diff --git a/waywall/lua/api.lua b/waywall/lua/api.lua
index 95664bf..fd15145 100644
--- a/waywall/lua/api.lua
+++ b/waywall/lua/api.lua
@@ -36,11 +36,10 @@ local function event_handler(name)
     end
 end
 
-local events = {
-    ["load"] = event_handler("load"),
-    ["resolution"] = event_handler("resolution"),
-    ["state"] = event_handler("state"),
-}
+local events = {}
+events.load         = event_handler("load")
+events.resolution   = event_handler("resolution")
+events.state        = event_handler("state")
 
 local M = {}
 

@bmwiedemann
Copy link
Copy Markdown
Contributor Author

bmwiedemann commented May 4, 2026

edit: your patch helps for one of two issues and my original sorting patch did indeed not help. I force-pushed a better version now.

@bmwiedemann
Copy link
Copy Markdown
Contributor Author

bmwiedemann commented May 4, 2026

or there is only a different diff left:

--- old /usr/bin/waywall (objdump)
+++ new /usr/bin/waywall (objdump)
@@ -15231,8 +15231,8 @@
  3cfc0 72720000 16007000 00040302 00072cba  rr....p.......,.
  3cfd0 01022d00 01003900 00002d02 02003503  ..-...9...-...5.
  3cfe0 01004200 03022e00 00004b00 01000a80  ..B.......K.....
- 3cff0 0bc000c0 01000306 78030a09 73697a65  ........x...size
- 3d000 03010679 030a0974 65787401 01010101  ...y...text.....
+ 3cff0 0bc000c0 01000309 73697a65 03010679  ........size...y
+ 3d000 030a0678 030a0974 65787401 01010101  ...x...text.....
  3d010 01026175 746f6765 6e5f7465 78740077  ..autogen_text.w
  3d020 61797761 6c6c0061 75746f67 656e5f6e  aywall.autogen_n
  3d030 6f746963 650000c6 0a030011 001d0045  otice..........E

from variations in lua/init.h

to behave in a deterministic way.

See https://reproducible-builds.org/ for why this is good.

Co-Authored-By: tesselslate
@tesselslate tesselslate merged commit 7fe2591 into tesselslate:main May 5, 2026
@tesselslate
Copy link
Copy Markdown
Owner

Thanks for the PR!

@bmwiedemann bmwiedemann deleted the sort branch May 6, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants