Skip to content

nixvim: can't extend package #1379

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

Open
2 tasks done
Felipe-9 opened this issue May 24, 2025 · 9 comments
Open
2 tasks done

nixvim: can't extend package #1379

Felipe-9 opened this issue May 24, 2025 · 9 comments
Labels
kind: bug Unintended behavior

Comments

@Felipe-9
Copy link

I assert that this issue is relevant for Stylix

  • I assert that this is a bug and not a user error or support request.
  • I assert that this is not a duplicate of an existing issue.

Description

Followint the instructions on the manual i get the following error:

error: attribute 'extend' missing
       at /nix/store/0xcrk95509nldwmh7kf17ws9w91icrvf-source/modules/core/base/texteditors/nvim.nix:15:21:
           14|
           15|   nixvim-extended = nixvim.extend config.lib.stylix.nixvim.config;
             |                     ^
           16|   nvf-extended = nvf.extend config.lib.stylix.nvf.config;

This is the config file in question:

{
  lib,
  config,
  pkgs,
  inputs,
  ...
}:
let
  cfg = config.modules.nvim;
  inherit (pkgs.stdenv.hostPlatform) system;

  nixvim = inputs.nixvim-wrapped.packages.${system}.default;
  nvf = inputs.nixvim-wrapped.packages.${system}.default;

  nixvim-extended = nixvim.extend config.lib.stylix.nixvim.config;
  nvf-extended = nvf.extend config.lib.stylix.nvf.config;

  inherit (config.modules) stylix;
in
{
  options.modules.nvim = {
    enable = lib.mkEnableOption "enable nvim configuration";
    pkg = lib.mkOption {
      type = lib.types.enum [
        "nixvim"
        "nvf"
      ];
      default = "nixvim";
      description = ''
        chose which neovim configuration to use:
        "nixvim" default and more reliable and more complete
        "nvf" very new and very incomplete
      '';
    };
  };

  config = lib.mkIf cfg.enable {
    environment = {
      variables.EDITOR = "nvim";
      systemPackages = [
        (
          if cfg.pkg == "nixvim" then
            (if stylix.enable then nixvim-extended else nixvim)
          else
            (if stylix.enable then nvf-extended else nvf)
        )
      ];
    };
  };
}

flake.lock

Field can not be longer than 65536 characters

Installation Method

NixOS

System Information

  • system: "x86_64-linux"
  • host os: Linux 6.12.28, NixOS, 25.11 (Xantusia), 25.11.20250518.292fa7d
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.28.3
  • channels(root): "nixos"
  • nixpkgs: /nix/store/wkjmkjrfr9ik1blw8zmv9g5xjl412py8-source

Notify maintainers

@trueNAHO

@Felipe-9 Felipe-9 added the kind: bug Unintended behavior label May 24, 2025
@awwpotato awwpotato changed the title cant extend nixvim package nixvim: can't extend package May 25, 2025
@MattSturgeon
Copy link
Member

MattSturgeon commented May 27, 2025

How are you creating the nixvim package?

If you're using the "old" way documented in nixvim's docs (makeNixvim), then it should add an extend function to the package's passthru.

However, if you're creating a nixvim configuration and reading its config.build.package option, then this doesn't have an extend function.

It is assumed that if you're using a nixvim configuration, you can use the configuration's extendModules function instead.

@Felipe-9
Copy link
Author

Actually i use nixvim as standalone, you can check on my flake right here: https://gitlab.com/felipepinto-flakes/nixvim-wrapped

@MattSturgeon
Copy link
Member

you can check on my flake right here: https://gitlab.com/felipepinto-flakes/nixvim-wrapped

You're using the new/experimental standalone template, not the old/documented standalone function.

As above, that's why you don't have an extend function on your nixvim package.

Instead you should extend your nixvim configuration and use its package.

@Felipe-9
Copy link
Author

Oh i see, im a bit confused how to proceed, is it the right way to add stylix as input to my nixvim flake? how should i add the makeNixivm?

@MattSturgeon
Copy link
Member

MattSturgeon commented May 27, 2025

In your NixOS or Home Manager configuration, you want to extend your Nixvim configuration.

This is just an example, I haven't checked the attrpaths are correct:

{ inputs, config, pkgs, ... }:
let
  system = pkgs.stdenv.hostPlatform.system;
  nixvimConfiguration = inputs.nixvim-config.nixvimConfigurations.${system}.default;

  extendedNixvim nixvimConfiguration.extendModules {
    modules = [
      config.lib.stylix.nixvim.config
    ];
  };

  nixvimPackage = extendedNixvim.config.build.package;
in
{
  home.packages = [
    nixvimPackage
  ];
}

Alternatively, you may find it simpler to use nixvim's home-manager module, and import your nixvimModule into it to reuse your config:

{ inputs, config, ... }:
{
  imports = [
    inputs.nixvim-config.inputs.nixvim.homeModules.default
  ];

  programs.nixvim = {
    enable = true;

    imports = [
      config.lib.stylix.nixvim.config
      inputs.nixvim-config.nixvimModules.default
    ];
  };
}

These examples are probably full of typos as I just knocked them up quickly on my phone.

@Felipe-9
Copy link
Author

