Error: betterbird ... removed ... insufficient maintainers

What options do I have besides switching to another client?

Package it yourself as part of your NixOS config, which would effectively make you the maintainer of said package (and you’d be responsible for updating it and fixing breakages with it).

Personally my recommendation in situations like these is to look for another avenue. In this case, it looks like Betterbird is available via Flatpak. You can set up Flatpak via your NixOS configuration then use it normally.

If you want to declaratively install Flatpak applications, there is nix-flatpak. See the project page and discussion.

Of course, this has a number of trade-offs and might not be the right choice for you. If you would prefer lifting the derivation into your configuration instead, we can probably help you figure that out. However, if it’s much like the Firefox build process, without the benefit of Hydra caching, this will probably not be a great experience.

If the developers provide an executable binary, you can create a Nix package for that. You’d likely need to use autoPatchelfHook (or buildFHSEnv) to get it to run, but the build would be much faster than trying to build such a large application from source.

Error: betterbird … removed … insufficient maintainers

That is only half the story. People put pressure on me to both support stable (I have no graphical system on stable) and unstable. Building betterbird even on good hardware, usually takes like 20 minutes and when it fails at the linking stage it is a bit annoying and can take a few tries to update. I usually did it on weekends when I usually have a lot of time but sometimes it feel through. Also I sometimes get the feeling that people get overzealous about packages other maintainers packages when they lack the security updates late.

If someone wants to help me maintain it, I think we could bring it back especially if people have the need for it.

5 Likes

Thanks for the suggestion. I feel like if I’m going to go that route, I might as well just switch to blendos or use distrobox.

I appreciate all of the maintainers but that just isn’t me anymore. I used to run gentoo on everything a decade ago but I guess I’m too old for this $#!+…?

I don’t think it’s so dire to be honest. I use Flatpak apps on all of my NixOS machines (mainly The GIMP nightly releases.) It does have some potential caveats but in my experience it is a perfectly reasonable escape hatch.

Of course, it’s all up to you. Distrobox and blendOS are also perfectly fine choices if you think those would fit your needs better.

1 Like

Here is an updated Betterbird package built from source based on Thunderbird 140 ESR, if anyone is interested.
It includes globamenu support.

I’m starting to understand why the original maintainer gave up on this, every build takes ~25 minutes to complete, so it takes a quite while to fix and test any error. :smile:

# To enable traysupport,set mail.biff.show_tray_icon_always to true in about:config
# To enable globalmenu: set widget.gtk.global-menu.wayland.enabled to true in about:config, and enable 'use system title bar'
{
  pkgs,
  lib,
  buildMozillaMach,
  cacert,
  fetchFromGitHub,
  fetchurl,
  git,
  libdbusmenu-gtk3,
  runtimeShell,
  thunderbirdPackages,
}: let
  thunderbird-unwrapped = thunderbirdPackages.thunderbird-140;
  # Globalmenu in kde/gnome, https://github.com/Lexi-Ewald/unity-menubar
  unityMenubar = fetchurl {
    url = "https://raw.githubusercontent.com/Lexi-Ewald/unity-menubar/e8dbaf63201165631edb12aac679d45eb970edf7/unity-menubar.patch";
    sha256 = "sha256-GQdsV+WQRnVsU1+rvh5Irhk8XBJeQk1/uMFATMXErDc=";
  };
  version = "140.2.1esr";
  majVer = lib.versions.major version;
  betterbird-patches = fetchFromGitHub {
    owner = "Betterbird";
    repo = "thunderbird-patches";
    rev = "${version}-bb10";
    hash = "sha256-9eQYptHMtkUe6h54i1khLQ2VFS8sdbf0YP/QC9GYbpk=";
    postFetch = ''
      echo "Retrieving external patches"
      echo "#!${runtimeShell}" > external.sh
      # if no external patches need to be downloaded, don't fail
      { grep " # " $out/${majVer}/series-moz || true ; } >> external.sh
      { grep " # " $out/${majVer}/series || true ; } >> external.sh
      sed -i -e '/^#/d' external.sh
      sed -i -e 's/\/rev\//\/raw-rev\//' external.sh
      sed -i -e 's|\(.*\) # \(.*\)|curl -L \2 -o $out/${majVer}/external/\1|' external.sh
      chmod 700 external.sh
      mkdir $out/${majVer}/external
      SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
      cp ${unityMenubar} "$out/${majVer}/features/unity-menubar-142.patch"
      echo 'unity-menubar-142.patch' >> $out/${majVer}/series-moz
      . ./external.sh
    '';
  };
