-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot build Haskell programs that depend on gtk+3 statically #50
Comments
I'm not super familiar with cross-compiling support in nixpkgs, and I don't really know the relationship between $ nix-build ./nixpkgs -A pkgsMusl.systemd
...
$ nix-build ./nixpkgs -A pkgsStatic.systemd
... Neither of these worked. All the dependencies for |
Oh, hmm, I found NixOS/nixpkgs#61580, which makes it sound like |
I made some progress with this. I was able to get everything building except for one system dependency, VTE: $ nix-build build-termonad.nix
these derivations will be built:
/nix/store/j4kwsxxzcx34c99zqxi7b9aaw01cm31d-vte-0.56.3.drv
/nix/store/rjjaia4f6fajgd0szail634gdfbf8cwh-gi-gtk-3.0.27.drv
/nix/store/rq0922i46774q7mx7d3zfxfyn7mzziqn-gi-vte-2.91.19.drv
/nix/store/x1wmi30vyzjg7kq5fsj842nrx1i5qqm4-termonad-2.0.0.0.drv
building '/nix/store/j4kwsxxzcx34c99zqxi7b9aaw01cm31d-vte-0.56.3.drv'...
...
vte.cc:3587:53: warning: unused variable ‘wp_str’ [-Wunused-variable]
char const* wp_str = g_unichar_isprint(c) ? c_buf : _vte_debug_sequence_to_string(c_buf, -1);
^~~~~~
vte.cc: In member function ‘void vte::terminal::Terminal::expand_rectangle(cairo_rectangle_int_t&) const’:
vte.cc:8994:31: warning: variable ‘old_rect’ set but not used [-Wunused-but-set-variable]
cairo_rectangle_int_t old_rect = rect;
^~~~~~~~
CXX libvte_2_91_la-vtedraw.lo
vte.cc: In member function ‘void vte::terminal::Terminal::insert_char(gunichar, bool, bool)’:
vte.cc:2908:40: warning: missed loop optimization, the loop counter may overflow [-Wunsafe-loop-optimizations]
while (cell && cell->attr.fragment() && col > 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
vte.cc: In member function ‘GString* vte::terminal::Terminal::get_text(vte::grid::row_t, vte::grid::column_t, vte::grid::row_t, vte::grid::column_t, bool, bool, GArray*)’:
vte.cc:6171:82: warning: missed loop optimization, the loop counter may overflow [-Wunsafe-loop-optimizations]
while ((pcell = _vte_row_data_get (row_data, col))) {
^
CXX libvte_2_91_la-vtegtk.lo
CXX libvte_2_91_la-vteregex.lo
vteregex.cc:109:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
#pragma GCC diagnostic ignored "-Wcast-function-type"
^~~~~~~~~~~~~~~~~~~~~~
CXX libvte_2_91_la-vterowdata.lo
CXX libvte_2_91_la-vtespawn.lo
CXX libvte_2_91_la-vteseq.lo
CXX libvte_2_91_la-vtestream.lo
CXX libvte_2_91_la-vtetypes.lo
CXX libvte_2_91_la-vteunistr.lo
CXX libvte_2_91_la-vteutils.lo
CXX libvte_2_91_la-widget.lo
widget.cc: In member function ‘void vte::platform::Widget::dispose()’:
widget.cc:134:30: error: ‘W_EXITCODE’ was not declared in this scope
int status = W_EXITCODE(0, SIGKILL);
^~~~~~~~~~
widget.cc:134:30: note: suggested alternative: ‘WEXITED’
int status = W_EXITCODE(0, SIGKILL);
^~~~~~~~~~
WEXITED
make[4]: *** [Makefile:1810: libvte_2_91_la-widget.lo] Error 1
make[4]: *** Waiting for unfinished jobs....
make[4]: Leaving directory '/build/vte-0.56.3/src'
make[3]: *** [Makefile:2133: all-recursive] Error 1
make[3]: Leaving directory '/build/vte-0.56.3/src'
make[2]: *** [Makefile:1279: all] Error 2
make[2]: Leaving directory '/build/vte-0.56.3/src'
make[1]: *** [Makefile:578: all-recursive] Error 1
make[1]: Leaving directory '/build/vte-0.56.3'
make: *** [Makefile:485: all] Error 2
builder for '/nix/store/j4kwsxxzcx34c99zqxi7b9aaw01cm31d-vte-0.56.3.drv' failed with exit code 2 Here's the nix file I am using. It is basically the same as the above, with some additional overrides: let
gtk3NoCupsOverlay = self: super: {
gtk3 = super.gtk3.override {
cups = null;
cupsSupport = false;
};
};
dbusNoSystemdOverlay = self: super: {
dbus = super.dbus.override {
systemd = null;
};
};
survey = import ./survey {
normalPkgs = import ./nixpkgs {
overlays = [
dbusNoSystemdOverlay
gtk3NoCupsOverlay
];
};
};
termonad-pkg =
{ mkDerivation, adjunctions, base, Cabal, cabal-doctest
, classy-prelude, colour, constraints, containers, data-default
, directory, distributive, doctest, dyre, filepath, focuslist
, genvalidity-containers, genvalidity-hspec, gi-gdk, gi-gio
, gi-glib, gi-gtk, gi-pango, gi-vte, gtk3, haskell-gi-base
, hedgehog, inline-c, lens, libpcre2, mono-traversable
, pretty-simple, QuickCheck, singletons, stdenv, tasty
, tasty-hedgehog, tasty-hspec, template-haskell, text, vte_291
, xml-conduit, xml-html-qq
}:
mkDerivation {
pname = "termonad";
version = "2.0.0.0";
sha256 = "0rprqn5vcvhbqqg0grrmz0ijjpkrprza88la4mbdg6skb34fjsp0";
isLibrary = true;
isExecutable = true;
enableSeparateDataOutput = true;
setupHaskellDepends = [ base Cabal cabal-doctest ];
libraryHaskellDepends = [
adjunctions base classy-prelude colour constraints containers
data-default directory distributive dyre filepath focuslist gi-gdk
gi-gio gi-glib gi-gtk gi-pango gi-vte haskell-gi-base inline-c lens
mono-traversable pretty-simple QuickCheck singletons text
xml-conduit xml-html-qq
];
libraryPkgconfigDepends = [ gtk3 libpcre2 vte_291 ];
executableHaskellDepends = [ base ];
testHaskellDepends = [
base doctest genvalidity-containers genvalidity-hspec hedgehog lens
QuickCheck tasty tasty-hedgehog tasty-hspec template-haskell
];
homepage = "https://github.com/cdepillabout/termonad";
description = "Terminal emulator configurable in Haskell";
license = stdenv.lib.licenses.bsd3;
};
myHaskellPackages =
survey.haskellPackages.override {
overrides = self: super: {
termonad = self.callPackage termonad-pkg {
libpcre2 = survey.pkgs.pcre2;
vte_291 = survey.pkgs.gnome3.vte;
};
gi-gtk = survey.pkgs.haskell.lib.unmarkBroken super.gi-gtk;
gi-vte = survey.pkgs.haskell.lib.unmarkBroken super.gi-vte;
gtk3 = survey.pkgs.gtk3;
};
};
in
myHaskellPackages.termonad This is pretty exciting! I'm surprised it was this easy to get gtk3 compiled statically! @nh2 I'd be interested if you had any suggestions on how to get VTE compiled statically as well. |
Oh, looks like I was able to get VTE building as well with a small patch: let
gtk3NoCupsOverlay = self: super: {
gtk3 = super.gtk3.override {
cups = null;
cupsSupport = false;
};
};
dbusNoSystemdOverlay = self: super: {
dbus = super.dbus.override {
systemd = null;
};
};
vteMuslPatchOverlay = self: super: {
vteForMusl = super.gnome3.vte.overrideAttrs (oldAttrs: {
patches = (oldAttrs.patches or []) ++ [
(self.fetchpatch {
name = "0001-Add-W_EXITCODE-macro-for-non-glibc-systems.patch";
url = "https://gitlab.gnome.org/GNOME/vte/uploads/c334f767f5d605e0f30ecaa2a0e4d226/0001-Add-W_EXITCODE-macro-for-non-glibc-systems.patch";
sha256 = "1ii9db9i5l3fy2alxz7bjfsgjs3lappnlx339dvxbi2141zknf5r";
})
];
});
};
survey = import ./survey {
normalPkgs = import ./nixpkgs {
overlays = [
dbusNoSystemdOverlay
gtk3NoCupsOverlay
vteMuslPatchOverlay
];
};
};
termonad-pkg =
{ mkDerivation, adjunctions, base, Cabal, cabal-doctest
, classy-prelude, colour, constraints, containers, data-default
, directory, distributive, doctest, dyre, filepath, focuslist
, genvalidity-containers, genvalidity-hspec, gi-gdk, gi-gio
, gi-glib, gi-gtk, gi-pango, gi-vte, gtk3, haskell-gi-base
, hedgehog, inline-c, lens, libpcre2, mono-traversable
, pretty-simple, QuickCheck, singletons, stdenv, tasty
, tasty-hedgehog, tasty-hspec, template-haskell, text, vte_291
, xml-conduit, xml-html-qq
}:
mkDerivation {
pname = "termonad";
version = "2.0.0.0";
sha256 = "0rprqn5vcvhbqqg0grrmz0ijjpkrprza88la4mbdg6skb34fjsp0";
isLibrary = true;
isExecutable = true;
enableSeparateDataOutput = true;
setupHaskellDepends = [ base Cabal cabal-doctest ];
libraryHaskellDepends = [
adjunctions base classy-prelude colour constraints containers
data-default directory distributive dyre filepath focuslist gi-gdk
gi-gio gi-glib gi-gtk gi-pango gi-vte haskell-gi-base inline-c lens
mono-traversable pretty-simple QuickCheck singletons text
xml-conduit xml-html-qq
];
libraryPkgconfigDepends = [ gtk3 libpcre2 vte_291 ];
executableHaskellDepends = [ base ];
testHaskellDepends = [
base doctest genvalidity-containers genvalidity-hspec hedgehog lens
QuickCheck tasty tasty-hedgehog tasty-hspec template-haskell
];
homepage = "https://github.com/cdepillabout/termonad";
description = "Terminal emulator configurable in Haskell";
license = stdenv.lib.licenses.bsd3;
};
myHaskellPackages =
survey.haskellPackages.override {
overrides = self: super: {
termonad = self.callPackage termonad-pkg {
libpcre2 = survey.pkgs.pcre2;
vte_291 = survey.pkgs.vteForMusl;
gtk3 = survey.pkgs.gtk3;
};
gi-gtk = survey.pkgs.haskell.lib.unmarkBroken super.gi-gtk;
gi-vte =
(survey.pkgs.haskell.lib.unmarkBroken super.gi-vte).override {
vte_291 = survey.pkgs.vteForMusl;
};
};
};
in
myHaskellPackages.termonad Running it: $ nix-build build-termonad.nix
these derivations will be built:
/nix/store/rjjaia4f6fajgd0szail634gdfbf8cwh-gi-gtk-3.0.27.drv
/nix/store/njrrx5fxn17q37fmxjv5x6fqvfc8kpyc-gi-vte-2.91.19.drv
/nix/store/a310ambi2z9xcr2d7lc4lml823jd9h7i-termonad-2.0.0.0.drv
building '/nix/store/rjjaia4f6fajgd0szail634gdfbf8cwh-gi-gtk-3.0.27.drv'...
$ cd nixpkgs/ # this is the nixpkgs submodule in this repo, currently at commit b577340eb5b
$ nix-build -A haskellPackages.gi-gtk
error: Package ‘gi-gtk-3.0.27’ in /home/illabout/git/static-haskell-nix/nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix:93780 is marked as broken, refusing to evaluate.
a) For `nixos-rebuild` you can set
{ nixpkgs.config.allowBroken = true; }
in configuration.nix to override this.
b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
{ allowBroken = true; }
to ~/.config/nixpkgs/config.nix.
(use '--show-trace' to show detailed location information) However it looks like @nh2, I guess this issue can be closed, since I figured out most of the questions I had. |
Thanks for the detailed writeup! I also want to try building static GUI applications soon, so I'm very grateful for this.
That should be after #61 is done. |
@cdepillabout Would you mind PRing this into You can check for musl using the bool |
@nh2 I've sent 4 PRs to nixpkgs that are needed to get I wasn't sure exactly what was the best way to do the check for
|
Awesome, very appreciated! |
This was made possible by making systemd dependencies optional in recent nixpkgs `master`, initiated by #50 (comment) with some follow-ups by me at NixCon.
This was made possible by making systemd dependencies optional in recent nixpkgs `master`, initiated by #50 (comment) with some follow-ups by me at NixCon.
This was made possible by making systemd dependencies optional in recent nixpkgs `master`, initiated by #50 (comment) with some follow-ups by me at NixCon.
@cdepillabout There is another obstacle we have to take on: When moving from autotools to Meson, gtk3 lost the ability to build static libraries: https://gitlab.gnome.org/GNOME/gtk/issues/2248 CC @flokli |
My PR to fix it for gtk4 got merged: https://gitlab.gnome.org/GNOME/gtk/merge_requests/1172#note_648846 Now we should probably backport it to gtk3 upstream. |
I've done it in https://gitlab.gnome.org/GNOME/gtk/merge_requests/1196. |
Merged. |
Another upstream PR: https://gitlab.gnome.org/GNOME/at-spi2-atk/merge_requests/19 Also very relevant: meson |
Behold tens of hours of effort: (Edit: For a fancy button example scroll down.)
This is a static GTK app written in C built with meson. Some first sizes evaluation (plain
|
@nh2 Great work! I'm really impressed how much work went in to this (including upstreaming all the required fixes)! |
For some more reproducibility, I just checked that this still works, and pushed the following branches:
I also made the demo app way cooler, it now has a button that actually does something to show that it can do more than rendering empty windows: |
|
See #50 (comment) It currently fails with: (demo-glade:8872): GModule-CRITICAL **: 22:19:02.953: g_module_symbol: assertion 'module != NULL' failed (demo-glade:8872): GModule-CRITICAL **: 22:19:02.986: g_module_close: assertion 'module != NULL' failed Dynamic loading not supported Failed to load module: /nix/store/88gpkpcfjbgihn3fl8b8vk5ggfs8wn73-dconf-0.36.0-lib/lib/gio/modules/libdconfsettings.so Dynamic loading not supported Failed to load module: /nix/store/d6l7xwbdm23xgds5vafzibw57790zw71-glib-networking-2.64.3/lib/gio/modules/libgiolibproxy.so Dynamic loading not supported Failed to load module: /nix/store/d6l7xwbdm23xgds5vafzibw57790zw71-glib-networking-2.64.3/lib/gio/modules/libgiognutls.so Dynamic loading not supported Failed to load module: /nix/store/d6l7xwbdm23xgds5vafzibw57790zw71-glib-networking-2.64.3/lib/gio/modules/libgiognomeproxy.so Dynamic loading not supported Failed to load module: /nix/store/bkjpypri81svkgq5rdfd4mdn33ic1pja-gvfs-1.44.1/lib/gio/modules/libgioremote-volume-monitor.so Dynamic loading not supported Failed to load module: /nix/store/bkjpypri81svkgq5rdfd4mdn33ic1pja-gvfs-1.44.1/lib/gio/modules/libgvfsdbus.so (demo-glade:8872): GModule-CRITICAL **: 22:19:03.183: g_module_symbol: assertion 'module != NULL' failed (demo-glade:8872): Gtk-ERROR **: 22:19:03.186: gtk_builder_connect_signals() requires working GModule
Indeed, loading glade files does not work yet; I made a demo glade app
Need to check whether those disappear if you specify those libs as direct build dependencies of the static exe. |
I'm trying to build a Haskell executable (Termonad) statically that uses gi-gtk, which is built using haskell-gi and depends on
gtk+3
.It appears to be failing when building
systemd
.Termonad depdends on
gi-gtk
, which depends ongtk+3
, which depends onat-spi2-atk
, which depends ondbus
, which depends onsystemd
.I can include the output from the failed
systemd
build if it would help.Alternatively, here is the derivation I am trying to build:
Note the following:
termonad-pkg
is generated usingcabal2nix
. The current version oftermonad
in nixpkgs would probably work too.gi-gtk
andgi-vte
(Haskell dependencies of Termonad) are marked broken, probably because they don't compile with the latest version of GTK+3. I'm not worried about this, since this also occurs when building with dynamic linking. (I'm mostly concerned with getting GTK+3 built statically, so that I can work on creating static builds of Termonad).static-haskell-nix
, which is commit 761f34b.It is possible this should just be an issue on the
nixpkgs
repo. If this is the case, I will move it there.The text was updated successfully, but these errors were encountered: