From c0c5087218c27e31c3e6f66f3937bff22fa0f647 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Tue, 24 Sep 2024 23:13:51 +0530 Subject: Using nix flake modules to manage the configurations. --- modules/tools/default.nix | 11 + modules/tools/editor/default.nix | 7 + modules/tools/editor/neovim/default.nix | 43 +++ modules/tools/editor/neovim/keybindings.lua | 8 + modules/tools/editor/neovim/options.lua | 21 ++ modules/tools/editor/neovim/plugins/base16.lua | 6 + modules/tools/editor/neovim/plugins/comment.lua | 1 + modules/tools/editor/neovim/plugins/lualine.lua | 5 + modules/tools/editor/neovim/plugins/nvim-tree.lua | 13 + modules/tools/editor/neovim/plugins/treesitter.nix | 13 + modules/tools/file-manager/default.nix | 8 + modules/tools/file-manager/lf/default.nix | 21 ++ modules/tools/file-manager/lf/icons | 334 +++++++++++++++++++++ modules/tools/file-manager/lf/scripts/previewer.sh | 3 + modules/tools/file-manager/lsd/default.nix | 17 ++ modules/tools/git/default.nix | 20 ++ modules/tools/system-monitor/default.nix | 7 + modules/tools/system-monitor/htop/default.nix | 12 + modules/tools/viewer/bat/default.nix | 14 + modules/tools/viewer/bat/theme.nix | 124 ++++++++ modules/tools/viewer/default.nix | 7 + 21 files changed, 695 insertions(+) create mode 100644 modules/tools/default.nix create mode 100644 modules/tools/editor/default.nix create mode 100644 modules/tools/editor/neovim/default.nix create mode 100644 modules/tools/editor/neovim/keybindings.lua create mode 100644 modules/tools/editor/neovim/options.lua create mode 100644 modules/tools/editor/neovim/plugins/base16.lua create mode 100644 modules/tools/editor/neovim/plugins/comment.lua create mode 100644 modules/tools/editor/neovim/plugins/lualine.lua create mode 100644 modules/tools/editor/neovim/plugins/nvim-tree.lua create mode 100644 modules/tools/editor/neovim/plugins/treesitter.nix create mode 100644 modules/tools/file-manager/default.nix create mode 100644 modules/tools/file-manager/lf/default.nix create mode 100644 modules/tools/file-manager/lf/icons create mode 100644 modules/tools/file-manager/lf/scripts/previewer.sh create mode 100644 modules/tools/file-manager/lsd/default.nix create mode 100644 modules/tools/git/default.nix create mode 100644 modules/tools/system-monitor/default.nix create mode 100644 modules/tools/system-monitor/htop/default.nix create mode 100644 modules/tools/viewer/bat/default.nix create mode 100644 modules/tools/viewer/bat/theme.nix create mode 100644 modules/tools/viewer/default.nix (limited to 'modules/tools') diff --git a/modules/tools/default.nix b/modules/tools/default.nix new file mode 100644 index 0000000..bf96557 --- /dev/null +++ b/modules/tools/default.nix @@ -0,0 +1,11 @@ +{ lib, config, ... }: + +{ + imports = [ + ./editor + ./file-manager + ./git + ./system-monitor + ./viewer + ]; +} diff --git a/modules/tools/editor/default.nix b/modules/tools/editor/default.nix new file mode 100644 index 0000000..1a146bf --- /dev/null +++ b/modules/tools/editor/default.nix @@ -0,0 +1,7 @@ +{ lib, config, ... }: + +{ + imports = [ + ./neovim + ]; +} diff --git a/modules/tools/editor/neovim/default.nix b/modules/tools/editor/neovim/default.nix new file mode 100644 index 0000000..e06ec88 --- /dev/null +++ b/modules/tools/editor/neovim/default.nix @@ -0,0 +1,43 @@ +{ pkgs, config, lib, ... }: + +{ + options = { + neovim.enable = lib.mkEnableOption "Enables neovim."; + }; + + config = lib.mkIf config.neovim.enable { + programs.neovim.enable = true; + programs.neovim.viAlias = true; + programs.neovim.vimAlias = true; + programs.neovim.vimdiffAlias = true; + programs.neovim.defaultEditor = true; + + programs.neovim.extraPackages = with pkgs; [ + gcc # Required for treesitter + ]; + + programs.neovim.extraLuaConfig = + '' + ${builtins.readFile ./options.lua} + ${builtins.readFile ./keybindings.lua} + + -- Plugins configuration + ${builtins.readFile ./plugins/comment.lua} + ${builtins.readFile ./plugins/lualine.lua} + ${import ./plugins/treesitter.nix config} + ${builtins.readFile ./plugins/base16.lua} + ${builtins.readFile ./plugins/nvim-tree.lua} + ''; + + programs.neovim.plugins = with pkgs.vimPlugins; [ + comment-nvim + lualine-nvim + nvim-treesitter + nvim-web-devicons + nvim-tree-lua + (base16-vim.overrideAttrs (old: { + patchPhase = "ln -s ${config.scheme base16-vim} colors/base16-scheme.vim"; + })) + ]; + }; +} diff --git a/modules/tools/editor/neovim/keybindings.lua b/modules/tools/editor/neovim/keybindings.lua new file mode 100644 index 0000000..3e8e0fa --- /dev/null +++ b/modules/tools/editor/neovim/keybindings.lua @@ -0,0 +1,8 @@ +-- Navigate splits +vim.keymap.set("n", "", ":wincmd h", { silent = true }); +vim.keymap.set("n", "", ":wincmd j", { silent = true }); +vim.keymap.set("n", "", ":wincmd k", { silent = true }); +vim.keymap.set("n", "", ":wincmd l", { silent = true }); + +-- NvimTree +vim.keymap.set("n", "", ":NvimTreeToggle", { silent = true }); diff --git a/modules/tools/editor/neovim/options.lua b/modules/tools/editor/neovim/options.lua new file mode 100644 index 0000000..b1fe9cb --- /dev/null +++ b/modules/tools/editor/neovim/options.lua @@ -0,0 +1,21 @@ +vim.g.mapleader = " "; +vim.g.maplocalleader = " "; + +vim.o.clipboard = "unnamedplus"; + +vim.o.number = true; +vim.o.list = true; +vim.o.listchars = "tab:| ,trail:_,lead:_"; + +vim.o.laststatus = 3; + +vim.o.signcolumn = "auto"; +vim.opt.fillchars = { eob = " " }; + +vim.o.tabstop = 2; +vim.o.shiftwidth = 2; +vim.o.expandtab = false; + +vim.o.updatetime = 300; + +vim.o.mouse = "a"; diff --git a/modules/tools/editor/neovim/plugins/base16.lua b/modules/tools/editor/neovim/plugins/base16.lua new file mode 100644 index 0000000..9843b76 --- /dev/null +++ b/modules/tools/editor/neovim/plugins/base16.lua @@ -0,0 +1,6 @@ +vim.o.termguicolors = true; +vim.opt.termguicolors = true; +vim.o.background = "dark"; +vim.g.base16colorspace = 256 +vim.cmd.colorscheme("base16-scheme"); +vim.api.nvim_set_hl(0, "LineNr", { link = "Normal" }); -- disable the background of line numbers diff --git a/modules/tools/editor/neovim/plugins/comment.lua b/modules/tools/editor/neovim/plugins/comment.lua new file mode 100644 index 0000000..9086261 --- /dev/null +++ b/modules/tools/editor/neovim/plugins/comment.lua @@ -0,0 +1 @@ +require("Comment").setup(); diff --git a/modules/tools/editor/neovim/plugins/lualine.lua b/modules/tools/editor/neovim/plugins/lualine.lua new file mode 100644 index 0000000..ba2eda6 --- /dev/null +++ b/modules/tools/editor/neovim/plugins/lualine.lua @@ -0,0 +1,5 @@ +require("lualine").setup { + options = { + globalstatus = true, + }, +}; diff --git a/modules/tools/editor/neovim/plugins/nvim-tree.lua b/modules/tools/editor/neovim/plugins/nvim-tree.lua new file mode 100644 index 0000000..c6c4102 --- /dev/null +++ b/modules/tools/editor/neovim/plugins/nvim-tree.lua @@ -0,0 +1,13 @@ +require("nvim-tree").setup { + filters = { + enable = false + }, + renderer = { + indent_markers = { + enable = true + }, + root_folder_label = function(path) + return vim.fn.fnamemodify(path, ":t") + end, + }, +}; diff --git a/modules/tools/editor/neovim/plugins/treesitter.nix b/modules/tools/editor/neovim/plugins/treesitter.nix new file mode 100644 index 0000000..05f1f2a --- /dev/null +++ b/modules/tools/editor/neovim/plugins/treesitter.nix @@ -0,0 +1,13 @@ +config: + +'' +require("nvim-treesitter.configs").setup { + auto_install = true, + highlight = { + enable = true, + }, + parser_install_dir = "${config.xdg.dataHome}/nvim", +}; + +vim.opt.runtimepath:append("${config.xdg.dataHome}/nvim"); +'' diff --git a/modules/tools/file-manager/default.nix b/modules/tools/file-manager/default.nix new file mode 100644 index 0000000..d127a66 --- /dev/null +++ b/modules/tools/file-manager/default.nix @@ -0,0 +1,8 @@ +{ lib, config, ... }: + +{ + imports = [ + ./lf + ./lsd + ]; +} diff --git a/modules/tools/file-manager/lf/default.nix b/modules/tools/file-manager/lf/default.nix new file mode 100644 index 0000000..00784cf --- /dev/null +++ b/modules/tools/file-manager/lf/default.nix @@ -0,0 +1,21 @@ +{ config, pkgs, lib, ... }: + +{ + options = { + lf.enable = lib.mkEnableOption "Enables lf."; + }; + + config = lib.mkIf config.lf.enable { + programs.lf.enable = true; + programs.lf.settings = { + hidden = true; + }; + programs.lf.previewer.source = pkgs.writeShellScript + "previewer.sh" + (builtins.readFile ./scripts/previewer.sh); + + programs.lf.extraConfig = "set icons"; + + xdg.configFile."lf/icons".source = ./icons; + }; +} diff --git a/modules/tools/file-manager/lf/icons b/modules/tools/file-manager/lf/icons new file mode 100644 index 0000000..2e9d8a2 --- /dev/null +++ b/modules/tools/file-manager/lf/icons @@ -0,0 +1,334 @@ +# vim:ft=conf + +# These examples require Nerd Fonts or a compatible font to be used. +# See https://www.nerdfonts.com for more information. + +# file types (with matching order) +ln  # LINK +or  # ORPHAN +tw t # STICKY_OTHER_WRITABLE +ow  # OTHER_WRITABLE +st t # STICKY +di  # DIR +pi p # FIFO +so s # SOCK +bd b # BLK +cd c # CHR +su u # SETUID +sg g # SETGID +ex  # EXEC +fi  # FILE + +# file extensions (vim-devicons) +*.styl  +*.sass  +*.scss  +*.htm  +*.html  +*.slim  +*.haml  +*.ejs  +*.css  +*.less  +*.md  +*.mdx  +*.markdown  +*.rmd  +*.json  +*.webmanifest  +*.js  +*.mjs  +*.jsx  +*.rb  +*.gemspec  +*.rake  +*.php  +*.py  +*.pyc  +*.pyo  +*.pyd  +*.coffee  +*.mustache  +*.hbs  +*.conf  +*.ini  +*.yml  +*.yaml  +*.toml  +*.bat  +*.mk  +*.jpg  +*.jpeg  +*.bmp  +*.png  +*.webp  +*.gif  +*.ico  +*.twig  +*.cpp  +*.c++  +*.cxx  +*.cc  +*.cp  +*.c  +*.cs 󰌛 +*.h  +*.hh  +*.hpp  +*.hxx  +*.hs  +*.lhs  +*.nix  +*.lua  +*.java  +*.sh  +*.fish  +*.bash  +*.zsh  +*.ksh  +*.csh  +*.awk  +*.ps1  +*.ml λ +*.mli λ +*.diff  +*.db  +*.sql  +*.dump  +*.clj  +*.cljc  +*.cljs  +*.edn  +*.scala  +*.go  +*.dart  +*.xul  +*.sln  +*.suo  +*.pl  +*.pm  +*.t  +*.rss  +'*.f#'  +*.fsscript  +*.fsx  +*.fs  +*.fsi  +*.rs  +*.rlib  +*.d  +*.erl  +*.hrl  +*.ex  +*.exs  +*.eex  +*.leex  +*.heex  +*.vim  +*.ai  +*.psd  +*.psb  +*.ts  +*.tsx  +*.jl  +*.pp  +*.vue  +*.elm  +*.swift  +*.xcplayground  +*.tex 󰙩 +*.r 󰟔 +*.rproj 󰗆 +*.sol 󰡪 +*.pem  + +# file names (vim-devicons) (case-insensitive not supported in lf) +*gruntfile.coffee  +*gruntfile.js  +*gruntfile.ls  +*gulpfile.coffee  +*gulpfile.js  +*gulpfile.ls  +*mix.lock  +*dropbox  +*.ds_store  +*.gitconfig  +*.gitignore  +*.gitattributes  +*.gitlab-ci.yml  +*.bashrc  +*.zshrc  +*.zshenv  +*.zprofile  +*.vimrc  +*.gvimrc  +*_vimrc  +*_gvimrc  +*.bashprofile  +*favicon.ico  +*license  +*node_modules  +*react.jsx  +*procfile  +*dockerfile  +*docker-compose.yml  +*docker-compose.yaml  +*compose.yml  +*compose.yaml  +*rakefile  +*config.ru  +*gemfile  +*makefile  +*cmakelists.txt  +*robots.txt 󰚩 + +# file names (case-sensitive adaptations) +*Gruntfile.coffee  +*Gruntfile.js  +*Gruntfile.ls  +*Gulpfile.coffee  +*Gulpfile.js  +*Gulpfile.ls  +*Dropbox  +*.DS_Store  +*LICENSE  +*React.jsx  +*Procfile  +*Dockerfile  +*Docker-compose.yml  +*Docker-compose.yaml  +*Rakefile  +*Gemfile  +*Makefile  +*CMakeLists.txt  + +# file patterns (file name adaptations) +*jquery.min.js  +*angular.min.js  +*backbone.min.js  +*require.min.js  +*materialize.min.js  +*materialize.min.css  +*mootools.min.js  +*vimrc  +Vagrantfile  + +# archives or compressed (extensions from dircolors defaults) +*.tar  +*.tgz  +*.arc  +*.arj  +*.taz  +*.lha  +*.lz4  +*.lzh  +*.lzma  +*.tlz  +*.txz  +*.tzo  +*.t7z  +*.zip  +*.z  +*.dz  +*.gz  +*.lrz  +*.lz  +*.lzo  +*.xz  +*.zst  +*.tzst  +*.bz2  +*.bz  +*.tbz  +*.tbz2  +*.tz  +*.deb  +*.rpm  +*.jar  +*.war  +*.ear  +*.sar  +*.rar  +*.alz  +*.ace  +*.zoo  +*.cpio  +*.7z  +*.rz  +*.cab  +*.wim  +*.swm  +*.dwm  +*.esd  + +# image formats (extensions from dircolors defaults) +*.jpg  +*.jpeg  +*.mjpg  +*.mjpeg  +*.gif  +*.bmp  +*.pbm  +*.pgm  +*.ppm  +*.tga  +*.xbm  +*.xpm  +*.tif  +*.tiff  +*.png  +*.svg  +*.svgz  +*.mng  +*.pcx  +*.mov  +*.mpg  +*.mpeg  +*.m2v  +*.mkv  +*.webm  +*.ogm  +*.mp4  +*.m4v  +*.mp4v  +*.vob  +*.qt  +*.nuv  +*.wmv  +*.asf  +*.rm  +*.rmvb  +*.flc  +*.avi  +*.fli  +*.flv  +*.gl  +*.dl  +*.xcf  +*.xwd  +*.yuv  +*.cgm  +*.emf  +*.ogv  +*.ogx  + +# audio formats (extensions from dircolors defaults) +*.aac  +*.au  +*.flac  +*.m4a  +*.mid  +*.midi  +*.mka  +*.mp3  +*.mpc  +*.ogg  +*.ra  +*.wav  +*.oga  +*.opus  +*.spx  +*.xspf  + +# other formats +*.pdf  diff --git a/modules/tools/file-manager/lf/scripts/previewer.sh b/modules/tools/file-manager/lf/scripts/previewer.sh new file mode 100644 index 0000000..407e0a0 --- /dev/null +++ b/modules/tools/file-manager/lf/scripts/previewer.sh @@ -0,0 +1,3 @@ +#!/bin/sh +unset COLORTERM +bat -pp --line-range=:500 --color=always "$1" diff --git a/modules/tools/file-manager/lsd/default.nix b/modules/tools/file-manager/lsd/default.nix new file mode 100644 index 0000000..0f57e6b --- /dev/null +++ b/modules/tools/file-manager/lsd/default.nix @@ -0,0 +1,17 @@ +{ pkgs, lib, config, ... }: + +{ + options = { + lsd.enable = lib.mkEnableOption "Enables lsd."; + }; + + config = lib.mkIf config.lsd.enable { + programs.lsd.enable = true; + programs.lsd.enableAliases = true; + programs.bash.shellAliases."tree" = "${pkgs.lsd}/bin/lsd -a --tree"; + + programs.lsd.settings = { + icons.separator = " "; + }; + }; +} diff --git a/modules/tools/git/default.nix b/modules/tools/git/default.nix new file mode 100644 index 0000000..7396cb8 --- /dev/null +++ b/modules/tools/git/default.nix @@ -0,0 +1,20 @@ +{ lib, config, ... }: + +{ + options = { + git.enable = lib.mkEnableOption "Enables git."; + }; + + config = lib.mkIf config.git.enable { + programs.git.enable = true; + programs.git.userEmail = "54011232+arpitchakladar@users.noreply.github.com"; + programs.git.userName = "Arpit Chakladar"; + programs.git.extraConfig = { + credential.helper = "store --file ${config.xdg.cacheHome}/git/credential"; + core.askPass = ""; + }; + + # The base directory of the credential file must exist + home.activation.createGitCacheDirectory = lib.hm.dag.entryAfter [ "writeBoundary" ] "mkdir -p ${config.xdg.cacheHome}/git"; + }; +} diff --git a/modules/tools/system-monitor/default.nix b/modules/tools/system-monitor/default.nix new file mode 100644 index 0000000..a5b569c --- /dev/null +++ b/modules/tools/system-monitor/default.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + imports = [ + ./htop + ]; +} diff --git a/modules/tools/system-monitor/htop/default.nix b/modules/tools/system-monitor/htop/default.nix new file mode 100644 index 0000000..f27174a --- /dev/null +++ b/modules/tools/system-monitor/htop/default.nix @@ -0,0 +1,12 @@ +{ pkgs, lib, config, ... }: + +{ + options = { + htop.enable = lib.mkEnableOption "Enables htop."; + }; + + config = lib.mkIf config.htop.enable { + programs.htop.enable = true; + programs.htop.package = pkgs.htop-vim; + }; +} diff --git a/modules/tools/viewer/bat/default.nix b/modules/tools/viewer/bat/default.nix new file mode 100644 index 0000000..cc01f82 --- /dev/null +++ b/modules/tools/viewer/bat/default.nix @@ -0,0 +1,14 @@ +{ config, lib, ... }: + +{ + options = { + bat.enable = lib.mkEnableOption "Enables bat."; + }; + + config = lib.mkIf config.bat.enable { + programs.bat.enable = true; + programs.bat.config.theme = "customTheme"; + xdg.configFile."bat/themes/customTheme.tmTheme".text + = import ./theme.nix config; + }; +} diff --git a/modules/tools/viewer/bat/theme.nix b/modules/tools/viewer/bat/theme.nix new file mode 100644 index 0000000..e345ee4 --- /dev/null +++ b/modules/tools/viewer/bat/theme.nix @@ -0,0 +1,124 @@ +config: + +with config.scheme.withHashtag; +'' + + + + name + customTheme + settings + + + + settings + + background + #0F1419 + foreground + #E6E1CF + caret + #F3F4F5 + invisibles + #3E4B59 + lineHighlight + #272D38 + selection + #3E4B59 + + + + + + scope + comment + settings + + foreground + #BFBDB6 + + + + + scope + string + settings + + foreground + #FFB454 + + + + + scope + constant.numeric + settings + + foreground + #FF8F40 + + + + + scope + variable + settings + + foreground + #F07178 + + + + + scope + keyword + settings + + foreground + #59C2FF + + + + + scope + support.function + settings + + foreground + #D2A6FF + + + + + scope + constant.language + settings + + foreground + #B8CC52 + + + + + scope + entity.name.tag + settings + + foreground + #95E6CB + + + + + scope + invalid + settings + + foreground + #E6B673 + + + + + +'' diff --git a/modules/tools/viewer/default.nix b/modules/tools/viewer/default.nix new file mode 100644 index 0000000..dde782b --- /dev/null +++ b/modules/tools/viewer/default.nix @@ -0,0 +1,7 @@ +{ lib, config, ... }: + +{ + imports = [ + ./bat + ]; +} -- cgit v1.2.3