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

Nix flake input ignored when using nixvim with home-manager and NixOS #333

Closed
GaetanLepage opened this issue Apr 14, 2023 · 8 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@GaetanLepage
Copy link
Member

When using the nixvim HM/NixOS modules, the nixpkgs input of the flake is ignored in favor of whatever version of nixpkgs is used by home-manager (or NixOS).
This has annoying consequences:

  • A user following an older channel of nixpkgs or who did not updated his flake's inputs recently enough can suffer from bugs.
    Example: error: attribute 'typst-lsp' missing #332
  • Oppositely, if a user updates his nixpkgs, and the latter contains vim plugins updates which are not compatible with nixvim can suffer from breakage/deprecation warnings.

Ideally, we would like nixvim to use its own nixpkgs input. This can let us (nixvim maintainers) pin nixpkgs to a version we know works and only update it carefully after some testing.
Users could still override this (at their own risk) by setting for instance inputs.nixvim.inputs.nixpkgs.follows = "nixpkgs";.

Note: when using the standalone nixvim wrapper, the behavior is correct. The problem is only present for the HM and NixOS modules.

@GaetanLepage
Copy link
Member Author

After discussing with other home-manager contributors, it seems that we should keep on with the current behavior.
Indeed, home-manager modules are expected to use the same import of nixpkgs as home-manager.

Hence, we have decided to adopt the following approach: The nixvim repo will have two branches: main which is adapted to nixos-unstable users and a 23.05 branch for stable (nixos-23.05) users.
Note: this idea is from @traxys.
This strategy will be effective from the release of nixos-23.05 which should be around 05/22/2023.

@mikkel1156
Copy link

Thought about writing here instead of opening a new issue.

I there a way to get the effect you are mentioning? I'd like to keep my system on stable and only let nixvim use unstable packages.

Almost got it working using overlays to have the missing packages from unstable in nixpkgs. But some parts of the code use new lib features from unstable so it wasn't enough.

Right now I am using HM and NixOS with flakes.

@siph
Copy link
Contributor

siph commented Sep 10, 2023

If you're willing to build a standalone config you can use whichever nixpkgs you want.

@mikkel1156
Copy link

mikkel1156 commented Sep 10, 2023

If you're willing to build a standalone config you can use whichever nixpkgs you want.

I tried using the makeNixvimWithModule function without success, it's giving me an error I can't find much info on.

nvim = nixvim.legacyPackages.${system}.makeNixvimWithModule {
        pkgs = import nixpkgs-unstable {
          inherit system;
          config.allowUnfree = true;
        };
        module = {
          config = {
            luaLoader.enable = true;
          };
        };
      };
error: The option `__ignoreNulls' does not exist. Definition values:
       - In `<unknown-file>': true

Though this might be something that will require it's own issue then.

@siph
Copy link
Contributor

siph commented Sep 10, 2023

If you generate an external config in it's own flake with:

nix flake init --template github:nix-community/nixvim

Then you can treat that as its own separate project with its own set of flake inputs. To use it in your NixOS configuration you can add it as a flake input to your NixOS flake and you can grab the derivations from the external flake (something like inputs.nixvim-flake.packages.${system}.default;).

@siph
Copy link
Contributor

siph commented Sep 11, 2023

I wrote a small guide here: https://gist.github.com/siph/288b7c6b5f68a1902d28aebc95fde4c5

@GaetanLepage
Copy link
Member Author

I wrote a small guide here: https://gist.github.com/siph/288b7c6b5f68a1902d28aebc95fde4c5

Thank you very much for this guide !
Would you mind if we somehow include it in the default nixvim documentation ?

@siph
Copy link
Contributor

siph commented Sep 13, 2023

Thank you very much for this guide ! Would you mind if we somehow include it in the default nixvim documentation ?

Sure.

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

No branches or pull requests

5 participants