-
Notifications
You must be signed in to change notification settings - Fork 476
Description
Feature description
I have submitted a PR for NixOS support in #906.
I would like to add to the wiki about NixOS support.
module options
will be replaced with appropriate ones when the PR is merged
Please review.
what's inside ?
- Usage for NixOS
mason.nvim
cannot build packages or run installed binaries- How to check for required dependencies.
- What to do if you can't build with
mason.nvim
.
- Usage for
home-manager
on non-NixOS - Module Options
Preview
raw markdown code
# NixOS and home-managerThis repository contains the nixosModule for home-manager provided by flakes.
You can use it right away if you are using home-manager on NixOS as well as non-NixOS.
Usage for NixOS.
Add the following to your flake.nix
, configuration.nix
and nvimdots.nix
.
Relogin to shell after nixos-rebuild switch --flake <flake-url>
.
-
flake.nix
{ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; inputs.nvimdots.url = "github:ayamir/nvimdots"; inputs.home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; nixosConfigurations = { use-nvimdots = inputs.nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ # ... inputs.home-manager.nixosModules.home-manager { home-manager.users."example-user" = { imports = [ inputs.nvimdots.nixosModules.nvimdots (import ./nvimdots.nix) ]; }; home-manager.extraSpecialArgs = { inherit inputs; }; } ./configuration.nix ]; specialArgs = { inherit inputs; }; }; }; }; }
-
configuration.nix
{ # ... programs.nix-ld.enable = true; # ... }
-
nvimdots.nix
setBuildEnv
providesCPATH
,CPLUG_INCLUDE_PATH
,LD_LIBLARY_PATH
,LIBRARY_PATH
,NIX_LD_LIBRARY_PATH
,PKG_CONFIG_PATH
.
withBuildTools
provides basic build tools such asgcc
andpkg-config
.
These are required formason.nvim
andnvim-treesitter
to work properly.
Also, they are only provided toneovim
and do not affect the entire session.{ programs.neovim.nvimdots = { enable = true; setBuildEnv = true; withBuildTools = true; }; }
mason.nvim
cannot build packages or run installed binaries.
This is because the dependencies are not included.
NixOS does not conform to the Filesystem Hierarchy Standard (FHS), so some ingenuity is required.
This nixosModules provides options to simplify dependency resolution.
You can still use programs.neovim.extraPackages
, programs.neovim.extraPython3Packages
, programs.neovim.extraLuaPackages
provided by home-manager.
-
nvimdots.nix
{pkgs, ...}: { programs.neovim.nvimdots = { enable = true; setBuildEnv = true; withBuildTools = true; extraRPackages = rPkgs: []; # need packages for R include `nixpkgs.rPackages`. extraHaskellPackages = hsPkgs: []; # need packages for haskell include `nixpkgs.haskellPackages`. extraDependentPackages = with pkgs; [] # need packages `lib`, `include`, and `pkgconfig`. }; }
How to check for required dependencies.
For binaries, patchelf --print-needed <binary>
will list the required packages.
You can also check the library link status with ldd <binary>
.
You can check the dependencies required at build time from the build log from the UI of mason.nvim
opened with :Mason
.
If it is included in nixpkgs
, you may be able to find the package you need by looking at the *.nix
sources.
What to do if you can't build with mason.nvim
.
If it is provided by nixpkgs
, you should be able to use it by adding the following settings.
nvimdots/lua/modules/configs/completion/lsp.lua
Lines 143 to 148 in 6de8afe
-- Setup lsps that are not supported by `mason.nvim` but supported by `nvim-lspconfig` here. | |
if vim.fn.executable("dart") == 1 then | |
local _opts = require("completion.servers.dartls") | |
local final_opts = vim.tbl_deep_extend("keep", _opts, opts) | |
nvim_lsp.dartls.setup(final_opts) | |
end |
Usage for home-manager
on non-NixOS
Unlike on NixOS, build tools and dependencies should be provided by the package manager provided by the distribution.
Of course, you can let nix
resolve dependencies as they do for NixOS, but that can be a problem if you run the build command from within neovim
.
Add the following to your flake.nix
and nvimdots.nix
.
Relogin to shell after home-manager switch --flake <flake-url>
.
-
flake.nix
{ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; inputs.nvimdots.url = "github:ayamir/nvimdots"; inputs.home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; homeConfigurations = { use-nvimdots = inputs.home-manager.lib.homeManagerConfiguration { inherit (inputs) nixpkgs; modules = [ inputs.nvimdots.nixosModules.nvimdots (import ./nvimdots.nix) ]; extraSpecialArgs = { inherit inputs; }; }; }; }
-
nvimdots.nix
{ programs.neovim.nvimdots = { enable = true; # Comment out if resolving dependencies on `nix`. # setBuildEnv = true; # withBuildTools = true; }; }
Module Options
NixOS and home-manager
This repository contains the nixosModule for home-manager provided by flakes.
You can use it right away if you are using home-manager on NixOS as well as non-NixOS.
Usage for NixOS.
Add the following to your flake.nix
, configuration.nix
and nvimdots.nix
.
Relogin to shell after nixos-rebuild switch --flake <flake-url>
.
-
flake.nix
{ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; inputs.nvimdots.url = "github:ayamir/nvimdots"; inputs.home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; nixosConfigurations = { use-nvimdots = inputs.nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ # ... inputs.home-manager.nixosModules.home-manager { home-manager.users."example-user" = { imports = [ inputs.nvimdots.nixosModules.nvimdots (import ./nvimdots.nix) ]; }; home-manager.extraSpecialArgs = { inherit inputs; }; } ./configuration.nix ]; specialArgs = { inherit inputs; }; }; }; }; }
-
configuration.nix
{ # ... programs.nix-ld.enable = true; # ... }
-
nvimdots.nix
setBuildEnv
providesCPATH
,CPLUG_INCLUDE_PATH
,LD_LIBLARY_PATH
,LIBRARY_PATH
,NIX_LD_LIBRARY_PATH
,PKG_CONFIG_PATH
.
withBuildTools
provides basic build tools such asgcc
andpkg-config
.
These are required formason.nvim
andnvim-treesitter
to work properly.
Also, they are only provided toneovim
and do not affect the entire session.{ programs.neovim.nvimdots = { enable = true; setBuildEnv = true; withBuildTools = true; }; }
mason.nvim
cannot build packages or run installed binaries.
This is because the dependencies are not included.
NixOS does not conform to the Filesystem Hierarchy Standard (FHS), so some ingenuity is required.
This nixosModules provides options to simplify dependency resolution.
You can still use programs.neovim.extraPackages
, programs.neovim.extraPython3Packages
, programs.neovim.extraLuaPackages
provided by home-manager.
-
nvimdots.nix
{pkgs, ...}: { programs.neovim.nvimdots = { enable = true; setBuildEnv = true; withBuildTools = true; extraRPackages = rPkgs: []; # need packages for R include `nixpkgs.rPackages`. extraHaskellPackages = hsPkgs: []; # need packages for haskell include `nixpkgs.haskellPackages`. extraDependentPackages = with pkgs; [] # need packages `lib`, `include`, and `pkgconfig`. }; }
How to check for required dependencies.
For binaries, patchelf --print-needed <binary>
will list the required packages.
You can also check the library link status with ldd <binary>
.
You can check the dependencies required at build time from the build log from the UI of mason.nvim
opened with :Mason
.
If it is included in nixpkgs
, you may be able to find the package you need by looking at the *.nix
sources.
What to do if you can't build with mason.nvim
.
If it is provided by nixpkgs
, you should be able to use it by adding the following settings.
nvimdots/lua/modules/configs/completion/lsp.lua
Lines 143 to 148 in 6de8afe
-- Setup lsps that are not supported by `mason.nvim` but supported by `nvim-lspconfig` here. | |
if vim.fn.executable("dart") == 1 then | |
local _opts = require("completion.servers.dartls") | |
local final_opts = vim.tbl_deep_extend("keep", _opts, opts) | |
nvim_lsp.dartls.setup(final_opts) | |
end |
Usage for home-manager
on non-NixOS
Unlike on NixOS, build tools and dependencies should be provided by the package manager provided by the distribution.
Of course, you can let nix
resolve dependencies as they do for NixOS, but that can be a problem if you run the build command from within neovim
.
Add the following to your flake.nix
and nvimdots.nix
.
Relogin to shell after home-manager switch --flake <flake-url>
.
-
flake.nix
{ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; inputs.nvimdots.url = "github:ayamir/nvimdots"; inputs.home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; homeConfigurations = { use-nvimdots = inputs.home-manager.lib.homeManagerConfiguration { inherit (inputs) nixpkgs; modules = [ inputs.nvimdots.nixosModules.nvimdots (import ./nvimdots.nix) ]; extraSpecialArgs = { inherit inputs; }; }; }; }
-
nvimdots.nix
{ programs.neovim.nvimdots = { enable = true; # Comment out if resolving dependencies on `nix`. # setBuildEnv = true; # withBuildTools = true; }; }
Module Options
Additional information
No response