moved r-nvim to flake build

This commit is contained in:
Daniel Winkler 2026-05-13 12:30:17 +10:00
commit 1055522af9
9 changed files with 54 additions and 37 deletions

5
.Rprofile Normal file
View file

@ -0,0 +1,5 @@
if (Sys.getenv("RNVIM_TMPDIR") == "") {
options(defaultPackages = c("utils", "grDevices", "graphics", "stats", "methods"))
} else {
options(defaultPackages = c("utils", "grDevices", "graphics", "stats", "methods", "nvimcom"))
}

View file

View file

38
flake.lock generated
View file

@ -22,11 +22,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1777954456,
"narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=",
"lastModified": 1778443072,
"narHash": "sha256-zi7/fsqM/kFdNuED//4WOCUtezGtKKqRNORjMvfwjnA=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1",
"rev": "da5ad661ba4e5ef59ba743f0d112cbc30e474f32",
"type": "github"
},
"original": {
@ -69,6 +69,29 @@
"type": "github"
}
},
"r-nvim-nix": {
"inputs": {
"nixpkgs": [
"rixpkgs"
],
"rnvimsrc": [
"plugins-r"
]
},
"locked": {
"lastModified": 1778638679,
"narHash": "sha256-+mdjgYfyNtI/5E6X8uUx3u9qpGC9POS4LagOHSM3Iy0=",
"owner": "dwinkler1",
"repo": "r_nvim_nix",
"rev": "eb784558e18b8f1dead5bd211b96fd287ac1bed7",
"type": "github"
},
"original": {
"owner": "dwinkler1",
"repo": "r_nvim_nix",
"type": "github"
}
},
"rixpkgs": {
"locked": {
"lastModified": 1771303851,
@ -80,8 +103,8 @@
},
"original": {
"owner": "dwinkler1",
"ref": "nixpkgs",
"repo": "rixpkgs",
"rev": "af2dd3f7b4b172077747c0869d4e30702fb71b0e",
"type": "github"
}
},
@ -91,6 +114,7 @@
"nixpkgs": "nixpkgs",
"plugins-cmp-pandoc-references": "plugins-cmp-pandoc-references",
"plugins-r": "plugins-r",
"r-nvim-nix": "r-nvim-nix",
"rixpkgs": "rixpkgs",
"wrappers": "wrappers"
}
@ -102,11 +126,11 @@
]
},
"locked": {
"lastModified": 1777991014,
"narHash": "sha256-0DS24OW9d9iz+w0LCz6KpS2IpE2z2gHxeBdMZg9xpDY=",
"lastModified": 1778560014,
"narHash": "sha256-Hu9RMo7vJt/4dx/vAvyG+cE9RBwpaH1ouyunvruYaDI=",
"owner": "BirdeeHub",
"repo": "nix-wrapper-modules",
"rev": "dc5184095ad488e937ec308b52c9c0b218959d8b",
"rev": "e30aa99c9c7038e16efae3cad7916a47307a9e36",
"type": "github"
},
"original": {

View file

@ -10,7 +10,11 @@
url = "github:BirdeeHub/nix-wrapper-modules";
inputs.nixpkgs.follows = "nixpkgs";
};
rixpkgs.url = "github:dwinkler1/rixpkgs/nixpkgs";
rixpkgs.url = "github:dwinkler1/rixpkgs/af2dd3f7b4b172077747c0869d4e30702fb71b0e";
r-nvim-nix.url = "github:dwinkler1/r_nvim_nix";
r-nvim-nix.inputs.rnvimsrc.follows = "plugins-r";
r-nvim-nix.inputs.nixpkgs.follows = "rixpkgs";
fran = {
url = "github:dwinkler1/fran";
@ -61,6 +65,7 @@
janitor
languageserver
styler
pkgs.nvimcom
];
julia = ["DataFramesMeta" "QuackIO"];
};
@ -187,6 +192,8 @@
air-formatter
yaml-language-server
updateR
nvimcom
rnvimserver
];
juliaPackages = let

