From e64967fa76645e63a8392e3adab71702686a61c2 Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Thu, 30 May 2024 22:12:15 +0200 Subject: [PATCH] nvim -> helix --- common/gaming.nix | 44 +++--- common/tooling/c.nix | 17 +-- common/tooling/default.nix | 30 ++-- common/tooling/git.nix | 26 +--- common/tooling/helix.nix | 73 +++++++++ common/tooling/java.nix | 2 +- common/tooling/lsp.nix | 139 ++++++++---------- common/tooling/nix.nix | 6 +- common/tooling/nvim.nix | 95 ------------ common/tooling/python.nix | 17 ++- common/tooling/rust.nix | 3 - modules/nextcloud.nix | 2 +- specific/grimm-nixos-laptop/configuration.nix | 1 - 13 files changed, 205 insertions(+), 250 deletions(-) create mode 100644 common/tooling/helix.nix delete mode 100644 common/tooling/nvim.nix diff --git a/common/gaming.nix b/common/gaming.nix index ced414d..1d196f1 100644 --- a/common/gaming.nix +++ b/common/gaming.nix @@ -6,7 +6,12 @@ }: let inherit (config.grimmShared) enable gaming; - inherit (lib) mkIf getExe mkEnableOption optional; + inherit (lib) + mkIf + getExe + mkEnableOption + optional + ; in { config = mkIf (enable && gaming) { @@ -40,23 +45,26 @@ in GAMEMODERUNEXEC = "env DRI_PRIME=1"; }; - environment.systemPackages = with pkgs; [ - heroic - prismlauncher - mangohud - the-powder-toy - factorio - pactorio - (symlinkJoin { - name = "osu"; - paths = [ - (writeShellScriptBin "osu!" '' - exec gamemoderun ${getExe osu-lazer-bin} - '') - osu-lazer-bin - ]; - }) - ] ++ optional (!isNull factorio.passthru.updateScript) factorio; + environment.systemPackages = + with pkgs; + [ + heroic + prismlauncher + mangohud + the-powder-toy + factorio + pactorio + (symlinkJoin { + name = "osu"; + paths = [ + (writeShellScriptBin "osu!" '' + exec gamemoderun ${getExe osu-lazer-bin} + '') + osu-lazer-bin + ]; + }) + ] + ++ optional (!isNull factorio.passthru.updateScript) factorio; }; options.grimmShared.gaming = mkEnableOption "enables steam, heroic, prism and gamemoded"; diff --git a/common/tooling/c.nix b/common/tooling/c.nix index 49a3bbb..bf7cc52 100644 --- a/common/tooling/c.nix +++ b/common/tooling/c.nix @@ -28,26 +28,18 @@ in glibc clang clang-tools + cmake ] ++ optionals graphical [ libva-utils jetbrains.clion ]; + environment.sessionVariables.CMAKE_EXPORT_COMPILE_COMMANDS = "1"; grimmShared.tooling.lang_servers = [ { lsp = { package = pkgs.clang-tools; - lspconf_config = '' - { - cmd = { 'clangd', '--background-index'}, - root_dir = require("lspconfig.util").root_pattern( - "CMakeLists.txt", - "flake.nix", - ".git" - ) - }''; - lspconf_mod_name = "clangd"; }; fmt = rec { package = pkgs.clang-tools; @@ -60,6 +52,11 @@ in ]; }; } + { + lsp = { + package = pkgs.cmake-language-server; + }; + } ]; }; diff --git a/common/tooling/default.nix b/common/tooling/default.nix index da13039..234b36f 100644 --- a/common/tooling/default.nix +++ b/common/tooling/default.nix @@ -8,8 +8,6 @@ let inherit (config.grimmShared) enable tooling graphical; inherit (lib) mkEnableOption - mkOption - types getExe optionals mkIf @@ -17,13 +15,13 @@ let in { imports = [ - ./lilypond.nix + # ./lilypond.nix ./nix.nix ./security.nix ./python.nix ./rust.nix - ./nvim.nix ./lsp.nix + ./helix.nix ./git.nix ./c.nix ./java.nix @@ -100,19 +98,23 @@ in }; programs.thefuck.enable = true; - programs.starship.enable = true; - programs.bash.shellInit = '' - eval "$(starship init bash)" - ''; + programs.starship = { + enable = true; + settings = { + format = "$all$directory$character"; + nodejs.disabled = true; + cmake.symbol = "cmake "; + custom.shell = { + command = "basename $SHELL"; + when = "test -v SHELL"; + format = " in [$output]($style)"; + }; + # env_var.SHELL = {variable = "SHELL"; default = ""; }; + }; + }; }; options.grimmShared.tooling = { enable = mkEnableOption "grimm-tooling"; - - supportedLangs = mkOption { - type = types.listOf (types.enum [ ]); - default = [ ]; - description = "Languages for which to enable support"; - }; }; } diff --git a/common/tooling/git.nix b/common/tooling/git.nix index 8b5ff80..e75afa3 100644 --- a/common/tooling/git.nix +++ b/common/tooling/git.nix @@ -14,16 +14,6 @@ let ; in { - imports = [ - ./lilypond.nix - ./nix.nix - ./security.nix - ./python.nix - ./rust.nix - ./nvim.nix - ./lsp.nix - ]; - config = mkIf (enable && tooling.enable) { environment.systemPackages = [ (pkgs.writeShellScriptBin "silent-add" "${getExe config.programs.git.package} add --intent-to-add $@ ; ${getExe config.programs.git.package} update-index --assume-unchanged $@") @@ -33,8 +23,6 @@ in pkgs.delta ]; - grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ fugitive ]; - programs.git = { enable = true; lfs.enable = true; @@ -47,12 +35,14 @@ in push.autoSetupRemote = true; core.autocrlf = "input"; commit.gpgsign = true; - core.excludesfile = (pkgs.writeText ".gitignore" '' - .idea - .obsidian - *~ - result - ''); + core.excludesfile = ( + pkgs.writeText ".gitignore" '' + .idea + .obsidian + *~ + result + '' + ); pull.rebase = false; include.path = "${pkgs.delta.src}/themes.gitconfig"; diff --git a/common/tooling/helix.nix b/common/tooling/helix.nix new file mode 100644 index 0000000..a419f8b --- /dev/null +++ b/common/tooling/helix.nix @@ -0,0 +1,73 @@ +{ + pkgs, + config, + lib, + ... +}: +let + inherit (config.grimmShared) enable tooling; + inherit (lib) + mkOption + types + getExe + mkIf + ; + inherit (pkgs) + helix + symlinkJoin + writeTextDir + concatTextFile + makeWrapper + ; + inherit (pkgs.writers) writeTOML; + + conf-file-name = "config.toml"; + lang-file-name = "languages.toml"; + + helix-conf = symlinkJoin { + name = "helix-conf"; + paths = [ + (concatTextFile { + name = "helix-conf-partial"; + destination = "/${conf-file-name}"; + files = [ (writeTOML conf-file-name config.programs.helix.config) ]; + }) + (writeTextDir lang-file-name '' + [[language]] + language-servers = ["nixd"] + name = "nix" + + [language-server.nixd] + command = "${getExe pkgs.nixd}" + '') + ]; + }; + + helix-wrapped = pkgs.symlinkJoin { + name = helix.pname; + + paths = [ helix ]; + buildInputs = [ makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/${helix.meta.mainProgram} --add-flags "-c ${helix-conf}/${conf-file-name}" + ''; + }; +in +{ + config = mkIf (enable && tooling.enable) { + environment.systemPackages = [ helix-wrapped ]; + environment.sessionVariables.EDITOR = getExe helix; + + programs.helix.config = { + theme = "catppuccin_mocha"; + }; + }; + + options.programs.helix = { + config = mkOption { + type = types.attrs; + default = { }; + description = "Helix configuration"; + }; + }; +} diff --git a/common/tooling/java.nix b/common/tooling/java.nix index caa1c70..358d933 100644 --- a/common/tooling/java.nix +++ b/common/tooling/java.nix @@ -25,7 +25,7 @@ in grimmShared.tooling.lang_servers = [ { lsp = { - package = pkgs.java-language-server; + package = pkgs.jdt-language-server; }; fmt = { package = pkgs.google-java-format; diff --git a/common/tooling/lsp.nix b/common/tooling/lsp.nix index d56689a..fe75d1a 100644 --- a/common/tooling/lsp.nix +++ b/common/tooling/lsp.nix @@ -11,7 +11,6 @@ let types mkIf getName - mkEnableOption getExe filter optionalString @@ -43,92 +42,72 @@ in ++ (map (v: v.fmt.package) (filter (v: !isNull v.fmt) tooling.lang_servers)); environment.shellAliases."treefmt" = "${getExe pkgs.treefmt} --config-file $(${getExe find_conf})"; - - grimmShared.tooling.nvim.extraLuaRC = - [ "vim.g.coq_settings = { auto_start = 'shut-up' }" ] - ++ (map ( - v: - "require'lspconfig'.${v.lsp.lspconf_mod_name}.setup(require('coq').lsp_ensure_capabilities(${v.lsp.lspconf_config}))" - ) (filter (v: !isNull v.lsp && v.lsp.vimIntegration) tooling.lang_servers)); - - grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ - nvim-lspconfig - coq_nvim - coq-artifacts - ]; }; - options.grimmShared.tooling.lang_servers = mkOption { - type = types.listOf ( - types.submodule { - options = { - lsp = mkOption { - type = types.nullOr ( - types.submodule ( - { config, ... }: - { - options = { - lspconf_mod_name = mkOption { - type = types.nullOr types.nonEmptyStr; - default = builtins.replaceStrings [ "-" ] [ "_" ] (getName config.package); - description = "lspconfig module name"; - }; + options.grimmShared.tooling = { + supportedLangs = mkOption { + type = types.listOf (types.enum [ ]); + default = [ ]; + description = "Languages for which to enable support"; + }; + lang_servers = mkOption { - lspconf_config = mkOption { - type = types.nonEmptyStr; - default = "{}"; - description = "options to pass to lspconfig"; + type = types.listOf ( + types.submodule { + options = { + lsp = mkOption { + type = types.nullOr ( + types.submodule ( + { config, ... }: + { + options = { + package = mkOption { + type = types.package; + default = null; + description = "LSP package"; + }; }; + } + ) + ); + }; - package = mkOption { - type = types.package; - default = null; - description = "LSP package"; - }; + fmt = mkOption { + default = null; + type = types.nullOr ( + types.submodule ( + { config, ... }: + { + options = { + package = mkOption { + type = types.package; + description = "FMT package"; + }; - vimIntegration = mkEnableOption "Enable coq/nvim-lspconfig integration" // { - default = true; + options = mkOption { + type = types.listOf types.nonEmptyStr; + default = [ ]; + }; + + includes = mkOption { + type = types.listOf types.nonEmptyStr; + default = [ ]; + }; + + command = mkOption { + type = types.nonEmptyStr; + default = getExe config.package; + }; }; - }; - } - ) - ); + } + ) + ); + }; }; - - fmt = mkOption { - type = types.nullOr ( - types.submodule ( - { config, ... }: - { - options = { - package = mkOption { - type = types.package; - description = "FMT package"; - }; - - options = mkOption { - type = types.listOf types.nonEmptyStr; - default = [ ]; - }; - - includes = mkOption { - type = types.listOf types.nonEmptyStr; - default = [ ]; - }; - - command = mkOption { - type = types.nonEmptyStr; - default = getExe config.package; - }; - }; - } - ) - ); - }; - }; - } - ); - default = { }; - description = "Language servers available on the system"; + } + ); + default = { }; + description = "Language servers available on the system"; + }; }; } diff --git a/common/tooling/nix.nix b/common/tooling/nix.nix index 6eb0a98..e5871f0 100644 --- a/common/tooling/nix.nix +++ b/common/tooling/nix.nix @@ -17,13 +17,9 @@ environment.sessionVariables = lib.mkIf pkgs.config.allowUnfree { NIXPKGS_ALLOW_UNFREE = "1"; }; - grimmShared.tooling.nvim = { - plugins = with pkgs.vimPlugins; [ vim-nix ]; - }; - grimmShared.tooling.lang_servers = [ { - lsp.package = pkgs.nixd; + lsp.package = pkgs.nil; fmt = { package = pkgs.nixpkgs-fmt; includes = [ "*.nix" ]; diff --git a/common/tooling/nvim.nix b/common/tooling/nvim.nix deleted file mode 100644 index b87ea3b..0000000 --- a/common/tooling/nvim.nix +++ /dev/null @@ -1,95 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: -let - inherit (config.grimmShared) enable tooling; - inherit (lib) - mkOption - types - getExe - mkIf - concatLines - ; -in -{ - config = mkIf (enable && tooling.enable) { - environment.systemPackages = with pkgs; [ - dos2unix - neovim-remote - ]; - - programs.git.config.core.editor = getExe pkgs.neovim; - - grimmShared.tooling.nvim = { - plugins = with pkgs.vimPlugins; [ vim-monokai-pro ]; - # extraLuaRC = [ "vim.lsp.inlay_hint.enable(true)" ]; - }; - - programs.neovim = { - enable = true; - viAlias = true; - defaultEditor = true; - withPython3 = true; - configure = { - customRC = - let - luarc = pkgs.writeText "init.lua" (concatLines tooling.nvim.extraLuaRC); - in - '' - set number - set hidden - set fileencodings=utf-8 - set nocompatible - set clipboard+=unnamedplus - set ff=unix - set termguicolors - colorscheme monokai_pro - hi Normal guibg=NONE ctermbg=NONE - hi NonText guibg=NONE ctermbg=NONE - - " Toggle transparent background - let t:is_transparent = 1 - function! Toggle_transparent() - if t:is_transparent == 0 - hi Normal guibg=NONE ctermbg=NONE - hi NonText guibg=NONE ctermbg=NONE - let t:is_transparent = 1 - else - set background=dark - hi EndOfBuffer ctermfg=bg - let t:is_transparent = 0 - endif - endfunction - nnoremap : call Toggle_transparent() - - luafile ${luarc} - - if filereadable($HOME . "/.vimrc") - source ~/.vimrc - endif - ''; - packages.myVimPackage = { - start = tooling.nvim.plugins; - opt = [ ]; - }; - }; - }; - }; - - options.grimmShared.tooling.nvim = { - plugins = mkOption { - type = types.listOf types.package; - default = [ ]; - description = "Extra vim plugins to include"; - }; - - extraLuaRC = mkOption { - type = types.listOf types.nonEmptyStr; - default = [ ]; - description = "Extra init LUA scripts"; - }; - }; -} diff --git a/common/tooling/python.nix b/common/tooling/python.nix index 7ffa025..04f1a88 100644 --- a/common/tooling/python.nix +++ b/common/tooling/python.nix @@ -36,9 +36,18 @@ in programs.xonsh = { enable = true; config = - '' - execx($(${getExe pkgs.starship} init xonsh)) - '' + ( + let + cfg = config.programs.starship; + settingsFormat = pkgs.formats.toml { }; + settingsFile = settingsFormat.generate "starship.toml" cfg.settings; + in + '' + $STARSHIP_CONFIG="${settingsFile}" + $SHELL="${getExe config.programs.xonsh.package}" + execx($(${getExe pkgs.starship} init xonsh)) + '' + ) + concatLines ( mapAttrsToList ( name: value: "aliases[\"${name}\"] = '''${value}'''" @@ -49,7 +58,7 @@ in grimmShared.tooling.lang_servers = [ { - lsp.package = pkgs.pyright; + lsp.package = pkgs.python311Packages.python-lsp-server; fmt = { package = pkgs.yapf; includes = [ "*.py" ]; diff --git a/common/tooling/rust.nix b/common/tooling/rust.nix index 39555fb..3e0c601 100644 --- a/common/tooling/rust.nix +++ b/common/tooling/rust.nix @@ -25,13 +25,10 @@ in ] ++ optionals graphical [ jetbrains.clion ]; - grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ rustaceanvim ]; - grimmShared.tooling.lang_servers = [ { lsp = { package = pkgs.rust-analyzer; - vimIntegration = false; }; fmt = { package = pkgs.rustfmt; diff --git a/modules/nextcloud.nix b/modules/nextcloud.nix index c209bbc..99cf03b 100644 --- a/modules/nextcloud.nix +++ b/modules/nextcloud.nix @@ -21,7 +21,7 @@ in group = "nextcloud"; mode = "0600"; }; - nextcloud_server_key = { + nextcloud_server_key = { file = ../secrets/nextcloud_server_key.age; owner = "nextcloud"; group = "nextcloud"; diff --git a/specific/grimm-nixos-laptop/configuration.nix b/specific/grimm-nixos-laptop/configuration.nix index 034b5d0..cc853f6 100644 --- a/specific/grimm-nixos-laptop/configuration.nix +++ b/specific/grimm-nixos-laptop/configuration.nix @@ -12,7 +12,6 @@ grimmShared = { tooling = { pass = true; - lilypond = true; }; gaming = true; printing = true;