Hey everyone !
Because I’m using Neovim both on my NixOS computer and Work computer (Ubuntu) I’ve decided to use a FHS environment to run Neovim. This helps avoid doing changes to my config in my work laptop to then see it doesn’t work when I’m on NixOS.
I’ve struggled a lot, but thanks to Ioga Master config I was able to make it work and understand better what overlays are.
My current config looks like this:
My global flake.nix
{
description = "My first Flake";
inputs = {
neovim-flake = { url="./flakes/neovim"; };
nixpkgs.url = "nixpkgs/nixos-25.11";
home-manager = {
url = "github:nix-community/home-manager/release-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
ashell.url = "github:romanstingler/ashell/e26d2591a3472548b199c5f9396fe7186f1cec56";
};
outputs = { ... }@inputs: {
nixosConfigurations.nixos-btw = inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
};
system = "x86_62-linux";
modules = [
./configuration.nix
{
nixpkgs.overlays = [ inputs.neovim-flake.overlays.default ]; # <--- HERE
}
inputs.home-manager.nixosModules.home-manager
{
home-manager = {
extraSpecialArgs = {inherit inputs; };
useGlobalPkgs = true;
useUserPackages = true;
users.henmir = import ./home.nix;
backupFileExtension = "backup";
};
}
];
};
};
}
neovim/neovim.nix
{ lib, wrapNeovimUnstable, neovim-unwrapped, neovimUtils, writeShellScript
, lua5_1, luarocks, pkg-config, cargo, buildFHSEnv
, tree-sitter,}:
let
nvim = let
config = let
extraPackages = [
lua5_1
luarocks
tree-sitter
];
in neovimUtils.makeNeovimConfig {
withPython3 = false;
withRuby = false;
withNodeJs = false;
extraLuaPackages = p: with p; [ ];
inherit extraPackages;
customRC = ''
set runtimepath-=~/.config/nvim
source ~/.config/nvim/init.lua
'';
} // {
wrapperArgs =
[ "--prefix" "PATH" ":" "${lib.makeBinPath extraPackages}" ];
};
in wrapNeovimUnstable neovim-unwrapped config;
in buildFHSEnv {
name = "nvim";
targetPkgs = pkgs: [ nvim ];
runScript = writeShellScript "nvim-fhs.sh" ''
exec ${nvim}/bin/nvim "$@"
'';
}
neovim/flake.nix
{
description = "IogaMaster's Neovim Configuration";
inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
outputs = { nixpkgs, ... }:
let
inherit (nixpkgs) lib;
forAllSystems = function:
nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ]
(system: function nixpkgs.legacyPackages.${system});
in rec {
devShells = forAllSystems (pkgs: {
default =
pkgs.mkShell { nativeBuildInputs = with pkgs; [ alejandra stylua ]; };
});
packages = forAllSystems (pkgs: rec {
neovim = pkgs.callPackage ./neovim.nix { };
});
overlays.default = final: prev: {
neovim = final.callPackage ./neovim.nix { };
};
};
}
Now I want to use the unstable channel in order to get the latest version of NeoVim, but was unable to make it work. From what I understand, callPackage automatically pass needed arguments to my neovim.nix file, and it’s using the stable channel to get the neovim-unwrapped package. So I think I need to tell it to get neovim-unwrapped from unstable.
And that’s where I’m stuck, I’ve search the doc to try to find an answer but I’ve been on this for 3 days and can’t find a solution.
I’m pretty sure the solution to this problem should be simple but I’m a big newbie with most tools used for this setup ![]()
If anyone can help me that would be great ! ![]()
Edit
If anyone stumble on this in the future, here is what my config looks like after following @oo-infty advice:
My global flake.nix
{
description = "My first Flake";
inputs = {
neovim-flake = { url="./flakes/neovim"; };
nixpkgs.url = "nixpkgs/nixos-25.11";
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager/release-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
ashell.url = "github:romanstingler/ashell/e26d2591a3472548b199c5f9396fe7186f1cec56";
};
outputs = { ... }@inputs:
let
system = "x86_64-linux";
pkgs-unstable = import inputs.nixpkgs-unstable{
inherit system;
overlays = [ inputs.neovim-flake.overlays.default ];
};
in {
nixosConfigurations.nixos-btw = inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
};
modules = [
./configuration.nix
{
nixpkgs.overlays = [ inputs.neovim-flake.overlays.default ];
}
inputs.home-manager.nixosModules.home-manager
{
home-manager = {
extraSpecialArgs = {
inherit inputs;
inherit pkgs-unstable;
};
useGlobalPkgs = true;
useUserPackages = true;
users.henmir = import ./home.nix;
backupFileExtension = "backup";
};
}
];
};
};
}
neovim/neovim.nix
{ lib, wrapNeovimUnstable, neovim-unwrapped, neovimUtils, writeShellScript
, lua5_1, luarocks, pkg-config, cargo, buildFHSEnv
, tree-sitter,}:
let
nvim = let
config = let
extraPackages = [
lua5_1
luarocks
tree-sitter
];
in neovimUtils.makeNeovimConfig {
withPython3 = false;
withRuby = false;
withNodeJs = false;
extraLuaPackages = p: with p; [ ];
inherit extraPackages;
customRC = ''
set runtimepath-=~/.config/nvim
source ~/.config/nvim/init.lua
'';
} // {
wrapperArgs =
[ "--prefix" "PATH" ":" "${lib.makeBinPath extraPackages}" ];
};
in wrapNeovimUnstable neovim-unwrapped config;
in buildFHSEnv {
name = "nvim";
targetPkgs = pkgs: [ nvim ];
runScript = writeShellScript "nvim-fhs.sh" ''
echo "tototo"
exec ${nvim}/bin/nvim "$@"
'';
}
neovim/flake.nix
{
description = "IogaMaster's Neovim Configuration";
inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
outputs = { nixpkgs, ... }:
let
inherit (nixpkgs) lib;
forAllSystems = function:
nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ]
(system: function nixpkgs.legacyPackages.${system});
in rec {
devShells = forAllSystems (pkgs: {
default =
pkgs.mkShell { nativeBuildInputs = with pkgs; [ alejandra stylua ]; };
});
packages = forAllSystems (pkgs: rec {
neovim = pkgs.callPackage ./neovim.nix { };
});
overlays.default = final: prev: {
neovim = final.callPackage ./neovim.nix { };
};
};
}
And I’ve modified my home.nix with this:
{ config, pkgs, inputs, pkgs-unstable, ... }:
# Stuff
home.packages =
(with pkgs; [
# All my installed packages
])
++
(with pkgs-unstable; [
neovim
]);