in
  (
    (buildMozillaMach {
      pname = "betterbird";
      inherit version;
      applicationName = "Betterbird";
      binaryName = "betterbird";
      branding = "comm/mail/branding/betterbird";
      inherit (thunderbird-unwrapped) extraPatches;

      src = fetchurl {
        # https://download.cdn.mozilla.net/pub/thunderbird/releases/
        url = "mirror://mozilla/thunderbird/releases/${version}/source/thunderbird-${version}.source.tar.xz";
        hash = "sha256-yeS5j3LbPpCE3Hq+XwzPCb/D4vMncGNx26TC7goUwps=";
      };

      extraPostPatch =
        # bash
        ''
          set -euo pipefail
          PATH=$PATH:${lib.makeBinPath [git]}

          patches=$(mktemp -d)
          for dir in branding bugs external features misc; do
            cp -f ${betterbird-patches}/${majVer}/$dir/*.patch "$patches/" 2>/dev/null || true
          done
          cp -f ${betterbird-patches}/${majVer}/series* "$patches/" 2>/dev/null || true
          chmod -R u+w "$patches"

          # Fix include paths in systray patch
          if [ -f "$patches/12-feature-linux-systray.patch" ]; then
            substituteInPlace "$patches/12-feature-linux-systray.patch" \
              --replace-fail "/usr/include/libdbusmenu-glib-0.4/" "${lib.getDev libdbusmenu-gtk3}/include/libdbusmenu-glib-0.4/" \
              --replace-fail "/usr/include/libdbusmenu-gtk3-0.4/"  "${lib.getDev libdbusmenu-gtk3}/include/libdbusmenu-gtk3-0.4/"
          fi

          # Normalize series lines: (Don't know if this is needed, but some branding patches kept getting skipped)
          normalize_series() {
            sed -E 's/#.*$//; s/^[[:space:]]+//; s/[[:space:]]+$//' "$1" | sed '/^$/d'
          }

          # Patches to skip
          skip_patch() {
            case "$1" in
              14-feature-regexp-searchterm.patch|\
              14-feature-regexp-searchterm-m-c.patch|\
              feature-506064-match-diacritics.patch)
                return 0 ;;
              *)  return 1 ;;
            esac
          }

          apply_patch_root() {
            echo ">> applying (m-c) $1"
            test -f "$patches/$1" || { echo "!! missing patch: $1" >&2; exit 1; }
            git apply -p1 -v < "$patches/$1"
          }

          apply_patch_comm() {
            echo ">> applying (c-c) $1"
            test -f "$patches/$1" || { echo "!! missing patch: $1" >&2; exit 1; }
            git apply -p1 -v --directory=comm < "$patches/$1"
          }

          # Apply m-c patches first
          if [ -f "$patches/series-moz" ]; then
            normalize_series "$patches/series-moz" | while IFS= read -r p; do
              if skip_patch "$p"; then
                echo ">> skipping $p"
                continue
              fi
              apply_patch_root "$p"
            done
          fi

          # Then c-c patches
          if [ -f "$patches/series" ]; then
            normalize_series "$patches/series" | while IFS= read -r p; do
              if skip_patch "$p"; then
                echo ">> skipping $p"
                continue
              fi
              apply_patch_comm "$p"
            done
          # copy Betterbird mozconfig
          cp -f ${betterbird-patches}/${majVer}/mozconfig-Linux mozconfig
          fi
        '';

      extraBuildInputs = [
        libdbusmenu-gtk3
      ];

      meta = with lib; {
        description = "Betterbird is a fine-tuned version of Mozilla Thunderbird, Thunderbird on steroids, if you will";
        homepage = "https://www.betterbird.eu/";
        mainProgram = "betterbird";
        maintainers = with maintainers; [dp];
        inherit (thunderbird-unwrapped.meta) platforms broken license;
      };
    }).override
    {
      crashreporterSupport = false; # not supported
      geolocationSupport = false;
      webrtcSupport = false;
      pgoSupport = false; # console.warn: feeds: "downloadFeed: network connection unavailable"

      inherit (thunderbird-unwrapped.passthru) icu77;
    }
  ).overrideAttrs
  (oldAttrs: {
    # let betterbird mozconfig handle configure, only add libclang
    configureFlags =
      []
      ++ [
        "--with-libclang-path=${lib.getLib pkgs.llvmPackages.libclang}/lib"
        "--with-distribution-id=org.nixos"
        "--disable-updater"
      ];
    # show build errors
    MOZ_MAKE_FLAGS = "-j$NIX_BUILD_CORES V=1";
    # prevent nounset crash
    dontWrapGApps = true;
    nativeBuildInputs = let
      base = oldAttrs.nativeBuildInputs or [];
    in
      (builtins.filter (x: x != pkgs.wrapGAppsHook && x != pkgs.makeBinaryWrapper) base)
      ++ [pkgs.makeWrapper];

    postInstall =
      oldAttrs.postInstall or ""
      + ''
        if file "$out/lib/betterbird/betterbird" | grep -q ELF; then
          mv "$out/lib/betterbird/betterbird" "$out/lib/betterbird/betterbird-bin"
        fi

        mv $out/lib/thunderbird/* $out/lib/betterbird
        rmdir $out/lib/thunderbird/
        rm $out/bin/thunderbird
        # Desktop file
        mkdir -p "$out/share/applications"
        cat > "$out/share/applications/eu.betterbird.Betterbird.desktop" <<'EOF'
          [Desktop Entry]
          Type=Application
          Name=Betterbird
          Comment=Fine-tuned Thunderbird
          Exec=betterbird %u
          Icon=betterbird
          Terminal=false
          Categories=Network;Email;
          MimeType=x-scheme-handler/mailto;x-scheme-handler/webcal;text/calendar;
          StartupWMClass=eu.betterbird.Betterbird
        EOF

        # Icons
        for s in 64 128; do
          if [ -f "comm/mail/branding/betterbird/content/icon"''${s}".png" ]; then
            install -Dm644 "comm/mail/branding/betterbird/content/icon"''${s}".png" \
            "$out/share/icons/hicolor/"''${s}"x"''${s}"/apps/betterbird.png"
          fi
        done
      '';

    # 4) Wrap manually, cant get the GApps magic working
    postFixup =
      (oldAttrs.postFixup or "")
      + ''

         # Build runtime lib path
         LD_PATH="${
          lib.makeLibraryPath [
            pkgs.libglvnd
            pkgs.libdrm
            pkgs.pciutils
            pkgs.wayland
            pkgs.libxkbcommon
            pkgs.xorg.libX11
            pkgs.xorg.libXcursor
            pkgs.xorg.libXrandr
            pkgs.xorg.libXdamage
            pkgs.xorg.libXcomposite
            pkgs.gtk3
            pkgs.glib
            pkgs.pango
            pkgs.cairo
            pkgs.freetype
            pkgs.fontconfig
            pkgs.nss
            pkgs.nspr
            pkgs.dbus
            pkgs.glib-networking
            pkgs.libdbusmenu-gtk3
          ]
        }"

        XDG_DIRS="$out/share:${pkgs.gsettings-desktop-schemas}/share:${pkgs.gtk3}/share:${pkgs.adwaita-icon-theme}/share:${pkgs.hicolor-icon-theme}/share"

        makeWrapper "$out/lib/betterbird/betterbird-bin" "$out/bin/betterbird" \
        --set MOZ_ENABLE_WAYLAND 1 \
        --set GTK_USE_PORTAL 1 \
        --set MOZ_DBUS_REMOTE 1 \
        --set GTK_MODULES appmenu-gtk-module \
        --prefix GTK_PATH : "${pkgs.appmenu-gtk3-module}/lib/gtk-3.0" \
        --set GIO_EXTRA_MODULES "${pkgs.glib-networking}/lib/gio/modules" \
        --prefix XDG_DATA_DIRS : "$XDG_DIRS" \
        --prefix LD_LIBRARY_PATH : "$LD_PATH"
      '';

    doInstallCheck = false;

    passthru =
      oldAttrs.passthru
      // {
        inherit betterbird-patches;
      };
  })
1 Like

I suggest checking out https://nur.nix-community.org and keeping your derivations built via github actions and uitilise cachix. Also you can monitor for any breakages to your packages due to updates from nixpkgs.

These kind of packages are a perfect fit for nur.

1 Like

Here is a gist that works for installing betterbird-bin for x86_64-linux: pkgs/by-name/be/betterbird-bin/package.nix Ā· GitHub

I cannot run it correctly at the moment because I’m using Thunderbird managed by Home-Manager, but I will do that in a couple of days. In the meantime, feel free to test it and let me know how it goes.

Edit: got it working successfully !

I am trying to maintain betterbird in my nur repo github.com/mio-19/nurpkgs Thanks to shelvacu’s works to fix various problems

1 Like

I’d like to use ā€œbetterbird-binā€ version in my NixOS installation (I don’t want to do 20 minute builds whenever there’s a new release..)

I’m a newbie when it comes to NixOS.. I’ve got a working nix + home-manager setup, and I’m not sure where I need to put / reference the betterbird-bin/package.nix linked above by @drupol. Please help!

UPDATE: currently reading Packaging/Binaries - NixOS Wiki - I think I’ll try to that into /etc/nixos/applications/betterbird-bin/default.nix and add this line to my /etc/nixos/configuration.nix:

betterbird-bin = callPackage applications/betterbird-bin {};

is that correct? I’ll try that now..

UPDATE2: I’m currently trying to see if I can add ā€œNURā€ to my system so I could include betterbird from nurpkgs/pkgs/betterbird/default.nix at main Ā· mio-19/nurpkgs Ā· GitHub

UPDATE3: haha, 20 minutes, I wish! It feels like this build job has been running for over an hour now. I didn’t clock it but I’m 100% certain I’m well past 20 minutes.. I think I’ll go sleep now and leave my laptop running over night…

Wrong wiki, use wiki.nixos.org if you must, or better, use Package parameters and overrides with callPackage — nix.dev documentation to understand what callPackage does.

1 Like

thanks for your reply! Since that callPackage seemed terribly complex to me I’ve tried the NUR package path instead, but even though the build took hours, it sadly failed in the end :frowning:

error: Cannot build '/nix/store/vchi9bbc4xgmvs6c5aal37cry3mkw9qi-betterbird-unwrapped-140.6.0esr-bb15-build2-with-metadata.drv'.
       Reason: builder failed with exit code 2.
       Output paths:
         /nix/store/d4xfml64vrkpybx55w0jr2gad6j0almf-betterbird-unwrapped-140.6.0esr-bb15-build2-with-metadata-debug
         /nix/store/xiqfc0gg0rq5fyh913vyw2i11ja7251j-betterbird-unwrapped-140.6.0esr-bb15-build2-with-metadata
       Last 25 log lines:
       > toolkit/library/build/libxul.so
       > rm -f ../../../dist/bin/libxul.so
       > /nix/store/h8rf3hxmmzazaag0jsqa95xaqvf9iv9j-clang-wrapper-21.1.2/bin/clang++ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -fstrict-flex-arrays=1 -fno-rtti -pthread -fno-sized-deallocation -fno-aligned-new -ffunction-sections -fdata-sections -fno-math-errno -fno-exceptions -fPIC -gdwarf-4 -O2 -fomit-frame-pointer -funwind-tables -shared -Wl,-z,defs -Wl,--gc-sections -Wl,-h,libxul.so -o ../../../dist/bin/libxul.so -Wl,@/build/mozillaDir/objdir/toolkit/library/build/libxul_so.list  -B /build/mozillaDir/objdir/build/unix/elfhack -Wl,--real-linker,/nix/store/njlgx99l0x48mz0y2s2zw208apiqsnyl-llvm-binutils-wrapper-21.1.2/bin/ld.lld -flto -Wl,-plugin-opt=-import-instr-limit=10 -Wl,-plugin-opt=-import-hot-multiplier=30 -Wl,--icf=safe -Wl,--build-id=sha1 -Wl,-z,noexecstack -Wl,-z,text -Wl,-z,relro -Wl,-z,now -Wl,-z,nocopyreloc -fuse-ld=lld -fstack-protector-strong -fstack-clash-protection -Wl,-rpath-link,/build/mozillaDir/objdir/dist/bin  ../../../js/src/build/libjs_static.a ../../../build/pure_virtual/libpure_virtual.a ../../../x86_64-unknown-linux-gnu/release/libgkrust.a ../../../dist/bin/libmozsandbox.so ../../../dist/bin/libgkcodecs.so ../../../dist/bin/liblgpllibs.so ../../../dist/bin/libmozsqlite3.so ../../../dist/bin/libmozgtk.so ../../../dist/bin/libmozwayland.so -Wl,--version-script,libxul.so.symbols  -L/nix/store/r73vph55zdvgc2jzjy0q0ix5n9d97b15-icu4c-77.1/lib -licuuc -licui18n -lresolv -ldl -lasound -lpthread -lc -L/nix/store/8hm6kz26gq7cfaw07lg8vs5632abrmdm-nspr-4.38.2/lib -lplds4 -lplc4 -lnspr4 -L/nix/store/b9p0zpa93hwvh4d0r1rmgc2500yx2ldn-libffi-3.5.2/lib/../lib64 -lffi -L/nix/store/l7xwm1f6f3zj2x8jwdbi8gdyfbx07sh7-zlib-1.3.1/lib -lz -lm -L/nix/store/3qix2clbn8ic79pl0z6y8w08c7a1yg0s-nss-3.112.2/lib64 -lssl3 -lsmime3 -lnss3 -lnssutil3 -L/nix/store/b6rhgkvrwzq0bzfpaw79b60i1bfbhk3w-freetype-2.13.3/lib -lfreetype -L/nix/store/5l5wsn4qxkw90h6sxxz43gbnar7w5x8s-fontconfig-2.17.1-lib/lib -lfontconfig -L/nix/store/cs86fhm7hsgxm20m826cl5qqc4nyg33s-gtk+3-3.24.51/lib -L/nix/store/ildy6f9q59c8c4imgwcbdbf3xc9dnc5j-at-spi2-core-2.58.1/lib -L/nix/store/5qdsnc26nv61j5rrw492f19xav2rz45v-glib-2.86.1/lib -L/nix/store/0ci3da6db19gckz0i5j3br992cspvlz1-cairo-1.18.4/lib -L/nix/store/cfnas28yx8ni9izjmk3f9hgwzin798nl-gdk-pixbuf-2.44.4/lib -L/nix/store/2ryq506h3bjvkrbydqjrr5b4id9m63a3-pango-1.57.0/lib -L/nix/store/8mk1lafnnrx0a6lvjh69afm8w3i4pvqx-harfbuzz-12.1.0/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lrt -ljpeg -L/nix/store/s8md611ry6w14m4awmgivld52ym8s3b2-libpng-apng-1.6.50/lib -lpng16 -L/nix/store/bcv98jffnvqxvyncf1bayz50r9wj7g3q-libwebp-1.6.0/lib -lwebp -lwebpdemux -L/nix/store/58lnfa43dm43r4wy8mppqxh6n5xgwqpc-libevent-2.1.12/lib -levent -L/nix/store/j5hnqcfd65g73rn6yd3zv2vapw31237c-libvpx-1.15.2/lib -lvpx -L/nix/store/pw03xfrnb6a7nz6ivq6jijsx0n52afnp-pixman-0.46.4/lib -lpixman-1 -L/nix/store/ibgwqf5qna1cy3gc30w27dcjvij60ick-dbus-1.14.10-lib/lib -ldbus-1 -L/nix/store/55071y2xjibw8f317scvlg788w31k7k8-libxext-1.3.6/lib -L/nix/store/ja09m2gfni7pqk4bsrhjb8y9cq74rspp-libx11-1.8.12/lib -L/nix/store/9babi8y8p9crps6l8sz5gr5xm5fljw1h-libxcb-1.17.0/lib -L/nix/store/llr8wn0a3q8vfrg6i7vr2l2k66izm56a-libxrandr-1.5.4/lib -lxcb-shm -lX11-xcb -lX11 -lxcb -lXext -lXrandr
       > clang: warning: argument unused during compilation: '-Wa,--compress-debug-sections' [-Wunused-command-line-argument]
       > clang++: warning: argument unused during compilation: '-Wa,--compress-debug-sections' [-Wunused-command-line-argument]
       > /build/mozbuild/srcdirs/mozillaDir-dec127ac7afa/_virtualenvs/build/bin/python -m mozbuild.action.check_binary ../../../dist/bin/libmozavutil.so
       > chmod +x ../../../dist/bin/libmozavutil.so
       > make[3]: Leaving directory '/build/mozillaDir/objdir/media/ffvpx/libavutil'
       > make[3]: Entering directory '/build/mozillaDir/objdir/media/ffvpx/libavcodec'
       > media/ffvpx/libavcodec/libmozavcodec.so
       > rm -f ../../../dist/bin/libmozavcodec.so
       > /nix/store/h8rf3hxmmzazaag0jsqa95xaqvf9iv9j-clang-wrapper-21.1.2/bin/clang++ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -fstrict-flex-arrays=1 -fno-rtti -pthread -fno-sized-deallocation -fno-aligned-new -ffunction-sections -fdata-sections -fno-math-errno -fno-exceptions -fPIC -gdwarf-4 -O2 -fomit-frame-pointer -funwind-tables -shared -Wl,-z,defs -Wl,--gc-sections -Wl,-h,libmozavcodec.so -o ../../../dist/bin/libmozavcodec.so -Wl,@/build/mozillaDir/objdir/media/ffvpx/libavcodec/libmozavcodec_so.list  -B /build/mozillaDir/objdir/build/unix/elfhack -Wl,--real-linker,/nix/store/njlgx99l0x48mz0y2s2zw208apiqsnyl-llvm-binutils-wrapper-21.1.2/bin/ld.lld -flto -Wl,-plugin-opt=-import-instr-limit=10 -Wl,-plugin-opt=-import-hot-multiplier=30 -Wl,--icf=safe -Wl,--build-id=sha1 -Wl,-z,noexecstack -Wl,-z,text -Wl,-z,relro -Wl,-z,now -Wl,-z,nocopyreloc -fuse-ld=lld -fstack-protector-strong -fstack-clash-protection -Wl,-rpath-link,/build/mozillaDir/objdir/dist/bin  ../../../build/pure_virtual/libpure_virtual.a ../../../dist/bin/libgkcodecs.so ../../../dist/bin/libmozavutil.so -Wl,--version-script,libmozavcodec.so.symbols  -ldl -L/nix/store/j5hnqcfd65g73rn6yd3zv2vapw31237c-libvpx-1.15.2/lib -lvpx -lm
       > clang++: warning: argument unused during compilation: '-Wa,--compress-debug-sections' [-Wunused-command-line-argument]
       > /build/mozbuild/srcdirs/mozillaDir-dec127ac7afa/_virtualenvs/build/bin/python -m mozbuild.action.check_binary ../../../dist/bin/libmozavcodec.so
       > chmod +x ../../../dist/bin/libmozavcodec.so
       > make[3]: Leaving directory '/build/mozillaDir/objdir/media/ffvpx/libavcodec'
       > /nix/store/njlgx99l0x48mz0y2s2zw208apiqsnyl-llvm-binutils-wrapper-21.1.2/bin/ld.lld: line 273: 31141 Killed                     /nix/store/hyciwxlqj1kf8x8b4asjgsjc554i7li9-llvm-binutils-21.1.2/bin/ld.lld ${extraBefore+"${extraBefore[@]}"} ${params+"${params[@]}"} ${extraAfter+"${extraAfter[@]}"}
       > clang++: error: linker command failed with exit code 137 (use -v to see invocation)
       > make[3]: *** [/build/mozillaDir/config/rules.mk:539: ../../../dist/bin/libxul.so] Error 1
       > make[3]: Leaving directory '/build/mozillaDir/objdir/toolkit/library/build'
       > make[2]: *** [/build/mozillaDir/config/recurse.mk:72: toolkit/library/build/target] Error 2
       > make[2]: Leaving directory '/build/mozillaDir/objdir'
       > make[1]: *** [/build/mozillaDir/config/recurse.mk:34: compile] Error 2
       > make[1]: Leaving directory '/build/mozillaDir/objdir'
       > make: *** [/build/mozillaDir/config/rules.mk:359: default] Error 2
       For full logs, run:
         nix log /nix/store/vchi9bbc4xgmvs6c5aal37cry3mkw9qi-betterbird-unwrapped-140.6.0esr-bb15-build2-with-metadata.drv
error: Cannot build '/nix/store/p2vsmcg42vbbi1vfz9cvhv0g6skrz3vc-betterbird-140.6.0esr-bb15-build2-with-metadata.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/ffn01gq98chnn11i5vffa52isip6a37c-betterbird-140.6.0esr-bb15-build2-with-metadata
error: Cannot build '/nix/store/7xac6l40643470lhs8hbsfm5gcm4qjn1-home-manager-path.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/phmg4fd0bjhrj11dsgv5ngny3y1ydz5m-home-manager-path
error: Cannot build '/nix/store/23slgz8q089g5bxw0383hywdavl3jbf4-home-manager-generation.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/k3qb1dwivhj8kh4148m8mjqjnfmyqi90-home-manager-generation
error: Cannot build '/nix/store/jf6yksaac1ppj3rkcdzhmzyibzmiwfnh-user-environment.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/r7lhm6la9lz0pfja86ysf5f8mkbpxy95-user-environment
error: Cannot build '/nix/store/vvijxampcb0ksgplrzakv2qxm1i5il2b-etc.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/z8qlf75w39z5368wjdf5lmcyh8ccazqc-etc
error: Cannot build '/nix/store/lafxzzbpnw2fbbrzmvnp1kasfahbzr32-nixos-system-Lenovo_P16v_nixos-25.11.20251209.09eb77e.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/9q49nhfphmd591c3h9py09zh1dgn00v4-nixos-system-Lenovo_P16v_nixos-25.11.20251209.09eb77e

It auto-passes all attributes of pkgs to the function defined in the file you provide.

You can just put (pkgs.callPackage ./path/to/betterbird.nix {}) - keep the parens! - in environment.systemPackages or similar package list.

Your machine probably doesn’t have enough physical RAM (no, swap doesn’t count).

1 Like

ahhh, perfect, adding (callPackage ./betterbird.nix {}) into environment.systemPackages = with pkgs; [ .. ]; in my configuration.nix file and saving betterbird-bin/package.nix
to betterbird.nix in the same directory worked like a charm :slight_smile:

I have 32GB physical RAM on this machine, and I’ve even closed Firefox before going to sleep so it has most of it (whatever plasma doesn’t use) for building - still it seems it wasn’t enough. strange imho.

Thats normal unfortunately, 32 gigs isn’t enough.

I’ve modified my betterbird.nix to update to the latest bin release and add a desktop entry with icons for it:

{
  lib,
  stdenv,
  fetchurl,
  autoPatchelfHook,
  patchelfUnstable,
  wrapGAppsHook3,
  alsa-lib,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "betterbird";
  version = "140.7.1esr-bb18";

  src = fetchurl {
    url = "https://www.betterbird.eu/downloads/LinuxArchive/betterbird-140.7.1esr-bb18.en-US.linux-x86_64.tar.xz";
    hash = "sha256-XTzXokiZfzc75nAcotWPdVPMYFDkLVLglyIxwFpcvWk=";
  };

  nativeBuildInputs = [
    autoPatchelfHook
    patchelfUnstable
    wrapGAppsHook3
  ];

  buildInputs = [
    alsa-lib
  ];

  # Thunderbird uses "relrhack" to manually process relocations from a fixed offset
  patchelfFlags = [ "--no-clobber-old-sections" ];

  strictDeps = true;

  postPatch = ''
    # Don't download updates from Mozilla directly
    echo 'pref("app.update.auto", "false");' >> defaults/pref/channel-prefs.js
  '';

  installPhase = ''
    runHook preInstall

    appdir="$out/usr/lib/betterbird-bin-${finalAttrs.version}"

    mkdir -p "$appdir"
    cp -r ./* "$appdir"

    mkdir -p "$out/bin"
    ln -s "$appdir/betterbird" "$out/bin/betterbird"

    # wrapThunderbird expects "$out/lib" instead of "$out/usr/lib"
    ln -s "$out/usr/lib" "$out/lib"

    # ---------- Desktop entry ----------
    mkdir -p "$out/share/applications"
    cat > "$out/share/applications/betterbird.desktop" <<EOF
    [Desktop Entry]
    Name=Betterbird
    GenericName=Mail Client
    Comment=Fine-tuned version of Mozilla Thunderbird
    Exec=betterbird %u
    Terminal=false
    Type=Application
    Icon=betterbird
    Categories=Network;Email;GTK;
    MimeType=message/rfc822;x-scheme-handler/mailto;
    StartupWMClass=Betterbird
    EOF

    # ---------- Icons (symlinks) ----------
    icon_src_dir="$appdir/chrome/icons/default"
    if [ -d "$icon_src_dir" ]; then
      for size in 16 22 24 32 48 64 128 256; do
        icon_src="$icon_src_dir/default''${size}.png"
        if [ -f "$icon_src" ]; then
          icon_dest_dir="$out/share/icons/hicolor/''${size}x''${size}/apps"
          mkdir -p "$icon_dest_dir"
          ln -s "$icon_src" "$icon_dest_dir/betterbird.png"
        fi
      done
      # Optional: SVG, if desktop environment prefers it
      if [ -f "$icon_src_dir/default.svg" ]; then
        icon_dest_dir="$out/share/icons/hicolor/scalable/apps"
        mkdir -p "$icon_dest_dir"
        ln -s "$icon_src_dir/default.svg" "$icon_dest_dir/betterbird.svg"
      fi
    fi

    runHook postInstall
  '';

  meta = {
    changelog = "https://www.betterbird.net/en-US/betterbird/${finalAttrs.version}/releasenotes/";
    description = "Betterbird is a fine-tuned version of Mozilla Thunderbird, Thunderbird on steroids, if you will.";
    homepage = "https://www.betterbird.eu";
    mainProgram = "betterbird";
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    license = lib.licenses.mpl20;
    maintainers = with lib.maintainers; [ ];
    platforms = [ "x86_64-linux" ];
  };
})