Setting up R and Julia, RCall does not find R packages

Hi, I have difficulties getting Julia and R working together. Specifically, the Julia library RCall does not recognize R packages. Here is my

shell.nix

  # shell.nix
with import <nixpkgs> {};
pkgs.mkShell {
  buildInputs = [
     (pkgs.rWrapper.override {
      packages = with pkgs.rPackages; [
        sf
      ]; # Include sf inside Nix
     })
    R
    julia-lts
    curl
    gdal
    proj
    sqlite
    geos
  ];
  NIX_LD_LIBRARY_PATH = lib.makeLibraryPath [
    gcc  # ...
    gfortran
    stdenv
    openspecfun
    curl
    proj
    sqlite
    geos
    libssh2
  ];
  NIX_LD = lib.fileContents "${stdenv.cc}/nix-support/dynamic-linker";
  shellHook = ''
  # Set R_LIBS_USER to an empty value to avoid unwanted user-specific libraries
  export R_LIBS_USER=""
  export R_LIBS_SITE=$(R RHOME)/library
  export R_HOME=$(R RHOME)
'';
}

Then
nix-shell --pure
and in Julia
using Pkg; Pkg.build("RCall"); using RCall
However, I get

julia> using RCall
┌ Warning: RCall.jl: During startup - Warning messages:
│ 1: package "methods" in options("defaultPackages") was not found 
│ 2: package 'utils' in options("defaultPackages") was not found 
│ 3: package 'grDevices' in options("defaultPackages") was not found 
│ 4: package 'graphics' in options("defaultPackages") was not found 
│ 5: package 'stats' in options("defaultPackages") was not found 
│ 6: package 'methods' in options("defaultPackages") was not found 

I found a solution, instead of the shell hooks above I specified

let my-r = (rWrapper.override {
       packages = with pkgs.rPackages; [
         sf
      ]; # Include sf inside Nix
     });
in ...

and then

  shellHook = ''
    export LD_LIBRARY_PATH="${my-r}/lib/R/lib:$LD_LIBRARY_PATH"
      '';

Now, the base r libraries are found.

julia> using RCall

R> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: NixOS 24.11 (Vicuna)

Matrix products: default
BLAS:   /nix/store/qpblxz0ip2s1dbp6mh6lhpkw0dnsdbw4-blas-3/lib/libblas.so.3 
LAPACK: /nix/store/iik9z8fv0bmy5fyppdi1z4qm3k2mbaqx-lapack-3/lib/liblapack.so.3;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                 
 [3] LC_TIME=en_US.UTF-8           LC_COLLATE=en_US.UTF-8       
 [5] LC_MONETARY=en_US.UTF-8       LC_MESSAGES=en_US.UTF-8      
 [7] LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8          
 [9] LC_ADDRESS=en_US.UTF-8        LC_TELEPHONE=en_US.UTF-8     
[11] LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8

time zone: Europe/Berlin
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.4.1


I read, however, that changing LD_LIBRARY_PATH is discouraged. I would like to use nix-ld, but I did not get it to work