LnL7 / nix-darwin

nix modules for darwin
MIT License
2.79k stars 429 forks source link

Neovim nightly - how!? #316

Closed a-h closed 3 years ago

a-h commented 3 years ago

I'm trying to run a later version of Neovim with Nix, but I can't get it working with the configuration etc.

There's a community overlay at https://github.com/nix-community/neovim-nightly-overlay that lets me install neovim nightly by adding neovim-nightly to my environment.systemPackages, but it only takes effect if I also remove my custom vim configuration:

{ config, pkgs, ... }:

let

  coverage = pkgs.vimUtils.buildVimPlugin {
    name = "vim-coverage";
    src = pkgs.fetchFromGitHub {
      owner = "ruanyl";
      repo = "coverage.vim";
      rev = "1d4cd01e1e99d567b640004a8122be8105046921";
      sha256 = "1vr6ylppwd61rj0l7m6xb0scrld91wgqm0bvnxs54b20vjbqcsap";
    };
  };

  easygrep = pkgs.vimUtils.buildVimPlugin {
    name = "vim-easygrep";
    src = pkgs.fetchFromGitHub {
      owner = "dkprice";
      repo = "vim-easygrep";
      rev = "d0c36a77cc63c22648e792796b1815b44164653a";
      sha256 = "0y2p5mz0d5fhg6n68lhfhl8p4mlwkb82q337c22djs4w5zyzggbc";
    };
  };

  vimBuilder = pkgs.vimUtils.buildVimPlugin {
    name = "builder.vim";
    src = pkgs.fetchFromGitHub {
      owner = "b0o";
      repo = "builder.vim";
      rev = "940e0deff0fb4ff2c4fdfe263cdbe669152688c6";
      sha256 = "1synvwz7xqy68wb45rdy5lscp2z19wdd7wnp07smylv4jcnlya51";
    };
  };

  vimQuicktemplate = pkgs.vimUtils.buildVimPlugin {
    name = "quicktemplate.vim";
    src = pkgs.fetchFromGitHub {
      owner = "b0o";
      repo = "quicktemplate.vim";
      rev = "c2aed012c0de37303509e93d3010524a361a7795";
      sha256 = "1lgjj01cifvkqgikr976b45j9cdhrc28wzhr7bshf400g1fwfdim";
    };
  };

  python-with-global-packages = pkgs.python3.withPackages(ps: with ps; [
    pip
    botocore
    boto3
    numpy
  ]);

  #goreleaser = pkgs.callPackage ./goreleaser.nix {};
  goreplace = pkgs.callPackage ./goreplace.nix {};
  twet = pkgs.callPackage ./twet.nix {};

  nodePackages = import ./node-env/default.nix {
    inherit pkgs;
  }; 

in

{
  nixpkgs.config.allowUnfree = true;
  environment.variables = { EDITOR = "vim"; };

  nixpkgs.overlays = [
    (import (builtins.fetchTarball {
      url = https://github.com/nix-community/neovim-nightly-overlay/archive/master.tar.gz;
    }))
  ];

  # List packages installed in system profile. To search by name, run:
  # $ nix-env -qaP | grep wget
  environment.systemPackages =
    [
      #goreleaser
      goreplace
      twet
      nodePackages."@aws-amplify/cli"
      #awsSamCli
      python-with-global-packages
      pkgs.awslogs
      pkgs.aerc
      pkgs.asciinema
      pkgs.awscli2
      pkgs.ssm-session-manager-plugin
      pkgs.aws-vault
      pkgs.docker
      pkgs.dotnetCorePackages.sdk_3_1
      pkgs.fzf
      pkgs.gcalcli
      pkgs.gifsicle
      pkgs.git
      pkgs.gitAndTools.gh
      pkgs.gnupg
      pkgs.go
      pkgs.gopls
      pkgs.goimports
      pkgs.graphviz
      pkgs.htop
      pkgs.hugo
      pkgs.imagemagick
      pkgs.jq
      pkgs.lynx
      pkgs.mutt
      pkgs.nmap
      pkgs.nodejs
      pkgs.nodePackages.prettier
      pkgs.nodePackages.typescript
      pkgs.nodePackages.node2nix
      pkgs.pass
      pkgs.ripgrep
      pkgs.terraform
      pkgs.tmux
      pkgs.tree
      pkgs.unzip
      pkgs.urlscan
      pkgs.wget
      pkgs.yarn
      pkgs.zip
      pkgs.neovim-nightly
      #(
     #pkgs.neovim.override {
        #vimAlias = true;
        #configure = {
          #packages.myPlugins = with pkgs.vimPlugins; {
        #start = [
          #vim-go
          #vim-lastplace
          #vim-nix
          #coc-prettier
          #coc-nvim
          #coc-tsserver # neoclide/coc-tsserver
          #vim-jsx-typescript
          #vim-graphql
          #coc-json
          #nerdcommenter #preservim/nerdcommenter
          #ctrlp #ctrlpvim/ctrlp.vim
          #vim-sleuth #tpope/vim-sleuth
          #vim-surround #tpope/vim-surround
          #vim-test #janko/vim-test
          #coverage #ruanyl/coverage.vim
          #ultisnips #SirVer/ultisnips
          #vim-snippets #honza/vim-snippets
          #vim-visual-multi #mg979/vim-visual-multi
          #easygrep #dkprice/vim-easygrep
          ##nvim-lspconfig #https://neovim.io/doc/user/lsp.html#lsp-extension-example
        #];
        #opt = [];
          #};
          #customRC = builtins.readFile ./../dotfiles/.vimrc;
      #};
    #}
      #)
    ];

  programs.zsh.enable = true;  # default shell on catalina

  # Used for backwards compatibility, please read the changelog before changing.
  # $ darwin-rebuild changelog
  system.stateVersion = 4;
}

