From 1df02ef4d8354d4702e076268625cec38aa81e8f Mon Sep 17 00:00:00 2001 From: Sokhibjon Orzikulov Date: Tue, 2 Jul 2024 03:56:54 +0500 Subject: [PATCH] bringing back homeModules and setting everything locally --- .github/configs/config/fastfetch/config.jsonc | 48 ++ .github/configs/share/fastfetch/logos/orzklv | 15 + flake.lock | 142 +----- flake.nix | 17 +- home/sakhib.nix | 43 ++ modules/home/default.nix | 10 + modules/home/neovim/default.nix | 149 ++++++ modules/home/neovim/readme.md | 228 +++++++++ modules/home/neovim/user/init.lua | 458 ++++++++++++++++++ modules/home/neovim/user/mappings.lua | 68 +++ modules/home/nixpkgs/default.nix | 33 ++ modules/home/packages/default.nix | 67 +++ modules/home/topgrade/default.nix | 30 ++ modules/home/zsh/default.nix | 205 ++++++++ modules/home/zsh/starship.nix | 10 + modules/home/zsh/zoxide.nix | 7 + modules/nixos/default.nix | 2 + modules/nixos/nixpkgs.nix | 53 ++ modules/nixos/ssh.nix | 16 + modules/nixos/users/default.nix | 5 + modules/nixos/users/sakhib.nix | 33 ++ nixos/kolyma-1/configuration.nix | 59 +-- nixos/kolyma-2/configuration.nix | 59 +-- nixos/kolyma-3/configuration.nix | 62 +-- 24 files changed, 1496 insertions(+), 323 deletions(-) create mode 100644 .github/configs/config/fastfetch/config.jsonc create mode 100644 .github/configs/share/fastfetch/logos/orzklv create mode 100644 home/sakhib.nix create mode 100644 modules/home/default.nix create mode 100644 modules/home/neovim/default.nix create mode 100644 modules/home/neovim/readme.md create mode 100644 modules/home/neovim/user/init.lua create mode 100644 modules/home/neovim/user/mappings.lua create mode 100644 modules/home/nixpkgs/default.nix create mode 100644 modules/home/packages/default.nix create mode 100644 modules/home/topgrade/default.nix create mode 100644 modules/home/zsh/default.nix create mode 100644 modules/home/zsh/starship.nix create mode 100644 modules/home/zsh/zoxide.nix create mode 100644 modules/nixos/nixpkgs.nix create mode 100644 modules/nixos/ssh.nix create mode 100644 modules/nixos/users/default.nix create mode 100644 modules/nixos/users/sakhib.nix diff --git a/.github/configs/config/fastfetch/config.jsonc b/.github/configs/config/fastfetch/config.jsonc new file mode 100644 index 0000000..5ce12ec --- /dev/null +++ b/.github/configs/config/fastfetch/config.jsonc @@ -0,0 +1,48 @@ +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "source": "orzklv", + "padding": { + "top": 3, + "right": 3, + "left": 3 + } + }, + "display": { + "binaryPrefix": "si", + "color": "black" + }, + "modules": [ + "title", + "separator", + "os", + "host", + "kernel", + "uptime", + "packages", + "shell", + "display", + "de", + "wm", + "wmtheme", + "theme", + "icons", + "font", + "cursor", + "terminal", + "terminalfont", + "cpu", + "gpu", + "memory", + "swap", + "disk", + "localip", + "battery", + "poweradapter", + "locale", + "break", + "colors" + ] +} + + \ No newline at end of file diff --git a/.github/configs/share/fastfetch/logos/orzklv b/.github/configs/share/fastfetch/logos/orzklv new file mode 100644 index 0000000..6a00510 --- /dev/null +++ b/.github/configs/share/fastfetch/logos/orzklv @@ -0,0 +1,15 @@ + ## + #### + ###### + ################### + ################### + ################## + ###### ############ + ####### ############ +####### ############ + ####### + ####### + ####### + ###### + #### + ## \ No newline at end of file diff --git a/flake.lock b/flake.lock index f946fd7..42fd617 100644 --- a/flake.lock +++ b/flake.lock @@ -17,70 +17,6 @@ "type": "github" } }, - "astronvim_2": { - "flake": false, - "locked": { - "lastModified": 1702659104, - "narHash": "sha256-h019vKDgaOk0VL+bnAPOUoAL8VAkhY6MGDbqEy+uAKg=", - "owner": "AstroNvim", - "repo": "AstroNvim", - "rev": "271c9c3f71c2e315cb16c31276dec81ddca6a5a6", - "type": "github" - }, - "original": { - "owner": "AstroNvim", - "ref": "v3.40.3", - "repo": "AstroNvim", - "type": "github" - } - }, - "cfg-sakhib": { - "inputs": { - "astronvim": "astronvim_2", - "disko": "disko", - "flake-utils": "flake-utils", - "home-manager": "home-manager", - "nixpkgs": [ - "nixpkgs" - ], - "nixpkgs-unstable": "nixpkgs-unstable" - }, - "locked": { - "lastModified": 1719860615, - "narHash": "sha256-MNJ9t+rhJ9DwCVe/QGbtdOgA/8+oxa3yeMbvq184q1k=", - "owner": "orzklv", - "repo": "nix", - "rev": "fd20d4fed90b2a01c79b9a0bbd8a14bc7505e3fe", - "type": "github" - }, - "original": { - "owner": "orzklv", - "ref": "master", - "repo": "nix", - "type": "github" - } - }, - "disko": { - "inputs": { - "nixpkgs": [ - "cfg-sakhib", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1719733833, - "narHash": "sha256-6h2EqZU9bL9rHlXE+2LCBgnDImejzbS+4dYsNDDFlkY=", - "owner": "nix-community", - "repo": "disko", - "rev": "d185770ea261fb5cf81aa5ad1791b93a7834d12c", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "disko", - "type": "github" - } - }, "flake-utils": { "inputs": { "systems": "systems" @@ -99,47 +35,7 @@ "type": "github" } }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "home-manager": { - "inputs": { - "nixpkgs": [ - "cfg-sakhib", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1719827439, - "narHash": "sha256-tneHOIv1lEavZ0vQ+rgz67LPNCgOZVByYki3OkSshFU=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "59ce796b2563e19821361abbe2067c3bb4143a7d", - "type": "github" - }, - "original": { - "owner": "nix-community", - "ref": "master", - "repo": "home-manager", - "type": "github" - } - }, - "home-manager_2": { "inputs": { "nixpkgs": [ "nixpkgs" @@ -192,30 +88,13 @@ "type": "github" } }, - "nixpkgs-unstable_2": { - "locked": { - "lastModified": 1719690277, - "narHash": "sha256-0xSej1g7eP2kaUF+JQp8jdyNmpmCJKRpO12mKl/36Kc=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "2741b4b489b55df32afac57bc4bfd220e8bf617e", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { "astronvim": "astronvim", - "cfg-sakhib": "cfg-sakhib", - "flake-utils": "flake-utils_2", - "home-manager": "home-manager_2", + "flake-utils": "flake-utils", + "home-manager": "home-manager", "nixpkgs": "nixpkgs", - "nixpkgs-unstable": "nixpkgs-unstable_2" + "nixpkgs-unstable": "nixpkgs-unstable" } }, "systems": { @@ -232,21 +111,6 @@ "repo": "default", "type": "github" } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index e50801d..168bca0 100644 --- a/flake.nix +++ b/flake.nix @@ -32,18 +32,6 @@ url = "github:AstroNvim/AstroNvim/v3.40.3"; flake = false; }; - - # Orzklv (Kolyma's Owner) - cfg-sakhib = { - url = "github:orzklv/nix/master"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - # Muzaffar (Minecraft Server Moderator) - # cfg-muzaffar = { - # url = "github:Muzaffar-x/nix"; - # inputs.nixpkgs.follows = "nixpkgs"; - # }; }; # In this context, outputs are mostly about getting home-manager what it @@ -54,7 +42,6 @@ nixpkgs-unstable, home-manager, flake-utils, - cfg-sakhib, ... } @ inputs: let inherit (self) outputs; @@ -127,6 +114,10 @@ # These are usually stuff you would upstream into nixpkgs nixosModules = import ./modules/nixos; + # Reusable home-manager modules you might want to export + # These are usually stuff you would upstream into home-manager + homeManagerModules = import ./modules/home; + # Reusable server modules you might want to export # These are usually stuff you would upstream services to global serverModules = import ./modules/server; diff --git a/home/sakhib.nix b/home/sakhib.nix new file mode 100644 index 0000000..8ceb8f4 --- /dev/null +++ b/home/sakhib.nix @@ -0,0 +1,43 @@ +{ + inputs, + lib, + pkgs, + config, + outputs, + packages, + self, + ... +}: { + imports = [ + outputs.homeManagerModules.zsh + outputs.homeManagerModules.neovim + outputs.homeManagerModules.nixpkgs + outputs.homeManagerModules.topgrade + outputs.homeManagerModules.packages + ]; + + # This is required information for home-manager to do its job + home = { + stateVersion = "24.05"; + username = "sakhib"; + homeDirectory = "/home/sakhib"; + + # Tell it to map everything in the `config` directory in this + # repository to the `.config` in my home-manager directory + file.".config" = { + source = ../.github/configs/config; + recursive = true; + }; + + file.".local/share" = { + source = ../.github/configs/share; + recursive = true; + }; + + # Don't check if home manager is same as nixpkgs + enableNixpkgsReleaseCheck = false; + }; + + # Let's enable home-manager + programs.home-manager.enable = true; +} diff --git a/modules/home/default.nix b/modules/home/default.nix new file mode 100644 index 0000000..c6cddcc --- /dev/null +++ b/modules/home/default.nix @@ -0,0 +1,10 @@ +# Add your reusable home-manager modules to this directory, on their own file (https://nixos.wiki/wiki/Module). +# These should be stuff you would like to share with others, not your personal configurations. +{ + # List your module files here + zsh = import ./zsh; + neovim = import ./neovim; + nixpkgs = import ./nixpkgs; + topgrade = import ./topgrade; + packages = import ./packages; +} diff --git a/modules/home/neovim/default.nix b/modules/home/neovim/default.nix new file mode 100644 index 0000000..59c6f71 --- /dev/null +++ b/modules/home/neovim/default.nix @@ -0,0 +1,149 @@ +{ + inputs, + pkgs, + ... +}: { + imports = []; + + xdg.configFile = { + # astronvim's config + "nvim".source = inputs.astronvim; + + # my custom astronvim config, astronvim will load it after base config + # https://github.com/AstroNvim/AstroNvim/blob/v3.32.0/lua/astronvim/bootstrap.lua#L15-L16 + "astronvim/lua/user".source = ./user; + }; + + nixpkgs.config = { + programs.npm.npmrc = '' + prefix = ''${HOME}/.npm-global + ''; + }; + + programs = { + neovim = { + enable = true; + + defaultEditor = true; + viAlias = true; + vimAlias = true; + + # currently we use lazy.nvim as neovim's package manager, so comment this one. + # plugins = with pkgs.vimPlugins; [ + # # search all the plugins using https://search.nixos.org/packages + # ]; + + # Extra packages only available to nvim(won't pollute the global home environment) + extraPackages = with pkgs; + [ + #-- c/c++ + cmake + cmake-language-server + gnumake + checkmake + gcc # c/c++ compiler, required by nvim-treesitter! + llvmPackages.clang-unwrapped # c/c++ tools with clang-tools such as clangd + lldb + + #-- python + python3Packages.black # python formatter + python3Packages.ruff-lsp + (python3.withPackages ( + ps: + with ps; [ + pynvim # Python client and plugin host for Nvim + + ipython + pandas + requests + pyquery + pyyaml + ] + )) + + #-- rust + rust-analyzer + cargo # rust package manager + rustfmt + + #-- zig + zls + + #-- nix + nil + # nixd + statix # Lints and suggestions for the nix programming language + deadnix # Find and remove unused code in .nix source files + alejandra # Nix Code Formatter + + #-- golang + go + gomodifytags + iferr # generate error handling code for go + impl # generate function implementation for go + gotools # contains tools like: godoc, goimports, etc. + gopls # go language server + delve # go debugger + + # -- java + jdk17 + gradle + maven + spring-boot-cli + + #-- lua + stylua + lua-language-server + + #-- bash + nodePackages.bash-language-server + shellcheck + shfmt + + #-- javascript/typescript --# + nodePackages.nodejs + nodePackages.typescript + nodePackages.typescript-language-server + # HTML/CSS/JSON/ESLint language servers extracted from vscode + nodePackages.vscode-langservers-extracted + nodePackages."@tailwindcss/language-server" + + #-- CloudNative + nodePackages.dockerfile-language-server-nodejs + emmet-ls + jsonnet + jsonnet-language-server + hadolint # Dockerfile linter + + #-- Others + taplo # TOML language server / formatter / validator + nodePackages.yaml-language-server + sqlfluff # SQL linter + actionlint # GitHub Actions linter + buf # protoc plugin for linting and formatting + proselint # English prose linter + guile # scheme language + + #-- Misc + tree-sitter # common language parser/highlighter + nodePackages.prettier # common code formatter + marksman # language server for markdown + glow # markdown previewer + fzf + + #-- Optional Requirements: + gdu # disk usage analyzer, required by AstroNvim + ripgrep # fast search tool, required by AstroNvim's 'fw'( is space key) + ] + ++ ( + if pkgs.stdenv.isDarwin + then [] + else [ + #-- verilog / systemverilog + verible + gdb + ] + ); + }; + }; +} diff --git a/modules/home/neovim/readme.md b/modules/home/neovim/readme.md new file mode 100644 index 0000000..73d728f --- /dev/null +++ b/modules/home/neovim/readme.md @@ -0,0 +1,228 @@ +# AstroNvim Configuration and Shortcuts + +My Neovim config based on [AstroNvim](https://github.com/AstroNvim/AstroNvim). +For more details, visit the [AstroNvim website](https://astronvim.com/). + +This document outlines neovim's configuration structure and various shortcuts/commands for efficient usage. + +## Configuration Structure + +| Description | Standard Location | My Location | +| ------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------- | +| Neovim's config | `~/.config/nvim` | AstroNvim's github repository, referenced as a flake input in this flake. | +| AstroNvim's user configuration | `$XDG_CONFIG_HOME/astronvim/lua/user` | [./astronvim_user/](./astronvim_user/) | +| Plugins installation directory (lazy.nvim) | `~/.local/share/nvim/` | The same as standard location, generated and managed by lazy.nvim. | +| LSP servers, DAP servers, linters, and formatters | `~/.local/share/nvim/mason/`(by mason.nvim) | [./default.nix](./default.nix), installed by nix. | + +## Update/Clean Plugins + +Note that lazy.nvim will not automatically update plugins, so you need to update them manually. + +```bash +:Lazy update +``` + +Remove all unused plugins: + +```bash +:Lazy clean +``` + +## Screenshots + +![](/_img/astronvim_2023-07-13_00-39.webp) +![](/_img/hyprland_2023-07-29_2.webp) + +## Visual Modes + +| Action | Shortcut | +| ------------------------ | ---------------------------------------- | +| Toggle visual mode | `v` | +| Toggle visual block mode | ` + v` (select a block vertically) | + +## Incremental Selection + +Provided by nvim-treesitter. + +| Action | Shortcut | +| ----------------- | -------------- | +| init selection | `` | +| node incremental | `` | +| scope incremental | `` | +| node decremental | `Backspace` | + +## Search and Jump + +Provided by [flash.nvim](https://github.com/folke/flash.nvim), it's a intelligent search and jump plugin. + +1. It enhaces the default search and jump behavior of neovim.(search with prefix `/`) + +| Action | Shortcut | +| ----------------- | ------------------------------------------------------------------------------------------------------------- | +| Search | `/`(normal search), `s`(disable all code highlight, only highlight matches) | +| Treesitter Search | `yR`,`dR`, `cR`, `vR`, `ctrl+v+R`(arround your matches, all the surrounding Treesitter nodes will be labeled) | +| Remote Flash | `yr`, `dr`, `cr`, (arround your matches, all the surrounding Treesitter nodes will be labeled) | + +## Text Manipulation + +- Add at the end of multiple lines: `:normal A` + + - Execublock: `:A` + + - visual block mode(ctrl + v) + - Append text at the end of each line in the selected block + - If position exceeds line end, neovim adds spaces automatically + +- Delete the last char of multivle lines: `:normal $x` + + - Execute `$x` on each line + - visual mode(v) + - `$` moves cursor to the end of line + - `x` deletes the character under the cursor + +- Delete the last word of multiple lines: `:normal $bD` + - Execute `$bD` on each line + - visual mode(v) + - `$` moves cursor to the end of line + - `b` moves cursor to the beginning of the last word + - `D` deletes from cursor to the end of line + +## Commands & Shortcuts + +| Action | Shortcut | +| ----------------------------- | -------------- | +| Learn Neovim's Basics | `:Tutor` | +| Open file explorer | ` + e` | +| Focus Neotree to current file | ` + o` | +| Floating Terminal | ` + tf` | +| Horizontal Split Terminal | ` + th` | +| Vertical Split Terminal | ` + tv` | +| Open IPython REPL | ` + tp` | +| Toggle line wrap | ` + uw` | +| Show line diagnostics | `gl` | +| Show function/variable info | `K` | +| Go to definition | `gd` | +| References of a symbol | `gr` | + +## Window Navigation + +- Switch between windows: ` + h/j/k/l` +- Resize windows: ` + Up/Down/Left/Right` + - Note: On macOS, conflicts with system shortcuts + - Disable in System Preferences -> Keyboard -> Shortcuts -> Mission Control + +## Splitting and Buffers + +| Action | Shortcut | +| --------------------- | ------------- | +| Horizontal Split | `\` | +| Vertical Split | `\|` | +| Next Buffer (Tab) | `]b` | +| Previous Buffer (Tab) | `[b` | +| Close Buffer | ` + c` | + +## Editing and Formatting + +| Action | Shortcut | +| ----------------------------------------------------- | -------------- | +| Toggle buffer auto formatting | ` + uf` | +| Format Document | ` + lf` | +| Code Actions | ` + la` | +| Rename | ` + lr` | +| Opening LSP symbols | ` + lS` | +| Comment Line(support multiple lines) | ` + /` | +| Open filepath/URL at cursor(neovim's builtin command) | `gx` | +| Find files by name (fzf) | ` + ff` | +| Grep string in files (ripgrep) | ` + fw` | + +## Sessions + +| Action | Shortcut | +| ------------------------------ | -------------- | +| Save Session | ` + Ss` | +| Last Session | ` + Sl` | +| Delete Session | ` + Sd` | +| Search Session | ` + Sf` | +| Load Current Directory Session | ` + S.` | + +## Debugging + +Press ` + D` to view available bindings and options. + +## Find and Replace + +| Action | Command | +| ------------------------ | ----------------------------------- | +| Replace in selected area | `:s/old/new/g` | +| Replace in current line | Same as above | +| Replace in whole file | `:% s/old/new/g` | +| Replace with regex | `:% s@\vhttp://(\w+)@https://\1@gc` | + +1. `\v` means means that in the regex pattern after it can be used without backslash escaping(similar to python's raw string). +2. `\1` means the first matched group in the pattern. + +## Replace in the specific lines + +| Action | Command | +| ----------------------------------------- | -------------------------------------- | +| From the 10th line to the end of the file | `:10,$ s/old/new/g` or `:10,$ s@^@#@g` | +| From the 10th line to the 20th line | `:10,20 s/old/new/g` | + +The postfix(flags) in the above commands: + +1. `g` means replace all the matched strings in the current line/file. +2. `c` means ask for confirmation before replacing. +3. `i` means ignore case. + +## Search and Replace Globally + +| Description | Shortcut | +| ------------------------------------------------------------ | ---------------------------------------------------------------- | +| Open spectre.nvim search and replace panel | ` + ss` | +| Search and replace in command line(need install `sad` first) | `find -name "*.nix" \| sad '' '' \| delta` | + +## Surrounding Characters + +Provided by mini.surround plugin. + +- Prefix `gz` + +| Action | Shortcut | Description | +| ------------------------------ | -------- | ----------------------------------------------- | +| Add surrounding characters | `gzaiw'` | Add `'` around the word under cursor | +| Delete surrounding characters | `gzd'` | Delete `'` around the word under cursor | +| Replace surrounding characters | `gzr'"` | Replace `'` by `"` around the word under cursor | +| Highlight surrounding | `gzh'` | Highlight `'` around the word under cursor | + +## Text Manipulation + +| Action | | +| -------------------------------------- | ------------- | +| Join Selection of Lines With Space | `:join` | +| Join without spaces | `:join!` | +| Join with LSP intelligence(treesj) | ` + j` | +| Split Line into Multiple Lines(treesj) | ` + s` | + +## Convert Text Case + +| Action | | +| -------------------- | --- | +| Toggle text's case | `~` | +| Convert to uppercase | `U` | +| Convert to lowercase | `u` | + +## Miscellaneous + +| Action | | +| ---------------------------- | -------------------------------------------- | +| Save selected text to a file | `:w filename` (Will show `:'<,'>w filename`) | +| Show all Yank History | `: + yh` | +| Show undo history | `: + uh` | + +## Additional Resources + +For more detailed information and advanced usage, refer to: + +1. [AstroNvim walkthrough](https://astronvim.com/Basic%20Usage/walkthrough) +2. [./astronvim_user/mapping.lua](./astronvim_user/mappings.lua) +3. All the plugins' documentations \ No newline at end of file diff --git a/modules/home/neovim/user/init.lua b/modules/home/neovim/user/init.lua new file mode 100644 index 0000000..c8ad282 --- /dev/null +++ b/modules/home/neovim/user/init.lua @@ -0,0 +1,458 @@ +return { + colorscheme = "oxocarbon", + + options = { + opt = { + relativenumber = true, -- Show relative numberline + signcolumn = "auto", -- Show sign column when used only + spell = false, -- Spell checking + swapfile = false, -- Swapfile + smartindent = false, -- fix https://github.com/ryan4yin/nix-config/issues/4 + }, + }, + + plugins = { + "AstroNvim/astrocommunity", + -- colorscheme - oxocarbon + { import = "astrocommunity.colorscheme.oxocarbon-nvim" }, + -- Highly experimental plugin that completely replaces + -- the UI for messages, cmdline and the popupmenu. + { import = "astrocommunity.utility.noice-nvim" }, + -- Fully featured & enhanced replacement for copilot.vim + -- work with both auto completion in cmp and copilot + { import = "astrocommunity.motion.leap-nvim" }, + { import = "astrocommunity.motion.flit-nvim" }, + { import = "astrocommunity.scrolling.nvim-scrollbar" }, + { import = "astrocommunity.editing-support.todo-comments-nvim" }, + -- Language Support + ---- Frontend & NodeJS + { import = "astrocommunity.pack.typescript-all-in-one" }, + { import = "astrocommunity.pack.tailwindcss" }, + { import = "astrocommunity.pack.html-css" }, + { import = "astrocommunity.pack.prisma" }, + { import = "astrocommunity.pack.vue" }, + ---- Configuration Language + { import = "astrocommunity.pack.markdown" }, + { import = "astrocommunity.pack.json" }, + { import = "astrocommunity.pack.yaml" }, + { import = "astrocommunity.pack.toml" }, + ---- Backend + { import = "astrocommunity.pack.lua" }, + { import = "astrocommunity.pack.go" }, + { import = "astrocommunity.pack.rust" }, + { import = "astrocommunity.pack.python" }, + { import = "astrocommunity.pack.java" }, + { import = "astrocommunity.pack.nix" }, -- manually add config for nix, comment this one. + { import = "astrocommunity.pack.proto" }, + ---- Operation & Cloud Native + { import = "astrocommunity.pack.terraform" }, + { import = "astrocommunity.pack.bash" }, + { import = "astrocommunity.pack.cmake" }, + { import = "astrocommunity.pack.cpp" }, + { import = "astrocommunity.pack.docker" }, + -- Motion + { import = "astrocommunity.motion.mini-surround" }, + -- https://github.com/echasnovski/mini.ai + { import = "astrocommunity.motion.mini-ai" }, + { import = "astrocommunity.motion.flash-nvim" }, + { "folke/flash.nvim", vscode = false }, + -- Lua implementation of CamelCaseMotion, with extra consideration of punctuation. + { import = "astrocommunity.motion.nvim-spider" }, + -- AI Assistant + { import = "astrocommunity.completion.copilot-lua-cmp" }, + -- Custom copilot-lua to enable filtypes: markdown + { + "zbirenbaum/copilot.lua", + opts = function(_, opts) + opts.filetypes = { + yaml = true, + markdown = true, + } + end, + }, + + { + "0x00-ketsu/autosave.nvim", + -- lazy-loading on events + event = { "InsertLeave", "TextChanged" }, + opts = function(_, opts) + opts.prompt_style = "notify" -- or stdout + end, + }, + + -- markdown preview + { + "0x00-ketsu/markdown-preview.nvim", + ft = { "md", "markdown", "mkd", "mkdn", "mdwn", "mdown", "mdtxt", "mdtext", "rmd", "wiki" }, + config = function() + require("markdown-preview").setup({ + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the setup section below + }) + end, + }, + + -- clipboard manager + { + "gbprod/yanky.nvim", + opts = function() + local mapping = require("yanky.telescope.mapping") + local mappings = mapping.get_defaults() + mappings.i[""] = nil + return { + highlight = { timer = 200 }, + picker = { + telescope = { + use_default_mappings = false, + mappings = mappings, + }, + }, + } + end, + keys = { + { + "y", + "(YankyYank)", + mode = { "n", "x" }, + desc = "Yank text", + }, + { + "p", + "(YankyPutAfter)", + mode = { "n", "x" }, + desc = "Put yanked text after cursor", + }, + { + "P", + "(YankyPutBefore)", + mode = { "n", "x" }, + desc = "Put yanked text before cursor", + }, + { + "gp", + "(YankyGPutAfter)", + mode = { "n", "x" }, + desc = "Put yanked text after selection", + }, + { + "gP", + "(YankyGPutBefore)", + mode = { "n", "x" }, + desc = "Put yanked text before selection", + }, + { "[y", "(YankyCycleForward)", desc = "Cycle forward through yank history" }, + { "]y", "(YankyCycleBackward)", desc = "Cycle backward through yank history" }, + { "]p", "(YankyPutIndentAfterLinewise)", desc = "Put indented after cursor (linewise)" }, + { "[p", "(YankyPutIndentBeforeLinewise)", desc = "Put indented before cursor (linewise)" }, + { "]P", "(YankyPutIndentAfterLinewise)", desc = "Put indented after cursor (linewise)" }, + { "[P", "(YankyPutIndentBeforeLinewise)", desc = "Put indented before cursor (linewise)" }, + { ">p", "(YankyPutIndentAfterShiftRight)", desc = "Put and indent right" }, + { "(YankyPutIndentAfterShiftLeft)", desc = "Put and indent left" }, + { ">P", "(YankyPutIndentBeforeShiftRight)", desc = "Put before and indent right" }, + { "(YankyPutIndentBeforeShiftLeft)", desc = "Put before and indent left" }, + { "=p", "(YankyPutAfterFilter)", desc = "Put after applying a filter" }, + { "=P", "(YankyPutBeforeFilter)", desc = "Put before applying a filter" }, + }, + }, + + -- Enhanced matchparen.vim plugin for Neovim to highlight the outer pair. + { + "utilyre/sentiment.nvim", + version = "*", + event = "VeryLazy", -- keep for lazy loading + opts = { + -- config + }, + init = function() + -- `matchparen.vim` needs to be disabled manually in case of lazy loading + vim.g.loaded_matchparen = 1 + end, + }, + + -- joining blocks of code into oneline, or splitting one line into multiple lines. + { + "Wansmer/treesj", + keys = { "m", "j", "s" }, + dependencies = { "nvim-treesitter/nvim-treesitter" }, + config = function() + require("treesj").setup({ --[[ your config ]] + }) + end, + }, + + -- File explorer(Custom configs) + { + "nvim-neo-tree/neo-tree.nvim", + opts = { + filesystem = { + filtered_items = { + visible = true, -- visible by default + hide_dotfiles = false, + hide_gitignored = false, + }, + }, + }, + }, + -- The plugin offers the alibity to refactor code. + { + "ThePrimeagen/refactoring.nvim", + dependencies = { + { "nvim-lua/plenary.nvim" }, + { "nvim-treesitter/nvim-treesitter" }, + }, + }, + -- The plugin offers the abilibty to search and replace. + { + "nvim-pack/nvim-spectre", + dependencies = { + { "nvim-lua/plenary.nvim" }, + }, + }, + + -- full signature help, docs and completion for the nvim lua API. + { "folke/neodev.nvim", opts = {} }, + + { "RRethy/vim-illuminate", config = function() end }, + + -- Language Parser for syntax highlighting / indentation / folding / Incremental selection + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + local utils = require("astronvim.utils") + opts.incremental_selection = { + enable = true, + keymaps = { + init_selection = "", -- Ctrl + Space + node_incremental = "", + scope_incremental = "", -- Alt + Space + node_decremental = "", -- Backspace + }, + } + opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { + -- neovim + "vim", + "lua", + -- operation & cloud native + "dockerfile", + "hcl", + "jsonnet", + "regex", + "terraform", + "nix", + }) + end, + }, + + -- implementation/definition preview + { + "rmagatti/goto-preview", + config = function() + require("goto-preview").setup({}) + end, + }, + + -- Undo tree + { "debugloop/telescope-undo.nvim" }, + + -- Install lsp, formmatter and others via home manager instead of Mason.nvim + -- LSP installations + { + "williamboman/mason-lspconfig.nvim", + -- overwrite ensure_installed to install lsp via home manager(except emmet_ls) + opts = function(_, opts) + opts.ensure_installed = { + "emmet_ls", -- not exist in nixpkgs, so install it via mason + } + end, + }, + -- Formatters/Linter installation + { + "jay-babu/mason-null-ls.nvim", + -- ensure_installed nothing + opts = function(_, opts) + opts.ensure_installed = nil + opts.automatic_installation = false + end, + }, + { + "jose-elias-alvarez/null-ls.nvim", + opts = function(_, opts) + local null_ls = require("null-ls") + local code_actions = null_ls.builtins.code_actions + local diagnostics = null_ls.builtins.diagnostics + local formatting = null_ls.builtins.formatting + local hover = null_ls.builtins.hover + local completion = null_ls.builtins.completion + -- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md + if type(opts.sources) == "table" then + vim.list_extend(opts.sources, { + -- Common Code Actions + code_actions.gitsigns, + -- common refactoring actions based off the Refactoring book by Martin Fowler + code_actions.refactoring, + code_actions.gomodifytags, -- Go - modify struct field tags + code_actions.impl, -- Go - generate interface method stubs + code_actions.shellcheck, + code_actions.proselint, -- English prose linter + code_actions.statix, -- Lints and suggestions for Nix. + + -- Diagnostic + diagnostics.actionlint, -- GitHub Actions workflow syntax checking + diagnostics.buf, -- check text in current buffer + diagnostics.checkmake, -- check Makefiles + diagnostics.deadnix, -- Scan Nix files for dead code. + + -- Formatting + formatting.prettier, -- js/ts/vue/css/html/json/... formatter + diagnostics.hadolint, -- Dockerfile linter + formatting.black, -- Python formatter + formatting.ruff, -- extremely fast Python linter + formatting.goimports, -- Go formatter + formatting.shfmt, -- Shell formatter + formatting.rustfmt, -- Rust formatter + formatting.taplo, -- TOML formatteautoindentr + formatting.terraform_fmt, -- Terraform formatter + formatting.stylua, -- Lua formatter + formatting.alejandra, -- Nix formatter + formatting.sqlfluff.with({ -- SQL formatter + extra_args = { "--dialect", "postgres" }, -- change to your dialect + }), + formatting.nginx_beautifier, -- Nginx formatter + null_ls.builtins.formatting.verible_verilog_format, -- Verilog formatter + }) + end + end, + }, + -- Debugger installation + { + "jay-babu/mason-nvim-dap.nvim", + -- overrides `require("mason-nvim-dap").setup(...)` + opts = function(_, opts) + opts.ensure_installed = nil + opts.automatic_installation = false + end, + }, + + { + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + dependencies = { "nvim-lua/plenary.nvim" }, + init = function() + -- 1. Disable highlighting for certain filetypes + -- 2. Ignore files larger than a certain filesize + local previewers = require("telescope.previewers") + + local _bad = { ".*%.csv", ".*%.min.js" } -- Put all filetypes that slow you down in this array + local filesize_threshold = 300 * 1024 -- 300KB + local bad_files = function(filepath) + for _, v in ipairs(_bad) do + if filepath:match(v) then + return false + end + end + return true + end + + local new_maker = function(filepath, bufnr, opts) + opts = opts or {} + if opts.use_ft_detect == nil then + opts.use_ft_detect = true + end + + -- 1. Check if the file is in the bad_files array, and if so, don't highlight it + opts.use_ft_detect = opts.use_ft_detect == false and false or bad_files(filepath) + + -- 2. Check the file size, and ignore it if it's too big(preview nothing). + filepath = vim.fn.expand(filepath) + vim.loop.fs_stat(filepath, function(_, stat) + if not stat then + return + end + if stat.size > filesize_threshold then + return + else + previewers.buffer_previewer_maker(filepath, bufnr, opts) + end + end) + end + + require("telescope").setup({ + defaults = { + buffer_previewer_maker = new_maker, + }, + }) + end, + }, + }, + + -- Configure require("lazy").setup() options + lazy = { + defaults = { lazy = true }, + performance = { + rtp = { + -- customize default disabled vim plugins + disabled_plugins = {}, + }, + }, + }, + + -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md + lsp = { + config = { + -- the offset_enconding of clangd will confilicts whit null-ls + -- so we need to manually set it to utf-8 + clangd = { + capabilities = { + offsetEncoding = "utf-8", + }, + }, + }, + -- enable servers that installed by home-manager instead of mason + servers = { + ---- Frontend & NodeJS + "tsserver", -- typescript/javascript language server + "tailwindcss", -- tailwindcss language server + "html", -- html language server + "cssls", -- css language server + "prismals", -- prisma language server + "volar", -- vue language server + ---- Configuration Language + "marksman", -- markdown ls + "jsonls", -- json language server + "yamlls", -- yaml language server + "taplo", -- toml language server + ---- Backend + "lua_ls", -- lua + "gopls", -- go + "rust_analyzer", -- rust + "pyright", -- python + "ruff_lsp", -- extremely fast Python linter and code transformation + "jdtls", -- java + "nil_ls", -- nix language server + "bufls", -- protocol buffer language server + "zls", -- zig language server + ---- HDL + "verible", -- verilog language server + ---- Operation & Cloud Nativautoindente + "bashls", -- bash + "cmake", -- cmake language server + "clangd", -- c/c++ + "dockerls", -- dockerfile + "jsonnet_ls", -- jsonnet language server + "terraformls", -- terraform hcl + }, + formatting = { + disabled = {}, + format_on_save = { + enabled = true, + allow_filetypes = { + "go", + "jsonnet", + "rust", + "terraform", + }, + }, + }, + }, + } diff --git a/modules/home/neovim/user/mappings.lua b/modules/home/neovim/user/mappings.lua new file mode 100644 index 0000000..e84ff00 --- /dev/null +++ b/modules/home/neovim/user/mappings.lua @@ -0,0 +1,68 @@ +-- Mapping data with "desc" stored directly by vim.keymap.set(). +-- +-- Please use this mappings table to set keyboard mapping since this is the +-- lower level configuration and more robust one. (which-key will +-- automatically pick-up stored data by this setting.) +local utils = require "astronvim.utils" + +require("telescope").load_extension("refactoring") +require("telescope").load_extension("yank_history") +require("telescope").load_extension("undo") + +return { + -- normal mode + n = { + -- second key is the lefthand side of the map + -- mappings seen under group name "Buffer" + ["bn"] = { "tabnew", desc = "New tab" }, + -- quick save + [""] = { ":w!", desc = "Save File" }, -- change description but the same command + + -- Terminal + -- NOTE: https://neovim.io/doc/user/builtin.html#jobstart() + -- 1. If {cmd} is a List it runs directly (no 'shell') + -- 2. If {cmd} is a String it runs in the 'shell' + ["tp"] = { function() utils.toggle_term_cmd({ cmd = "ipython" }) end, desc = "ToggleTerm python" }, + + -- search and replace globally + ['ss'] = {'lua require("spectre").toggle()', desc = "Toggle Spectre" }, + ['sw'] = {'lua require("spectre").open_visual({select_word=true})', desc = "Search current word" }, + ['sp'] ={'lua require("spectre").open_file_search({select_word=true})', desc = "Search on current file" }, + + -- refactoring + ["ri"] = { function() require('refactoring').refactor('Inline Variable') end, desc = "Inverse of extract variable" }, + ["rb"] = { function() require('refactoring').refactor('Extract Block') end, desc = "Extract Block" }, + ["rbf"] = { function() require('refactoring').refactor('Extract Block To File') end, desc = "Extract Block To File" }, + ["rr"] = { function() require('telescope').extensions.refactoring.refactors() end, desc = "Prompt for a refactor to apply" }, + ["rp"] = { function() require('refactoring').debug.printf({below = false}) end, desc = "Insert print statement to mark the calling of a function" }, + ["rv"] = { function() require('refactoring').debug.print_var() end, desc = "Insert print statement to print a variable" }, + ["rc"] = { function() require('refactoring').debug.cleanup({}) end, desc = "Cleanup of all generated print statements" }, + + -- yank_history + ["yh"] = { function() require("telescope").extensions.yank_history.yank_history() end, desc = "Preview Yank History" }, + + -- undo history + ["uh"] = {"Telescope undo", desc="Telescope undo" }, + + -- implementation/definition preview + ["gpd"] = { "lua require('goto-preview').goto_preview_definition()", desc="goto_preview_definition" }, + ["gpt"] = { "lua require('goto-preview').goto_preview_type_definition()", desc="goto_preview_type_definition" }, + ["gpi"] = { "lua require('goto-preview').goto_preview_implementation()", desc="goto_preview_implementation" }, + ["gP" ] = { "lua require('goto-preview').close_all_win()", desc="close_all_win" }, + ["gpr"] = { "lua require('goto-preview').goto_preview_references()", desc="goto_preview_references" }, + }, + -- Visual mode + v = { + -- search and replace globally + ['sw'] = {'lua require("spectre").open_visual()', desc = "Search current word" }, + }, + -- visual mode(what's the difference between v and x???) + x = { + -- refactoring + ["ri"] = { function() require('refactoring').refactor('Inline Variable') end, desc = "Inverse of extract variable" }, + ["re"] = { function() require('refactoring').refactor('Extract Function') end, desc = "Extracts the selected code to a separate function" }, + ["rf"] = { function() require('refactoring').refactor('Extract Function To File') end, desc = "Extract Function To File" }, + ["rv"] = { function() require('refactoring').refactor('Extract Variable') end, desc = "Extracts occurrences of a selected expression to its own variable" }, + ["rr"] = { function() require('telescope').extensions.refactoring.refactors() end, desc = "Prompt for a refactor to apply" }, + }, +} \ No newline at end of file diff --git a/modules/home/nixpkgs/default.nix b/modules/home/nixpkgs/default.nix new file mode 100644 index 0000000..b9bc5cd --- /dev/null +++ b/modules/home/nixpkgs/default.nix @@ -0,0 +1,33 @@ +{outputs, ...}: { + config = { + nixpkgs = { + # You can add overlays here + overlays = [ + # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.unstable-packages + + # You can also add overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + + # Configure your nixpkgs instance + config = { + # Wallahi, forgive me RMS... + allowUnfree = true; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = _: true; + # Let the system use fucked up programs + allowBroken = true; + }; + }; + }; +} diff --git a/modules/home/packages/default.nix b/modules/home/packages/default.nix new file mode 100644 index 0000000..4f8c62d --- /dev/null +++ b/modules/home/packages/default.nix @@ -0,0 +1,67 @@ +{ + config, + pkgs, + lib, + ... +}: let + linux = with pkgs; [ + # Add new packages here + docker-compose + pinentry + ]; + + globals = with pkgs; [ + # Downloader + aria + + # Developer Mode + gh + jq + wget + zola + gitui + zellij + netcat + direnv + git-lfs + gitoxide + cargo-update + + # Environment + fd + bat + btop + eza + figlet + gping + hyperfine + lolcat + fastfetch + onefetch + procs + ripgrep + tealdeer + topgrade + + # Tech + rustup + + # Media encode & decode + ffmpeg + libheif + + # Anime + crunchy-cli + + # GPG Signing + gnupg + + # Selfmade programs + fp + ]; +in { + config = { + # Packages to be installed on my machine + home.packages = globals ++ linux; + }; +} diff --git a/modules/home/topgrade/default.nix b/modules/home/topgrade/default.nix new file mode 100644 index 0000000..9117f10 --- /dev/null +++ b/modules/home/topgrade/default.nix @@ -0,0 +1,30 @@ +{pkgs, ...}: { + config = { + programs.topgrade = { + enable = true; + settings = { + misc = { + disable = [ + "bun" + "node" + "pnpm" + "yarn" + "cargo" + "vscode" + ]; + no_retry = true; + assume_yes = true; + no_self_update = true; + }; + commands = {}; + linux = { + nix_arguments = "--flake github:orzklv/nix"; + home_manager_arguments = ["--flake" "github:orzklv/nix"]; + }; + brew = { + autoremove = true; + }; + }; + }; + }; +} diff --git a/modules/home/zsh/default.nix b/modules/home/zsh/default.nix new file mode 100644 index 0000000..8296de3 --- /dev/null +++ b/modules/home/zsh/default.nix @@ -0,0 +1,205 @@ +{pkgs, ...}: { + imports = [ + ./zoxide.nix + ./starship.nix + ]; + + # I use zsh, but bash and fish work just as well here. This will setup + # the shell to use home-manager properly on startup, neat! + programs.zsh = { + # Install zsh + enable = true; + + # ZSH Autosuggestions + # The option `programs.zsh.enableAutosuggestions' defined in config + # has been renamed to `programs.zsh.autosuggestion.enable'. + autosuggestion.enable = true; + + # ZSH Completions + enableCompletion = true; + + # ZSH Syntax Highlighting + syntaxHighlighting.enable = true; + + shellAliases = { + # General aliases + down = "cd ~/Downloads"; + ".." = "cd .."; + "...." = "cd ../.."; + "celar" = "clear"; + ":q" = "exit"; + neofetch = "neofetch --source ~/.config/neofetch/logo.ascii"; + ssh-hosts = "grep -P \"^Host ([^*]+)$\" $HOME/.ssh/config | sed 's/Host //'"; + + # Polite motherfucker! + # Do you speak it?! + please = "sudo"; + move = "mv"; + copy = "cp"; + remove = "rm"; + list = "ls"; + edit = "hx"; + + # Made with Rust + top = "btop"; + cat = "bat"; + ls = "eza"; + sl = "eza"; + ps = "procs"; + grep = "rg"; + search = "rg"; + look = "fd"; + find = "fd"; + ping = "gping"; + time = "hyperfine"; + korgi = "cargo"; + + # Refresh + refresh = "source ~/.zshrc"; + clean = "nix store gc && nix-collect-garbage -d"; + + # Zellij + hack = "zellij"; + + # Others (Developer) + ports = "sudo lsof -PiTCP -sTCP:LISTEN"; + rit = "gitui"; + dotenv = "eval export $(cat .env)"; + xclip = "xclip -selection c"; + speedtest = "curl -o /dev/null cachefly.cachefly.net/100mb.test"; + dockfm = "docker ps --all --format \"NAME: {{.Names}}\nSTATUS: {{.Status}}\nPORTS: {{.Ports}}\n\""; + + # Updating system + update = "nix store gc && topgrade"; + + nix-shell = "nix-shell --run zsh"; + nix-develop = "nix develop -c \"$SHELL\""; + }; + + # Extra manually typed configs + initExtra = '' + # Global settings + setopt AUTO_CD + setopt BEEP + setopt HIST_BEEP + setopt HIST_EXPIRE_DUPS_FIRST + setopt HIST_FIND_NO_DUPS + setopt HIST_IGNORE_ALL_DUPS + setopt HIST_IGNORE_DUPS + setopt HIST_REDUCE_BLANKS + setopt HIST_SAVE_NO_DUPS + setopt HIST_VERIFY + setopt INC_APPEND_HISTORY + setopt INTERACTIVE_COMMENTS + setopt MAGIC_EQUAL_SUBST + setopt NO_NO_MATCH + setopt NOTIFY + setopt NUMERIC_GLOB_SORT + setopt PROMPT_SUBST + setopt SHARE_HISTORY + + # Key bindings + bindkey -e + bindkey '^U' backward-kill-line + bindkey '^[[2~' overwrite-mode + bindkey '^[[3~' delete-char + bindkey '^[[H' beginning-of-line + bindkey '^[[1~' beginning-of-line + bindkey '^[[F' end-of-line + bindkey '^[[4~' end-of-line + bindkey '^[[1;5C' forward-word + bindkey '^[[1;5D' backward-word + bindkey '^[[3;5~' kill-word + bindkey '^[[5~' beginning-of-buffer-or-history + bindkey '^[[6~' end-of-buffer-or-history + bindkey '^[[Z' undo + bindkey ' ' magic-space + + # History files + HISTFILE=~/.zsh_history + HIST_STAMPS=mm/dd/yyyy + HISTSIZE=5000 + SAVEHIST=5000 + ZLE_RPROMPT_INDENT=0 + WORDCHARS=''${WORDCHARS//\/} + PROMPT_EOL_MARK= + TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S\ncpu\t%P' + + # Zsh Autosuggestions Configs + ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=gray" + + # Zsh Completions Configs + zstyle ':completion:*:*:*:*:*' menu select + zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' + zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}" + zstyle ':completion:*' auto-description 'specify: %d' + zstyle ':completion:*' completer _expand _complete + zstyle ':completion:*' format 'Completing %d' + zstyle ':completion:*' group-name ' ' + zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s + zstyle ':completion:*' rehash true + zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s + zstyle ':completion:*' use-compctl false + zstyle ':completion:*' verbose true + zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' + typeset -gA ZSH_HIGHLIGHT_STYLES + ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern) + ZSH_HIGHLIGHT_STYLES[default]=none + ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=white,underline + ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=cyan,bold + ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=green,underline + ZSH_HIGHLIGHT_STYLES[global-alias]=fg=green,bold + ZSH_HIGHLIGHT_STYLES[precommand]=fg=green,underline + ZSH_HIGHLIGHT_STYLES[commandseparator]=fg=blue,bold + ZSH_HIGHLIGHT_STYLES[autodirectory]=fg=green,underline + ZSH_HIGHLIGHT_STYLES[path]=bold + ZSH_HIGHLIGHT_STYLES[path_pathseparator]= + ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]= + ZSH_HIGHLIGHT_STYLES[globbing]=fg=blue,bold + ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=blue,bold + ZSH_HIGHLIGHT_STYLES[command-substitution]=none + ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]=fg=magenta,bold + ZSH_HIGHLIGHT_STYLES[process-substitution]=none + ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]=fg=magenta,bold + ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=green + ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=green + ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none + ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]=fg=blue,bold + ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=yellow + ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=yellow + ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=yellow + ZSH_HIGHLIGHT_STYLES[rc-quote]=fg=magenta + ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=magenta,bold + ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=magenta,bold + ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=fg=magenta,bold + ZSH_HIGHLIGHT_STYLES[assign]=none + ZSH_HIGHLIGHT_STYLES[redirection]=fg=blue,bold + ZSH_HIGHLIGHT_STYLES[comment]=fg=black,bold + ZSH_HIGHLIGHT_STYLES[named-fd]=none + ZSH_HIGHLIGHT_STYLES[numeric-fd]=none + ZSH_HIGHLIGHT_STYLES[arg0]=fg=cyan + ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold + ZSH_HIGHLIGHT_STYLES[bracket-level-1]=fg=blue,bold + ZSH_HIGHLIGHT_STYLES[bracket-level-2]=fg=green,bold + ZSH_HIGHLIGHT_STYLES[bracket-level-3]=fg=magenta,bold + ZSH_HIGHLIGHT_STYLES[bracket-level-4]=fg=yellow,bold + ZSH_HIGHLIGHT_STYLES[bracket-level-5]=fg=cyan,bold + ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]=standout + + # Extra Aliases + if [[ "$(uname)" == "Linux" && -f /etc/nixos/configuration.nix ]]; then + alias open="xdg-open" + fi + + # Cargo + export PATH="$HOME/.cargo/bin:$PATH" + + # Golang's Trash + export GOPATH="$HOME/.go" + export PATH="$PATH:$HOME/.go/bin" + + # Extra services + # here... + ''; + }; +} diff --git a/modules/home/zsh/starship.nix b/modules/home/zsh/starship.nix new file mode 100644 index 0000000..a025c62 --- /dev/null +++ b/modules/home/zsh/starship.nix @@ -0,0 +1,10 @@ +{pkgs, ...}: { + # Prettier terminal prompt + programs.starship = { + enable = true; + enableZshIntegration = true; + settings = { + battery.disabled = true; + }; + }; +} diff --git a/modules/home/zsh/zoxide.nix b/modules/home/zsh/zoxide.nix new file mode 100644 index 0000000..7191075 --- /dev/null +++ b/modules/home/zsh/zoxide.nix @@ -0,0 +1,7 @@ +{pkgs, ...}: { + # Zpxide path integration + programs.zoxide = { + enable = true; + enableZshIntegration = true; + }; +} diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 309dd28..cac4a12 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -2,8 +2,10 @@ # These should be stuff you would like to share with others, not your personal configurations. { # List your module files here + ssh = import ./ssh.nix; zsh = import ./zsh.nix; boot = import ./boot.nix; data = import ./data.nix; network = import ./network.nix; + nixpkgs = import ./nixpkgs.nix; } diff --git a/modules/nixos/nixpkgs.nix b/modules/nixos/nixpkgs.nix new file mode 100644 index 0000000..d1df8ea --- /dev/null +++ b/modules/nixos/nixpkgs.nix @@ -0,0 +1,53 @@ +{ + pkgs, + outputs, + lib, + config, + inputs, + ... +}: { + config = { + nixpkgs = { + # You can add overlays here + overlays = [ + # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.unstable-packages + + # You can also add overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + allowUnsupportedSystem = true; + }; + }; + + nix = { + # This will add each flake input as a registry + # To make nix3 commands consistent with your flake + registry = lib.mapAttrs (_: value: {flake = value;}) inputs; + + # This will additionally add your inputs to the system's legacy channels + # Making legacy nix commands consistent as well, awesome! + nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; + + settings = { + # Enable flakes and new 'nix' command + experimental-features = "nix-command flakes"; + # Deduplicate and optimize nix store + auto-optimise-store = true; + }; + }; + }; +} diff --git a/modules/nixos/ssh.nix b/modules/nixos/ssh.nix new file mode 100644 index 0000000..bb802b8 --- /dev/null +++ b/modules/nixos/ssh.nix @@ -0,0 +1,16 @@ +{...}: { + config = { + # This setups a SSH server. Very important if you're setting up a headless system. + # Feel free to remove if you don't need it. + services.openssh = { + enable = true; + settings = { + # Forbid root login through SSH. + PermitRootLogin = "no"; + # Use keys only. Remove if you want to SSH using password (not recommended) + PasswordAuthentication = false; + }; + ports = [2222]; + }; + }; +} diff --git a/modules/nixos/users/default.nix b/modules/nixos/users/default.nix new file mode 100644 index 0000000..653010e --- /dev/null +++ b/modules/nixos/users/default.nix @@ -0,0 +1,5 @@ +# Keep all specific user configs here as a module +{ + # List your users here + sakhib = import ./sakhib.nix; +} diff --git a/modules/nixos/users/sakhib.nix b/modules/nixos/users/sakhib.nix new file mode 100644 index 0000000..4ba36d4 --- /dev/null +++ b/modules/nixos/users/sakhib.nix @@ -0,0 +1,33 @@ +{ + pkgs, + inputs, + outputs, + lib, + config, + packages, + ... +}: { + config = { + users.users = { + sakhib = { + isNormalUser = true; + description = "Sokhibjon Orzikulov"; + initialPassword = "F1st1ng15300Buck$!?"; + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDAGqU+JleLM0T44P2quirtLPrhFExOi6EOe0GYXkTFcTSjhw9LqiuX1/FbqNdKTaP9k6CdV3xc/8Z5wxbNOhpcPi9XLoupv9oNyIew7QYl+ZoAck6/qPsM7uptGYCwo0/ErzPNLd3ERD3KT1axCqrI6rWJ+JFOMAPtGeAZZxIedksViZ5SuNhpzXCIzS2PACqDTxFj7JwXK/pQ200h9ZS0MSh7iLKggXQfRVDndJxRnVY69NmbRa4MqkjgyxqWSDbqrDAXuTHpqKJ5kpXJ6p2a82EIHcCwXXpEmLwKxatxWJWJb9nurm3aS74BYmT3pRVVSPC6n5a2LWN9GxzvVh3AXXZtWGvjXSqBxHdSyUoDPuZnDneycdRC5vs6I1jSGTyDFdc4Etq1M5uUYb6SqCjJIBvTNqVnOf8nzFwl/ENvc8sbIVtILgAbBdwDiiQSu8xppqWMZfkQJy+uI5Ok7TZ8o5rGIblzfKyTiljCQb7RO7Klg3TwysetREn8ZEykBx0= This world soon will cherish into my darkness of my madness" + ]; + extraGroups = ["networkmanager" "wheel" "docker" "admins"]; + # packages = + # (with pkgs; []) ++ (with pkgs.unstable; []); + }; + }; + + home-manager = { + extraSpecialArgs = {inherit inputs outputs;}; + users = { + # Import your home-manager configuration + sakhib = import ../../../home/sakhib.nix; + }; + }; + }; +} diff --git a/nixos/kolyma-1/configuration.nix b/nixos/kolyma-1/configuration.nix index b7b42a0..bb68ae8 100644 --- a/nixos/kolyma-1/configuration.nix +++ b/nixos/kolyma-1/configuration.nix @@ -8,12 +8,14 @@ }: { imports = [ # If you want to use modules your own flake exports (from modules/nixos): + outputs.nixosModules.ssh outputs.nixosModules.zsh outputs.nixosModules.boot outputs.nixosModules.data + outputs.nixosModules.nixpkgs # User configs - inputs.cfg-sakhib.nixosModules.users.sakhib + outputs.nixosModules.users.sakhib # Import your deployed service list ./services.nix @@ -25,67 +27,12 @@ inputs.home-manager.nixosModules.home-manager ]; - nixpkgs = { - # You can add overlays here - overlays = [ - # Add overlays your own flake exports (from overlays and pkgs dir): - outputs.overlays.additions - outputs.overlays.modifications - outputs.overlays.unstable-packages - - # You can also add overlays exported from other flakes: - # neovim-nightly-overlay.overlays.default - - # Or define it inline, for example: - # (final: prev: { - # hi = final.hello.overrideAttrs (oldAttrs: { - # patches = [ ./change-hello-to-hi.patch ]; - # }); - # }) - ]; - # Configure your nixpkgs instance - config = { - # Disable if you don't want unfree packages - allowUnfree = true; - }; - }; - - nix = { - # This will add each flake input as a registry - # To make nix3 commands consistent with your flake - registry = lib.mapAttrs (_: value: {flake = value;}) inputs; - - # This will additionally add your inputs to the system's legacy channels - # Making legacy nix commands consistent as well, awesome! - nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; - - settings = { - # Enable flakes and new 'nix' command - experimental-features = "nix-command flakes"; - # Deduplicate and optimize nix store - auto-optimise-store = true; - }; - }; - # Hostname of the system networking.hostName = "Kolyma-1"; # Don't ask for password security.sudo.wheelNeedsPassword = false; - # This setups a SSH server. Very important if you're setting up a headless system. - # Feel free to remove if you don't need it. - services.openssh = { - enable = true; - settings = { - # Forbid root login through SSH. - PermitRootLogin = "no"; - # Use keys only. Remove if you want to SSH using password (not recommended) - PasswordAuthentication = false; - }; - ports = [2222]; - }; - # To be able to SSH into the system on emergency users.users.root.openssh.authorizedKeys.keys = [''ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDAGqU+JleLM0T44P2quirtLPrhFExOi6EOe0GYXkTFcTSjhw9LqiuX1/FbqNdKTaP9k6CdV3xc/8Z5wxbNOhpcPi9XLoupv9oNyIew7QYl+ZoAck6/qPsM7uptGYCwo0/ErzPNLd3ERD3KT1axCqrI6rWJ+JFOMAPtGeAZZxIedksViZ5SuNhpzXCIzS2PACqDTxFj7JwXK/pQ200h9ZS0MSh7iLKggXQfRVDndJxRnVY69NmbRa4MqkjgyxqWSDbqrDAXuTHpqKJ5kpXJ6p2a82EIHcCwXXpEmLwKxatxWJWJb9nurm3aS74BYmT3pRVVSPC6n5a2LWN9GxzvVh3AXXZtWGvjXSqBxHdSyUoDPuZnDneycdRC5vs6I1jSGTyDFdc4Etq1M5uUYb6SqCjJIBvTNqVnOf8nzFwl/ENvc8sbIVtILgAbBdwDiiQSu8xppqWMZfkQJy+uI5Ok7TZ8o5rGIblzfKyTiljCQb7RO7Klg3TwysetREn8ZEykBx0= This world soon will cherish into my darkness of my madness'']; diff --git a/nixos/kolyma-2/configuration.nix b/nixos/kolyma-2/configuration.nix index 5910307..28ba680 100644 --- a/nixos/kolyma-2/configuration.nix +++ b/nixos/kolyma-2/configuration.nix @@ -8,12 +8,14 @@ }: { imports = [ # If you want to use modules your own flake exports (from modules/nixos): + outputs.nixosModules.ssh outputs.nixosModules.zsh outputs.nixosModules.boot outputs.nixosModules.data + outputs.nixosModules.nixpkgs # User configs - inputs.cfg-sakhib.nixosModules.users.sakhib + outputs.nixosModules.users.sakhib # Import your deployed service list ./services.nix @@ -25,67 +27,12 @@ inputs.home-manager.nixosModules.home-manager ]; - nixpkgs = { - # You can add overlays here - overlays = [ - # Add overlays your own flake exports (from overlays and pkgs dir): - outputs.overlays.additions - outputs.overlays.modifications - outputs.overlays.unstable-packages - - # You can also add overlays exported from other flakes: - # neovim-nightly-overlay.overlays.default - - # Or define it inline, for example: - # (final: prev: { - # hi = final.hello.overrideAttrs (oldAttrs: { - # patches = [ ./change-hello-to-hi.patch ]; - # }); - # }) - ]; - # Configure your nixpkgs instance - config = { - # Disable if you don't want unfree packages - allowUnfree = true; - }; - }; - - nix = { - # This will add each flake input as a registry - # To make nix3 commands consistent with your flake - registry = lib.mapAttrs (_: value: {flake = value;}) inputs; - - # This will additionally add your inputs to the system's legacy channels - # Making legacy nix commands consistent as well, awesome! - nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; - - settings = { - # Enable flakes and new 'nix' command - experimental-features = "nix-command flakes"; - # Deduplicate and optimize nix store - auto-optimise-store = true; - }; - }; - # Hostname of the system networking.hostName = "Kolyma-2"; # Don't ask for password security.sudo.wheelNeedsPassword = false; - # This setups a SSH server. Very important if you're setting up a headless system. - # Feel free to remove if you don't need it. - services.openssh = { - enable = true; - settings = { - # Forbid root login through SSH. - PermitRootLogin = "no"; - # Use keys only. Remove if you want to SSH using password (not recommended) - PasswordAuthentication = false; - }; - ports = [2222]; - }; - # To be able to SSH into the system on emergency users.users.root.openssh.authorizedKeys.keys = [''ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDAGqU+JleLM0T44P2quirtLPrhFExOi6EOe0GYXkTFcTSjhw9LqiuX1/FbqNdKTaP9k6CdV3xc/8Z5wxbNOhpcPi9XLoupv9oNyIew7QYl+ZoAck6/qPsM7uptGYCwo0/ErzPNLd3ERD3KT1axCqrI6rWJ+JFOMAPtGeAZZxIedksViZ5SuNhpzXCIzS2PACqDTxFj7JwXK/pQ200h9ZS0MSh7iLKggXQfRVDndJxRnVY69NmbRa4MqkjgyxqWSDbqrDAXuTHpqKJ5kpXJ6p2a82EIHcCwXXpEmLwKxatxWJWJb9nurm3aS74BYmT3pRVVSPC6n5a2LWN9GxzvVh3AXXZtWGvjXSqBxHdSyUoDPuZnDneycdRC5vs6I1jSGTyDFdc4Etq1M5uUYb6SqCjJIBvTNqVnOf8nzFwl/ENvc8sbIVtILgAbBdwDiiQSu8xppqWMZfkQJy+uI5Ok7TZ8o5rGIblzfKyTiljCQb7RO7Klg3TwysetREn8ZEykBx0= This world soon will cherish into my darkness of my madness'']; diff --git a/nixos/kolyma-3/configuration.nix b/nixos/kolyma-3/configuration.nix index 324e23d..4d1ec51 100644 --- a/nixos/kolyma-3/configuration.nix +++ b/nixos/kolyma-3/configuration.nix @@ -8,15 +8,14 @@ }: { imports = [ # If you want to use modules your own flake exports (from modules/nixos): + outputs.nixosModules.ssh outputs.nixosModules.zsh outputs.nixosModules.boot outputs.nixosModules.data + outputs.nixosModules.nixpkgs # User configs - inputs.cfg-sakhib.nixosModules.users.sakhib - - # Third party modules - # inputs.muzaffar-cfg.nixosModules.users.muzaffar + outputs.nixosModules.users.sakhib # Import your deployed service list ./services.nix @@ -28,48 +27,6 @@ inputs.home-manager.nixosModules.home-manager ]; - nixpkgs = { - # You can add overlays here - overlays = [ - # Add overlays your own flake exports (from overlays and pkgs dir): - outputs.overlays.additions - outputs.overlays.modifications - outputs.overlays.unstable-packages - - # You can also add overlays exported from other flakes: - # neovim-nightly-overlay.overlays.default - - # Or define it inline, for example: - # (final: prev: { - # hi = final.hello.overrideAttrs (oldAttrs: { - # patches = [ ./change-hello-to-hi.patch ]; - # }); - # }) - ]; - # Configure your nixpkgs instance - config = { - # Disable if you don't want unfree packages - allowUnfree = true; - }; - }; - - nix = { - # This will add each flake input as a registry - # To make nix3 commands consistent with your flake - registry = lib.mapAttrs (_: value: {flake = value;}) inputs; - - # This will additionally add your inputs to the system's legacy channels - # Making legacy nix commands consistent as well, awesome! - nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; - - settings = { - # Enable flakes and new 'nix' command - experimental-features = "nix-command flakes"; - # Deduplicate and optimize nix store - auto-optimise-store = true; - }; - }; - # Hostname of the system networking.hostName = "Kolyma-3"; @@ -84,19 +41,6 @@ # Don't ask for password security.sudo.wheelNeedsPassword = false; - # This setups a SSH server. Very important if you're setting up a headless system. - # Feel free to remove if you don't need it. - services.openssh = { - enable = true; - settings = { - # Forbid root login through SSH. - PermitRootLogin = "no"; - # Use keys only. Remove if you want to SSH using password (not recommended) - PasswordAuthentication = false; - }; - ports = [2222]; - }; - # To be able to SSH into the system on emergency users.users.root.openssh.authorizedKeys.keys = [''ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDAGqU+JleLM0T44P2quirtLPrhFExOi6EOe0GYXkTFcTSjhw9LqiuX1/FbqNdKTaP9k6CdV3xc/8Z5wxbNOhpcPi9XLoupv9oNyIew7QYl+ZoAck6/qPsM7uptGYCwo0/ErzPNLd3ERD3KT1axCqrI6rWJ+JFOMAPtGeAZZxIedksViZ5SuNhpzXCIzS2PACqDTxFj7JwXK/pQ200h9ZS0MSh7iLKggXQfRVDndJxRnVY69NmbRa4MqkjgyxqWSDbqrDAXuTHpqKJ5kpXJ6p2a82EIHcCwXXpEmLwKxatxWJWJb9nurm3aS74BYmT3pRVVSPC6n5a2LWN9GxzvVh3AXXZtWGvjXSqBxHdSyUoDPuZnDneycdRC5vs6I1jSGTyDFdc4Etq1M5uUYb6SqCjJIBvTNqVnOf8nzFwl/ENvc8sbIVtILgAbBdwDiiQSu8xppqWMZfkQJy+uI5Ok7TZ8o5rGIblzfKyTiljCQb7RO7Klg3TwysetREn8ZEykBx0= This world soon will cherish into my darkness of my madness''];