I’m trying to bundle a Zig project that uses mach. Building works perfectly (even when cross-compiling), but the bundle output (standalone binary) doesn’t seem to include the runtime dependencies, unlike the build output, which has a proper launcher script that accounts for these.
For instance, the wrapped program from nix build .#packages.x86_64-linux.x86_64-linux-gnu
includes these libs from the store too, and I can’t find these strings anywhere in the bundled program created by nix bundle .#packages.x86_64-linux.x86_64-linux-gnu
:
alsa-lib-1.2.9/lib
libXinerama-1.1.5/lib
libXrandr-1.5.4/lib
libXrender-0.9.11/lib
libXi-1.8.1/lib
libXfixes-6.0.1/lib
libXext-1.3.5/lib
libX11-1.8.7/lib
libGL-1.7.0/lib
vulkan-loader-1.3.268.0/lib
Minimal flake.nix:
{
description = "zenui";
inputs = {
self = {
type = "git";
url = "https://github.com/thinnerthinker/zenui.git";
rev = "19d6d20ce327a02e88eee88939cbf257b7c6d602";
};
mach.url = "github:Cloudef/mach-flake?rev=047c0fa57b7650d69a6fa199a4d93fe0a08c3938";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, mach, flake-utils, ... }:
let
allTargetTriples = [
"x86_64-windows-gnu"
"aarch64-linux-gnu"
"x86_64-linux-gnu"
"aarch64-darwin"
"x86_64-darwin"
];
in
flake-utils.lib.eachDefaultSystem (system:
let
env = mach.outputs.mach-env.${system} { };
system-triple = env.lib.zigTripleFromString system;
in
with builtins; rec {
packages = env.pkgs.lib.genAttrs allTargetTriples (targetTriple: env.packageForTarget targetTriple {
name = "zenui";
src = self;
buildInputs = with env.pkgsForTarget targetTriple; [ ];
zigPreferMusl = false;
zigDisableWrap = false;
zigBuildFlags = [ "-Doptimize=ReleaseSmall" ];
});
});
}
Nix version: 2.18.1
NixOS version: 23.11.20240328.219951b (Tapir)