mozilla / nixpkgs-mozilla

Mozilla overlay for Nixpkgs.
MIT License
517 stars 128 forks source link

Question: How do *you* actually use the gecko devEnv in a nix-shell || is it just me? #246

Closed calbrecht closed 3 years ago

calbrecht commented 3 years ago
% nix-shell ../../nixpkgs-overlays/nixpkgs-mozilla/release.nix -A gecko.x86_64-linux.clang
error: attribute 'gcc' missing, at /home/alab/ws/nixpkgs-overlays/nixpkgs-mozilla/pkgs/gecko/default.nix:25:51
% nix-shell ../../nixpkgs-overlays/nixpkgs-mozilla/release.nix -A gecko.x86_64-linux.gcc
[nix-shell:~/ws/firefox-source/mozilla-central]$ python ./mach build
...
 0:06.09 ERROR: Cannot find m4
% nix-shell ../../nixpkgs-overlays/nixpkgs-mozilla/release.nix -A gecko.x86_64-linux.gcc.fhs.env
gecko-deps-fhs-chrootenv:alab@tutnix:~/ws/firefox-source/mozilla-central$ python ./mach build
...
0:05.27 ERROR: Package 'harfbuzz', required by 'pango', not found

I am on nixpkgs master of this morning and have some other overlays like the nixpkgs-wayland and emacs-overlay in my system.

Do i have a borked system and this is working for everyone else?

calbrecht commented 3 years ago

Hm, okay. Got it to compile at least, with this patch

index ae48192..83694f0 100644
--- a/pkgs/gecko/default.nix
+++ b/pkgs/gecko/default.nix
@@ -1,6 +1,7 @@
 { geckoSrc ? null, lib
 , stdenv, fetchFromGitHub, pythonFull, which, autoconf213
-, perl, unzip, zip, gnumake, yasm, pkgconfig, xlibs, gnome2, pango, freetype, fontconfig, cairo
+, perl, unzip, zip, gnumake, yasm, pkgconfig, m4
+, xlibs, gnome2, pango, freetype, fontconfig, cairo
 , dbus, dbus_glib, alsaLib, libpulseaudio
 , gtk3, glib, gobjectIntrospection, gdk_pixbuf, atk, gtk2
 , git, mercurial, openssl, cmake, procps
@@ -22,7 +23,7 @@ let

   inherit (lib) updateFromGitHub importJSON optionals inNixShell;

-  gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
+  gcc = if stdenv.cc.isGNU then stdenv.cc.cc else lib.stdenv.gcc;

   # Gecko sources are huge, we do not want to import them in the nix-store when
   # we use this expression for making a build environment.
@@ -42,7 +43,7 @@ let
     pythonFull setuptools which autoconf213

     # Expected by the configure script
-    perl unzip zip gnumake yasm pkgconfig
+    perl unzip zip gnumake yasm pkgconfig m4

     xlibs.libICE xlibs.libSM xlibs.libX11 xlibs.libXau xlibs.libxcb
     xlibs.libXdmcp xlibs.libXext xlibs.libXt

The m4 change i am capable to comprehend, the change of the gcc attribute is over my head. But it seems to work.

calbrecht commented 3 years ago

Heh, compiling doesn't finish successfully:

37:05.53 error: failed to run custom build command for `webrender v0.61.0 (/home/alab/ws/firefox-source/mozilla-central/gfx/wr/webrender)`
37:05.54 Caused by:
37:05.54   process didn't exit successfully: `/home/alab/ws/firefox-source/mozilla-central/obj-x86_64-pc-linux-gnu/release/build/webrender-9fb4d98728a278fd/build-script-build` (exit code: 127)
37:05.54   --- stderr
37:05.55   /home/alab/ws/firefox-source/mozilla-central/obj-x86_64-pc-linux-gnu/release/build/webrender-9fb4d98728a278fd/build-script-build: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

error while loading shared libraries: libstdc++.so.6, hmm probably the gcc change was not that good.

calbrecht commented 3 years ago

I am just digging in the dark, hopefully it is amusing for some of you :)

calbrecht commented 3 years ago

Actually, when it started to compile, i used to call the gcc gecko devEnv nix-shell like so nix-shell ../../nixpkgs-overlays/nixpkgs-mozilla/release.nix -A gecko.x86_64-linux.gcc

Now if i try to use clang because, i don't know, it's hot and less complicated or something i heard, i notice that lib does not even have stdenv and i am doing stupid things.

calbrecht commented 3 years ago

Next try, after git apply <(curl -s https://patch-diff.githubusercontent.com/raw/mozilla/nixpkgs-mozilla/pull/196.patch)

calbrecht commented 3 years ago

Again, uff

% nix-shell ../../nixpkgs-overlays/nixpkgs-mozilla/release.nix -A gecko.x86_64-linux.gcc
[nix-shell:~/ws/firefox-source/mozilla-central]$ python ./mach build
...
0:05.47 checking for libclang for bindgen... not found
 0:05.47 ERROR: Could not find libclang to generate rust bindings for C/C++. Please install the necessary packages, run `mach bootstrap`, or use --with-libclang-path to give the path containing it.
calbrecht commented 3 years ago

Ok, building again, big hopes after removing double /lib from https://github.com/mozilla/nixpkgs-mozilla/pull/196#pullrequestreview-555614737

calbrecht commented 3 years ago

Nope, fails with same error as in https://github.com/mozilla/nixpkgs-mozilla/issues/246#issuecomment-748111202

calbrecht commented 3 years ago

Aha:

[nix-shell:~/ws/firefox-source/mozilla-central]$ ldd /home/alab/ws/firefox-source/mozilla-central/obj-x86_64-pc-linux-gnu/release/build/webrender-9fb4d98728a278fd/build-script-build
    linux-vdso.so.1 (0x00007ffcedb26000)
    libpthread.so.0 => /nix/store/1yvpgm763b3hvg8q4fzpzmflr5674x4j-glibc-2.32-10/lib/libpthread.so.0 (0x00007fe3d9065000)
    libstdc++.so.6 => not found
    libdl.so.2 => /nix/store/1yvpgm763b3hvg8q4fzpzmflr5674x4j-glibc-2.32-10/lib/libdl.so.2 (0x00007fe3d9060000)
    libgcc_s.so.1 => /nix/store/1yvpgm763b3hvg8q4fzpzmflr5674x4j-glibc-2.32-10/lib/libgcc_s.so.1 (0x00007fe3d9046000)
    libc.so.6 => /nix/store/1yvpgm763b3hvg8q4fzpzmflr5674x4j-glibc-2.32-10/lib/libc.so.6 (0x00007fe3d8e86000)
    /nix/store/1yvpgm763b3hvg8q4fzpzmflr5674x4j-glibc-2.32-10/lib/ld-linux-x86-64.so.2 => /nix/store/1yvpgm763b3hvg8q4fzpzmflr5674x4j-glibc-2.32-10/lib64/ld-linux-x86-64.so.2 (0x00007fe3d9253000)
    libm.so.6 => /nix/store/1yvpgm763b3hvg8q4fzpzmflr5674x4j-glibc-2.32-10/lib/libm.so.6 (0x00007fe3d8d41000)

But now what?

calbrecht commented 3 years ago
[nix-shell:~/ws/firefox-source/mozilla-central]$ rg build-script-build --files-with-matches
obj-x86_64-pc-linux-gnu/config/cbindgen-metadata.json
calbrecht commented 3 years ago

Finally got it to build ;), i did cheat and use the working derivation from nixos/nixpkgs instead to build a shell.

{ pkgs ? import <nixpkgs> { } }:

with pkgs; let

  firefox = firefoxPackages.firefox.override
    {
      # e.g. different versions of dependencies defined in another overlay
      nss = nss_3_60;
      gtk3 = gtk3_24;

      # also possible to build a debug version
      debugBuild = false;
    };

in
mkShell {
  inherit (firefox)
    configureFlags
    NIX_LDFLAGS
    NIX_CFLAGS_COMPILE
    MACH_USE_SYSTEM_PYTHON
    nativeBuildInputs
    buildInputs;

  shellHook = ''
    alias mach="python3 $(pwd)/mach"

    if [[ ! -f mozconfig ]] ; then
      ${''
        cat >> mozconfig <<EOC
        ${lib.concatMapStringsSep "\n" (s: "ac_add_options " + s) firefox.configureFlags}
        EOC
      ''}
      ${firefox.preConfigure}
    else
      export MOZCONFIG=$(pwd)/mozconfig
      unset AS
    fi
  '';
}
calbrecht commented 3 years ago

Good night :)

nbp commented 3 years ago

@calbrecht interesting trick, I usualy use it from the release.nix file. It is not stable and I have to backport many modification as you encountered here :/