I tried the following but got that the extendModule function is missing.

{
  lib,
  config,
  pkgs,
  inputs,
  ...
}:
let
  cfg = config.modules.nvim;
  inherit (pkgs.stdenv.hostPlatform) system;

  nixvim = inputs.nixvim-wrapped.packages.${system}.default;
  nvf = inputs.nixvim-wrapped.packages.${system}.default;

  nixvim-extended =
    (nixvim.extendModules { modules = [ config.lib.stylix.nixvim.config ]; }).config.build.package;
  nvf-extended =
    (nvf.extendModules { modules = [ config.lib.stylix.nvf.config ]; }).config.build.package;

  inherit (config.modules) stylix;
in
{
  options.modules.nvim = {
    enable = lib.mkEnableOption "enable nvim configuration";
    pkg = lib.mkOption {
      type = lib.types.enum [
        "nixvim"
        "nvf"
      ];
      default = "nixvim";
      description = ''
        chose which neovim configuration to use:
        "nixvim" default and more reliable and more complete
        "nvf" very new and very incomplete
      '';
    };
  };

  config = lib.mkIf cfg.enable {
    environment = {
      variables.EDITOR = "nvim";
      systemPackages = [
        (
          if cfg.pkg == "nixvim" then
            (if stylix.enable then nixvim-extended else nixvim)
          else
            (if stylix.enable then nvf-extended else nvf)
        )
      ];
    };
  };
}

@Felipe-9
Copy link
Author

I also tryied the hm but got another error:

error: attribute 'homeModules' missing
┃        at /nix/store/ax8czhlrsvmr0xbl8wamnhbpgpd3ymay-source/modules/home/base/nvim.nix:24:5:
┃            23|   imports = [
┃            24|     inputs.nixvim-wrapped.inputs.nixvim.homeModules.default
┃              |     ^
┃            25|     inputs.nvf-wrapped.inputs.nvf.homeModules.default

this is the config:

{
  lib,
  config,
  pkgs,
  inputs,
  ...
}:
let
  cfg = config.modules.nvim;
  inherit (pkgs.stdenv.hostPlatform) system;

  # nixvim = inputs.nixvim-wrapped.packages.${system}.default;
  # nvf = inputs.nixvim-wrapped.packages.${system}.default;

  # nixvim-extended =
  #   (nixvim.extendModules { modules = [ config.lib.stylix.nixvim.config ]; }).config.build.package;
  # nvf-extended =
  #   (nvf.extendModules { modules = [ config.lib.stylix.nvf.config ]; }).config.build.package;

  inherit (config.modules) stylix;
in
{
  imports = [
    inputs.nixvim-wrapped.inputs.nixvim.homeModules.default
    inputs.nvf-wrapped.inputs.nvf.homeModules.default
  ];

  options.modules.nvim = {
    enable = lib.mkEnableOption "enable nvim configuration";
    pkg = lib.mkOption {
      type = lib.types.enum [
        "nixvim"
        "nvf"
      ];
      default = "nixvim";
      description = ''
        chose which neovim configuration to use:
        "nixvim" default and more reliable and more complete
        "nvf" very new and very incomplete
      '';
    };
  };

  config = lib.mkIf cfg.enable {
    home.sessionVariables = {
      EDITOR = "nvim";
    };
    programs = lib.mergeAttrs [
      (lib.mkIf (cfg.pkg == "nixvim") {
        nixvim = {
          enable = true;
          imports = [
            inputs.nixvim-wrapped.nixvimModules.default
          ] ++ (lib.mkOptional stylix.enable config.lib.stylix.nixvim.config);
        };
      })
      (lib.mkIf (cfg.pkg == "nvf") {
        nvf = {
          enable = true;
          imports = [
            inputs.nvf-wrapped.nvfModules.default
          ] ++ (lib.mkOptional stylix.enable config.lib.stylix.nvf.config);
        };
      })
    ];
  };
}

@MattSturgeon
Copy link
Member

nixvim = inputs.nixvim-wrapped.packages.${system}.default;
# ...
nixvim-extended =
    (nixvim.extendModules

A configuration and a package are two different things.

Here you're trying to use extendModules on a package, when this function only exists on configurations.

Your configurations are defined in your nixvimConfigurations flake output. Your packages are defined in your packages flake output. Nixvim's package is available from a nixvim configuration at the read-only build.package option.


I also tryied the hm but got another error:

error: attribute 'homeModules' missing
┃        at /nix/store/ax8czhlrsvmr0xbl8wamnhbpgpd3ymay-source/modules/home/base/nvim.nix:24:5:
┃            23|   imports = [
┃            24|     inputs.nixvim-wrapped.inputs.nixvim.homeModules.default
┃              |     ^
┃            25|     inputs.nvf-wrapped.inputs.nvf.homeModules.default

This flake output was recently renamed in nixvim. If you have an up-to-date nixvim lock you should be able to use homeModules. If you have an older revision of nixvim, you should use homeManagerModules.

@Felipe-9
Copy link
Author

Felipe-9 commented Jun 1, 2025

A configuration and a package are two different things.

Oooh ok, well from this im confused how to reach the nixvim config from my computer configuration. im imported the wrapped nixvim as a flake input, how should i extend then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants