complete setup for nixvim in nixos for a user name piyush I use home-manager and flake
- User
complete setup for nixvim in nixos for a user name piyush I use home-manager and flake
- Assistant
complete setup for nixvim in nixos for a user name piyush I use home-manager and flake
To set up Neovim with Nix on NixOS for a user named piyush using Home Manager and flakes, you'll need to follow a series of steps. Here's a complete configuration that includes the necessary settings.
If you haven't already, make sure you have Nix configured to allow flakes. Add the following lines to your Nix configuration file (usually found at /etc/nixos/configuration.nix or ~/.config/nix/nix.conf):
experimental-features = flakes
Then, rebuild your NixOS configuration if you modified the system-wide configuration:
sudo nixos-rebuild switch
Create a new directory for your Home Manager configuration if it doesn't already exist:
mkdir -p ~/nix-config
cd ~/nix-config
Add a flake.nix file with the following content:
{
description = "Home Manager configuration for Piyush";
inputs = {
# Home Manager Flake
home-manager.url = "github:nix-community/home-manager/release-23.05";
# Optional: If you want to use Neovim plugins with a specific plugin manager.
# nvim-nightly.url = "github:neovim/neovim";
};
outputs = { self, nixpkgs, home-manager, ... }: {
homeManagerConfigurations.piyush = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux; # Adjust for your system architecture if needed
modules = [
{
# Enable Neovim
programs.neovim = {
enable = true;
# Optional: Specify the version you want
# python3Packages = with pkgs.python3Packages; [ flake8 black ];
};
# Install Packer for Neovim
environment.systemPackages = with pkgs; [
neovim
git
ripgrep
];
# Set up the Neovim configuration
home.file."config/nvim/init.vim".text = ''
set nocompatible " be iMproved, required
set runtimepath+=~/.config/nvim,~/.local/share/nvim/site
syntax on " syntax highlighting
set encoding=UTF-8
set number " show line numbers
set smartindent " autoindent smartly
set tabstop=4 " number of spaces that a <Tab> counts for
set shiftwidth=4 " the size of an indent
set expandtab " convert tabs to spaces
set cursorline " highlight current line
set background=dark " dark background
colorscheme desert " set colorscheme
'';
# Optionally, you can include plugins here using a plugin manager like Packer or Pdnvim.
home.file."config/nvim/lua/plugins.lua".text = ''
require('packer').startup(function(use)
use 'wbthomason/packer.nvim' -- Package manager
use 'nvim-treesitter/nvim-treesitter'
use 'neovim/nvim-lspconfig' -- LSP configurations
-- Add more plugins here as needed
end)
'';
}
];
};
};
}
Once you have the flake set up, update and apply the Home Manager configuration:
home-manager switch --flake ~/nix-config
To verify your Neovim installation, run the following command:
nvim --version
You should see output confirming that Neovim is installed and configured as specified.
You can expand your Neovim setup further by adding more configurations for plugins, LSPs, themes, and other tools as your development needs evolve. If you plan to use a plugin manager like Packer, remember to install it as part of your Neovim startup configuration.
With this setup, Neovim should be ready for use under the user piyush, utilizing Home Manager with flakes on NixOS. Adjust the configuration as necessary for your personal preferences and development environment.
Not yet included in a published release.