How can I perform modifications on host system from a flatpak install?

'm building a flatpak and wish to run some commands on the host machine (among other things: I wish/need to add the current user to the uinput group).

I tried adding post-install commands to do this but when trying to build, I’m getting: “sudo command not found”. I am guessing that this is because the command is ran in the sandbox and that sandbox doesn’t have the sudo binary? Any suggestion on how should I proceed/what is the best practice for performing changes on the system host from a flatpak?

Note, I also tried prefixing the commands with flatpak-spawn --host but then I’m getting: Can’t find bus: Cannot autolaunch D-Bus without X11 $DISPLAY. Exporting DISPLAY=:0 before running the post-install script, then I got: Failed to execute child process “dbus-launch”.

No, there’s no way to run unsandboxed code during installation. post-install is run after the install phase on the build machine, not the target.

If you have the permission needed to use flatpak-spawn --host, there’s nothing stopping you from using it from a wrapper script at run time. Though doing something that requires superuser access would be, I think, taking things too far.

Your best option is probably to document that the user needs to add themself to that group.