foxnne / pixi

Pixel art editor made with Zig.
https://foxnne.github.io/pixi/
MIT License
738 stars 23 forks source link

Building with a flake on NixOS #52

Open t56k opened 4 months ago

t56k commented 4 months ago

I've used Cloudef/mach-flake to set up an env to build pixi, and I get this error when trying to build:

run
└─ run pixi
   └─ zig build-exe pixi Debug native failure
error: error: unable to find Dynamic system library 'atk-1.0' using strategy 'paths_first'. searched paths:
  /home/user/build/pixi/zig-cache/mach/gpu-dawn/release-cdd4a1a/x86_64-linux-gnu/release-fast/libatk-1.0.so

Anyone have any experience here? Thanks so much

slimsag commented 4 months ago

This appears to be a dependency of nfd-zig, which is used for opening native file dialogs. https://github.com/foxnne/pixi/blob/ce3f3c676c1ad2ca678f4d6163d05c2e6f73d55b/src/deps/nfd-zig/build.zig#L45-L45

Probably the 'correct' solution to this would be to make a better native file dialog library in Zig which uses dlopen or similar to get access to these functions at runtime, rather than linking dynamically to that library. At some point I want Mach itself to provide something like this.

As for fixing the nixos build, maybe @Cloudef would have an idea for how to do that - but I'm unsure myself how you would go about getting those libraries into the nix build.

Cloudef commented 4 months ago

Hello, I answered similar question here: https://ziggit.dev/t/zig2nix-nix-flake-for-packaging-building-and-running-zig-projects/2830/6

Basically:

env = mach-flake.outputs.mach-env.${system} {
    customRuntimeDeps = with pkgs; [ pkg-config ];
    customRuntimeLibs = with pkgs; [ atk ];
};

If you also plan to package using mach-flake, then you need to also add these into nativeBuildInputs and buildInputs respectively in the package derivation.

Cloudef commented 4 months ago

@slimsag You might be interested in https://flatpak.github.io/xdg-desktop-portal/ https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.FileChooser.html Sadly it uses dbus, but this is currently the way in linux for opening file browser and it will use the system's toolkit to do it (separate process). This originates from flatpak, but is not only limited to flatpak. Other than that, mach fully rendering the file dialog would be sure way and work / look the same everywhere.