View file

@ -13,7 +13,7 @@
})
(lib.mkIf (config.cats.r or false) {
RNVIM_COMPLDIR = "$PWD/.r-compl";
R_LIBS_USER = "${pkgs.nvimcom}:$PWD/.Rlibs";
R_LIBS_USER = "${pkgs.nvimcom}/library:$PWD/.Rlibs";
TMPDIR = "$PWD/.r-tmp";
})
];
@ -21,7 +21,7 @@
# Environment variables with defaults (can be overridden by user)
config.envDefault = lib.mkMerge [
(lib.mkIf (config.cats.r or false) {
R_LIBS_USER = "${pkgs.nvimcom}:$PWD/.Rlibs";
R_LIBS_USER = "${pkgs.nvimcom}/library:$PWD/.Rlibs";
})
];
}

View file

@ -14,7 +14,7 @@
(config.nvim-lib.neovimPlugins.r.overrideAttrs (old: {
postInstall = (old.postInstall or "") + ''
mkdir -p $out/rnvimserver
cp ${pkgs.nvimcom}/bin/rnvimserver $out/rnvimserver/rnvimserver
cp ${pkgs.rnvimserver}/bin/rnvimserver $out/rnvimserver/rnvimserver
chmod +x $out/rnvimserver/rnvimserver
'';
}))

View file

@ -3,12 +3,14 @@ let
lib = nixpkgs.lib;
rOverlay = import ./r.nix {inherit inputs;};
rNvimNixOverlay = inputs.r-nvim-nix.overlays.default;
franOverlay = inputs.fran.overlays.default;
pythonOverlay = import ./python.nix inputs;
pluginsOverlay = import ./plugins.nix inputs;
dependencyOverlays = [
rOverlay
rNvimNixOverlay
pythonOverlay
pluginsOverlay
];
@ -17,6 +19,7 @@ in
{
inherit
rOverlay
rNvimNixOverlay
franOverlay
pythonOverlay
pluginsOverlay
@ -30,6 +33,7 @@ in
overlays = {
inherit
rOverlay
rNvimNixOverlay
franOverlay
pythonOverlay
pluginsOverlay

View file

@ -33,38 +33,15 @@
overlays = [inputs.fran.overlays.default];
}; # rixpkgs.legacyPackages.${prev.stdenv.hostPlatform.system};
# Pre-build nvimcom from R.nvim plugin source so R.nvim never tries to
# compile it at runtime into the read-only nix store.
nvimcom = final.stdenv.mkDerivation {
pname = "nvimcom";
version = "0.9.92";
src = inputs.plugins-r;
nativeBuildInputs = [
(rpkgs.rWrapper.override { packages = []; })
];
buildPhase = ''
mkdir -p $out/bin
R CMD INSTALL -l $out nvimcom
cd rnvimserver
$CC -pthread -O2 -Wall \
complete.c resolve.c hover.c definition.c signature.c \
rhelp.c chunk.c roxygen.c data_structures.c logging.c \
rnvimserver.c obbr.c tcp.c utilities.c ../nvimcom/src/common.c \
-o $out/bin/rnvimserver
cd ..
mkdir -p $out/nvimcom/bin
cp $out/bin/rnvimserver $out/nvimcom/bin/rnvimserver
chmod +x $out/bin/rnvimserver $out/nvimcom/bin/rnvimserver
'';
installPhase = "true";
};
# nvimcom and rnvimserver are provided by the r-nvim-nix flake overlay
# (inputs.r-nvim-nix.overlays.default)
# Standard R packages used by default in rWrapper and quarto
reqPkgs = with rpkgs.rPackages; [
# languageserver
];
in {
inherit rpkgs nvimcom;
inherit rpkgs;
baseRPackages = reqPkgs;
# R wrapper with standard packages