Neovim-nightly and emacs-pgtk-nativecomp overlays

I was learning how to use cachix with github actions and am now maintaining two overlays: neovim-nightly and pure gtk emacs with native compilation. The latter, a pure gtk port of the emacs gui, is not available in the nix-community overlay, as the pure gtk port of emacs has not yet been merged upstream (and it also is based on a branch that merges pure gtk and native compilation feature branches). I provide binaries via cachix for neovim-nightly for both mac and linux, and binaries for emacs-pgtk-nativecomp for linux.

5 Likes

thanks for providing this. I never managed to share my neovim-master derivation like you did. Do you run niv update or a cronjob ? I find the repo a bit overwhelming for a change that can be done by just overriding the src with builtins.fetchGit https://github.com/neovim/neovim.git; .
I plan to setup a sr.ht job as part of neovim’s upstream tests, which may come in handy too.

The repo is a bit huge, most of that is overhead from cachix/CI/CD/github actions/niv.

The update of the repo is done via niv with a cronjob using a github action:

name: Update niv

on:
  schedule:
    # every day at 8am UTC
    - cron: '0 8 * * *'

jobs:
  update-dependencies:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2.3.2
    - uses: cachix/install-nix-action@v10
    - run: nix-shell --run "niv update"
    - name: Create Pull Request
      uses: peter-evans/create-pull-request@v3
      with:
        commit-message: "chore: update niv dependencies"
        title: "chore: update niv dependencies"
        branch: "chore/update-niv-dependencies"

This automatically makes a PR, which I merge (triggering the CI which builds for linux and macos and pushes to cachix).

The other source of overhead is I version nixpkgs itself in the overlay with niv,


let
  sources = import ./nix/sources.nix;
  nixpkgs = sources."nixpkgs-unstable";
  pkgs = import nixpkgs {};
in
_: _:
  {
    neovim-nightly = pkgs.neovim-unwrapped.overrideAttrs (
      _: {
        version = "master";
        src = pkgs.fetchFromGitHub {
          inherit (sources.neovim) owner repo rev sha256;
        };
      }
    );
  }

There are two main reason I did this; I wanted to ensure that if you use the overlay, you are guaranteed not to have a nixpkgs-unstable hash mismatch and always hit my cachix cache. The second reason, is I wanted anyone who uses the overlay to be able to easily rollback to prior commits of neovim/nixpkgs, should there be a breaking change (which you don’t get when you replace the source with master) such as that which has happened surrounding lua/libluv.

The majority of the repository is taken straight from https://github.com/nix-dot-dev/getting-started-nix-template, but I’m happy to simplify or align with best practices!

Edit: Also, I think you helped me on IRC when I first started using nix and wanted to use neovim builds from master!

For those interested, I’ve added a flake.nix to neovim repository (not on master but in the flake branch:
https://github.com/neovim/neovim/blob/6b2ff65f3b12fe0cae8f5c6266816a7e63981f7e/flake.nix).

1 Like

Thanks @teto! On a separate note, I should also mention I am now providing binaries for nativecomp emacs on macOS via cachix in the emacs-pgtk-nativecomp overlay (not using pgtk of course).

@teto any chance you’re going to take a crack at getting tree-sitter working on aarch64? (sorry, this was a bit off-topic of me, feel free to ignore)

@colemickens nope sry, but I am sure big distribs like debian will contribute to this.

Just as an update, I recently refactored the overlay to use flakes and flakes-compat (for those using stable-nix). You shouldn’t have to change anything if you’re currently using the overlay.

I also added a GHA to auto merge commits, so now there won’t be a lag period of 1-2 days while I test things (which was never that comprehensive anyways). The nice part with this overlay is you can always pin the flake if you find a breakage, and will still hit the binary cache (if cachix hasn’t garbage collected it).

I have deprecated the emacs-pgtk-nativecomp overlay since most of the changes have been upstreamed into emacs-overlay, I still maintain a more flakified overlay (for which I provide macos binaries) here:

This version tracks nix-community/emacs-overlay closely

1 Like

And neovim-nightly-overlay has moved to nix-community! Be sure to add (if you haven’t already) the nix-community cachix binary cache

@mjlbach I have these two overlays. The first one is used to install neovim from master. The other one is used to have a neovim with its python client and other python modules. Using neovim-nightly-overlay is possible to have neovim with its python client and the python modules I have in this overlay? Thanks!

final: prev: {
  neovim-unwrapped = prev.neovim-unwrapped.overrideDerivation (oldAttrs: rec{
    pname = "neovim-unwrapped";
    version = "0.5.0";
    name = "${pname}-${version}";
    src = prev.pkgs.fetchFromGitHub {
      owner = "neovim";
      repo = "neovim";
      rev = "48caf1df8581a9a9da9072f901411b918333952d";
      sha256 = "sha256-gVyVFYMn9UF6U0UQK8oYxFltjS7YQnRKGGzdEQQ1oco=";
    };
    buildInputs = oldAttrs.buildInputs ++ [ prev.pkgs.tree-sitter ];
  });

  neovim = prev.neovim.override {
    extraPython3Packages = (ps: with ps; [
      pynvim
      black
      isort
      pylint
    ]);
    extraPythonPackages = (ps: with ps; [
      pynvim
    ]);
  };
}

Yes, neovim-nightly is the unwrapped neovim derivation just with substituted sources and tree sitter added to the build inputs, so you can treat it as such. You should be able to use wrapNeovim, to create a wrapped neovim, and then override the newly wrapped nightly the same way you do above.

Thanks @mjlbach, I did this ways, it seems to be correct:

final: prev: {
  neovim-nightly = prev.wrapNeovim prev.neovim-nightly {

    extraPython3Packages = (ps: with ps; [
      pynvim
      black
      isort
      pylint
    ]);

    extraPythonPackages = (ps: with ps; [
      pynvim
    ]);

    withNodeJs = true;

    withRuby = true;

  };
}
1 Like