I think I've tried every permutation possible to try and get my custom config loaded into neovim-nightly.

The obvious thing to try is switching neovim to neovim-nightly produces an error that vimAlias is an unexpected argument:

      (
     pkgs.neovim-nightly.override {
        vimAlias = true;
        configure = {
          packages.myPlugins = with pkgs.vimPlugins; {
        start = [
          vim-go
          vim-lastplace
          vim-nix
          coc-prettier
          coc-nvim
          coc-tsserver # neoclide/coc-tsserver
          vim-jsx-typescript
          vim-graphql
          coc-json
          nerdcommenter #preservim/nerdcommenter
          ctrlp #ctrlpvim/ctrlp.vim
          vim-sleuth #tpope/vim-sleuth
          vim-surround #tpope/vim-surround
          vim-test #janko/vim-test
          coverage #ruanyl/coverage.vim
          ultisnips #SirVer/ultisnips
          vim-snippets #honza/vim-snippets
          vim-visual-multi #mg979/vim-visual-multi
          easygrep #dkprice/vim-easygrep
          #nvim-lspconfig #https://neovim.io/doc/user/lsp.html#lsp-extension-example
        ];
        opt = [];
          };
          customRC = builtins.readFile ./../dotfiles/.vimrc;
      };
    }
      )
error: anonymous function at /nix/store/r85slpvs1z7gykc968bbsqy3dmcc1a5h-source/pkgs/applications/editors/neovim/default.nix:1:1 called with unexpected argument 'vimAlias', at /nix/store/r85slpvs1z7gykc968bbsqy3dmcc1a5h-source/lib/customisation.nix:79:63

I've been Googling and reading around, but keep coming up against solutions that seem to be designed for NixOS, or Home Manager, or overlays, or overrides or flakes. Anything except what I'm trying to do!

How can I run 0.5 of Neovim, complete with my configuration?

a-h commented 3 years ago

The maintainer of the neovim-nightly-overlay responded to my (closed) issue saying that they'd made some changes and it now just works. Here's the commit that got me working: https://github.com/a-h/dotfiles/commit/dd56c35908958a4abf727ab590421b93b071486e

573 commented 2 years ago

The maintainer of the neovim-nightly-overlay responded to my (closed) issue saying that they'd made some changes and it now just works. Here's the commit that got me working: a-h/dotfiles@dd56c35

In https://github.com/a-h/dotfiles/blob/dd56c35908958a4abf727ab590421b93b071486e/.nixpkgs/darwin-configuration.nix#L124 you're using but neovim not neovim-nightly. Just asking bc I'm still experiencing same issue when using neovim-nightly and would like to learn if that is supposed to work by the change.

thx

a-h commented 2 years ago

Sorry, no idea. Since Neovim 0.6 came out, I've been happy, and have pegged my version to Neovim 6 for the time being:

  neovim6Revision = import (builtins.fetchTarball {
    name = "nixos-unstable-2022-01-01";
    url = "https://github.com/nixos/nixpkgs/archive/9d6d1a474b946c98168bf7fee9e4185ed11cfd8f.tar.gz";
    # Hash obtained using `nix-prefetch-url --unpack <url>`
    # https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/neovim/default.nix
    sha256 = "183q04asndwganf31q4fx0aigc20ad6ixs56m92y3d4iry70qv91";
  }) {};
  neovim6 = neovim6Revision.neovim;
573 commented 2 years ago

Tested using this commits pkgs.neovim.override it worked and installed the expected version of neovim according to the neovim-nightly-overlay.

The maintainer of the neovim-nightly-overlay responded to my (closed) issue saying that they'd made some changes and it now just works. Here's the commit that got me working: a-h/dotfiles@dd56c35

In https://github.com/a-h/dotfiles/blob/dd56c35908958a4abf727ab590421b93b071486e/.nixpkgs/darwin-configuration.nix#L124 you're using but neovim not neovim-nightly. Just asking bc I'm still experiencing same issue when using neovim-nightly and would like to learn if that is supposed to work by the change.

thx