-
I've been able to create a simple Nix derivation that might eventually be the base for submitting for inclusion in nixpkgs, and therefore also NixOS. { lib
, buildGoModule
, fetchFromGitHub
, pkg-config
, gtk3
, webkitgtk
}:
buildGoModule rec {
pname = "wails";
version = "f923a43";
src = fetchFromGitHub
{
owner = "wailsapp";
repo = pname;
rev = "${version}";
sha256 = "RXt4/DPOtC99Z2PDdRrnJQ0rRAXZWePkHk90TBNZFvI=";
} + "/v2";
vendorSha256 = "qPMVsvud2L7hpXUOfYYMiO32JXff8ZZC34EsxFoSJ0g=";
proxyVendor = true;
subPackages = [ "cmd/wails" ];
nativeBuildInputs = [
pkg-config
];
propagatedBuildInputs = [
gtk3
webkitgtk
];
doCheck = true;
ldflags = [
"-s"
"-w"
];
meta = with lib; {
description = "Build applications using Go + HTML + CSS + JS";
homepage = "https://wails.io";
license = licenses.mit;
maintainers = with maintainers; [ ianmjones ];
platforms = platforms.linux;
};
} After building that derivation I can use it to initialize a project with After updating the with import <nixpkgs> { };
stdenv.mkDerivation {
name = "env";
nativeBuildInputs = [
pkg-config
];
buildInputs = [
gtk3
webkitgtk
];
} The above nix-shell makes sure PKG_CONFIG_PATH is set correctly for the dynamically linked libraries, and also works when running the app: However, it does not always work, sometimes the window flashes and goes away leaving a fatal error. And when it does work, when I quit the app it too leaves the same critical error like follows:
Does anyone know how I can stop that fatal error? @diogox, any ideas? And would you like to be added to the maintainers list if/when I submit a PR to nixpkgs for Wails v2 once it officially supports Linux (or is in stable-ish beta)? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 11 replies
-
Hi Ian! Thanks for this amazing work. It would be great to get this working. |
Beta Was this translation helpful? Give feedback.
-
Hi 👋 Tbh I'm a bit confused by how you managed to run Like you, I have managed to get this working on my local machine by using a Despite that, here's what I have, maybe it'll help: Nix derivation buildGo117Module {
name = "wails";
src = ../../wails/v2;
vendorSha256 = "sha256-jFXVDwJJP110mcqmayToBmTWKnyDctS0QdE6ICO5IFc=";
subPackages = [ "cmd/wails" ];
nativeBuildInputs = [ self.makeWrapper ];
# Needed to be able to make a copy of Go below
allowGoReference = true;
postInstall = let
pkgConfigPath = self.lib.makeBinPath [ self.pkg-config ];
in
''
# Injects the needed dependencies into pkg-config
makeWrapper "${pkgConfigPath}/pkg-config" "$out/lib/pkg-config" \
--prefix PKG_CONFIG_PATH : "${
self.lib.concatStringsSep ":" [
"${self.gtk3.dev}/lib/pkgconfig"
"${self.webkitgtk.dev}/lib/pkgconfig"
"${self.pango.dev}/lib/pkgconfig"
"${self.glib.dev}/lib/pkgconfig"
"${self.harfbuzz.dev}/lib/pkgconfig"
"${self.atk.dev}/lib/pkgconfig"
"${self.cairo.dev}/lib/pkgconfig"
"${self.gdk-pixbuf.dev}/lib/pkgconfig"
"${self.libsoup.dev}/lib/pkgconfig"
"${self.zlib.dev}/lib/pkgconfig"
]
}" \
--prefix LD_LIBRARY_PATH : "${
self.lib.concatStringsSep ":" [
"${self.gtk3.dev}/lib/pkgconfig"
"${self.webkitgtk.dev}/lib/pkgconfig"
"${self.pango.dev}/lib/pkgconfig"
"${self.glib.dev}/lib/pkgconfig"
"${self.harfbuzz.dev}/lib/pkgconfig"
"${self.atk.dev}/lib/pkgconfig"
"${self.cairo.dev}/lib/pkgconfig"
"${self.gdk-pixbuf.dev}/lib/pkgconfig"
"${self.libsoup.dev}/lib/pkgconfig"
"${self.zlib.dev}/lib/pkgconfig"
]
}"
# Wails runs Go directly, so we need to give it access to it. We need to copy it, so we can wrap it below.
cp ${self.go_1_17}/bin/go $out/lib
# Without the shell.nix file, I get the following error when "wails dev" is run:
# ---
# Compiling application: # github.com/wailsapp/wails/v2/internal/frontend/desktop/linux
# /nix/store/h19zwlkrp6b0hp3ypbqdcggnyarn3af6-binutils-2.35.2/bin/ld: cannot find -lz
# collect2: error: ld returned 1 exit status
# ---
# This means that I'm missing some dependencies here, I think. In fact, some of these are probably not needed, but I ran out of ideas and just started adding stuff.
wrapProgram $out/lib/go \
--prefix PATH : "${self.lib.makeBinPath [ self.webkitgtk self.gcc self.stdenv.cc.cc self.glibc ]}"
# Inject dependencies into "wails" executable
wrapProgram $out/bin/wails \
--prefix PATH : "$out/lib:${self.lib.makeBinPath [ self.webkitgtk self.gtk3 ]}"
'';
} Please note that I had this inside an overlay, so this may need some tweaking to make it work. Namely, some of the shell.nix { pkgs ? import <nixpkgs> {}, makeLibraryPath ? pkgs.lib.makeLibraryPath}:
pkgs.mkShell {
buildInputs = with pkgs; [
webkitgtk
];
} With both of these I can run and build projects just fine. |
Beta Was this translation helpful? Give feedback.
-
I've submitted a PR to nixpkgs, hopefully it'll pass review and test. 🤞 |
Beta Was this translation helpful? Give feedback.
I've submitted a PR to nixpkgs, hopefully it'll pass review and test. 🤞
NixOS/nixpkgs#162947