Add home manager modules
This commit is contained in:
141
modules/home/git/default.nix
Normal file
141
modules/home/git/default.nix
Normal file
@@ -0,0 +1,141 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.nut.git;
|
||||
inherit (lib) mkEnableOption mkIf mkOption;
|
||||
types = lib.types;
|
||||
name = "Yadunand Prem";
|
||||
email = "yadunand@yadunut.com";
|
||||
in
|
||||
{
|
||||
options.nut.git = {
|
||||
enable = mkEnableOption "Git";
|
||||
gpgProgram = mkOption {
|
||||
default = null;
|
||||
type = types.nullOr types.str;
|
||||
};
|
||||
signingKey = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
home.packages = with pkgs; [
|
||||
git
|
||||
lazygit
|
||||
jujutsu
|
||||
delta
|
||||
];
|
||||
|
||||
programs.zsh.shellAliases = {
|
||||
lg = "lazygit";
|
||||
js = "jj status";
|
||||
jd = "jj diff";
|
||||
jn = "jj new";
|
||||
jf = "jj git fetch";
|
||||
jp = "jj git push";
|
||||
};
|
||||
programs.delta = {
|
||||
enable = true;
|
||||
enableGitIntegration = true;
|
||||
};
|
||||
programs.git = {
|
||||
ignores = [
|
||||
".DS_Store"
|
||||
".direnv/"
|
||||
".envrc"
|
||||
"**/.claude/settings.local.json"
|
||||
];
|
||||
enable = true;
|
||||
lfs.enable = true;
|
||||
|
||||
settings = lib.mkMerge [
|
||||
{
|
||||
init = {
|
||||
defaultBranch = "main";
|
||||
defaultRefFormat = "files";
|
||||
};
|
||||
user = {
|
||||
email = email;
|
||||
name = name;
|
||||
};
|
||||
|
||||
pull = {
|
||||
rebase = true;
|
||||
autostash = true;
|
||||
};
|
||||
push = {
|
||||
autoSetupRemote = true;
|
||||
followTags = true;
|
||||
};
|
||||
commit = {
|
||||
gpgsign = true;
|
||||
verbose = true;
|
||||
};
|
||||
diff = {
|
||||
# merge.conflictstyle = "zdiff2";
|
||||
colorMoved = true;
|
||||
algorithm = "histogram";
|
||||
mnemonicPrefix = true;
|
||||
};
|
||||
feature.experimental = true;
|
||||
branch.sort = "committerdate";
|
||||
fetch.all = true;
|
||||
column.ui = "auto";
|
||||
tags.sort = "version:refname";
|
||||
rerere = {
|
||||
enabled = true;
|
||||
autoupdate = true;
|
||||
};
|
||||
rebase = {
|
||||
autostash = true;
|
||||
autosquash = true;
|
||||
updateRefs = true;
|
||||
};
|
||||
credential = {
|
||||
helper = [
|
||||
"${pkgs.git-credential-oauth}/bin/git-credential-oauth"
|
||||
];
|
||||
"https://git.yadunut.dev" = {
|
||||
oauthClientId = "a4792ccc-144e-407e-86c9-5e7d8d9c3269";
|
||||
oauthScopes = "read:repository write:repository";
|
||||
oauthAuthURL = "/login/oauth/authorize";
|
||||
oauthTokenURL = "/login/oauth/access_token";
|
||||
};
|
||||
};
|
||||
gpg.format = "ssh";
|
||||
}
|
||||
(mkIf (cfg.gpgProgram != null) { gpg.ssh.program = cfg.gpgProgram; })
|
||||
(mkIf (cfg.signingKey != null) { user.signingkey = "key::${cfg.signingKey}"; })
|
||||
];
|
||||
};
|
||||
|
||||
programs.jujutsu = {
|
||||
enable = true;
|
||||
settings = {
|
||||
user = {
|
||||
name = name;
|
||||
email = email;
|
||||
};
|
||||
aliases = {
|
||||
tug = [
|
||||
"bookmark"
|
||||
"move"
|
||||
"--from"
|
||||
"heads(::@- & bookmarks())"
|
||||
"--to"
|
||||
"@-"
|
||||
];
|
||||
};
|
||||
ui.default-command = "log";
|
||||
};
|
||||
};
|
||||
programs.gh.enable = true;
|
||||
};
|
||||
}
|
||||
461
modules/home/neovim/default.nix
Normal file
461
modules/home/neovim/default.nix
Normal file
@@ -0,0 +1,461 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.nut.neovim;
|
||||
inherit (lib) mkEnableOption mkIf mkOption;
|
||||
in
|
||||
{
|
||||
options.nut.neovim = {
|
||||
enable = mkEnableOption "Neovim";
|
||||
nix.enable = mkOption {
|
||||
default = true;
|
||||
description = "Enable nix related vim packages";
|
||||
type = lib.types.bool;
|
||||
};
|
||||
performance.enable = mkOption {
|
||||
default = false;
|
||||
description = "Enable performance options";
|
||||
type = lib.types.bool;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.sessionVariables = {
|
||||
EDITOR = "nvim";
|
||||
VISUAL = "nvim";
|
||||
};
|
||||
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
|
||||
performance = mkIf cfg.performance.enable {
|
||||
combinePlugins.enable = true;
|
||||
byteCompileLua = {
|
||||
enable = true;
|
||||
nvimRuntime = true;
|
||||
plugins = true;
|
||||
};
|
||||
};
|
||||
|
||||
defaultEditor = true;
|
||||
colorschemes.gruvbox.enable = true;
|
||||
plugins = {
|
||||
flash.enable = true;
|
||||
oil.enable = true;
|
||||
neogit.enable = true;
|
||||
image = {
|
||||
enable = true;
|
||||
settings = {
|
||||
backend = "kitty";
|
||||
};
|
||||
};
|
||||
lsp = {
|
||||
enable = true;
|
||||
servers = {
|
||||
# gleam.enable = true;
|
||||
ts_ls.enable = true; # TS/JS
|
||||
biome.enable = true; # TS/JS
|
||||
pyright.enable = true; # Python
|
||||
ruff.enable = true; # python
|
||||
nixd = mkIf cfg.nix.enable {
|
||||
enable = true;
|
||||
extraOptions.settings.nixd = {
|
||||
formatting.command = "nixfmt";
|
||||
};
|
||||
};
|
||||
cssls.enable = true;
|
||||
jsonls.enable = true;
|
||||
html.enable = true;
|
||||
tinymist.enable = true;
|
||||
gopls.enable = true;
|
||||
texlab = {
|
||||
enable = true;
|
||||
settings = {
|
||||
texlab.build = {
|
||||
executable = "tectonic";
|
||||
args = [
|
||||
"-X"
|
||||
"compile"
|
||||
"%f"
|
||||
"--synctex"
|
||||
"--keep-logs"
|
||||
"--keep-intermediates"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
keymaps.lspBuf = {
|
||||
gd = {
|
||||
action = "definition";
|
||||
desc = "Goto Definition";
|
||||
};
|
||||
gr = {
|
||||
action = "references";
|
||||
desc = "Goto References";
|
||||
};
|
||||
gD = {
|
||||
action = "declaration";
|
||||
desc = "Goto Declaration";
|
||||
};
|
||||
gI = {
|
||||
action = "implementation";
|
||||
desc = "Goto Implementation";
|
||||
};
|
||||
gT = {
|
||||
action = "type_definition";
|
||||
desc = "Type Definition";
|
||||
};
|
||||
K = {
|
||||
action = "hover";
|
||||
desc = "Hover";
|
||||
};
|
||||
"<leader>rn" = {
|
||||
action = "rename";
|
||||
desc = "Rename";
|
||||
};
|
||||
};
|
||||
keymaps.extra = [
|
||||
{
|
||||
action.__raw = "vim.lsp.buf.code_action";
|
||||
key = "<leader>la";
|
||||
}
|
||||
{
|
||||
action.__raw = "function() vim.lsp.buf.format { async = true } end";
|
||||
key = "<leader>lf";
|
||||
}
|
||||
];
|
||||
keymaps.diagnostic = {
|
||||
"<leader>cd" = {
|
||||
action = "open_float";
|
||||
desc = "Line Diagnostics";
|
||||
};
|
||||
"[d" = {
|
||||
action = "goto_next";
|
||||
desc = "Next Diagnostic";
|
||||
};
|
||||
"]d" = {
|
||||
action = "goto_prev";
|
||||
desc = "Previous Diagnostic";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
trouble.enable = true;
|
||||
cmp = {
|
||||
enable = true;
|
||||
autoEnableSources = true;
|
||||
settings = {
|
||||
sources = [
|
||||
{ name = "nvim_lsp"; }
|
||||
{ name = "nvim_lua"; }
|
||||
# {name = "emoji";}
|
||||
{
|
||||
name = "buffer";
|
||||
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
|
||||
keywordLength = 3;
|
||||
}
|
||||
{
|
||||
name = "path";
|
||||
keywordLength = 3;
|
||||
}
|
||||
{
|
||||
name = "luasnip";
|
||||
keywordLength = 3;
|
||||
}
|
||||
];
|
||||
window = {
|
||||
# completion = { border = "solid"; };
|
||||
# documentation = { border = "solid"; };
|
||||
};
|
||||
mapping = {
|
||||
"<C-n>" = "cmp.mapping.select_next_item()";
|
||||
"<C-p>" = "cmp.mapping.select_prev_item()";
|
||||
"<C-e>" = "cmp.mapping.abort()";
|
||||
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
|
||||
"<C-f>" = "cmp.mapping.scroll_docs(4)";
|
||||
"<C-Space>" = "cmp.mapping.complete()";
|
||||
"<CR>" = "cmp.mapping.confirm({ select = true })";
|
||||
"<S-CR>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })";
|
||||
};
|
||||
};
|
||||
};
|
||||
cmp-nvim-lsp.enable = true;
|
||||
cmp-nvim-lua.enable = true;
|
||||
cmp-buffer.enable = true;
|
||||
cmp-path.enable = true;
|
||||
cmp_luasnip.enable = true;
|
||||
cmp-cmdline.enable = true;
|
||||
nvim-tree = {
|
||||
enable = true;
|
||||
settings = {
|
||||
view.side = "right";
|
||||
update_focused_file.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
friendly-snippets.enable = true;
|
||||
|
||||
luasnip = {
|
||||
enable = true;
|
||||
settings = {
|
||||
enable_autosnippets = true;
|
||||
store_selection_keys = "<Tab>";
|
||||
};
|
||||
fromVscode = [
|
||||
{
|
||||
lazyLoad = true;
|
||||
paths = "${pkgs.vimPlugins.friendly-snippets}";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
bufferline.enable = true;
|
||||
|
||||
treesitter = {
|
||||
enable = true;
|
||||
folding = true;
|
||||
grammarPackages = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [
|
||||
bash
|
||||
json
|
||||
lua
|
||||
make
|
||||
markdown
|
||||
nix
|
||||
regex
|
||||
toml
|
||||
vim
|
||||
vimdoc
|
||||
xml
|
||||
yaml
|
||||
javascript
|
||||
go
|
||||
typescript
|
||||
];
|
||||
settings = {
|
||||
highlight.enable = true;
|
||||
indent.enable = true;
|
||||
};
|
||||
};
|
||||
treesitter-context.enable = true;
|
||||
treesitter-textobjects = {
|
||||
enable = true;
|
||||
settings.move = {
|
||||
enable = true;
|
||||
gotoNextStart = {
|
||||
"]m" = {
|
||||
query = "@function.outer";
|
||||
};
|
||||
"]]" = {
|
||||
query = "@class.outer";
|
||||
desc = "Next class start";
|
||||
};
|
||||
"]o" = {
|
||||
query = "@loop.*";
|
||||
};
|
||||
"]s" = {
|
||||
query = "@scope";
|
||||
queryGroup = "locals";
|
||||
desc = "Next scope";
|
||||
};
|
||||
"]z" = {
|
||||
query = "@fold";
|
||||
queryGroup = "folds";
|
||||
desc = "Next fold";
|
||||
};
|
||||
};
|
||||
gotoNextEnd = {
|
||||
"]M" = {
|
||||
query = "@function.outer";
|
||||
};
|
||||
"][" = {
|
||||
query = "@class.outer";
|
||||
};
|
||||
};
|
||||
gotoPreviousStart = {
|
||||
"[m" = {
|
||||
query = "@function.outer";
|
||||
};
|
||||
"[[" = {
|
||||
query = "@class.outer";
|
||||
};
|
||||
};
|
||||
gotoPreviousEnd = {
|
||||
"[M" = {
|
||||
query = "@function.outer";
|
||||
};
|
||||
"[]" = {
|
||||
query = "@class.outer";
|
||||
};
|
||||
};
|
||||
gotoNext = {
|
||||
"]d" = {
|
||||
query = "@conditional.outer";
|
||||
};
|
||||
};
|
||||
gotoPrevious = {
|
||||
"[d" = {
|
||||
query = "@conditional.outer";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
ts-autotag.enable = true;
|
||||
|
||||
which-key.enable = true;
|
||||
telescope = {
|
||||
enable = true;
|
||||
extensions.fzf-native.enable = true;
|
||||
settings = {
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
"<C-t>".__raw = "require('trouble.sources.telescope').open";
|
||||
};
|
||||
n = {
|
||||
"<C-t>".__raw = "require('trouble.sources.telescope').open";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
web-devicons.enable = true;
|
||||
|
||||
overseer = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
opts = {
|
||||
number = true;
|
||||
relativenumber = true;
|
||||
signcolumn = "yes";
|
||||
updatetime = 250;
|
||||
undofile = true;
|
||||
ignorecase = true;
|
||||
smartcase = true;
|
||||
swapfile = false;
|
||||
foldlevel = 9;
|
||||
smartindent = true;
|
||||
tabstop = 2;
|
||||
shiftwidth = 2;
|
||||
softtabstop = 0;
|
||||
expandtab = true;
|
||||
smarttab = true;
|
||||
scrolloff = 5;
|
||||
termguicolors = true;
|
||||
foldmethod = lib.mkForce "expr";
|
||||
foldexpr = lib.mkForce "v:lua.vim.treesitter.foldexpr()";
|
||||
};
|
||||
|
||||
globals = {
|
||||
mapleader = " ";
|
||||
maplocalleader = " ";
|
||||
};
|
||||
keymaps = [
|
||||
{
|
||||
action = ":";
|
||||
key = ";";
|
||||
mode = [ "n" ];
|
||||
}
|
||||
# { action = "gj"; key = "j"; mode = [ "n" ]; }
|
||||
# { action = "gk"; key = "k"; mode = [ "n" ]; }
|
||||
{
|
||||
action = "<Esc>";
|
||||
key = "jk";
|
||||
mode = [ "i" ];
|
||||
}
|
||||
|
||||
{
|
||||
action = "<cmd>Telescope find_files<CR>";
|
||||
key = "<leader><leader>";
|
||||
options.desc = "Find Files";
|
||||
}
|
||||
{
|
||||
action.__raw = "function() require('telescope.builtin').lsp_document_symbols({symbols='method'}) end";
|
||||
key = "<leader>fm";
|
||||
options.desc = "Find Methods";
|
||||
}
|
||||
{
|
||||
action = "<cmd>Telescope live_grep<CR>";
|
||||
key = "<leader>fg";
|
||||
options.desc = "Grep";
|
||||
}
|
||||
{
|
||||
action = "<cmd>Telescope buffers<CR>";
|
||||
key = "<leader>fb";
|
||||
options.desc = "Find Buffers";
|
||||
}
|
||||
{
|
||||
action = "<cmd>Telescope buffers<CR>";
|
||||
key = "<leader>fb";
|
||||
options.desc = "Find Buffers";
|
||||
}
|
||||
{
|
||||
action = "<cmd>Telescope projects<CR>";
|
||||
key = "<leader>pp";
|
||||
options.desc = "Switch Projects";
|
||||
}
|
||||
|
||||
{
|
||||
action = "<cmd>Trouble diagnostics toggle<CR>";
|
||||
key = "<leader>tr";
|
||||
}
|
||||
{
|
||||
action = "<cmd>Neogit<CR>";
|
||||
key = "<leader>gg";
|
||||
options.desc = "Open Git";
|
||||
}
|
||||
{
|
||||
action = "<cmd>NvimTreeToggle<CR>";
|
||||
key = "<leader>tt";
|
||||
options.desc = "Tree View";
|
||||
}
|
||||
|
||||
{
|
||||
action.__raw = "function() require('flash').jump() end";
|
||||
key = "s";
|
||||
mode = [
|
||||
"n"
|
||||
"x"
|
||||
"o"
|
||||
];
|
||||
options.desc = "Flash";
|
||||
}
|
||||
{
|
||||
action.__raw = "function() require('flash').treesitter() end";
|
||||
key = "S";
|
||||
mode = [
|
||||
"n"
|
||||
"x"
|
||||
"o"
|
||||
];
|
||||
options.desc = "Flash Treesitter";
|
||||
}
|
||||
{
|
||||
action.__raw = "function() require('flash').remote() end";
|
||||
key = "r";
|
||||
mode = [ "o" ];
|
||||
options.desc = "Remote Flash";
|
||||
}
|
||||
{
|
||||
action.__raw = "function() require('flash').treesitter_search() end";
|
||||
key = "R";
|
||||
mode = [ "o" ];
|
||||
options.desc = "Treesitter Search";
|
||||
}
|
||||
{
|
||||
action.__raw = "function() require('flash').toggle() end";
|
||||
key = "<c-s>";
|
||||
mode = [ "c" ];
|
||||
options.desc = "Toggle Flash";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
93
modules/home/zsh/default.nix
Normal file
93
modules/home/zsh/default.nix
Normal file
@@ -0,0 +1,93 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.nut.zsh;
|
||||
inherit (lib) mkEnableOption mkIf;
|
||||
in
|
||||
{
|
||||
options.nut.zsh = {
|
||||
enable = mkEnableOption "Zsh";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
home.packages = with pkgs; [
|
||||
zsh-completions
|
||||
fd
|
||||
ripgrep
|
||||
wget
|
||||
delta
|
||||
];
|
||||
|
||||
programs = {
|
||||
bat = {
|
||||
enable = true;
|
||||
};
|
||||
dircolors = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
direnv = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
nix-direnv.enable = true;
|
||||
config = {
|
||||
hide_env_diff = true;
|
||||
};
|
||||
};
|
||||
zsh = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
syntaxHighlighting.enable = true;
|
||||
autosuggestion.enable = true;
|
||||
autocd = true;
|
||||
history = {
|
||||
size = 1000000;
|
||||
extended = true;
|
||||
append = true;
|
||||
expireDuplicatesFirst = true;
|
||||
ignoreDups = true;
|
||||
ignoreAllDups = true;
|
||||
ignoreSpace = true;
|
||||
};
|
||||
historySubstringSearch.enable = true;
|
||||
shellAliases = {
|
||||
cat = "bat --theme=\"$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo 'gruvbox-dark' || echo 'gruvbox-light')\"";
|
||||
diff = "delta";
|
||||
};
|
||||
profileExtra = builtins.readFile ./functions.zsh;
|
||||
};
|
||||
fzf = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
zoxide = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
eza = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
extraOptions = [ "--group-directories-first" ];
|
||||
};
|
||||
starship = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
settings = {
|
||||
nodejs.disabled = true;
|
||||
package.disabled = true;
|
||||
aws.disabled = true;
|
||||
python.disabled = true;
|
||||
};
|
||||
};
|
||||
nix-your-shell = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
15
modules/home/zsh/functions.zsh
Normal file
15
modules/home/zsh/functions.zsh
Normal file
@@ -0,0 +1,15 @@
|
||||
# helper function to crop cs3223 slides
|
||||
crop_slides() {
|
||||
input="$1"
|
||||
if [ -z "$input" ]; then
|
||||
echo "Usage: crop_slides <inputfile>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Get base name (without extension)
|
||||
base="${input%.*}"
|
||||
output="${base}-slides.mp4"
|
||||
|
||||
# Crop left 2/3 of a 1280x640 video (≈853 px wide)
|
||||
nix run "nixpkgs#ffmpeg" -- -i "$input" -filter:v "crop=853:640:0:0" -c:a copy "$output"
|
||||
}
|
||||
Reference in New Issue
Block a user