Cross-compile cups for armv6l-linux

TL;DR

Adding the following overlays fixes the cups build to armv6l-linux for me:

          nixpkgs.overlays = [
            (final: super: {
              llvmPackages = super.llvmPackages_14;
              cmake = super.cmake.overrideAttrs (old: { env.NIX_CFLAGS_COMPILE = "-latomic"; });
              jbig2dec = super.jbig2dec.overrideAttrs (old: { configureScript = "./autogen.sh"; preConfigure = ""; });
              cups-filters = super.cups-filters.overrideAttrs (old: {
                configureFlags = old.configureFlags ++ [ "--with-cups-config=${pkgs.cups.dev}/bin/cups-config" ];
                nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.glib ];
              });
            })
          ];

Detailed explaination

After a lot of debugging and trial and error I found out:

  1. That not the cups package was the issue, but the jbig2dec. I then looked at the git history of that nix pkg and found out, that this issue was recently patched in f4c5149 and 3d69cf4. So I added the following overlay:

    jbig2dec = super.jbig2dec.overrideAttrs (old: { configureScript = "./autogen.sh"; preConfigure = ""; });
    
  2. The build process then continues and the following error appeared:

    checking for CFLocaleCopyCurrent... no
    checking for GNU gettext in libc... yes
    checking whether to use NLS... yes
    checking where the gettext function comes from... libc
    checking for armv6l-unknown-linux-gnueabihf-cups-config... no
    checking for cups-config... no
    configure: error: Required cups-config is missing. Please install CUPS developer packages.
    

    After looking at the cups configure script I found out, that cups-config is a utility that is used by cups-filters to extract the correct cups version and much more. But from the error message it seemed like it is not installed. I then discovered the --with-cups-config parameter and tried out to manually pass the correct path to the cups-config binary.

    cups-filters = super.cups-filters.overrideAttrs (old: { configureFlags = old.configureFlags ++ [ "--with-cups-config=${pkgs.cups.dev}/bin/cups-config" ]; });
    
  3. Then the configure for cups-filters finished and I got this error in the build phase:

    @nix { "action": "setPhase", "phase": "buildPhase" }
    building
    build flags: -j6 SHELL=/nix/store/q1c2flcykgr4wwg5a6h450hxbk4ch589-bash-5.2-p15/bin/bash CUPS_SERVERBIN=\$\(out\)/lib/cups CUPS_DATADIR=\$\(out\)/share/cups CUPS_SERVERROOT=\$\(out\)/etc/cups
    gdbus-codegen \
        --interface-prefix org.cups.cupsd \
        --c-namespace Cups \
        --generate-c-code cups-notifier \
        utils/org.cups.cupsd.Notifier.xml
    gdbus-codegen \
        --interface-prefix org.cups.cupsd \
        --c-namespace Cups \
        --generate-c-code cups-notifier \
        utils/org.cups.cupsd.Notifier.xml
    /nix/store/q1c2flcykgr4wwg5a6h450hxbk4ch589-bash-5.2-p15/bin/bash: line 2: gdbus-codegen: command not found
    make: *** [Makefile:5832: cups-notifier.c] Error 127
    make: *** Waiting for unfinished jobs....
    /nix/store/q1c2flcykgr4wwg5a6h450hxbk4ch589-bash-5.2-p15/bin/bash: line 2: gdbus-codegen: command not found
    make: *** [Makefile:5832: cups-notifier.h] Error 127
    

    After a lot of googling I found out, that gdbus-codegen was not installed for building, so adding the following finally fixed the build:

    cups-filters = super.cups-filters.overrideAttrs (old: { nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.glib ]; });
    
1 Like