Help building r-inla package

I’m trying to build an R package from source, specifically the r-inla package found here. I’ve only done this once before, and it went fine. This time, the error message is not very informative. Can someone help me figure out what I’m missing? Alternatively, is there a way to set environment variables in the flake to allow using R’s nativeinstall.packages() function?

I really appreciate any guidance.

The error log shows:

Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/wlrfq2l3h7s8w2hrq24b7yhnana8j9kn-source
source root is source
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase">
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: installPhase
@nix { "action": "setPhase", "phase": "installPhase" }
Warning: invalid package '.'
Error: ERROR: no packages specified

Here is the flake (abridged):

{
  description = "A basic flake with a shell";
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/25.05";
  inputs.systems.url = "github:nix-systems/default";
  inputs.flake-utils = {
    url = "github:numtide/flake-utils";
    inputs.systems.follows = "systems";
  };

  outputs =
    { nixpkgs, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
        
        r-inla = pkgs.rPackages.buildRPackage {
          name = "R-INLA";
          src = pkgs.fetchFromGitHub{
            owner = "hrue";
            repo = "r-inla";
            rev = "daf931c988cadd7567c07cae23ff75eb7e6ad02d";
            sha256 = "1ll6azffga02kxqygalj4d03xplj7xb98qjwrdm7v17lznlamvx9";
          };
       propagatedBuildInputs = with pkgs.rPackages; [bslib evaluate Matrix sp INLAspacetime fmesher jsonlite knitr stringr tinytex yaml xfun];
      };
      in
      {
        devShells.default = pkgs.mkShell {
          nativeBuildInputs = [ pkgs.bashInteractive ];
          buildInputs = with pkgs; [
            R
            chromium
            pandoc
            r-inla
            texlive.combined.scheme-full
            rstudio
            (with rPackages; [
               a bunch of packages
            ])
          ];
        };
      }
    );
}

Hello, I’ve run into the same problem.

I’ve only done this once before, and it went fine.

How did you do it before?

Have you tried building it from source as per the R - Official NixOS Wiki?

EDIT: After some search, it’d seem that this is caused by the repository lacking a DESCRIPTION file.

This seems to be intentional:

Hello, this seems to have worked:

{
  description = "Flake for quarto development";
  inputs = {
    # I'm on unstable, but this should work for you.
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };
  outputs = {
    self,
    nixpkgs,
    flake-utils,
  }:
    flake-utils.lib.eachDefaultSystem (system: let
      pkgs = nixpkgs.legacyPackages.${system};
      r-inla = pkgs.rPackages.buildRPackage {
        name = "INLA";
        src = pkgs.fetchurl {
          url = "https://inla.r-inla-download.org/R/stable/src/contrib/INLA_25.10.19.tar.gz"; # Use it from the INLA website instead of GH
          sha256 = "0mymw6my8zz2s5v7jp289kf0a3fy9hwb1fr00mk6ga3vfnxf93q1"; # Use nix-prefetch-url to get this
        };
      };
    in {
      devShells.default = pkgs.mkShell {
        buildInputs = with pkgs; [
          R
          # fmesher is a dependency. Doesn't work when adding to propagate build inputs for some reason.
          rPackages.fmesher
          r-inla
        ];
      };
    });
}
> library(INLA)
Loading required package: Matrix
This is INLA_25.10.19 built 2025-10-19 19:10:20 UTC.
 - See www.r-inla.org/contact-us for how to get help.
 - List available models/likelihoods/etc with inla.list.models()
 - Use inla.doc(<NAME>) to access documentation
> 
1 Like

Awesome, thank you. I will try it out soon.

Works great, thanks.