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

Nixos Module Broken #19

Closed
OrdoFlammae opened this issue May 11, 2022 · 14 comments · Fixed by #34
Closed

Nixos Module Broken #19

OrdoFlammae opened this issue May 11, 2022 · 14 comments · Fixed by #34
Labels
bug Something isn't working

Comments

@OrdoFlammae
Copy link

OrdoFlammae commented May 11, 2022

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.

@pta2002
Copy link
Collaborator

pta2002 commented May 12, 2022 via email

@OrdoFlammae
Copy link
Author

OrdoFlammae commented May 13, 2022

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 OrdoFlammae changed the title Must use neovim-unwrapped? Nixos Module Broken May 13, 2022
@OrdoFlammae
Copy link
Author

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
Copy link
Author

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.

@pta2002
Copy link
Collaborator

pta2002 commented May 17, 2022

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 pta2002 added the bug Something isn't working label May 17, 2022
@OrdoFlammae
Copy link
Author

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.

@pta2002
Copy link
Collaborator

pta2002 commented May 17, 2022

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.

@jhilker98
Copy link

I've noticed the same issue as well.

@pta2002
Copy link
Collaborator

pta2002 commented Aug 25, 2022

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

@jhilker98
Copy link

jhilker98 commented Aug 25, 2022

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?

@OrdoFlammae
Copy link
Author

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.

@jhilker98
Copy link

alright, my bad.

@pta2002
Copy link
Collaborator

pta2002 commented Aug 26, 2022

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!

@dit7ya
Copy link

dit7ya commented Aug 26, 2022

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?

@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
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants