From 4c8272025134b56e028fa5b8b3e3dbe402660d4d Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 7 Jul 2025 21:19:08 +0800 Subject: [PATCH] feat(homes/rafiq): port over configs --- flake.lock | 91 ++++++++++++++++ flake.nix | 29 ++++- nix/homes/rafiq/_nvf/autocomplete.nix | 25 +++++ nix/homes/rafiq/_nvf/binds.nix | 3 + nix/homes/rafiq/_nvf/languages.nix | 34 ++++++ nix/homes/rafiq/_nvf/lsp.nix | 17 +++ nix/homes/rafiq/_nvf/navigation.nix | 9 ++ nix/homes/rafiq/_nvf/snippets.nix | 28 +++++ nix/homes/rafiq/_nvf/statusline.nix | 10 ++ nix/homes/rafiq/_nvf/ui.nix | 16 +++ nix/homes/rafiq/_nvf/utility.nix | 11 ++ nix/homes/rafiq/_nvf/visuals.nix | 7 ++ nix/homes/rafiq/default.nix | 150 ++++++++++++++++++++++++++ nix/meta.nix | 11 +- nix/modules/cli/shell.nix | 1 + 15 files changed, 440 insertions(+), 2 deletions(-) create mode 100644 nix/homes/rafiq/_nvf/autocomplete.nix create mode 100644 nix/homes/rafiq/_nvf/binds.nix create mode 100644 nix/homes/rafiq/_nvf/languages.nix create mode 100644 nix/homes/rafiq/_nvf/lsp.nix create mode 100644 nix/homes/rafiq/_nvf/navigation.nix create mode 100644 nix/homes/rafiq/_nvf/snippets.nix create mode 100644 nix/homes/rafiq/_nvf/statusline.nix create mode 100644 nix/homes/rafiq/_nvf/ui.nix create mode 100644 nix/homes/rafiq/_nvf/utility.nix create mode 100644 nix/homes/rafiq/_nvf/visuals.nix create mode 100644 nix/homes/rafiq/default.nix diff --git a/flake.lock b/flake.lock index d5e0ec6..2436ed5 100644 --- a/flake.lock +++ b/flake.lock @@ -15,6 +15,26 @@ "type": "github" } }, + "dedupe_flake-utils": { + "inputs": { + "systems": [ + "systems" + ] + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "dedupe_gitignore": { "inputs": { "nixpkgs": [ @@ -35,6 +55,21 @@ "type": "github" } }, + "dedupe_mnw": { + "locked": { + "lastModified": 1748710831, + "narHash": "sha256-eZu2yH3Y2eA9DD3naKWy/sTxYS5rPK2hO7vj8tvUCSU=", + "owner": "gerg-l", + "repo": "mnw", + "rev": "cff958a4e050f8d917a6ff3a5624bc4681c6187d", + "type": "github" + }, + "original": { + "owner": "gerg-l", + "repo": "mnw", + "type": "github" + } + }, "disko": { "inputs": { "nixpkgs": [ @@ -186,6 +221,26 @@ "type": "github" } }, + "nix-index-database": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1751774635, + "narHash": "sha256-DuOznGdgMxeSlPpUu6Wkq0ZD5e2Cfv9XRZeZlHWMd1s=", + "owner": "nix-community", + "repo": "nix-index-database", + "rev": "85686025ba6d18df31cc651a91d5adef63378978", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-index-database", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1751637120, @@ -202,10 +257,44 @@ "type": "github" } }, + "nvf": { + "inputs": { + "flake-parts": [ + "flake-parts" + ], + "flake-utils": [ + "dedupe_flake-utils" + ], + "mnw": [ + "dedupe_mnw" + ], + "nixpkgs": [ + "nixpkgs" + ], + "systems": [ + "systems" + ] + }, + "locked": { + "lastModified": 1751887073, + "narHash": "sha256-M92RDGGx330MPqK2v7IRn98938Y2b1tkfe0ujD5GK70=", + "owner": "notashelf", + "repo": "nvf", + "rev": "d70c3a834061b9f24cfcc350ce2325c3bbede774", + "type": "github" + }, + "original": { + "owner": "notashelf", + "repo": "nvf", + "type": "github" + } + }, "root": { "inputs": { "dedupe_flake-compat": "dedupe_flake-compat", + "dedupe_flake-utils": "dedupe_flake-utils", "dedupe_gitignore": "dedupe_gitignore", + "dedupe_mnw": "dedupe_mnw", "disko": "disko", "files": "files", "flake-parts": "flake-parts", @@ -214,7 +303,9 @@ "impermanence": "impermanence", "import-tree": "import-tree", "make-shell": "make-shell", + "nix-index-database": "nix-index-database", "nixpkgs": "nixpkgs", + "nvf": "nvf", "sops-nix": "sops-nix", "systems": "systems", "text": "text" diff --git a/flake.nix b/flake.nix index b719d88..19d392c 100644 --- a/flake.nix +++ b/flake.nix @@ -21,6 +21,9 @@ }; # impermanence provides a nice abstraction over linking files from /persist impermanence.url = "github:nix-community/impermanence"; + + ### FLAKE PARTS MODULES ### + # sops-nix lets us version control secrets like passwords and api keys sops-nix = { url = "github:Mic92/sops-nix"; @@ -47,8 +50,32 @@ }; }; - # The following are not used but are here for deduplication. + ### PROGRAMS ### + # nix-index-database indexes the nixpkgs binaries for use with comma + nix-index-database = { + url = "github:nix-community/nix-index-database"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # nvf provides modules to wrap neovim + nvf = { + url = "github:notashelf/nvf"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-parts.follows = "flake-parts"; + systems.follows = "systems"; + flake-utils.follows = "dedupe_flake-utils"; + mnw.follows = "dedupe_mnw"; + }; + }; + + ### DEDUPE ### + # The following are not used in the flake dedupe_flake-compat.url = "github:edolstra/flake-compat"; + dedupe_flake-utils = { + url = "github:numtide/flake-utils"; + inputs.systems.follows = "systems"; + }; + dedupe_mnw.url = "github:gerg-l/mnw"; dedupe_gitignore = { url = "github:hercules-ci/gitignore.nix"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/nix/homes/rafiq/_nvf/autocomplete.nix b/nix/homes/rafiq/_nvf/autocomplete.nix new file mode 100644 index 0000000..ca12dea --- /dev/null +++ b/nix/homes/rafiq/_nvf/autocomplete.nix @@ -0,0 +1,25 @@ +{ lib }: +{ + blink-cmp = { + enable = true; + friendly-snippets.enable = true; + sourcePlugins.ripgrep.enable = true; + setupOpts = { + # Disable completion in markdown files + # TODO: Disable completion when in comments + enabled = + lib.generators.mkLuaInline + # lua + '' + function() + return not vim.tbl_contains({"markdown"}, vim.bo.filetype) + and vim.bo.buftype ~= "prompt" + and vim.b.completion ~= false + end + ''; + completion.documentation.auto_show_delay_ms = 0; + # Show e.g. function parameters + signature.enabled = true; + }; + }; +} diff --git a/nix/homes/rafiq/_nvf/binds.nix b/nix/homes/rafiq/_nvf/binds.nix new file mode 100644 index 0000000..2859d24 --- /dev/null +++ b/nix/homes/rafiq/_nvf/binds.nix @@ -0,0 +1,3 @@ +{ + whichKey.enable = true; +} diff --git a/nix/homes/rafiq/_nvf/languages.nix b/nix/homes/rafiq/_nvf/languages.nix new file mode 100644 index 0000000..cc3dd8c --- /dev/null +++ b/nix/homes/rafiq/_nvf/languages.nix @@ -0,0 +1,34 @@ +{ + enableExtraDiagnostics = true; + enableFormat = true; + enableTreesitter = true; + bash.enable = true; + clang.enable = true; + csharp.enable = true; + css.enable = true; + go.enable = true; + html.enable = true; + lua.enable = true; + markdown = { + enable = true; + extensions.markview-nvim.enable = true; + format.type = "prettierd"; + }; + nix = { + enable = true; + format.type = "nixfmt"; + lsp.server = "nil"; + }; + python = { + enable = true; + format.type = "ruff"; + lsp.server = "pyright"; + }; + rust.enable = true; + rust.crates.enable = true; + ts.enable = true; + ts.extensions.ts-error-translator.enable = true; + typst.enable = true; + typst.extensions.typst-preview-nvim.enable = true; + yaml.enable = true; +} diff --git a/nix/homes/rafiq/_nvf/lsp.nix b/nix/homes/rafiq/_nvf/lsp.nix new file mode 100644 index 0000000..98b8fe3 --- /dev/null +++ b/nix/homes/rafiq/_nvf/lsp.nix @@ -0,0 +1,17 @@ +{ + enable = true; + # Show virtual text hints + inlayHints.enable = true; + lightbulb.enable = true; + # Show icons for lsp actions + lspkind.enable = true; + null-ls.enable = true; + otter-nvim = { + enable = true; + setupOpts = { + buffers.set_filetype = true; + buffers.write_to_disk = true; + handle_leading_whitespace = true; + }; + }; +} diff --git a/nix/homes/rafiq/_nvf/navigation.nix b/nix/homes/rafiq/_nvf/navigation.nix new file mode 100644 index 0000000..65ab456 --- /dev/null +++ b/nix/homes/rafiq/_nvf/navigation.nix @@ -0,0 +1,9 @@ +{ + harpoon = { + enable = true; + mappings.listMarks = "ml"; + mappings.markFile = "mm"; + setupOpts.defaults.save_on_toggle = true; + setupOpts.defaults.sync_on_ui_close = true; + }; +} diff --git a/nix/homes/rafiq/_nvf/snippets.nix b/nix/homes/rafiq/_nvf/snippets.nix new file mode 100644 index 0000000..8c7c199 --- /dev/null +++ b/nix/homes/rafiq/_nvf/snippets.nix @@ -0,0 +1,28 @@ +{ pkgs }: +{ + luasnip = { + enable = true; + setupOpts.enable_autosnippets = true; + providers = with pkgs.vimPlugins; [ vim-snippets ]; + loaders = "require('luasnip.loaders.from_vscode').lazy_load()"; + customSnippets.snipmate = { + nix = [ + { + trigger = "mod"; + description = "empty module"; + body = # nix + '' + {config, lib, ...}: + let + cfg = config.$1; + in + { + options.$1 = { $2 }; + config = $3; + } + ''; + } + ]; + }; + }; +} diff --git a/nix/homes/rafiq/_nvf/statusline.nix b/nix/homes/rafiq/_nvf/statusline.nix new file mode 100644 index 0000000..b21b714 --- /dev/null +++ b/nix/homes/rafiq/_nvf/statusline.nix @@ -0,0 +1,10 @@ +{ + lualine = { + enable = true; + refresh = { + statusline = 10; + winbar = 10; + }; + #TODO: rice lualine + }; +} diff --git a/nix/homes/rafiq/_nvf/ui.nix b/nix/homes/rafiq/_nvf/ui.nix new file mode 100644 index 0000000..e0dc2d7 --- /dev/null +++ b/nix/homes/rafiq/_nvf/ui.nix @@ -0,0 +1,16 @@ +{ + borders = { + enable = true; + globalStyle = "rounded"; + }; + breadcrumbs.enable = true; + # Show color values e.g. #ffffff + colorizer.enable = true; + # Highlight matching symbols + illuminate.enable = true; + noice.enable = true; + noice.setupOpts.notify.enabled = false; + # Make folds look nicer + nvim-ufo.enable = true; + smartcolumn.enable = true; +} diff --git a/nix/homes/rafiq/_nvf/utility.nix b/nix/homes/rafiq/_nvf/utility.nix new file mode 100644 index 0000000..e69efcb --- /dev/null +++ b/nix/homes/rafiq/_nvf/utility.nix @@ -0,0 +1,11 @@ +{ + motion.hop.enable = true; + yazi-nvim = { + enable = true; + mappings = { + openYazi = "tt"; + openYaziDir = "TT"; + }; + setupOpts.open_for_directories = true; + }; +} diff --git a/nix/homes/rafiq/_nvf/visuals.nix b/nix/homes/rafiq/_nvf/visuals.nix new file mode 100644 index 0000000..f2993ee --- /dev/null +++ b/nix/homes/rafiq/_nvf/visuals.nix @@ -0,0 +1,7 @@ +{ + indent-blankline.enable = true; + fidget-nvim.enable = true; + fidget-nvim.setupOpts.notification.override_vim_notify = true; + nvim-web-devicons.enable = true; + rainbow-delimiters.enable = true; +} diff --git a/nix/homes/rafiq/default.nix b/nix/homes/rafiq/default.nix new file mode 100644 index 0000000..c46af80 --- /dev/null +++ b/nix/homes/rafiq/default.nix @@ -0,0 +1,150 @@ +{ lib, inputs, ... }: +let + inherit (lib.strings) concatStrings; +in +{ + flake.homes.rafiq = + { pkgs, ... }: + { + imports = [ + inputs.nvf.homeManagerModules.default + inputs.nix-index-database.hmModules.nix-index + ]; + persistDirs = [ + ".local/share/zoxide" + "notebook" + ]; + xdg.configFile."aichat/config.yaml".text = '' + model: gemini:gemini-2.0-flash + clients: + - type: gemini + ''; + home = { + sessionVariables = { + EDITOR = "nvim"; + FETCH = "hyfetch"; + FILE_BROWSER = "yazi"; + SHELL = "fish"; + }; + shellAliases = { + fetch = "hyfetch"; + windows = "sudo systemctl reboot --boot-loader-entry=auto-windows"; + v = "$EDITOR"; + e = "edit"; + cd = "z"; # zoxide + ai = "aichat -r %shell% -e"; + }; + packages = with pkgs; [ + fastfetch + ripgrep + aichat + (pkgs.writeShellScriptBin "note" # bash + '' + zk edit -i + pushd ~/notebook > /dev/null + git add . + commit -u + popd > /dev/null + '' + ) + ]; + }; + programs = { + nvf.enable = true; + nvf.settings.vim = { + syntaxHighlighting = true; + hideSearchHighlight = true; + searchCase = "ignore"; + undoFile.enable = true; + telescope.enable = true; + fzf-lua.enable = true; + git.enable = true; + autopairs.nvim-autopairs.enable = true; + autocomplete = import ./_nvf/autocomplete.nix { inherit lib; }; + binds = import ./_nvf/binds.nix; + languages = import ./_nvf/languages.nix; + lsp = import ./_nvf/lsp.nix; + navigation = import ./_nvf/navigation.nix; + notes.todo-comments.enable = true; + options = { + autoindent = true; + backspace = "indent,eol,start"; + cursorline = true; + expandtab = true; + shiftwidth = 2; + smartindent = true; + tabstop = 2; + }; + snippets = import ./_nvf/snippets.nix { inherit pkgs; }; + statusline = import ./_nvf/statusline.nix; + treesitter = { + autotagHtml = true; + fold = true; + indent.disable = [ "markdown" ]; + textobjects.enable = true; + }; + ui = import ./_nvf/ui.nix; + utility = import ./_nvf/utility.nix; + visuals = import ./_nvf/visuals.nix; + }; + zk = { + enable = true; + settings.notebook.dir = "~/notebook"; + }; + hyfetch = { + enable = true; + settings = { + preset = "bisexual"; + mode = "rgb"; + light_dark = "dark"; + lightness = 0.5; + color_align = { + # Flag color alignment + mode = "horizontal"; + fore_back = null; + }; + backend = "fastfetch"; + }; + }; + + tealdeer.enable = true; + tealdeer.enableAutoUpdates = true; + direnv = { + enable = true; + nix-direnv.enable = true; + }; + zoxide.enable = true; + nix-index.enable = true; + nix-index-database.comma.enable = true; + fzf.enable = true; + fzf.enableZshIntegration = true; + yazi = { + enable = true; + shellWrapperName = "t"; + settings.mgr.sort_by = "natural"; + }; + fish.enable = true; + starship = { + enable = true; + settings = { + add_newline = false; + format = concatStrings [ + # First Line + ## Left Prompt + "$hostname$directory" + "$fill" + ## Right Prompt + "$all" + # Second Line + ## Left Prompt + "$character" + ]; + git_branch.format = "[$symbol$branch(:$remote_branch)]($style) "; + shlvl.disabled = false; + username.disabled = true; + fill.symbol = " "; + }; + }; + }; + }; +} diff --git a/nix/meta.nix b/nix/meta.nix index ee694c3..36b3568 100644 --- a/nix/meta.nix +++ b/nix/meta.nix @@ -6,7 +6,12 @@ }: let inherit (lib.options) mkOption; - inherit (lib.types) path lazyAttrsOf raw; + inherit (lib.types) + path + lazyAttrsOf + raw + deferredModule + ; inherit (inputs.flake-parts.lib) mkSubmoduleOptions; inherit (cfg.lib.attrsets) firstAttrNameMatching; cfg = config.flake; @@ -29,6 +34,10 @@ in type = lazyAttrsOf raw; default = { }; }; + homes = mkOption { + type = lazyAttrsOf deferredModule; + default = { }; + }; }; config.flake = { paths.secrets = cfg.paths.root + "/secrets"; diff --git a/nix/modules/cli/shell.nix b/nix/modules/cli/shell.nix index 58ad6f3..c28f00b 100644 --- a/nix/modules/cli/shell.nix +++ b/nix/modules/cli/shell.nix @@ -18,5 +18,6 @@ in { config, ... }: { programs.${cfg.manifest.users.${config.home.username}.shell}.enable = true; + home.shell.enableShellIntegration = true; }; }