Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rix(r_pkgs = "<rpkg@version>") Nix expression should assign to cran_build_pkgs instead of git_archive_pkgs variable #348

Open
philipp-baumann opened this issue Oct 2, 2024 · 1 comment

Comments

@philipp-baumann
Copy link
Collaborator

library("rix")

rix(
  r_ver = "latest",
  r_pkgs = "[email protected]",
  project_path = ".",
  overwrite = TRUE
)

nix_build(project_path = ".")

currently produces this Nix expression

# This file was generated by the {rix} R package v0.12.4 on 2024-10-03
# with following call:
# >rix(r_ver = "1839883cd0068572aed75fb9442b508bbd9ef09c",
#  > r_pkgs = "[email protected]",
#  > project_path = "_test",
#  > overwrite = TRUE)
# It uses nixpkgs' revision 1839883cd0068572aed75fb9442b508bbd9ef09c for reproducibility purposes
# which will install R version latest.
# Report any issues to https://github.com/ropensci/rix
let
 pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/1839883cd0068572aed75fb9442b508bbd9ef09c.tar.gz") {};
  
  git_archive_pkgs = [ 
    (pkgs.rPackages.buildRPackage {
      name = "rlang";
      src = pkgs.fetchzip {
       url = "https://cran.r-project.org/src/contrib/Archive/rlang/rlang_1.1.3.tar.gz";
       sha256 = "sha256-+xSUK2YpQHE0sezKMngihHVKG0r63b6OuJb6136qgRM=";
      };
      propagatedBuildInputs = builtins.attrValues {
        inherit (pkgs.rPackages) ;
      };
    })
  ];
   
  system_packages = builtins.attrValues {
    inherit (pkgs) 
      glibcLocales
      nix
      R;
  };
  
in

pkgs.mkShell {
  LOCALE_ARCHIVE = if pkgs.system == "x86_64-linux" then "${pkgs.glibcLocales}/lib/locale/locale-archive" else "";
  LANG = "en_US.UTF-8";
   LC_ALL = "en_US.UTF-8";
   LC_TIME = "en_US.UTF-8";
   LC_MONETARY = "en_US.UTF-8";
   LC_PAPER = "en_US.UTF-8";
   LC_MEASUREMENT = "en_US.UTF-8";

  buildInputs = [ git_archive_pkgs   system_packages   ];
  
}

It should be tagged under cran_build_pkgs. Its the same hashing procedure, but semantically its not a git archive.

@philipp-baumann philipp-baumann changed the title rix(r_pkgs = <rpkg@version>) should produce cran_build_pkgs instead of git_archive_pkgs rix(r_pkgs = <rpkg@version>) result should be assigned to cran_build_pkgs instead of git_archive_pkgs variable Oct 2, 2024
@philipp-baumann philipp-baumann changed the title rix(r_pkgs = <rpkg@version>) result should be assigned to cran_build_pkgs instead of git_archive_pkgs variable rix(r_pkgs = <rpkg@version>) Nix expression should assign to cran_build_pkgs instead of git_archive_pkgs variable Oct 2, 2024
@philipp-baumann philipp-baumann changed the title rix(r_pkgs = <rpkg@version>) Nix expression should assign to cran_build_pkgs instead of git_archive_pkgs variable rix(r_pkgs = "<rpkg@version>") Nix expression should assign to cran_build_pkgs instead of git_archive_pkgs variable Oct 2, 2024
@b-rodrigues
Copy link
Contributor

Right, but I wonder if this will not be removed anyways with what we’re planning to do with renv2nix(). If we go that route, then something like [email protected] would be pulled from its specific nixpkgs revision instead like so:

let
 pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/019f5c29c5afeb215587e17bf1ec31dc1913595b.tar.gz") {};
 old_dplyr = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/a4684b5462b6c66dd7ad2a7dfb2e5c1fca5582e4.tar.gz") {};

  rpkgs = builtins.attrValues {
    inherit (pkgs.rPackages) 
      ggplot2
      languageserver;
  };
    
  system_packages = builtins.attrValues {
    inherit (pkgs) 
      glibcLocales
      nix
      R;
  };
  
in

pkgs.mkShell {
  LOCALE_ARCHIVE = if pkgs.system == "x86_64-linux" then "${pkgs.glibcLocales}/lib/locale/locale-archive" else "";
  LANG = "en_US.UTF-8";
   LC_ALL = "en_US.UTF-8";
   LC_TIME = "en_US.UTF-8";
   LC_MONETARY = "en_US.UTF-8";
   LC_PAPER = "en_US.UTF-8";
   LC_MEASUREMENT = "en_US.UTF-8";

  buildInputs = [  rpkgs  system_packages old_dplyr.rPackages.dplyr  ];
  
}

so maybe we can just leave this for now, because we would end up removing it once we start using dedicated nixpkgs revisions for individual packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants