Skip to content

Fix running under Flatpak with a NixOS host.#236

Open
shymega wants to merge 2 commits intodevfrom
shymega/fix-flatpak-nixos-host
Open

Fix running under Flatpak with a NixOS host.#236
shymega wants to merge 2 commits intodevfrom
shymega/fix-flatpak-nixos-host

Conversation

@shymega
Copy link
Copy Markdown
Member

@shymega shymega commented Jan 25, 2026

No description provided.

@shymega shymega self-assigned this Jan 25, 2026
@shymega shymega requested a review from marvin1099 February 22, 2026 18:37
@shymega shymega force-pushed the shymega/fix-flatpak-nixos-host branch from b5f24c1 to 97dc902 Compare February 23, 2026 20:22
@shymega shymega marked this pull request as ready for review February 24, 2026 00:21
Comment thread src/coreutils.py
Comment thread src/setup.py
Comment thread src/setup.py
@shymega shymega force-pushed the shymega/fix-flatpak-nixos-host branch 5 times, most recently from e721203 to c797f7b Compare March 7, 2026 22:15
@shymega shymega changed the base branch from main to dev March 7, 2026 22:25
@shymega shymega force-pushed the shymega/fix-flatpak-nixos-host branch from c797f7b to 6b012d1 Compare March 7, 2026 22:29
@shymega shymega force-pushed the shymega/fix-flatpak-nixos-host branch 2 times, most recently from e721203 to fd4fdbf Compare March 20, 2026 20:37
@marvin1099
Copy link
Copy Markdown
Collaborator

Is this ready for testing?

@shymega
Copy link
Copy Markdown
Member Author

shymega commented May 1, 2026 via email

@marvin1099 marvin1099 force-pushed the shymega/fix-flatpak-nixos-host branch from 292fbc0 to fd4fdbf Compare May 1, 2026 08:40
shymega and others added 2 commits May 1, 2026 10:40
To avoid ELF binary conflicts between Flatpak and host environments,
virtual environments are now created in separate subdirectories:
- wemod_venv/flatpak: For Flatpak sandbox environment
- wemod_venv/host: For host system environment

This ensures that binaries compiled for one environment don't get
executed in the other, preventing "wrong ELF class" errors.

Changes:
- mk_venv(): Creates venv in appropriate subdirectory based on environment
- venv_manager(): Checks for existing venv in correct subdirectory
- check_flatpak(): Creates host venv in wemod_venv/host with dependencies
- Adds venv detection to prevent infinite rerun loops
Adds support for running wemod-launcher on NixOS hosts, particularly
when running from inside a Flatpak sandbox. NixOS requires special
handling due to its non-standard filesystem layout and package management.

Key features:
- is_nixos(): Detects NixOS by checking /etc/NIXOS or /run/current-system/nixos-version
  - Works from inside Flatpak using flatpak-spawn to check host filesystem
- get_python_command(): Wraps Python commands with nix-shell when needed
  - Provides access to python3, tkinter, and pip packages
  - Handles both Flatpak and host invocations

NixOS venv creation:
- Uses nix-shell ONLY during venv creation (not for subsequent invocations)
- Creates venv with --copies flag to copy Python binary
- Bootstraps pip using ensurepip module
- Copies tkinter packages from nix-shell into venv's site-packages
- Results in self-contained venv that works without nix-shell wrapper
- Automatically installs dependencies from requirements.txt

Changes:
- mainutils.py: Add is_nixos() and get_python_command() functions
- setup.py: Add NixOS-specific venv creation in mk_venv() and check_flatpak()
- coreutils.py: Update pip() to use venv's bin/python directly, add NixOS comments

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@marvin1099 marvin1099 force-pushed the shymega/fix-flatpak-nixos-host branch from fd4fdbf to 495fec1 Compare May 1, 2026 08:40
@marvin1099
Copy link
Copy Markdown
Collaborator

Confirmed working on my end too.
Rebased on the newest version.
Should be good to merge.
Give me some confirmation that your done here, then i will merge.

@marvin1099 marvin1099 added the merging soon This will be merged within around 24 hours. label May 1, 2026
@shymega
Copy link
Copy Markdown
Member Author

shymega commented May 4, 2026 via email

@marvin1099 marvin1099 added under development This feature/issue is under development right now and removed merging soon This will be merged within around 24 hours. labels May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

under development This feature/issue is under development right now

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants