Skip to content

[Feature Request] Any plans in the future to make this exension compatable with nixos? #229

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

Closed
oTheAnalyst opened this issue Sep 2, 2024 · 17 comments

Comments

@oTheAnalyst
Copy link

Was wondering if there where plans in the future to make this compatable with nixos & the nix-shell enviroment?

Currently there is no way to get this working on nixos, unless its dependenceis are added to nixpkgs.

@jalvesaq
Copy link
Member

jalvesaq commented Sep 2, 2024

Debian has an application named equivs-build that I use to create "empty" Debian packages that depend on other packages that I need to compile R, compile Neovim, etc... Maybe NixOS has something similar.

@jalvesaq
Copy link
Member

jalvesaq commented Sep 2, 2024

What would be necessary to make R.nvim compatible with NixOS?

@jalvesaq
Copy link
Member

jalvesaq commented Sep 9, 2024

@VtheRtech, I'm closing the issue. Please reopen it if you know what would be required for R.nvim to work on NixOS.

@jalvesaq jalvesaq closed this as completed Sep 9, 2024
@oTheAnalyst
Copy link
Author

oTheAnalyst commented Oct 4, 2024

NixOS/nixpkgs#346445 (comment)
@jalvesaq
Hello I'm re-opening this issue. Sorry for the delay in the response before was still learning how nixos functions. I believe this plugin needs to packaged under nix packages or atleast a nvimcom does for it work on nixos & with nix shells. Nvimcom is not precompilled, with package manager I just opened a request for on nixpkgs to if anyone was willing to pick this up.

@jalvesaq
Copy link
Member

jalvesaq commented Oct 4, 2024

Doesn't it work if you install gcc and make?

@oTheAnalyst
Copy link
Author

oTheAnalyst commented Oct 4, 2024

Doesn't it work if you install gcc and make?

I installed the dependecies but unfortunatly no it did not work. There where majore issues with how it was interacting with shell enviroments. After talking with people who know a bit more than me, I was told it was because it compiled at run time, nix is immutable and won't let things compile unless its explicently through nix.

@gueyenono
Copy link

I just spent a little over a week attempting to package neovim and R.nvim with Nix and I am glad I stumbled upon this issue. Now I know that it wasn't a skill issue 😄 It would be awesome if it worked! Nix is becoming increasingly popular in the R community thanks to the {rix} package: https://github.com/ropensci/rix/

@gueyenono
Copy link

I just spent a little over a week attempting to package neovim and R.nvim with Nix and I am glad I stumbled upon this issue. Now I know that it wasn't a skill issue 😄 It would be awesome if it worked! Nix is becoming increasingly popular in the R community thanks to the {rix} package: https://github.com/ropensci/rix/

It turns out that I followed the suggestion of @jalvesaq and it worked! I included gcc and gnumake to my configuration. I need to add that I do not use NixOS but I use (Nix) Home-Manager and Nix Flakes in my Ubuntu distro.

@oTheAnalyst
Copy link
Author

I just spent a little over a week attempting to package neovim and R.nvim with Nix and I am glad I stumbled upon this issue. Now I know that it wasn't a skill issue 😄 It would be awesome if it worked! Nix is becoming increasingly popular in the R community thanks to the {rix} package: https://github.com/ropensci/rix/

It turns out that I followed the suggestion of @jalvesaq and it worked! I included gcc and gnumake to my configuration. I need to add that I do not use NixOS but I use (Nix) Home-Manager and Nix Flakes in my Ubuntu distro.

The issue I had was that it would break upon entering a shell. I haven't tested it with flakes yet so maybe that is a work around? But I've I'm using nixos, so that is probably my issue until this gets packaged.

@gueyenono
Copy link

I just spent a little over a week attempting to package neovim and R.nvim with Nix and I am glad I stumbled upon this issue. Now I know that it wasn't a skill issue 😄 It would be awesome if it worked! Nix is becoming increasingly popular in the R community thanks to the {rix} package: https://github.com/ropensci/rix/

It turns out that I followed the suggestion of @jalvesaq and it worked! I included gcc and gnumake to my configuration. I need to add that I do not use NixOS but I use (Nix) Home-Manager and Nix Flakes in my Ubuntu distro.

The issue I had was that it would break upon entering a shell. I haven't tested it with flakes yet so maybe that is a work around? But I've I'm using nixos, so that is probably my issue until this gets packaged.

Clearly, the ultimate solution would be for the plugin to be packaged. You are right! Although I don't use NixOS, I know for a fact that home-manager and flakes can be used inside it. You may be hesitant to use flakes because it is still considered "experimental". However, they have become so popular that I would not really worry about it.

@Neurarian
Copy link

Hi,
Just in case anyone stumbles across this: Personally, I use nixCats on NixOS and just added the dependencies for nvimcom to the list of runtime dependencies and it worked flawlessly. However, I also created an overlay for nvimcom:

