Troubleshooting broken packages

I recently found out that the polybar package is broken on nixpkgs-unstable.

Here’s the actual error:

error: Cannot build '/nix/store/gb99cwmakrs4vvdppfzcak3xrymml306-polybar-3.7.2.drv'.
       Reason: builder failed with exit code 2.
       Output paths:
         /nix/store/wgz50yhvyn10kp68g3ffa0h1khzb55rf-polybar-3.7.2
       Last 25 log lines:
       >    28 |   vector<uint8_t> encode(const type_t type, const string& payload) {
       >       |          ^~~~~~~
       > /build/source/src/ipc/encoder.cpp:28:10: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
       > /build/source/src/ipc/encoder.cpp:28:17: error: template argument 1 is invalid
       >    28 |   vector<uint8_t> encode(const type_t type, const string& payload) {
       >       |                 ^
       > /build/source/src/ipc/encoder.cpp:28:17: error: template argument 2 is invalid
       > /build/source/src/ipc/encoder.cpp:28:32: error: 'type_t' does not name a type; did you mean 'time_t'?
       >    28 |   vector<uint8_t> encode(const type_t type, const string& payload) {
       >       |                                ^~~~~~
       >       |                                time_t
       > [ 35%] Building CXX object bin/CMakeFiles/poly.dir/modules/bspwm.cpp.o
       > make[2]: *** [bin/CMakeFiles/poly.dir/build.make:401: bin/CMakeFiles/poly.dir/ipc/encoder.cpp.o] Error 1
       > make[2]: *** Waiting for unfinished jobs....
       > In file included from /build/source/src/ipc/util.cpp:9:
       > /build/source/include/utils/string.hpp:48:3: error: 'uint32_t' does not name a type
       >    48 |   uint32_t codepoint{0};
       >       |   ^~~~~~~~
       > /build/source/include/utils/string.hpp:4:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
       >     3 | #include <sstream>
       >   +++ |+#include <cstdint>
       >     4 |
       > make[2]: *** [bin/CMakeFiles/poly.dir/build.make:415: bin/CMakeFiles/poly.dir/ipc/util.cpp.o] Error 1
       > make[1]: *** [CMakeFiles/Makefile2:607: bin/CMakeFiles/poly.dir/all] Error 2
       > make: *** [Makefile:136: all] Error 2
       For full logs, run:
         nix log /nix/store/gb99cwmakrs4vvdppfzcak3xrymml306-polybar-3.7.2.drv
error: Cannot build '/nix/store/9a29ls4rk0hff3vimg209l1rnx8dfgjn-nix-shell-env.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/fpxw11288b59czpnkr1szjfm38plf060-nix-shell-env
error: Build failed due to failed dependency

And here’s the shell.nix that can reproduce the error:

let
  nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/archive/76eec3925eb9bbe193934987d3285473dbcfad50.tar.gz";
  pkgs = import nixpkgs { };
in
pkgs.mkShell {
  buildInputs = [ pkgs.polybar ];
}

I’d like to be able to troubleshoot this error and similar errors in general, but I’m a little unsure where to start.

I can see that the latest change to the polybar source in nixpkgs is about three weeks ago. Within that time, I’ve built polybar from unstable successfully multiple times (up until yesterday in fact). So the actual error must be from elsewhere.

Any tips on what those places might be? The GitHub issue tracker hasn’t been that helpful.

This is a classic use case for git bisect.

Make a local clone of Nixpkgs if you don’t have one, run git bisect start --first-parent to avoid commits internal to PRs, mark the commit that has an error as bad, mark a commit in which everything was working as good, and then git bisect run nix-build --no-out-link ./. -A polybar and grab a drink (or dinner if the package is big — fortunately polybar is not).

But it looks like this was fixed in polybar: fix gcc15 compilation by kylosus · Pull Request #475892 · NixOS/nixpkgs · GitHub.

2 Likes

You can add an overlay to apply the patch while the PR is waiting to be merged. Something like

polybar = let
  patch = final.fetchpatch {
    name = "gcc15-cstdint-fix.patch";
    url = "https://github.com/polybar/polybar/commit/f99e0b1c7a5b094f5a04b14101899d0cb4ece69d.patch";
    sha256 = "sha256-Mf9R4u1Kq4yqLqTFD5ZoLjrK+GmlvtSsEyRFRCiQ72U=";
  };
in
  prev.polybar.overrideAttrs (old: {
    patches = old.patches ++ [patch];
  });

I was just about to reply that I found your fix applied already on master ~ I’m going to try the overlay now. Thanks :slight_smile: !

How was the failure first detected on nixpkgs?

I just tried building both on nixos-unstable and nixpkgs-unstable and to my surprise the build failed on both branches ~ so I’m curious how my builds 2+ days ago worked :thinking:.