Skip to content

feat(build): add nix devshell, FHS binary patching, Linux .deb packaging#45

Open
usrbinkat wants to merge 3 commits intovanloctech:mainfrom
usrbinkat:feat/nix-devshell
Open

feat(build): add nix devshell, FHS binary patching, Linux .deb packaging#45
usrbinkat wants to merge 3 commits intovanloctech:mainfrom
usrbinkat:feat/nix-devshell

Conversation

@usrbinkat
Copy link

Problem

Building Youwee inside a Nix devshell produces binaries with a nix store dynamic linker
(/nix/store/.../ld-linux-x86-64.so.2) and nix store RPATH entries baked into the ELF
binary. When this binary is packaged into a .deb and installed on a standard
Ubuntu/Debian system, it crashes at launch because the nix linker cannot find system
libraries like libayatana-appindicator3.so.1.

Additionally, the existing .deb bundles yt-dlp at /usr/bin/yt-dlp via externalBin,
which conflicts with the yt-dlp apt package — dpkg refuses to install both.

Solution

FHS binary portability (scripts/patch-fhs-binary.sh)

  • beforeBundleCommand in tauri.conf.json invokes the script after cargo build
    but before .deb assembly
  • Patches ELF interpreter from nix store to standard FHS path (/lib64/ld-linux-x86-64.so.2)
  • Removes RPATH so the binary uses the system library search path
  • Multi-arch support: x86_64, aarch64, armv7l, i686 (via TAURI_ENV_ARCH)
  • Derives binary path dynamically from TAURI_ENV_TARGET_TRIPLE and TAURI_ENV_DEBUG
  • No-op when patchelf is not on PATH (macOS, Windows, CI without Nix)
  • Idempotent: skips if interpreter is already FHS

Linux .deb packaging (tauri.linux.conf.json)

  • Overrides externalBin to [] on Linux — no bundled yt-dlp (eliminates file conflict)
  • Declares ffmpeg and yt-dlp as .deb dependencies (Tauri auto-appends
    libayatana-appindicator3-1, libwebkit2gtk-4.1-0, libgtk-3-0)
  • apt install ./Youwee.deb pulls runtime deps automatically

Nix devshell (flake.nix, flake.lock, .envrc)

  • flake.nix consumes github:braincraftio/konductor frontend devshell via inputsFrom
  • Adds yt-dlp, ffmpeg, deno, glib-networking as runtime packages
  • Sets GIO_EXTRA_MODULES for WebKitGTK TLS support (without this, HTTPS image
    loads fail with "TLS support is not available")
  • flake.lock pinned to konductor rev 84a1bcd (includes pkgs.bun)
  • .envrc provides optional direnv integration

README updates

  • Documents tomtomtom/yt-dlp PPA for current yt-dlp on Ubuntu/Debian
  • Documents nix develop build workflow
  • Updates Tauri prerequisites link to v2
  • Clarifies yt-dlp bundling is macOS/Windows only

Test plan

  • nix develop enters devshell with bun, cargo, rustc, all Tauri deps
  • bun run tauri dev launches development build with working thumbnails and TLS
  • bun run tauri build -b deb produces .deb with FHS-patched binary
  • beforeBundleCommand output confirms interpreter patched from nix store to /lib64/ld-linux-x86-64.so.2
  • .deb declares correct depends: ffmpeg, yt-dlp, libayatana-appindicator3-1, libwebkit2gtk-4.1-0, libgtk-3-0
  • .deb contains no bundled yt-dlp binary (no file conflict with apt)
  • sudo apt install ./Youwee.deb pulls yt-dlp + ffmpeg automatically
  • Installed app launches from desktop and CLI without library errors
  • Download completes successfully with system yt-dlp and ffmpeg

binary path resolution:
- reorder get_system_binary_candidates() in ffmpeg.rs, ytdlp.rs to check $PATH before /opt/homebrew/bin, /usr/local/bin, /usr/bin
- reorder get_deno_path()/check_deno_internal() in deno.rs: which/where before ~/.deno/bin
- fixes binary resolution for Nix, Homebrew, and other PATH-based environments

dev build sidecar:
- build.rs creates yt-dlp placeholder (<1024 bytes) for tauri_build::build() externalBin validation
- get_bundled_ytdlp_path() rejects placeholders under 1024 bytes
- get_ytdlp_path() falls through to system PATH as last resort in Auto mode

ffmpeg mux progress:
- add parse_ffmpeg_progress() to progress.rs matching time=HH:MM:SS, speed=Nx, Lsize=
- download.rs stderr task emits status=muxing when parse_ffmpeg_progress() matches
- add isMuxing to DownloadItem, set in DownloadContext.tsx/UniversalContext.tsx
- QueueItem.tsx/UniversalQueueItem.tsx render shimmer bar with Muxing label and speed

youtube thumbnail fallback:
- add getYouTubeVideoId() in UniversalQueueItem.tsx
- fallback to img.youtube.com/vi/{id}/mqdefault.jpg when item.thumbnail is null
- useEffect resets thumbError on item.thumbnail/item.url change

firefox profile sorting:
- add parse_firefox_profiles() to dependencies.rs
- parse Install section Default= to identify active profile path
- sort active profile first, replaces inline Name= scanning on macOS/Windows/Linux
…working

- flake.nix consumes github:braincraftio/konductor #frontend devshell via inputsFrom
- adds yt-dlp, ffmpeg, deno, glib-networking as runtime packages on PATH
- GIO_EXTRA_MODULES set to glib-networking + dconf for WebKitGTK TLS support
- .envrc provides direnv integration with cargo env sourcing
- use flake commented out by default (opt-in for Nix users)
- flake.lock pinned against public GitHub konductor flake
nix devshell:
- flake.lock updated to konductor 84a1bcd (adds pkgs.bun)
- README.md documents nix develop workflow and build instructions

FHS binary portability:
- scripts/patch-fhs-binary.sh patches ELF interpreter and removes RPATH
- handles x86_64, aarch64, armv7l, i686 via TAURI_ENV_ARCH
- derives binary path from TAURI_ENV_TARGET_TRIPLE and TAURI_ENV_DEBUG
- no-op when patchelf unavailable (macOS, Windows, CI)
- idempotent: skips if interpreter already FHS
- tauri.conf.json beforeBundleCommand invokes the script

Linux .deb packaging:
- tauri.linux.conf.json overrides externalBin to [] (no bundled yt-dlp)
- declares ffmpeg and yt-dlp as .deb depends (Tauri appends lib defaults)
- eliminates /usr/bin/yt-dlp file conflict with apt yt-dlp package
- README.md documents tomtomtom/yt-dlp PPA for current yt-dlp versions

README updates:
- Tauri 2 prerequisites link replaces deprecated v1 link
- tech stack clarifies yt-dlp bundling is macOS/Windows only
@vanloctech
Copy link
Owner

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4d247621e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"beforeDevCommand": "bun run dev",
"beforeBuildCommand": "bun run build"
"beforeBuildCommand": "bun run build",
"beforeBundleCommand": "bash scripts/patch-fhs-binary.sh"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate Linux patch script so Windows bundles do not require bash

The new beforeBundleCommand always invokes bash scripts/patch-fhs-binary.sh, which makes tauri build depend on a Bash executable even when packaging on Windows. On Windows environments without Git Bash in PATH, bundling now fails before Tauri can build artifacts, even though the patch script is Linux-specific and intended to no-op only after it starts. Please make this command conditional for Linux (or use a cross-platform wrapper) so Windows packaging remains runnable.

Useful? React with 👍 / 👎.

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