TigerVNC / tigervnc

High performance, multi-platform VNC client and server
https://tigervnc.org
GNU General Public License v2.0
5.25k stars 956 forks source link

Add Nix flake #1854

Open svenssonaxel opened 1 month ago

svenssonaxel commented 1 month ago

After much failure trying to follow BUILDING.txt instructions, I only managed to build using Nix. Contributing a flake.nix in case others have similar trouble.

Marking as draft due to a couple of questions:

CendioOssman commented 1 month ago

I'm not too keen on another build script to maintain. So first I'd like to explore where you got stuck, and see if we can ease that hurdle?

svenssonaxel commented 1 month ago

Sure. I've already provided a Dockerfile explaining where I get stuck. Attached again here:

Dockerfile-debian.txt

Run it as docker build -f Dockerfile-debian.txt .. If you can edit this file so that building works, perhaps even simplify it, I think you'll have produced better documentation already.

I suppose my point is that this PR is not "another build script"; it's not an alternative to CMakeLists.txt. It is more like an executable description of dependencies, something that currently does not exist at all. The Dockerfile fulfills (or would, if fixed) the same function, in a less pure but perhaps more accessible way.

CendioOssman commented 1 week ago

The Dockerfile is based on Debian, which does explain a lot of the difficulties. Unfortunately, they don't have a good MinGW environment to use. So you have to set up one from scratch, with all the difficulties that entails.

Using Arch or Fedora makes the process much easier as you can just install all the needed tools and libraries from their repositories.

MXE is available for Debian/Ubuntu, though, which could make things easier.

The main issue with the given Dockerfile seems to be that pkg-config isn't properly used. Which is how the build system finds most things. Usually, you specify the cross-compiler pkg-config to CMake (just like you specify the cross-compiler). But since there isn't one, you'll need to use the normal pkg-config with a different search path:

RUN cd tigervnc && \
    mkdir build && \
    cd build && \
    PKG_CONFIG_LIBDIR=/usr/x86_64-w64-mingw32/lib/pkgconfig:/usr/x86_64-w64-mingw32/share/pkgconfig \
    $CMAKE -G "Unix Makefiles" \
        ..

At this point it works much better. It still fails for me because we apparently have a bug on master if GnuTLS is missing. And we have #949 if gettext is missing. If those two are added, then I would assume things build just fine.