Can't Resolve a Derivation Issue

I am unable to make my derivation work.
Just curious if I am doing something flagrantly inept.

{
  description = "A flake for building the FadeIn package";

  inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

  outputs = { self, nixpkgs }: 
  let
    system = "x86_64-linux";
    pkgs = nixpkgs.legacyPackages.${system};
  in {
    packages.${system} = {
      fadein = pkgs.stdenv.mkDerivation {
        pname = "fadein";
        version = "4.1.1";

        src = pkgs.fetchurl {
          url = "https://www.fadeinpro.com/download/demo/fadein-linux-amd64-demo.tar.gz";
          sha256 = "1h7qkvnc6m2fqjdfjysmf7011kdji39h8dg82pb9k8yc5brcl42f";
        };
      
        buildInputs = with pkgs; [ fontconfig stdenv libuuid gtk3 ];
        nativeBuildInputs = with pkgs; [ binutils autoPatchelfHook xorg.libXxf86vm ];

        configurePhase = "true";

        buildPhase = "true";

        installPhase = ''
          mkdir -p $out/bin
          cp usr/share/fadein/fadein $out/bin/
          chmod +x $out/bin/fadein
        '';

        shellHook = ''
          export ADDR2LINE=${pkgs.binutils}/bin/addr2line
          export PATH=${pkgs.binutils}/bin:$PATH
        '';


        meta = with pkgs.lib; {
        description = "FadeInPro screenplay writing software - free license";
        homepage = "https://www.fadeinpro.com";
        license = licenses.unfree;
        maintainers = [ maintainers.yourname ];
        
        };
      };
    };

    defaultPackage.${system} = self.packages.${system}.fadein;
  };
}

which produces two errors

Nixos/Derivations/Fadein 🌴🌴 ./result/bin/fadein
Fontconfig error: "/etc/fonts/fonts.conf", line 5: not well-formed (invalid token)
Fontconfig error: Cannot load config file from /etc/fonts/fonts.conf
22:01:45:622: ForceRmDir: /home/marcus/.fadein/cache
sh: ligne 1: addr2line : commande introuvable
Aborted (core dumped)

I’ll speak mainly to the latter error since I’m not terribly familiar with fontconfig or its config format. (but I imagine the fix there likely involves either figuring out what the format problem in fonts.conf is or patching your executable(s) to look somewhere else for the font config.)

I see that you’re setting an env that points to addr2line, but this sounds like addr2line is being invoked bare somewhere that binutils isn’t on PATH. One possibility is that there’s a shell script in the execution chain that is hard-setting a PATH.

Nix isn’t quite magic, so if result/bin/fadein is or eventually runs a shell script (or anything else that is interpreted code, really), it won’t just magically have binutils on PATH. You’ll either need to wrap the shell script (to inject an appropriate PATH), or use one of a few approaches to ~rewrite the executables in the script(s).

Does the coredump identify what’s running when this fails?

2 Likes

Thank you Abathur, this is exactly right. It is solved by injecting the path with makeWrapper.

1 Like