Skip to content

build(nix): add a flake for NixOS installation - #1967

Merged
l0gicgate merged 6 commits into
lgse:mainfrom
gusjengis:build/1-nix-packaging
Oct 31, 2026
Merged

l0gicgate merged 6 commits into
lgse:mainfrom
gusjengis:build/1-nix-packaging

Conversation

@gusjengis

@gusjengis gusjengis commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Description

This adds a Nix flake so Strata can be installed on NixOS or through Home Manager. It includes the package definition, the dependencies needed to run Strata, and brief installation instructions.

Updates are handled through Nix. The package has been built and tested on x86_64 Linux; ARM builds have not been tested yet.

Visual evidence

N/A — this changes how Strata is installed, not how it looks.

How to test

  1. Check out this branch and run nix run .# -- --version to check that it builds.
  2. Run nix run .# -- /path/to/a/test-folder, then browse the folder and preview an image or video.
  3. Follow the README instructions to add Strata to a NixOS or Home Manager configuration, rebuild, and open it from the application menu.

Expected result: Strata installs and opens normally, and image and video previews work. Updates are handled by updating the Nix flake input and rebuilding.

Related issue

Closes #1956

@github-actions github-actions Bot added the build Build system or packaging changes label Oct 31, 2026
@gusjengis gusjengis changed the title build(nix): add reusable Linux flake package build(nix): add a flake for NixOS installation Oct 31, 2026
@wmfeht

wmfeht commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

Verified on a QEMU vm

image

@wmfeht

wmfeht commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the flake. Review notes below, most important first.

Runtime integrations register the internal .strata-wrapped binary

wrapGAppsHook4 turns $out/bin/strata into a wrapper that runs $out/bin/.strata-wrapped. installed_executable() reads /proc/self/exe, so every integration Strata sets up itself records /nix/store/<hash>-strata-…/bin/.strata-wrapped. This affects the file chooser portal and FileManager1 service in ~/.local/share/dbus-1/services/, the Omarchy setup and the udiskie unlock hook (src/portal_setup.rs, src/portal_setup/udiskie.rs). There are two problems:

  • The wrapper is skipped. A D-Bus-activated instance starts without the wrapper's GST_PLUGIN_SYSTEM_PATH_1_0, GDK_PIXBUF_MODULE_FILE, XDG_DATA_DIRS and GIO_EXTRA_MODULES, so audio and video previews fail. Strata is single-instance, so later launches from the menu join that instance.
  • Stale store paths. Each flake update leaves these files pointing at the previous build, and garbage collection then leaves them pointing at nothing. secure_executable resolves symlinks, so a stable profile path such as ~/.nix-profile/bin/strata doesn't help either.

Suggested direction

On Nix, the package should provide these integrations and Strata should not write them at runtime:

  1. A build configuration, along the lines of the existing STRATA_UPDATER=disabled. For example STRATA_INTEGRATIONS=package, a generic name since Guix and other store-based or self-contained packages have the same issue. With it set:
    • Settings shows these integrations as provided by the package instead of offering install/uninstall.
    • The CLI modes refuse.
    • The startup portal refresh is skipped.
  2. The flake fills in what the build turns off. package.nix ships the D-Bus service files, share/xdg-desktop-portal/portals/strata.portal and anything else the runtime installer used to write, all pointing at $out/bin/strata. The README (or a small NixOS/Home Manager module) shows how to turn them on (services.dbus.packages, xdg.portal.extraPortals, xdg.portal.config), so updates, rollbacks and garbage collection keep them in sync.

Before deciding what to gate, it's worth going through every Settings and CLI path that changes the user's setup or assumes an FHS install. Starting points:

  • Settings → General: the file chooser portal and default file manager row (src/ui/portal_preferences.rs) and the udiskie unlock row (src/ui/udiskie_preferences.rs).
  • CLI: --install-portal, --uninstall-portal, --dismiss-portal-prompt, --install-udiskie-unlock and --uninstall-udiskie-unlock (src/main.rs).
  • Startup: portal_setup::refresh_stale_portal() (src/main.rs).
  • Updates: already hidden by STRATA_UPDATER=disabled. Check that nothing else reached from update_install.rs still runs on a Nix build, for example the desktop entry and icon cache refresh.
  • Settings → Integrations and Diagnostics: requirement and missing-tool install hints come from PackageManager::detect() (pacman/apt/dnf/zypper). Check what NixOS shows there and whether a Nix hint or none is better.

Setting the default folder handler (xdg-mime default io.github.lgse.Strata.desktop) stores only the desktop ID, which stays the same across updates, so it may be fine to keep.

The build switch is a Rust change, so it may suit a follow-up issue. In that case, a README note in this PR that these Settings integrations aren't supported on Nix yet would cover the gap until then.

