Skip to content
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

use without HM or nixos #16

Closed
edrex opened this issue Apr 18, 2022 · 3 comments · Fixed by #34
Closed

use without HM or nixos #16

edrex opened this issue Apr 18, 2022 · 3 comments · Fixed by #34
Labels
enhancement New feature or request

Comments

@edrex
Copy link

edrex commented Apr 18, 2022

I would like to use nixvim in a prototype runnable flake "env" project https://github.com/aquiferma/noter (see discussion 1). For this, I need a myNeoVim package with config/customizations baked in.

There is a broader design need at the ecosystem level to define an ergonomic relationship between flakes and the module system outside the context of HM/nixos, but nixvim seems an OK place to pick up the conversation.

It seems like a "quick fix" might be to inline or maybe wrap one of the programs.neovim modules 23.

Also probably worth a look, @syberant's nix-neovim flake 4, which IIUC inlines its own module system for config, and only calls pkgs.wrappedNeoVim.

Footnotes

  1. https://github.com/aquiferma/noter/issues/2

  2. https://github.com/nix-community/home-manager/blob/master/modules/programs/neovim.nix

  3. https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/programs/neovim.nix

  4. https://github.com/syberant/nix-neovim/blob/main/flake.nix

@pta2002
Copy link
Collaborator

pta2002 commented Apr 18, 2022

Hey, thanks for the pointers! This is actually something I've wanted to do for a while, but never quite figured out/had the patience to look into. It's definitely doable, so I'll look into what you suggested!

@syberant
Copy link

syberant commented Apr 22, 2022

Hi! My flake does indeed use a separate module system for config (so no programs.nix-neovim.vim.g.showmode = false but just vim.g.showmode = false).
Doing this is surprisingly easy as you can reuse the library functions implementing NixOS's module system (extra benefit: you can also automatically generate documentation a la man configuration.nix).
The relevant piece from my flake.nix is this part:

buildNeovim = { pkgs ? dpkgs, configuration }:
  let
    eval = evalModules {
      modules = getNixFiles ./modules ++ [
        (rec {
          _file = ./flake.nix;
          key = _file;
          config = {
            _module.args.pkgs = mkForce pkgs;
            _module.args.vimLib = import ./lib { lib = pkgs.lib; };
          };
        })

        configuration
      ];
    };
  in eval.config.product.binary;

Here configuration is your entry point configuration module, evalModules is just pkgs.lib.evalModules and product.binary is the read-only option that contains the final executable.

To actually use the resulting binary you have to add something like environment.systemPackages = [ (nix-neovim.buildNeovim { inherit pkgs; configuration = ./some-file.nix; }) ] to your NixOS configuration.

Not really sure if this style is something you want but feel free to ask me any questions!

@pta2002 pta2002 added the enhancement New feature or request label May 17, 2022
@pta2002
Copy link
Collaborator

pta2002 commented Jun 5, 2022

I've been working on this on the standalone branch, if you want to check it out! As far as I can tell, the only thing left to support on this branch are the home-manager and NixOS modules. However, if you use it, you can generate a package derivation like this:

{
  outputs = { self, nixvim, ... }: {
    nvim-with-gruvbox = nixvim.build "x86_64-linux" {
      colorschemes.gruvbox.enable = true;
    };
  };
}

If you have any questions please ask!

@pta2002 pta2002 mentioned this issue Aug 23, 2022
6 tasks
@pta2002 pta2002 linked a pull request Aug 27, 2022 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants