-
Notifications
You must be signed in to change notification settings - Fork 459
NixOS Support
This repository contains the nixosModule
for home-manager using flakes.
No matter which OS you are using, you can use this configuration out of the box, as long as you use home-manager to manage your environment.
Add the home-manager
URL and nvimdots
to inputs
in the top-level flake.nix
.
Next, add the following snippets to your configuration.nix
and nvimdots.nix
.
Re-login to your shell after executing nixos-rebuild switch --flake <flake-url>
or home-manager switch --flake <flake-url>
.
flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nvimdots.url = "github:ayamir/nvimdots";
home-manager = {
url = "github:nix-community/home-manager";
nixpkgs.follows = "nixpkgs";
};
# ...
};
# ...
}
-
configuration.nix
- This is only required if you're using NixOS. See the FAQ section for details on this.
{
# Other contents...
programs.nix-ld.enable = true;
# ...
}
-
nvimdots.nix
-
setBuildEnv
: If set, automatically configures your$CPATH
,$CPLUG_INCLUDE_PATH
,$LD_LIBLARY_PATH
,$LIBRARY_PATH
,$NIX_LD_LIBRARY_PATH
, and$PKG_CONFIG_PATH
. -
withBuildTools
: If set, automatically installs some build utils such asgcc
andpkg-config
. -
Caveats:
-
setBuildEnv
andwithBuildTools
is only required on NixOS. Q&A for this details - These are required tooling so that
mason.nvim
andnvim-treesitter
can work as expected. - They bundle with
neovim
and won't affect other sessions.
-
-
{
programs.neovim.nvimdots = {
enable = true;
setBuildEnv = true; # Only needed for NixOS
withBuildTools = true; # Only needed for NixOS
};
}
This repository provides programs.dotnet.dev
to manage dotnet
installation and environment variables inspired by programs.java
in home-manager
.
See dotnet/default.nix for a list of available options.
programs.dotnet.dev = {
enabled = true;
environmentVariables = {
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT = "0"; # Will set environment variables for DotNET.
};
}
Have a look at default.nix (selection) for more information.
This is because some dependencies are not distributed along with the system - NixOS does not conform to the Filesystem Hierarchy Standard (FHS), so some ingenuity is required.
This nixosModules
provides several options to simplify dependency resolution. Nevertheless, you may 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;
withHaskell = true; # If you want to use Haskell.
extraHaskellPackages = hsPkgs: []; # Configure packages for Haskell (nixpkgs.haskellPackages).
extraDependentPackages = with pkgs; [] # Properly setup the directory hierarchy (`lib`, `include`, and `pkgconfig`).
}
}
You should include the necessary packages for building this dependency, including include
, lib
, and pkgconfig
requirements, in programs.neovim.extraDependentPackages
.
- As an example, for runtime dependencies, add the corresponding dependencies to
home.packages
orprograms.neovim.extraPackages
. - NOTE:
home.packages
is effective inside the user scope whereasprograms.neovim.extraPackages
is effective inside the entire neovim scope. Some languages may also require the use of wrapper, see below example for details.
{ pkgs, ... }:
{
# Install to the user scope.
home.packages = with pkgs; [
go
];
programs.neovim = {
# Packages only accessible from neovim
nvimdots = {
extraDependentPackages = with pkgs; [ icu ];
# Haskell packages can be easily installed with the `nvimdots` options.
extraHaskellPackages = hs: with hs; [ ghcup ];
};
extraPackages = with pkgs; [
go
# Some languages require the use of wrapper.
rWrapper.override
{
packages = with pkgs.rPackages;
[ xml2 lintr roxygen2 ];
}
];
# Python and Lua packages can be easily installed with the corresponding `home-manager` options.
extraPython3Packages = ps: with ps; [
numpy
];
};
}
This list is incomplete - not all mason.nvim
's dependent sources are tracked and included. You can help by adding missing items.
Language | extraPackages | extraDependentPackages |
---|---|---|
Go | - | hunspell |
PHP | php phpPackages.composer |
- |
R | rWrapper.override { packages = with pkgs.rPackages; [ xml2 lintr roxygen2 ]; } |
- |
Vala |
meson vala
|
vala jsonrpc-glib
|
- For binaries,
patchelf --print-needed <binary>
will list the required packages. - You can also check the information used by
ldd
in this package and/or dynamiclib withldd <binary>
. - You can check the list of dependencies required during build time using the build log (via
mason.nvim
's UI). - If this dependency is included in
nixpkgs
, you may be able to find the package you need by looking at the*.nix
sources. - If you want to be on the safe side, here is a list of dependencies for all packages that have already been registered in
mason-registry
:
libamd <==> https://github.com/zship/libamd
libc <==> https://www.gnu.org/software/libc/
[OR] libc++ <==> https://libcxx.llvm.org/
libevent <==> https://libevent.org/
libiconv <==> https://www.gnu.org/software/libiconv/
libmsgpack <==> http://msgpack.org/
libz <==> https://www.zlib.net/
libzstd <==> https://github.com/facebook/zstd
If it is provided by nixpkgs
, you should be able to use it by adding the following settings. This is the same as setting up other packages that require external installation:
-- 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