Lower priority

  • --prefix PATH in preFixup puts ffmpeg, imagemagick, coreutils, util-linux, xdg-utils, fontconfig and bubblewrap ahead of the user's PATH. Terminals and "Open with" programs launched from Strata inherit it, so they pick up Strata's pinned tools first. Strata's own lookups already use the build-time STRATA_TRUSTED_COMMAND_PATH and STRATA_SANDBOX_PATH, so the block can probably be dropped, or switched to --suffix if a fallback is wanted.
  • Build commit is always unknown. The Nix build has no .git, so build.rs falls back to unknown for diagnostics and bug reports. The flake can pass STRATA_BUILD_COMMIT = self.shortRev or self.dirtyShortRev or "unknown" into package.nix.
  • README RAR instructions. pkgs.callPackage ./package.nix { rarSupport = true; } won't resolve from a user's own config. It needs pkgs.callPackage "${inputs.strata}/package.nix" { rarSupport = true; } with a nixpkgs that allows unfree packages. .override on the flake's package won't work because that package set doesn't allow unfree software.
  • docs/packaging.md describes install-source.toml as a format only for the AUR packages, "not a public cross-distribution packaging API". Please document the Nix marker there. It's harmless today with the updater off, but update_method() returns UpdateMethod::Aur for any marker. A future change could otherwise end up querying the AUR for a package named strata.

I checked that STRATA_SANDBOX_GDK_PIXBUF_MODULE_FILE exists in the locked nixpkgs (librsvg-2.62.3/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache). I haven't built the full package.

@wmfeht

wmfeht commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

Just to translate clanker-speak into tl:dr; - we need to disable various integrations like "default file manager" and "file chooser" and so on from the preferences in a build configuration and move those to the flake for NixOS and similar setups.

Strata resolves bubblewrap and the preview helpers through the embedded
STRATA_TRUSTED_COMMAND_PATH and STRATA_SANDBOX_PATH, so prepending the
closure to PATH only made terminals and Open With programs inherit the
pinned tools. The source tree has no .git, so pass the flake revision
as STRATA_BUILD_COMMIT instead of reporting unknown in diagnostics.
…tion gaps

callPackage ./package.nix cannot resolve from a user's configuration;
reference the flake input and an unfree-enabled package set. Document the
Nix install marker next to the AUR one and note that the runtime-installed
integrations are unsupported until the package provides them (lgse#1969).
@l0gicgate

Copy link
Copy Markdown
Contributor

Merged main (1cb84d0) into the branch and pushed two review commits.

build(nix): drop the PATH prefix and record the flake revision (e33503b)

  • Removed the preFixup --prefix PATH block. Strata finds bubblewrap and the helpers through the embedded STRATA_TRUSTED_COMMAND_PATH / STRATA_SANDBOX_PATH, so the prefix only made terminals and Open With programs inherit the pinned tools.
  • flake.nix now passes buildCommit = self.shortRev or self.dirtyShortRev or null into package.nix, which sets STRATA_BUILD_COMMIT, so Diagnostics reports the flake revision instead of unknown. A path: build leaves it unset and keeps the build.rs fallback.

docs(nix): correct the RAR override and record the marker and integration gaps (7aebc5e)

  • README: the RAR example now uses pkgs.callPackage "${inputs.strata}/package.nix" { rarSupport = true; } from an unfree-enabled package set, and states that the runtime-installed integrations (file chooser portal, FileManager1 service, udiskie unlock hook) are not supported on Nix yet.
  • docs/packaging.md: documents the Nix marker next to the AUR one, why it is safe only with STRATA_UPDATER=disabled, and a short Nix section covering the embedded sandbox paths and the .strata-wrapped problem.

The wrapper/stale-store-path concern is real (wrapGAppsHook4 in the locked nixpkgs emits a binary wrapper with --inherit-argv0, but /proc/self/exe still resolves to .strata-wrapped). The fix needs a build switch plus package-provided integration files, which is Rust work beyond this PR, so I filed #1969 with the design from the review above and left the README note in place.

Verification (Nix is not installed here, so everything ran in a nixos/nix container against a copy of the tree):

  • nix flake check --all-systems --no-build and nix flake show evaluate both systems.
  • nixfmt --check flake.nix package.nix passes (nixfmt 1.5.0 from the locked nixpkgs).
  • nix build .#strata on x86_64-linux succeeds; the output's bin/strata wrapper sets only GIO_EXTRA_MODULES, GDK_PIXBUF_MODULE_FILE, XDG_DATA_DIRS and GST_PLUGIN_SYSTEM_PATH_1_0, strata --version prints 1.1.1, and the desktop entry, icon, licenses, install-source.toml and inactive FileManager1 template are installed. From a git+file: reference, STRATA_BUILD_COMMIT in the derivation equals the short revision.
  • typos and git diff --check on the changed files are clean. No Rust code changed, so the Rust suites were not rerun.

Not verified: an aarch64 build, rarSupport = true, and running the GUI from the Nix output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Build system or packaging changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Nix flake for NixOS installation

3 participants