(final: _prev: {
  rPackages =
    prev.rPackages
    // {
      nvimcom = final.rPackages.buildRPackage {
        name = "nvimcom";
        src = final.fetchFromGitHub {
          owner = "R-nvim";
          repo = "R.nvim";
          rev = "main";
          sha256 = "sha256-5QYQRN5zQWGTSEpkNr7WHVe167vHtyytSE+vF10cdZI=";
        };
        sourceRoot = "source/nvimcom";
        buildInputs = with final; [R gcc gnumake];
        propagatedBuildInputs = with final.rPackages; [];
      };
    };
})
   

and then just added it to the rWrapper:

RCustom = { pkgs.rWrapper.override {
  packages = with pkgs.rPackages; [
    nvimcom
    tidyverse
    # ...
  ];
}; 

Unfortunately, I was not able to get rix to work with R.nvim without major manual intervention every time a new shell environment template is created (which kinda defeats the purpose of rix), or forking rix and changing the way it handles remote dependencies / overlayed packages. Perhaps adding the ability to specify a subfolder for fetching R packages via remote repos within rix may be the best solution to this.

@b-rodrigues
Copy link

Hello, author of rix here, what would be the best approach to solve this? rix allows for IDEs to be specific in the ide argument, so would adding nvimcom to the buildInputs of the shell solve this issue if the user indicates ide = "vim"? @Neurarian could you share an example of a default.nix generated by rix you had to change to make it work properly with (n)vim?

@Neurarian
Copy link

Neurarian commented Feb 7, 2025

Hi, thanks for the great work and the fast reply!
The problem is, that nvimcom is an R package which would have to be specified within the rix function call to work inside the nix-shell at all (like R.Nvim itself, it is not part of nixpkgs). My overlay would not work, as rix is pulling the packages from the rstats-on-nix archive, so I would have to e.g., change the pkgs definition in default.nix to use nixpkgs as defined by my flake (which kinda defeats the purpose of rix). So my thought was to add another optional "subdir" element to the git_pkg parameter of the rix fetchgit() function to allow fetching R packages from specfic parts of a git repository via the sparseCheckout argument of nixpkgs' fetchgit() as it would be the case with nvimcom. However, I do believe that this would also require some tweaks to the get_sri_hash_deps() function, as I think that nixpkgs' fetchgit() determines the hash by the content it fetches. I could experiment with these ideas a bit and submit a pull request if this sound like a good idea. The other option would be a dedicated repo for nvimcom itself. Or perhaps I'm overlooking some better way to make it work.

@b-rodrigues
Copy link

I mean, we could simply add the following (by changing what’s needed, but most would stay I guess) to the default.nix:

      nvimcom = final.rPackages.buildRPackage {
        name = "nvimcom";
        src = final.fetchFromGitHub {
          owner = "R-nvim";
          repo = "R.nvim";
          rev = "main";
          sha256 = "sha256-5QYQRN5zQWGTSEpkNr7WHVe167vHtyytSE+vF10cdZI=";
        };
        sourceRoot = "source/nvimcom";
        buildInputs = with final; [R gcc gnumake];
        propagatedBuildInputs = with final.rPackages; [];
      };

when the user sets ide = "vim", no?

@Neurarian
Copy link

Neurarian commented Feb 7, 2025

Whops, of course you could just overlay it in default.nix itself! Sorry for the misinterpretation. I knew I missed something. I guess that's a way to do it. The problem is the hardcoded hash and that R.Nvim will complain if there is a version mismatch between itself and nvimcom, so optimally I guess R.Nvim would have to be included into the build inputs as well somehow. Personally I don't have an issue with manually updating it. But this is such a niche case, I'm not sure if this should be any kind of default for rix.

This is a working default.nix with a R.Nvim installed on the system if running impure:

let
  pkgs = import (fetchTarball "https://github.com/rstats-on-nix/nixpkgs/archive/2025-01-27.tar.gz") {
    overlays = [
      (final: prev: {
        rPackages =
          prev.rPackages
          // {
            nvimcom = final.rPackages.buildRPackage {
              name = "nvimcom";
              src = final.fetchFromGitHub {
                owner = "R-nvim";
                repo = "R.nvim";
                rev = "main";
                sha256 = "sha256-5QYQRN5zQWGTSEpkNr7WHVe167vHtyytSE+vF10cdZI=";
              };
              sourceRoot = "source/nvimcom";
              buildInputs = with final; [R gcc gnumake];
              propagatedBuildInputs = with final.rPackages; [];
            };
          };
      })
    ];
  };

  rpkgs = builtins.attrValues {
    inherit
      (pkgs.rPackages)
      dplyr
      ggplot2
      nvimcom
      ;
  };

  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];
  }

@b-rodrigues
Copy link

Thanks! 🤔 maybe we could get this into upstream, I guess it’ll make things easier. I have 0 experience with packaging vim extensions for nix though

@Neurarian
Copy link

Same. Even with upstreaming it, I imagine it would be a hassle to keep the nvimcom version in sync with R and R.nvim when using rix, where R.nvim can't just install nvimcom itself. But I'm quite happy that just adding the overlay to the import gets it working. Thanks for the help!

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

No branches or pull requests

5 participants