I'm trying to make a nixos package from a program distributed in binary form only. Like most, links to the standard linker and to libraries don't match a nixos system, so I'm trying to create a new derivation that uses patchelf to update those link. I'm basing my work off of the zoom-us package already in the packages repository.

However, when I try to install the package, I get this error:

savanni@lapis:~  $ nix-env -i all --show-trace
replacing old ‘all’
installing ‘all’
error: while evaluating the attribute ‘pkgs’ of the derivation ‘all’ at /nix/store/1fxfp03ya08rnzrzyxy7dhca3c5qm0jk-nixos-16.09.1829.c88e67d/nixos/pkgs/build-support/trivial-builders.nix:10:14:
while evaluating the attribute ‘nativeBuildInputs’ of the derivation ‘GoPanda’ at /home/savanni/.nixpkgs/gopanda2.nix:9:5:
cannot coerce a set to a string, at /home/savanni/.nixpkgs/gopanda2.nix:9:5

Here is the text of my derivation:

{ cairo, fetchurl, glib, patchelf, stdenv, xorg }:
stdenv.mkDerivation rec {
    name = "GoPanda";
    version = "2";
    meta = {
        homepage = "http://pandanet-igs.com/communities/gopanda2";
    };

    src = fetchurl {
        url = "http://pandanet-igs.com/gopanda2/installer/stable/linux-64/gopanda2-linux-64.tar.gz";
        sha256 = "6d0a13e81a4646779331ff182acdbf9fe7982b2659f12a794a50897ea7368e1c";
    };  

    phases = [ "unpackPhase" "installPhase" ];
    nativeBuildInputs = [ ];
    buildInputs = [
        cairo
        glib
        xorg
    ];

    libPath = stdenv.lib.makeLibraryPath buildInputs;

    installPhase = ''
        mkdir -p $out/bin
        cp GoPanda2 $out/bin/GoPanda2
        patchelf \
            --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
            --set-rpath ${libPath} \
            $out/bin/GoPanda2
    '';
}

If I remove the nativeBuildInputs line, the buildInputs line, the libPath line, and references to libPath, I get a successful build, but an executable that doesn't know where to find the libraries. So I know I need to specify the libraries. Furthermore, I can start with the above code and add things to nativeBuildInputs, and still get the same error.

But the question is, why is there a failing coercion around nativeBuildInputs, and how can I fix it?

up vote 0 down vote accepted

The issue lay in the xorg entry in buildInputs.

xorg is a collection, not an individual module. So far as I can see, the expectation for buildInputs is that everything in the list be coercible to a string, and apparently modules can be coerced in such a way (presumably to the module name). A list cannot be coerced in such a way.

The reference to nativeBuildInputs presumably indicates that buildInputs gets mushed into nativeBuildInputs.

Here is the text of a derivation that builds but is simply missing some of the libraries that I have not yet included from xorg. I'll replace it with a complete derivation once I have the application completely working.

{ pkgs ? import <nixpkgs> {}
, cairo ? pkgs.cairo
, fetchurl ? pkgs.fetchurl
, glib ? pkgs.glib
, patchelf ? pkgs.patchelf
, stdenv ? pkgs.stdenv
, xorg ? pkgs.xorg
}:
stdenv.mkDerivation rec {
    name = "GoPanda";
    version = "2";
    meta = {
        homepage = "http://pandanet-igs.com/communities/gopanda2";
    };

    src = fetchurl {
        url = "http://pandanet-igs.com/gopanda2/installer/stable/linux-64/gopanda2-linux-64.tar.gz";
        sha256 = "6d0a13e81a4646779331ff182acdbf9fe7982b2659f12a794a50897ea7368e1c";
    };

    phases = [ "unpackPhase" "installPhase" ];
    buildInputs = [
        cairo
        glib
        xorg.libX11
    ];

    libPath = stdenv.lib.makeLibraryPath buildInputs;

    installPhase = ''
        mkdir -p $out/share
        mkdir -p $out/bin
        cp -r locales $out/share
        cp GoPanda2 $out/bin/GoPanda2
        patchelf \
            --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
            --set-rpath ${libPath} \
            $out/bin/GoPanda2
    '';
}

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.