feat(fzf): embed fzf binary #26

Open
kbity wants to merge 6 commits from feature/embed-fzf into main
Collaborator

closes #24, allows for the embedding of a statically-compiled fzf binary into wbij itself.

adds two compile options:

  • embed_fzf (bool, defaults to false): whether to embed fzf
  • fzf_path (?[]const u8): where to take the fzf binary from

and a struct FzfBinProvider, which resolves the fzf path (or deploys our own if a cache is available)

closes #24, allows for the embedding of a statically-compiled fzf binary into wbij itself. adds two compile options: - `embed_fzf` (`bool`, defaults to `false`): whether to embed fzf - `fzf_path` (`?[]const u8`): where to take the fzf binary from and a struct `FzfBinProvider`, which resolves the fzf path (or deploys our own if a cache is available)
Author
Collaborator

for example, to test with latest (as of writing) prebuilt static fzf:

wget https://github.com/junegunn/fzf/releases/download/v0.73.1/fzf-0.73.1-linux_amd64.tar.gz -qO fzf-latest.tar.gz
tar xf fzf-latest.tar.gz
zig build -Dembed_fzf -Dfzf_path=./fzf run -- [args...]
for example, to test with latest (as of writing) prebuilt static fzf: ```sh wget https://github.com/junegunn/fzf/releases/download/v0.73.1/fzf-0.73.1-linux_amd64.tar.gz -qO fzf-latest.tar.gz tar xf fzf-latest.tar.gz zig build -Dembed_fzf -Dfzf_path=./fzf run -- [args...] ```
kbity changed title from WIP: feat(fzf): embed fzf binary to feat(fzf): embed fzf binary 2026-05-27 15:34:49 +02:00
maleszka left a comment
Owner

thanks! awesome work

thanks! awesome work
build.zig Outdated
@ -30,0 +37,4 @@
} else if (fzf_path != null) {
std.log.info("-Dfzf_path=... has no effect without -Dembed_fzf", .{});
}
Owner

This relation between embed_fzf and fzf_path you can solve this way that embed_fzf in itself is ?[]const u8 and it accepts path for fzf bin

This relation between `embed_fzf` and `fzf_path` you can solve this way that `embed_fzf` in itself is `?[]const u8` and it accepts path for fzf bin
Author
Collaborator

fair point, sounds good

fair point, sounds good
kbity marked this conversation as resolved
@ -0,0 +31,4 @@
_ = self;
}
/// Removes potentially created temporary files
Owner

add build module also to mod module. This way, you will be able to import build directly here.

add `build` module also to `mod` module. This way, you will be able to import `build` directly here.
Author
Collaborator

i'm having some issues with Zig complaining about build existing in multiple files (src/fzf/FzfBinProvider.zig:1:1: error: file exists in modules 'build' and 'build0'); do you happen to know any tricks i could use to get around that?

i'm having some issues with Zig complaining about `build` existing in multiple files (`src/fzf/FzfBinProvider.zig:1:1: error: file exists in modules 'build' and 'build0'`); do you happen to know any tricks i could use to get around that?
kbity marked this conversation as resolved
src/root.zig Outdated
@ -17,3 +18,3 @@
queried_for_nondefault: bool, // referenced in select{Account,Contest,CodeLang}
pub fn init(allocator: std.mem.Allocator, args: anytype) !Wbij {
pub fn init(allocator: std.mem.Allocator, args: anytype, comptime has_embedded_fzf: bool) !Wbij {
Owner

you don't need it if you add build module to mod module in build.zig; you can source build directly then

you don't need it if you add `build` module to `mod` module in `build.zig`; you can source `build` directly then
kbity marked this conversation as resolved
Owner

Will you manage to add fzf as submodule and add fzf build step inside build.zig directly? Then you can import fzf binary as a build artifact into wbij.

You can compile fzf with the following commands for static compilation:

export CGO_ENABLED=0
export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
make
make bin/fzf
Will you manage to add `fzf` as submodule and add fzf build step inside `build.zig` directly? Then you can import fzf binary as a build artifact into wbij. You can compile fzf with the following commands for static compilation: ``` export CGO_ENABLED=0 export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw" make make bin/fzf ```
kbity force-pushed feature/embed-fzf from 4eb3501505 to 9de1c7ee6a 2026-06-18 10:25:23 +02:00 Compare
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feature/embed-fzf:feature/embed-fzf
git switch feature/embed-fzf

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff feature/embed-fzf
git switch feature/embed-fzf
git rebase main
git switch main
git merge --ff-only feature/embed-fzf
git switch feature/embed-fzf
git rebase main
git switch main
git merge --no-ff feature/embed-fzf
git switch main
git merge --squash feature/embed-fzf
git switch main
git merge --ff-only feature/embed-fzf
git switch main
git merge feature/embed-fzf
git push origin main
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
maleszka/wbij!26
No description provided.