Sample Header Ad - 728x90

nix-shell default.nix: How to install rPackages.data_table with the zlib dependency?

-1 votes
1 answer
199 views
I have a multi-user installation of nix on ubuntu 22.04. I'm trying to develop an R package that depends on data.table, but am unable to install data.table with zlib headers so that I can use the fwrite function with gzip compression. Here is the default.nix I'm using with direnv:
with import  {};

let
    rlibs = with rPackages; [
      R
      Rcpp
      data_table
      roxygen2
      pkgbuild
    ];

    _libs = with pkgs; [
        zlib
        ccls
    ];

in mkShell {
    nativeBuildInputs = [
      rlibs
      _libs
    ];
}
Everything installs fine and runs, but when I call fwrite(iris, "iris.txt.gz', compress="gzip") I get Compression in fwrite uses zlib library. Its header files were not found at the time data.table was compiled. To enable fwrite compression, please reinstall data.table and study the output for further guidance. At first I didn't have zlib in default.nix so I added it and tried reinstalling. This required cleaning out the full set of packages. I can do nix-store --delete, but it also makes me garbage collect all the specified packages. Reinstaling did not solve the problem though. I don't see any output to inspect either. How do I specify zlib as a dependency? Also is there a way to re-install a package with nix? I can't find any documentation online about it - any results are about reinstalling nix as a whole, not a single package. UPDATE: I've also tried nix-shell -p pkg-config zlib R rPackages.data_table. During the data.table install, there are messages that pkg-config was not found. However, in that shell, running pkg-config --libs zlib gives -L/nix/store/37a5krk4a1a8vhl93q2bm9nbv8hymyii-zlib-1.2.13/lib -lz Trying the nix manuals override doesn't work either:
{
    packageOverrides = super: let self = super.pkgs; in
    {

        rEnv = super.rWrapper.override {
            packages = with self.rPackages; [
                data_table
                ];
        };
    };
}
Asked by basesorbytes (1 rep)
Jun 6, 2023, 03:50 PM
Last activity: Jun 8, 2023, 03:13 PM