nixvim icon indicating copy to clipboard operation
nixvim copied to clipboard

Nixos Module Broken

Open OrdoFlammae opened this issue 3 years ago • 14 comments

Hi y'all. I'm not super experienced with Nix, so this may just be something that I don't quite understand, but I could not use this because I was getting errors along the lines of

> substituteStream(): WARNING: pattern 'Name=Neovim' doesn't match anything in file '/nix/store/mv12ajfnyndzdc1isj0kgmwdjm61n023-neovim-0.7.0/share/applications/nvim.desktop'
> /nix/store/zwrxbc3d1kzgnkqg0i0zn0fgakcw212a-hook/nix-support/setup-hook: line 110: /nix/store/fgicl65q7nz56jd5ngd5glsblgb1lq53-neovim-0.7.0/bin/nvim-python3: Permission denied

I Finally found this: https://discourse.nixos.org/t/help-needed-neovim-completions-fail-to-build/14223, and fixed the problem by setting package = pkgs.neovim-unwrapped. Shouldn't this be a default, if it doesn't work out-of-the-box? I don't entirely understand why this happens, though, so maybe I'm just mistaken.

OrdoFlammae avatar May 11 '22 21:05 OrdoFlammae

Hi, this isn't something I have experienced before, and I don't override the default, but it might be a bug in the newer versions. I'll make sure to check this out soon.

A quarta, 11/05/2022, 22:05, Aiden Loyd @.***> escreveu:

Hi y'all. I'm not super experienced with Nix, so this may just be something that I don't quite understand, but I could not use this because I was getting errors along the lines of

substituteStream(): WARNING: pattern 'Name=Neovim' doesn't match anything in file '/nix/store/mv12ajfnyndzdc1isj0kgmwdjm61n023-neovim-0.7.0/share/applications/nvim.desktop' > /nix/store/zwrxbc3d1kzgnkqg0i0zn0fgakcw212a-hook/nix-support/setup-hook: line 110: /nix/store/fgicl65q7nz56jd5ngd5glsblgb1lq53-neovim-0.7.0/bin/nvim-python3: Permission denied


I Finally found this: https://discourse.nixos.org/t/help-needed-neovim-completions-fail-to-build/14223, and fixed the problem by setting `package = pkgs.neovim-unwrapped`. Shouldn't this be a default, if it doesn't work out-of-the-box? I don't entirely understand *why* this happens, though, so maybe I'm just mistaken.

—
Reply to this email directly, view it on GitHub
<https://github.com/pta2002/nixvim/issues/19>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYZLTF6BU24GCL47LHFMTDVJQOJHANCNFSM5VWGEYBA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>

pta2002 avatar May 12 '22 04:05 pta2002

I think this is actually a symptom of a much broader issue, and I'm still trying to pin it down exactly. It works fine with the setup in home-manager (which is what I think you use, looking at your dotfiles), and package can be left as default. However, with the setup in nixos, it breaks a number of things, of which this is just one. With the exact same config as with home-manager (changing package = pkgs.neovim-unwrapped), it will install neovim, but it will not apply any configuration or plugins.

OrdoFlammae avatar May 13 '22 03:05 OrdoFlammae

Additional note: home-manager uses neovim-unwrapped by default as the base package, so that is why it isn't crashing and burning when you don't set it in that mode. The nixos module does no such thing.

OrdoFlammae avatar May 13 '22 22:05 OrdoFlammae

Status: I've figured out why the config is not being copied across, you have to add customRC = configure.customRC in the neovimConfig definition. Still working on why plugins are being ignored.

OrdoFlammae avatar May 13 '22 22:05 OrdoFlammae

Hey, finally have time to work on this, can you show me what your config looks like? Because I've not had this issue myself.

pta2002 avatar May 17 '22 12:05 pta2002

nixvim.nix:

{ pkgs, ... }: {
  enable = true;

  colorscheme = "one";
  colorschemes.one.enable = true;

  plugins.airline.enable = true;

  plugins.lsp.enable = true;
  plugins.lsp.servers.rnix-lsp.enable = true;

  options = {
    shiftwidth = 2;
    tabstop = 2;
    expandtab = true;

    modeline = false;
  };

  extraConfigLua = ''
    vim.opt.formatoptions:remove('t')
    vim.opt.linebreak = true

    vim.api.nvim_command('filetype indent plugin on')
    vim.api.nvim_command('syntax on')
  '';

  extraPlugins = with pkgs.vimPlugins; [
    vim-nix
  ];
}

flake.nix:

{
  description = "My NixOS config";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    nixvim.url = "github:pta2002/nixvim";
    home-manager.url = "github:nix-community/home-manager";
  };

  outputs = { self, nixpkgs, nixvim, home-manager, ... } @ inputs:
  let
    system = "x86_64-linux";

    pkgs = import nixpkgs {
      inherit system;

      config = {
        allowUnfree = true;
      };
    };
  in {
    nixosConfigurations = {
      ordoflammae-virtual = nixpkgs.lib.nixosSystem {
        inherit system;

        specialArgs = inputs;

        modules = [
          {
            boot = {
              loader.grub = {
                enable = true;
                version = 2;
                device = "/dev/sda";
              };

              initrd = {
                availableKernelModules = [ "ata_piix" "ohci_pci" "ahci" "sd_mod" "sr_mod" ];
                kernelModules = [ ];
              };

              kernelModules = [ ];
              extraModulePackages = [ ];
            };

            fileSystems = {
              "/" = {
                device = "/dev/disk/by-label/nixos";
                fsType = "ext4";
              };

              "/nixos" = {
                fsType = "vboxsf";
                device = "nixos";
                options = [ "rw" "nofail" ];
              };
            };

            swapDevices = [
              { device = "/dev/disk/by-label/swap"; }
            ];

            hardware.cpu.intel.updateMicrocode = false;
            virtualisation.virtualbox.guest.enable = true;

            nix = {
              package = pkgs.nixFlakes;
              extraOptions = ''
                experimental-features = nix-command flakes
              '';
            };

            networking = {
              hostName = "ordoflammae-virtual";
              useDHCP = false;
              interfaces.enp0s3.useDHCP = true;
            };

            users.users.ordoflammae = {
              isNormalUser = true;
              extraGroups = [ "wheel" "sudo" "vboxsf" ];
            };

            environment.systemPackages = with pkgs; [
              curl
              git
            ];

            imports = [ nixvim.nixosModules.nixvim ];

            programs.nixvim = import ./nixvim.nix { inherit pkgs; };

            system.stateVersion = "21.11";
          }
        ];
      };
    };
  };
}

My guess is that the reason you haven't seen this is that this is only an issue with nixosModules, and there are no issues when using the home-manager setup.

OrdoFlammae avatar May 17 '22 17:05 OrdoFlammae

Seems like it! As part of my work with #16, this should get fixed soon, since I am effectively redoing the whole non-HM setup from scratch.

pta2002 avatar May 17 '22 18:05 pta2002

I've noticed the same issue as well.

jhilker98 avatar Aug 25 '22 21:08 jhilker98

For now, I'd recomend using the standalone branch, and not using the NixOS module, instead using the build function and putting it on environment.systemPackages:

{
  environment.systemPackages = [
    # ...
    (nixvim.build "x86_64-linux" {
      colorschemes.gruvbox.enable = true;
      # etc...
    })
  ];
}

This branch will get merged soon, I just need to get the NixOS and home-manager modules working, but the standalone build function is working perfectly fine!

Let me know if you need any help

pta2002 avatar Aug 25 '22 23:08 pta2002

i've been using it in home-manager and an alias to use my config. As a side question, is it possible to use nix-colors to create a colorscheme in nixvim?

jhilker98 avatar Aug 25 '22 23:08 jhilker98

i've been using it in home-manager and an alias to use my config. As a side question, is it possible to use nix-colors to create a colorscheme in nixvim?

Please make a new issue for this, I know it's difficult on everyone (maintainer and future readers) when issues are not kept on-topic.

OrdoFlammae avatar Aug 26 '22 00:08 OrdoFlammae

alright, my bad.

jhilker98 avatar Aug 26 '22 00:08 jhilker98

As a side question, is it possible to use nix-colors to create a colorscheme in nixvim?

There isn't any nix-colors module right now, but I can add one. If you have any extra requests regarding it though, or some idea for how it should work, please do create an issue though!

pta2002 avatar Aug 26 '22 08:08 pta2002

I tried to use this package today using the homeManager module but it failed with something like programs.neovim.extraConfig is no longer a valid option. Any help?

dit7ya avatar Aug 26 '22 11:08 dit7ya