feat(nixos): migrate system configuration

This commit is contained in:
2026-08-30 19:40:21 -04:00
parent c5f34e9460
commit 7a6dc4d6f3
101 changed files with 6247 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
-- Imperative configuration that has no typed nixvim option: the colorscheme call and autocmds.
-- gbprod/nord.nvim.
require("nord").setup({
transparent = true,
})
vim.cmd.colorscheme("nord")
-- Conceal markdown syntax in markdown buffers.
-- conceallevel is window-local, so it is set with opt_local when the filetype
-- is applied to the buffer's window.
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
vim.opt_local.conceallevel = 2
end,
})
-- Soft-wrap prose buffers without inserting line breaks.
vim.api.nvim_create_autocmd("FileType", {
pattern = { "gitcommit", "markdown", "text" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.linebreak = true
vim.opt_local.breakindent = true
end,
})
-- Turn line blame off again once the Neogit status buffer is closed.
vim.api.nvim_create_autocmd("BufUnload", {
callback = function(args)
if vim.bo[args.buf].filetype == "NeogitStatus" then
require("gitsigns").toggle_current_line_blame(false)
end
end,
})

View File

@@ -0,0 +1,204 @@
{
config,
lib,
pkgs,
inputs,
...
}:
# Neovim for the primary user, configured declaratively through nixvim.
let
cfg = config.modules.shell.nvim;
user = config.user.name;
in
{
options.modules.shell.nvim.enable = lib.mkEnableOption "Neovim, configured declaratively via nixvim";
config = lib.mkIf cfg.enable {
registry.shell-shortcut.${config.networking.hostName} = {
vi = "nvim";
vim = "nvim";
};
home-manager.sharedModules = [ inputs.nixvim.homeModules.nixvim ];
home-manager.users.${user} = hm: {
programs.nixvim = {
enable = true;
nixpkgs.useGlobalPackages = true;
extraPackages = with pkgs; [
git # neogit and gitsigns shell out to git
ripgrep # backs the picker's live grep
fd # backs the picker's file finder
];
globals.mapleader = " ";
globals.clipboard = "osc52"; # built-in OSC 52 provider, no external binary needed
opts = {
clipboard = "unnamedplus";
number = true;
relativenumber = true;
shiftwidth = 2;
tabstop = 2;
expandtab = true;
mouse = "a";
undofile = true;
ignorecase = true;
smartcase = true;
splitright = true;
splitbelow = true;
wrap = false;
scrolloff = 8;
cursorline = true;
};
keymaps = [
{
mode = "n";
key = "<C-h>";
action = "<C-w>h";
options.desc = "Move focus left";
}
{
mode = "n";
key = "<C-j>";
action = "<C-w>j";
options.desc = "Move focus down";
}
{
mode = "n";
key = "<C-k>";
action = "<C-w>k";
options.desc = "Move focus up";
}
{
mode = "n";
key = "<C-l>";
action = "<C-w>l";
options.desc = "Move focus right";
}
{
mode = "n";
key = "<Esc>";
action = "<cmd>nohlsearch<CR>";
options.desc = "Clear search highlight";
}
{
mode = "n";
key = "j";
action = "gj";
options.desc = "Move down by display line";
}
{
mode = "n";
key = "k";
action = "gk";
options.desc = "Move up by display line";
}
{
mode = "n";
key = "<leader>e";
action = "<cmd>Oil<CR>";
options.desc = "Open file browser";
}
{
mode = "n";
key = "<leader>f";
action.__raw = "function() require('snacks').picker.files() end";
options.desc = "Find files";
}
{
mode = "n";
key = "<leader>s";
action.__raw = "function() require('snacks').picker.grep() end";
options.desc = "Search text";
}
{
mode = "n";
key = "<leader>b";
action.__raw = "function() require('snacks').picker.buffers() end";
options.desc = "Switch buffer";
}
{
mode = "n";
key = "<leader>g";
action.__raw = ''
function()
require('gitsigns').toggle_current_line_blame(true)
require('neogit').open()
end
'';
options.desc = "Open git (Neogit)";
}
];
plugins = {
gitsigns = {
enable = true;
settings.current_line_blame = false;
};
neogit.enable = true;
diffview.enable = true; # neogit's diff integration
oil = {
enable = true;
settings.view_options.show_hidden = true;
};
snacks = {
enable = true;
settings = {
picker.enabled = true;
notifier.enabled = true;
input.enabled = true;
};
};
which-key.enable = true;
render-markdown.enable = true;
treesitter = {
enable = true;
highlight.enable = true;
indent.enable = true;
grammarPackages = with hm.config.programs.nixvim.plugins.treesitter.package.builtGrammars; [
nix
lua
bash
fish
markdown
markdown_inline
rust
python
java
kotlin
c
cpp
html
css
javascript
typescript
go
];
};
};
# `gbprod-nord` provides the `require("nord").setup()` API used in `./config.lua`.
# nixpkgs packages `shaunsingh/nord.nvim` as `nord-nvim`, which is a different plugin.
extraPlugins = [ pkgs.vimPlugins.gbprod-nord ];
extraConfigLua = builtins.readFile ./config.lua;
};
};
};
}