From f93e12accde82ded126cad504ead169b9538003d Mon Sep 17 00:00:00 2001 From: yukkop Date: Fri, 20 Feb 2026 16:41:18 +0000 Subject: [PATCH] feat: nixvim + zsh, fix: warnings --- nixos/module/hectic/archetype/dev.nix | 2 + .../module/hectic/hardware/hetzner-cloud.nix | 3 +- nixos/module/hectic/program/nixvim.nix | 197 ++++++++++++++++++ nixos/module/hectic/program/zsh.nix | 51 +++++ 4 files changed, 252 insertions(+), 1 deletion(-) create mode 100644 nixos/module/hectic/program/nixvim.nix create mode 100644 nixos/module/hectic/program/zsh.nix diff --git a/nixos/module/hectic/archetype/dev.nix b/nixos/module/hectic/archetype/dev.nix index 253da9f..284d599 100644 --- a/nixos/module/hectic/archetype/dev.nix +++ b/nixos/module/hectic/archetype/dev.nix @@ -19,6 +19,8 @@ in { config = lib.mkIf cfg.enable { hectic.archetype.base.enable = true; + hectic.program.zsh.enable = true; + hectic.program.nixvim.enable = true; services.getty.autologinUser = "root"; diff --git a/nixos/module/hectic/hardware/hetzner-cloud.nix b/nixos/module/hectic/hardware/hetzner-cloud.nix index b750fb4..525fe27 100644 --- a/nixos/module/hectic/hardware/hetzner-cloud.nix +++ b/nixos/module/hectic/hardware/hetzner-cloud.nix @@ -73,7 +73,8 @@ in { "xen_blkfront" ] ++ (if pkgs.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []); - networking.useDHCP = lib.mkDefault true; + networking.useDHCP = false; + networking.useNetworkd = true; systemd.network.enable = true; systemd.network.networks."30-wan" = { matchConfig.Name = cfg.networkMatchConfigName; diff --git a/nixos/module/hectic/program/nixvim.nix b/nixos/module/hectic/program/nixvim.nix new file mode 100644 index 0000000..22b9475 --- /dev/null +++ b/nixos/module/hectic/program/nixvim.nix @@ -0,0 +1,197 @@ +{ + inputs, + flake, + self, +}: { + pkgs, + lib, + config, + ... +}: let + cfg = config.hectic.program.nixvim; +in { + imports = [ + inputs.nixvim.nixosModules.nixvim + ]; + + options.hectic.program.nixvim.enable = lib.mkEnableOption "Enable hectic nixvim config"; + + config = lib.mkIf cfg.enable { + programs.nixvim = { + enable = true; + + extraPackages = with pkgs; [ gcc ]; + + colorschemes.kanagawa = { + enable = true; + settings.colors.theme.all = {}; + }; + + opts = { + spell = true; + spelllang = [ "en" "ru" "it" ]; + tabstop = 2; + shiftwidth = 2; + softtabstop = 2; + expandtab = true; + }; + + extraFiles = { + "spell/ru.utf-8.spl".source = pkgs.fetchurl { + url = "https://ftp.nluug.nl/vim/runtime/spell/ru.utf-8.spl"; + sha256 = "sha256-6y0714ogILMLzAp8/r2s6/t6QnWBEU9muIpXeubaxU0="; + }; + "spell/ru.utf-8.sug".source = pkgs.fetchurl { + url = "https://ftp.nluug.nl/vim/runtime/spell/ru.utf-8.sug"; + sha256 = "sha256-6r2GForYXVv7gGiAjPeYK6sDdK/CmctJ7MidcWFvOTs="; + }; + "spell/it.utf-8.spl".source = pkgs.fetchurl { + url = "https://ftp.nluug.nl/vim/runtime/spell/it.utf-8.spl"; + hash = "sha256-2AczkD6DbVN5DAq4wcLyn2Y8oqd67ns4Guprh2KudBM="; + }; + "spell/it.utf-8.sug".source = pkgs.fetchurl { + url = "https://ftp.nluug.nl/vim/runtime/spell/it.utf-8.sug"; + hash = "sha256-4LsXYaeScJJrdaj69PTQ2EDVWis0UY/Y5RKSfCckzko="; + }; + "ftdetect/hemar.vim".text = '' + au BufRead,BufNewFile *.hemar setfiletype hemar + ''; + "queries/hemar/highlights.scm".text = '' + (interpolation) @keyword + + (for "for" @keyword) + (for "in" @keyword) + (done "done" @keyword) + + (path) @field + (string) @string + (text) @text + + (for + "{[" @punctuation.bracket + "]}" @punctuation.bracket) + + (done + "{[" @punctuation.bracket + "]}" @punctuation.bracket) + + (interpolation + "{[" @punctuation.bracket + "]}" @punctuation.bracket) + ''; + }; + + extraConfigLuaPre = /* lua */ '' + -- map leader + vim.api.nvim_set_keymap("", "", "", { noremap = true, silent = true }) + vim.g.mapleader = ' ' + + -- render markdown + require('render-markdown').setup({ + link = { + enabled = true, + render_modes = false, + }, + }) + + -- nowrap for *.nowrap.* markdown files + vim.api.nvim_create_autocmd("FileType", { + pattern = "markdown", + callback = function() + if vim.fn.expand("%:t"):find("%.nowrap%.") then vim.opt_local.wrap = false end + end, + }) + + -- toggle conceallevel + vim.keymap.set("n", "tc", ":setlocal =&conceallevel ? 'conceallevel=0' : 'conceallevel=2'", { desc = "[T]oggle [C]onceallevel" }) + + -- tree-sitter: register hemar parser + local parser_config = require("nvim-treesitter.parsers").get_parser_configs() + parser_config.hemar = { + install_info = { + url = "https://github.com/hectic-lab/util.nix", + files = { "package/hemar/grammar/tree-sitter/src/parser.c" }, + generate_requires_npm = false, + requires_generate_from_grammar = false, + }, + filetype = "hemar", + } + ''; + + extraConfigLuaPost = /* lua */ '' + vim.cmd [[ + hi Normal guibg=none ctermbg=none + hi NonText guibg=none ctermbg=none + ]] + ''; + + keymaps = [ + { mode = "n"; key = "o"; options.silent = true; action = "Oil"; } + { mode = "n"; key = "dd"; action = "lua vim.diagnostic.open_float()"; } + { mode = "n"; key = "dn"; action = "lua vim.diagnostic.goto_next()"; } + { mode = "n"; key = "dp"; action = "lua vim.diagnostic.goto_prev()"; } + ]; + + extraPlugins = with pkgs.vimPlugins; [ + nvim-treesitter-parsers.templ + vim-shellcheck + vim-grammarous + ]; + + plugins = { + render-markdown.enable = true; + fidget.enable = true; + oil.enable = true; + + treesitter = { + enable = true; + settings = { + ensure_installed = [ "hemar" ]; + highlight.enable = true; + }; + }; + + lsp = { + enable = true; + keymaps.lspBuf = { + "lh" = "hover"; + "ld" = "definition"; + "lD" = "references"; + "lr" = "rename"; + "li" = "implementation"; + "lt" = "type_definition"; + "lf" = "format"; + "la" = "code_action"; + }; + servers = { + rust_analyzer = { + enable = true; + installRustc = false; + installCargo = false; + }; + nixd = { + enable = true; + }; + nil_ls = { + enable = true; + extraOptions.formatting.command = [ "nixpkgs-fmt" ]; + }; + clangd.enable = true; + ts_ls.enable = true; + gopls.enable = true; + templ.enable = true; + bashls.enable = true; + kotlin_language_server.enable = true; + metals = { + enable = true; + cmd = [ "metals" ]; + }; + sqls.enable = true; + java_language_server.enable = true; + pyright.enable = true; + }; + }; + }; + }; + }; +} diff --git a/nixos/module/hectic/program/zsh.nix b/nixos/module/hectic/program/zsh.nix new file mode 100644 index 0000000..07e8c7e --- /dev/null +++ b/nixos/module/hectic/program/zsh.nix @@ -0,0 +1,51 @@ +{ + inputs, + flake, + self, +}: { + pkgs, + lib, + config, + ... +}: let + cfg = config.hectic.program.zsh; +in { + imports = [ + inputs.home-manager.nixosModules.home-manager + ]; + + options.hectic.program.zsh.enable = lib.mkEnableOption "Enable hectic zsh config"; + + config = lib.mkIf cfg.enable { + # system-level zsh must be on for home-manager zsh to work + programs.zsh.enable = true; + users.defaultUserShell = pkgs.zsh; + + home-manager.users.root = { + home.stateVersion = lib.mkDefault "25.05"; + + programs.zsh = { + enable = true; + enableCompletion = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + + history = { + size = 10000; + path = "$HOME/.zsh/.zsh_history"; + }; + + oh-my-zsh = { + enable = true; + theme = "terminalparty"; + }; + + shellAliases = self.lib.sharedShellAliases; + + initContent = '' + set -ovi + ''; + }; + }; + }; +}