Skip to content

Instantly share code, notes, and snippets.

@daniel-fahey
Created January 20, 2025 23:49
Show Gist options
  • Save daniel-fahey/29a6c6f18116e2582be2b94c9eff24aa to your computer and use it in GitHub Desktop.
Save daniel-fahey/29a6c6f18116e2582be2b94c9eff24aa to your computer and use it in GitHub Desktop.
NixVim custom plugin module loading issue after specialArgs.lib removal (reprex)
{
description = "NixVim Reprex VM Flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixvim = {
url = "github:nix-community/nixvim/b5efe91c5215aaaeefbb117d1951ea773e96ddd1"; # Breaking commit that removed specialArgs.lib
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nixvim, home-manager, ... }@inputs:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
# The minimal scnvim plugin module that demonstrates the issue
scnvim-module = { config, pkgs, lib, ... }: {
options.programs.nixvim.plugins.scnvim.enable = lib.mkEnableOption "scnvim";
config.programs.nixvim.extraPlugins = [ pkgs.vimPlugins.scnvim ];
};
in
{
nixosConfigurations.nixvim-test-vm = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
# Basic VM configuration
({ config, pkgs, ... }: {
virtualisation.vmVariant = {
virtualisation = {
memorySize = 2048;
cores = 2;
};
};
# Basic system configuration
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
system.stateVersion = "25.05";
# Auto-login and keyboard
services.getty.autologinUser = "nixos";
console.useXkbConfig = true;
services.xserver.exportConfiguration = true;
# Create nixos user
users.users.nixos = {
isNormalUser = true;
extraGroups = [ "wheel" ];
password = "nixos";
};
# Enable sudo without password for testing
security.sudo.wheelNeedsPassword = false;
})
# Home Manager with Nixvim
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.sharedModules = [
nixvim.homeManagerModules.nixvim
# WORKS: Loading custom plugin module here, lib.nixvim is available
scnvim-module
];
home-manager.users.nixos = {
# DOESN'T WORK: Loading module here results in 'attribute nixvim missing' error in cmp plugin.
# It appears the removal of specialArgs.lib has broken the ability to create custom plugin
# modules at the user level, while still working when loaded alongside NixVim's own module.
# imports = [ scnvim-module ];
home = {
stateVersion = "25.05";
username = "nixos";
homeDirectory = "/home/nixos";
};
programs.home-manager.enable = true;
programs.nixvim = {
enable = true;
plugins = {
scnvim.enable = true;
oil.enable = true;
};
};
};
}
];
};
};
}
@daniel-fahey
Copy link
Author

Build with nixos-rebuild build-vm --flake .#nixvim-test-vm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment