diff --git a/.github/actions/setup-nix/action.yml b/.github/actions/setup-nix/action.yml new file mode 100644 index 0000000..dfd6c22 --- /dev/null +++ b/.github/actions/setup-nix/action.yml @@ -0,0 +1,67 @@ +name: setup-nix + +inputs: + system: + type: string + required: true + sandbox: + type: string + default: "true" + +runs: + using: composite + steps: + - name: reclaim space (linux) + if: runner.os == 'Linux' + uses: wimpysworld/nothing-but-nix@main + with: + hatchet-protocol: rampage + + - name: reclaim space (darwin) + if: runner.os == 'macOS' + shell: bash + run: | + echo "::group::disk space (before)" + sudo df -h + echo "::endgroup::" + + echo "::group::disable mds" + sudo mdutil -i off -a || echo "mdutil failed" + sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist \ + || echo "launchctl unload failed" + echo "::endgroup::" + + echo "Background space expansion started. /nix will grow as space becomes available." + sudo rm -rf \ + /Applications/Xcode_* \ + /Library/Developer/CoreSimulator \ + /Library/Frameworks \ + /Users/runner/.dotnet \ + /Users/runner/.rustup \ + /Users/runner/Library/Android \ + /Users/runner/Library/Caches \ + /Users/runner/Library/Developer/CoreSimulator \ + /Users/runner/hostedtoolcache & + + - name: install nix + uses: cachix/install-nix-action@v31 + with: + # Putting build-dir in /nix is a workaround for https://github.com/wimpysworld/nothing-but-nix/issues/18 + extra_nix_config: | + build-dir = /nix/build + sandbox = ${{ inputs.sandbox }} + system = ${{ inputs.system }} + + - name: create build-dir + shell: bash + run: sudo mkdir -p /nix/build + + - name: post setup-nix + if: runner.os == 'macOS' + uses: srz-zumix/post-run-action@v2 + with: + shell: bash -e {0} + post-run: | + echo "::group::disk space (after)" + sudo df -h + echo "::endgroup::" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 471c361..c8e831c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,46 +4,113 @@ on: push: workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: - runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + system: + - x86_64-linux + - aarch64-linux + - x86_64-darwin + runs-on: ${{ matrix.system == 'x86_64-linux' && 'ubuntu-24.04' + || matrix.system == 'aarch64-linux' && 'ubuntu-24.04-arm' + || matrix.system == 'x86_64-darwin' && 'macos-latest' }} steps: - - name: Checkout the repository - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: Install nix - uses: cachix/install-nix-action@v16 + - name: setup nix + uses: ./.github/actions/setup-nix + with: + system: ${{ matrix.system }} + - name: Login to tailscale + uses: tailscale/github-action@v3.2.3 + with: + oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} + oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} + hostname: ${{ matrix.system == 'x86_64-linux' && 'github-actions-x86-64-linux' + || matrix.system == 'aarch64-linux' && 'github-actions-aarch64-linux' + || matrix.system == 'x86_64-darwin' && 'github-actions-x86-64-darwin' }} + tags: tag:ci - # TODO: add a binary cache - # - uses: cachix/cachix-action@v10 - # with: - # name: YOURCACHE - # authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + # - name: Install and start Tailscale + # run: | + # # Start tailscaled daemon in background using nix shell + # nix profile add nixpkgs#tailscale + # sudo tailscaled --state=mem: & + + # # Wait for daemon to be ready + # sleep 10 + + # # Connect using OAuth + # HOSTNAME="${{ matrix.system == 'x86_64-linux' && 'github-actions-x86-64-linux' + # || matrix.system == 'aarch64-linux' && 'github-actions-aarch64-linux' + # || matrix.system == 'x86_64-darwin' && 'github-actions-x86-64-darwin' }}" + + # tailscale up \ + # --authkey="${{ secrets.TS_OAUTH_SECRET }}?preauthorized=true&ephemeral=true" \ + # --hostname="$HOSTNAME" \ + # --advertise-tags="tag:ci" \ + # --accept-routes + - name: Tailscale status + run: tailscale status || true + + - name: Check if Attic endpoint is reachable + id: check_attic + run: | + if curl --connect-timeout 20 --silent --head http://wallfacer.curl-boga.ts.net:7080 | grep "200 OK"; then + echo "Attic endpoint is reachable" + echo "reachable=true" >> $GITHUB_OUTPUT + else + echo "Attic endpoint is not reachable" + echo "reachable=false" >> $GITHUB_OUTPUT + fi + + - name: Curl the cache + run: | + curl --connect-timeout 20 --silent http://wallfacer.curl-boga.ts.net:7080/main/nix-cache-info || echo "Cache endpoint not reachable" + + - name: Setup Attic cache + if: steps.check_attic.outputs.reachable == 'true' + uses: ryanccn/attic-action@v0.3.1 + with: + endpoint: http://wallfacer.curl-boga.ts.net:7080 + cache: main + token: ${{ secrets.ATTIC_TOKEN }} - name: Check the flake run: nix flake check --accept-flake-config - - name: Pre-build the system configuration - run: nix build --accept-flake-config . + - name: Build the Neovim Configuration + run: nix build --accept-flake-config . -j3 + timeout-minutes: 300 + continue-on-error: true - name: Print out the size of /nix/store run: du -sh /nix/store - name: Get the init.lua path + if: matrix.system == 'x86_64-linux' run: | init_path=$(grep "init=" result/bin/nixvim-print-init | awk -F'=' '{print $2}') cp $init_path init.lua - name: Upload the artifact uses: actions/upload-artifact@v4 + if: matrix.system == 'x86_64-linux' with: name: neovim-configuration path: init.lua - name: Publish the init.lua to an orphan github branch + if: matrix.system == 'x86_64-linux' run: | git config --global user.name github-actions git config --global user.email github-actions@github.com @@ -52,6 +119,7 @@ jobs: git add init.lua git commit -m "Publish init.lua" git push --force origin init-lua + git checkout main # switch back to main branch for graceful job ending check-formatting: runs-on: ubuntu-24.04 diff --git a/config/colorscheme.nix b/config/colorscheme.nix index 18da321..9d792c8 100644 --- a/config/colorscheme.nix +++ b/config/colorscheme.nix @@ -1,6 +1,6 @@ { colorschemes = { - catppuccin = { + catppuccin = { enable = true; settings.flavor = "mocha"; }; diff --git a/config/default.nix b/config/default.nix index c8b1cd7..c288068 100644 --- a/config/default.nix +++ b/config/default.nix @@ -1,6 +1,64 @@ -{lib, ...}: let - definitions = lib.attrNames (lib.filterAttrs (filename: kind: - filename != "default.nix" && (kind == "regular" || kind == "directory")) - (builtins.readDir ./.)); -in - lib.mkMerge (map (file: import ./${file}) definitions) +{pkgs, ...}: { + imports = [ + ./colorscheme.nix + ./options.nix + ./plugins + ]; + + config = { + # Use as leader key + globals.mapleader = " "; + globals.maplocalleader = " "; + + # Set 'vi' and 'vim' aliases to nixvim + viAlias = true; + vimAlias = true; + + # Setup clipboard support + clipboard = { + # Use xsel as clipboard provider + # providers.xsel.enable = true; + + # Sync system clipboard + register = "unnamedplus"; + }; + extraPackages = with pkgs; [ + nix-inspect + nixd + git + git-lfs + cloc + ripgrep + lazygit + black + fd + ripgrep + ]; + + keymaps = [ + { + mode = "n"; + key = "gg"; + action = "LazyGit"; + options = { + desc = "LazyGit (root dir)"; + }; + } + ]; + extraPlugins = with pkgs.vimPlugins; [ + lazygit-nvim + ]; + + extraConfigLua = '' + require("telescope").load_extension("lazygit") + ''; + performance = { + byteCompileLua = { + enable = true; + nvimRuntime = true; + configs = true; + plugins = true; + }; + }; + }; +} diff --git a/config/options.nix b/config/options.nix index 1c33d6f..fa918f5 100644 --- a/config/options.nix +++ b/config/options.nix @@ -19,5 +19,31 @@ autoindent = true; # Do clever autoindenting # TODO: i want to see 4 spaces when i press tab in python and 2 spaces in nix using setlocal # is it possible for me to set this per language? + + # folding + foldmethod = "expr"; + foldexpr = "nvim_treesitter#foldexpr()"; + foldlevel = 99; # Folds with a level higher than this number will be closed + foldcolumn = "1"; + foldenable = true; + foldlevelstart = -1; + fillchars = { + horiz = "━"; + horizup = "┻"; + horizdown = "┳"; + vert = "┃"; + vertleft = "┫"; + vertright = "┣"; + verthoriz = "╋"; + + eob = " "; + diff = "╱"; + + fold = " "; + foldopen = ""; + foldclose = ""; + + msgsep = "‾"; + }; }; } diff --git a/config/plugins/avante.nix b/config/plugins/avante.nix new file mode 100644 index 0000000..dbe9ec7 --- /dev/null +++ b/config/plugins/avante.nix @@ -0,0 +1,23 @@ +{ + plugins.avante = { + lazyLoad.settings.event = ["DeferredUIEnter"]; + settings = { + # provider = "ollama"; + # provider = "claude"; + providers = { + # claude = { + # endpoint = "https://api.anthropic.com"; + # extra_request_body = { + # max_tokens = 4096; + # temperature = 0; + # }; + # model = "claude-3-5-sonnet-20240620"; + # }; + ollama = { + endpoint = "http://localhost:11434"; + model = "qwen2.5-coder:32b"; + }; + }; + }; + }; +} diff --git a/config/plugins/blink-cmp.nix b/config/plugins/blink-cmp.nix new file mode 100644 index 0000000..73a09b4 --- /dev/null +++ b/config/plugins/blink-cmp.nix @@ -0,0 +1,36 @@ +{ + plugins.blink-cmp = { + settings = { + # snippets = { + # preset = "luasnip"; + # }; + sources = { + default = [ + "lsp" + "path" + "buffer" + "copilot" + ]; + providers = { + copilot = { + async = true; + module = "blink-copilot"; + name = "copilot"; + score_offset = 100; + # Optional configurations + opts = { + max_completions = 3; + max_attempts = 4; + kind = "Copilot"; + debounce = 750; + auto_refresh = { + backward = true; + forward = true; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/plugins/cmp.nix b/config/plugins/cmp.nix similarity index 100% rename from plugins/cmp.nix rename to config/plugins/cmp.nix diff --git a/plugins/comment.nix b/config/plugins/comment.nix similarity index 100% rename from plugins/comment.nix rename to config/plugins/comment.nix diff --git a/plugins/default.nix b/config/plugins/default.nix similarity index 73% rename from plugins/default.nix rename to config/plugins/default.nix index 0af3fea..e417720f 100644 --- a/plugins/default.nix +++ b/config/plugins/default.nix @@ -1,16 +1,9 @@ -{ - # settings of these plugins live in their respective files - imports = [ - ./blink-cmp.nix - ./cmp.nix - ./comment.nix - ./gitsigns.nix - ./lsp.nix - ./mini.nix - ./oil.nix - ./treesitter.nix - ./which-key.nix - ]; +{lib, ...}: { + imports = + lib.mapAttrsToList (name: _path: ./. + "/${name}") + (lib.filterAttrs (filename: kind: + filename != "default.nix" && (kind == "regular" || kind == "directory")) + (builtins.readDir ./.)); plugins = { # todo comments highlighter @@ -53,7 +46,7 @@ mini.enable = true; # TODO look more into the mini plugin # cursor animation - smear-cursor.enable = true; + smear-cursor.enable = false; # add buffer tab plugin bufferline.enable = true; @@ -72,5 +65,17 @@ # tip pop-up which-key.enable = true; + + # ai support + avante.enable = true; + + # lazy loading provider + lz-n.enable = true; + + # oil git status shower + oil-git-status.enable = true; + + # blink copilot + blink-copilot.enable = true; }; } diff --git a/plugins/gitsigns.nix b/config/plugins/gitsigns.nix similarity index 100% rename from plugins/gitsigns.nix rename to config/plugins/gitsigns.nix diff --git a/plugins/lsp.nix b/config/plugins/lsp.nix similarity index 100% rename from plugins/lsp.nix rename to config/plugins/lsp.nix diff --git a/plugins/mini.nix b/config/plugins/mini.nix similarity index 100% rename from plugins/mini.nix rename to config/plugins/mini.nix diff --git a/plugins/oil.nix b/config/plugins/oil.nix similarity index 87% rename from plugins/oil.nix rename to config/plugins/oil.nix index 8297a2b..4a6151b 100644 --- a/plugins/oil.nix +++ b/config/plugins/oil.nix @@ -7,6 +7,9 @@ view_options = { show_hidden = true; }; + win_options = { + signcolumn = "yes:2"; + }; }; # add this keymaps only if oil plugin is enabled keymaps = lib.mkIf config.plugins.oil.enable [ diff --git a/plugins/treesitter.nix b/config/plugins/treesitter.nix similarity index 78% rename from plugins/treesitter.nix rename to config/plugins/treesitter.nix index 954f711..54cec01 100644 --- a/plugins/treesitter.nix +++ b/config/plugins/treesitter.nix @@ -1,6 +1,6 @@ { plugins.treesitter = { - # folding = true; # i dont like the way it starts neovim with everything folded + folding = true; # i dont like the way it starts neovim with everything folded settings = { ensure_installed = [ "python" diff --git a/plugins/which-key.nix b/config/plugins/which-key.nix similarity index 100% rename from plugins/which-key.nix rename to config/plugins/which-key.nix diff --git a/default.nix b/default.nix deleted file mode 100644 index b3b896b..0000000 --- a/default.nix +++ /dev/null @@ -1,60 +0,0 @@ -{pkgs, ...}: { - imports = [./config ./plugins]; - - config = { - # Use as leader key - globals.mapleader = " "; - globals.maplocalleader = " "; - - # Set 'vi' and 'vim' aliases to nixvim - viAlias = true; - vimAlias = true; - - # Setup clipboard support - clipboard = { - # Use xsel as clipboard provider - # providers.xsel.enable = true; - - # Sync system clipboard - register = "unnamedplus"; - }; - extraPackages = with pkgs; [ - nix-inspect - nixd - git - git-lfs - cloc - ripgrep - lazygit - black - fd - ripgrep - ]; - - keymaps = [ - { - mode = "n"; - key = "gg"; - action = "LazyGit"; - options = { - desc = "LazyGit (root dir)"; - }; - } - ]; -extraPlugins = with pkgs.vimPlugins; [ - lazygit-nvim - ]; - - extraConfigLua = '' - require("telescope").load_extension("lazygit") - ''; - performance = { - byteCompileLua = { - enable = true; - nvimRuntime = true; - configs = true; - plugins = true; - }; - }; - }; -} diff --git a/flake.lock b/flake.lock index 5ae264e..a386e99 100644 --- a/flake.lock +++ b/flake.lock @@ -8,11 +8,11 @@ ] }, "locked": { - "lastModified": 1749398372, - "narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=", + "lastModified": 1760948891, + "narHash": "sha256-TmWcdiUUaWk8J4lpjzu4gCGxWY6/Ok7mOK4fIFfBuU4=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569", + "rev": "864599284fc7c0ba6357ed89ed5e2cd5040f0c04", "type": "github" }, "original": { @@ -53,16 +53,16 @@ ] }, "locked": { - "lastModified": 1748294338, - "narHash": "sha256-FVO01jdmUNArzBS7NmaktLdGA5qA3lUMJ4B7a05Iynw=", + "lastModified": 1754860581, + "narHash": "sha256-EM0IE63OHxXCOpDHXaTyHIOk2cNvMCGPqLt/IdtVxgk=", "owner": "NuschtOS", "repo": "ixx", - "rev": "cc5f390f7caf265461d4aab37e98d2292ebbdb85", + "rev": "babfe85a876162c4acc9ab6fb4483df88fa1f281", "type": "github" }, "original": { "owner": "NuschtOS", - "ref": "v0.0.8", + "ref": "v0.1.1", "repo": "ixx", "type": "github" } @@ -76,11 +76,11 @@ "nmt": "nmt" }, "locked": { - "lastModified": 1742249870, - "narHash": "sha256-U37ECk3zpfp92D3H0gzfWPyb5sf0RdOdublCq1zjq+w=", + "lastModified": 1756744433, + "narHash": "sha256-6BSEvkprwEQDQQgW5UH/1GkBPGM8M9+qX6o9ePslr6E=", "owner": "Gerschtli", "repo": "nix-formatter-pack", - "rev": "fe5b4498e3161191bd93fe0683dff347f6f689df", + "rev": "63b748033a3fa0af80f8ed908521122e48858c30", "type": "github" }, "original": { @@ -91,11 +91,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1749285348, - "narHash": "sha256-frdhQvPbmDYaScPFiCnfdh3B/Vh81Uuoo0w5TkWmmjU=", + "lastModified": 1761373498, + "narHash": "sha256-Q/uhWNvd7V7k1H1ZPMy/vkx3F8C13ZcdrKjO7Jv7v0c=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3e3afe5174c561dee0df6f2c2b2236990146329f", + "rev": "6a08e6bb4e46ff7fcbb53d409b253f6bad8a28ce", "type": "github" }, "original": { @@ -107,11 +107,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1749523198, - "narHash": "sha256-How2kQw0psKmCdXgojc95Sf3K5maHB3qfINxTZFCAPM=", + "lastModified": 1761656231, + "narHash": "sha256-EiED5k6gXTWoAIS8yQqi5mAX6ojnzpHwAQTS3ykeYMg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "cdc68935eba9f86d155585fdf6f17af6824f38ac", + "rev": "e99366c665bdd53b7b500ccdc5226675cfc51f45", "type": "github" }, "original": { @@ -129,11 +129,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1749761870, - "narHash": "sha256-y+rCuxTylur4k2MbL8cJwOR3pHIamCxp8xG9Vuhwvgw=", + "lastModified": 1761744315, + "narHash": "sha256-OknzyEoI+VEYgk/FWMyx3tvjb/MPPyqS+G/aemDz51w=", "owner": "nix-community", "repo": "nixvim", - "rev": "18d838e88945b554d059db5f1fff1daed4b7bf8f", + "rev": "6233fc6b2c3f203d8a5970f4a2c1df5777902717", "type": "github" }, "original": { @@ -184,11 +184,11 @@ ] }, "locked": { - "lastModified": 1749531675, - "narHash": "sha256-UB8Mc88rW9frjpJ1Fj2ro7f07Gg8dX3uVXvMXnFR4CE=", + "lastModified": 1761730856, + "narHash": "sha256-t1i5p/vSWwueZSC0Z2BImxx3BjoUDNKyC2mk24krcMY=", "owner": "NuschtOS", "repo": "search", - "rev": "4029d450d0266909ee52775849b7da54e79b328e", + "rev": "e29de6db0cb3182e9aee75a3b1fd1919d995d85b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 2c0fcc5..ab0b46c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,15 @@ { description = "My custom neovim configuration that has been mixed and matched from various sources"; + nixConfig = { + extra-substituters = [ + "https://nix-community.cachix.org" + ]; + extra-trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; + inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # https://gerschtli.github.io/nix-formatter-pack/nix-formatter-pack-options.html @@ -41,18 +50,22 @@ mkNixvim = specialArgs: nixvim.legacyPackages.${system}.makeNixvimWithModule { inherit pkgs; - - module = ./.; - + module = ./config; extraSpecialArgs = specialArgs // { inherit pkgs self; }; }; - in { + in rec { default = mkNixvim {}; lite = mkNixvim {withLSP = false;}; + + default-print-init = default.config.build.printInitPackage; + lite-print-init = lite.config.build.printInitPackage; + + default-init = default.config.build.initSource; + lite-init = lite.config.build.initSource; }); }; } diff --git a/plugins/blink-cmp.nix b/plugins/blink-cmp.nix deleted file mode 100644 index cb98844..0000000 --- a/plugins/blink-cmp.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - plugins.blink-cmp = { - settings = { - }; - }; -}