From 599434e43d4d92e1df6c7f1504b454e44f753400 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 28 Sep 2024 16:18:16 +0200 Subject: [PATCH 01/53] kakoune: set up package with plugins --- packages/common/default.nix | 1 + .../common/nki-kakoune/autoload/latex.kak | 133 +++++++++++ .../common/nki-kakoune/autoload/markdown.kak | 29 +++ packages/common/nki-kakoune/default.nix | 3 + packages/common/nki-kakoune/plugins.nix | 209 ++++++++++++++++++ 5 files changed, 375 insertions(+) create mode 100644 packages/common/nki-kakoune/autoload/latex.kak create mode 100644 packages/common/nki-kakoune/autoload/markdown.kak create mode 100644 packages/common/nki-kakoune/default.nix create mode 100644 packages/common/nki-kakoune/plugins.nix diff --git a/packages/common/default.nix b/packages/common/default.nix index be4ba2a..fadb679 100644 --- a/packages/common/default.nix +++ b/packages/common/default.nix @@ -2,4 +2,5 @@ final: prev: { epfl-cups-drivers = final.callPackage ./epfl-cups-drivers { }; ttaenc = final.callPackage ./ttaenc.nix { }; suwako-cursors = final.callPackage ./suwako-cursors { }; + nki-kakoune = final.callPackage ./nki-kakoune { }; } diff --git a/packages/common/nki-kakoune/autoload/latex.kak b/packages/common/nki-kakoune/autoload/latex.kak new file mode 100644 index 0000000..4bb9c9d --- /dev/null +++ b/packages/common/nki-kakoune/autoload/latex.kak @@ -0,0 +1,133 @@ +## Author: @natsukagami (https://github.com/natsukagami) +## +## To activate, source the file into kakrc and add: +### require-module latex-kak +## +## NOTE: This overrides , so if you don't like it, remove it. + +# Create a simple begin block, put the cursors in and remove multi-cursor on exit. +define-command -hidden create-begin-block %{ + execute-keys "i\begin{b0}\end{b0}" + execute-keys "b0" + execute-keys -with-hooks -with-maps "c" + hook -once buffer ModeChange .*:normal %{ + execute-keys -with-maps ",gl" + } +} +# Create a begin block with the given parameter as block name. +define-command -params 1 create-begin-block-with %{ + execute-keys "i\begin{b0}\end{b0}" + execute-keys "b0c%arg{1}," + execute-keys "ok" + execute-keys -with-maps "gl" +} +# Create a \param{} block and put the cursor in the middle. +define-command -params 2 -hidden create-delims %{ + execute-keys "i%arg{1}hZa%arg{2}zl" + execute-keys -with-hooks -with-maps "i" +} +define-command -params 1 create-block-with %{ + create-delims "\%arg{1}{" "}" +} + +# The font-menu +declare-user-mode latex-font +## Semantics +map -docstring "Text" global latex-font t ": create-block-with text" +map -docstring "Emphasize (emph)" global latex-font e ": create-block-with emph" +## Shape +map -docstring "Italics (textit)" global latex-font i ": create-block-with textit" +map -docstring "Upright (textup)" global latex-font u ": create-block-with textup" +# map -docstring "Slanted (textsl)" global latex-font S ": create-block-with textsl" +# map -docstring "Swash font (textsw)" global latex-font W ": create-block-with textsw" +# map -docstring "Small caps (textsc)" global latex-font C ": create-block-with textsc" +# Weight +map -docstring "Bold text (textbf)" global latex-font b ": create-block-with textbf" +# map -docstring "Medium bold (textmd)" global latex-font M ": create-block-with textmd" +# map -docstring "Normal (textnormal)" global latex-font N ": create-block-with textnormal" +## Family +# map -docstring "Serif font (textsf)" global latex-font s ": create-block-with textsf" +# map -docstring "Roman text (textrm)" global latex-font r ": create-block-with textrm" +map -docstring "Monospace (texttt)" global latex-font m ": create-block-with texttt" +## Math styles +map -docstring "Math Calligraphic (mathcal)" global latex-font ": create-block-with mathcal" +map -docstring "Math Blackboard (mathbb)" global latex-font ": create-block-with mathbb" +# map -docstring "Math Fraktur (mathfr)" global latex-font ": create-block-with mathfr" +# map -docstring "Math Roman (mathrm)" global latex-font ": create-block-with mathrm" +# map -docstring "Math Italics (mathit)" global latex-font ": create-block-with mathit" +# map -docstring "Math Bold (mathbf)" global latex-font ": create-block-with mathbf" +# map -docstring "Serif font (mathsf)" global latex-font ": create-block-with mathsf" +map -docstring "Math Monospace (mathtt)" global latex-font ": create-block-with mathtt" +map -docstring "Math Fraktur (mathfrak)" global latex-font f ": create-block-with mathfrak" + +# "Insert block" menu +declare-user-mode latex-insert-block +## Common normal text blocks +map -docstring "Unordered list" global latex-insert-block u ": create-begin-block-with itemize" +map -docstring "Ordered list" global latex-insert-block o ": create-begin-block-with enumerate" +## Common math blocks +map -docstring "Theorem" global latex-insert-block t ": create-begin-block-with theorem" +map -docstring "Definition" global latex-insert-block d ": create-begin-block-with definition" +map -docstring "Lemma" global latex-insert-block l ": create-begin-block-with lemma" +map -docstring "Example" global latex-insert-block e ": create-begin-block-with example" +map -docstring "Proof" global latex-insert-block p ": create-begin-block-with proof" +map -docstring "Remark" global latex-insert-block r ": create-begin-block-with remark" +map -docstring "Proposition" global latex-insert-block ": create-begin-block-with proposition" +map -docstring "Corollary" global latex-insert-block C ": create-begin-block-with corollary" +## Common environments +map -docstring "align*" global latex-insert-block a ": create-begin-block-with align*" +map -docstring "align" global latex-insert-block ": create-begin-block-with align" +map -docstring "equation" global latex-insert-block E ": create-begin-block-with equation" +map -docstring "equation*" global latex-insert-block ": create-begin-block-with equation*" +map -docstring "Matrix" global latex-insert-block m ": create-begin-block-with bmatrix" +map -docstring "Cases" global latex-insert-block C ": create-begin-block-with cases" +map -docstring "Table" global latex-insert-block T ": create-begin-block-with tabular" +## Custom +map -docstring "Custom" global latex-insert-block c ": create-begin-block" + +# Pairs of delimiters +declare-user-mode latex-insert-delims +map -docstring "Grouping" global latex-insert-delims g ": create-delims { }" +map -docstring "Parentheses" global latex-insert-delims p ": create-delims ( )" +map -docstring "Large Parentheses" global latex-insert-delims P ": create-delims \left( \right)" +map -docstring "Brackets" global latex-insert-delims b ": create-delims \left[ \right]" +map -docstring "Sets" global latex-insert-delims s ": create-delims \{ \}" +map -docstring "Large Sets" global latex-insert-delims S ": create-delims \left\{ \right\}" + + +hook global WinSetOption filetype=(tex|latex) %{ + ## Create delims (shortcuts) + map buffer normal ": enter-user-mode latex-insert-delimsp" + map buffer insert ": enter-user-mode latex-insert-delimsp" + map buffer normal ": enter-user-mode latex-insert-delimsg" + map buffer insert ": enter-user-mode latex-insert-delimsg" + map buffer normal "i\(\)Zhhi" + map buffer insert "\(\)Z2h" + map buffer normal "i\[\]Zhhi" + map buffer insert "\[\]Z2h" + map buffer normal ": enter-user-mode latex-insert-delims" + map buffer insert ": enter-user-mode latex-insert-delims" + + ## Quickly create begin/end blocks + map buffer normal ": create-begin-block" + map buffer insert ": create-begin-block" + + ## Font menu + map buffer normal ": enter-user-mode latex-font" + map buffer insert ": enter-user-mode latex-font" + + ## Insert menu + map buffer normal ": enter-user-mode latex-insert-block" + map buffer insert ": enter-user-mode latex-insert-block" + + ## Select math equations and environment blocks + map buffer object e -docstring "Inline Math equation \( \)" "c\\\\\\(,\\\\\\)" + map buffer object E -docstring "Display Math equation \[ \]" "c\\\\\\[,\\\\\\]" + map buffer object v -docstring "Simple environment \env{}" "c\\\\\\w+\\{,\\}" + map buffer object V -docstring "Full environment \begin{env}\end{env}" "c\\\\begin\\{\\w+\\}(?:\\{[\\w\\s]*\\})*(?:\\[[\\w\\s]*\\])*,\\\\end\\{\\w+\\}" + + ## Quickly get a new item + map buffer normal "o\item " + map buffer insert "o\item " +} + diff --git a/packages/common/nki-kakoune/autoload/markdown.kak b/packages/common/nki-kakoune/autoload/markdown.kak new file mode 100644 index 0000000..fb10581 --- /dev/null +++ b/packages/common/nki-kakoune/autoload/markdown.kak @@ -0,0 +1,29 @@ +hook global WinSetOption filetype=(markdown) %{ + map buffer normal ": enter-user-mode markdown-menu" +} + +# A menu for common markdown actions +declare-user-mode markdown-menu + +map -docstring "Toggle the checkboxes on the same line" global markdown-menu t ": markdown-toggle-checkbox" + +define-command -hidden markdown-toggle-checkbox %{ + try %{ + execute-keys -draft "xs^\s*- \[( |x)\]h: markdown-toggle-checkbox-selections" + } +} + +define-command -hidden markdown-toggle-checkbox-selections %{ + try %{ + execute-keys -draft -itersel ": markdown-toggle-checkbox-one" + } +} + +define-command -hidden markdown-toggle-checkbox-one %{ + try %{ + execute-keys -draft "sxr " + } catch %{ + execute-keys -draft "s rx" + } +} + diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix new file mode 100644 index 0000000..6e181ce --- /dev/null +++ b/packages/common/nki-kakoune/default.nix @@ -0,0 +1,3 @@ +{ callPackage, kakoune, ... }: kakoune.override { + plugins = (callPackage ./plugins.nix { }).plugins; +} diff --git a/packages/common/nki-kakoune/plugins.nix b/packages/common/nki-kakoune/plugins.nix new file mode 100644 index 0000000..a16c898 --- /dev/null +++ b/packages/common/nki-kakoune/plugins.nix @@ -0,0 +1,209 @@ +{ pkgs, symlinkJoin, writeTextDir, kakouneUtils, ... }: +with { + inherit (kakouneUtils) buildKakounePluginFrom2Nix; +}; +let + toDir = name: file: writeTextDir name (builtins.readFile file); + + writeActivationScript = script: writeTextDir "on-load.kak" '' + hook global KakBegin .* %{ + ${script} + } + ''; + + writeModuleWrapper = name: script: writeTextDir "module.kak" '' + provide-module ${name} %◍ + ${script} + ◍ + ''; + + kakounePlugin = { name, src, wrapAsModule ? false, activationScript ? null, ... }@attrs: + let + module = if wrapAsModule then writeModuleWrapper name (builtins.readFile src) else src; + in + buildKakounePluginFrom2Nix { + pname = name; + version = attrs.version or "latest"; + src = if activationScript == null then module else + symlinkJoin { + name = "${name}-src"; + paths = [ + module + (writeActivationScript activationScript) + ]; + }; + }; +in +{ + plugins = builtins.map kakounePlugin + [ + # My own scripts + { + name = "latex.kak"; + src = toDir "latex.kak" ./autoload/latex.kak; + } + { + name = "markdown.kak"; + src = toDir "markdown.kak" ./autoload/markdown.kak; + } + + # Plugins + { + name = "luar"; + src = pkgs.fetchFromGitHub { + owner = "gustavo-hms"; + repo = "luar"; + rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; + sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; + }; + activationScript = '' + # Enable luar + require-module luar + # Use luajit + set-option global luar_interpreter ${pkgs.luajit}/bin/luajit + ''; + } + { + name = "peneira"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "peneira"; + rev = "743b9971472853a752475e7c070ce99089c6840c"; + sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; + }; + activationScript = '' + require-module peneira + + # Change selection color + set-face global PeneiraSelected @PrimarySelection + + # Buffers list + define-command -hidden peneira-buffers %{ + peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ + buffer %arg{1} + } + } + + # Grep in the current location + define-command peneira-grep %{ + peneira 'line: ' "rg -n ." %{ + lua %arg{1} %{ + local file, line = arg[1]:match("([^:]+):(%d+):") + kak.edit(file, line) + } + } + } + + # A peneira menu + declare-user-mode fuzzy-match-menu + + map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" + map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" + map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" + map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" + map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" + map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" + + # Bind menu to user mode + map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" + ''; + } + { + name = "kakoune-focus"; + src = pkgs.fetchFromGitHub { + owner = "caksoylar"; + repo = "kakoune-focus"; + rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; + sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; + }; + activationScript = '' + map global user ': focus-toggle' -docstring "toggle selections focus" + ''; + } + { + name = "kakoune-inc-dec"; + src = pkgs.fetchFromGitLab { + owner = "Screwtapello"; + repo = "kakoune-inc-dec"; + rev = "7bfe9c51"; + sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; + }; + } + { + name = "racket.kak"; + src = (builtins.fetchTree { + type = "git"; + url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; + rev = "e397042009b46916ff089d79166ec0e8ca813a18"; + narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; + }) + "/rc"; + } + # { + # name = "kakoune-discord"; + # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; + # } + rec { + name = "kakoune-mirror"; + src = pkgs.fetchFromGitHub + { + owner = "Delapouite"; + repo = "kakoune-mirror"; + rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; + sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; + } + "/mirror.kak"; + wrapAsModule = true; + activationScript = '' + require-module ${name} + + # Bind to ${name} + map global normal ': enter-user-mode -lock mirror' + ''; + } + { + name = "unicode-math"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "kakoune-unicode-math"; + rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; + # sha256 = lib.fakeSha256; + sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; + fetchSubmodules = true; + }; + activationScript = '' + require-module unicode-math + + # Bind to the menu + map global insert ': insert-unicode ' + ''; + } + { + name = "kakoune-buffers"; + src = pkgs.fetchFromGitHub { + owner = "Delapouite"; + repo = "kakoune-buffers"; + rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; + sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; + }; + activationScript = '' + # Suggested hook + + hook global WinDisplay .* info-buffers + + # Suggested mappings + + map global user b ':enter-buffers-mode' -docstring 'buffers…' + map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' + map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' + + # Suggested aliases + + alias global bd delete-buffer + alias global bf buffer-first + alias global bl buffer-last + alias global bo buffer-only + alias global bo! buffer-only-force + ''; + } + ]; +} + From d160c48ba20cdbb5509095e865421664d11bf2b7 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 28 Sep 2024 16:34:57 +0200 Subject: [PATCH 02/53] kakoune: add back kaktex --- packages/common/nki-kakoune/default.nix | 4 +- .../common/nki-kakoune/kaktex/default.nix | 22 ++ .../common/nki-kakoune/kaktex/kaktex.fish | 26 ++ packages/common/nki-kakoune/plugins.nix | 312 +++++++++--------- 4 files changed, 205 insertions(+), 159 deletions(-) create mode 100644 packages/common/nki-kakoune/kaktex/default.nix create mode 100755 packages/common/nki-kakoune/kaktex/kaktex.fish diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 6e181ce..53622ec 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,3 +1,5 @@ { callPackage, kakoune, ... }: kakoune.override { - plugins = (callPackage ./plugins.nix { }).plugins; + plugins = (callPackage ./plugins.nix { }) ++ [ + ./kaktex + ]; } diff --git a/packages/common/nki-kakoune/kaktex/default.nix b/packages/common/nki-kakoune/kaktex/default.nix new file mode 100644 index 0000000..a8005d5 --- /dev/null +++ b/packages/common/nki-kakoune/kaktex/default.nix @@ -0,0 +1,22 @@ +{ fish, lib, writeScript, writeTextDir, kakouneUtils, ... }: +let + kaktex-script = writeScript "kaktex" '' + #!/usr/bin/env ${lib.getExe fish} + + ${builtins.readFile ./kaktex.fish} + ''; + kaktex = writeTextDir "kaktex.kak" '' + hook global WinSetOption filetype=(tex|latex) %{ + hook window WinDisplay '.*' %{ + eval %sh{ + ${kaktex-script} set $kak_client $kak_session + } + } + } + ''; +in +kakouneUtils.buildKakounePluginFrom2Nix { + pname = "kaktex"; + version = "latest"; + src = kaktex; +} diff --git a/packages/common/nki-kakoune/kaktex/kaktex.fish b/packages/common/nki-kakoune/kaktex/kaktex.fish new file mode 100755 index 0000000..bb6690b --- /dev/null +++ b/packages/common/nki-kakoune/kaktex/kaktex.fish @@ -0,0 +1,26 @@ +function usage + echo "Usage: " + echo " kaktex set [client] [session]" + echo " kaktex jump [file] [line] [column]" + exit 1 +end + +if test (count $argv) -lt 3 + usage +end + +switch $argv[1] + case "set" + set -U _kaktex_client $argv[2] + set -U _kaktex_session $argv[3] + case "jump" + echo " + evaluate-commands -client $_kaktex_client %{ + evaluate-commands -try-client $_kaktex_client %{ + edit -existing -- $argv[2] $(math $argv[3] + 1) $(math $argv[4] + 1) + } + } + " | kak -p $_kaktex_session + case '*' + usage +end diff --git a/packages/common/nki-kakoune/plugins.nix b/packages/common/nki-kakoune/plugins.nix index a16c898..b524a14 100644 --- a/packages/common/nki-kakoune/plugins.nix +++ b/packages/common/nki-kakoune/plugins.nix @@ -34,176 +34,172 @@ let }; }; in -{ - plugins = builtins.map kakounePlugin - [ - # My own scripts - { - name = "latex.kak"; - src = toDir "latex.kak" ./autoload/latex.kak; - } - { - name = "markdown.kak"; - src = toDir "markdown.kak" ./autoload/markdown.kak; - } +builtins.map kakounePlugin [ + # My own scripts + { + name = "latex.kak"; + src = toDir "latex.kak" ./autoload/latex.kak; + } + { + name = "markdown.kak"; + src = toDir "markdown.kak" ./autoload/markdown.kak; + } - # Plugins - { - name = "luar"; - src = pkgs.fetchFromGitHub { - owner = "gustavo-hms"; - repo = "luar"; - rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; - sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; - }; - activationScript = '' - # Enable luar - require-module luar - # Use luajit - set-option global luar_interpreter ${pkgs.luajit}/bin/luajit - ''; - } - { - name = "peneira"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "peneira"; - rev = "743b9971472853a752475e7c070ce99089c6840c"; - sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; - }; - activationScript = '' - require-module peneira + # Plugins + { + name = "luar"; + src = pkgs.fetchFromGitHub { + owner = "gustavo-hms"; + repo = "luar"; + rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; + sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; + }; + activationScript = '' + # Enable luar + require-module luar + # Use luajit + set-option global luar_interpreter ${pkgs.luajit}/bin/luajit + ''; + } + { + name = "peneira"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "peneira"; + rev = "743b9971472853a752475e7c070ce99089c6840c"; + sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; + }; + activationScript = '' + require-module peneira - # Change selection color - set-face global PeneiraSelected @PrimarySelection + # Change selection color + set-face global PeneiraSelected @PrimarySelection - # Buffers list - define-command -hidden peneira-buffers %{ - peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ - buffer %arg{1} - } + # Buffers list + define-command -hidden peneira-buffers %{ + peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ + buffer %arg{1} } + } - # Grep in the current location - define-command peneira-grep %{ - peneira 'line: ' "rg -n ." %{ - lua %arg{1} %{ - local file, line = arg[1]:match("([^:]+):(%d+):") - kak.edit(file, line) - } - } + # Grep in the current location + define-command peneira-grep %{ + peneira 'line: ' "rg -n ." %{ + lua %arg{1} %{ + local file, line = arg[1]:match("([^:]+):(%d+):") + kak.edit(file, line) } - - # A peneira menu - declare-user-mode fuzzy-match-menu - - map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" - map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" - map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" - map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" - map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" - map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" - - # Bind menu to user mode - map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" - ''; + } } + + # A peneira menu + declare-user-mode fuzzy-match-menu + + map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" + map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" + map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" + map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" + map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" + map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" + + # Bind menu to user mode + map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" + ''; + } + { + name = "kakoune-focus"; + src = pkgs.fetchFromGitHub { + owner = "caksoylar"; + repo = "kakoune-focus"; + rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; + sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; + }; + activationScript = '' + map global user ': focus-toggle' -docstring "toggle selections focus" + ''; + } + { + name = "kakoune-inc-dec"; + src = pkgs.fetchFromGitLab { + owner = "Screwtapello"; + repo = "kakoune-inc-dec"; + rev = "7bfe9c51"; + sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; + }; + } + { + name = "racket.kak"; + src = (builtins.fetchTree { + type = "git"; + url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; + rev = "e397042009b46916ff089d79166ec0e8ca813a18"; + narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; + }) + "/rc"; + } + # { + # name = "kakoune-discord"; + # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; + # } + rec { + name = "kakoune-mirror"; + src = pkgs.fetchFromGitHub { - name = "kakoune-focus"; - src = pkgs.fetchFromGitHub { - owner = "caksoylar"; - repo = "kakoune-focus"; - rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; - sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; - }; - activationScript = '' - map global user ': focus-toggle' -docstring "toggle selections focus" - ''; - } - { - name = "kakoune-inc-dec"; - src = pkgs.fetchFromGitLab { - owner = "Screwtapello"; - repo = "kakoune-inc-dec"; - rev = "7bfe9c51"; - sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; - }; - } - { - name = "racket.kak"; - src = (builtins.fetchTree { - type = "git"; - url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; - rev = "e397042009b46916ff089d79166ec0e8ca813a18"; - narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; - }) + "/rc"; - } - # { - # name = "kakoune-discord"; - # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; - # } - rec { - name = "kakoune-mirror"; - src = pkgs.fetchFromGitHub - { - owner = "Delapouite"; - repo = "kakoune-mirror"; - rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; - sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; - } + "/mirror.kak"; - wrapAsModule = true; - activationScript = '' - require-module ${name} + owner = "Delapouite"; + repo = "kakoune-mirror"; + rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; + sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; + } + "/mirror.kak"; + wrapAsModule = true; + activationScript = '' + require-module ${name} - # Bind to ${name} - map global normal ': enter-user-mode -lock mirror' - ''; - } - { - name = "unicode-math"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "kakoune-unicode-math"; - rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; - # sha256 = lib.fakeSha256; - sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; - fetchSubmodules = true; - }; - activationScript = '' - require-module unicode-math + # Bind to ${name} + map global normal ': enter-user-mode -lock mirror' + ''; + } + { + name = "unicode-math"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "kakoune-unicode-math"; + rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; + # sha256 = lib.fakeSha256; + sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; + fetchSubmodules = true; + }; + activationScript = '' + require-module unicode-math - # Bind to the menu - map global insert ': insert-unicode ' - ''; - } - { - name = "kakoune-buffers"; - src = pkgs.fetchFromGitHub { - owner = "Delapouite"; - repo = "kakoune-buffers"; - rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; - sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; - }; - activationScript = '' - # Suggested hook + # Bind to the menu + map global insert ': insert-unicode ' + ''; + } + { + name = "kakoune-buffers"; + src = pkgs.fetchFromGitHub { + owner = "Delapouite"; + repo = "kakoune-buffers"; + rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; + sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; + }; + activationScript = '' + # Suggested hook - hook global WinDisplay .* info-buffers + hook global WinDisplay .* info-buffers - # Suggested mappings + # Suggested mappings - map global user b ':enter-buffers-mode' -docstring 'buffers…' - map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' - map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' + map global user b ':enter-buffers-mode' -docstring 'buffers…' + map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' + map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' - # Suggested aliases - - alias global bd delete-buffer - alias global bf buffer-first - alias global bl buffer-last - alias global bo buffer-only - alias global bo! buffer-only-force - ''; - } - ]; -} + # Suggested aliases + alias global bd delete-buffer + alias global bf buffer-first + alias global bl buffer-last + alias global bo buffer-only + alias global bo! buffer-only-force + ''; + } +] From 8e886fd13bf50bd01f8b8f685bf3ea6cd71bbfab Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 28 Sep 2024 16:54:39 +0200 Subject: [PATCH 03/53] kakoune: add back themes --- packages/common/nki-kakoune/default.nix | 4 +- packages/common/nki-kakoune/themes.nix | 9 +++ .../nki-kakoune/themes/catppuccin-latte.kak | 79 +++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 packages/common/nki-kakoune/themes.nix create mode 100644 packages/common/nki-kakoune/themes/catppuccin-latte.kak diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 53622ec..2c6a83d 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,5 +1,7 @@ { callPackage, kakoune, ... }: kakoune.override { - plugins = (callPackage ./plugins.nix { }) ++ [ + plugins = callPackage ./plugins.nix { } + ++ callPackage ./themes.nix { } + ++ [ ./kaktex ]; } diff --git a/packages/common/nki-kakoune/themes.nix b/packages/common/nki-kakoune/themes.nix new file mode 100644 index 0000000..5be9a6d --- /dev/null +++ b/packages/common/nki-kakoune/themes.nix @@ -0,0 +1,9 @@ +{ writeScriptDir, ... }: +let + themes = [ + { name = "catppuccin-latte"; src = ./themes/catppucin-latte.kak; } + ]; + + themeToColorscheme = name: src: writeScriptDir "share/kak/colors/${name}.kak" (builtins.readFile src); +in +builtins.map themeToColorscheme themes diff --git a/packages/common/nki-kakoune/themes/catppuccin-latte.kak b/packages/common/nki-kakoune/themes/catppuccin-latte.kak new file mode 100644 index 0000000..bd40ead --- /dev/null +++ b/packages/common/nki-kakoune/themes/catppuccin-latte.kak @@ -0,0 +1,79 @@ +# Catppuccin theme for Kakoune + +declare-option str rosewater "rgb:dc8a78" +declare-option str flamingo "rgb:dd7878" +declare-option str pink "rgb:ea76cb" +declare-option str mauve "rgb:8839ef" +declare-option str red "rgb:d20f39" +declare-option str maroon "rgb:e64553" +declare-option str peach "rgb:fe640b" +declare-option str yellow "rgb:df8e1d" +declare-option str green "rgb:40a02b" +declare-option str teal "rgb:179299" +declare-option str sky "rgb:04a5e5" +declare-option str sapphire "rgb:209fb5" +declare-option str blue "rgb:1e66f5" +declare-option str lavender "rgb:7287fd" +declare-option str text "rgb:4c4f69" +declare-option str subtext1 "rgb:5c5f77" +declare-option str subtext0 "rgb:6c6f85" +declare-option str overlay2 "rgb:7c7f93" +declare-option str overlay1 "rgb:8c8fa1" +declare-option str overlay0 "rgb:9ca0b0" +declare-option str surface2 "rgb:acb0be" +declare-option str surface1 "rgb:bcc0cc" +declare-option str surface0 "rgb:ccd0da" +declare-option str base "rgb:eff1f5" +declare-option str mantle "rgb:e6e9ef" +declare-option str crust "rgb:dce0e8" + + +set-face global title "%opt{text}+b" +set-face global header "%opt{subtext0}+b" +set-face global bold "%opt{maroon}+b" +set-face global italic "%opt{maroon}+i" +set-face global mono "%opt{green}" +set-face global block "%opt{sapphire}" +set-face global link "%opt{blue}" +set-face global bullet "%opt{peach}" +set-face global list "%opt{peach}" + +set-face global Default "%opt{text},%opt{base}" +set-face global PrimarySelection "%opt{text},%opt{surface2}" +set-face global SecondarySelection "%opt{text},%opt{surface2}" +set-face global PrimaryCursor "%opt{crust},%opt{rosewater}" +set-face global SecondaryCursor "%opt{text},%opt{overlay0}" +set-face global PrimaryCursorEol "%opt{surface2},%opt{lavender}" +set-face global SecondaryCursorEol "%opt{surface2},%opt{overlay1}" +set-face global LineNumbers "%opt{overlay1},%opt{base}" +set-face global LineNumberCursor "%opt{rosewater},%opt{surface2}+b" +set-face global LineNumbersWrapped "%opt{rosewater},%opt{surface2}+i" +set-face global MenuForeground "%opt{text},%opt{surface1}+b" +set-face global MenuBackground "%opt{text},%opt{surface0}" +set-face global MenuInfo "%opt{crust},%opt{teal}" +set-face global Information "%opt{crust},%opt{teal}" +set-face global Error "%opt{crust},%opt{red}" +set-face global StatusLine "%opt{text},%opt{mantle}" +set-face global StatusLineMode "%opt{crust},%opt{yellow}" +set-face global StatusLineInfo "%opt{crust},%opt{teal}" +set-face global StatusLineValue "%opt{crust},%opt{yellow}" +set-face global StatusCursor "%opt{crust},%opt{rosewater}" +set-face global Prompt "%opt{teal},%opt{base}+b" +set-face global MatchingChar "%opt{maroon},%opt{base}" +set-face global Whitespace "%opt{overlay1},%opt{base}+f" +set-face global WrapMarker "Whitespace" +set-face global BufferPadding "%opt{base},%opt{base}" + +set-face global value "%opt{peach}" +set-face global type "%opt{blue}" +set-face global variable "%opt{text}" +set-face global module "%opt{maroon}" +set-face global function "%opt{blue}" +set-face global string "%opt{green}" +set-face global keyword "%opt{mauve}" +set-face global operator "%opt{sky}" +set-face global attribute "%opt{green}" +set-face global comment "%opt{overlay0}" +set-face global documentation "comment" +set-face global meta "%opt{yellow}" +set-face global builtin "%opt{red}" From 8a19a3d900db4ad1148e661aaff78e56e8c4bcca Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 14:30:47 +0200 Subject: [PATCH 04/53] Add lsp and rc --- home/common.nix | 1 + overlay.nix | 2 + packages/common/nki-kakoune/default.nix | 22 +- packages/common/nki-kakoune/kakrc | 191 ++++++++++++ packages/common/nki-kakoune/lsp.nix | 307 ++++++++++++++++++++ packages/common/nki-kakoune/rc.nix | 18 ++ packages/common/nki-kakoune/source-pwd.fish | 14 + packages/common/nki-kakoune/themes.nix | 6 +- packages/common/nki-kakoune/utils.nix | 5 + 9 files changed, 560 insertions(+), 6 deletions(-) create mode 100644 packages/common/nki-kakoune/kakrc create mode 100644 packages/common/nki-kakoune/lsp.nix create mode 100644 packages/common/nki-kakoune/rc.nix create mode 100755 packages/common/nki-kakoune/source-pwd.fish create mode 100644 packages/common/nki-kakoune/utils.nix diff --git a/home/common.nix b/home/common.nix index 253c8b1..feeab1c 100644 --- a/home/common.nix +++ b/home/common.nix @@ -41,6 +41,7 @@ unzip zstd atool + nki-kakoune ]; home.sessionVariables = { diff --git a/overlay.nix b/overlay.nix index 88159df..60fa42d 100644 --- a/overlay.nix +++ b/overlay.nix @@ -113,6 +113,8 @@ let buildInputs = (with final; lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Security SystemConfiguration CoreServices ]) ) ++ (with final; [ libiconv ]); + + meta.mainProgram = "kak-lsp"; }; zen-browser-bin = final.callPackage ./packages/x86_64-linux/zen-browser-bin.nix { diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 2c6a83d..bb65355 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,7 +1,23 @@ -{ callPackage, kakoune, ... }: kakoune.override { +{ callPackage, kakoune, kakoune-unwrapped, ... }: +let + lsp = callPackage ./lsp.nix { }; +in +(kakoune.override { plugins = callPackage ./plugins.nix { } ++ callPackage ./themes.nix { } ++ [ - ./kaktex + (callPackage ./kaktex { }) + (callPackage ./rc.nix { }) + lsp.plugin ]; -} +}).overrideAttrs (attrs: { + buildCommand = '' + ${attrs.buildCommand or ""} + # location of kak binary is used to find ../share/kak/autoload, + # unless explicitly overriden with KAKOUNE_RUNTIME + rm "$out/bin/kak" + makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ + --set KAKOUNE_RUNTIME "$out/share/kak" \ + --suffix PATH ":" "${lsp.extraPaths}" + ''; +}) diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc new file mode 100644 index 0000000..aafa044 --- /dev/null +++ b/packages/common/nki-kakoune/kakrc @@ -0,0 +1,191 @@ +# Enable kak-tree-sitter +eval %sh{test -z "$WE_STARTED_KAK" && kak-tree-sitter --kakoune -d --server --init $kak_session} +map global normal ": enter-user-mode tree-sitter" +# ## Set some color overrides +# set global kts_yellow "rgb:e2b75e" +# set global kts_teal "rgb:008080" +# set global kts_mauve "rgb:c264ff" +# set global kts_sky "rgb:6aa622" +# Color scheme +colorscheme catppuccin-latte +set global base "default" + +# Set indentation guides +add-highlighter global/indent-guides show-whitespaces -tab " " -spc " " -lf " " -nbsp " " +set-face global Whitespace default,default +set-face global WhitespaceIndent +d@comment + +# Assistant +set global ui_options terminal_assistant=cat + +# Enable line numbers +hook global WinCreate .* %{ + addhl window/number-lines number-lines +} + +set global grepcmd "rg --line-number --no-column --no-heading --color=never " + +# Kitty-specific options +hook -group windowing global KakBegin .* %{ + set global kitty_window_type os-window +} + +# Comment line and block +map global normal <#> ': comment-line' +map global normal ': comment-block' + +# Go to grep-jump +map global goto f -docstring "current grep-jump match" ': grep-jump' + +# System clipboard interactions +hook global RegisterModified '"' %{ nop %sh{ + printf "%s" "$kak_main_reg_dquote" | pbcopy >/dev/null 2>/dev/null & +}} +map global user P -docstring "Paste before cursor from clipboard" '! pbpaste -n | cat' +map global user p -docstring "Paste after cursor from clipboard" ' pbpaste -n | cat' +map global user R -docstring "Replace selection with text from clipboard" '! pbpaste -n | cat' +define-command -params 0 -docstring "Copy line down" copyline %{ + execute-keys -draft 'xy'%val{count}'P' +} +map global normal <+> -docstring "Copy line down" ': copyline' +define-command -params 0 -docstring "Delete current pair of brackets" delete-current-brackets %{ + execute-keys 'm' + execute-keys -draft 'd' + execute-keys 'H' +} +map global normal D ": delete-current-brackets" + +# Disable write-to +# unalias global w +# define-command -params 0 -docstring "Writes the current file" w "write" + +# Tab sizes +hook global InsertChar \t %{ exec -draft -itersel h@ } +set global tabstop 2 +set global indentwidth 2 + +# Language-specific tabstop with override +hook global WinSetOption filetype=(rust) %{ + set window tabstop 4 + set window indentwidth 4 +} + +# Ctrl + a in insert mode = esc +map global insert '' + +# Tab completion +hook global InsertCompletionShow .* %{ + try %{ + # this command temporarily removes cursors preceded by whitespace; + # if there are no cursors left, it raises an error, does not + # continue to execute the mapping commands, and the error is eaten + # by the `try` command so no warning appears. + execute-keys -draft 'h\h' + map window insert + map window insert + } +} +hook global InsertCompletionHide .* %{ + unmap window insert + unmap window insert +} + +# in Insert mode moves to end of line. +map global insert 'A' + +hook global WinSetOption filetype=(fsharp) %{ + set-option window comment_line "//" + # Set up formatting + # set-option window formatcmd "~/.dotnet/tools/fantomas --stdin --stdout" + # hook window -group fsharp-format BufWritePre .* %{ format } +} + +hook global WinSetOption filetype=(ocaml) %{ + unset-option buffer comment_line + set-option buffer comment_block_begin "(*" + set-option buffer comment_block_end "*)" +} + +hook global WinSetOption filetype=(haskell) %{ + set-option buffer makecmd "cabal build" +} + +hook global WinSetOption filetype=(rust) %{ + set-option buffer makecmd "cargo check" +} + +hook global WinSetOption filetype=(scala) %{ + # Format the document if possible + hook -group scala-fmt window BufWritePre .* %{ lsp-formatting-sync } +} + +hook global WinSetOption filetype=(typst) %{ + set-option window comment_line "//" + set-option window comment_block_begin "/*" + set-option window comment_block_end "*/" + + # borrow markdown's hooks + require-module markdown + + hook window ModeChange pop:insert:.* -group markdown-trim-indent markdown-trim-indent + hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line + hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } +} + +define-command -params 0 -docstring "Set up build" scala-build-connect %{ + lsp-execute-command 'build-connect' '"[]"' +} + +define-command -params 0 -docstring "Import build" scala-build-import %{ + lsp-execute-command 'build-import' '"[]"' +} + +def -hidden insert-c-n %{ + try %{ + lsp-snippets-select-next-placeholders + exec 'd' + } catch %{ + exec -with-hooks '' + } +} +map global insert ": insert-c-n" + +# Use C++ for .h headers +hook global BufCreate .*[.](h) %{ + set-option buffer filetype cpp +} + +hook global BufCreate .*[.]kakrc %{ + set-option buffer filetype kak +} + +hook global BufCreate .*[.]md %{ + add-highlighter buffer/ wrap +} + +hook global BufCreate .*[.](sc|sbt) %{ + set-option buffer filetype scala +} + +hook global BufCreate .*[.]typ %{ + set-option buffer filetype typst + add-highlighter buffer/ wrap +} + +hook global BufCreate .*[.]templ %{ + set-option buffer filetype templ + set-option buffer comment_line "//" +} + +hook global BufCreate .*[.]hylo %{ + set-option buffer filetype hylo + set-option buffer comment_line "//" +} + +hook global BufOpenFile .* %{ + modeline-parse +} + +map global normal ':inc-dec-modify-numbers + %val{count}' +map global normal ':inc-dec-modify-numbers - %val{count}' diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix new file mode 100644 index 0000000..3712d6f --- /dev/null +++ b/packages/common/nki-kakoune/lsp.nix @@ -0,0 +1,307 @@ +{ lib +, writeTextDir +, formats +, kak-lsp +, # LSP packages + ccls +, gopls +, nil +, nixpkgs-fmt +, python311Packages +, ltex-ls +, nodePackages +, tailwindcss-language-server +, fsautocomplete +, metals +, texlab +, marksman +, rust-analyzer +, ... +}: +let + # Configuration for kak-lsp + config = { + languageIDs = { + c = "c_cpp"; + cpp = "c_cpp"; + javascript = "javascriptreact"; + typescript = "typescriptreact"; + protobuf = "proto"; + sh = "shellscript"; + }; + + languageServers = + let + vscodeServerOf = name: { + name = "vscode-${name}-language-server"; + value = { + args = [ "--stdio" ]; + command = "vscode-${name}-language-server"; + filetypes = [ name "templ" ]; + roots = [ "package.json" ".git" ]; + }; + package = nodePackages.vscode-langservers-extracted; + }; + in + { + ccls = { + args = [ "-v=2" "-log-file=/tmp/ccls.log" ]; + package = ccls; + command = "ccls"; + filetypes = [ "c" "cpp" ]; + roots = [ "compile_commands.json" ".cquery" ".git" ]; + }; + gopls = { + command = "gopls"; + package = gopls; + filetypes = [ "go" ]; + offset_encoding = "utf-8"; + roots = [ "Gopkg.toml" "go.mod" ".git" ".hg" ]; + settings = { gopls = { hoverKind = "SynopsisDocumentation"; semanticTokens = true; }; }; + settings_section = "gopls"; + }; + haskell-language-server = { + args = [ "--lsp" ]; + command = "haskell-language-server-wrapper"; + filetypes = [ "haskell" ]; + roots = [ "Setup.hs" "stack.yaml" "*.cabal" "package.yaml" ]; + settings_section = "haskell"; + }; + nil = { + command = "nil"; + package = nil; + filetypes = [ "nix" ]; + roots = [ "flake.nix" "shell.nix" ".git" ]; + settings.nil = { + formatting.command = [ "${lib.getExe nixpkgs-fmt}" ]; + }; + }; + pylsp = { + command = "pylsp"; + package = python311Packages.python-lsp-server; + filetypes = [ "python" ]; + offset_encoding = "utf-8"; + roots = [ "requirements.txt" "setup.py" ".git" ".hg" ]; + }; + # Spellchecking server + ltex-ls = { + command = "ltex-ls"; + args = [ "--log-file=/tmp" ]; + filetypes = [ "latex" "typst" ]; + roots = [ "main.tex" "main.typ" ".git" ]; + package = ltex-ls; + }; + tailwind = { + command = "tailwindcss-language-server"; + args = [ "--stdio" ]; + filetypes = [ "html" "css" "javascript" "typescript" "templ" ]; + roots = [ "tailwind.config.{js,cjs,mjs,ts}" "package.json" ".git" ]; + settings_section = "tailwindCSS"; + settings.tailwindCSS = { + validate = "warning"; + userLanguages.templ = "html"; + }; + package = tailwindcss-language-server; + }; + elixir-ls = { + args = [ ]; + command = "elixir-ls"; + filetypes = [ "elixir" ]; + roots = [ "mix.exs" ]; + }; + typescript-language-server = { + args = [ "--stdio" ]; + command = "typescript-language-server"; + filetypes = [ "typescript" "javascript" ]; + roots = [ "package.json" ]; + package = nodePackages.typescript-language-server; + }; + fsautocomplete = { + args = [ "--adaptive-lsp-server-enabled" "--project-graph-enabled" "--source-text-factory" "RoslynSourceText" ]; + command = "fsautocomplete"; + filetypes = [ "fsharp" ]; + roots = [ "*.fsproj" ]; + settings_section = "FSharp"; + settings.FSharp = { + AutomaticWorkspaceInit = true; + }; + package = fsautocomplete; + }; + metals = { + command = "metals"; + filetypes = [ "scala" ]; + roots = [ "build.sbt" "build.sc" ]; + settings_section = "metals"; + settings.metals = { + enableSemanticHighlighting = true; + showInferredType = true; + decorationProvider = true; + inlineDecorationProvider = true; + # From kakoune-lsp's own options + icons = "unicode"; + isHttpEnabled = true; + statusBarProvider = "log-message"; + compilerOptions = { overrideDefFormat = "unicode"; }; + }; + package = metals; + }; + texlab = { + command = "texlab"; + filetypes = [ "latex" ]; + roots = [ "main.tex" "all.tex" ".git" ]; + settings_section = "texlab"; + settings.texlab = { + build.executable = "latexmk"; + build.args = [ "-pdf" "-shell-escape" "-interaction=nonstopmode" "-synctex=1" "%f" ]; + + build.forwardSearchAfter = true; + build.onSave = true; + + # forwardSearch = + # (if pkgs.stdenv.isDarwin then { + # executable = "/Applications/Skim.app/Contents/SharedSupport/displayline"; + # args = [ "-r" "-g" "%l" "%p" "%f" ]; + # } else + # { + # executable = "${pkgs.zathura}/bin/zathura"; + # args = [ "--synctex-forward" "%l:1:%f" "%p" "-x" "${./kaktex} jump %%{input} %%{line} %%{column}" ]; + # }); + }; + package = texlab; + }; + typst-lsp = { + command = "typst-lsp"; + filetypes = [ "typst" ]; + roots = [ "main.typ" ".git" ]; + settings_section = "typst-lsp"; + settings.typst-lsp = { + experimentalFormatterMode = "on"; + }; + }; + marksman = { + command = "marksman"; + filetypes = [ "markdown" ]; + roots = [ ".marksman.toml" ".git" ]; + package = marksman; + }; + rust-analyzer = { + args = [ ]; + command = "rust-analyzer"; + filetypes = [ "rust" ]; + roots = [ "Cargo.toml" ]; + package = rust-analyzer; + }; + + } // (builtins.listToAttrs (builtins.map vscodeServerOf [ "html" "css" "json" ])); + + faces = [ + ## Items + # (Rust) Macros + { face = "attribute"; token = "attribute"; } + { face = "attribute"; token = "derive"; } + { face = "macro"; token = "macro"; } # Function-like Macro + # Keyword and Fixed Tokens + { face = "keyword"; token = "keyword"; } + { face = "operator"; token = "operator"; } + # Functions and Methods + { face = "function"; token = "function"; } + { face = "method"; token = "method"; } + # Constants + { face = "string"; token = "string"; } + { face = "format_specifier"; token = "formatSpecifier"; } + # Variables + { face = "variable"; token = "variable"; modifiers = [ "readonly" ]; } + { face = "mutable_variable"; token = "variable"; } + { face = "module"; token = "namespace"; } + { face = "variable"; token = "type_parameter"; } + { face = "class"; token = "enum"; } + { face = "class"; token = "struct"; } + { face = "class"; token = "trait"; } + { face = "class"; token = "union"; } + { face = "class"; token = "class"; } + + ## Comments + { face = "documentation"; token = "comment"; modifiers = [ "documentation" ]; } + { face = "comment"; token = "comment"; } + + # Typst + { face = "header"; token = "heading"; } + { face = "ts_markup_link_url"; token = "link"; } + { face = "ts_markup_link_uri"; token = "ref"; } + { face = "ts_markup_link_label"; token = "label"; } + { face = "ts_property"; token = "pol"; } + { face = "ts_markup_list_checked"; token = "marker"; } + { face = "ts_constant_builtin_boolean"; token = "bool"; } + { face = "ts_keyword_control"; token = "delim"; } + { face = "ts_number"; token = "text"; modifiers = [ "math" ]; } + { face = "ts_markup_bold"; token = "text"; modifiers = [ "strong" ]; } + { face = "ts_markup_italic"; token = "text"; modifiers = [ "emph" ]; } + ]; + + raw = { + server = { timeout = 1800; }; + snippet_support = false; + verbosity = 255; + }; + }; + + kak-lsp-config = + let + toml = formats.toml { }; + toLspConfig = attrs: builtins.removeAttrs attrs [ "package" ]; + in + toml.generate "kak-lsp.toml" ({ + semantic_tokens.faces = config.faces; + language_server = toLspConfig config.languageServers; + language_ids = config.languageIDs; + } // config.raw); + + serverPackages = + builtins.filter (v: v != null) + (lib.mapAttrsToList (_: serv: serv.package or null) config.languageServers); +in +{ + extraPaths = lib.makeBinPath serverPackages; + plugin = writeTextDir "share/kak/autoload/kak-lsp.kak" '' + hook global KakBegin .* %{ + try %{ + eval %sh{${lib.getExe kak-lsp} --config ${kak-lsp-config} -s $kak_session} + } + + lsp-enable + map window lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" + map window normal ": enter-user-mode lsp" + map window normal ": lsp-hover" + map window normal ": lsp-hover-buffer" + # lsp-auto-hover-insert-mode-enable + set window lsp_hover_anchor true + map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' + map global object a 'lsp-object' -docstring 'LSP any symbol' + map global object 'lsp-object' -docstring 'LSP any symbol' + map global object f 'lsp-object Function Method' -docstring 'LSP function or method' + map global object t 'lsp-object Class Interface Struct' -docstring 'LSP class interface or struct' + map global object d 'lsp-diagnostic-object --include-warnings' -docstring 'LSP errors and warnings' + map global object D 'lsp-diagnostic-object' -docstring 'LSP errors' + + hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|haskell|nix|fsharp|templ) %{ + # Format the document if possible + hook window BufWritePre .* %{ lsp-formatting-sync } + } + + hook global WinSetOption filetype=(rust|scala|fsharp) %{ + # Enable inlay hints + lsp-inlay-hints-enable window + } + + hook global WinSetOption filetype=(rust|go|fsharp|typst|scala) %{ + hook window -group semantic-tokens BufReload .* lsp-semantic-tokens + hook window -group semantic-tokens NormalIdle .* lsp-semantic-tokens + hook window -group semantic-tokens InsertIdle .* lsp-semantic-tokens + hook -once -always window WinSetOption filetype=.* %{ + remove-hooks window semantic-tokens + } + } + } + ''; +} + diff --git a/packages/common/nki-kakoune/rc.nix b/packages/common/nki-kakoune/rc.nix new file mode 100644 index 0000000..fa4c94d --- /dev/null +++ b/packages/common/nki-kakoune/rc.nix @@ -0,0 +1,18 @@ +{ lib, fish, writeScript, writeTextDir, ... }: + +let + source-pwd = writeScript "source-pwd" '' + #!/usr/bin/env ${lib.getExe fish} + + ${builtins.readFile ./source-pwd.fish} + ''; +in +writeTextDir "share/kak/kakrc.local" '' + ${builtins.readFile ./kakrc} + + # Source any settings in the current working directory, + # recursive upwards + evaluate-commands %sh{ + ${source-pwd} + } +'' diff --git a/packages/common/nki-kakoune/source-pwd.fish b/packages/common/nki-kakoune/source-pwd.fish new file mode 100755 index 0000000..aa9aa37 --- /dev/null +++ b/packages/common/nki-kakoune/source-pwd.fish @@ -0,0 +1,14 @@ +if test (pwd) = "/home/natsukagami/.config/kak" + exit 0 +end + +while true + set kakrc (pwd)/.kakrc + if test -f $kakrc + echo source $kakrc + end + if test (pwd) = "/" + exit 0 + end + cd .. +end diff --git a/packages/common/nki-kakoune/themes.nix b/packages/common/nki-kakoune/themes.nix index 5be9a6d..5c24299 100644 --- a/packages/common/nki-kakoune/themes.nix +++ b/packages/common/nki-kakoune/themes.nix @@ -1,9 +1,9 @@ -{ writeScriptDir, ... }: +{ writeTextDir, ... }: let themes = [ - { name = "catppuccin-latte"; src = ./themes/catppucin-latte.kak; } + { name = "catppuccin-latte"; src = ./themes/catppuccin-latte.kak; } ]; - themeToColorscheme = name: src: writeScriptDir "share/kak/colors/${name}.kak" (builtins.readFile src); + themeToColorscheme = { name, src }: writeTextDir "share/kak/colors/${name}.kak" (builtins.readFile src); in builtins.map themeToColorscheme themes diff --git a/packages/common/nki-kakoune/utils.nix b/packages/common/nki-kakoune/utils.nix new file mode 100644 index 0000000..47e7c75 --- /dev/null +++ b/packages/common/nki-kakoune/utils.nix @@ -0,0 +1,5 @@ +{ lib, writeFile, ... }: { + mkFacesScript = name: faces: writeFile "${name}-faces.kak" ( + lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") faces)) + ); +} From 32e5d3a3a5eb2af508dba9c52828df20773c1c3e Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 16:31:33 +0200 Subject: [PATCH 05/53] Add tree-sitter --- packages/common/kak-tree-sitter.nix | 2 + packages/common/nki-kakoune/default.nix | 7 +- packages/common/nki-kakoune/kakrc | 3 - packages/common/nki-kakoune/rc.nix | 11 +- .../nki-kakoune/tree-sitter/default.nix | 171 ++++++++++++++++++ .../nki-kakoune/tree-sitter/grammars.nix | 119 ++++++++++++ packages/common/nki-kakoune/utils.nix | 10 +- 7 files changed, 314 insertions(+), 9 deletions(-) create mode 100644 packages/common/nki-kakoune/tree-sitter/default.nix create mode 100644 packages/common/nki-kakoune/tree-sitter/grammars.nix diff --git a/packages/common/kak-tree-sitter.nix b/packages/common/kak-tree-sitter.nix index 3e0c6a9..9819e3a 100644 --- a/packages/common/kak-tree-sitter.nix +++ b/packages/common/kak-tree-sitter.nix @@ -35,6 +35,8 @@ let self.runtime_dir.join("sources").join(url_dir) '') ]; + + meta.mainProgram = "kak-tree-sitter"; }; in kak-tree-sitter diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index bb65355..0d48b06 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,13 +1,18 @@ { callPackage, kakoune, kakoune-unwrapped, ... }: let lsp = callPackage ./lsp.nix { }; + tree-sitter = callPackage ./tree-sitter { }; + rc = (callPackage ./rc.nix { + prependRc = tree-sitter.rc; + }); in (kakoune.override { plugins = callPackage ./plugins.nix { } ++ callPackage ./themes.nix { } ++ [ (callPackage ./kaktex { }) - (callPackage ./rc.nix { }) + rc + tree-sitter.plugin lsp.plugin ]; }).overrideAttrs (attrs: { diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc index aafa044..dc06ca3 100644 --- a/packages/common/nki-kakoune/kakrc +++ b/packages/common/nki-kakoune/kakrc @@ -1,6 +1,3 @@ -# Enable kak-tree-sitter -eval %sh{test -z "$WE_STARTED_KAK" && kak-tree-sitter --kakoune -d --server --init $kak_session} -map global normal ": enter-user-mode tree-sitter" # ## Set some color overrides # set global kts_yellow "rgb:e2b75e" # set global kts_teal "rgb:008080" diff --git a/packages/common/nki-kakoune/rc.nix b/packages/common/nki-kakoune/rc.nix index fa4c94d..ac579c9 100644 --- a/packages/common/nki-kakoune/rc.nix +++ b/packages/common/nki-kakoune/rc.nix @@ -1,4 +1,11 @@ -{ lib, fish, writeScript, writeTextDir, ... }: +{ lib +, fish +, writeScript +, writeTextDir +, prependRc ? "" +, appendRc ? "" +, ... +}: let source-pwd = writeScript "source-pwd" '' @@ -8,7 +15,9 @@ let ''; in writeTextDir "share/kak/kakrc.local" '' + ${prependRc} ${builtins.readFile ./kakrc} + ${appendRc} # Source any settings in the current working directory, # recursive upwards diff --git a/packages/common/nki-kakoune/tree-sitter/default.nix b/packages/common/nki-kakoune/tree-sitter/default.nix new file mode 100644 index 0000000..ce16343 --- /dev/null +++ b/packages/common/nki-kakoune/tree-sitter/default.nix @@ -0,0 +1,171 @@ +{ lib +, callPackage +, formats +, runCommandLocal +, kak-tree-sitter +, ... +}: +let + utils = callPackage ../utils.nix { }; + grammars = (callPackage ./grammars.nix { }).grammars; + # Highlighter groups to add to the `highlighterGroups`. Maps from group names to face names. + highlighterGroups = { + attribute = "@attribute"; + comment = "@comment"; + conceal = "%opt{mauve}+i"; + constant = "%opt{peach}"; + constant_builtin_boolean = "%opt{sky}"; + constant_character = "%opt{yellow}"; + constant_macro = "%opt{mauve}"; + constant_numeric = "%opt{peach}"; + constructor = "%opt{sapphire}"; + diff_plus = "%opt{green}"; + diff_minus = "%opt{red}"; + diff_delta = "%opt{blue}"; + diff_delta_moved = "%opt{mauve}"; + error = "%opt{red}+b"; + function = "@function"; + function_builtin = "@builtin"; + function_macro = "+i@ts_function"; + hint = "%opt{blue}+b"; + info = "%opt{green}+b"; + keyword = "keyword"; + keyword_conditional = "+i@ts_keyword"; + keyword_control_conditional = "+i@ts_keyword"; + keyword_control_directive = "+i@ts_keyword"; + keyword_control_import = "+i@ts_keyword"; + keyword_directive = "+i@ts_keyword"; + label = "%opt{sapphire}+i"; + markup_bold = "%opt{peach}+b"; + markup_heading = "%opt{red}"; + markup_heading_1 = "%opt{red}"; + markup_heading_2 = "%opt{mauve}"; + markup_heading_3 = "%opt{green}"; + markup_heading_4 = "%opt{yellow}"; + markup_heading_5 = "%opt{pink}"; + markup_heading_6 = "%opt{teal}"; + markup_heading_marker = "%opt{peach}+b"; + markup_italic = "%opt{pink}+i"; + markup_list_checked = "%opt{green}"; + markup_list_numbered = "%opt{blue}+i"; + markup_list_unchecked = "%opt{teal}"; + markup_list_unnumbered = "%opt{mauve}"; + markup_link_label = "%opt{blue}"; + markup_link_url = "%opt{teal}+u"; + markup_link_uri = "%opt{teal}+u"; + markup_link_text = "%opt{blue}"; + markup_quote = "%opt{crust}"; + markup_raw = "%opt{sky}"; + markup_raw_block = "%opt{sky}"; + markup_raw_inline = "%opt{green}"; + markup_strikethrough = "%opt{crust}+s"; + namespace = "@module"; + operator = "@operator"; + property = "%opt{sky}"; + punctuation = "%opt{overlay2}"; + punctuation_special = "%opt{sky}"; + special = "%opt{blue}"; + spell = "%opt{mauve}"; + string = "%opt{green}"; + string_regex = "%opt{peach}"; + string_regexp = "%opt{peach}"; + string_escape = "%opt{mauve}"; + string_special = "%opt{blue}"; + string_special_path = "%opt{green}"; + string_special_symbol = "%opt{mauve}"; + string_symbol = "%opt{red}"; + tag = "%opt{teal}"; + tag_error = "%opt{red}"; + text_title = "%opt{mauve}"; + type = "@type"; + type_enum_variant = "+i@ts_type"; + variable = "@variable"; + variable_builtin = "@builtin"; + variable_other_member = "%opt{teal}"; + variable_parameter = "+i@variable"; + warning = "%opt{peach}+b"; + }; + + # Highlighter groups to be aliased by other groups + aliases = { + comment_block = "comment"; + comment_line = "comment"; + constant_character_escape = "constant_character"; + constant_numeric_float = "constant_numeric"; + constant_numeric_integer = "constant_numeric"; + function_method = "function"; + function_special = "function"; + keyword_control = "keyword"; + keyword_control_repeat = "keyword"; + keyword_control_return = "keyword"; + keyword_control_except = "keyword"; + keyword_control_exception = "keyword"; + keyword_function = "keyword"; + keyword_operator = "keyword"; + keyword_special = "keyword"; + keyword_storage = "keyword"; + keyword_storage_modifier = "keyword"; + keyword_storage_modifier_mut = "keyword"; + keyword_storage_modifier_ref = "keyword"; + keyword_storage_type = "keyword"; + punctuation_bracket = "punctuation"; + punctuation_delimiter = "punctuation"; + text = "string"; + type_builtin = "type"; + + # Scala stuff + method = "function"; + module = "namespace"; + function_call = "function"; + method_call = "method"; + + boolean = "constant_builtin_boolean"; + number = "constant_numeric"; + float = "constant_numeric_float"; + + type_qualifier = "keyword_special"; + storageclass = "keyword_storage_modifier"; + conditional = "keyword_conditional"; + include = "keyword_control_import"; + }; + + configDir = + let + toScm = name: lib.concatStringsSep "." (lib.splitString "_" name); + + toml = formats.toml { }; + file = + toml.generate "config.toml" { + highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); + features = { + highlighting = true; + text_objects = true; + }; + language = grammars; + }; + in + runCommandLocal "kak-tree-sitter-config" { } '' + mkdir -p $out/kak-tree-sitter + ln -s ${file} $out/kak-tree-sitter/config.toml + ''; + + extraFaces = + let + toTs = name: "ts_${lib.concatStringsSep "_" (lib.splitString "." name)}"; + + definedFaces = lib.mapAttrs' (name: value: { inherit value; name = toTs name; }) highlighterGroups; + aliasFaces = lib.mapAttrs' (name: value: { name = toTs name; value = "@${toTs value}"; }) aliases; + faces = lib.recursiveUpdate definedFaces aliasFaces; + in + faces; +in +{ + rc = '' + # Enable kak-tree-sitter + eval %sh{env XDG_CONFIG_DIR=${configDir} ${lib.getExe' kak-tree-sitter "kak-tree-sitter"} --kakoune -d --server --init $kak_session} + map global normal ": enter-user-mode tree-sitter" + ''; + + plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces; +} + diff --git a/packages/common/nki-kakoune/tree-sitter/grammars.nix b/packages/common/nki-kakoune/tree-sitter/grammars.nix new file mode 100644 index 0000000..426edb3 --- /dev/null +++ b/packages/common/nki-kakoune/tree-sitter/grammars.nix @@ -0,0 +1,119 @@ +{ lib, stdenv, fetchFromGitHub, runCommandLocal, ... }: +let + mkGrammarPackage = + { name + , src + , grammarPath ? "src" + , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] + , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] + , ... + }: stdenv.mkDerivation { + inherit src; + name = "kak-tree-sitter-grammar-${name}"; + version = "latest"; + buildPhase = '' + mkdir ${grammarPath}/build + cd ${grammarPath}/build + $CC ${lib.concatStringsSep " " grammarCompileArgs} + $CC ${lib.concatStringsSep " " grammarLinkArgs} -o ${name}.so + ''; + installPhase = '' + mkdir $out + cp ${name}.so $out + ''; + }; + mkGrammar = + args @ { name + , src + , grammarPath ? "src" + , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] + , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] + , querySrc ? src + , queryPath ? "runtime/queries/${name}" + , + }: { + grammar.source.local.path = "${mkGrammarPackage args}"; + queries.source.local.path = querySrc; + queries.path = queryPath; + }; + + tree-sitter-go = fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-go"; + rev = "v0.20.0"; + hash = "sha256-G7d8CHCyKDAb9j6ijRfHk/HlgPqSI+uvkuRIRRvjkHI="; + }; +in +{ + grammars = builtins.mapAttrs (name: value: mkGrammar ({ inherit name; } // value)) { + scala = { + src = fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-scala"; + rev = "70afdd5632d57dd63a960972ab25945e353a52f6"; + hash = "sha256-bi0Lqo/Zs2Uaz1efuKAARpEDg5Hm59oUe7eSXgL1Wow="; + }; + queryPath = "queries/scala"; + }; + haskell = { + src = fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-haskell"; + rev = "ba0bfb0e5d8e9e31c160d287878c6f26add3ec08"; + hash = "sha256-ZSOF0CLOn82GwU3xgvFefmh/AD2j5zz8I0t5YPwfan0="; + }; + grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "../unicode.h" "-I" ".." ]; + queryPath = "queries"; + }; + yaml = { + src = fetchFromGitHub { + owner = "ikatyang"; + repo = "tree-sitter-yaml"; + rev = "0e36bed171768908f331ff7dff9d956bae016efb"; + hash = "sha256-bpiT3FraOZhJaoiFWAoVJX1O+plnIi8aXOW2LwyU23M="; + }; + grammarCompileArgs = [ "-c" "-fpic" "../scanner.cc" "../parser.c" "-I" ".." ]; + grammarLinkArgs = [ "-lstdc++" "-shared" "-fpic" "scanner.o" "parser.o" ]; + querySrc = fetchFromGitHub { + owner = "helix-editor"; + repo = "helix"; + rev = "dbd248fdfa680373d94fbc10094a160aafa0f7a7"; + hash = "sha256-wk8qVUDFXhAOi1Ibc6iBMzDCXb6t+YiWZcTd0IJybqc="; + }; + }; + templ = rec { + src = fetchFromGitHub { + owner = "vrischmann"; + repo = "tree-sitter-templ"; + rev = "044ad200092170727650fa6d368df66a8da98f9d"; + hash = "sha256-hJuB3h5pp+LLfP0/7bAYH0uLVo+OQk5jpzJb3J9BNkY="; + }; + querySrc = runCommandLocal "templ-tree-sitter-queries" { } '' + mkdir -p $out/queries + # copy most stuff from tree-sitter-templ + install -m644 ${src}/queries/templ/* $out/queries + # override inherited files + cat ${tree-sitter-go}/queries/highlights.scm ${src}/queries/templ/highlights.scm > $out/queries/highlights.scm + ''; + queryPath = "queries"; + }; + go = { + src = tree-sitter-go; + grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; + grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; + queryPath = "queries"; + }; + hylo = { + src = fetchFromGitHub { + owner = "natsukagami"; + repo = "tree-sitter-hylo"; + rev = "494cbdff0d13cbc67348316af2efa0286dbddf6f"; + hash = "sha256-R5UeoglCTl0do3VDJ/liCTeqbxU9slvmVKNRA/el2VY="; + }; + grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; + grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; + queryPath = "queries"; + }; + }; +} + diff --git a/packages/common/nki-kakoune/utils.nix b/packages/common/nki-kakoune/utils.nix index 47e7c75..4183aa6 100644 --- a/packages/common/nki-kakoune/utils.nix +++ b/packages/common/nki-kakoune/utils.nix @@ -1,5 +1,7 @@ -{ lib, writeFile, ... }: { - mkFacesScript = name: faces: writeFile "${name}-faces.kak" ( - lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") faces)) - ); +{ lib, writeTextDir, ... }: { + mkFacesScript = name: faces: writeTextDir "share/kak/autoload/${name}/faces.kak" '' + hook global KakBegin .* { + ${lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: " face global ${name} \"${face}\"") faces))} + } + ''; } From 2a2cbc295f96e9e3a0bc6d2a5b01d5775236d9a5 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 21:11:48 +0200 Subject: [PATCH 06/53] Make tree-sitter kinda work --- home/common.nix | 2 +- overlay.nix | 2 +- .../default.nix} | 1 + .../common/kak-tree-sitter/user_config.patch | 129 ++++++++++++++++++ packages/common/nki-kakoune/default.nix | 4 +- packages/common/nki-kakoune/faces.nix | 31 +++++ packages/common/nki-kakoune/lsp.nix | 14 +- .../nki-kakoune/tree-sitter/default.nix | 28 ++-- .../nki-kakoune/tree-sitter/grammars.nix | 1 + packages/common/nki-kakoune/utils.nix | 2 +- 10 files changed, 187 insertions(+), 27 deletions(-) rename packages/common/{kak-tree-sitter.nix => kak-tree-sitter/default.nix} (98%) create mode 100644 packages/common/kak-tree-sitter/user_config.patch create mode 100644 packages/common/nki-kakoune/faces.nix diff --git a/home/common.nix b/home/common.nix index feeab1c..49b62ae 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,7 +2,7 @@ { imports = [ - ./kakoune/kak.nix + # ./kakoune/kak.nix ./fish/fish.nix ./modules/programs/my-broot.nix ./modules/programs/my-sway diff --git a/overlay.nix b/overlay.nix index 60fa42d..75da770 100644 --- a/overlay.nix +++ b/overlay.nix @@ -101,7 +101,7 @@ let }; overlay-packages = final: prev: { - kak-tree-sitter = final.callPackage ./packages/common/kak-tree-sitter.nix { rustPlatform = final.unstable.rustPlatform; }; + kak-tree-sitter = final.callPackage ./packages/common/kak-tree-sitter { rustPlatform = final.unstable.rustPlatform; }; kak-lsp = let diff --git a/packages/common/kak-tree-sitter.nix b/packages/common/kak-tree-sitter/default.nix similarity index 98% rename from packages/common/kak-tree-sitter.nix rename to packages/common/kak-tree-sitter/default.nix index 9819e3a..69da116 100644 --- a/packages/common/kak-tree-sitter.nix +++ b/packages/common/kak-tree-sitter/default.nix @@ -34,6 +34,7 @@ let self.runtime_dir.join("sources").join(url_dir) '') + ./user_config.patch ]; meta.mainProgram = "kak-tree-sitter"; diff --git a/packages/common/kak-tree-sitter/user_config.patch b/packages/common/kak-tree-sitter/user_config.patch new file mode 100644 index 0000000..b2b1b6a --- /dev/null +++ b/packages/common/kak-tree-sitter/user_config.patch @@ -0,0 +1,129 @@ +diff --git a/kak-tree-sitter-config/src/lib.rs b/kak-tree-sitter-config/src/lib.rs +index e4edc42..a9c92cb 100644 +--- a/kak-tree-sitter-config/src/lib.rs ++++ b/kak-tree-sitter-config/src/lib.rs +@@ -52,9 +52,13 @@ impl Config { + } + + /// Load the default configuration, the user configuration, and merge both. +- pub fn load_default_user() -> Result { ++ pub fn load_default_user(path: Option>) -> Result { + let mut config = Self::load_default_config()?; +- match UserConfig::load_from_xdg() { ++ let user_config = match path { ++ Some(p) => UserConfig::load(p), ++ None => UserConfig::load_from_xdg(), ++ }; ++ match user_config { + Ok(user_config) => { + config.merge_user_config(user_config)?; + } +@@ -448,7 +452,7 @@ impl UserConfig { + } + + /// Load the configuration from a given path. +- fn load(path: impl AsRef) -> Result { ++ pub fn load(path: impl AsRef) -> Result { + let path = path.as_ref(); + + log::debug!("loading configuration at {path}", path = path.display()); +diff --git a/kak-tree-sitter/src/cli.rs b/kak-tree-sitter/src/cli.rs +index b8102cd..923312c 100644 +--- a/kak-tree-sitter/src/cli.rs ++++ b/kak-tree-sitter/src/cli.rs +@@ -22,6 +22,10 @@ pub struct Cli { + #[clap(short, long)] + pub server: bool, + ++ /// Specify a custom path for the user config. ++ #[clap(short, long)] ++ pub user_config: Option, ++ + /// Try to daemonize, if not already done. + #[clap(short, long)] + pub daemonize: bool, +diff --git a/kak-tree-sitter/src/main.rs b/kak-tree-sitter/src/main.rs +index bee9698..cbd7b39 100644 +--- a/kak-tree-sitter/src/main.rs ++++ b/kak-tree-sitter/src/main.rs +@@ -43,7 +43,7 @@ fn start() -> Result<(), OhNo> { + } + } + +- let config = Config::load_default_user()?; ++ let config = Config::load_default_user(cli.user_config.as_ref())?; + + // inject rc if we start from Kakoune + if cli.kakoune && cli.init.is_some() { +diff --git a/kak-tree-sitter/src/server.rs b/kak-tree-sitter/src/server.rs +index f3b7723..000c81d 100644 +--- a/kak-tree-sitter/src/server.rs ++++ b/kak-tree-sitter/src/server.rs +@@ -73,6 +73,7 @@ impl Server { + log::debug!("creating IO handler"); + let io_handler = IOHandler::new( + config, ++ cli.user_config.clone(), + cli.is_standalone(), + cli.with_highlighting || config.features.highlighting, + resources, +@@ -165,6 +166,7 @@ struct IOHandler { + connections: HashMap, + enqueue_response: EnqueueResponse, + handler: Handler, ++ user_config_path: Option, + } + + impl IOHandler { +@@ -173,6 +175,7 @@ impl IOHandler { + + fn new( + config: &Config, ++ user_config_path: Option, + is_standalone: bool, + with_highlighting: bool, + resources: ServerResources, +@@ -203,6 +206,7 @@ impl IOHandler { + connections, + enqueue_response, + handler, ++ user_config_path, + }) + } + +@@ -450,7 +454,7 @@ impl IOHandler { + } + + fn reload(&mut self) { +- let config = match Config::load_default_user() { ++ let config = match Config::load_default_user(self.user_config_path.as_ref()) { + Ok(config) => config, + Err(err) => { + log::error!("reloading config failed: {err}"); +diff --git a/ktsctl/src/cli.rs b/ktsctl/src/cli.rs +index dfac5c3..09f86f3 100644 +--- a/ktsctl/src/cli.rs ++++ b/ktsctl/src/cli.rs +@@ -11,6 +11,9 @@ pub struct Cli { + #[clap(long)] + pub verbose: bool, + ++ #[clap(short, long)] ++ pub user_config: Option, ++ + #[clap(subcommand)] + pub cmd: Cmd, + } +diff --git a/ktsctl/src/main.rs b/ktsctl/src/main.rs +index f9a3499..f823633 100644 +--- a/ktsctl/src/main.rs ++++ b/ktsctl/src/main.rs +@@ -37,7 +37,7 @@ fn start() -> Result<(), HellNo> { + simple_logger::init_with_level(log::Level::Debug)?; + } + +- let config = Config::load_default_user()?; ++ let config = Config::load_default_user(cli.user_config.as_ref())?; + log::debug!("ktsctl configuration:\n{config:#?}"); + + match cli.cmd { diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 0d48b06..4cb34c7 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -11,6 +11,7 @@ in ++ callPackage ./themes.nix { } ++ [ (callPackage ./kaktex { }) + (callPackage ./faces.nix { }) rc tree-sitter.plugin lsp.plugin @@ -23,6 +24,7 @@ in rm "$out/bin/kak" makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ --set KAKOUNE_RUNTIME "$out/share/kak" \ - --suffix PATH ":" "${lsp.extraPaths}" + --suffix PATH ":" "${lsp.extraPaths}" \ + --suffix PATH ":" "${tree-sitter.extraPaths}" ''; }) diff --git a/packages/common/nki-kakoune/faces.nix b/packages/common/nki-kakoune/faces.nix new file mode 100644 index 0000000..367472c --- /dev/null +++ b/packages/common/nki-kakoune/faces.nix @@ -0,0 +1,31 @@ +{ callPackage, ... } : +let +utils = callPackage ./utils.nix { }; +faces = { + Default = "%opt{text},%opt{base}"; + BufferPadding = "%opt{base},%opt{base}"; + MenuForeground = "%opt{blue},white+bF"; + MenuBackground = "%opt{sky},white+F"; + Information = "%opt{sky},white"; + # Markdown help color scheme + InfoDefault = "Information"; + InfoBlock = "@block"; + InfoBlockQuote = "+i@block"; + InfoBullet = "@bullet"; + InfoHeader = "@header"; + InfoLink = "@link"; + InfoLinkMono = "+b@mono"; + InfoMono = "@mono"; + InfoRule = "+b@Information"; + InfoDiagnosticError = "@DiagnosticError"; + InfoDiagnosticHint = "@DiagnosticHint"; + InfoDiagnosticInformation = "@Information"; + InfoDiagnosticWarning = "@DiagnosticWarning"; + # Extra faces + macro = "+u@function"; + method = "@function"; + format_specifier = "+i@string"; + mutable_variable = "+i@variable"; + class = "+b@variable"; +}; +in utils.mkFacesScript "default-faces" faces diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix index 3712d6f..6511ee9 100644 --- a/packages/common/nki-kakoune/lsp.nix +++ b/packages/common/nki-kakoune/lsp.nix @@ -248,7 +248,7 @@ let kak-lsp-config = let toml = formats.toml { }; - toLspConfig = attrs: builtins.removeAttrs attrs [ "package" ]; + toLspConfig = builtins.mapAttrs (_: attrs: builtins.removeAttrs attrs [ "package" ]); in toml.generate "kak-lsp.toml" ({ semantic_tokens.faces = config.faces; @@ -265,16 +265,16 @@ in plugin = writeTextDir "share/kak/autoload/kak-lsp.kak" '' hook global KakBegin .* %{ try %{ - eval %sh{${lib.getExe kak-lsp} --config ${kak-lsp-config} -s $kak_session} + eval %sh{${lib.getExe kak-lsp} --kakoune --config ${kak-lsp-config} -s $kak_session} } lsp-enable - map window lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" - map window normal ": enter-user-mode lsp" - map window normal ": lsp-hover" - map window normal ": lsp-hover-buffer" + map global lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" + map global normal ": enter-user-mode lsp" + map global normal ": lsp-hover" + map global normal ": lsp-hover-buffer" # lsp-auto-hover-insert-mode-enable - set window lsp_hover_anchor true + set global lsp_hover_anchor true map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' map global object a 'lsp-object' -docstring 'LSP any symbol' map global object 'lsp-object' -docstring 'LSP any symbol' diff --git a/packages/common/nki-kakoune/tree-sitter/default.nix b/packages/common/nki-kakoune/tree-sitter/default.nix index ce16343..b94a771 100644 --- a/packages/common/nki-kakoune/tree-sitter/default.nix +++ b/packages/common/nki-kakoune/tree-sitter/default.nix @@ -129,25 +129,19 @@ let include = "keyword_control_import"; }; - configDir = + configFile = let toScm = name: lib.concatStringsSep "." (lib.splitString "_" name); - toml = formats.toml { }; - file = - toml.generate "config.toml" { - highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); - features = { - highlighting = true; - text_objects = true; - }; - language = grammars; - }; in - runCommandLocal "kak-tree-sitter-config" { } '' - mkdir -p $out/kak-tree-sitter - ln -s ${file} $out/kak-tree-sitter/config.toml - ''; + toml.generate "config.toml" { + highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); + features = { + highlighting = true; + text_objects = true; + }; + language = grammars; + }; extraFaces = let @@ -162,10 +156,12 @@ in { rc = '' # Enable kak-tree-sitter - eval %sh{env XDG_CONFIG_DIR=${configDir} ${lib.getExe' kak-tree-sitter "kak-tree-sitter"} --kakoune -d --server --init $kak_session} + eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session --user-config ${configFile}} map global normal ": enter-user-mode tree-sitter" ''; + extraPaths = "${kak-tree-sitter}/bin"; + plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces; } diff --git a/packages/common/nki-kakoune/tree-sitter/grammars.nix b/packages/common/nki-kakoune/tree-sitter/grammars.nix index 426edb3..d1f6417 100644 --- a/packages/common/nki-kakoune/tree-sitter/grammars.nix +++ b/packages/common/nki-kakoune/tree-sitter/grammars.nix @@ -33,6 +33,7 @@ let , }: { grammar.source.local.path = "${mkGrammarPackage args}"; + grammar.link_args = grammarLinkArgs ++ [ "-o" "${name}.so" ]; queries.source.local.path = querySrc; queries.path = queryPath; }; diff --git a/packages/common/nki-kakoune/utils.nix b/packages/common/nki-kakoune/utils.nix index 4183aa6..0307bc6 100644 --- a/packages/common/nki-kakoune/utils.nix +++ b/packages/common/nki-kakoune/utils.nix @@ -1,6 +1,6 @@ { lib, writeTextDir, ... }: { mkFacesScript = name: faces: writeTextDir "share/kak/autoload/${name}/faces.kak" '' - hook global KakBegin .* { + hook global KakBegin .* %{ ${lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: " face global ${name} \"${face}\"") faces))} } ''; From 12dcbcb3f6e93a21040e5f50156009925b3858e5 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 22:25:59 +0200 Subject: [PATCH 07/53] Cleanup the home kakoune module, restore tree-sitter --- home/common.nix | 3 +- home/kakoune/kak.nix | 374 +----------------- home/modules/programs/my-kakoune/default.nix | 94 +---- home/modules/programs/my-kakoune/kak-lsp.nix | 213 ---------- .../programs/my-kakoune/tree-sitter.nix | 59 +-- packages/common/nki-kakoune/default.nix | 8 +- packages/common/nki-kakoune/kakrc | 1 + 7 files changed, 58 insertions(+), 694 deletions(-) delete mode 100644 home/modules/programs/my-kakoune/kak-lsp.nix diff --git a/home/common.nix b/home/common.nix index 49b62ae..253c8b1 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,7 +2,7 @@ { imports = [ - # ./kakoune/kak.nix + ./kakoune/kak.nix ./fish/fish.nix ./modules/programs/my-broot.nix ./modules/programs/my-sway @@ -41,7 +41,6 @@ unzip zstd atool - nki-kakoune ]; home.sessionVariables = { diff --git a/home/kakoune/kak.nix b/home/kakoune/kak.nix index c39fca2..cfd5d6a 100644 --- a/home/kakoune/kak.nix +++ b/home/kakoune/kak.nix @@ -1,67 +1,9 @@ { pkgs, lib, ... }: - let - kak-lsp-frontend = { pkgs, lib, ... }: - let - langserver = name: { - name = "vscode-${name}-language-server"; - value = { - args = [ "--stdio" ]; - command = "vscode-${name}-language-server"; - filetypes = [ name ]; - roots = [ "package.json" ".git" ]; - }; - package = pkgs.nodePackages.vscode-langservers-extracted; - }; - - tailwind = { - command = "tailwindcss-language-server"; - args = [ "--stdio" ]; - filetypes = [ "html" "css" "javascript" "typescript" "templ" ]; - roots = [ "tailwind.config.{js,cjs,mjs,ts}" "package.json" ".git" ]; - settings_section = "tailwindCSS"; - settings.tailwindCSS = { - validate = "warning"; - userLanguages.templ = "html"; - }; - package = pkgs.tailwindcss-language-server; - }; - - templModule = { pkgs, lib, ... }: { - programs.kak-lsp.languageServers."vscode-html-language-server".filetypes = [ "templ" ]; - programs.kak-lsp.languageServers."tailwindcss-language-server".filetypes = [ "templ" ]; - programs.kak-lsp.languageServers.templ = { - command = "templ"; - args = [ "lsp" ]; - filetypes = [ "templ" ]; - roots = [ "go.mod" ".git" ]; - package = pkgs.unstable.templ; - }; - - }; - - in - { - imports = [ templModule ]; - - programs.kak-lsp.languageServers = (builtins.listToAttrs (map langserver [ "html" "css" "json" ])) // { - tailwindcss-language-server = tailwind; - }; - }; - - ltexLsp = { pkgs, lib, ... }: { - programs.kak-lsp.languageServers.ltex-ls = { - command = "ltex-ls"; - args = [ "--log-file=/tmp" ]; - filetypes = [ "latex" "typst" ]; - roots = [ "main.tex" "main.typ" ".git" ]; - package = pkgs.ltex-ls; - }; - }; in { - imports = [ ../modules/programs/my-kakoune ./kaktex.nix kak-lsp-frontend ltexLsp ]; + imports = [ ../modules/programs/my-kakoune ./kaktex.nix ]; home.packages = with pkgs; [ # ctags for peneira @@ -75,109 +17,6 @@ in # Enable the kakoune package. programs.my-kakoune.enable = true; programs.my-kakoune.enable-fish-session = true; - programs.kak-lsp.enable = true; - programs.kak-lsp.semanticTokens.additionalFaces = [ - # Typst - { face = "header"; token = "heading"; } - { face = "ts_markup_link_url"; token = "link"; } - { face = "ts_markup_link_uri"; token = "ref"; } - { face = "ts_markup_link_label"; token = "label"; } - { face = "ts_property"; token = "pol"; } - { face = "ts_markup_list_checked"; token = "marker"; } - { face = "ts_constant_builtin_boolean"; token = "bool"; } - { face = "ts_keyword_control"; token = "delim"; } - { face = "ts_number"; token = "text"; modifiers = [ "math" ]; } - { face = "ts_markup_bold"; token = "text"; modifiers = [ "strong" ]; } - { face = "ts_markup_italic"; token = "text"; modifiers = [ "emph" ]; } - ]; - - programs.kak-lsp.languageServers.elixir-ls = { - args = [ ]; - command = "elixir-ls"; - filetypes = [ "elixir" ]; - roots = [ "mix.exs" ]; - }; - programs.kak-lsp.languageServers.typescript-language-server = { - args = [ "--stdio" ]; - command = "typescript-language-server"; - filetypes = [ "typescript" "javascript" ]; - roots = [ "package.json" ]; - package = pkgs.nodePackages.typescript-language-server; - }; - programs.kak-lsp.languageServers.fsautocomplete = { - args = [ "--adaptive-lsp-server-enabled" "--project-graph-enabled" "--source-text-factory" "RoslynSourceText" ]; - command = "fsautocomplete"; - filetypes = [ "fsharp" ]; - roots = [ "*.fsproj" ]; - settings_section = "FSharp"; - settings.FSharp = { - AutomaticWorkspaceInit = true; - }; - }; - programs.kak-lsp.languageServers.metals = { - command = "metals"; - filetypes = [ "scala" ]; - roots = [ "build.sbt" "build.sc" ]; - settings_section = "metals"; - settings.metals = { - enableSemanticHighlighting = true; - showInferredType = true; - decorationProvider = true; - inlineDecorationProvider = true; - # From kakoune-lsp's own options - icons = "unicode"; - isHttpEnabled = true; - statusBarProvider = "log-message"; - compilerOptions = { overrideDefFormat = "unicode"; }; - }; - package = pkgs.metals; - }; - programs.kak-lsp.languageServers.texlab = { - command = "texlab"; - filetypes = [ "latex" ]; - roots = [ "main.tex" "all.tex" ".git" ]; - settings_section = "texlab"; - settings.texlab = { - build.executable = "latexmk"; - build.args = [ "-pdf" "-shell-escape" "-interaction=nonstopmode" "-synctex=1" "%f" ]; - - build.forwardSearchAfter = true; - build.onSave = true; - - forwardSearch = - (if pkgs.stdenv.isDarwin then { - executable = "/Applications/Skim.app/Contents/SharedSupport/displayline"; - args = [ "-r" "-g" "%l" "%p" "%f" ]; - } else - { - executable = "${pkgs.zathura}/bin/zathura"; - args = [ "--synctex-forward" "%l:1:%f" "%p" "-x" "${./kaktex} jump %%{input} %%{line} %%{column}" ]; - }); - }; - package = pkgs.texlab; - }; - programs.kak-lsp.languageServers.typst-lsp = { - command = "typst-lsp"; - filetypes = [ "typst" ]; - roots = [ "main.typ" ".git" ]; - settings_section = "typst-lsp"; - settings.typst-lsp = { - experimentalFormatterMode = "on"; - }; - }; - programs.kak-lsp.languageServers.marksman = { - command = "marksman"; - filetypes = [ "markdown" ]; - roots = [ ".marksman.toml" ".git" ]; - package = pkgs.marksman; - }; - programs.kak-lsp.languageServers.rust-analyzer = { - args = [ ]; - command = "rust-analyzer"; - filetypes = [ "rust" ]; - roots = [ "Cargo.toml" ]; - package = pkgs.rust-analyzer; - }; programs.my-kakoune.tree-sitter.extraAliases = { # Scala stuff @@ -300,216 +139,5 @@ in queries.path = "queries"; }; }; - - programs.my-kakoune.package = pkgs.kakoune; - programs.my-kakoune.rc = - builtins.readFile ./kakrc + '' - - # Source any settings in the current working directory, - # recursive upwards - evaluate-commands %sh{ - ${pkgs.writeScript "source-pwd" (builtins.readFile ./source-pwd)} - } - ''; - - programs.my-kakoune.extraFaces = { - Default = "%opt{text},%opt{base}"; - BufferPadding = "%opt{base},%opt{base}"; - MenuForeground = "%opt{blue},white+bF"; - MenuBackground = "%opt{sky},white+F"; - Information = "%opt{sky},white"; - # Markdown help color scheme - InfoDefault = "Information"; - InfoBlock = "@block"; - InfoBlockQuote = "+i@block"; - InfoBullet = "@bullet"; - InfoHeader = "@header"; - InfoLink = "@link"; - InfoLinkMono = "+b@mono"; - InfoMono = "@mono"; - InfoRule = "+b@Information"; - InfoDiagnosticError = "@DiagnosticError"; - InfoDiagnosticHint = "@DiagnosticHint"; - InfoDiagnosticInformation = "@Information"; - InfoDiagnosticWarning = "@DiagnosticWarning"; - # Extra faces - macro = "+u@function"; - method = "@function"; - format_specifier = "+i@string"; - mutable_variable = "+i@variable"; - class = "+b@variable"; - }; - programs.my-kakoune.autoload = [ - # My own scripts - { - name = "latex.kak"; - src = ./autoload/latex.kak; - } - { - name = "markdown.kak"; - src = ./autoload/markdown.kak; - } - - # Plugins - { - name = "luar"; - src = pkgs.fetchFromGitHub { - owner = "gustavo-hms"; - repo = "luar"; - rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; - sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; - }; - activationScript = '' - # Enable luar - require-module luar - # Use luajit - set-option global luar_interpreter ${pkgs.luajit}/bin/luajit - ''; - } - { - name = "peneira"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "peneira"; - rev = "743b9971472853a752475e7c070ce99089c6840c"; - sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; - }; - activationScript = '' - require-module peneira - - # Change selection color - set-face global PeneiraSelected @PrimarySelection - - # Buffers list - define-command -hidden peneira-buffers %{ - peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ - buffer %arg{1} - } - } - - # Grep in the current location - define-command peneira-grep %{ - peneira 'line: ' "rg -n ." %{ - lua %arg{1} %{ - local file, line = arg[1]:match("([^:]+):(%d+):") - kak.edit(file, line) - } - } - } - - # A peneira menu - declare-user-mode fuzzy-match-menu - - map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" - map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" - map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" - map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" - map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" - map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" - - # Bind menu to user mode - map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" - ''; - } - { - name = "kakoune-focus"; - src = pkgs.fetchFromGitHub { - owner = "caksoylar"; - repo = "kakoune-focus"; - rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; - sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; - }; - activationScript = '' - map global user ': focus-toggle' -docstring "toggle selections focus" - ''; - } - { - name = "kakoune-inc-dec"; - src = pkgs.fetchFromGitLab { - owner = "Screwtapello"; - repo = "kakoune-inc-dec"; - rev = "7bfe9c51"; - sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; - }; - } - { - name = "racket.kak"; - src = (builtins.fetchTree { - type = "git"; - url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; - rev = "e397042009b46916ff089d79166ec0e8ca813a18"; - narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; - }) + "/rc"; - } - # { - # name = "kakoune-discord"; - # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; - # } - rec { - name = "kakoune-mirror"; - src = pkgs.fetchFromGitHub - { - owner = "Delapouite"; - repo = "kakoune-mirror"; - rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; - sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; - } + "/mirror.kak"; - wrapAsModule = true; - activationScript = '' - require-module ${name} - - # Bind to ${name} - map global normal ': enter-user-mode -lock mirror' - ''; - } - { - name = "unicode-math"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "kakoune-unicode-math"; - rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; - # sha256 = lib.fakeSha256; - sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; - fetchSubmodules = true; - }; - activationScript = '' - require-module unicode-math - - # Bind to the menu - map global insert ': insert-unicode ' - ''; - } - { - name = "kakoune-buffers"; - src = pkgs.fetchFromGitHub { - owner = "Delapouite"; - repo = "kakoune-buffers"; - rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; - sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; - }; - activationScript = '' - # Suggested hook - - hook global WinDisplay .* info-buffers - - # Suggested mappings - - map global user b ':enter-buffers-mode' -docstring 'buffers…' - map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' - map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' - - # Suggested aliases - - alias global bd delete-buffer - alias global bf buffer-first - alias global bl buffer-last - alias global bo buffer-only - alias global bo! buffer-only-force - ''; - } - ]; - programs.my-kakoune.themes = { - catppuccin-latte = ./catppuccin-latte.kak; - }; } diff --git a/home/modules/programs/my-kakoune/default.nix b/home/modules/programs/my-kakoune/default.nix index 125484a..62a9cb1 100644 --- a/home/modules/programs/my-kakoune/default.nix +++ b/home/modules/programs/my-kakoune/default.nix @@ -1,40 +1,17 @@ -{ config, pkgs, lib, ... }: +{ config, options, pkgs, lib, ... }: with lib; let cfg = config.programs.my-kakoune; - - autoloadModule = types.submodule { - options = { - name = mkOption { - type = types.str; - description = "Name of the autoload script/folder. It might affect kakoune's load order."; - }; - src = mkOption { - type = types.path; - description = "Path to the autoload script/folder."; - }; - wrapAsModule = mkOption { - type = types.bool; - default = false; - description = "Wrap the given source file in a `provide-module` command. Fails if the `src` is not a single file."; - }; - activationScript = mkOption { - type = types.nullOr types.lines; - default = null; - description = "Add an activation script to the module. It will be wrapped in a `hook global KakBegin .*` wrapper."; - }; - }; - }; in { - imports = [ ./kak-lsp.nix ./fish-session.nix ./tree-sitter.nix ]; + imports = [ ./fish-session.nix ./tree-sitter.nix ]; options.programs.my-kakoune = { enable = mkEnableOption "My version of the kakoune configuration"; package = mkOption { type = types.package; - default = pkgs.kakoune; + default = pkgs.nki-kakoune; description = "The kakoune package to be installed"; }; rc = mkOption { @@ -42,22 +19,16 @@ in default = ""; description = "Content of the kakrc file. A line-concatenated string"; }; - autoload = mkOption { - type = types.listOf autoloadModule; - default = [ ]; - description = "Sources to autoload"; - }; - themes = mkOption { - type = types.attrsOf types.path; - default = { }; - description = "Themes to load"; - }; - extraFaces = mkOption { type = types.attrsOf types.str; default = { }; description = "Extra faces to include"; }; + autoloadFile = mkOption { + type = options.xdg.configFile.type; + default = { }; + description = "Extra autoload files"; + }; }; config = mkIf cfg.enable { @@ -65,37 +36,6 @@ in xdg.configFile = let - kakouneAutoload = { name, src, wrapAsModule ? false, activationScript ? null }: - [ - (if !wrapAsModule then { - name = "kak/autoload/${name}"; - value.source = src; - } else { - name = "kak/autoload/${name}/module.kak"; - value.text = '' - provide-module ${name} %◍ - ${readFile src} - ◍ - ''; - }) - ] ++ (if activationScript == null then [ ] else [{ - name = "kak/autoload/on-load/${name}.kak"; - value.text = '' - hook global KakBegin .* %{ - ${activationScript} - } - ''; - }]); - - kakouneThemes = builtins.listToAttrs (builtins.attrValues ( - builtins.mapAttrs - (name: src: { - name = "kak/colors/${name}.kak"; - value.source = src; - }) - cfg.themes - )); - kakouneFaces = let txt = strings.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") cfg.extraFaces)); @@ -103,6 +43,7 @@ in pkgs.writeText "faces.kak" txt; in { + "kak/autoload/builtin".source = "${cfg.package}/share/kak/autoload"; # kakrc "kak/kakrc".text = '' ${cfg.rc} @@ -110,15 +51,14 @@ in # Load faces source ${kakouneFaces} ''; - } // - (builtins.listToAttrs (lib.lists.flatten (map kakouneAutoload ([ - # include the original autoload files - { - name = "rc"; - src = "${cfg.package}/share/kak/autoload/rc"; - } - ] ++ cfg.autoload)))) - // kakouneThemes; + } // lib.mapAttrs' + (name: attrs: { + name = "kak/autoload/${name}"; + value = attrs // { + target = "kak/autoload/${name}"; + }; + }) + cfg.autoloadFile; }; } diff --git a/home/modules/programs/my-kakoune/kak-lsp.nix b/home/modules/programs/my-kakoune/kak-lsp.nix deleted file mode 100644 index eaf3b6b..0000000 --- a/home/modules/programs/my-kakoune/kak-lsp.nix +++ /dev/null @@ -1,213 +0,0 @@ -{ config, pkgs, lib, ... }: - -with lib; -let - lspConfig = - { - language_ids = { - c = "c_cpp"; - cpp = "c_cpp"; - javascript = "javascriptreact"; - typescript = "typescriptreact"; - protobuf = "proto"; - sh = "shellscript"; - }; - - language_servers = { - ccls = { - args = [ "-v=2" "-log-file=/tmp/ccls.log" ]; - command = "ccls"; - filetypes = [ "c" "cpp" ]; - roots = [ "compile_commands.json" ".cquery" ".git" ]; - }; - gopls = { - command = "gopls"; - filetypes = [ "go" ]; - offset_encoding = "utf-8"; - roots = [ "Gopkg.toml" "go.mod" ".git" ".hg" ]; - settings = { gopls = { hoverKind = "SynopsisDocumentation"; semanticTokens = true; }; }; - settings_section = "gopls"; - }; - haskell-language-server = { - args = [ "--lsp" ]; - command = "haskell-language-server-wrapper"; - filetypes = [ "haskell" ]; - roots = [ "Setup.hs" "stack.yaml" "*.cabal" "package.yaml" ]; - settings_section = "haskell"; - }; - nil = { - command = "${pkgs.nil}/bin/nil"; - filetypes = [ "nix" ]; - roots = [ "flake.nix" "shell.nix" ".git" ]; - settings.nil = { - formatting.command = [ "${getExe pkgs.nixpkgs-fmt}" ]; - }; - }; - pyls = { - command = "pyls"; - filetypes = [ "python" ]; - offset_encoding = "utf-8"; - roots = [ "requirements.txt" "setup.py" ".git" ".hg" ]; - }; - }; - semantic_tokens.faces = [ - ## Items - # (Rust) Macros - { face = "attribute"; token = "attribute"; } - { face = "attribute"; token = "derive"; } - { face = "macro"; token = "macro"; } # Function-like Macro - # Keyword and Fixed Tokens - { face = "keyword"; token = "keyword"; } - { face = "operator"; token = "operator"; } - # Functions and Methods - { face = "function"; token = "function"; } - { face = "method"; token = "method"; } - # Constants - { face = "string"; token = "string"; } - { face = "format_specifier"; token = "formatSpecifier"; } - # Variables - { face = "variable"; token = "variable"; modifiers = [ "readonly" ]; } - { face = "mutable_variable"; token = "variable"; } - { face = "module"; token = "namespace"; } - { face = "variable"; token = "type_parameter"; } - { face = "class"; token = "enum"; } - { face = "class"; token = "struct"; } - { face = "class"; token = "trait"; } - { face = "class"; token = "union"; } - { face = "class"; token = "class"; } - - ## Comments - { face = "documentation"; token = "comment"; modifiers = [ "documentation" ]; } - { face = "comment"; token = "comment"; } - ]; - server = { timeout = 1800; }; - snippet_support = false; - verbosity = 255; - }; - - languageServerOption = types.submodule { - options = { - filetypes = mkOption { - type = types.listOf types.str; - description = "The list of filetypes to assign the language to"; - }; - roots = mkOption { - type = types.listOf types.str; - description = "The list of root filenames that are used to determine the project root"; - }; - command = mkOption { - type = types.str; - description = "The LSP server command to be called."; - }; - args = mkOption { - type = types.listOf types.str; - default = [ ]; - description = "The arguments passed onto the LSP server."; - }; - offset_encoding = mkOption { - type = types.nullOr (types.enum [ "utf-8" ]); - default = null; - description = "The offset encoding used by the LSP server."; - }; - settings_section = mkOption { - type = types.nullOr types.str; - default = null; - description = "The settings section to be sent to LSP server."; - }; - settings = mkOption { - type = types.nullOr (types.attrsOf types.anything); - default = null; - description = "Additional settings to be passed to the LSP server."; - }; - package = mkOption { - type = types.nullOr types.package; - default = null; - description = "The default package of the language server. Will be appended as the ending segments of the PATH to kak-lsp"; - }; - }; - }; - - cfg = config.programs.kak-lsp; - - serverPackages = - filter (v: v != null) - (lib.mapAttrsToList (_: serv: serv.package) cfg.languageServers); - - wrappedPackage = pkgs.symlinkJoin { - name = "kak-lsp-wrapped"; - nativeBuildInputs = [ pkgs.makeWrapper ]; - paths = [ cfg.package ]; - postBuild = '' - wrapProgram $out/bin/kak-lsp --suffix PATH ":" ${lib.makeBinPath serverPackages} - ''; - }; -in -{ - options.programs.kak-lsp = { - enable = mkEnableOption "Enable kak-lsp support"; - - package = mkOption { - type = types.package; - default = pkgs.kak-lsp; - }; - - enableSnippets = mkOption { - type = types.bool; - default = false; - description = "Enable snippet support"; - }; - - semanticTokens.faces = mkOption { - type = types.listOf types.anything; - default = lspConfig.semantic_tokens.faces; - description = "The semantic tokens faces mapping given to kak"; - }; - semanticTokens.additionalFaces = mkOption { - type = types.listOf types.anything; - default = [ ]; - description = "The semantic tokens faces mapping given to kak"; - }; - - serverTimeout = mkOption { - type = types.int; - default = 1000; - description = "Server timeout"; - }; - - languageServers = mkOption { - type = types.attrsOf languageServerOption; - default = { }; - description = "The language options"; - }; - - languageIds = mkOption { - type = types.attrsOf types.str; - default = { }; - description = "Language IDs to be sent to the LSP"; - }; - }; - - config = mkIf cfg.enable - { - home.packages = [ wrappedPackage ]; - - # Configurations - xdg.configFile."kak-lsp/kak-lsp.toml" = - let - toml = pkgs.formats.toml { }; - toLspConfig = lib.filterAttrsRecursive (n: v: n != "package" && v != null); - in - { - source = toml.generate "config.toml" - { - semantic_tokens.faces = cfg.semanticTokens.faces ++ cfg.semanticTokens.additionalFaces; - server.timeout = cfg.serverTimeout; - snippet_support = cfg.enableSnippets; - verbosity = 255; - language_server = toLspConfig (lspConfig.language_servers // cfg.languageServers); - language_ids = lspConfig.language_ids // cfg.languageIds; - }; - }; - }; -} - diff --git a/home/modules/programs/my-kakoune/tree-sitter.nix b/home/modules/programs/my-kakoune/tree-sitter.nix index 4304ca5..07f12cf 100644 --- a/home/modules/programs/my-kakoune/tree-sitter.nix +++ b/home/modules/programs/my-kakoune/tree-sitter.nix @@ -33,6 +33,27 @@ let }; }; }; + mkGrammarPackage = + { name + , src + , grammarPath ? "src" + , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] + , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] + }: pkgs.stdenv.mkDerivation { + inherit src; + name = "kak-tree-sitter-grammar-${name}.so"; + version = "latest"; + buildPhase = '' + mkdir ${grammarPath}/build + cd ${grammarPath}/build + $CC ${lib.concatStringsSep " " grammarCompileArgs} + $CC ${lib.concatStringsSep " " grammarLinkArgs} -o ${name}.so + ''; + installPhase = '' + cp ${name}.so $out + ''; + }; + in { options.programs.my-kakoune.tree-sitter = { @@ -200,24 +221,15 @@ in toml = pkgs.formats.toml { }; - srcName = src: lib.removePrefix "/nix/store/" src.outPath; - mkGitRepo = src: pkgs.runCommandLocal "${src.name}-git" { } '' - cp -r --no-preserve=all ${src} $out - cd $out - if ! test -d $out/.git; then - ${lib.getExe pkgs.git} init -b ${srcName src} - ${lib.getExe pkgs.git} config user.email "a@b.com" - ${lib.getExe pkgs.git} config user.name "a" - ${lib.getExe pkgs.git} add . - ${lib.getExe pkgs.git} commit -m "Just making a git commit" - fi - ''; - toLanguageConf = name: lang: with lang; { grammar = { - inherit (grammar) path; - source.git.url = "${mkGitRepo grammar.src}"; - source.git.pin = "${srcName grammar.src}"; + source.local.path = mkGrammarPackage { + inherit name; + src = grammar.src; + grammarPath = grammar.path; + grammarCompileArgs = grammar.compile.flags ++ grammar.compile.args; + grammarLinkArgs = grammar.link.flags ++ grammar.link.args; + }; compile = grammar.compile.command; compile_args = grammar.compile.args; compile_flags = grammar.compile.flags; @@ -225,10 +237,9 @@ in link_args = grammar.link.args ++ [ "-o" "${name}.so" ]; link_flags = grammar.link.flags; }; - queries = { - source.git.url = "${mkGitRepo queries.src}"; - source.git.pin = "${srcName queries.src}"; + queries = rec { path = if queries.path == null then "runtime/queries/${name}" else queries.path; + source.local.path = "${queries.src}/${path}"; }; }; in @@ -249,14 +260,14 @@ in features = cfg.features; language = builtins.mapAttrs toLanguageConf cfg.languages; }; - - onChange = '' - export PATH=$PATH:${lib.getBin pkgs.gcc} - ${cfg.package}/bin/ktsctl sync -a - ''; }; programs.my-kakoune.extraFaces = faces; + programs.my-kakoune.autoloadFile."kak-tree-sitter.kak".text = '' + # Enable kak-tree-sitter + eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session} + map global normal ": enter-user-mode tree-sitter" + ''; }; } diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 4cb34c7..c7d4324 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,9 +1,8 @@ { callPackage, kakoune, kakoune-unwrapped, ... }: let lsp = callPackage ./lsp.nix { }; - tree-sitter = callPackage ./tree-sitter { }; rc = (callPackage ./rc.nix { - prependRc = tree-sitter.rc; + # prependRc = tree-sitter.rc; }); in (kakoune.override { @@ -13,7 +12,7 @@ in (callPackage ./kaktex { }) (callPackage ./faces.nix { }) rc - tree-sitter.plugin + # tree-sitter.plugin lsp.plugin ]; }).overrideAttrs (attrs: { @@ -24,7 +23,6 @@ in rm "$out/bin/kak" makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ --set KAKOUNE_RUNTIME "$out/share/kak" \ - --suffix PATH ":" "${lsp.extraPaths}" \ - --suffix PATH ":" "${tree-sitter.extraPaths}" + --suffix PATH ":" "${lsp.extraPaths}" ''; }) diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc index dc06ca3..0bc3dc0 100644 --- a/packages/common/nki-kakoune/kakrc +++ b/packages/common/nki-kakoune/kakrc @@ -5,6 +5,7 @@ # set global kts_sky "rgb:6aa622" # Color scheme colorscheme catppuccin-latte +set-face global module "%opt{sapphire}" set global base "default" # Set indentation guides From 139af8729f9a6345d6cbb1775e740d37c26e4f02 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 22:26:49 +0200 Subject: [PATCH 08/53] Revert tree-sitter --- packages/common/kak-tree-sitter/default.nix | 1 - .../common/kak-tree-sitter/user_config.patch | 129 -------------- packages/common/nki-kakoune/default.nix | 5 +- .../nki-kakoune/tree-sitter/default.nix | 167 ------------------ .../nki-kakoune/tree-sitter/grammars.nix | 120 ------------- 5 files changed, 1 insertion(+), 421 deletions(-) delete mode 100644 packages/common/kak-tree-sitter/user_config.patch delete mode 100644 packages/common/nki-kakoune/tree-sitter/default.nix delete mode 100644 packages/common/nki-kakoune/tree-sitter/grammars.nix diff --git a/packages/common/kak-tree-sitter/default.nix b/packages/common/kak-tree-sitter/default.nix index 69da116..9819e3a 100644 --- a/packages/common/kak-tree-sitter/default.nix +++ b/packages/common/kak-tree-sitter/default.nix @@ -34,7 +34,6 @@ let self.runtime_dir.join("sources").join(url_dir) '') - ./user_config.patch ]; meta.mainProgram = "kak-tree-sitter"; diff --git a/packages/common/kak-tree-sitter/user_config.patch b/packages/common/kak-tree-sitter/user_config.patch deleted file mode 100644 index b2b1b6a..0000000 --- a/packages/common/kak-tree-sitter/user_config.patch +++ /dev/null @@ -1,129 +0,0 @@ -diff --git a/kak-tree-sitter-config/src/lib.rs b/kak-tree-sitter-config/src/lib.rs -index e4edc42..a9c92cb 100644 ---- a/kak-tree-sitter-config/src/lib.rs -+++ b/kak-tree-sitter-config/src/lib.rs -@@ -52,9 +52,13 @@ impl Config { - } - - /// Load the default configuration, the user configuration, and merge both. -- pub fn load_default_user() -> Result { -+ pub fn load_default_user(path: Option>) -> Result { - let mut config = Self::load_default_config()?; -- match UserConfig::load_from_xdg() { -+ let user_config = match path { -+ Some(p) => UserConfig::load(p), -+ None => UserConfig::load_from_xdg(), -+ }; -+ match user_config { - Ok(user_config) => { - config.merge_user_config(user_config)?; - } -@@ -448,7 +452,7 @@ impl UserConfig { - } - - /// Load the configuration from a given path. -- fn load(path: impl AsRef) -> Result { -+ pub fn load(path: impl AsRef) -> Result { - let path = path.as_ref(); - - log::debug!("loading configuration at {path}", path = path.display()); -diff --git a/kak-tree-sitter/src/cli.rs b/kak-tree-sitter/src/cli.rs -index b8102cd..923312c 100644 ---- a/kak-tree-sitter/src/cli.rs -+++ b/kak-tree-sitter/src/cli.rs -@@ -22,6 +22,10 @@ pub struct Cli { - #[clap(short, long)] - pub server: bool, - -+ /// Specify a custom path for the user config. -+ #[clap(short, long)] -+ pub user_config: Option, -+ - /// Try to daemonize, if not already done. - #[clap(short, long)] - pub daemonize: bool, -diff --git a/kak-tree-sitter/src/main.rs b/kak-tree-sitter/src/main.rs -index bee9698..cbd7b39 100644 ---- a/kak-tree-sitter/src/main.rs -+++ b/kak-tree-sitter/src/main.rs -@@ -43,7 +43,7 @@ fn start() -> Result<(), OhNo> { - } - } - -- let config = Config::load_default_user()?; -+ let config = Config::load_default_user(cli.user_config.as_ref())?; - - // inject rc if we start from Kakoune - if cli.kakoune && cli.init.is_some() { -diff --git a/kak-tree-sitter/src/server.rs b/kak-tree-sitter/src/server.rs -index f3b7723..000c81d 100644 ---- a/kak-tree-sitter/src/server.rs -+++ b/kak-tree-sitter/src/server.rs -@@ -73,6 +73,7 @@ impl Server { - log::debug!("creating IO handler"); - let io_handler = IOHandler::new( - config, -+ cli.user_config.clone(), - cli.is_standalone(), - cli.with_highlighting || config.features.highlighting, - resources, -@@ -165,6 +166,7 @@ struct IOHandler { - connections: HashMap, - enqueue_response: EnqueueResponse, - handler: Handler, -+ user_config_path: Option, - } - - impl IOHandler { -@@ -173,6 +175,7 @@ impl IOHandler { - - fn new( - config: &Config, -+ user_config_path: Option, - is_standalone: bool, - with_highlighting: bool, - resources: ServerResources, -@@ -203,6 +206,7 @@ impl IOHandler { - connections, - enqueue_response, - handler, -+ user_config_path, - }) - } - -@@ -450,7 +454,7 @@ impl IOHandler { - } - - fn reload(&mut self) { -- let config = match Config::load_default_user() { -+ let config = match Config::load_default_user(self.user_config_path.as_ref()) { - Ok(config) => config, - Err(err) => { - log::error!("reloading config failed: {err}"); -diff --git a/ktsctl/src/cli.rs b/ktsctl/src/cli.rs -index dfac5c3..09f86f3 100644 ---- a/ktsctl/src/cli.rs -+++ b/ktsctl/src/cli.rs -@@ -11,6 +11,9 @@ pub struct Cli { - #[clap(long)] - pub verbose: bool, - -+ #[clap(short, long)] -+ pub user_config: Option, -+ - #[clap(subcommand)] - pub cmd: Cmd, - } -diff --git a/ktsctl/src/main.rs b/ktsctl/src/main.rs -index f9a3499..f823633 100644 ---- a/ktsctl/src/main.rs -+++ b/ktsctl/src/main.rs -@@ -37,7 +37,7 @@ fn start() -> Result<(), HellNo> { - simple_logger::init_with_level(log::Level::Debug)?; - } - -- let config = Config::load_default_user()?; -+ let config = Config::load_default_user(cli.user_config.as_ref())?; - log::debug!("ktsctl configuration:\n{config:#?}"); - - match cli.cmd { diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index c7d4324..f4851af 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,9 +1,7 @@ { callPackage, kakoune, kakoune-unwrapped, ... }: let lsp = callPackage ./lsp.nix { }; - rc = (callPackage ./rc.nix { - # prependRc = tree-sitter.rc; - }); + rc = (callPackage ./rc.nix { }); in (kakoune.override { plugins = callPackage ./plugins.nix { } @@ -12,7 +10,6 @@ in (callPackage ./kaktex { }) (callPackage ./faces.nix { }) rc - # tree-sitter.plugin lsp.plugin ]; }).overrideAttrs (attrs: { diff --git a/packages/common/nki-kakoune/tree-sitter/default.nix b/packages/common/nki-kakoune/tree-sitter/default.nix deleted file mode 100644 index b94a771..0000000 --- a/packages/common/nki-kakoune/tree-sitter/default.nix +++ /dev/null @@ -1,167 +0,0 @@ -{ lib -, callPackage -, formats -, runCommandLocal -, kak-tree-sitter -, ... -}: -let - utils = callPackage ../utils.nix { }; - grammars = (callPackage ./grammars.nix { }).grammars; - # Highlighter groups to add to the `highlighterGroups`. Maps from group names to face names. - highlighterGroups = { - attribute = "@attribute"; - comment = "@comment"; - conceal = "%opt{mauve}+i"; - constant = "%opt{peach}"; - constant_builtin_boolean = "%opt{sky}"; - constant_character = "%opt{yellow}"; - constant_macro = "%opt{mauve}"; - constant_numeric = "%opt{peach}"; - constructor = "%opt{sapphire}"; - diff_plus = "%opt{green}"; - diff_minus = "%opt{red}"; - diff_delta = "%opt{blue}"; - diff_delta_moved = "%opt{mauve}"; - error = "%opt{red}+b"; - function = "@function"; - function_builtin = "@builtin"; - function_macro = "+i@ts_function"; - hint = "%opt{blue}+b"; - info = "%opt{green}+b"; - keyword = "keyword"; - keyword_conditional = "+i@ts_keyword"; - keyword_control_conditional = "+i@ts_keyword"; - keyword_control_directive = "+i@ts_keyword"; - keyword_control_import = "+i@ts_keyword"; - keyword_directive = "+i@ts_keyword"; - label = "%opt{sapphire}+i"; - markup_bold = "%opt{peach}+b"; - markup_heading = "%opt{red}"; - markup_heading_1 = "%opt{red}"; - markup_heading_2 = "%opt{mauve}"; - markup_heading_3 = "%opt{green}"; - markup_heading_4 = "%opt{yellow}"; - markup_heading_5 = "%opt{pink}"; - markup_heading_6 = "%opt{teal}"; - markup_heading_marker = "%opt{peach}+b"; - markup_italic = "%opt{pink}+i"; - markup_list_checked = "%opt{green}"; - markup_list_numbered = "%opt{blue}+i"; - markup_list_unchecked = "%opt{teal}"; - markup_list_unnumbered = "%opt{mauve}"; - markup_link_label = "%opt{blue}"; - markup_link_url = "%opt{teal}+u"; - markup_link_uri = "%opt{teal}+u"; - markup_link_text = "%opt{blue}"; - markup_quote = "%opt{crust}"; - markup_raw = "%opt{sky}"; - markup_raw_block = "%opt{sky}"; - markup_raw_inline = "%opt{green}"; - markup_strikethrough = "%opt{crust}+s"; - namespace = "@module"; - operator = "@operator"; - property = "%opt{sky}"; - punctuation = "%opt{overlay2}"; - punctuation_special = "%opt{sky}"; - special = "%opt{blue}"; - spell = "%opt{mauve}"; - string = "%opt{green}"; - string_regex = "%opt{peach}"; - string_regexp = "%opt{peach}"; - string_escape = "%opt{mauve}"; - string_special = "%opt{blue}"; - string_special_path = "%opt{green}"; - string_special_symbol = "%opt{mauve}"; - string_symbol = "%opt{red}"; - tag = "%opt{teal}"; - tag_error = "%opt{red}"; - text_title = "%opt{mauve}"; - type = "@type"; - type_enum_variant = "+i@ts_type"; - variable = "@variable"; - variable_builtin = "@builtin"; - variable_other_member = "%opt{teal}"; - variable_parameter = "+i@variable"; - warning = "%opt{peach}+b"; - }; - - # Highlighter groups to be aliased by other groups - aliases = { - comment_block = "comment"; - comment_line = "comment"; - constant_character_escape = "constant_character"; - constant_numeric_float = "constant_numeric"; - constant_numeric_integer = "constant_numeric"; - function_method = "function"; - function_special = "function"; - keyword_control = "keyword"; - keyword_control_repeat = "keyword"; - keyword_control_return = "keyword"; - keyword_control_except = "keyword"; - keyword_control_exception = "keyword"; - keyword_function = "keyword"; - keyword_operator = "keyword"; - keyword_special = "keyword"; - keyword_storage = "keyword"; - keyword_storage_modifier = "keyword"; - keyword_storage_modifier_mut = "keyword"; - keyword_storage_modifier_ref = "keyword"; - keyword_storage_type = "keyword"; - punctuation_bracket = "punctuation"; - punctuation_delimiter = "punctuation"; - text = "string"; - type_builtin = "type"; - - # Scala stuff - method = "function"; - module = "namespace"; - function_call = "function"; - method_call = "method"; - - boolean = "constant_builtin_boolean"; - number = "constant_numeric"; - float = "constant_numeric_float"; - - type_qualifier = "keyword_special"; - storageclass = "keyword_storage_modifier"; - conditional = "keyword_conditional"; - include = "keyword_control_import"; - }; - - configFile = - let - toScm = name: lib.concatStringsSep "." (lib.splitString "_" name); - toml = formats.toml { }; - in - toml.generate "config.toml" { - highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); - features = { - highlighting = true; - text_objects = true; - }; - language = grammars; - }; - - extraFaces = - let - toTs = name: "ts_${lib.concatStringsSep "_" (lib.splitString "." name)}"; - - definedFaces = lib.mapAttrs' (name: value: { inherit value; name = toTs name; }) highlighterGroups; - aliasFaces = lib.mapAttrs' (name: value: { name = toTs name; value = "@${toTs value}"; }) aliases; - faces = lib.recursiveUpdate definedFaces aliasFaces; - in - faces; -in -{ - rc = '' - # Enable kak-tree-sitter - eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session --user-config ${configFile}} - map global normal ": enter-user-mode tree-sitter" - ''; - - extraPaths = "${kak-tree-sitter}/bin"; - - plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces; -} - diff --git a/packages/common/nki-kakoune/tree-sitter/grammars.nix b/packages/common/nki-kakoune/tree-sitter/grammars.nix deleted file mode 100644 index d1f6417..0000000 --- a/packages/common/nki-kakoune/tree-sitter/grammars.nix +++ /dev/null @@ -1,120 +0,0 @@ -{ lib, stdenv, fetchFromGitHub, runCommandLocal, ... }: -let - mkGrammarPackage = - { name - , src - , grammarPath ? "src" - , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] - , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] - , ... - }: stdenv.mkDerivation { - inherit src; - name = "kak-tree-sitter-grammar-${name}"; - version = "latest"; - buildPhase = '' - mkdir ${grammarPath}/build - cd ${grammarPath}/build - $CC ${lib.concatStringsSep " " grammarCompileArgs} - $CC ${lib.concatStringsSep " " grammarLinkArgs} -o ${name}.so - ''; - installPhase = '' - mkdir $out - cp ${name}.so $out - ''; - }; - mkGrammar = - args @ { name - , src - , grammarPath ? "src" - , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] - , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] - , querySrc ? src - , queryPath ? "runtime/queries/${name}" - , - }: { - grammar.source.local.path = "${mkGrammarPackage args}"; - grammar.link_args = grammarLinkArgs ++ [ "-o" "${name}.so" ]; - queries.source.local.path = querySrc; - queries.path = queryPath; - }; - - tree-sitter-go = fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-go"; - rev = "v0.20.0"; - hash = "sha256-G7d8CHCyKDAb9j6ijRfHk/HlgPqSI+uvkuRIRRvjkHI="; - }; -in -{ - grammars = builtins.mapAttrs (name: value: mkGrammar ({ inherit name; } // value)) { - scala = { - src = fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-scala"; - rev = "70afdd5632d57dd63a960972ab25945e353a52f6"; - hash = "sha256-bi0Lqo/Zs2Uaz1efuKAARpEDg5Hm59oUe7eSXgL1Wow="; - }; - queryPath = "queries/scala"; - }; - haskell = { - src = fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-haskell"; - rev = "ba0bfb0e5d8e9e31c160d287878c6f26add3ec08"; - hash = "sha256-ZSOF0CLOn82GwU3xgvFefmh/AD2j5zz8I0t5YPwfan0="; - }; - grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "../unicode.h" "-I" ".." ]; - queryPath = "queries"; - }; - yaml = { - src = fetchFromGitHub { - owner = "ikatyang"; - repo = "tree-sitter-yaml"; - rev = "0e36bed171768908f331ff7dff9d956bae016efb"; - hash = "sha256-bpiT3FraOZhJaoiFWAoVJX1O+plnIi8aXOW2LwyU23M="; - }; - grammarCompileArgs = [ "-c" "-fpic" "../scanner.cc" "../parser.c" "-I" ".." ]; - grammarLinkArgs = [ "-lstdc++" "-shared" "-fpic" "scanner.o" "parser.o" ]; - querySrc = fetchFromGitHub { - owner = "helix-editor"; - repo = "helix"; - rev = "dbd248fdfa680373d94fbc10094a160aafa0f7a7"; - hash = "sha256-wk8qVUDFXhAOi1Ibc6iBMzDCXb6t+YiWZcTd0IJybqc="; - }; - }; - templ = rec { - src = fetchFromGitHub { - owner = "vrischmann"; - repo = "tree-sitter-templ"; - rev = "044ad200092170727650fa6d368df66a8da98f9d"; - hash = "sha256-hJuB3h5pp+LLfP0/7bAYH0uLVo+OQk5jpzJb3J9BNkY="; - }; - querySrc = runCommandLocal "templ-tree-sitter-queries" { } '' - mkdir -p $out/queries - # copy most stuff from tree-sitter-templ - install -m644 ${src}/queries/templ/* $out/queries - # override inherited files - cat ${tree-sitter-go}/queries/highlights.scm ${src}/queries/templ/highlights.scm > $out/queries/highlights.scm - ''; - queryPath = "queries"; - }; - go = { - src = tree-sitter-go; - grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; - grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; - queryPath = "queries"; - }; - hylo = { - src = fetchFromGitHub { - owner = "natsukagami"; - repo = "tree-sitter-hylo"; - rev = "494cbdff0d13cbc67348316af2efa0286dbddf6f"; - hash = "sha256-R5UeoglCTl0do3VDJ/liCTeqbxU9slvmVKNRA/el2VY="; - }; - grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; - grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; - queryPath = "queries"; - }; - }; -} - From 89ca51d7e22004d132bd96424c73be6935882793 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 22:30:13 +0200 Subject: [PATCH 09/53] Further cleanup --- home/common.nix | 2 +- home/{kakoune/kak.nix => kakoune.nix} | 2 +- home/kakoune/autoload/latex.kak | 133 --------------- home/kakoune/autoload/markdown.kak | 29 ---- home/kakoune/catppuccin-latte.kak | 79 --------- home/kakoune/kakrc | 233 -------------------------- home/kakoune/kaktex | 28 ---- home/kakoune/kaktex.nix | 14 -- home/kakoune/source-pwd | 16 -- 9 files changed, 2 insertions(+), 534 deletions(-) rename home/{kakoune/kak.nix => kakoune.nix} (98%) delete mode 100644 home/kakoune/autoload/latex.kak delete mode 100644 home/kakoune/autoload/markdown.kak delete mode 100644 home/kakoune/catppuccin-latte.kak delete mode 100644 home/kakoune/kakrc delete mode 100755 home/kakoune/kaktex delete mode 100644 home/kakoune/kaktex.nix delete mode 100755 home/kakoune/source-pwd diff --git a/home/common.nix b/home/common.nix index 253c8b1..e7eb15b 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,7 +2,7 @@ { imports = [ - ./kakoune/kak.nix + ./kakoune.nix ./fish/fish.nix ./modules/programs/my-broot.nix ./modules/programs/my-sway diff --git a/home/kakoune/kak.nix b/home/kakoune.nix similarity index 98% rename from home/kakoune/kak.nix rename to home/kakoune.nix index cfd5d6a..1963430 100644 --- a/home/kakoune/kak.nix +++ b/home/kakoune.nix @@ -3,7 +3,7 @@ let in { - imports = [ ../modules/programs/my-kakoune ./kaktex.nix ]; + imports = [ ./modules/programs/my-kakoune ]; home.packages = with pkgs; [ # ctags for peneira diff --git a/home/kakoune/autoload/latex.kak b/home/kakoune/autoload/latex.kak deleted file mode 100644 index 4bb9c9d..0000000 --- a/home/kakoune/autoload/latex.kak +++ /dev/null @@ -1,133 +0,0 @@ -## Author: @natsukagami (https://github.com/natsukagami) -## -## To activate, source the file into kakrc and add: -### require-module latex-kak -## -## NOTE: This overrides , so if you don't like it, remove it. - -# Create a simple begin block, put the cursors in and remove multi-cursor on exit. -define-command -hidden create-begin-block %{ - execute-keys "i\begin{b0}\end{b0}" - execute-keys "b0" - execute-keys -with-hooks -with-maps "c" - hook -once buffer ModeChange .*:normal %{ - execute-keys -with-maps ",gl" - } -} -# Create a begin block with the given parameter as block name. -define-command -params 1 create-begin-block-with %{ - execute-keys "i\begin{b0}\end{b0}" - execute-keys "b0c%arg{1}," - execute-keys "ok" - execute-keys -with-maps "gl" -} -# Create a \param{} block and put the cursor in the middle. -define-command -params 2 -hidden create-delims %{ - execute-keys "i%arg{1}hZa%arg{2}zl" - execute-keys -with-hooks -with-maps "i" -} -define-command -params 1 create-block-with %{ - create-delims "\%arg{1}{" "}" -} - -# The font-menu -declare-user-mode latex-font -## Semantics -map -docstring "Text" global latex-font t ": create-block-with text" -map -docstring "Emphasize (emph)" global latex-font e ": create-block-with emph" -## Shape -map -docstring "Italics (textit)" global latex-font i ": create-block-with textit" -map -docstring "Upright (textup)" global latex-font u ": create-block-with textup" -# map -docstring "Slanted (textsl)" global latex-font S ": create-block-with textsl" -# map -docstring "Swash font (textsw)" global latex-font W ": create-block-with textsw" -# map -docstring "Small caps (textsc)" global latex-font C ": create-block-with textsc" -# Weight -map -docstring "Bold text (textbf)" global latex-font b ": create-block-with textbf" -# map -docstring "Medium bold (textmd)" global latex-font M ": create-block-with textmd" -# map -docstring "Normal (textnormal)" global latex-font N ": create-block-with textnormal" -## Family -# map -docstring "Serif font (textsf)" global latex-font s ": create-block-with textsf" -# map -docstring "Roman text (textrm)" global latex-font r ": create-block-with textrm" -map -docstring "Monospace (texttt)" global latex-font m ": create-block-with texttt" -## Math styles -map -docstring "Math Calligraphic (mathcal)" global latex-font ": create-block-with mathcal" -map -docstring "Math Blackboard (mathbb)" global latex-font ": create-block-with mathbb" -# map -docstring "Math Fraktur (mathfr)" global latex-font ": create-block-with mathfr" -# map -docstring "Math Roman (mathrm)" global latex-font ": create-block-with mathrm" -# map -docstring "Math Italics (mathit)" global latex-font ": create-block-with mathit" -# map -docstring "Math Bold (mathbf)" global latex-font ": create-block-with mathbf" -# map -docstring "Serif font (mathsf)" global latex-font ": create-block-with mathsf" -map -docstring "Math Monospace (mathtt)" global latex-font ": create-block-with mathtt" -map -docstring "Math Fraktur (mathfrak)" global latex-font f ": create-block-with mathfrak" - -# "Insert block" menu -declare-user-mode latex-insert-block -## Common normal text blocks -map -docstring "Unordered list" global latex-insert-block u ": create-begin-block-with itemize" -map -docstring "Ordered list" global latex-insert-block o ": create-begin-block-with enumerate" -## Common math blocks -map -docstring "Theorem" global latex-insert-block t ": create-begin-block-with theorem" -map -docstring "Definition" global latex-insert-block d ": create-begin-block-with definition" -map -docstring "Lemma" global latex-insert-block l ": create-begin-block-with lemma" -map -docstring "Example" global latex-insert-block e ": create-begin-block-with example" -map -docstring "Proof" global latex-insert-block p ": create-begin-block-with proof" -map -docstring "Remark" global latex-insert-block r ": create-begin-block-with remark" -map -docstring "Proposition" global latex-insert-block ": create-begin-block-with proposition" -map -docstring "Corollary" global latex-insert-block C ": create-begin-block-with corollary" -## Common environments -map -docstring "align*" global latex-insert-block a ": create-begin-block-with align*" -map -docstring "align" global latex-insert-block ": create-begin-block-with align" -map -docstring "equation" global latex-insert-block E ": create-begin-block-with equation" -map -docstring "equation*" global latex-insert-block ": create-begin-block-with equation*" -map -docstring "Matrix" global latex-insert-block m ": create-begin-block-with bmatrix" -map -docstring "Cases" global latex-insert-block C ": create-begin-block-with cases" -map -docstring "Table" global latex-insert-block T ": create-begin-block-with tabular" -## Custom -map -docstring "Custom" global latex-insert-block c ": create-begin-block" - -# Pairs of delimiters -declare-user-mode latex-insert-delims -map -docstring "Grouping" global latex-insert-delims g ": create-delims { }" -map -docstring "Parentheses" global latex-insert-delims p ": create-delims ( )" -map -docstring "Large Parentheses" global latex-insert-delims P ": create-delims \left( \right)" -map -docstring "Brackets" global latex-insert-delims b ": create-delims \left[ \right]" -map -docstring "Sets" global latex-insert-delims s ": create-delims \{ \}" -map -docstring "Large Sets" global latex-insert-delims S ": create-delims \left\{ \right\}" - - -hook global WinSetOption filetype=(tex|latex) %{ - ## Create delims (shortcuts) - map buffer normal ": enter-user-mode latex-insert-delimsp" - map buffer insert ": enter-user-mode latex-insert-delimsp" - map buffer normal ": enter-user-mode latex-insert-delimsg" - map buffer insert ": enter-user-mode latex-insert-delimsg" - map buffer normal "i\(\)Zhhi" - map buffer insert "\(\)Z2h" - map buffer normal "i\[\]Zhhi" - map buffer insert "\[\]Z2h" - map buffer normal ": enter-user-mode latex-insert-delims" - map buffer insert ": enter-user-mode latex-insert-delims" - - ## Quickly create begin/end blocks - map buffer normal ": create-begin-block" - map buffer insert ": create-begin-block" - - ## Font menu - map buffer normal ": enter-user-mode latex-font" - map buffer insert ": enter-user-mode latex-font" - - ## Insert menu - map buffer normal ": enter-user-mode latex-insert-block" - map buffer insert ": enter-user-mode latex-insert-block" - - ## Select math equations and environment blocks - map buffer object e -docstring "Inline Math equation \( \)" "c\\\\\\(,\\\\\\)" - map buffer object E -docstring "Display Math equation \[ \]" "c\\\\\\[,\\\\\\]" - map buffer object v -docstring "Simple environment \env{}" "c\\\\\\w+\\{,\\}" - map buffer object V -docstring "Full environment \begin{env}\end{env}" "c\\\\begin\\{\\w+\\}(?:\\{[\\w\\s]*\\})*(?:\\[[\\w\\s]*\\])*,\\\\end\\{\\w+\\}" - - ## Quickly get a new item - map buffer normal "o\item " - map buffer insert "o\item " -} - diff --git a/home/kakoune/autoload/markdown.kak b/home/kakoune/autoload/markdown.kak deleted file mode 100644 index fb10581..0000000 --- a/home/kakoune/autoload/markdown.kak +++ /dev/null @@ -1,29 +0,0 @@ -hook global WinSetOption filetype=(markdown) %{ - map buffer normal ": enter-user-mode markdown-menu" -} - -# A menu for common markdown actions -declare-user-mode markdown-menu - -map -docstring "Toggle the checkboxes on the same line" global markdown-menu t ": markdown-toggle-checkbox" - -define-command -hidden markdown-toggle-checkbox %{ - try %{ - execute-keys -draft "xs^\s*- \[( |x)\]h: markdown-toggle-checkbox-selections" - } -} - -define-command -hidden markdown-toggle-checkbox-selections %{ - try %{ - execute-keys -draft -itersel ": markdown-toggle-checkbox-one" - } -} - -define-command -hidden markdown-toggle-checkbox-one %{ - try %{ - execute-keys -draft "sxr " - } catch %{ - execute-keys -draft "s rx" - } -} - diff --git a/home/kakoune/catppuccin-latte.kak b/home/kakoune/catppuccin-latte.kak deleted file mode 100644 index bd40ead..0000000 --- a/home/kakoune/catppuccin-latte.kak +++ /dev/null @@ -1,79 +0,0 @@ -# Catppuccin theme for Kakoune - -declare-option str rosewater "rgb:dc8a78" -declare-option str flamingo "rgb:dd7878" -declare-option str pink "rgb:ea76cb" -declare-option str mauve "rgb:8839ef" -declare-option str red "rgb:d20f39" -declare-option str maroon "rgb:e64553" -declare-option str peach "rgb:fe640b" -declare-option str yellow "rgb:df8e1d" -declare-option str green "rgb:40a02b" -declare-option str teal "rgb:179299" -declare-option str sky "rgb:04a5e5" -declare-option str sapphire "rgb:209fb5" -declare-option str blue "rgb:1e66f5" -declare-option str lavender "rgb:7287fd" -declare-option str text "rgb:4c4f69" -declare-option str subtext1 "rgb:5c5f77" -declare-option str subtext0 "rgb:6c6f85" -declare-option str overlay2 "rgb:7c7f93" -declare-option str overlay1 "rgb:8c8fa1" -declare-option str overlay0 "rgb:9ca0b0" -declare-option str surface2 "rgb:acb0be" -declare-option str surface1 "rgb:bcc0cc" -declare-option str surface0 "rgb:ccd0da" -declare-option str base "rgb:eff1f5" -declare-option str mantle "rgb:e6e9ef" -declare-option str crust "rgb:dce0e8" - - -set-face global title "%opt{text}+b" -set-face global header "%opt{subtext0}+b" -set-face global bold "%opt{maroon}+b" -set-face global italic "%opt{maroon}+i" -set-face global mono "%opt{green}" -set-face global block "%opt{sapphire}" -set-face global link "%opt{blue}" -set-face global bullet "%opt{peach}" -set-face global list "%opt{peach}" - -set-face global Default "%opt{text},%opt{base}" -set-face global PrimarySelection "%opt{text},%opt{surface2}" -set-face global SecondarySelection "%opt{text},%opt{surface2}" -set-face global PrimaryCursor "%opt{crust},%opt{rosewater}" -set-face global SecondaryCursor "%opt{text},%opt{overlay0}" -set-face global PrimaryCursorEol "%opt{surface2},%opt{lavender}" -set-face global SecondaryCursorEol "%opt{surface2},%opt{overlay1}" -set-face global LineNumbers "%opt{overlay1},%opt{base}" -set-face global LineNumberCursor "%opt{rosewater},%opt{surface2}+b" -set-face global LineNumbersWrapped "%opt{rosewater},%opt{surface2}+i" -set-face global MenuForeground "%opt{text},%opt{surface1}+b" -set-face global MenuBackground "%opt{text},%opt{surface0}" -set-face global MenuInfo "%opt{crust},%opt{teal}" -set-face global Information "%opt{crust},%opt{teal}" -set-face global Error "%opt{crust},%opt{red}" -set-face global StatusLine "%opt{text},%opt{mantle}" -set-face global StatusLineMode "%opt{crust},%opt{yellow}" -set-face global StatusLineInfo "%opt{crust},%opt{teal}" -set-face global StatusLineValue "%opt{crust},%opt{yellow}" -set-face global StatusCursor "%opt{crust},%opt{rosewater}" -set-face global Prompt "%opt{teal},%opt{base}+b" -set-face global MatchingChar "%opt{maroon},%opt{base}" -set-face global Whitespace "%opt{overlay1},%opt{base}+f" -set-face global WrapMarker "Whitespace" -set-face global BufferPadding "%opt{base},%opt{base}" - -set-face global value "%opt{peach}" -set-face global type "%opt{blue}" -set-face global variable "%opt{text}" -set-face global module "%opt{maroon}" -set-face global function "%opt{blue}" -set-face global string "%opt{green}" -set-face global keyword "%opt{mauve}" -set-face global operator "%opt{sky}" -set-face global attribute "%opt{green}" -set-face global comment "%opt{overlay0}" -set-face global documentation "comment" -set-face global meta "%opt{yellow}" -set-face global builtin "%opt{red}" diff --git a/home/kakoune/kakrc b/home/kakoune/kakrc deleted file mode 100644 index c254669..0000000 --- a/home/kakoune/kakrc +++ /dev/null @@ -1,233 +0,0 @@ -# Enable kak-tree-sitter -eval %sh{test -z "$WE_STARTED_KAK" && kak-tree-sitter --kakoune -d --server --init $kak_session} -map global normal ": enter-user-mode tree-sitter" -# ## Set some color overrides -# set global kts_yellow "rgb:e2b75e" -# set global kts_teal "rgb:008080" -# set global kts_mauve "rgb:c264ff" -# set global kts_sky "rgb:6aa622" -# Color scheme -colorscheme catppuccin-latte -set global base "default" - -# Set indentation guides -add-highlighter global/indent-guides show-whitespaces -tab " " -spc " " -lf " " -nbsp " " -set-face global Whitespace default,default -set-face global WhitespaceIndent +d@comment - -# Assistant -set global ui_options terminal_assistant=cat - -# Enable line numbers -hook global WinCreate .* %{ - addhl window/number-lines number-lines -} - -set global grepcmd "rg --line-number --no-column --no-heading --color=never " - -# Kitty-specific options -hook -group windowing global KakBegin .* %{ - set global kitty_window_type os-window -} - -# Comment line and block -map global normal <#> ': comment-line' -map global normal ': comment-block' - -# Go to grep-jump -map global goto f -docstring "current grep-jump match" ': grep-jump' - -# System clipboard interactions -hook global RegisterModified '"' %{ nop %sh{ - printf "%s" "$kak_main_reg_dquote" | pbcopy >/dev/null 2>/dev/null & -}} -map global user P -docstring "Paste before cursor from clipboard" '! pbpaste -n | cat' -map global user p -docstring "Paste after cursor from clipboard" ' pbpaste -n | cat' -map global user R -docstring "Replace selection with text from clipboard" '! pbpaste -n | cat' -define-command -params 0 -docstring "Copy line down" copyline %{ - execute-keys -draft 'xy'%val{count}'P' -} -map global normal <+> -docstring "Copy line down" ': copyline' -define-command -params 0 -docstring "Delete current pair of brackets" delete-current-brackets %{ - execute-keys 'm' - execute-keys -draft 'd' - execute-keys 'H' -} -map global normal D ": delete-current-brackets" - -# Disable write-to -# unalias global w -# define-command -params 0 -docstring "Writes the current file" w "write" - -# Tab sizes -hook global InsertChar \t %{ exec -draft -itersel h@ } -set global tabstop 2 -set global indentwidth 2 - -# Language-specific tabstop with override -hook global WinSetOption filetype=(rust) %{ - set window tabstop 4 - set window indentwidth 4 -} - -# Ctrl + a in insert mode = esc -map global insert '' - -# Tab completion -hook global InsertCompletionShow .* %{ - try %{ - # this command temporarily removes cursors preceded by whitespace; - # if there are no cursors left, it raises an error, does not - # continue to execute the mapping commands, and the error is eaten - # by the `try` command so no warning appears. - execute-keys -draft 'h\h' - map window insert - map window insert - } -} -hook global InsertCompletionHide .* %{ - unmap window insert - unmap window insert -} - -# Enable LSP -try %{ - eval %sh{test -z "$WE_STARTED_KAK" && kak-lsp --kakoune -s $kak_session} - set-option global lsp_cmd "kak-lsp -s %val{session}" -} -hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|fsharp|ocaml|haskell|nix|scala|typst|html|css|json|markdown|templ|elixir) %{ - lsp-enable-window - map window lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" - map window normal ": enter-user-mode lsp" - map window normal ": lsp-hover" - map window normal ": lsp-hover-buffer" - # lsp-auto-hover-insert-mode-enable - set window lsp_hover_anchor true - map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' - map global object a 'lsp-object' -docstring 'LSP any symbol' - map global object 'lsp-object' -docstring 'LSP any symbol' - map global object f 'lsp-object Function Method' -docstring 'LSP function or method' - map global object t 'lsp-object Class Interface Struct' -docstring 'LSP class interface or struct' - map global object d 'lsp-diagnostic-object --include-warnings' -docstring 'LSP errors and warnings' - map global object D 'lsp-diagnostic-object' -docstring 'LSP errors' -} - -hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|haskell|nix|fsharp|templ) %{ - # Format the document if possible - hook window BufWritePre .* %{ lsp-formatting-sync } -} - -hook global WinSetOption filetype=(rust|scala|fsharp) %{ - # Enable inlay hints - lsp-inlay-hints-enable window -} - -hook global WinSetOption filetype=(rust|go|fsharp|typst|scala) %{ - hook window -group semantic-tokens BufReload .* lsp-semantic-tokens - hook window -group semantic-tokens NormalIdle .* lsp-semantic-tokens - hook window -group semantic-tokens InsertIdle .* lsp-semantic-tokens - hook -once -always window WinSetOption filetype=.* %{ - remove-hooks window semantic-tokens - } -} - -# in Insert mode moves to end of line. -map global insert 'A' - -hook global WinSetOption filetype=(fsharp) %{ - set-option window comment_line "//" - # Set up formatting - # set-option window formatcmd "~/.dotnet/tools/fantomas --stdin --stdout" - # hook window -group fsharp-format BufWritePre .* %{ format } -} - -hook global WinSetOption filetype=(ocaml) %{ - unset-option buffer comment_line - set-option buffer comment_block_begin "(*" - set-option buffer comment_block_end "*)" -} - -hook global WinSetOption filetype=(haskell) %{ - set-option buffer makecmd "cabal build" -} - -hook global WinSetOption filetype=(rust) %{ - set-option buffer makecmd "cargo check" -} - -hook global WinSetOption filetype=(scala) %{ - # Format the document if possible - hook -group scala-fmt window BufWritePre .* %{ lsp-formatting-sync } -} - -hook global WinSetOption filetype=(typst) %{ - set-option window comment_line "//" - set-option window comment_block_begin "/*" - set-option window comment_block_end "*/" - - # borrow markdown's hooks - require-module markdown - - hook window ModeChange pop:insert:.* -group markdown-trim-indent markdown-trim-indent - hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line - hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } -} - - -define-command -params 0 -docstring "Set up build" scala-build-connect %{ - lsp-execute-command 'build-connect' '"[]"' -} - -define-command -params 0 -docstring "Import build" scala-build-import %{ - lsp-execute-command 'build-import' '"[]"' -} - -def -hidden insert-c-n %{ - try %{ - lsp-snippets-select-next-placeholders - exec 'd' - } catch %{ - exec -with-hooks '' - } -} -map global insert ": insert-c-n" - -# Use C++ for .h headers -hook global BufCreate .*[.](h) %{ - set-option buffer filetype cpp -} - -hook global BufCreate .*[.]kakrc %{ - set-option buffer filetype kak -} - -hook global BufCreate .*[.]md %{ - add-highlighter buffer/ wrap -} - -hook global BufCreate .*[.](sc|sbt) %{ - set-option buffer filetype scala -} - -hook global BufCreate .*[.]typ %{ - set-option buffer filetype typst - add-highlighter buffer/ wrap -} - -hook global BufCreate .*[.]templ %{ - set-option buffer filetype templ - set-option buffer comment_line "//" -} - -hook global BufCreate .*[.]hylo %{ - set-option buffer filetype hylo - set-option buffer comment_line "//" -} - -hook global BufOpenFile .* %{ - modeline-parse -} - -map global normal ':inc-dec-modify-numbers + %val{count}' -map global normal ':inc-dec-modify-numbers - %val{count}' diff --git a/home/kakoune/kaktex b/home/kakoune/kaktex deleted file mode 100755 index bdcf722..0000000 --- a/home/kakoune/kaktex +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env fish - -function usage - echo "Usage: " - echo " kaktex set [client] [session]" - echo " kaktex jump [file] [line] [column]" - exit 1 -end - -if test (count $argv) -lt 3 - usage -end - -switch $argv[1] - case "set" - set -U _kaktex_client $argv[2] - set -U _kaktex_session $argv[3] - case "jump" - echo " - evaluate-commands -client $_kaktex_client %{ - evaluate-commands -try-client $_kaktex_client %{ - edit -existing -- $argv[2] $(math $argv[3] + 1) $(math $argv[4] + 1) - } - } - " | kak -p $_kaktex_session - case '*' - usage -end diff --git a/home/kakoune/kaktex.nix b/home/kakoune/kaktex.nix deleted file mode 100644 index 1256c79..0000000 --- a/home/kakoune/kaktex.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - # Source kaktex whenever we have a tex file - programs.my-kakoune.rc = '' - hook global WinSetOption filetype=(tex|latex) %{ - hook window WinDisplay '.*' %{ - eval %sh{ - ${./kaktex} set $kak_client $kak_session - } - } - } - ''; -} diff --git a/home/kakoune/source-pwd b/home/kakoune/source-pwd deleted file mode 100755 index 35e5b0f..0000000 --- a/home/kakoune/source-pwd +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env fish - -if test (pwd) = "/home/natsukagami/.config/kak" - exit 0 -end - -while true - set kakrc (pwd)/.kakrc - if test -f $kakrc - echo source $kakrc - end - if test (pwd) = "/" - exit 0 - end - cd .. -end From 75b3f8d1f4c296c0ffa58cc2e650a12c122bd4b4 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 22 Oct 2024 15:36:22 +0200 Subject: [PATCH 10/53] podman: add slirp4netns to the wrapper --- modules/common/linux/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/common/linux/default.nix b/modules/common/linux/default.nix index 2fae826..91c37ab 100644 --- a/modules/common/linux/default.nix +++ b/modules/common/linux/default.nix @@ -71,6 +71,7 @@ let virtualisation = { pkgs, ... }: mkIf cfg.enable { virtualisation.podman = { enable = true; + extraPackages = [ pkgs.slirp4netns ]; dockerCompat = true; defaultNetwork.settings.dns_enabled = true; }; From 75f8ce74c5fa91af40f7860c18edba732e2097ea Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 4 Nov 2024 14:48:54 +0100 Subject: [PATCH 11/53] Update templ and vscode langservers --- home/kakoune.nix | 4 ++-- packages/common/nki-kakoune/lsp.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/home/kakoune.nix b/home/kakoune.nix index 1963430..5e10869 100644 --- a/home/kakoune.nix +++ b/home/kakoune.nix @@ -98,8 +98,8 @@ in src = pkgs.fetchFromGitHub { owner = "vrischmann"; repo = "tree-sitter-templ"; - rev = "044ad200092170727650fa6d368df66a8da98f9d"; - hash = "sha256-hJuB3h5pp+LLfP0/7bAYH0uLVo+OQk5jpzJb3J9BNkY="; + rev = "4519e3ec9ca92754ca25659bb1fd410d5e0f8d88"; + hash = "sha256-ic5SlqDEZoYakrJFe0H9GdzravqovlL5sTaHjyhe74M="; }; in { diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix index 6511ee9..82f0b51 100644 --- a/packages/common/nki-kakoune/lsp.nix +++ b/packages/common/nki-kakoune/lsp.nix @@ -39,8 +39,8 @@ let command = "vscode-${name}-language-server"; filetypes = [ name "templ" ]; roots = [ "package.json" ".git" ]; + package = nodePackages.vscode-langservers-extracted; }; - package = nodePackages.vscode-langservers-extracted; }; in { From 1f7294581f367736da4cc436c07bf8dd49ea4905 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 18 Nov 2024 15:31:38 +0100 Subject: [PATCH 12/53] Remove vulkan fork patch --- overlay.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/overlay.nix b/overlay.nix index 75da770..d5f72de 100644 --- a/overlay.nix +++ b/overlay.nix @@ -87,13 +87,6 @@ let }) ]; }; - - # https://github.com/NixOS/nixpkgs/issues/334822 - vulkan-validation-layers = prev.vulkan-validation-layers.overrideAttrs (attrs: { - buildInputs = attrs.buildInputs ++ [ - final.spirv-tools - ]; - }); }; overlay-libs = final: prev: { From 07368dce7ee70d23ec2f71b7a68a56e3858ad683 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 30 Nov 2024 17:25:34 +0100 Subject: [PATCH 13/53] home: Add openrazer back --- nki-home/configuration.nix | 12 ++++++++++++ overlay.nix | 1 - overlays/openrazer/default.nix | 31 ------------------------------- 3 files changed, 12 insertions(+), 32 deletions(-) delete mode 100644 overlays/openrazer/default.nix diff --git a/nki-home/configuration.nix b/nki-home/configuration.nix index 1c0112c..a9456c1 100644 --- a/nki-home/configuration.nix +++ b/nki-home/configuration.nix @@ -5,6 +5,16 @@ { lib, config, pkgs, ... }: with lib; +let + openrazer = { pkgs, ... }: { + # Razer stuff + hardware.openrazer = { + enable = true; + users = [ "nki" ]; + }; + environment.systemPackages = with pkgs; [ polychromatic ]; + }; +in { imports = [ @@ -17,6 +27,7 @@ with lib; # Other services ../modules/personal/u2f.nix ./peertube-runner.nix + openrazer ]; # Kernel @@ -181,5 +192,6 @@ with lib; passwordFile = config.sops.secrets."scrobble/listenbrainz".path; }; }; + } diff --git a/overlay.nix b/overlay.nix index 88159df..1273836 100644 --- a/overlay.nix +++ b/overlay.nix @@ -140,7 +140,6 @@ in inputs.rust-overlay.overlays.default inputs.youmubot.overlays.default - (import ./overlays/openrazer) overlay-unstable overlay-needs-unstable overlay-packages diff --git a/overlays/openrazer/default.nix b/overlays/openrazer/default.nix deleted file mode 100644 index dfcff64..0000000 --- a/overlays/openrazer/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -final: prev: -let - version = "3.3.0"; - src = final.fetchFromGitHub { - owner = "openrazer"; - repo = "openrazer"; - rev = "v${version}"; - sha256 = "sha256-lElE1nIiJ5fk2DupHu43tmxRjRsS5xeL1Yz/LuRlgtM="; - }; -in -rec -{ - openrazer-daemon = prev.openrazer-daemon.overrideAttrs (old: { - inherit src version; - }); - - python3 = prev.python3.override { - packageOverrides = self: super: { - openrazer-daemon = super.openrazer-daemon.overrideAttrs (old: { - inherit src version; - }); - }; - }; - python3Packages = python3.pkgs; - - linuxPackages_latest = prev.linuxPackages_latest.extend (self: super: { - openrazer = super.openrazer.overrideAttrs (old: { - inherit src version; - }); - }); -} From 67f6aba9c57441186a6b287f4cf705a148a955a6 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 2 Dec 2024 21:15:07 +0100 Subject: [PATCH 14/53] Update nixpkgs and home-manager --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index d9e1d78..2fa3ba5 100644 --- a/flake.lock +++ b/flake.lock @@ -742,11 +742,11 @@ ] }, "locked": { - "lastModified": 1731887066, - "narHash": "sha256-uw7K/RsYioJicV79Nl39yjtfhdfTDU2aRxnBgvFhkZ8=", + "lastModified": 1732884235, + "narHash": "sha256-r8j6R3nrvwbT1aUp4EPQ1KC7gm0pu9VcV1aNaB+XG6Q=", "owner": "nix-community", "repo": "home-manager", - "rev": "f3a2ff69586f3a54b461526e5702b1a2f81e740a", + "rev": "819f682269f4e002884702b87e445c82840c68f2", "type": "github" }, "original": { @@ -1022,11 +1022,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1731890469, - "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", + "lastModified": 1732812356, + "narHash": "sha256-LNcgjOLArRlx2W6XSi0yc0xwLjrK3KF9LxAMqUgFDgw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5083ec887760adfe12af64830a66807423a859a7", + "rev": "581d7e4d23b91daf2afa0005a5d3d01d6a8884fe", "type": "github" }, "original": { From e4aae3b8ae4b1e12efe6dafba1bfce31a60fa443 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 3 Dec 2024 00:00:00 +0100 Subject: [PATCH 15/53] cloud: Update nixpkgs to 24.11 --- flake.lock | 16 ++++++++-------- flake.nix | 4 ++-- nki-personal-do/gitea.nix | 11 ++--------- nki-personal-do/headscale.nix | 22 ++++++++++++---------- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/flake.lock b/flake.lock index 2fa3ba5..501fa01 100644 --- a/flake.lock +++ b/flake.lock @@ -721,16 +721,16 @@ ] }, "locked": { - "lastModified": 1716736833, - "narHash": "sha256-rNObca6dm7Qs524O4st8VJH6pZ/Xe1gxl+Rx6mcWYo0=", + "lastModified": 1733050161, + "narHash": "sha256-lYnT+EYE47f5yY3KS/Kd4pJ6CO9fhCqumkYYkQ3TK20=", "owner": "nix-community", "repo": "home-manager", - "rev": "a631666f5ec18271e86a5cde998cba68c33d9ac6", + "rev": "62d536255879be574ebfe9b87c4ac194febf47c5", "type": "github" }, "original": { "owner": "nix-community", - "ref": "release-24.05", + "ref": "release-24.11", "repo": "home-manager", "type": "github" } @@ -1166,16 +1166,16 @@ }, "nixpkgs_9": { "locked": { - "lastModified": 1731239293, - "narHash": "sha256-q2yjIWFFcTzp5REWQUOU9L6kHdCDmFDpqeix86SOvDc=", + "lastModified": 1732981179, + "narHash": "sha256-F7thesZPvAMSwjRu0K8uFshTk3ZZSNAsXTIFvXBT+34=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9256f7c71a195ebe7a218043d9f93390d49e6884", + "rev": "62c435d93bf046a5396f3016472e8f7c8e2aed65", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-24.05", + "ref": "nixos-24.11", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 6699c7d..fc74abd 100644 --- a/flake.nix +++ b/flake.nix @@ -2,12 +2,12 @@ description = "nki's systems"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable"; nixos-hardware.url = "github:nixos/nixos-hardware"; darwin.url = "github:lnl7/nix-darwin/master"; darwin.inputs.nixpkgs.follows = "nixpkgs-unstable"; - home-manager.url = "github:nix-community/home-manager/release-24.05"; + home-manager.url = "github:nix-community/home-manager/release-24.11"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; home-manager-unstable.url = "github:nix-community/home-manager"; home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs-unstable"; diff --git a/nki-personal-do/gitea.nix b/nki-personal-do/gitea.nix index 237d6d5..be30f00 100644 --- a/nki-personal-do/gitea.nix +++ b/nki-personal-do/gitea.nix @@ -180,7 +180,6 @@ in MINIO_USE_SSL = "true"; MINIO_ENDPOINT = "60c0807121eb35ef52cdcd4a33735fa6.r2.cloudflarestorage.com"; MINIO_ACCESS_KEY_ID = "704c29ade7a8b438b77ab520da2799ca"; - MINIO_SECRET_ACCESS_KEY = "#miniosecretkey#"; MINIO_BUCKET = "dtth-gitea"; MINIO_LOCATION = "auto"; MINIO_CHECKSUM_ALGORITHM = "md5"; # R2 moment @@ -192,7 +191,8 @@ in stateDir = "/mnt/data/gitea"; - mailerPasswordFile = secrets."gitea/mailer-password".path; + secrets.mailer.PASSWD = secrets."gitea/mailer-password".path; + secrets.storage.MINIO_SECRET_ACCESS_KEY = config.sops.secrets."gitea/minio-secret-key".path; database = { inherit user; @@ -216,14 +216,7 @@ in # https://github.com/NixOS/nixpkgs/commit/93c1d370db28ad4573fb9890c90164ba55391ce7 serviceConfig.SystemCallFilter = mkForce "~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io @reboot @setuid @swap"; preStart = - let - configFile = "${config.services.forgejo.customDir}/conf/app.ini"; - in '' - # Update minio secret key - chmod u+w ${configFile} && \ - ${lib.getExe pkgs.replace-secret} '#miniosecretkey#' '${config.sops.secrets."gitea/minio-secret-key".path}' '${configFile}' && \ - chmod u-w ${configFile} # Import the signing subkey if cat ${config.services.forgejo.stateDir}/.gnupg/gpg.conf | grep -q ${signingKey}; then echo "Keys already imported" diff --git a/nki-personal-do/headscale.nix b/nki-personal-do/headscale.nix index acb6da1..d439d52 100644 --- a/nki-personal-do/headscale.nix +++ b/nki-personal-do/headscale.nix @@ -35,23 +35,25 @@ rec { settings = { server_url = "https://hs.dtth.ch"; - db_type = "postgres"; - db_host = "/var/run/postgresql"; # find out yourself - db_user = "headscale"; - db_name = "headscale"; + database.type = "postgres"; + database.postgres = { + host = "/var/run/postgresql"; # find out yourself + user = "headscale"; + name = "headscale"; + }; - dns_config = { - base_domain = host; + dns = { + base_domain = "dtth.ts"; }; noise = { private_key_path = "/var/lib/headscale/noise_private.key"; }; - ip_prefixes = [ - "fd7a:115c:a1e0::/48" - "100.64.0.0/10" - ]; + prefixes = { + v6 = "fd7a:115c:a1e0::/48"; + v4 = "100.64.0.0/10"; + }; derp.paths = [ secrets."headscale/derp-servers/vnm".path From 924944f8fe2589313add460f5c44f830c4b2bfc8 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 3 Dec 2024 14:29:16 +0100 Subject: [PATCH 16/53] cloud: add vikunja --- nki-personal-do/configuration.nix | 1 + nki-personal-do/secrets/secrets.yaml | 9 ++- nki-personal-do/vikunja.nix | 112 +++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 nki-personal-do/vikunja.nix diff --git a/nki-personal-do/configuration.nix b/nki-personal-do/configuration.nix index 447da89..3670b29 100644 --- a/nki-personal-do/configuration.nix +++ b/nki-personal-do/configuration.nix @@ -25,6 +25,7 @@ ./owncast.nix ./peertube.nix ./outline.nix + ./vikunja.nix ]; system.stateVersion = "21.11"; diff --git a/nki-personal-do/secrets/secrets.yaml b/nki-personal-do/secrets/secrets.yaml index c02ed8e..d041d34 100644 --- a/nki-personal-do/secrets/secrets.yaml +++ b/nki-personal-do/secrets/secrets.yaml @@ -5,7 +5,7 @@ authentik-oidc-client-secret: ENC[AES256_GCM,data:lD/xyU87nik68JX+T2H3Gw5ZqsSGzX cloudflare-dns-api-token: ENC[AES256_GCM,data:2ny3JehpK30fTUDKrbzHv1QOczriChRyMQn6kNPULpUJ+eVwdptLvg==,iv:8wNAn3oawzLez7sO4ZvhFXcaZIpFVKgKCvTBlszFHn8=,tag:fRaO+u/5MtAWnTiy2Zwh0Q==,type:str] #ENC[AES256_GCM,data:KWrVRQg+cLm5MUdfsYrh7hkI4CWkl4Z0sDj0769eebeXDy+veixrQrxh1ZW+ro3WLwoIdU/IH5DPM4TWYn2qoM5aDHjGX764pr1x,iv:uZHBsGvSHv9vd/Wragl1dYNJ+8vCcMit2K3SrMFlz7s=,tag:7z4LyADfQvXsM2vvtWru8w==,type:comment] traefik-dashboard-users: ENC[AES256_GCM,data:kviapOq+xzxhjryse+5DaZbXRS/LEYyjqqFbHymXAZVEkWlu0T5pZ2bxSNCbXN+tXnb0u+6YPgGCaRNPLW74AF1hO8W8QqlLDA==,iv:41bwPyFQcuOLILTjLWUu5Kcnct/MaIIJsMbllc+n7Y0=,tag:17HyUjfRUcLGb0FrUm1O2A==,type:str] -mail-users: ENC[AES256_GCM,data:qKLi42k8LT6ojxbPXQgbi6FlI2I6ge6qJn0aNj/Lp9iRjjnnuArdsLJTfBMB7rPUyKWELa7jPrh8cHzJZZX7PsaXt1x07tQrVitKY6aDMpmb0pdU5TsvRTNhMV8lNWDrQeDXMV3hfigFXDU9YYRowllTJn8Uh5m20oGm8xjQrc55pPd2mDRWUt8WdJYGIYvXJ4Dyc+kXwibFC5xb0+7sLIPOcL8SkurMk0v2E63oBvoR089ZOhgWZ2DtqsUF7cGMcEDj6D6GcH2tlIkhTXo/na0b6caK6/mSIHbz/cfeVD/kdphC+q9edqm5UAAm5SaBDsar5vrXZcgQfD3/iEDHpqfdNJQv7Jt1l4vfwSY6nx3BgjggAZpL7YKXME+5Qqrp/epSegailDled5GUOlXKtomzixTA4OsgTjhMFPPOR/GiBuNIbYoGWnnR6Zs6l9Nw5ITJXKFgwNQTZVkndvQcr1Bw6nQqBDXt1qgmTdKTtNkrWEfgyYBnJtQW6qS+rZL8RB1x9Rjnu5PE+ao4YzrZEnKcenlWRh7+1GUdkRPm5qJWAMnuT1LkBdUx4bUPGf1D8iQ12kMLa5NnMQMq4Yek,iv:fTsBB5yZYi47dk8JIDs1JmgtnK8dOhkNt481vqAU+ME=,tag:pAXBSgzPB8nDdAO9YXM02A==,type:str] +mail-users: ENC[AES256_GCM,data:/Ca14QPfdmVS8U/MpPgApi9FTfgE3PMojNBmJaOtGxf7RYrq0AjCqIq5d5Byzp7K92xrUdIKWSr+lTAxK7TnMbM9y8EdGJ1v+ZIgAW9dVEFVxZ+wm3dwaFZ5jLn+f6dwB9JdTVFvHuOyxf+abMiGAVxCJIxdV9JreEnS3tMJPIFdl97WFuBFG6DJlT9hjwvAmscXYQFioCHtmnvp/E4r+gMxOs04TLVj+vrhP/JbTgIJ2uTiaB9lYJbVMqeaz9W64LyQlPLeh1cdZHFtYN8vMR8UfkQIAVKRREEu0+/wjH5ZTEQsktjw2j1jNbz+mmcPnJLpfVWzZoAW7Dt+azQ+V4X1GP510q9JpfYZUuy6DtstIrbn3+CSqPm4oFmCD77ASwqOtKRvP0qbx8SC3Bn/s6zFHakxzTPLA5HtrDDhnqm3xl+PYdEW1wlINaVyvGtwK5SYUwVFJVGBdeiof2Zn9Zz2T417JAVN9C7qZ3BY2Ur8Fx9DDqZGclwJNhHC5HLaqWG4ajAJIeSzmtu8Bn5wmuF8c1AobkoljCunRjaXGfMt0+FVDnxkppXeONOiuLCw44Ii+ejZ3gxtz+xebYiLQhhYx2vOX1vJJfG0T8FDawTn32jlakmt1Nb9IzwgTWE/0yQAKJTjWztEahEcUUxmslISKPUlLtvCyUOf31Wq4Eg+iC0qMoKFTejp+DjLVwPhEMpNdMRA1JC8Wg==,iv:agQUE9UstOv/QYYamKWU6ouw9aSmrvl8HEYc8eTM25A=,tag:Qf+FuSpvfea9POljQ3UweQ==,type:str] youmubot-env: ENC[AES256_GCM,data:EQ9e6lmCrjofHiHyN5Qe4b2oplP9/3JKl0vuFp54Hw9aYIS7j3nqzWLCvV54ZK7j1PcQ+CQorjeCVMV0TUy1f1Pf3qjrLkdOdV7ICq540gdfXOeXuhAx2EILpGkwIYOdKmTMSO3l2QkOlM02RNOn1lq/DogAydkEq7gJ7qSWnUEr45oNCa1+LamH8vcbDmIyzUWWXyA5EQ==,iv:fnNGZ6OaZ4D71SvWPRynsMpO1IsvxjQ3XtrswNSY+Wo=,tag:cN/ZnKrjSfD6AbU9pYNl+Q==,type:str] outline: smtp-password: ENC[AES256_GCM,data:zpIi6jVB2Y7ksBOR8SGFgjOD1x3aS6dKa6taLKB8v2l9p92iWDti75qgB1puglmmq8mCzz8KXLrM0Bv7W8GWRg==,iv:6tKINzQcApmNuIbNn0kSzFJtwn3rky/uFG2Ff3lazUk=,tag:kjB6qB87tRQVpy32Pt3D5A==,type:str] @@ -42,6 +42,9 @@ peertube: ENC[AES256_GCM,data:YWySVZVTC26qPMcgSV5v4Vp1u69jGt7VV2ElQBSxvG/R589PCJ peertube-env: ENC[AES256_GCM,data:ZrWBwSfMuepIYTzHVCCSnpsXb+MTcOfklI0O/UdcGaR3RzO1R+/wXQcFlV46g9dvKLMOaH7bxrHeWxqPh/7hlPEYFYwlbwcX31MGiSeRyeR5YtVi0CmhiGRA3l8X5NMCpvZmNhnjYNuri/My86SMkjhuaFQ5+BjYISoJ5WnbNSqE9qgQKuJVu64hsOgaQQbmaBL/LU7Pv/vushbNg421kdbRnzCPcc3IzkVzsFsgYH2fdEJa3gE8M63eLn99PbA+e5cWEwGNkuoNuro2tnaMaX1PM6iTF+q0A8HbiEioNMRIdD9czatgF7EwKgCFNu44cm2lp/c5qj+Lm/nC,iv:+MjpreGr9M+Oe5DrDe5SIBKtLuIqtb0a50YvGhDZT2Y=,tag:gYGlMcgWwa1ZpbQb4XfMmQ==,type:str] nix-build-farm: private-key: ENC[AES256_GCM,data:bYQ5TAHgJ8rZmmnp0ZW9pM3p6e2ewAqz9+clp2lDnvPsU/YHr/POSW+UESvulT0UDI8t5th71py2G4BG3z9PdPaWw2iSm6hW3VITYCGYvLbF2yK6anSkww0ilpjwm5NXKJLTiPehkAqsZlZsAxeYw5bF0+7JjeH9+49jLOXtGD0uFSf5M3wVZcObzSYsdGaNKGYkokBYeZii1tdwZvAuUKKZ1eOvDAz5v6hjqZA7brDWr5IZXNCqRZOdyGQ5g3UP4o5XFnl57d1RAmKPK9WaTCjbi0hMfms4zldqGeXTRDAhvqMH2w/BY7KvgIOr+aQelTvQbOciq+DaZbzNgdI5gqrSUA19EEL04Qu/gjoVGwMhZ7Lq9+yS2Lb+xdhmn/99sbcRjaRqqjgzHRvbyirPT9EuEAdrijyuZzY9kASv8LN/Q8cawRZNk2vf0M8Qzg0F7iw2kcDrf+dwdcyrrAbg2XDlGsFBckBcPKA44PkOPtFLHZRU9pSpd15rL1JIes6m2YX7AmJFP2+FA5WjXQoqF+CRhBVUWXaXAmcq,iv:7Uqnu2xEcHotczRzIcDfq9bM7wNXdz0Fg2HNpxlV1/Q=,tag:w5aLsT9LN92+83rdP2YJTg==,type:str] +vikunja: + env: ENC[AES256_GCM,data:TyHSS5aqrzdKDki42vtTKj707R2HRWDCmKqU/ntUfHVADgy3fljpBslokbO2PdXH8/WbV42STALqPXdWvN6EYSpoE/NZECP35W0PS4bYhQfhvY/tMDiTR1aBTDJejzgadC1n4/uIeicbnzAU8BQNljilFGg3GIR+A36M42CJUjAHPAAOuKarz+5ADs/T1WJRL3kG30TVC8o=,iv:9PI4jjVmRcsVg7aYpSrxSxMofIflYZ0WYT5vRbB2Hxc=,tag:4AZmCfB8xLRfV9vFdp3Vng==,type:str] + provider-clientsecret: ENC[AES256_GCM,data:/fN1rH2CKoaivhespd+/KamERjBQOdwR7QQ+hoB+pQ3ZSrBVIKbLMWyOJe8f7rVwXAByqDxQIZJEVPjcjhWSU1eicwpu57FBx+/xJLFazspTVZ+5XKyAwR+UxTHDGAgtFV00QHN53l7ygg4joWWko4IPN1JIpNIASaIWWzpsrIo=,iv:NLsZcmE1kKlzV7B/XPVfENMWlpQtOpESH0ByX1KQ8IQ=,tag:P+ZmsKq0KJAeRTTbvbduMg==,type:str] sops: kms: [] gcp_kms: [] @@ -75,8 +78,8 @@ sops: by9kZFlTRVdCZFkxYTVVb0RIRk8zUlkKCqMw9oL9RaYBV5Hhy3o8Nm5xmGrPH8Sd hv36sxRFFNZT/DCKaHaSRbT3mfpBZSTXJt1dgl4nZe6whH54t/1KmA== -----END AGE ENCRYPTED FILE----- - lastmodified: "2024-10-26T12:06:05Z" - mac: ENC[AES256_GCM,data:nici08Luubj2xDfsi1s16VCyG5oizIC6DRfvypmjWRpn0DSpcoWW1j32ya2poEwzpBJoVksFp7ijyjaJv8obExKx94ZYc790eOp/kp1f8lBaHDF8qrYYPL5penkt+UTKeb8xb7BPCJ7O89IVkIjAt7EoQOliMYrLpbiZGkMdHE0=,iv:qY5+MjU5VaXAesuFGt4SgmEdcJ6+vb/mk+NdOPLjCik=,tag:poRJZW3sAMv6EMi64SEQyA==,type:str] + lastmodified: "2024-12-03T01:35:02Z" + mac: ENC[AES256_GCM,data:DrcQDEOAQZnyJ2e0hLdWJ3tYVuRBhYa/TcdoUV6/J3tLMcFYQRZXbO8GxQMMWAs6hZ4nqJWNihAbAwfwRqCLR5mmd2ntjjEYYcRzekWaqQ2JV+yCnXEMouUeVWabkrbbuB0k600Po8vsU2gMb6RtIf95YaUJRkA9dkkAyQVN1mU=,iv:av7TlBrMLHfnkOVzXyKSG9IfZOrDD2t1KCWWjJsmNTE=,tag:tKkYUn6Y32HwXYBHFO4CZg==,type:str] pgp: [] unencrypted_suffix: _unencrypted version: 3.9.1 diff --git a/nki-personal-do/vikunja.nix b/nki-personal-do/vikunja.nix new file mode 100644 index 0000000..0ed6177 --- /dev/null +++ b/nki-personal-do/vikunja.nix @@ -0,0 +1,112 @@ +{ pkgs, lib, config, ... }: +let + secrets = config.sops.secrets; + + host = "kanban.dtth.ch"; + user = "vikunja"; + port = 12785; + + storageMount = "/mnt/data/vikunja"; +in +{ + sops.secrets."vikunja/env" = { }; + sops.secrets."vikunja/provider-clientsecret" = { }; + cloud.postgresql.databases = [ user ]; + cloud.traefik.hosts.vikunja = { + inherit port host; + }; + + # users + users.users."${user}" = { + group = "${user}"; + isSystemUser = true; + }; + users.groups."${user}" = { }; + + + services.vikunja = { + inherit port; + enable = true; + package = + builtins.seq + (lib.assertMsg (pkgs.vikunja.version == "0.24.5") "Vikunja probably doesn't need custom versions anymore") + (pkgs.vikunja.overrideAttrs + (attrs: { + src = pkgs.fetchFromGitHub { + owner = "go-vikunja"; + repo = "vikunja"; + rev = "e57f04ec23e9ff8aa9877d2ea7d571c2a44790b0"; + hash = "sha256-W6o1h6XBPvT1lH1zO5N7HcodksKill5eqSuaFl2kfuY="; + }; + + passthru = attrs.passthru // { + overrideModAttrs = attrs: { + outputHash = "sha256-UWjlivF9ySXCAr84A1trCJ/n9pB98ZhEyG11qz3PL7g="; + }; + }; + })); + + frontendScheme = "https"; + frontendHostname = host; + + environmentFiles = [ secrets."vikunja/env".path ]; + + database = { + type = "postgres"; + host = "/var/run/postgresql"; + user = user; + database = user; + }; + + settings = { + service = { + publicurl = "https://${host}"; + enableregistration = false; + enablepublicteams = true; + }; + mailer = { + enabled = true; + host = "mx1.nkagami.me"; + port = 465; + forcessl = true; + }; + files.basepath = lib.mkForce storageMount; + auth = { + local.enabled = false; + openid = { + enabled = true; + providers.authentik = { + name = "DTTH Discord Account"; + authurl = "https://auth.dtth.ch/application/o/vikunja/"; + logouturl = "https://auth.dtth.ch/application/o/vikunja/end-session/"; + clientid = "GvCIBtdE2ZRbAo5BJzw4FbZjer7umJlaROT1Pvlp"; + scope = "openid profile email vikunja_scope"; + }; + }; + }; + defaultsettings = { + avatar_provider = "gravatar"; + week_start = 1; + language = "VN"; + timezone = "Asia/Ho_Chi_Minh"; + }; + }; + }; + + systemd.services.vikunja = { + serviceConfig.User = user; + serviceConfig.LoadCredential = [ "VIKUNJA_AUTH_OPENID_PROVIDERS_AUTHENTIK_CLIENTSECRET_FILE:${secrets."vikunja/provider-clientsecret".path}" ]; + serviceConfig.DynamicUser = lib.mkForce false; + environment.VIKUNJA_AUTH_OPENID_PROVIDERS_AUTHENTIK_CLIENTSECRET_FILE = "%d/VIKUNJA_AUTH_OPENID_PROVIDERS_AUTHENTIK_CLIENTSECRET_FILE"; + unitConfig = { + RequiresMountsFor = [ storageMount ]; + ReadWritePaths = [ storageMount ]; + }; + }; + systemd.tmpfiles.settings."10-vikunja".${storageMount}.d = { + user = user; + group = user; + mode = "0700"; + }; +} + From bfd19b166e8f2c86a56d59b2627ae126b4b73e59 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 7 Dec 2024 16:53:30 +0100 Subject: [PATCH 17/53] vikunja: add Todoist and Trello import --- nki-personal-do/secrets/secrets.yaml | 6 +++--- nki-personal-do/vikunja.nix | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/nki-personal-do/secrets/secrets.yaml b/nki-personal-do/secrets/secrets.yaml index d041d34..f671d26 100644 --- a/nki-personal-do/secrets/secrets.yaml +++ b/nki-personal-do/secrets/secrets.yaml @@ -43,7 +43,7 @@ peertube-env: ENC[AES256_GCM,data:ZrWBwSfMuepIYTzHVCCSnpsXb+MTcOfklI0O/UdcGaR3Rz nix-build-farm: private-key: ENC[AES256_GCM,data:bYQ5TAHgJ8rZmmnp0ZW9pM3p6e2ewAqz9+clp2lDnvPsU/YHr/POSW+UESvulT0UDI8t5th71py2G4BG3z9PdPaWw2iSm6hW3VITYCGYvLbF2yK6anSkww0ilpjwm5NXKJLTiPehkAqsZlZsAxeYw5bF0+7JjeH9+49jLOXtGD0uFSf5M3wVZcObzSYsdGaNKGYkokBYeZii1tdwZvAuUKKZ1eOvDAz5v6hjqZA7brDWr5IZXNCqRZOdyGQ5g3UP4o5XFnl57d1RAmKPK9WaTCjbi0hMfms4zldqGeXTRDAhvqMH2w/BY7KvgIOr+aQelTvQbOciq+DaZbzNgdI5gqrSUA19EEL04Qu/gjoVGwMhZ7Lq9+yS2Lb+xdhmn/99sbcRjaRqqjgzHRvbyirPT9EuEAdrijyuZzY9kASv8LN/Q8cawRZNk2vf0M8Qzg0F7iw2kcDrf+dwdcyrrAbg2XDlGsFBckBcPKA44PkOPtFLHZRU9pSpd15rL1JIes6m2YX7AmJFP2+FA5WjXQoqF+CRhBVUWXaXAmcq,iv:7Uqnu2xEcHotczRzIcDfq9bM7wNXdz0Fg2HNpxlV1/Q=,tag:w5aLsT9LN92+83rdP2YJTg==,type:str] vikunja: - env: ENC[AES256_GCM,data:TyHSS5aqrzdKDki42vtTKj707R2HRWDCmKqU/ntUfHVADgy3fljpBslokbO2PdXH8/WbV42STALqPXdWvN6EYSpoE/NZECP35W0PS4bYhQfhvY/tMDiTR1aBTDJejzgadC1n4/uIeicbnzAU8BQNljilFGg3GIR+A36M42CJUjAHPAAOuKarz+5ADs/T1WJRL3kG30TVC8o=,iv:9PI4jjVmRcsVg7aYpSrxSxMofIflYZ0WYT5vRbB2Hxc=,tag:4AZmCfB8xLRfV9vFdp3Vng==,type:str] + env: ENC[AES256_GCM,data:cHbpfD5THQidjF/Hx5QREJyUJApEHhtalLFMs3npY/zsS9WscCkpKwEPxOmxie/jB2iIQQvR5Xlvbnbr5DVAIduXy7KJCyDEUV1jyJI0+V1FeT5q+69fKg4Jbqz9S32ozMJP0agnKSIvMhZZ8vu+gyMU7UWro5r+VYtVsqb8TlC5Vn8vNK0GcB0nmRUxcBcjuywKhDBrGuAdXpNrb/fqLmnOe5iBk8oXqyyUjF6I+qVn+K8VMfl/Da/2pb7GbuXuQ4jJB1gVrN4+R3uRwB9iKlrc1lF+QJm+pCGqoQU9AjDHxDzIBaGYgSvU82EXUlbDBGyR9r/y0PQ8/59otE1A83EsMyMmA1CerncA8dM24Zv85O9tmsryqqPa6azfVi794tH6YT2lK2dBKxbn6cwusC7fRacON4JmMe2RLZWApZJF9xQd2h64Ffs4x9WC228vemRJC2iKp+Tj6CqCpcfHB/UJxyBaS5GSh6VJ1XV4gnilTLQBvOBgmXd4WOkHy1C1tEI8GKO+TJ0Q/TDuWMSb9hw+uGBi749OHOf5bizCRXo4IfdDt+g1KsnBp2ZLeX3wK3ucNR4UHUcb2MOT0gkRDljn8AhEwu9RrA4DmUTELclkMcyiiMJCl4kBdacjU1RM4GJ5AqqaeIzQd9ny5yRuU5ozQf3URaaRs3oAupAv/y0cuZo7ga80SQj8onxY3FCYeZpVZe+3Jjmx4Qqwrh5L7dNmVPTN1D2BF41oj6mCdM4fEconzt7L229QT/ZA,iv:W7vpIw2815QurKF3N18lP1eIqoc3IODfOvLyJOE0kA4=,tag:d2Ip7Y6Kwo4keP2hzQMwMQ==,type:str] provider-clientsecret: ENC[AES256_GCM,data:/fN1rH2CKoaivhespd+/KamERjBQOdwR7QQ+hoB+pQ3ZSrBVIKbLMWyOJe8f7rVwXAByqDxQIZJEVPjcjhWSU1eicwpu57FBx+/xJLFazspTVZ+5XKyAwR+UxTHDGAgtFV00QHN53l7ygg4joWWko4IPN1JIpNIASaIWWzpsrIo=,iv:NLsZcmE1kKlzV7B/XPVfENMWlpQtOpESH0ByX1KQ8IQ=,tag:P+ZmsKq0KJAeRTTbvbduMg==,type:str] sops: kms: [] @@ -78,8 +78,8 @@ sops: by9kZFlTRVdCZFkxYTVVb0RIRk8zUlkKCqMw9oL9RaYBV5Hhy3o8Nm5xmGrPH8Sd hv36sxRFFNZT/DCKaHaSRbT3mfpBZSTXJt1dgl4nZe6whH54t/1KmA== -----END AGE ENCRYPTED FILE----- - lastmodified: "2024-12-03T01:35:02Z" - mac: ENC[AES256_GCM,data:DrcQDEOAQZnyJ2e0hLdWJ3tYVuRBhYa/TcdoUV6/J3tLMcFYQRZXbO8GxQMMWAs6hZ4nqJWNihAbAwfwRqCLR5mmd2ntjjEYYcRzekWaqQ2JV+yCnXEMouUeVWabkrbbuB0k600Po8vsU2gMb6RtIf95YaUJRkA9dkkAyQVN1mU=,iv:av7TlBrMLHfnkOVzXyKSG9IfZOrDD2t1KCWWjJsmNTE=,tag:tKkYUn6Y32HwXYBHFO4CZg==,type:str] + lastmodified: "2024-12-07T15:37:34Z" + mac: ENC[AES256_GCM,data:iG2Nyy9vVyFni5n30ytm9fM6grpDIuCKy2oIjbAnlf98pIC3PXOW2DodTfyo5cP7Wqb5ursD8d89XhoDvB+ConWWyKTG982ek0C2PU8veiNTTlEuzNGg+GafadMyeK8zZv3Vvbc1tCH8bPyWkvLHKgEccX5YXj4rhC9JGch3Ry0=,iv:Milv9EVRVpiWrSYuXg4X1vUT+8EXVLH5CoCwiD1peQg=,tag:x5UWToiWeEHEwx+KhudJzQ==,type:str] pgp: [] unencrypted_suffix: _unencrypted version: 3.9.1 diff --git a/nki-personal-do/vikunja.nix b/nki-personal-do/vikunja.nix index 0ed6177..f576791 100644 --- a/nki-personal-do/vikunja.nix +++ b/nki-personal-do/vikunja.nix @@ -9,8 +9,8 @@ let storageMount = "/mnt/data/vikunja"; in { - sops.secrets."vikunja/env" = { }; - sops.secrets."vikunja/provider-clientsecret" = { }; + sops.secrets."vikunja/env" = { restartUnits = [ "vikunja.service" ]; }; + sops.secrets."vikunja/provider-clientsecret" = { restartUnits = [ "vikunja.service" ]; }; cloud.postgresql.databases = [ user ]; cloud.traefik.hosts.vikunja = { inherit port host; @@ -71,6 +71,10 @@ in forcessl = true; }; files.basepath = lib.mkForce storageMount; + migration = { + todoist.enable = true; + trello.enable = true; + }; auth = { local.enabled = false; openid = { @@ -97,10 +101,10 @@ in serviceConfig.User = user; serviceConfig.LoadCredential = [ "VIKUNJA_AUTH_OPENID_PROVIDERS_AUTHENTIK_CLIENTSECRET_FILE:${secrets."vikunja/provider-clientsecret".path}" ]; serviceConfig.DynamicUser = lib.mkForce false; + serviceConfig.ReadWritePaths = [ storageMount ]; environment.VIKUNJA_AUTH_OPENID_PROVIDERS_AUTHENTIK_CLIENTSECRET_FILE = "%d/VIKUNJA_AUTH_OPENID_PROVIDERS_AUTHENTIK_CLIENTSECRET_FILE"; unitConfig = { RequiresMountsFor = [ storageMount ]; - ReadWritePaths = [ storageMount ]; }; }; systemd.tmpfiles.settings."10-vikunja".${storageMount}.d = { From a3e4298d0aa006215ea97f66865e461ab93ba17e Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 7 Dec 2024 18:24:34 +0100 Subject: [PATCH 18/53] vikunja: Properly use the right frontend too --- nki-personal-do/secrets/secrets.yaml | 6 +- nki-personal-do/vikunja.nix | 19 +--- overlay.nix | 24 +---- packages/common/vikunja.nix | 128 +++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 41 deletions(-) create mode 100644 packages/common/vikunja.nix diff --git a/nki-personal-do/secrets/secrets.yaml b/nki-personal-do/secrets/secrets.yaml index f671d26..04f977b 100644 --- a/nki-personal-do/secrets/secrets.yaml +++ b/nki-personal-do/secrets/secrets.yaml @@ -43,7 +43,7 @@ peertube-env: ENC[AES256_GCM,data:ZrWBwSfMuepIYTzHVCCSnpsXb+MTcOfklI0O/UdcGaR3Rz nix-build-farm: private-key: ENC[AES256_GCM,data:bYQ5TAHgJ8rZmmnp0ZW9pM3p6e2ewAqz9+clp2lDnvPsU/YHr/POSW+UESvulT0UDI8t5th71py2G4BG3z9PdPaWw2iSm6hW3VITYCGYvLbF2yK6anSkww0ilpjwm5NXKJLTiPehkAqsZlZsAxeYw5bF0+7JjeH9+49jLOXtGD0uFSf5M3wVZcObzSYsdGaNKGYkokBYeZii1tdwZvAuUKKZ1eOvDAz5v6hjqZA7brDWr5IZXNCqRZOdyGQ5g3UP4o5XFnl57d1RAmKPK9WaTCjbi0hMfms4zldqGeXTRDAhvqMH2w/BY7KvgIOr+aQelTvQbOciq+DaZbzNgdI5gqrSUA19EEL04Qu/gjoVGwMhZ7Lq9+yS2Lb+xdhmn/99sbcRjaRqqjgzHRvbyirPT9EuEAdrijyuZzY9kASv8LN/Q8cawRZNk2vf0M8Qzg0F7iw2kcDrf+dwdcyrrAbg2XDlGsFBckBcPKA44PkOPtFLHZRU9pSpd15rL1JIes6m2YX7AmJFP2+FA5WjXQoqF+CRhBVUWXaXAmcq,iv:7Uqnu2xEcHotczRzIcDfq9bM7wNXdz0Fg2HNpxlV1/Q=,tag:w5aLsT9LN92+83rdP2YJTg==,type:str] vikunja: - env: ENC[AES256_GCM,data:cHbpfD5THQidjF/Hx5QREJyUJApEHhtalLFMs3npY/zsS9WscCkpKwEPxOmxie/jB2iIQQvR5Xlvbnbr5DVAIduXy7KJCyDEUV1jyJI0+V1FeT5q+69fKg4Jbqz9S32ozMJP0agnKSIvMhZZ8vu+gyMU7UWro5r+VYtVsqb8TlC5Vn8vNK0GcB0nmRUxcBcjuywKhDBrGuAdXpNrb/fqLmnOe5iBk8oXqyyUjF6I+qVn+K8VMfl/Da/2pb7GbuXuQ4jJB1gVrN4+R3uRwB9iKlrc1lF+QJm+pCGqoQU9AjDHxDzIBaGYgSvU82EXUlbDBGyR9r/y0PQ8/59otE1A83EsMyMmA1CerncA8dM24Zv85O9tmsryqqPa6azfVi794tH6YT2lK2dBKxbn6cwusC7fRacON4JmMe2RLZWApZJF9xQd2h64Ffs4x9WC228vemRJC2iKp+Tj6CqCpcfHB/UJxyBaS5GSh6VJ1XV4gnilTLQBvOBgmXd4WOkHy1C1tEI8GKO+TJ0Q/TDuWMSb9hw+uGBi749OHOf5bizCRXo4IfdDt+g1KsnBp2ZLeX3wK3ucNR4UHUcb2MOT0gkRDljn8AhEwu9RrA4DmUTELclkMcyiiMJCl4kBdacjU1RM4GJ5AqqaeIzQd9ny5yRuU5ozQf3URaaRs3oAupAv/y0cuZo7ga80SQj8onxY3FCYeZpVZe+3Jjmx4Qqwrh5L7dNmVPTN1D2BF41oj6mCdM4fEconzt7L229QT/ZA,iv:W7vpIw2815QurKF3N18lP1eIqoc3IODfOvLyJOE0kA4=,tag:d2Ip7Y6Kwo4keP2hzQMwMQ==,type:str] + env: ENC[AES256_GCM,data:wHwLaX7z31Ogee0fSIJ4EpP/FUHOmj8lESqPacmrgokf9+2NpG8OKt99csDiYM9EEq2S3P70N6r+Dhzxob53lmQhNK8JuvZqrZ1HxgvMXirjnkXl0LGqVHBM4QdMvxVkICRNc1GMrG6ZY4OBQkn5did1ZZiCuXFC/ByuNTqBNHXoZmZMrewF9MFY+wfGx7+gIYzZ5JF1sgkTqtBdnAiUT2t9AaYNc8qjoZvNj3sgMb35/tKG0CYpt0vz6QuMQwOBJNrRkh2lV7YgTcr1tOkTc2FvRoLLyDykl8fjUf9KDcJLz672E90D0rRA5oHp/Lk28sSThh9WAM0skJofjXMOpq9ScsljWovUuizXUVCg5O/79EyhI7zPX6M3C/415sWdmGLYcRYRq7Ww1IoRgi2j9nCDLstHSMgF1igRWnsBEIFISCmSURMHOZNMkxWsxJ+0HJoMX9bmoZLLMrkjCqyPi/1r0X90aforkmA2xB+pC8rvYBKSxXYt8Nfu6KOK1JsmKTMmmC1R1dswuXvt/qCCH0yf0tl7GrGACKkDerDXVDZj4+SygkXM2bQF/L/KjQI7UspSdmGUmAvjhX31Zt1qZoYa2E2gabBWSGgXDuNixgbL/twaUA1CcA+ZPVBH0oAlOCc0dLXy0OZSn2U4IV1NH//66s1cmWEQQs4GKxhXzABiBvYaSj45LQtnEo2/HaifKhBWPxkjY9fW85Hy4Bgock4ReHYKsCF0LbsgKZhZ+WQp9mjTGLKxmRJJskwSEgxLmjK+AC2FK8zq2COMQ/eOxHe9OxEwjiQs5xCwnYXt2wOMHcxg3yoBCkTxoqMLs11kWORqcXzyoW1rV5W5DHk8K+7a4N385arHyg9+9S2FtfFUL46/GPcqf7lw5qgCDP/An5lPQZxA7/ItLzxFkviSx+e/cNl3UMTdx2aX4dn4L2cv54GuXDMHVHw++onJJnqn97aczK4O5y0=,iv:4T7vftUcSOS84MpZUOM9ODA36GSrKeW5TClQM3GN2mk=,tag:5mzK4NsmmrYERRn+Vb01Eg==,type:str] provider-clientsecret: ENC[AES256_GCM,data:/fN1rH2CKoaivhespd+/KamERjBQOdwR7QQ+hoB+pQ3ZSrBVIKbLMWyOJe8f7rVwXAByqDxQIZJEVPjcjhWSU1eicwpu57FBx+/xJLFazspTVZ+5XKyAwR+UxTHDGAgtFV00QHN53l7ygg4joWWko4IPN1JIpNIASaIWWzpsrIo=,iv:NLsZcmE1kKlzV7B/XPVfENMWlpQtOpESH0ByX1KQ8IQ=,tag:P+ZmsKq0KJAeRTTbvbduMg==,type:str] sops: kms: [] @@ -78,8 +78,8 @@ sops: by9kZFlTRVdCZFkxYTVVb0RIRk8zUlkKCqMw9oL9RaYBV5Hhy3o8Nm5xmGrPH8Sd hv36sxRFFNZT/DCKaHaSRbT3mfpBZSTXJt1dgl4nZe6whH54t/1KmA== -----END AGE ENCRYPTED FILE----- - lastmodified: "2024-12-07T15:37:34Z" - mac: ENC[AES256_GCM,data:iG2Nyy9vVyFni5n30ytm9fM6grpDIuCKy2oIjbAnlf98pIC3PXOW2DodTfyo5cP7Wqb5ursD8d89XhoDvB+ConWWyKTG982ek0C2PU8veiNTTlEuzNGg+GafadMyeK8zZv3Vvbc1tCH8bPyWkvLHKgEccX5YXj4rhC9JGch3Ry0=,iv:Milv9EVRVpiWrSYuXg4X1vUT+8EXVLH5CoCwiD1peQg=,tag:x5UWToiWeEHEwx+KhudJzQ==,type:str] + lastmodified: "2024-12-07T15:58:00Z" + mac: ENC[AES256_GCM,data:ugW/IqGYYblO7GAM/W1PePKOJr5iJM42/SCHL8ew/QwXuOibhWWGkxObFeZ83u0DCmhH2fPqK/rI3seA6QLaWFeB2wrkyy4u13D5PISrObVtmQVD50kogObqd2CVdlQFIGQypw3/EB8oWNPcBRCvlAPPhZaB9a3SWS4CaTu+lPg=,iv:6IW7xOO9hBqK65WSLYnk7ViGs9xhoaMpsCeITbWNgHs=,tag:zXtnRBQemAT3cN1+QM7OHA==,type:str] pgp: [] unencrypted_suffix: _unencrypted version: 3.9.1 diff --git a/nki-personal-do/vikunja.nix b/nki-personal-do/vikunja.nix index f576791..2e25ec2 100644 --- a/nki-personal-do/vikunja.nix +++ b/nki-personal-do/vikunja.nix @@ -27,24 +27,6 @@ in services.vikunja = { inherit port; enable = true; - package = - builtins.seq - (lib.assertMsg (pkgs.vikunja.version == "0.24.5") "Vikunja probably doesn't need custom versions anymore") - (pkgs.vikunja.overrideAttrs - (attrs: { - src = pkgs.fetchFromGitHub { - owner = "go-vikunja"; - repo = "vikunja"; - rev = "e57f04ec23e9ff8aa9877d2ea7d571c2a44790b0"; - hash = "sha256-W6o1h6XBPvT1lH1zO5N7HcodksKill5eqSuaFl2kfuY="; - }; - - passthru = attrs.passthru // { - overrideModAttrs = attrs: { - outputHash = "sha256-UWjlivF9ySXCAr84A1trCJ/n9pB98ZhEyG11qz3PL7g="; - }; - }; - })); frontendScheme = "https"; frontendHostname = host; @@ -75,6 +57,7 @@ in todoist.enable = true; trello.enable = true; }; + backgrounds.providers.unsplash.enabled = true; auth = { local.enabled = false; openid = { diff --git a/overlay.nix b/overlay.nix index 1273836..2ed5783 100644 --- a/overlay.nix +++ b/overlay.nix @@ -74,26 +74,10 @@ let nativeMessagingHosts = with final; [ kdePackages.plasma-browser-integration ]; }); - # Add desktop file to premid - premid = final.symlinkJoin { - name = prev.premid.name; - paths = [ - prev.premid - (final.makeDesktopItem { - name = prev.premid.name; - desktopName = "PreMID"; - exec = "${final.lib.getExe prev.premid} --no-sandbox %U"; - icon = "premid"; - }) - ]; - }; - - # https://github.com/NixOS/nixpkgs/issues/334822 - vulkan-validation-layers = prev.vulkan-validation-layers.overrideAttrs (attrs: { - buildInputs = attrs.buildInputs ++ [ - final.spirv-tools - ]; - }); + vikunja = + builtins.seq + (final.lib.assertMsg (prev.vikunja.version == "0.24.5") "Vikunja probably doesn't need custom versions anymore") + (final.callPackage ./packages/common/vikunja.nix { }); }; overlay-libs = final: prev: { diff --git a/packages/common/vikunja.nix b/packages/common/vikunja.nix new file mode 100644 index 0000000..93fb842 --- /dev/null +++ b/packages/common/vikunja.nix @@ -0,0 +1,128 @@ +{ lib, fetchFromGitHub, stdenv, nodejs, pnpm, buildGoModule, mage, writeShellScriptBin, nixosTests, autoPatchelfHook, musl }: + +let + version = "0.24.5-git"; + src = fetchFromGitHub { + owner = "go-vikunja"; + repo = "vikunja"; + rev = "e57f04ec23e9ff8aa9877d2ea7d571c2a44790b0"; + hash = "sha256-W6o1h6XBPvT1lH1zO5N7HcodksKill5eqSuaFl2kfuY="; + }; + + frontend = stdenv.mkDerivation (finalAttrs: { + pname = "vikunja-frontend"; + inherit version src; + + sourceRoot = "${finalAttrs.src.name}/frontend"; + + pnpmDeps = pnpm.fetchDeps { + inherit (finalAttrs) pname version src sourceRoot; + hash = "sha256-sOCaJDBgEMID+lN5plQpSqaGBIUs5h2tAwDzhtOH53o="; + }; + + nativeBuildInputs = [ + nodejs + pnpm.configHook + autoPatchelfHook + ]; + + buildInputs = [ + musl # For sass-embedded + ]; + + doCheck = true; + dontAutoPatchelf = true; + + # See https://github.com/sass/embedded-host-node/issues/334 + preBuild = '' + autoPatchelf node_modules/.pnpm/sass-embedded* + ''; + + postBuild = '' + pnpm run build + ''; + + checkPhase = '' + pnpm run test:unit --run + ''; + + installPhase = '' + cp -r dist/ $out + ''; + }); + + # Injects a `t.Skip()` into a given test since there's apparently no other way to skip tests here. + skipTest = lineOffset: testCase: file: + let + jumpAndAppend = lib.concatStringsSep ";" (lib.replicate (lineOffset - 1) "n" ++ [ "a" ]); + in + '' + sed -i -e '/${testCase}/{ + ${jumpAndAppend} t.Skip(); + }' ${file} + ''; +in +buildGoModule { + inherit src version; + pname = "vikunja"; + + nativeBuildInputs = + let + fakeGit = writeShellScriptBin "git" '' + if [[ $@ = "describe --tags --always --abbrev=10" ]]; then + echo "${version}" + else + >&2 echo "Unknown command: $@" + exit 1 + fi + ''; + in + [ fakeGit mage ]; + + vendorHash = "sha256-UWjlivF9ySXCAr84A1trCJ/n9pB98ZhEyG11qz3PL7g="; + + inherit frontend; + + prePatch = '' + cp -r ${frontend} frontend/dist + ''; + + postConfigure = '' + # These tests need internet, so we skip them. + ${skipTest 1 "TestConvertTrelloToVikunja" "pkg/modules/migration/trello/trello_test.go"} + ${skipTest 1 "TestConvertTodoistToVikunja" "pkg/modules/migration/todoist/todoist_test.go"} + ''; + + buildPhase = '' + runHook preBuild + + # Fixes "mkdir /homeless-shelter: permission denied" - "Error: error compiling magefiles" during build + export HOME=$(mktemp -d) + mage build:build + + runHook postBuild + ''; + + checkPhase = '' + mage test:unit + mage test:integration + ''; + + installPhase = '' + runHook preInstall + install -Dt $out/bin vikunja + runHook postInstall + ''; + + passthru.tests.vikunja = nixosTests.vikunja; + + meta = { + changelog = "https://kolaente.dev/vikunja/api/src/tag/v${version}/CHANGELOG.md"; + description = "Todo-app to organize your life"; + homepage = "https://vikunja.io/"; + license = lib.licenses.agpl3Plus; + maintainers = with lib.maintainers; [ leona ]; + mainProgram = "vikunja"; + platforms = lib.platforms.linux; + }; +} From acf1e42b69d56c298e4419b303a7d3ffe4b34a3f Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 7 Dec 2024 19:26:34 +0100 Subject: [PATCH 19/53] Update nixpkgs-unstable --- flake.lock | 6 +++--- modules/personal/fonts/default.nix | 2 +- modules/services/nix-cache/default.nix | 2 +- overlay.nix | 17 ----------------- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/flake.lock b/flake.lock index 501fa01..f287845 100644 --- a/flake.lock +++ b/flake.lock @@ -1022,11 +1022,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1732812356, - "narHash": "sha256-LNcgjOLArRlx2W6XSi0yc0xwLjrK3KF9LxAMqUgFDgw=", + "lastModified": 1733376361, + "narHash": "sha256-aLJxoTDDSqB+/3orsulE6/qdlX6MzDLIITLZqdgMpqo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "581d7e4d23b91daf2afa0005a5d3d01d6a8884fe", + "rev": "929116e316068c7318c54eb4d827f7d9756d5e9c", "type": "github" }, "original": { diff --git a/modules/personal/fonts/default.nix b/modules/personal/fonts/default.nix index 5a02835..8d59fd8 100644 --- a/modules/personal/fonts/default.nix +++ b/modules/personal/fonts/default.nix @@ -8,7 +8,7 @@ with lib; packages = with pkgs; mkForce [ noto-fonts-emoji-blob-bin ibm-plex - (nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; }) + nerd-fonts.symbols-only noto-fonts (pkgs.noto-fonts-cjk-sans or pkgs.noto-fonts-cjk) merriweather diff --git a/modules/services/nix-cache/default.nix b/modules/services/nix-cache/default.nix index cfec3c3..1928ef0 100644 --- a/modules/services/nix-cache/default.nix +++ b/modules/services/nix-cache/default.nix @@ -39,7 +39,7 @@ in services.harmonia = mkIf cfg.enableServer { enable = true; - signKeyPath = cfg.privateKeyFile; + signKeyPaths = [ cfg.privateKeyFile ]; settings = { bind = bindAddr; priority = 45; diff --git a/overlay.nix b/overlay.nix index 2ed5783..e0bff79 100644 --- a/overlay.nix +++ b/overlay.nix @@ -9,9 +9,6 @@ let # Typst updates really quickly. typst = final.unstable.typst; typst-lsp = final.unstable.typst-lsp; - - # Until 0.35 is in - kitty = final.unstable.kitty; }; overlay-imported = final: prev: { sway = prev.sway.override { sway-unwrapped = final.swayfx-unwrapped; }; @@ -103,19 +100,6 @@ let nativeMessagingHosts = with final; [ kdePackages.plasma-browser-integration ]; }; }; - - overlay-rust-is-dumb = final: prev: { - # Use stable delta compiled with old Rust version - delta = final.stable.delta; - deepfilternet = final.stable.deepfilternet; - harmonia = final.callPackage - (import - (builtins.fetchurl { - url = "https://raw.githubusercontent.com/Mic92/nixpkgs/63f91202f5cd071187ede5e5ffc56003cb442876/pkgs/by-name/ha/harmonia/package.nix"; - sha256 = "1mz211c0bxn116ix0j5xx4wlglpbkfg7d3npw1z8hg9gc0vbj2xb"; - })) - { }; - }; in [ # inputs.swayfx.inputs.scenefx.overlays.override @@ -130,7 +114,6 @@ in overlay-imported overlay-versioning overlay-libs - overlay-rust-is-dumb (import ./packages/common) From dba80e2fd13c667ac575ebd4bb199b12566327ea Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 7 Dec 2024 19:36:01 +0100 Subject: [PATCH 20/53] Update authentik to 2024.10.4 --- modules/cloud/authentik/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/cloud/authentik/default.nix b/modules/cloud/authentik/default.nix index e0d6459..40e53a6 100644 --- a/modules/cloud/authentik/default.nix +++ b/modules/cloud/authentik/default.nix @@ -22,8 +22,8 @@ let }; authentik = mkImage { imageName = "ghcr.io/goauthentik/server"; - finalImageTag = "2024.8.2"; - imageDigest = "sha256:71984fdbb7a9414f5172bb446104d3fe4ab1ab412c8b3343bb97b04449dd53eb"; + finalImageTag = "2024.1.0.4"; + imageDigest = "sha256:5843c56a56be58dcee8927c705f8c9def0af7189511c0e8e687d430f543b0f6d"; }; }; authentikEnv = pkgs.writeText "authentik.env" '' From 48460fe71edf3ce88305f73aa57f2c67a9214431 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 3 Dec 2024 20:59:45 +0100 Subject: [PATCH 21/53] Add glab --- home/common.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/home/common.nix b/home/common.nix index 253c8b1..2034fce 100644 --- a/home/common.nix +++ b/home/common.nix @@ -26,6 +26,7 @@ ripgrep openssh tea # gitea CLI (gh-like) + glab # gitlab CLI fx # JSON viewer glow # Markdown viewer nix-output-monitor # Nice nix output formatting From ab5fcfd802e6185fb550ad2b219cded763f78a03 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 11 Dec 2024 16:14:49 +0100 Subject: [PATCH 22/53] yoga: enable vmware --- nki-yoga-g8/configuration.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nki-yoga-g8/configuration.nix b/nki-yoga-g8/configuration.nix index 672292f..faf8c3d 100644 --- a/nki-yoga-g8/configuration.nix +++ b/nki-yoga-g8/configuration.nix @@ -4,6 +4,14 @@ { config, pkgs, lib, ... }: +let + vmware = { pkgs, ... }: { + environment.systemPackages = [ pkgs.vmware-horizon-client ]; + virtualisation.vmware.host = { + enable = true; + }; + }; +in { imports = [ @@ -13,6 +21,8 @@ ../modules/personal/fonts # Encrypted DNS ../modules/services/edns + + vmware ]; # Secrets From abb7bd815c2ff73bdf279fc2e91ce4583770dc39 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 11 Dec 2024 17:07:12 +0100 Subject: [PATCH 23/53] yoga: new nerd-fonts not compatible with 24.11 --- modules/personal/fonts/default.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/personal/fonts/default.nix b/modules/personal/fonts/default.nix index 8d59fd8..99203d3 100644 --- a/modules/personal/fonts/default.nix +++ b/modules/personal/fonts/default.nix @@ -1,6 +1,13 @@ -{ pkgs, lib, ... }: +{ pkgs, lib, config, ... }: with lib; +let + nerd-fonts = + if builtins.hasAttr "nerd-fonts" pkgs then + pkgs.nerd-fonts.symbols-only + else + pkgs.nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; }; +in { imports = [ ./mounting.nix ]; # Fonts @@ -8,7 +15,7 @@ with lib; packages = with pkgs; mkForce [ noto-fonts-emoji-blob-bin ibm-plex - nerd-fonts.symbols-only + nerd-fonts noto-fonts (pkgs.noto-fonts-cjk-sans or pkgs.noto-fonts-cjk) merriweather From bd9604de5cd0189a483148b78af24b514f552120 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 11 Dec 2024 17:07:25 +0100 Subject: [PATCH 24/53] lanzaboote: update Will need manual intervention to re-set TPM keys --- flake.lock | 74 +++++++++++++++++++++--------------------------------- flake.nix | 2 +- 2 files changed, 30 insertions(+), 46 deletions(-) diff --git a/flake.lock b/flake.lock index f287845..99cdaeb 100644 --- a/flake.lock +++ b/flake.lock @@ -133,29 +133,17 @@ }, "crane_4": { "inputs": { - "flake-compat": [ - "lanzaboote", - "flake-compat" - ], - "flake-utils": [ - "lanzaboote", - "flake-utils" - ], "nixpkgs": [ "lanzaboote", "nixpkgs" - ], - "rust-overlay": [ - "lanzaboote", - "rust-overlay" ] }, "locked": { - "lastModified": 1681177078, - "narHash": "sha256-ZNIjBDou2GOabcpctiQykEQVkI8BDwk7TyvlWlI4myE=", + "lastModified": 1717535930, + "narHash": "sha256-1hZ/txnbd/RmiBPNUs7i8UQw2N89uAK3UzrGAWdnFfU=", "owner": "ipetkov", "repo": "crane", - "rev": "0c9f468ff00576577d83f5019a66c557ede5acf6", + "rev": "55e7754ec31dac78980c8be45f8a28e80e370946", "type": "github" }, "original": { @@ -319,11 +307,11 @@ "flake-compat_4": { "flake": false, "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { @@ -416,11 +404,11 @@ ] }, "locked": { - "lastModified": 1680392223, - "narHash": "sha256-n3g7QFr85lDODKt250rkZj2IFS3i4/8HBU2yKHO3tqw=", + "lastModified": 1717285511, + "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "dcc36e45d054d7bb554c9cdab69093debd91a0b5", + "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", "type": "github" }, "original": { @@ -521,11 +509,11 @@ "systems": "systems_5" }, "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -627,11 +615,11 @@ ] }, "locked": { - "lastModified": 1660459072, - "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", "owner": "hercules-ci", "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { @@ -800,16 +788,16 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1682802423, - "narHash": "sha256-Fb5TeRTdvUlo/5Yi2d+FC8a6KoRLk2h1VE0/peMhWPs=", + "lastModified": 1718178907, + "narHash": "sha256-eSZyrQ9uoPB9iPQ8Y5H7gAmAgAvCw3InStmU3oEjqsE=", "owner": "nix-community", "repo": "lanzaboote", - "rev": "64b903ca87d18cef2752c19c098af275c6e51d63", + "rev": "b627ccd97d0159214cee5c7db1412b75e4be6086", "type": "github" }, "original": { "owner": "nix-community", - "ref": "v0.3.0", + "ref": "v0.4.1", "repo": "lanzaboote", "type": "github" } @@ -1006,16 +994,16 @@ }, "nixpkgs-stable_2": { "locked": { - "lastModified": 1678872516, - "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", + "lastModified": 1710695816, + "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", + "rev": "614b4613980a522ba49f0d194531beddbb7220d3", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-22.11", + "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } @@ -1186,10 +1174,6 @@ "lanzaboote", "flake-compat" ], - "flake-utils": [ - "lanzaboote", - "flake-utils" - ], "gitignore": "gitignore", "nixpkgs": [ "lanzaboote", @@ -1198,11 +1182,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1681413034, - "narHash": "sha256-/t7OjNQcNkeWeSq/CFLYVBfm+IEnkjoSm9iKvArnUUI=", + "lastModified": 1717664902, + "narHash": "sha256-7XfBuLULizXjXfBYy/VV+SpYMHreNRHk9nKMsm1bgb4=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "d3de8f69ca88fb6f8b09e5b598be5ac98d28ede5", + "rev": "cc4d466cb1254af050ff7bdf47f6d404a7c646d1", "type": "github" }, "original": { @@ -1267,11 +1251,11 @@ ] }, "locked": { - "lastModified": 1682129965, - "narHash": "sha256-1KRPIorEL6pLpJR04FwAqqnt4Tzcm4MqD84yhlD+XSk=", + "lastModified": 1717813066, + "narHash": "sha256-wqbRwq3i7g5EHIui0bIi84mdqZ/It1AXBSLJ5tafD28=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "2c417c0460b788328220120c698630947547ee83", + "rev": "6dc3e45fe4aee36efeed24d64fc68b1f989d5465", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index fc74abd..8d3a2a8 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ # --- Secure boot lanzaboote = { - url = github:nix-community/lanzaboote/v0.3.0; + url = github:nix-community/lanzaboote/v0.4.1; inputs.nixpkgs.follows = "nixpkgs"; }; From f4a1a8e76c9395de49d9ab85b9efc498db3e4949 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 11 Dec 2024 18:13:05 +0100 Subject: [PATCH 25/53] zen: update to 1.0.2-b1 --- flake.lock | 79 ++++++++++++++++++++++- flake.nix | 1 + overlay.nix | 9 ++- packages/x86_64-linux/zen-browser-bin.nix | 32 --------- 4 files changed, 86 insertions(+), 35 deletions(-) delete mode 100644 packages/x86_64-linux/zen-browser-bin.nix diff --git a/flake.lock b/flake.lock index 99cdaeb..ff394c3 100644 --- a/flake.lock +++ b/flake.lock @@ -1040,6 +1040,22 @@ "type": "github" } }, + "nixpkgs_11": { + "locked": { + "lastModified": 1733759999, + "narHash": "sha256-463SNPWmz46iLzJKRzO3Q2b0Aurff3U1n0nYItxq7jU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a73246e2eef4c6ed172979932bc80e1404ba2d56", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1676300157, @@ -1219,7 +1235,8 @@ "rust-overlay": "rust-overlay_3", "secrets": "secrets", "sops-nix": "sops-nix", - "youmubot": "youmubot" + "youmubot": "youmubot", + "zen-browser": "zen-browser" } }, "rust-analyzer-src": { @@ -1545,6 +1562,66 @@ "repo": "youmubot", "type": "github" } + }, + "zen-browser": { + "inputs": { + "nixpkgs": "nixpkgs_11", + "zen-browser-aarch64": "zen-browser-aarch64", + "zen-browser-generic": "zen-browser-generic", + "zen-browser-specific": "zen-browser-specific" + }, + "locked": { + "lastModified": 1733866152, + "narHash": "sha256-r/uMP+ewTEoQLFaLa2EFktu9PCgOmat0xD1QvoPgwAY=", + "owner": "youwen5", + "repo": "zen-browser-flake", + "rev": "ebb6df0cf500b36ce76bcd49a1ad246e66d9edc3", + "type": "github" + }, + "original": { + "owner": "youwen5", + "repo": "zen-browser-flake", + "type": "github" + } + }, + "zen-browser-aarch64": { + "flake": false, + "locked": { + "lastModified": 1733825278, + "narHash": "sha256-UkfTh+p+8D5qP8ZmcdiTIvUay0kNBjWA9Bi6OVZu/b8=", + "type": "tarball", + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.0/zen.linux-aarch64.tar.bz2" + }, + "original": { + "type": "tarball", + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.0/zen.linux-aarch64.tar.bz2" + } + }, + "zen-browser-generic": { + "flake": false, + "locked": { + "lastModified": 1733829638, + "narHash": "sha256-4gEnE+4v3A35ggUCZOkqBOXcRE7vAV2A+kEDhJ3gpAs=", + "type": "tarball", + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.0/zen.linux-generic.tar.bz2" + }, + "original": { + "type": "tarball", + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.0/zen.linux-generic.tar.bz2" + } + }, + "zen-browser-specific": { + "flake": false, + "locked": { + "lastModified": 1733830242, + "narHash": "sha256-nXDJ1ZGrGkMr6tdkMgDTFfXJLbzUDSuVMUM5i8g79Rg=", + "type": "tarball", + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.0/zen.linux-specific.tar.bz2" + }, + "original": { + "type": "tarball", + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.0/zen.linux-specific.tar.bz2" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 8d3a2a8..8511cee 100644 --- a/flake.nix +++ b/flake.nix @@ -49,6 +49,7 @@ dtth-phanpy.url = "git+ssh://gitea@git.dtth.ch/nki-dtth/phanpy?ref=dtth-fork"; conduit.url = "gitlab:famedly/conduit/v0.9.0"; nix-gaming.url = github:fufexan/nix-gaming; + zen-browser.url = "github:youwen5/zen-browser-flake"; # --- Sources kakoune.url = github:mawww/kakoune; diff --git a/overlay.nix b/overlay.nix index e0bff79..6a7a134 100644 --- a/overlay.nix +++ b/overlay.nix @@ -96,8 +96,13 @@ let ) ++ (with final; [ libiconv ]); }; - zen-browser-bin = final.callPackage ./packages/x86_64-linux/zen-browser-bin.nix { - nativeMessagingHosts = with final; [ kdePackages.plasma-browser-integration ]; + zen-browser-bin = final.callPackage inputs.zen-browser.packages.${final.stdenv.system}.zen-browser.override { + wrap-firefox = opts: final.wrapFirefox (opts // { + nativeMessagingHosts = with final; [ kdePackages.plasma-browser-integration ]; + }); + zen-browser-unwrapped = final.callPackage inputs.zen-browser.packages.${final.stdenv.system}.zen-browser-unwrapped.override { + sources = inputs.zen-browser.inputs; + }; }; }; in diff --git a/packages/x86_64-linux/zen-browser-bin.nix b/packages/x86_64-linux/zen-browser-bin.nix deleted file mode 100644 index 18d3d67..0000000 --- a/packages/x86_64-linux/zen-browser-bin.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ appimageTools, fetchurl, nativeMessagingHosts ? [ ], ... }: -let - pname = "zen-browser-bin"; - version = "1.0.1-a.19"; - src = fetchurl { - url = "https://github.com/zen-browser/desktop/releases/download/${version}/zen-specific.AppImage"; - hash = "sha256-qAPZ4VyVmeZLRfL0kPHF75zyrSUFHKQUSUcpYKs3jk8="; - }; - - appimageContents = appimageTools.extract { - inherit pname version src; - }; - -in -appimageTools.wrapType2 { - inherit pname version src; - - extraInstallCommands = '' - mv $out/bin/${pname} $out/bin/zen - install -m 444 -D ${appimageContents}/zen.desktop $out/share/applications/zen.desktop - install -m 444 -D ${appimageContents}/usr/share/icons/hicolor/128x128/apps/zen.png \ - $out/share/icons/hicolor/128x128/apps/zen.png - - mkdir -p $out/lib/mozilla/native-messaging-hosts - for ext in ${toString nativeMessagingHosts}; do - ln -sLt $out/lib/mozilla/native-messaging-hosts $ext/lib/mozilla/native-messaging-hosts/* - done - ''; - - meta.mainProgram = "zen"; -} - From 840033ac1edddfae5fae62e87e2cec690743bc97 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 8 Dec 2024 00:14:14 +0100 Subject: [PATCH 26/53] Move docker directory to /mnt/data --- nki-personal-do/configuration.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nki-personal-do/configuration.nix b/nki-personal-do/configuration.nix index 3670b29..4ce1e55 100644 --- a/nki-personal-do/configuration.nix +++ b/nki-personal-do/configuration.nix @@ -61,6 +61,7 @@ ]; virtualisation.docker.enable = true; + virtualisation.docker.extraOptions = "--data-root /mnt/data/docker"; services.do-agent.enable = true; From 7a893711dc3ecbc860cb6cf487e3e435227e68cb Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 8 Dec 2024 00:21:57 +0100 Subject: [PATCH 27/53] Add authentik requirements to relevant services --- nki-personal-do/headscale.nix | 3 ++- nki-personal-do/miniflux.nix | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nki-personal-do/headscale.nix b/nki-personal-do/headscale.nix index d439d52..ddcd5db 100644 --- a/nki-personal-do/headscale.nix +++ b/nki-personal-do/headscale.nix @@ -27,7 +27,8 @@ rec { noCloudflare = true; }; - systemd.services.headscale.requires = [ "postgresql.service" ]; + systemd.services.headscale.requires = [ "postgresql.service" "arion-authentik.service" ]; + systemd.services.headscale.after = [ "postgresql.service" "arion-authentik.service" ]; services.headscale = { enable = true; inherit port; diff --git a/nki-personal-do/miniflux.nix b/nki-personal-do/miniflux.nix index f8157da..b8f3bcf 100644 --- a/nki-personal-do/miniflux.nix +++ b/nki-personal-do/miniflux.nix @@ -42,7 +42,7 @@ in systemd.services.miniflux = { description = "Miniflux service"; wantedBy = [ "multi-user.target" ]; - after = [ "network.target" ]; + after = [ "network.target" "postgresql.service" ]; requires = [ "postgresql.service" ]; serviceConfig = { From 28ce4a5feb5c40de89b5990087704cb097ccd043 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 8 Dec 2024 12:05:38 +0100 Subject: [PATCH 28/53] n8n: deploy --- nki-personal-do/configuration.nix | 3 +- nki-personal-do/n8n.nix | 71 ++++++++++++++++++++++++++++ nki-personal-do/secrets/secrets.yaml | 8 ++-- nki-personal-do/vikunja.nix | 2 +- 4 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 nki-personal-do/n8n.nix diff --git a/nki-personal-do/configuration.nix b/nki-personal-do/configuration.nix index 4ce1e55..81dc64c 100644 --- a/nki-personal-do/configuration.nix +++ b/nki-personal-do/configuration.nix @@ -26,6 +26,7 @@ ./peertube.nix ./outline.nix ./vikunja.nix + ./n8n.nix ]; system.stateVersion = "21.11"; @@ -153,7 +154,7 @@ }; # Mail - sops.secrets.mail-users = { owner = "maddy"; }; + sops.secrets.mail-users = { owner = "maddy"; reloadUnits = [ "maddy.service" ]; }; cloud.mail = { enable = true; debug = true; diff --git a/nki-personal-do/n8n.nix b/nki-personal-do/n8n.nix new file mode 100644 index 0000000..6da581e --- /dev/null +++ b/nki-personal-do/n8n.nix @@ -0,0 +1,71 @@ +{ config, lib, ... }: +let + secrets = config.sops.secrets; + + host = "n8n.dtth.ch"; + db = "n8n"; + user = db; + port = 23412; + + dataFolder = "/mnt/data/n8n"; +in +{ + sops.secrets."n8n/env" = { reloadUnits = [ "n8n.service" ]; }; + cloud.postgresql.databases = [ db ]; + cloud.traefik.hosts.n8n = { + inherit port host; + }; + + # users + users.users."${user}" = { + group = "${user}"; + isSystemUser = true; + }; + users.groups."${user}" = { }; + + services.n8n = { + enable = true; + webhookUrl = "https://${host}"; + }; + + systemd.services.n8n = { + environment = { + # Database + DB_TYPE = "postgresdb"; + DB_POSTGRESDB_DATABASE = db; + DB_POSTGRESDB_HOST = "/var/run/postgresql"; + DB_POSTGRESDB_USER = db; + # Deployment + N8N_EDITOR_BASE_URL = "https://${host}"; + N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS = "true"; + N8N_USER_FOLDER = lib.mkForce dataFolder; + HOME = lib.mkForce dataFolder; + N8N_HOST = host; + N8N_PORT = toString port; + N8N_LISTEN_ADDRESS = "127.0.0.1"; + N8N_HIRING_BANNER_ENABLED = "false"; + N8N_PROXY_HOPS = "1"; + # Logs + N8N_LOG_LEVEL = "debug"; + # License + N8N_HIDE_USAGE_PAGE = "true"; + # Security + N8N_BLOCK_ENV_ACCESS_IN_NODE = "true"; + # Timezone + GENERIC_TIMEZONE = "Europe/Berlin"; + }; + serviceConfig = { + EnvironmentFile = [ secrets."n8n/env".path ]; + User = user; + DynamicUser = lib.mkForce false; + ReadWritePaths = [ dataFolder ]; + # ReadOnlyPaths = [ "/var/run/postgresql" ]; + }; + unitConfig.RequiresMountsFor = [ dataFolder ]; + }; + systemd.tmpfiles.settings."10-n8n".${dataFolder}.d = { + user = user; + group = user; + mode = "0700"; + }; +} diff --git a/nki-personal-do/secrets/secrets.yaml b/nki-personal-do/secrets/secrets.yaml index 04f977b..b72c7e1 100644 --- a/nki-personal-do/secrets/secrets.yaml +++ b/nki-personal-do/secrets/secrets.yaml @@ -5,7 +5,7 @@ authentik-oidc-client-secret: ENC[AES256_GCM,data:lD/xyU87nik68JX+T2H3Gw5ZqsSGzX cloudflare-dns-api-token: ENC[AES256_GCM,data:2ny3JehpK30fTUDKrbzHv1QOczriChRyMQn6kNPULpUJ+eVwdptLvg==,iv:8wNAn3oawzLez7sO4ZvhFXcaZIpFVKgKCvTBlszFHn8=,tag:fRaO+u/5MtAWnTiy2Zwh0Q==,type:str] #ENC[AES256_GCM,data:KWrVRQg+cLm5MUdfsYrh7hkI4CWkl4Z0sDj0769eebeXDy+veixrQrxh1ZW+ro3WLwoIdU/IH5DPM4TWYn2qoM5aDHjGX764pr1x,iv:uZHBsGvSHv9vd/Wragl1dYNJ+8vCcMit2K3SrMFlz7s=,tag:7z4LyADfQvXsM2vvtWru8w==,type:comment] traefik-dashboard-users: ENC[AES256_GCM,data:kviapOq+xzxhjryse+5DaZbXRS/LEYyjqqFbHymXAZVEkWlu0T5pZ2bxSNCbXN+tXnb0u+6YPgGCaRNPLW74AF1hO8W8QqlLDA==,iv:41bwPyFQcuOLILTjLWUu5Kcnct/MaIIJsMbllc+n7Y0=,tag:17HyUjfRUcLGb0FrUm1O2A==,type:str] -mail-users: ENC[AES256_GCM,data:/Ca14QPfdmVS8U/MpPgApi9FTfgE3PMojNBmJaOtGxf7RYrq0AjCqIq5d5Byzp7K92xrUdIKWSr+lTAxK7TnMbM9y8EdGJ1v+ZIgAW9dVEFVxZ+wm3dwaFZ5jLn+f6dwB9JdTVFvHuOyxf+abMiGAVxCJIxdV9JreEnS3tMJPIFdl97WFuBFG6DJlT9hjwvAmscXYQFioCHtmnvp/E4r+gMxOs04TLVj+vrhP/JbTgIJ2uTiaB9lYJbVMqeaz9W64LyQlPLeh1cdZHFtYN8vMR8UfkQIAVKRREEu0+/wjH5ZTEQsktjw2j1jNbz+mmcPnJLpfVWzZoAW7Dt+azQ+V4X1GP510q9JpfYZUuy6DtstIrbn3+CSqPm4oFmCD77ASwqOtKRvP0qbx8SC3Bn/s6zFHakxzTPLA5HtrDDhnqm3xl+PYdEW1wlINaVyvGtwK5SYUwVFJVGBdeiof2Zn9Zz2T417JAVN9C7qZ3BY2Ur8Fx9DDqZGclwJNhHC5HLaqWG4ajAJIeSzmtu8Bn5wmuF8c1AobkoljCunRjaXGfMt0+FVDnxkppXeONOiuLCw44Ii+ejZ3gxtz+xebYiLQhhYx2vOX1vJJfG0T8FDawTn32jlakmt1Nb9IzwgTWE/0yQAKJTjWztEahEcUUxmslISKPUlLtvCyUOf31Wq4Eg+iC0qMoKFTejp+DjLVwPhEMpNdMRA1JC8Wg==,iv:agQUE9UstOv/QYYamKWU6ouw9aSmrvl8HEYc8eTM25A=,tag:Qf+FuSpvfea9POljQ3UweQ==,type:str] +mail-users: ENC[AES256_GCM,data:4ugvUKK1Hxlnt/bTrAe7pEt5Ehla6yfCzeeZkwaXGN0rlYO3zIFz2paajuFDVoZ1UOntxgdoL/bmS55SkvinQybzQqK+1HUb5N4esODZyJkf8qhacBjjUnDq2sK0GXmoWRoR36ny4haRTbfzTxoVph+Y81P6+T7etnMuARM55i/kWCTcKyin9WKkllLF8vEi6MdbvDj5fwVSxKYQZk2Ti4xY+hCGkEUFL3S2l4Hgbzt2irV0ccjU4+GXSrRepFWSakvDl0fuQf0N3oXMQWCYkRqsoPdtV/n1+C1all9HWtA4XNcnNHlPk7bbi51gO3fSQwmayrgsqO4QAIKY2oJMCrMOabvSjRF8pjR/WFqEMN6fLOCByPYTtej2JEDZ0mg/uQIuIh+Us+QIO/ulMSK+Cq4WTBsmN0V9tYucp1vNv2xzuLUN4GkHc0tRZ6jIVPFUCIGEgw9x7qVPNqFPgr4RFzGGP12746+UwHqDuBIz4od47aQMNrXJOD9xbX7mp54bqwkdASIP/5iBAsnzRDhg/9hHMkJrhPjzrGC4feVNYzI9yo+v0cOPworKYuSfk6KYX5SGu2HgcgCG7zGRL4/NoytNwDGoqBKWA81Xuyp9+vMFF//nm5bKQH6Zt2gVaMViyqKZrTkITrOZMaMKVkOeiJdQQpsM1jqU5ygsrHIq9jc8BJ2MbK8WW2wlfovAo2MNtSN68LknoWiMbEuRXIcC8rhvdVX9C++XT/JQH+kHwg==,iv:059jHrKniQmw2H45FDz/5DJqeTzKdsg9a51pX3FxvHE=,tag:aCMJOFv8PWtz80ouUqUCGA==,type:str] youmubot-env: ENC[AES256_GCM,data:EQ9e6lmCrjofHiHyN5Qe4b2oplP9/3JKl0vuFp54Hw9aYIS7j3nqzWLCvV54ZK7j1PcQ+CQorjeCVMV0TUy1f1Pf3qjrLkdOdV7ICq540gdfXOeXuhAx2EILpGkwIYOdKmTMSO3l2QkOlM02RNOn1lq/DogAydkEq7gJ7qSWnUEr45oNCa1+LamH8vcbDmIyzUWWXyA5EQ==,iv:fnNGZ6OaZ4D71SvWPRynsMpO1IsvxjQ3XtrswNSY+Wo=,tag:cN/ZnKrjSfD6AbU9pYNl+Q==,type:str] outline: smtp-password: ENC[AES256_GCM,data:zpIi6jVB2Y7ksBOR8SGFgjOD1x3aS6dKa6taLKB8v2l9p92iWDti75qgB1puglmmq8mCzz8KXLrM0Bv7W8GWRg==,iv:6tKINzQcApmNuIbNn0kSzFJtwn3rky/uFG2Ff3lazUk=,tag:kjB6qB87tRQVpy32Pt3D5A==,type:str] @@ -45,6 +45,8 @@ nix-build-farm: vikunja: env: ENC[AES256_GCM,data:wHwLaX7z31Ogee0fSIJ4EpP/FUHOmj8lESqPacmrgokf9+2NpG8OKt99csDiYM9EEq2S3P70N6r+Dhzxob53lmQhNK8JuvZqrZ1HxgvMXirjnkXl0LGqVHBM4QdMvxVkICRNc1GMrG6ZY4OBQkn5did1ZZiCuXFC/ByuNTqBNHXoZmZMrewF9MFY+wfGx7+gIYzZ5JF1sgkTqtBdnAiUT2t9AaYNc8qjoZvNj3sgMb35/tKG0CYpt0vz6QuMQwOBJNrRkh2lV7YgTcr1tOkTc2FvRoLLyDykl8fjUf9KDcJLz672E90D0rRA5oHp/Lk28sSThh9WAM0skJofjXMOpq9ScsljWovUuizXUVCg5O/79EyhI7zPX6M3C/415sWdmGLYcRYRq7Ww1IoRgi2j9nCDLstHSMgF1igRWnsBEIFISCmSURMHOZNMkxWsxJ+0HJoMX9bmoZLLMrkjCqyPi/1r0X90aforkmA2xB+pC8rvYBKSxXYt8Nfu6KOK1JsmKTMmmC1R1dswuXvt/qCCH0yf0tl7GrGACKkDerDXVDZj4+SygkXM2bQF/L/KjQI7UspSdmGUmAvjhX31Zt1qZoYa2E2gabBWSGgXDuNixgbL/twaUA1CcA+ZPVBH0oAlOCc0dLXy0OZSn2U4IV1NH//66s1cmWEQQs4GKxhXzABiBvYaSj45LQtnEo2/HaifKhBWPxkjY9fW85Hy4Bgock4ReHYKsCF0LbsgKZhZ+WQp9mjTGLKxmRJJskwSEgxLmjK+AC2FK8zq2COMQ/eOxHe9OxEwjiQs5xCwnYXt2wOMHcxg3yoBCkTxoqMLs11kWORqcXzyoW1rV5W5DHk8K+7a4N385arHyg9+9S2FtfFUL46/GPcqf7lw5qgCDP/An5lPQZxA7/ItLzxFkviSx+e/cNl3UMTdx2aX4dn4L2cv54GuXDMHVHw++onJJnqn97aczK4O5y0=,iv:4T7vftUcSOS84MpZUOM9ODA36GSrKeW5TClQM3GN2mk=,tag:5mzK4NsmmrYERRn+Vb01Eg==,type:str] provider-clientsecret: ENC[AES256_GCM,data:/fN1rH2CKoaivhespd+/KamERjBQOdwR7QQ+hoB+pQ3ZSrBVIKbLMWyOJe8f7rVwXAByqDxQIZJEVPjcjhWSU1eicwpu57FBx+/xJLFazspTVZ+5XKyAwR+UxTHDGAgtFV00QHN53l7ygg4joWWko4IPN1JIpNIASaIWWzpsrIo=,iv:NLsZcmE1kKlzV7B/XPVfENMWlpQtOpESH0ByX1KQ8IQ=,tag:P+ZmsKq0KJAeRTTbvbduMg==,type:str] +n8n: + env: ENC[AES256_GCM,data:LA/6tMfGgX0cDNfhIZ+n2Ay+6OW5gPPebcXQnfO3qQJSjMjf9vwauF2+W3KpIvM1Dsg3hyNEwqLNRn/28bgWC/qpBpgU2/gVI2n5oxcQaYGgnS/jB0nZWXvORVTnXjH0R+HBFCWgMJe7v+o0EeBH6kni/Nc9geb8paRkxZOGVKeJQy9K4OB2CN6FVO9KeR7gpeQpsh5V5SVW1MoND2tpCOiIK7d0uM6OHF/7p2RFrEEAarvJssj/dZRHjA/jALuqbQ6UDAaAppqlkEgIdZdFEfgebfCWR4e4aWjznW1DGOQQYtg4k/Kj8J/df8CWXX+lUO+9nTo/lhhcH395w+CRE8GUwze15yxQppUwqyLKdYwgmpK1tFnLP/W/As2f97c1fBB9rXrZYOUEIq4GspHOTPgjzcRfWOxX8cMKG69EmeZ3mWPsIDaC1ZvkVQjjcH/o9aC7QeFCwPfcy+mgI+9RjAaCw7qdig1CwgQabAaCd2hzQ4FTXBFJoZRfYZ1v3Rdwe8zqMivIcw2AHv6kYx6c9A==,iv:KmyJ/CLAGrYfzHjSWygtgA/+am9fUrKnOsGRPgV9QfU=,tag:G3LhfdSujcaC9ZZFUse0DQ==,type:str] sops: kms: [] gcp_kms: [] @@ -78,8 +80,8 @@ sops: by9kZFlTRVdCZFkxYTVVb0RIRk8zUlkKCqMw9oL9RaYBV5Hhy3o8Nm5xmGrPH8Sd hv36sxRFFNZT/DCKaHaSRbT3mfpBZSTXJt1dgl4nZe6whH54t/1KmA== -----END AGE ENCRYPTED FILE----- - lastmodified: "2024-12-07T15:58:00Z" - mac: ENC[AES256_GCM,data:ugW/IqGYYblO7GAM/W1PePKOJr5iJM42/SCHL8ew/QwXuOibhWWGkxObFeZ83u0DCmhH2fPqK/rI3seA6QLaWFeB2wrkyy4u13D5PISrObVtmQVD50kogObqd2CVdlQFIGQypw3/EB8oWNPcBRCvlAPPhZaB9a3SWS4CaTu+lPg=,iv:6IW7xOO9hBqK65WSLYnk7ViGs9xhoaMpsCeITbWNgHs=,tag:zXtnRBQemAT3cN1+QM7OHA==,type:str] + lastmodified: "2024-12-07T23:38:16Z" + mac: ENC[AES256_GCM,data:GKCMZJVKj5Fq7Ak4wQgI/pAl8JKDdzAYCBRwnxHlg0Z10AstbchAYm+LLwCaE85ebl6m/JexmfJeutJo0yGXuOIQKcEgfyNq9O/i/y34ISc4looQ6cyH5Hcxsd9JXgrmgQzVPquBXQzDHz4rj93VhNrvqmw+SgDPZVwcUznvCBI=,iv:HtUmf0qjvbYW7ngocISpqycX7ceNv0YsILgZhOMTSMg=,tag:kJ7EFOLL8o/2OFkn5PhvJw==,type:str] pgp: [] unencrypted_suffix: _unencrypted version: 3.9.1 diff --git a/nki-personal-do/vikunja.nix b/nki-personal-do/vikunja.nix index 2e25ec2..10afe17 100644 --- a/nki-personal-do/vikunja.nix +++ b/nki-personal-do/vikunja.nix @@ -81,8 +81,8 @@ in }; systemd.services.vikunja = { - serviceConfig.User = user; serviceConfig.LoadCredential = [ "VIKUNJA_AUTH_OPENID_PROVIDERS_AUTHENTIK_CLIENTSECRET_FILE:${secrets."vikunja/provider-clientsecret".path}" ]; + serviceConfig.User = user; serviceConfig.DynamicUser = lib.mkForce false; serviceConfig.ReadWritePaths = [ storageMount ]; environment.VIKUNJA_AUTH_OPENID_PROVIDERS_AUTHENTIK_CLIENTSECRET_FILE = "%d/VIKUNJA_AUTH_OPENID_PROVIDERS_AUTHENTIK_CLIENTSECRET_FILE"; From 56a8c33f9cc742b80b37f8ccf07d048fffb31523 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 9 Dec 2024 00:39:01 +0100 Subject: [PATCH 29/53] Update peertube requirements --- modules/cloud/authentik/default.nix | 2 ++ nki-personal-do/peertube.nix | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/modules/cloud/authentik/default.nix b/modules/cloud/authentik/default.nix index 40e53a6..74d7f61 100644 --- a/modules/cloud/authentik/default.nix +++ b/modules/cloud/authentik/default.nix @@ -105,6 +105,7 @@ in ports = [ "127.0.0.1:${toString cfg.port}:9000" ]; + }; services.worker.service = { image = images.authentik; @@ -123,6 +124,7 @@ in AUTHENTIK_POSTGRESQL__NAME = "authentik"; }; env_file = [ cfg.envFile "${authentikEnv}" ]; + user = "root"; }; docker-compose.volumes = { database.driver = "local"; diff --git a/nki-personal-do/peertube.nix b/nki-personal-do/peertube.nix index a390d90..1e07358 100644 --- a/nki-personal-do/peertube.nix +++ b/nki-personal-do/peertube.nix @@ -76,5 +76,10 @@ in dataDirs = [ "/var/lib/peertube" "/mnt/data/peertube" ]; }; + + systemd.services.peertube = { + requires = [ "arion-authentik.service" ]; + after = [ "arion-authentik.service" ]; + }; } From ea331093bb0e61c4ca9c60e61c44483039f47ef3 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 12 Dec 2024 01:49:42 +0100 Subject: [PATCH 30/53] Add luminance and external monitor kernel modules --- modules/common/linux/default.nix | 20 ++++++++++---------- nki-home/audio/default.nix | 2 +- nki-home/audio/sdac.conf.json | 19 +++++++++++++++++++ nki-home/audio/sdac.lua | 2 +- overlay.nix | 10 ++++++++++ 5 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 nki-home/audio/sdac.conf.json diff --git a/modules/common/linux/default.nix b/modules/common/linux/default.nix index 2fae826..3b53a0d 100644 --- a/modules/common/linux/default.nix +++ b/modules/common/linux/default.nix @@ -26,15 +26,13 @@ let }; }; - graphics = { config, ... }: { - hardware = - if config.system.nixos.release == "24.05" then { - opengl.enable = true; - opengl.driSupport32Bit = true; - } else { - graphics.enable = true; - graphics.enable32Bit = true; - }; + graphics = { config, pkgs, ... }: { + hardware.graphics.enable = true; + hardware.graphics.enable32Bit = true; + # Monitor backlight + hardware.i2c.enable = true; + services.ddccontrol.enable = true; + environment.systemPackages = [ pkgs.luminance pkgs.ddcutil ]; }; accounts = { pkgs, ... }: mkIf (config.common.linux.enable && !pkgs.stdenv.isAarch64) { @@ -88,7 +86,7 @@ let enable = true; # defaults (no need to be set unless modified) quantum = 32; - rate = 48000; + rate = 44100; }; security.rtkit.enable = true; @@ -240,6 +238,8 @@ in "wheel" # Enable ‘sudo’ for the user. "plugdev" # Enable openrazer-daemon privileges "audio" + "video" + "input" ]; shell = pkgs.fish; }; diff --git a/nki-home/audio/default.nix b/nki-home/audio/default.nix index 99a7463..2d149c8 100644 --- a/nki-home/audio/default.nix +++ b/nki-home/audio/default.nix @@ -1,5 +1,5 @@ { config, pkgs, lib, ... }: { environment.etc = { - "wireplumber/main.lua.d/51-sdac.lua".source = ./sdac.lua; + "wireplumber/wireplumber.conf.d/51-sdac.conf".source = ./sdac.conf.json; }; } diff --git a/nki-home/audio/sdac.conf.json b/nki-home/audio/sdac.conf.json new file mode 100644 index 0000000..489eb9f --- /dev/null +++ b/nki-home/audio/sdac.conf.json @@ -0,0 +1,19 @@ +monitor.alsa.rules = [ + { + matches = [ + { + device.name = "alsa_output.usb-Grace_Design_SDAC-00.*" + } + ] + actions = { + update-props = { + # audio.format = "S24_3LE" + audio.rate = 88200 + api.alsa.period-size = 2 + api.alsa.headroom = 0 + api.alsa.disable-batch = true + } + } + } +] + diff --git a/nki-home/audio/sdac.lua b/nki-home/audio/sdac.lua index 2c172d6..fcf6d7b 100644 --- a/nki-home/audio/sdac.lua +++ b/nki-home/audio/sdac.lua @@ -6,7 +6,7 @@ rule = { }, apply_properties = { ["audio.format"] = "S24_3LE", - ["audio.rate"] = 96000, + ["audio.rate"] = 44100, ["api.alsa.period-size"] = 2, ["api.alsa.headroom"] = 0, ["api.alsa.disable-batch"] = true diff --git a/overlay.nix b/overlay.nix index 6a7a134..4ad7209 100644 --- a/overlay.nix +++ b/overlay.nix @@ -75,6 +75,14 @@ let builtins.seq (final.lib.assertMsg (prev.vikunja.version == "0.24.5") "Vikunja probably doesn't need custom versions anymore") (final.callPackage ./packages/common/vikunja.nix { }); + + luminance = prev.luminance.overrideAttrs (attrs: { + nativeBuildInputs = attrs.nativeBuildInputs ++ [ final.wrapGAppsHook ]; + buildInputs = attrs.buildInputs ++ [ final.glib ]; + postInstall = attrs.postInstall + '' + glib-compile-schemas $out/share/glib-2.0/schemas + ''; + }); }; overlay-libs = final: prev: { @@ -125,3 +133,5 @@ in # Bug fixes ] # we assign the overlay created before to the overlays of nixpkgs. + + From 770b47b6d4e58805d1861034b3007f413665143d Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 12 Dec 2024 14:28:16 +0100 Subject: [PATCH 31/53] Update zen --- flake.lock | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/flake.lock b/flake.lock index ff394c3..9759881 100644 --- a/flake.lock +++ b/flake.lock @@ -1571,11 +1571,11 @@ "zen-browser-specific": "zen-browser-specific" }, "locked": { - "lastModified": 1733866152, - "narHash": "sha256-r/uMP+ewTEoQLFaLa2EFktu9PCgOmat0xD1QvoPgwAY=", + "lastModified": 1733978065, + "narHash": "sha256-3eHKW6BHyLxUWEvzifB3Kffm8hET0xMeJHUmjTzHHaI=", "owner": "youwen5", "repo": "zen-browser-flake", - "rev": "ebb6df0cf500b36ce76bcd49a1ad246e66d9edc3", + "rev": "5e64bc098ef8f286109b4fb8c99b31d62f747e13", "type": "github" }, "original": { @@ -1587,40 +1587,40 @@ "zen-browser-aarch64": { "flake": false, "locked": { - "lastModified": 1733825278, - "narHash": "sha256-UkfTh+p+8D5qP8ZmcdiTIvUay0kNBjWA9Bi6OVZu/b8=", + "lastModified": 1733949966, + "narHash": "sha256-fOtYyzis+ojwkTZKCWy05ROdgfM1Dqhx25+DirN18gs=", "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.0/zen.linux-aarch64.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.1/zen.linux-aarch64.tar.bz2" }, "original": { "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.0/zen.linux-aarch64.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.1/zen.linux-aarch64.tar.bz2" } }, "zen-browser-generic": { "flake": false, "locked": { - "lastModified": 1733829638, - "narHash": "sha256-4gEnE+4v3A35ggUCZOkqBOXcRE7vAV2A+kEDhJ3gpAs=", + "lastModified": 1733954563, + "narHash": "sha256-+ZP4UT+y99bxt7N6Pkmlj0F7FOouR0tzExemkLJiXK4=", "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.0/zen.linux-generic.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.1/zen.linux-generic.tar.bz2" }, "original": { "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.0/zen.linux-generic.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.1/zen.linux-generic.tar.bz2" } }, "zen-browser-specific": { "flake": false, "locked": { - "lastModified": 1733830242, - "narHash": "sha256-nXDJ1ZGrGkMr6tdkMgDTFfXJLbzUDSuVMUM5i8g79Rg=", + "lastModified": 1733955296, + "narHash": "sha256-gUKEfpTIfLdoXg3RyNpQybt/7K820a0ljFSZ+e+iyq4=", "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.0/zen.linux-specific.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.1/zen.linux-specific.tar.bz2" }, "original": { "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.0/zen.linux-specific.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.1/zen.linux-specific.tar.bz2" } } }, From c080abeb6cf0473c30b8d8c0c468bf4c1c70665f Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 12 Dec 2024 23:13:48 +0100 Subject: [PATCH 32/53] Add some n8n plugins --- nki-personal-do/n8n.nix | 17 +- nki-personal-do/n8n/plugins/.gitignore | 1 + nki-personal-do/n8n/plugins/package-lock.json | 1678 +++++++++++++++++ nki-personal-do/n8n/plugins/package.json | 8 + nki-personal-do/n8n/plugins/package.nix | 4 + 5 files changed, 1703 insertions(+), 5 deletions(-) create mode 100644 nki-personal-do/n8n/plugins/.gitignore create mode 100644 nki-personal-do/n8n/plugins/package-lock.json create mode 100644 nki-personal-do/n8n/plugins/package.json create mode 100644 nki-personal-do/n8n/plugins/package.nix diff --git a/nki-personal-do/n8n.nix b/nki-personal-do/n8n.nix index 6da581e..2ffad56 100644 --- a/nki-personal-do/n8n.nix +++ b/nki-personal-do/n8n.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, ... }: let secrets = config.sops.secrets; @@ -8,6 +8,8 @@ let port = 23412; dataFolder = "/mnt/data/n8n"; + + plugins = pkgs.callPackage ./n8n/plugins/package.nix { }; in { sops.secrets."n8n/env" = { reloadUnits = [ "n8n.service" ]; }; @@ -63,9 +65,14 @@ in }; unitConfig.RequiresMountsFor = [ dataFolder ]; }; - systemd.tmpfiles.settings."10-n8n".${dataFolder}.d = { - user = user; - group = user; - mode = "0700"; + systemd.tmpfiles.settings."10-n8n" = { + ${dataFolder}.d = { + user = user; + group = user; + mode = "0700"; + }; + "${dataFolder}/.n8n/nodes"."L+" = { + argument = "${plugins}"; + }; }; } diff --git a/nki-personal-do/n8n/plugins/.gitignore b/nki-personal-do/n8n/plugins/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/nki-personal-do/n8n/plugins/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/nki-personal-do/n8n/plugins/package-lock.json b/nki-personal-do/n8n/plugins/package-lock.json new file mode 100644 index 0000000..a310e3b --- /dev/null +++ b/nki-personal-do/n8n/plugins/package-lock.json @@ -0,0 +1,1678 @@ +{ + "name": "n8n-plugins", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "n8n-plugins", + "version": "1.0.0", + "dependencies": { + "n8n-nodes-turndown-html-to-markdown": "^1.0.5", + "n8n-nodes-vikunja": "^0.2.0" + } + }, + "node_modules/@mixmark-io/domino": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@mixmark-io/domino/-/domino-2.2.0.tgz", + "integrity": "sha512-Y28PR25bHXUg88kCV7nivXrP2Nj2RueZ3/l/jdx6J9f8J4nsEGcgX0Qe6lt7Pa+J79+kPiJU3LguR6O/6zrLOw==", + "license": "BSD-2-Clause" + }, + "node_modules/@n8n_io/riot-tmpl": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@n8n_io/riot-tmpl/-/riot-tmpl-4.0.0.tgz", + "integrity": "sha512-/xw8HQgYQlBCrt3IKpNSSB1CgpP7XArw1QTRjP+KEw+OHT8XGvHxXrW9VGdUu9RwDnzm/LFu+dNLeDmwJMeOwQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "eslint-config-riot": "^1.0.0" + } + }, + "node_modules/@n8n/tournament": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@n8n/tournament/-/tournament-1.0.5.tgz", + "integrity": "sha512-IPBHa7gC0wwHVct/dnBquHz+uMCDZaZ05cor1D/rjlwaOe/PVu5mtoZaPHYuR98R3W1/IyxC5PuBd0JizDP9gg==", + "license": "Apache-2.0", + "peer": true, + "dependencies": { + "@n8n_io/riot-tmpl": "^4.0.1", + "ast-types": "^0.16.1", + "esprima-next": "^5.8.4", + "recast": "^0.22.0" + }, + "engines": { + "node": ">=20.15", + "pnpm": ">=9.5" + } + }, + "node_modules/@n8n/tournament/node_modules/@n8n_io/riot-tmpl": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@n8n_io/riot-tmpl/-/riot-tmpl-4.0.1.tgz", + "integrity": "sha512-/zdRbEfTFjsm1NqnpPQHgZTkTdbp5v3VUxGeMA9098sps8jRCTraQkc3AQstJgHUm7ylBXJcIVhnVeLUMWAfwQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "eslint-config-riot": "^1.0.0" + } + }, + "node_modules/@n8n/tournament/node_modules/ast-types": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.16.1.tgz", + "integrity": "sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==", + "license": "MIT", + "peer": true, + "dependencies": { + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@n8n/tournament/node_modules/recast": { + "version": "0.22.0", + "resolved": "https://registry.npmjs.org/recast/-/recast-0.22.0.tgz", + "integrity": "sha512-5AAx+mujtXijsEavc5lWXBPQqrM4+Dl5qNH96N2aNeuJFUzpiiToKPsxQD/zAIJHspz7zz0maX0PCtCTFVlixQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "assert": "^2.0.0", + "ast-types": "0.15.2", + "esprima": "~4.0.0", + "source-map": "~0.6.1", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">= 4" + } + }, + "node_modules/@n8n/tournament/node_modules/recast/node_modules/ast-types": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.15.2.tgz", + "integrity": "sha512-c27loCv9QkZinsa5ProX751khO9DJl/AcB5c2KNtA6NRvHKS0PgLfcftz72KVq504vB0Gku5s2kUZzDBvQWvHg==", + "license": "MIT", + "peer": true, + "dependencies": { + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "peer": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/assert": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-2.1.0.tgz", + "integrity": "sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.2", + "is-nan": "^1.3.2", + "object-is": "^1.1.5", + "object.assign": "^4.1.4", + "util": "^0.12.5" + } + }, + "node_modules/ast-types": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.15.2.tgz", + "integrity": "sha512-c27loCv9QkZinsa5ProX751khO9DJl/AcB5c2KNtA6NRvHKS0PgLfcftz72KVq504vB0Gku5s2kUZzDBvQWvHg==", + "license": "MIT", + "peer": true, + "dependencies": { + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT", + "peer": true + }, + "node_modules/available-typed-arrays": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", + "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "possible-typed-array-names": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/axios": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", + "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", + "license": "MIT", + "peer": true, + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/call-bind": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", + "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind-apply-helpers": "^1.0.0", + "es-define-property": "^1.0.0", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.1.tgz", + "integrity": "sha512-BhYE+WDaywFg2TBWYNXAE+8B1ATnThNBqXHP5nQu0jWJdVvY2hvkpyB3qOmtmDePiS5/BDQ8wASEWGMWRG148g==", + "license": "MIT", + "peer": true, + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.2.tgz", + "integrity": "sha512-0lk0PHFe/uz0vl527fG9CgdE9WdafjDbCXvBbs+LUv000TVt2Jjhqbs4Jwm8gz070w8xXyEAxrPOMullsxXeGg==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.8", + "get-intrinsic": "^1.2.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", + "license": "BSD-3-Clause", + "peer": true, + "engines": { + "node": "*" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "license": "ISC", + "peer": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "license": "MIT", + "peer": true + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "peer": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", + "license": "BSD-3-Clause", + "peer": true, + "engines": { + "node": "*" + } + }, + "node_modules/deep-equal": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.0.tgz", + "integrity": "sha512-RdpzE0Hv4lhowpIUKKMJfeH6C1pXdtT1/it80ubgWqwI3qpuxUBpC1S4hnHg+zjnuOoDkzUtUCEEkG+XG5l3Mw==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.2", + "es-get-iterator": "^1.1.2", + "get-intrinsic": "^1.1.3", + "is-arguments": "^1.1.1", + "is-array-buffer": "^3.0.1", + "is-date-object": "^1.0.5", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.2", + "isarray": "^2.0.5", + "object-is": "^1.1.5", + "object-keys": "^1.1.1", + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.4.3", + "side-channel": "^1.0.4", + "which-boxed-primitive": "^1.0.2", + "which-collection": "^1.0.1", + "which-typed-array": "^1.1.9" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "license": "MIT", + "peer": true, + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "license": "MIT", + "peer": true, + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.0.tgz", + "integrity": "sha512-9+Sj30DIu+4KvHqMfLUGLFYL2PkURSYMVXJyXe92nFRvlYq5hBjLEhblKB+vkd/WVlUYMWigiY07T91Fkk0+4A==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind-apply-helpers": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "license": "MIT", + "peer": true + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-get-iterator": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz", + "integrity": "sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.3", + "has-symbols": "^1.0.3", + "is-arguments": "^1.1.1", + "is-map": "^2.0.2", + "is-set": "^2.0.2", + "is-string": "^1.0.7", + "isarray": "^2.0.5", + "stop-iteration-iterator": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-object-atoms": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz", + "integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==", + "license": "MIT", + "peer": true, + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/eslint-config-riot": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-riot/-/eslint-config-riot-1.0.0.tgz", + "integrity": "sha512-NB/L/1Y30qyJcG5xZxCJKW/+bqyj+llbcCwo9DEz8bESIP0SLTOQ8T1DWCCFc+wJ61AMEstj4511PSScqMMfCw==", + "license": "MIT", + "peer": true + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "license": "BSD-2-Clause", + "peer": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/esprima-next": { + "version": "5.8.4", + "resolved": "https://registry.npmjs.org/esprima-next/-/esprima-next-5.8.4.tgz", + "integrity": "sha512-8nYVZ4ioIH4Msjb/XmhnBdz5WRRBaYqevKa1cv9nGJdCehMbzZCPNEEnqfLCZVetUVrUPEcb5IYyu1GG4hFqgg==", + "license": "BSD-2-Clause", + "peer": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "peer": true, + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "license": "MIT", + "peer": true, + "dependencies": { + "is-callable": "^1.1.3" + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "license": "MIT", + "peer": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "peer": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "license": "MIT", + "peer": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "license": "ISC", + "peer": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.6.tgz", + "integrity": "sha512-qxsEs+9A+u85HhllWJJFicJfPDhRmjzoYdl64aMWW9yRIJmSyxdn8IEkuIM530/7T+lv0TIHd8L6Q/ra0tEoeA==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "dunder-proto": "^1.0.0", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "function-bind": "^1.1.2", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-bigints": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", + "license": "MIT", + "peer": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "license": "MIT", + "peer": true, + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "peer": true, + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC", + "peer": true + }, + "node_modules/internal-slot": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.7.tgz", + "integrity": "sha512-NGnrKwXzSms2qUUih/ILZ5JBqNTSa1+ZmP6flaIp6KmSElgE9qdndzS3cqjrDovwFdmwsGsLdeFgB6suw+1e9g==", + "license": "MIT", + "peer": true, + "dependencies": { + "es-errors": "^1.3.0", + "hasown": "^2.0.0", + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-arguments": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", + "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-array-buffer": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz", + "integrity": "sha512-wcjaerHw0ydZwfhiKbXJWLDY8A7yV7KhjQOpb83hGgGfId/aQa4TOvwyzn2PuswW2gPCYEL/nEAiSVpdOj1lXw==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-bigint": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.1.0.tgz", + "integrity": "sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "has-bigints": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-boolean-object": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.2.0.tgz", + "integrity": "sha512-kR5g0+dXf/+kXnqI+lu0URKYPKgICtHGGNCDSB10AaUFj3o/HkB3u7WfpRBJGFopxxY0oH3ux7ZsDjLtK7xqvw==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.7", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "license": "MIT", + "peer": true + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", + "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-generator-function": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", + "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", + "license": "MIT", + "peer": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz", + "integrity": "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-nan": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", + "integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number-object": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.1.0.tgz", + "integrity": "sha512-KVSZV0Dunv9DTPkhXwcZ3Q+tUc9TsaE1ZwX5J2WMvsSGS6Md8TFPun5uwh0yRdrNerI6vf/tbJxqSx4c1ZI1Lw==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.7", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", + "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bound": "^1.0.2", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-set": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.3.tgz", + "integrity": "sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-shared-array-buffer": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.3.tgz", + "integrity": "sha512-nA2hv5XIhLR3uVzDDfCIknerhx8XUKnstuOERPNNIinXG7v9u+ohXF67vxm4TPTEPU6lm61ZkwP3c9PCB97rhg==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-string": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.1.0.tgz", + "integrity": "sha512-PlfzajuF9vSo5wErv3MJAKD/nqf9ngAs1NFQYm16nUYFO2IzxJ2hcm+IOCg+EEopdykNNUhVq5cz35cAUxU8+g==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.7", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-symbol": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.1.0.tgz", + "integrity": "sha512-qS8KkNNXUZ/I+nX6QT8ZS1/Yx0A444yhzdTKxCzKkNjQ9sHErBxJnJAgh+f5YhusYECEcjo4XcyH87hn6+ks0A==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.7", + "has-symbols": "^1.0.3", + "safe-regex-test": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.13.tgz", + "integrity": "sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==", + "license": "MIT", + "peer": true, + "dependencies": { + "which-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakmap": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", + "integrity": "sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakset": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.3.tgz", + "integrity": "sha512-LvIm3/KWzS9oRFHugab7d+M/GcBXuXX5xZkzPmN+NxihdQlZUQ4dWuSV1xR/sq6upL1TJEDrfBgRepHFdBtSNQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.7", + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "license": "MIT", + "peer": true + }, + "node_modules/jmespath": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.16.0.tgz", + "integrity": "sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==", + "license": "Apache-2.0", + "peer": true, + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/js-base64": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.2.tgz", + "integrity": "sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ==", + "license": "BSD-3-Clause", + "peer": true + }, + "node_modules/jssha": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/jssha/-/jssha-3.3.1.tgz", + "integrity": "sha512-VCMZj12FCFMQYcFLPRm/0lOBbLi8uM2BhXPTqw3U4YAfs4AZfiApOoBLoN8cQE60Z50m1MYMTQVCfgF/KaCVhQ==", + "license": "BSD-3-Clause", + "peer": true, + "engines": { + "node": "*" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "license": "MIT", + "peer": true + }, + "node_modules/luxon": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.4.4.tgz", + "integrity": "sha512-zobTr7akeGHnv7eBOXcRgMeCP6+uyYsczwmeRCauvpvaAltgNyTbLH/+VaEAPUeWBT+1GuNmz4wC/6jtQzbbVA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/marked": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-11.2.0.tgz", + "integrity": "sha512-HR0m3bvu0jAPYiIvLUUQtdg1g6D247//lvcekpHO1WMvbwDlwSkZAX9Lw4F4YHE1T0HaaNve0tuAWuV1UJ6vtw==", + "license": "MIT", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/math-intrinsics": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.0.0.tgz", + "integrity": "sha512-4MqMiKP90ybymYvsut0CH2g4XWbfLtmlCkXmtmdcDCxNB+mQcu1w/1+L/VD7vi/PSv7X2JYV7SCcR+jiPXnQtA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "license": "BSD-3-Clause", + "peer": true, + "dependencies": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "peer": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/n8n-nodes-turndown-html-to-markdown": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/n8n-nodes-turndown-html-to-markdown/-/n8n-nodes-turndown-html-to-markdown-1.0.5.tgz", + "integrity": "sha512-Vd0ro0DFmF+vdYCURtD9YDIWzvLF5lU+4NhnvlZuJrpiuH2RlFtM1STs379KqfWZeIffbvXlF+wfioZ0BGwsuw==", + "license": "MIT", + "dependencies": { + "marked": "^11.0.0", + "turndown": "^7.1.2" + } + }, + "node_modules/n8n-nodes-vikunja": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/n8n-nodes-vikunja/-/n8n-nodes-vikunja-0.2.0.tgz", + "integrity": "sha512-ivRnezLO5kD17IjTKI2jFB/FCrJlEIjDsn9Dnrcefec9lspShUz/O8YQMifbsNk80JHwBRzRl+EEnHaThxCXwA==", + "license": "MIT", + "peerDependencies": { + "n8n-workflow": "*" + } + }, + "node_modules/n8n-workflow": { + "version": "1.70.0", + "resolved": "https://registry.npmjs.org/n8n-workflow/-/n8n-workflow-1.70.0.tgz", + "integrity": "sha512-suA+HJfpsggRAegtz8TQbgRgyPBgnDSVdacJJsaijH6lYaTb5yw3/bhiY/SvdfJdLzZ/E4UCswsSCVGfAGEs3A==", + "license": "SEE LICENSE IN LICENSE.md", + "peer": true, + "dependencies": { + "@n8n_io/riot-tmpl": "4.0.0", + "@n8n/tournament": "1.0.5", + "ast-types": "0.15.2", + "axios": "1.7.4", + "callsites": "3.1.0", + "deep-equal": "2.2.0", + "esprima-next": "5.8.4", + "form-data": "4.0.0", + "jmespath": "0.16.0", + "js-base64": "3.7.2", + "jssha": "3.3.1", + "lodash": "4.17.21", + "luxon": "3.4.4", + "md5": "2.3.0", + "recast": "0.21.5", + "title-case": "3.0.3", + "transliteration": "2.3.5", + "xml2js": "0.6.2" + } + }, + "node_modules/object-inspect": { + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz", + "integrity": "sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-is": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.6.tgz", + "integrity": "sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.5.tgz", + "integrity": "sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.5", + "define-properties": "^1.2.1", + "has-symbols": "^1.0.3", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/possible-typed-array-names": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", + "integrity": "sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT", + "peer": true + }, + "node_modules/recast": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/recast/-/recast-0.21.5.tgz", + "integrity": "sha512-hjMmLaUXAm1hIuTqOdeYObMslq/q+Xff6QE3Y2P+uoHAg2nmVlLBps2hzh1UJDdMtDTMXOFewK6ky51JQIeECg==", + "license": "MIT", + "peer": true, + "dependencies": { + "ast-types": "0.15.2", + "esprima": "~4.0.0", + "source-map": "~0.6.1", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">= 4" + } + }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.3.tgz", + "integrity": "sha512-vqlC04+RQoFalODCbCumG2xIOvapzVMHwsyIGM/SIE8fRhFFsXeH8/QQ+s0T0kDAhKc4k30s73/0ydkHQz6HlQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-errors": "^1.3.0", + "set-function-name": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/safe-regex-test": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.3.tgz", + "integrity": "sha512-CdASjNJPvRa7roO6Ra/gLYBTzYzzPyyBXxIMdGW3USQLyjWEls2RgW5UBTXaQVp+OrpeCK3bLem8smtmheoRuw==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind": "^1.0.6", + "es-errors": "^1.3.0", + "is-regex": "^1.1.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/sax": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz", + "integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==", + "license": "ISC", + "peer": true + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "license": "MIT", + "peer": true, + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-function-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.2.tgz", + "integrity": "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "peer": true, + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "peer": true, + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "license": "BSD-3-Clause", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stop-iteration-iterator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz", + "integrity": "sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "internal-slot": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "peer": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "peer": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/title-case": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/title-case/-/title-case-3.0.3.tgz", + "integrity": "sha512-e1zGYRvbffpcHIrnuqT0Dh+gEJtDaxDSoG4JAIpq4oDFyooziLBIiYQv0GBT4FUAnUop5uZ1hiIAj7oAF6sOCA==", + "license": "MIT", + "peer": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/transliteration": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/transliteration/-/transliteration-2.3.5.tgz", + "integrity": "sha512-HAGI4Lq4Q9dZ3Utu2phaWgtm3vB6PkLUFqWAScg/UW+1eZ/Tg6Exo4oC0/3VUol/w4BlefLhUUSVBr/9/ZGQOw==", + "license": "MIT", + "peer": true, + "dependencies": { + "yargs": "^17.5.1" + }, + "bin": { + "slugify": "dist/bin/slugify", + "transliterate": "dist/bin/transliterate" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD", + "peer": true + }, + "node_modules/turndown": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/turndown/-/turndown-7.2.0.tgz", + "integrity": "sha512-eCZGBN4nNNqM9Owkv9HAtWRYfLA4h909E/WGAWWBpmB275ehNhZyk87/Tpvjbp0jjNl9XwCsbe6bm6CqFsgD+A==", + "license": "MIT", + "dependencies": { + "@mixmark-io/domino": "^2.2.0" + } + }, + "node_modules/util": { + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", + "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", + "license": "MIT", + "peer": true, + "dependencies": { + "inherits": "^2.0.3", + "is-arguments": "^1.0.4", + "is-generator-function": "^1.0.7", + "is-typed-array": "^1.1.3", + "which-typed-array": "^1.1.2" + } + }, + "node_modules/which-boxed-primitive": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.1.0.tgz", + "integrity": "sha512-Ei7Miu/AXe2JJ4iNF5j/UphAgRoma4trE6PtisM09bPygb3egMH3YLW/befsWb1A1AxvNSFidOFTB18XtnIIng==", + "license": "MIT", + "peer": true, + "dependencies": { + "is-bigint": "^1.1.0", + "is-boolean-object": "^1.2.0", + "is-number-object": "^1.1.0", + "is-string": "^1.1.0", + "is-symbol": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-collection": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.2.tgz", + "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", + "license": "MIT", + "peer": true, + "dependencies": { + "is-map": "^2.0.3", + "is-set": "^2.0.3", + "is-weakmap": "^2.0.2", + "is-weakset": "^2.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.16", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.16.tgz", + "integrity": "sha512-g+N+GAWiRj66DngFwHvISJd+ITsyphZvD1vChfVg6cEdnzy53GzB3oy0fUNlvhz7H7+MiqhYr26qxQShCpKTTQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.7", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "license": "MIT", + "peer": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/xml2js": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.2.tgz", + "integrity": "sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==", + "license": "MIT", + "peer": true, + "dependencies": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "license": "ISC", + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "license": "MIT", + "peer": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "license": "ISC", + "peer": true, + "engines": { + "node": ">=12" + } + } + } +} diff --git a/nki-personal-do/n8n/plugins/package.json b/nki-personal-do/n8n/plugins/package.json new file mode 100644 index 0000000..808dc54 --- /dev/null +++ b/nki-personal-do/n8n/plugins/package.json @@ -0,0 +1,8 @@ +{ + "name": "n8n-plugins", + "version": "1.0.0", + "dependencies": { + "n8n-nodes-turndown-html-to-markdown": "^1.0.5", + "n8n-nodes-vikunja": "^0.2.0" + } +} diff --git a/nki-personal-do/n8n/plugins/package.nix b/nki-personal-do/n8n/plugins/package.nix new file mode 100644 index 0000000..3cf4ef4 --- /dev/null +++ b/nki-personal-do/n8n/plugins/package.nix @@ -0,0 +1,4 @@ +{ nodejs, importNpmLock }: importNpmLock.buildNodeModules { + inherit nodejs; + npmRoot = ./.; +} From 9c5f0981a3e88328d84a63c86a8fc0e5df953ad6 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 15 Dec 2024 23:51:33 +0100 Subject: [PATCH 33/53] Update osu --- home/osu.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/home/osu.nix b/home/osu.nix index 40844af..8b2212e 100644 --- a/home/osu.nix +++ b/home/osu.nix @@ -5,10 +5,10 @@ let osu-pkg = with pkgs; with lib; appimageTools.wrapType2 rec { pname = "osu-lazer-bin"; - version = "2024.1115.3"; + version = "2024.1208.0"; src = fetchurl { url = "https://github.com/ppy/osu/releases/download/${version}/osu.AppImage"; - sha256 = "sha256-kwZHy0FfOUFIWvyOj0ghlQz05U+Lnzl5TgC4T6bhm7o="; + hash = "sha256-gRUr7jf0+Xbfz8FurPk/o7F67TYisdNySNzVWEMb1es="; }; extraPkgs = pkgs: with pkgs; [ icu ]; @@ -19,7 +19,7 @@ let mv -v $out/bin/${pname} $out/bin/osu\! install -m 444 -D ${contents}/osu\!.desktop -t $out/share/applications for i in 16 32 48 64 96 128 256 512 1024; do - install -D ${contents}/osu\!.png $out/share/icons/hicolor/''${i}x$i/apps/osu\!.png + install -D ${contents}/osu.png $out/share/icons/hicolor/''${i}x$i/apps/osu.png done ''; }; From 318abcfc80787575171103524cd53ff3936c648b Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 16 Dec 2024 03:16:50 +0100 Subject: [PATCH 34/53] Update zen --- flake.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/flake.lock b/flake.lock index 9759881..ec765e6 100644 --- a/flake.lock +++ b/flake.lock @@ -1042,11 +1042,11 @@ }, "nixpkgs_11": { "locked": { - "lastModified": 1733759999, - "narHash": "sha256-463SNPWmz46iLzJKRzO3Q2b0Aurff3U1n0nYItxq7jU=", + "lastModified": 1733940404, + "narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a73246e2eef4c6ed172979932bc80e1404ba2d56", + "rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713", "type": "github" }, "original": { @@ -1571,11 +1571,11 @@ "zen-browser-specific": "zen-browser-specific" }, "locked": { - "lastModified": 1733978065, - "narHash": "sha256-3eHKW6BHyLxUWEvzifB3Kffm8hET0xMeJHUmjTzHHaI=", + "lastModified": 1734235629, + "narHash": "sha256-s2yr4KdY5qXHyOuLCWJm/CG7miiOR+G1PA2aqe3iJCA=", "owner": "youwen5", "repo": "zen-browser-flake", - "rev": "5e64bc098ef8f286109b4fb8c99b31d62f747e13", + "rev": "26237f7bcc5e61b040e1771e7adfe4dc71dd9075", "type": "github" }, "original": { @@ -1587,40 +1587,40 @@ "zen-browser-aarch64": { "flake": false, "locked": { - "lastModified": 1733949966, - "narHash": "sha256-fOtYyzis+ojwkTZKCWy05ROdgfM1Dqhx25+DirN18gs=", + "lastModified": 1734215440, + "narHash": "sha256-eUT6Zv6MJOjFeeY5WbXeaJ9alcx/11a+93n6LEFg8yI=", "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.1/zen.linux-aarch64.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.2/zen.linux-aarch64.tar.bz2" }, "original": { "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.1/zen.linux-aarch64.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.2/zen.linux-aarch64.tar.bz2" } }, "zen-browser-generic": { "flake": false, "locked": { - "lastModified": 1733954563, - "narHash": "sha256-+ZP4UT+y99bxt7N6Pkmlj0F7FOouR0tzExemkLJiXK4=", + "lastModified": 1734220871, + "narHash": "sha256-3NihEgT1GA9BRUf+H4+ZtXgz9wSrxphQUoozW34QuHI=", "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.1/zen.linux-generic.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.2/zen.linux-generic.tar.bz2" }, "original": { "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.1/zen.linux-generic.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.2/zen.linux-generic.tar.bz2" } }, "zen-browser-specific": { "flake": false, "locked": { - "lastModified": 1733955296, - "narHash": "sha256-gUKEfpTIfLdoXg3RyNpQybt/7K820a0ljFSZ+e+iyq4=", + "lastModified": 1734221044, + "narHash": "sha256-B7Jx+Yvr5m1EjHxVffSwzXnkvCyvdwiaeHM8RB5Eabc=", "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.1/zen.linux-specific.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.2/zen.linux-specific.tar.bz2" }, "original": { "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.1/zen.linux-specific.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.2/zen.linux-specific.tar.bz2" } } }, From e02b92e42729bab25a483b66d413b76e4c798a2d Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 17 Dec 2024 03:03:11 +0100 Subject: [PATCH 35/53] Enable virt-manager --- nki-home/configuration.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nki-home/configuration.nix b/nki-home/configuration.nix index a9456c1..5adebe4 100644 --- a/nki-home/configuration.nix +++ b/nki-home/configuration.nix @@ -193,5 +193,12 @@ in }; }; + programs.virt-manager.enable = true; + + users.groups.libvirtd.members = [ "nki" ]; + + virtualisation.libvirtd.enable = true; + + virtualisation.spiceUSBRedirection.enable = true; } From bfaa5c00c5a358887ca26060430f9073f2564245 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 20 Dec 2024 12:32:32 +0100 Subject: [PATCH 36/53] yoga: rename obsolete libinput path --- nki-yoga-g8/configuration.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nki-yoga-g8/configuration.nix b/nki-yoga-g8/configuration.nix index faf8c3d..8b58412 100644 --- a/nki-yoga-g8/configuration.nix +++ b/nki-yoga-g8/configuration.nix @@ -80,7 +80,7 @@ in services.printing.drivers = with pkgs; [ epfl-cups-drivers ]; # Enable touchpad support (enabled default in most desktopManager). - services.xserver.libinput.enable = true; + services.libinput.enable = true; # Keyboard services.input-remapper.enable = true; services.input-remapper.serviceWantedBy = [ "multi-user.target" ]; From 96b6b8c9548c3501a4c27104fd11fa1d6b2e1c17 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 20 Dec 2024 12:32:37 +0100 Subject: [PATCH 37/53] Update zen --- flake.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/flake.lock b/flake.lock index ec765e6..808cb73 100644 --- a/flake.lock +++ b/flake.lock @@ -1042,11 +1042,11 @@ }, "nixpkgs_11": { "locked": { - "lastModified": 1733940404, - "narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=", + "lastModified": 1734424634, + "narHash": "sha256-cHar1vqHOOyC7f1+tVycPoWTfKIaqkoe1Q6TnKzuti4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713", + "rev": "d3c42f187194c26d9f0309a8ecc469d6c878ce33", "type": "github" }, "original": { @@ -1571,11 +1571,11 @@ "zen-browser-specific": "zen-browser-specific" }, "locked": { - "lastModified": 1734235629, - "narHash": "sha256-s2yr4KdY5qXHyOuLCWJm/CG7miiOR+G1PA2aqe3iJCA=", + "lastModified": 1734667644, + "narHash": "sha256-vluyzRt6RikEn78Yk0t7Qd96iZZfyRBt4+ESI0mtlhk=", "owner": "youwen5", "repo": "zen-browser-flake", - "rev": "26237f7bcc5e61b040e1771e7adfe4dc71dd9075", + "rev": "8c8af380bf45b42ae14b2f6d5252be3627332f23", "type": "github" }, "original": { @@ -1587,40 +1587,40 @@ "zen-browser-aarch64": { "flake": false, "locked": { - "lastModified": 1734215440, - "narHash": "sha256-eUT6Zv6MJOjFeeY5WbXeaJ9alcx/11a+93n6LEFg8yI=", + "lastModified": 1734641206, + "narHash": "sha256-F5FwGqAgL4kfEy5rNWvofRQl8SH0udQvEIMhysRMDgs=", "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.2/zen.linux-aarch64.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.3/zen.linux-aarch64.tar.bz2" }, "original": { "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.2/zen.linux-aarch64.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.3/zen.linux-aarch64.tar.bz2" } }, "zen-browser-generic": { "flake": false, "locked": { - "lastModified": 1734220871, - "narHash": "sha256-3NihEgT1GA9BRUf+H4+ZtXgz9wSrxphQUoozW34QuHI=", + "lastModified": 1734646830, + "narHash": "sha256-slIWuEWSV9PK1JTr6UKKC+VP4oLNaczwkxkYiqcjZM8=", "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.2/zen.linux-generic.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.3/zen.linux-generic.tar.bz2" }, "original": { "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.2/zen.linux-generic.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.3/zen.linux-generic.tar.bz2" } }, "zen-browser-specific": { "flake": false, "locked": { - "lastModified": 1734221044, - "narHash": "sha256-B7Jx+Yvr5m1EjHxVffSwzXnkvCyvdwiaeHM8RB5Eabc=", + "lastModified": 1734645803, + "narHash": "sha256-zAo93sHeB8cTW2JBAqxx0wo3CANcxCgjEcTQgbDeWT4=", "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.2/zen.linux-specific.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.3/zen.linux-specific.tar.bz2" }, "original": { "type": "tarball", - "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.2/zen.linux-specific.tar.bz2" + "url": "https://github.com/zen-browser/desktop/releases/download/1.0.2-b.3/zen.linux-specific.tar.bz2" } } }, From a86023efc716be4f74023375f90ec5bf3e85c620 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 17 Dec 2024 22:42:51 +0100 Subject: [PATCH 38/53] Update nixpkgs and default peertube data to external --- flake.lock | 6 +++--- nki-personal-do/peertube.nix | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 808cb73..9d8573f 100644 --- a/flake.lock +++ b/flake.lock @@ -1170,11 +1170,11 @@ }, "nixpkgs_9": { "locked": { - "lastModified": 1732981179, - "narHash": "sha256-F7thesZPvAMSwjRu0K8uFshTk3ZZSNAsXTIFvXBT+34=", + "lastModified": 1734083684, + "narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "62c435d93bf046a5396f3016472e8f7c8e2aed65", + "rev": "314e12ba369ccdb9b352a4db26ff419f7c49fa84", "type": "github" }, "original": { diff --git a/nki-personal-do/peertube.nix b/nki-personal-do/peertube.nix index 1e07358..e5c78c9 100644 --- a/nki-personal-do/peertube.nix +++ b/nki-personal-do/peertube.nix @@ -3,7 +3,9 @@ let secrets = config.sops.secrets; cfg = config.services.peertube; + user = "peertube"; host = "peertube.dtth.ch"; + dataFolder = "/mnt/data/peertube"; port = 19878; in { @@ -57,12 +59,6 @@ in settings.client.videos = { resumable_upload.max_chunk_size = "90MB"; }; - settings.storage = { - storyboards = "/var/lib/peertube/storage/storyboards/"; - tmp = "/mnt/data/peertube/tmp/"; - tmp_persistent = "/mnt/data/peertube/tmp_persistent/"; - web_videos = "/mnt/data/peertube/web-videos/"; - }; # Trust proxy settings.trust_proxy = [ "loopback" ] ++ config.services.traefik.staticConfigOptions.entrypoints.https.forwardedHeaders.trustedIPs; @@ -80,6 +76,18 @@ in systemd.services.peertube = { requires = [ "arion-authentik.service" ]; after = [ "arion-authentik.service" ]; + unitConfig.RequiresMountsFor = [ dataFolder ]; + }; + systemd.tmpfiles.settings."10-peertube" = { + # The service hard-codes a lot of paths here, so it's nicer if we just symlink + "/var/lib/peertube"."L+" = { + argument = dataFolder; + }; + ${dataFolder}."d" = { + user = user; + group = user; + mode = "0700"; + }; }; } From a336f2dcd6fa658b7ba101fb9ca4c124d30c4deb Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 20 Dec 2024 20:53:25 +0100 Subject: [PATCH 39/53] Update nixpkgs-unstable --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 9d8573f..8dec570 100644 --- a/flake.lock +++ b/flake.lock @@ -1010,11 +1010,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1733376361, - "narHash": "sha256-aLJxoTDDSqB+/3orsulE6/qdlX6MzDLIITLZqdgMpqo=", + "lastModified": 1734126203, + "narHash": "sha256-0XovF7BYP50rTD2v4r55tR5MuBLet7q4xIz6Rgh3BBU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "929116e316068c7318c54eb4d827f7d9756d5e9c", + "rev": "71a6392e367b08525ee710a93af2e80083b5b3e2", "type": "github" }, "original": { From 983a1fb0714631d8f556e7bb8a581760121c5cb8 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 20 Dec 2024 20:53:30 +0100 Subject: [PATCH 40/53] Update osu --- home/osu.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/osu.nix b/home/osu.nix index 8b2212e..baef84b 100644 --- a/home/osu.nix +++ b/home/osu.nix @@ -5,7 +5,7 @@ let osu-pkg = with pkgs; with lib; appimageTools.wrapType2 rec { pname = "osu-lazer-bin"; - version = "2024.1208.0"; + version = "2024.1219.2"; src = fetchurl { url = "https://github.com/ppy/osu/releases/download/${version}/osu.AppImage"; hash = "sha256-gRUr7jf0+Xbfz8FurPk/o7F67TYisdNySNzVWEMb1es="; From f636223a8c451d135f1611bcdc8cd3bb5219e5b0 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 28 Sep 2024 16:18:16 +0200 Subject: [PATCH 41/53] kakoune: set up package with plugins --- packages/common/default.nix | 1 + .../common/nki-kakoune/autoload/latex.kak | 133 +++++++++++ .../common/nki-kakoune/autoload/markdown.kak | 29 +++ packages/common/nki-kakoune/default.nix | 3 + packages/common/nki-kakoune/plugins.nix | 209 ++++++++++++++++++ 5 files changed, 375 insertions(+) create mode 100644 packages/common/nki-kakoune/autoload/latex.kak create mode 100644 packages/common/nki-kakoune/autoload/markdown.kak create mode 100644 packages/common/nki-kakoune/default.nix create mode 100644 packages/common/nki-kakoune/plugins.nix diff --git a/packages/common/default.nix b/packages/common/default.nix index be4ba2a..fadb679 100644 --- a/packages/common/default.nix +++ b/packages/common/default.nix @@ -2,4 +2,5 @@ final: prev: { epfl-cups-drivers = final.callPackage ./epfl-cups-drivers { }; ttaenc = final.callPackage ./ttaenc.nix { }; suwako-cursors = final.callPackage ./suwako-cursors { }; + nki-kakoune = final.callPackage ./nki-kakoune { }; } diff --git a/packages/common/nki-kakoune/autoload/latex.kak b/packages/common/nki-kakoune/autoload/latex.kak new file mode 100644 index 0000000..4bb9c9d --- /dev/null +++ b/packages/common/nki-kakoune/autoload/latex.kak @@ -0,0 +1,133 @@ +## Author: @natsukagami (https://github.com/natsukagami) +## +## To activate, source the file into kakrc and add: +### require-module latex-kak +## +## NOTE: This overrides , so if you don't like it, remove it. + +# Create a simple begin block, put the cursors in and remove multi-cursor on exit. +define-command -hidden create-begin-block %{ + execute-keys "i\begin{b0}\end{b0}" + execute-keys "b0" + execute-keys -with-hooks -with-maps "c" + hook -once buffer ModeChange .*:normal %{ + execute-keys -with-maps ",gl" + } +} +# Create a begin block with the given parameter as block name. +define-command -params 1 create-begin-block-with %{ + execute-keys "i\begin{b0}\end{b0}" + execute-keys "b0c%arg{1}," + execute-keys "ok" + execute-keys -with-maps "gl" +} +# Create a \param{} block and put the cursor in the middle. +define-command -params 2 -hidden create-delims %{ + execute-keys "i%arg{1}hZa%arg{2}zl" + execute-keys -with-hooks -with-maps "i" +} +define-command -params 1 create-block-with %{ + create-delims "\%arg{1}{" "}" +} + +# The font-menu +declare-user-mode latex-font +## Semantics +map -docstring "Text" global latex-font t ": create-block-with text" +map -docstring "Emphasize (emph)" global latex-font e ": create-block-with emph" +## Shape +map -docstring "Italics (textit)" global latex-font i ": create-block-with textit" +map -docstring "Upright (textup)" global latex-font u ": create-block-with textup" +# map -docstring "Slanted (textsl)" global latex-font S ": create-block-with textsl" +# map -docstring "Swash font (textsw)" global latex-font W ": create-block-with textsw" +# map -docstring "Small caps (textsc)" global latex-font C ": create-block-with textsc" +# Weight +map -docstring "Bold text (textbf)" global latex-font b ": create-block-with textbf" +# map -docstring "Medium bold (textmd)" global latex-font M ": create-block-with textmd" +# map -docstring "Normal (textnormal)" global latex-font N ": create-block-with textnormal" +## Family +# map -docstring "Serif font (textsf)" global latex-font s ": create-block-with textsf" +# map -docstring "Roman text (textrm)" global latex-font r ": create-block-with textrm" +map -docstring "Monospace (texttt)" global latex-font m ": create-block-with texttt" +## Math styles +map -docstring "Math Calligraphic (mathcal)" global latex-font ": create-block-with mathcal" +map -docstring "Math Blackboard (mathbb)" global latex-font ": create-block-with mathbb" +# map -docstring "Math Fraktur (mathfr)" global latex-font ": create-block-with mathfr" +# map -docstring "Math Roman (mathrm)" global latex-font ": create-block-with mathrm" +# map -docstring "Math Italics (mathit)" global latex-font ": create-block-with mathit" +# map -docstring "Math Bold (mathbf)" global latex-font ": create-block-with mathbf" +# map -docstring "Serif font (mathsf)" global latex-font ": create-block-with mathsf" +map -docstring "Math Monospace (mathtt)" global latex-font ": create-block-with mathtt" +map -docstring "Math Fraktur (mathfrak)" global latex-font f ": create-block-with mathfrak" + +# "Insert block" menu +declare-user-mode latex-insert-block +## Common normal text blocks +map -docstring "Unordered list" global latex-insert-block u ": create-begin-block-with itemize" +map -docstring "Ordered list" global latex-insert-block o ": create-begin-block-with enumerate" +## Common math blocks +map -docstring "Theorem" global latex-insert-block t ": create-begin-block-with theorem" +map -docstring "Definition" global latex-insert-block d ": create-begin-block-with definition" +map -docstring "Lemma" global latex-insert-block l ": create-begin-block-with lemma" +map -docstring "Example" global latex-insert-block e ": create-begin-block-with example" +map -docstring "Proof" global latex-insert-block p ": create-begin-block-with proof" +map -docstring "Remark" global latex-insert-block r ": create-begin-block-with remark" +map -docstring "Proposition" global latex-insert-block ": create-begin-block-with proposition" +map -docstring "Corollary" global latex-insert-block C ": create-begin-block-with corollary" +## Common environments +map -docstring "align*" global latex-insert-block a ": create-begin-block-with align*" +map -docstring "align" global latex-insert-block ": create-begin-block-with align" +map -docstring "equation" global latex-insert-block E ": create-begin-block-with equation" +map -docstring "equation*" global latex-insert-block ": create-begin-block-with equation*" +map -docstring "Matrix" global latex-insert-block m ": create-begin-block-with bmatrix" +map -docstring "Cases" global latex-insert-block C ": create-begin-block-with cases" +map -docstring "Table" global latex-insert-block T ": create-begin-block-with tabular" +## Custom +map -docstring "Custom" global latex-insert-block c ": create-begin-block" + +# Pairs of delimiters +declare-user-mode latex-insert-delims +map -docstring "Grouping" global latex-insert-delims g ": create-delims { }" +map -docstring "Parentheses" global latex-insert-delims p ": create-delims ( )" +map -docstring "Large Parentheses" global latex-insert-delims P ": create-delims \left( \right)" +map -docstring "Brackets" global latex-insert-delims b ": create-delims \left[ \right]" +map -docstring "Sets" global latex-insert-delims s ": create-delims \{ \}" +map -docstring "Large Sets" global latex-insert-delims S ": create-delims \left\{ \right\}" + + +hook global WinSetOption filetype=(tex|latex) %{ + ## Create delims (shortcuts) + map buffer normal ": enter-user-mode latex-insert-delimsp" + map buffer insert ": enter-user-mode latex-insert-delimsp" + map buffer normal ": enter-user-mode latex-insert-delimsg" + map buffer insert ": enter-user-mode latex-insert-delimsg" + map buffer normal "i\(\)Zhhi" + map buffer insert "\(\)Z2h" + map buffer normal "i\[\]Zhhi" + map buffer insert "\[\]Z2h" + map buffer normal ": enter-user-mode latex-insert-delims" + map buffer insert ": enter-user-mode latex-insert-delims" + + ## Quickly create begin/end blocks + map buffer normal ": create-begin-block" + map buffer insert ": create-begin-block" + + ## Font menu + map buffer normal ": enter-user-mode latex-font" + map buffer insert ": enter-user-mode latex-font" + + ## Insert menu + map buffer normal ": enter-user-mode latex-insert-block" + map buffer insert ": enter-user-mode latex-insert-block" + + ## Select math equations and environment blocks + map buffer object e -docstring "Inline Math equation \( \)" "c\\\\\\(,\\\\\\)" + map buffer object E -docstring "Display Math equation \[ \]" "c\\\\\\[,\\\\\\]" + map buffer object v -docstring "Simple environment \env{}" "c\\\\\\w+\\{,\\}" + map buffer object V -docstring "Full environment \begin{env}\end{env}" "c\\\\begin\\{\\w+\\}(?:\\{[\\w\\s]*\\})*(?:\\[[\\w\\s]*\\])*,\\\\end\\{\\w+\\}" + + ## Quickly get a new item + map buffer normal "o\item " + map buffer insert "o\item " +} + diff --git a/packages/common/nki-kakoune/autoload/markdown.kak b/packages/common/nki-kakoune/autoload/markdown.kak new file mode 100644 index 0000000..fb10581 --- /dev/null +++ b/packages/common/nki-kakoune/autoload/markdown.kak @@ -0,0 +1,29 @@ +hook global WinSetOption filetype=(markdown) %{ + map buffer normal ": enter-user-mode markdown-menu" +} + +# A menu for common markdown actions +declare-user-mode markdown-menu + +map -docstring "Toggle the checkboxes on the same line" global markdown-menu t ": markdown-toggle-checkbox" + +define-command -hidden markdown-toggle-checkbox %{ + try %{ + execute-keys -draft "xs^\s*- \[( |x)\]h: markdown-toggle-checkbox-selections" + } +} + +define-command -hidden markdown-toggle-checkbox-selections %{ + try %{ + execute-keys -draft -itersel ": markdown-toggle-checkbox-one" + } +} + +define-command -hidden markdown-toggle-checkbox-one %{ + try %{ + execute-keys -draft "sxr " + } catch %{ + execute-keys -draft "s rx" + } +} + diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix new file mode 100644 index 0000000..6e181ce --- /dev/null +++ b/packages/common/nki-kakoune/default.nix @@ -0,0 +1,3 @@ +{ callPackage, kakoune, ... }: kakoune.override { + plugins = (callPackage ./plugins.nix { }).plugins; +} diff --git a/packages/common/nki-kakoune/plugins.nix b/packages/common/nki-kakoune/plugins.nix new file mode 100644 index 0000000..a16c898 --- /dev/null +++ b/packages/common/nki-kakoune/plugins.nix @@ -0,0 +1,209 @@ +{ pkgs, symlinkJoin, writeTextDir, kakouneUtils, ... }: +with { + inherit (kakouneUtils) buildKakounePluginFrom2Nix; +}; +let + toDir = name: file: writeTextDir name (builtins.readFile file); + + writeActivationScript = script: writeTextDir "on-load.kak" '' + hook global KakBegin .* %{ + ${script} + } + ''; + + writeModuleWrapper = name: script: writeTextDir "module.kak" '' + provide-module ${name} %◍ + ${script} + ◍ + ''; + + kakounePlugin = { name, src, wrapAsModule ? false, activationScript ? null, ... }@attrs: + let + module = if wrapAsModule then writeModuleWrapper name (builtins.readFile src) else src; + in + buildKakounePluginFrom2Nix { + pname = name; + version = attrs.version or "latest"; + src = if activationScript == null then module else + symlinkJoin { + name = "${name}-src"; + paths = [ + module + (writeActivationScript activationScript) + ]; + }; + }; +in +{ + plugins = builtins.map kakounePlugin + [ + # My own scripts + { + name = "latex.kak"; + src = toDir "latex.kak" ./autoload/latex.kak; + } + { + name = "markdown.kak"; + src = toDir "markdown.kak" ./autoload/markdown.kak; + } + + # Plugins + { + name = "luar"; + src = pkgs.fetchFromGitHub { + owner = "gustavo-hms"; + repo = "luar"; + rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; + sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; + }; + activationScript = '' + # Enable luar + require-module luar + # Use luajit + set-option global luar_interpreter ${pkgs.luajit}/bin/luajit + ''; + } + { + name = "peneira"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "peneira"; + rev = "743b9971472853a752475e7c070ce99089c6840c"; + sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; + }; + activationScript = '' + require-module peneira + + # Change selection color + set-face global PeneiraSelected @PrimarySelection + + # Buffers list + define-command -hidden peneira-buffers %{ + peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ + buffer %arg{1} + } + } + + # Grep in the current location + define-command peneira-grep %{ + peneira 'line: ' "rg -n ." %{ + lua %arg{1} %{ + local file, line = arg[1]:match("([^:]+):(%d+):") + kak.edit(file, line) + } + } + } + + # A peneira menu + declare-user-mode fuzzy-match-menu + + map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" + map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" + map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" + map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" + map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" + map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" + + # Bind menu to user mode + map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" + ''; + } + { + name = "kakoune-focus"; + src = pkgs.fetchFromGitHub { + owner = "caksoylar"; + repo = "kakoune-focus"; + rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; + sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; + }; + activationScript = '' + map global user ': focus-toggle' -docstring "toggle selections focus" + ''; + } + { + name = "kakoune-inc-dec"; + src = pkgs.fetchFromGitLab { + owner = "Screwtapello"; + repo = "kakoune-inc-dec"; + rev = "7bfe9c51"; + sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; + }; + } + { + name = "racket.kak"; + src = (builtins.fetchTree { + type = "git"; + url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; + rev = "e397042009b46916ff089d79166ec0e8ca813a18"; + narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; + }) + "/rc"; + } + # { + # name = "kakoune-discord"; + # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; + # } + rec { + name = "kakoune-mirror"; + src = pkgs.fetchFromGitHub + { + owner = "Delapouite"; + repo = "kakoune-mirror"; + rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; + sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; + } + "/mirror.kak"; + wrapAsModule = true; + activationScript = '' + require-module ${name} + + # Bind to ${name} + map global normal ': enter-user-mode -lock mirror' + ''; + } + { + name = "unicode-math"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "kakoune-unicode-math"; + rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; + # sha256 = lib.fakeSha256; + sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; + fetchSubmodules = true; + }; + activationScript = '' + require-module unicode-math + + # Bind to the menu + map global insert ': insert-unicode ' + ''; + } + { + name = "kakoune-buffers"; + src = pkgs.fetchFromGitHub { + owner = "Delapouite"; + repo = "kakoune-buffers"; + rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; + sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; + }; + activationScript = '' + # Suggested hook + + hook global WinDisplay .* info-buffers + + # Suggested mappings + + map global user b ':enter-buffers-mode' -docstring 'buffers…' + map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' + map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' + + # Suggested aliases + + alias global bd delete-buffer + alias global bf buffer-first + alias global bl buffer-last + alias global bo buffer-only + alias global bo! buffer-only-force + ''; + } + ]; +} + From 6a924444c9acab3bceb29610505d51061033804e Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 28 Sep 2024 16:34:57 +0200 Subject: [PATCH 42/53] kakoune: add back kaktex --- packages/common/nki-kakoune/default.nix | 4 +- .../common/nki-kakoune/kaktex/default.nix | 22 ++ .../common/nki-kakoune/kaktex/kaktex.fish | 26 ++ packages/common/nki-kakoune/plugins.nix | 312 +++++++++--------- 4 files changed, 205 insertions(+), 159 deletions(-) create mode 100644 packages/common/nki-kakoune/kaktex/default.nix create mode 100755 packages/common/nki-kakoune/kaktex/kaktex.fish diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 6e181ce..53622ec 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,3 +1,5 @@ { callPackage, kakoune, ... }: kakoune.override { - plugins = (callPackage ./plugins.nix { }).plugins; + plugins = (callPackage ./plugins.nix { }) ++ [ + ./kaktex + ]; } diff --git a/packages/common/nki-kakoune/kaktex/default.nix b/packages/common/nki-kakoune/kaktex/default.nix new file mode 100644 index 0000000..a8005d5 --- /dev/null +++ b/packages/common/nki-kakoune/kaktex/default.nix @@ -0,0 +1,22 @@ +{ fish, lib, writeScript, writeTextDir, kakouneUtils, ... }: +let + kaktex-script = writeScript "kaktex" '' + #!/usr/bin/env ${lib.getExe fish} + + ${builtins.readFile ./kaktex.fish} + ''; + kaktex = writeTextDir "kaktex.kak" '' + hook global WinSetOption filetype=(tex|latex) %{ + hook window WinDisplay '.*' %{ + eval %sh{ + ${kaktex-script} set $kak_client $kak_session + } + } + } + ''; +in +kakouneUtils.buildKakounePluginFrom2Nix { + pname = "kaktex"; + version = "latest"; + src = kaktex; +} diff --git a/packages/common/nki-kakoune/kaktex/kaktex.fish b/packages/common/nki-kakoune/kaktex/kaktex.fish new file mode 100755 index 0000000..bb6690b --- /dev/null +++ b/packages/common/nki-kakoune/kaktex/kaktex.fish @@ -0,0 +1,26 @@ +function usage + echo "Usage: " + echo " kaktex set [client] [session]" + echo " kaktex jump [file] [line] [column]" + exit 1 +end + +if test (count $argv) -lt 3 + usage +end + +switch $argv[1] + case "set" + set -U _kaktex_client $argv[2] + set -U _kaktex_session $argv[3] + case "jump" + echo " + evaluate-commands -client $_kaktex_client %{ + evaluate-commands -try-client $_kaktex_client %{ + edit -existing -- $argv[2] $(math $argv[3] + 1) $(math $argv[4] + 1) + } + } + " | kak -p $_kaktex_session + case '*' + usage +end diff --git a/packages/common/nki-kakoune/plugins.nix b/packages/common/nki-kakoune/plugins.nix index a16c898..b524a14 100644 --- a/packages/common/nki-kakoune/plugins.nix +++ b/packages/common/nki-kakoune/plugins.nix @@ -34,176 +34,172 @@ let }; }; in -{ - plugins = builtins.map kakounePlugin - [ - # My own scripts - { - name = "latex.kak"; - src = toDir "latex.kak" ./autoload/latex.kak; - } - { - name = "markdown.kak"; - src = toDir "markdown.kak" ./autoload/markdown.kak; - } +builtins.map kakounePlugin [ + # My own scripts + { + name = "latex.kak"; + src = toDir "latex.kak" ./autoload/latex.kak; + } + { + name = "markdown.kak"; + src = toDir "markdown.kak" ./autoload/markdown.kak; + } - # Plugins - { - name = "luar"; - src = pkgs.fetchFromGitHub { - owner = "gustavo-hms"; - repo = "luar"; - rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; - sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; - }; - activationScript = '' - # Enable luar - require-module luar - # Use luajit - set-option global luar_interpreter ${pkgs.luajit}/bin/luajit - ''; - } - { - name = "peneira"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "peneira"; - rev = "743b9971472853a752475e7c070ce99089c6840c"; - sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; - }; - activationScript = '' - require-module peneira + # Plugins + { + name = "luar"; + src = pkgs.fetchFromGitHub { + owner = "gustavo-hms"; + repo = "luar"; + rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; + sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; + }; + activationScript = '' + # Enable luar + require-module luar + # Use luajit + set-option global luar_interpreter ${pkgs.luajit}/bin/luajit + ''; + } + { + name = "peneira"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "peneira"; + rev = "743b9971472853a752475e7c070ce99089c6840c"; + sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; + }; + activationScript = '' + require-module peneira - # Change selection color - set-face global PeneiraSelected @PrimarySelection + # Change selection color + set-face global PeneiraSelected @PrimarySelection - # Buffers list - define-command -hidden peneira-buffers %{ - peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ - buffer %arg{1} - } + # Buffers list + define-command -hidden peneira-buffers %{ + peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ + buffer %arg{1} } + } - # Grep in the current location - define-command peneira-grep %{ - peneira 'line: ' "rg -n ." %{ - lua %arg{1} %{ - local file, line = arg[1]:match("([^:]+):(%d+):") - kak.edit(file, line) - } - } + # Grep in the current location + define-command peneira-grep %{ + peneira 'line: ' "rg -n ." %{ + lua %arg{1} %{ + local file, line = arg[1]:match("([^:]+):(%d+):") + kak.edit(file, line) } - - # A peneira menu - declare-user-mode fuzzy-match-menu - - map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" - map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" - map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" - map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" - map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" - map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" - - # Bind menu to user mode - map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" - ''; + } } + + # A peneira menu + declare-user-mode fuzzy-match-menu + + map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" + map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" + map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" + map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" + map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" + map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" + + # Bind menu to user mode + map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" + ''; + } + { + name = "kakoune-focus"; + src = pkgs.fetchFromGitHub { + owner = "caksoylar"; + repo = "kakoune-focus"; + rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; + sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; + }; + activationScript = '' + map global user ': focus-toggle' -docstring "toggle selections focus" + ''; + } + { + name = "kakoune-inc-dec"; + src = pkgs.fetchFromGitLab { + owner = "Screwtapello"; + repo = "kakoune-inc-dec"; + rev = "7bfe9c51"; + sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; + }; + } + { + name = "racket.kak"; + src = (builtins.fetchTree { + type = "git"; + url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; + rev = "e397042009b46916ff089d79166ec0e8ca813a18"; + narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; + }) + "/rc"; + } + # { + # name = "kakoune-discord"; + # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; + # } + rec { + name = "kakoune-mirror"; + src = pkgs.fetchFromGitHub { - name = "kakoune-focus"; - src = pkgs.fetchFromGitHub { - owner = "caksoylar"; - repo = "kakoune-focus"; - rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; - sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; - }; - activationScript = '' - map global user ': focus-toggle' -docstring "toggle selections focus" - ''; - } - { - name = "kakoune-inc-dec"; - src = pkgs.fetchFromGitLab { - owner = "Screwtapello"; - repo = "kakoune-inc-dec"; - rev = "7bfe9c51"; - sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; - }; - } - { - name = "racket.kak"; - src = (builtins.fetchTree { - type = "git"; - url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; - rev = "e397042009b46916ff089d79166ec0e8ca813a18"; - narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; - }) + "/rc"; - } - # { - # name = "kakoune-discord"; - # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; - # } - rec { - name = "kakoune-mirror"; - src = pkgs.fetchFromGitHub - { - owner = "Delapouite"; - repo = "kakoune-mirror"; - rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; - sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; - } + "/mirror.kak"; - wrapAsModule = true; - activationScript = '' - require-module ${name} + owner = "Delapouite"; + repo = "kakoune-mirror"; + rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; + sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; + } + "/mirror.kak"; + wrapAsModule = true; + activationScript = '' + require-module ${name} - # Bind to ${name} - map global normal ': enter-user-mode -lock mirror' - ''; - } - { - name = "unicode-math"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "kakoune-unicode-math"; - rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; - # sha256 = lib.fakeSha256; - sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; - fetchSubmodules = true; - }; - activationScript = '' - require-module unicode-math + # Bind to ${name} + map global normal ': enter-user-mode -lock mirror' + ''; + } + { + name = "unicode-math"; + src = pkgs.fetchFromGitHub { + owner = "natsukagami"; + repo = "kakoune-unicode-math"; + rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; + # sha256 = lib.fakeSha256; + sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; + fetchSubmodules = true; + }; + activationScript = '' + require-module unicode-math - # Bind to the menu - map global insert ': insert-unicode ' - ''; - } - { - name = "kakoune-buffers"; - src = pkgs.fetchFromGitHub { - owner = "Delapouite"; - repo = "kakoune-buffers"; - rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; - sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; - }; - activationScript = '' - # Suggested hook + # Bind to the menu + map global insert ': insert-unicode ' + ''; + } + { + name = "kakoune-buffers"; + src = pkgs.fetchFromGitHub { + owner = "Delapouite"; + repo = "kakoune-buffers"; + rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; + sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; + }; + activationScript = '' + # Suggested hook - hook global WinDisplay .* info-buffers + hook global WinDisplay .* info-buffers - # Suggested mappings + # Suggested mappings - map global user b ':enter-buffers-mode' -docstring 'buffers…' - map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' - map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' + map global user b ':enter-buffers-mode' -docstring 'buffers…' + map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' + map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' - # Suggested aliases - - alias global bd delete-buffer - alias global bf buffer-first - alias global bl buffer-last - alias global bo buffer-only - alias global bo! buffer-only-force - ''; - } - ]; -} + # Suggested aliases + alias global bd delete-buffer + alias global bf buffer-first + alias global bl buffer-last + alias global bo buffer-only + alias global bo! buffer-only-force + ''; + } +] From 22f6e123de7ce8ebc20c655de04b83dde0c4294e Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 28 Sep 2024 16:54:39 +0200 Subject: [PATCH 43/53] kakoune: add back themes --- packages/common/nki-kakoune/default.nix | 4 +- packages/common/nki-kakoune/themes.nix | 9 +++ .../nki-kakoune/themes/catppuccin-latte.kak | 79 +++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 packages/common/nki-kakoune/themes.nix create mode 100644 packages/common/nki-kakoune/themes/catppuccin-latte.kak diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 53622ec..2c6a83d 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,5 +1,7 @@ { callPackage, kakoune, ... }: kakoune.override { - plugins = (callPackage ./plugins.nix { }) ++ [ + plugins = callPackage ./plugins.nix { } + ++ callPackage ./themes.nix { } + ++ [ ./kaktex ]; } diff --git a/packages/common/nki-kakoune/themes.nix b/packages/common/nki-kakoune/themes.nix new file mode 100644 index 0000000..5be9a6d --- /dev/null +++ b/packages/common/nki-kakoune/themes.nix @@ -0,0 +1,9 @@ +{ writeScriptDir, ... }: +let + themes = [ + { name = "catppuccin-latte"; src = ./themes/catppucin-latte.kak; } + ]; + + themeToColorscheme = name: src: writeScriptDir "share/kak/colors/${name}.kak" (builtins.readFile src); +in +builtins.map themeToColorscheme themes diff --git a/packages/common/nki-kakoune/themes/catppuccin-latte.kak b/packages/common/nki-kakoune/themes/catppuccin-latte.kak new file mode 100644 index 0000000..bd40ead --- /dev/null +++ b/packages/common/nki-kakoune/themes/catppuccin-latte.kak @@ -0,0 +1,79 @@ +# Catppuccin theme for Kakoune + +declare-option str rosewater "rgb:dc8a78" +declare-option str flamingo "rgb:dd7878" +declare-option str pink "rgb:ea76cb" +declare-option str mauve "rgb:8839ef" +declare-option str red "rgb:d20f39" +declare-option str maroon "rgb:e64553" +declare-option str peach "rgb:fe640b" +declare-option str yellow "rgb:df8e1d" +declare-option str green "rgb:40a02b" +declare-option str teal "rgb:179299" +declare-option str sky "rgb:04a5e5" +declare-option str sapphire "rgb:209fb5" +declare-option str blue "rgb:1e66f5" +declare-option str lavender "rgb:7287fd" +declare-option str text "rgb:4c4f69" +declare-option str subtext1 "rgb:5c5f77" +declare-option str subtext0 "rgb:6c6f85" +declare-option str overlay2 "rgb:7c7f93" +declare-option str overlay1 "rgb:8c8fa1" +declare-option str overlay0 "rgb:9ca0b0" +declare-option str surface2 "rgb:acb0be" +declare-option str surface1 "rgb:bcc0cc" +declare-option str surface0 "rgb:ccd0da" +declare-option str base "rgb:eff1f5" +declare-option str mantle "rgb:e6e9ef" +declare-option str crust "rgb:dce0e8" + + +set-face global title "%opt{text}+b" +set-face global header "%opt{subtext0}+b" +set-face global bold "%opt{maroon}+b" +set-face global italic "%opt{maroon}+i" +set-face global mono "%opt{green}" +set-face global block "%opt{sapphire}" +set-face global link "%opt{blue}" +set-face global bullet "%opt{peach}" +set-face global list "%opt{peach}" + +set-face global Default "%opt{text},%opt{base}" +set-face global PrimarySelection "%opt{text},%opt{surface2}" +set-face global SecondarySelection "%opt{text},%opt{surface2}" +set-face global PrimaryCursor "%opt{crust},%opt{rosewater}" +set-face global SecondaryCursor "%opt{text},%opt{overlay0}" +set-face global PrimaryCursorEol "%opt{surface2},%opt{lavender}" +set-face global SecondaryCursorEol "%opt{surface2},%opt{overlay1}" +set-face global LineNumbers "%opt{overlay1},%opt{base}" +set-face global LineNumberCursor "%opt{rosewater},%opt{surface2}+b" +set-face global LineNumbersWrapped "%opt{rosewater},%opt{surface2}+i" +set-face global MenuForeground "%opt{text},%opt{surface1}+b" +set-face global MenuBackground "%opt{text},%opt{surface0}" +set-face global MenuInfo "%opt{crust},%opt{teal}" +set-face global Information "%opt{crust},%opt{teal}" +set-face global Error "%opt{crust},%opt{red}" +set-face global StatusLine "%opt{text},%opt{mantle}" +set-face global StatusLineMode "%opt{crust},%opt{yellow}" +set-face global StatusLineInfo "%opt{crust},%opt{teal}" +set-face global StatusLineValue "%opt{crust},%opt{yellow}" +set-face global StatusCursor "%opt{crust},%opt{rosewater}" +set-face global Prompt "%opt{teal},%opt{base}+b" +set-face global MatchingChar "%opt{maroon},%opt{base}" +set-face global Whitespace "%opt{overlay1},%opt{base}+f" +set-face global WrapMarker "Whitespace" +set-face global BufferPadding "%opt{base},%opt{base}" + +set-face global value "%opt{peach}" +set-face global type "%opt{blue}" +set-face global variable "%opt{text}" +set-face global module "%opt{maroon}" +set-face global function "%opt{blue}" +set-face global string "%opt{green}" +set-face global keyword "%opt{mauve}" +set-face global operator "%opt{sky}" +set-face global attribute "%opt{green}" +set-face global comment "%opt{overlay0}" +set-face global documentation "comment" +set-face global meta "%opt{yellow}" +set-face global builtin "%opt{red}" From 87af0ae3bacf4073325c895a02c38763212ae621 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 14:30:47 +0200 Subject: [PATCH 44/53] Add lsp and rc --- home/common.nix | 1 + overlay.nix | 2 + packages/common/nki-kakoune/default.nix | 22 +- packages/common/nki-kakoune/kakrc | 191 ++++++++++++ packages/common/nki-kakoune/lsp.nix | 307 ++++++++++++++++++++ packages/common/nki-kakoune/rc.nix | 18 ++ packages/common/nki-kakoune/source-pwd.fish | 14 + packages/common/nki-kakoune/themes.nix | 6 +- packages/common/nki-kakoune/utils.nix | 5 + 9 files changed, 560 insertions(+), 6 deletions(-) create mode 100644 packages/common/nki-kakoune/kakrc create mode 100644 packages/common/nki-kakoune/lsp.nix create mode 100644 packages/common/nki-kakoune/rc.nix create mode 100755 packages/common/nki-kakoune/source-pwd.fish create mode 100644 packages/common/nki-kakoune/utils.nix diff --git a/home/common.nix b/home/common.nix index 2034fce..3007565 100644 --- a/home/common.nix +++ b/home/common.nix @@ -42,6 +42,7 @@ unzip zstd atool + nki-kakoune ]; home.sessionVariables = { diff --git a/overlay.nix b/overlay.nix index 4ad7209..e38f3a1 100644 --- a/overlay.nix +++ b/overlay.nix @@ -102,6 +102,8 @@ let buildInputs = (with final; lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Security SystemConfiguration CoreServices ]) ) ++ (with final; [ libiconv ]); + + meta.mainProgram = "kak-lsp"; }; zen-browser-bin = final.callPackage inputs.zen-browser.packages.${final.stdenv.system}.zen-browser.override { diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 2c6a83d..bb65355 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,7 +1,23 @@ -{ callPackage, kakoune, ... }: kakoune.override { +{ callPackage, kakoune, kakoune-unwrapped, ... }: +let + lsp = callPackage ./lsp.nix { }; +in +(kakoune.override { plugins = callPackage ./plugins.nix { } ++ callPackage ./themes.nix { } ++ [ - ./kaktex + (callPackage ./kaktex { }) + (callPackage ./rc.nix { }) + lsp.plugin ]; -} +}).overrideAttrs (attrs: { + buildCommand = '' + ${attrs.buildCommand or ""} + # location of kak binary is used to find ../share/kak/autoload, + # unless explicitly overriden with KAKOUNE_RUNTIME + rm "$out/bin/kak" + makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ + --set KAKOUNE_RUNTIME "$out/share/kak" \ + --suffix PATH ":" "${lsp.extraPaths}" + ''; +}) diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc new file mode 100644 index 0000000..aafa044 --- /dev/null +++ b/packages/common/nki-kakoune/kakrc @@ -0,0 +1,191 @@ +# Enable kak-tree-sitter +eval %sh{test -z "$WE_STARTED_KAK" && kak-tree-sitter --kakoune -d --server --init $kak_session} +map global normal ": enter-user-mode tree-sitter" +# ## Set some color overrides +# set global kts_yellow "rgb:e2b75e" +# set global kts_teal "rgb:008080" +# set global kts_mauve "rgb:c264ff" +# set global kts_sky "rgb:6aa622" +# Color scheme +colorscheme catppuccin-latte +set global base "default" + +# Set indentation guides +add-highlighter global/indent-guides show-whitespaces -tab " " -spc " " -lf " " -nbsp " " +set-face global Whitespace default,default +set-face global WhitespaceIndent +d@comment + +# Assistant +set global ui_options terminal_assistant=cat + +# Enable line numbers +hook global WinCreate .* %{ + addhl window/number-lines number-lines +} + +set global grepcmd "rg --line-number --no-column --no-heading --color=never " + +# Kitty-specific options +hook -group windowing global KakBegin .* %{ + set global kitty_window_type os-window +} + +# Comment line and block +map global normal <#> ': comment-line' +map global normal ': comment-block' + +# Go to grep-jump +map global goto f -docstring "current grep-jump match" ': grep-jump' + +# System clipboard interactions +hook global RegisterModified '"' %{ nop %sh{ + printf "%s" "$kak_main_reg_dquote" | pbcopy >/dev/null 2>/dev/null & +}} +map global user P -docstring "Paste before cursor from clipboard" '! pbpaste -n | cat' +map global user p -docstring "Paste after cursor from clipboard" ' pbpaste -n | cat' +map global user R -docstring "Replace selection with text from clipboard" '! pbpaste -n | cat' +define-command -params 0 -docstring "Copy line down" copyline %{ + execute-keys -draft 'xy'%val{count}'P' +} +map global normal <+> -docstring "Copy line down" ': copyline' +define-command -params 0 -docstring "Delete current pair of brackets" delete-current-brackets %{ + execute-keys 'm' + execute-keys -draft 'd' + execute-keys 'H' +} +map global normal D ": delete-current-brackets" + +# Disable write-to +# unalias global w +# define-command -params 0 -docstring "Writes the current file" w "write" + +# Tab sizes +hook global InsertChar \t %{ exec -draft -itersel h@ } +set global tabstop 2 +set global indentwidth 2 + +# Language-specific tabstop with override +hook global WinSetOption filetype=(rust) %{ + set window tabstop 4 + set window indentwidth 4 +} + +# Ctrl + a in insert mode = esc +map global insert '' + +# Tab completion +hook global InsertCompletionShow .* %{ + try %{ + # this command temporarily removes cursors preceded by whitespace; + # if there are no cursors left, it raises an error, does not + # continue to execute the mapping commands, and the error is eaten + # by the `try` command so no warning appears. + execute-keys -draft 'h\h' + map window insert + map window insert + } +} +hook global InsertCompletionHide .* %{ + unmap window insert + unmap window insert +} + +# in Insert mode moves to end of line. +map global insert 'A' + +hook global WinSetOption filetype=(fsharp) %{ + set-option window comment_line "//" + # Set up formatting + # set-option window formatcmd "~/.dotnet/tools/fantomas --stdin --stdout" + # hook window -group fsharp-format BufWritePre .* %{ format } +} + +hook global WinSetOption filetype=(ocaml) %{ + unset-option buffer comment_line + set-option buffer comment_block_begin "(*" + set-option buffer comment_block_end "*)" +} + +hook global WinSetOption filetype=(haskell) %{ + set-option buffer makecmd "cabal build" +} + +hook global WinSetOption filetype=(rust) %{ + set-option buffer makecmd "cargo check" +} + +hook global WinSetOption filetype=(scala) %{ + # Format the document if possible + hook -group scala-fmt window BufWritePre .* %{ lsp-formatting-sync } +} + +hook global WinSetOption filetype=(typst) %{ + set-option window comment_line "//" + set-option window comment_block_begin "/*" + set-option window comment_block_end "*/" + + # borrow markdown's hooks + require-module markdown + + hook window ModeChange pop:insert:.* -group markdown-trim-indent markdown-trim-indent + hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line + hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } +} + +define-command -params 0 -docstring "Set up build" scala-build-connect %{ + lsp-execute-command 'build-connect' '"[]"' +} + +define-command -params 0 -docstring "Import build" scala-build-import %{ + lsp-execute-command 'build-import' '"[]"' +} + +def -hidden insert-c-n %{ + try %{ + lsp-snippets-select-next-placeholders + exec 'd' + } catch %{ + exec -with-hooks '' + } +} +map global insert ": insert-c-n" + +# Use C++ for .h headers +hook global BufCreate .*[.](h) %{ + set-option buffer filetype cpp +} + +hook global BufCreate .*[.]kakrc %{ + set-option buffer filetype kak +} + +hook global BufCreate .*[.]md %{ + add-highlighter buffer/ wrap +} + +hook global BufCreate .*[.](sc|sbt) %{ + set-option buffer filetype scala +} + +hook global BufCreate .*[.]typ %{ + set-option buffer filetype typst + add-highlighter buffer/ wrap +} + +hook global BufCreate .*[.]templ %{ + set-option buffer filetype templ + set-option buffer comment_line "//" +} + +hook global BufCreate .*[.]hylo %{ + set-option buffer filetype hylo + set-option buffer comment_line "//" +} + +hook global BufOpenFile .* %{ + modeline-parse +} + +map global normal ':inc-dec-modify-numbers + %val{count}' +map global normal ':inc-dec-modify-numbers - %val{count}' diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix new file mode 100644 index 0000000..3712d6f --- /dev/null +++ b/packages/common/nki-kakoune/lsp.nix @@ -0,0 +1,307 @@ +{ lib +, writeTextDir +, formats +, kak-lsp +, # LSP packages + ccls +, gopls +, nil +, nixpkgs-fmt +, python311Packages +, ltex-ls +, nodePackages +, tailwindcss-language-server +, fsautocomplete +, metals +, texlab +, marksman +, rust-analyzer +, ... +}: +let + # Configuration for kak-lsp + config = { + languageIDs = { + c = "c_cpp"; + cpp = "c_cpp"; + javascript = "javascriptreact"; + typescript = "typescriptreact"; + protobuf = "proto"; + sh = "shellscript"; + }; + + languageServers = + let + vscodeServerOf = name: { + name = "vscode-${name}-language-server"; + value = { + args = [ "--stdio" ]; + command = "vscode-${name}-language-server"; + filetypes = [ name "templ" ]; + roots = [ "package.json" ".git" ]; + }; + package = nodePackages.vscode-langservers-extracted; + }; + in + { + ccls = { + args = [ "-v=2" "-log-file=/tmp/ccls.log" ]; + package = ccls; + command = "ccls"; + filetypes = [ "c" "cpp" ]; + roots = [ "compile_commands.json" ".cquery" ".git" ]; + }; + gopls = { + command = "gopls"; + package = gopls; + filetypes = [ "go" ]; + offset_encoding = "utf-8"; + roots = [ "Gopkg.toml" "go.mod" ".git" ".hg" ]; + settings = { gopls = { hoverKind = "SynopsisDocumentation"; semanticTokens = true; }; }; + settings_section = "gopls"; + }; + haskell-language-server = { + args = [ "--lsp" ]; + command = "haskell-language-server-wrapper"; + filetypes = [ "haskell" ]; + roots = [ "Setup.hs" "stack.yaml" "*.cabal" "package.yaml" ]; + settings_section = "haskell"; + }; + nil = { + command = "nil"; + package = nil; + filetypes = [ "nix" ]; + roots = [ "flake.nix" "shell.nix" ".git" ]; + settings.nil = { + formatting.command = [ "${lib.getExe nixpkgs-fmt}" ]; + }; + }; + pylsp = { + command = "pylsp"; + package = python311Packages.python-lsp-server; + filetypes = [ "python" ]; + offset_encoding = "utf-8"; + roots = [ "requirements.txt" "setup.py" ".git" ".hg" ]; + }; + # Spellchecking server + ltex-ls = { + command = "ltex-ls"; + args = [ "--log-file=/tmp" ]; + filetypes = [ "latex" "typst" ]; + roots = [ "main.tex" "main.typ" ".git" ]; + package = ltex-ls; + }; + tailwind = { + command = "tailwindcss-language-server"; + args = [ "--stdio" ]; + filetypes = [ "html" "css" "javascript" "typescript" "templ" ]; + roots = [ "tailwind.config.{js,cjs,mjs,ts}" "package.json" ".git" ]; + settings_section = "tailwindCSS"; + settings.tailwindCSS = { + validate = "warning"; + userLanguages.templ = "html"; + }; + package = tailwindcss-language-server; + }; + elixir-ls = { + args = [ ]; + command = "elixir-ls"; + filetypes = [ "elixir" ]; + roots = [ "mix.exs" ]; + }; + typescript-language-server = { + args = [ "--stdio" ]; + command = "typescript-language-server"; + filetypes = [ "typescript" "javascript" ]; + roots = [ "package.json" ]; + package = nodePackages.typescript-language-server; + }; + fsautocomplete = { + args = [ "--adaptive-lsp-server-enabled" "--project-graph-enabled" "--source-text-factory" "RoslynSourceText" ]; + command = "fsautocomplete"; + filetypes = [ "fsharp" ]; + roots = [ "*.fsproj" ]; + settings_section = "FSharp"; + settings.FSharp = { + AutomaticWorkspaceInit = true; + }; + package = fsautocomplete; + }; + metals = { + command = "metals"; + filetypes = [ "scala" ]; + roots = [ "build.sbt" "build.sc" ]; + settings_section = "metals"; + settings.metals = { + enableSemanticHighlighting = true; + showInferredType = true; + decorationProvider = true; + inlineDecorationProvider = true; + # From kakoune-lsp's own options + icons = "unicode"; + isHttpEnabled = true; + statusBarProvider = "log-message"; + compilerOptions = { overrideDefFormat = "unicode"; }; + }; + package = metals; + }; + texlab = { + command = "texlab"; + filetypes = [ "latex" ]; + roots = [ "main.tex" "all.tex" ".git" ]; + settings_section = "texlab"; + settings.texlab = { + build.executable = "latexmk"; + build.args = [ "-pdf" "-shell-escape" "-interaction=nonstopmode" "-synctex=1" "%f" ]; + + build.forwardSearchAfter = true; + build.onSave = true; + + # forwardSearch = + # (if pkgs.stdenv.isDarwin then { + # executable = "/Applications/Skim.app/Contents/SharedSupport/displayline"; + # args = [ "-r" "-g" "%l" "%p" "%f" ]; + # } else + # { + # executable = "${pkgs.zathura}/bin/zathura"; + # args = [ "--synctex-forward" "%l:1:%f" "%p" "-x" "${./kaktex} jump %%{input} %%{line} %%{column}" ]; + # }); + }; + package = texlab; + }; + typst-lsp = { + command = "typst-lsp"; + filetypes = [ "typst" ]; + roots = [ "main.typ" ".git" ]; + settings_section = "typst-lsp"; + settings.typst-lsp = { + experimentalFormatterMode = "on"; + }; + }; + marksman = { + command = "marksman"; + filetypes = [ "markdown" ]; + roots = [ ".marksman.toml" ".git" ]; + package = marksman; + }; + rust-analyzer = { + args = [ ]; + command = "rust-analyzer"; + filetypes = [ "rust" ]; + roots = [ "Cargo.toml" ]; + package = rust-analyzer; + }; + + } // (builtins.listToAttrs (builtins.map vscodeServerOf [ "html" "css" "json" ])); + + faces = [ + ## Items + # (Rust) Macros + { face = "attribute"; token = "attribute"; } + { face = "attribute"; token = "derive"; } + { face = "macro"; token = "macro"; } # Function-like Macro + # Keyword and Fixed Tokens + { face = "keyword"; token = "keyword"; } + { face = "operator"; token = "operator"; } + # Functions and Methods + { face = "function"; token = "function"; } + { face = "method"; token = "method"; } + # Constants + { face = "string"; token = "string"; } + { face = "format_specifier"; token = "formatSpecifier"; } + # Variables + { face = "variable"; token = "variable"; modifiers = [ "readonly" ]; } + { face = "mutable_variable"; token = "variable"; } + { face = "module"; token = "namespace"; } + { face = "variable"; token = "type_parameter"; } + { face = "class"; token = "enum"; } + { face = "class"; token = "struct"; } + { face = "class"; token = "trait"; } + { face = "class"; token = "union"; } + { face = "class"; token = "class"; } + + ## Comments + { face = "documentation"; token = "comment"; modifiers = [ "documentation" ]; } + { face = "comment"; token = "comment"; } + + # Typst + { face = "header"; token = "heading"; } + { face = "ts_markup_link_url"; token = "link"; } + { face = "ts_markup_link_uri"; token = "ref"; } + { face = "ts_markup_link_label"; token = "label"; } + { face = "ts_property"; token = "pol"; } + { face = "ts_markup_list_checked"; token = "marker"; } + { face = "ts_constant_builtin_boolean"; token = "bool"; } + { face = "ts_keyword_control"; token = "delim"; } + { face = "ts_number"; token = "text"; modifiers = [ "math" ]; } + { face = "ts_markup_bold"; token = "text"; modifiers = [ "strong" ]; } + { face = "ts_markup_italic"; token = "text"; modifiers = [ "emph" ]; } + ]; + + raw = { + server = { timeout = 1800; }; + snippet_support = false; + verbosity = 255; + }; + }; + + kak-lsp-config = + let + toml = formats.toml { }; + toLspConfig = attrs: builtins.removeAttrs attrs [ "package" ]; + in + toml.generate "kak-lsp.toml" ({ + semantic_tokens.faces = config.faces; + language_server = toLspConfig config.languageServers; + language_ids = config.languageIDs; + } // config.raw); + + serverPackages = + builtins.filter (v: v != null) + (lib.mapAttrsToList (_: serv: serv.package or null) config.languageServers); +in +{ + extraPaths = lib.makeBinPath serverPackages; + plugin = writeTextDir "share/kak/autoload/kak-lsp.kak" '' + hook global KakBegin .* %{ + try %{ + eval %sh{${lib.getExe kak-lsp} --config ${kak-lsp-config} -s $kak_session} + } + + lsp-enable + map window lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" + map window normal ": enter-user-mode lsp" + map window normal ": lsp-hover" + map window normal ": lsp-hover-buffer" + # lsp-auto-hover-insert-mode-enable + set window lsp_hover_anchor true + map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' + map global object a 'lsp-object' -docstring 'LSP any symbol' + map global object 'lsp-object' -docstring 'LSP any symbol' + map global object f 'lsp-object Function Method' -docstring 'LSP function or method' + map global object t 'lsp-object Class Interface Struct' -docstring 'LSP class interface or struct' + map global object d 'lsp-diagnostic-object --include-warnings' -docstring 'LSP errors and warnings' + map global object D 'lsp-diagnostic-object' -docstring 'LSP errors' + + hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|haskell|nix|fsharp|templ) %{ + # Format the document if possible + hook window BufWritePre .* %{ lsp-formatting-sync } + } + + hook global WinSetOption filetype=(rust|scala|fsharp) %{ + # Enable inlay hints + lsp-inlay-hints-enable window + } + + hook global WinSetOption filetype=(rust|go|fsharp|typst|scala) %{ + hook window -group semantic-tokens BufReload .* lsp-semantic-tokens + hook window -group semantic-tokens NormalIdle .* lsp-semantic-tokens + hook window -group semantic-tokens InsertIdle .* lsp-semantic-tokens + hook -once -always window WinSetOption filetype=.* %{ + remove-hooks window semantic-tokens + } + } + } + ''; +} + diff --git a/packages/common/nki-kakoune/rc.nix b/packages/common/nki-kakoune/rc.nix new file mode 100644 index 0000000..fa4c94d --- /dev/null +++ b/packages/common/nki-kakoune/rc.nix @@ -0,0 +1,18 @@ +{ lib, fish, writeScript, writeTextDir, ... }: + +let + source-pwd = writeScript "source-pwd" '' + #!/usr/bin/env ${lib.getExe fish} + + ${builtins.readFile ./source-pwd.fish} + ''; +in +writeTextDir "share/kak/kakrc.local" '' + ${builtins.readFile ./kakrc} + + # Source any settings in the current working directory, + # recursive upwards + evaluate-commands %sh{ + ${source-pwd} + } +'' diff --git a/packages/common/nki-kakoune/source-pwd.fish b/packages/common/nki-kakoune/source-pwd.fish new file mode 100755 index 0000000..aa9aa37 --- /dev/null +++ b/packages/common/nki-kakoune/source-pwd.fish @@ -0,0 +1,14 @@ +if test (pwd) = "/home/natsukagami/.config/kak" + exit 0 +end + +while true + set kakrc (pwd)/.kakrc + if test -f $kakrc + echo source $kakrc + end + if test (pwd) = "/" + exit 0 + end + cd .. +end diff --git a/packages/common/nki-kakoune/themes.nix b/packages/common/nki-kakoune/themes.nix index 5be9a6d..5c24299 100644 --- a/packages/common/nki-kakoune/themes.nix +++ b/packages/common/nki-kakoune/themes.nix @@ -1,9 +1,9 @@ -{ writeScriptDir, ... }: +{ writeTextDir, ... }: let themes = [ - { name = "catppuccin-latte"; src = ./themes/catppucin-latte.kak; } + { name = "catppuccin-latte"; src = ./themes/catppuccin-latte.kak; } ]; - themeToColorscheme = name: src: writeScriptDir "share/kak/colors/${name}.kak" (builtins.readFile src); + themeToColorscheme = { name, src }: writeTextDir "share/kak/colors/${name}.kak" (builtins.readFile src); in builtins.map themeToColorscheme themes diff --git a/packages/common/nki-kakoune/utils.nix b/packages/common/nki-kakoune/utils.nix new file mode 100644 index 0000000..47e7c75 --- /dev/null +++ b/packages/common/nki-kakoune/utils.nix @@ -0,0 +1,5 @@ +{ lib, writeFile, ... }: { + mkFacesScript = name: faces: writeFile "${name}-faces.kak" ( + lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") faces)) + ); +} From 53cafeb0210aeb3baef41fe81449a774363d9d13 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 16:31:33 +0200 Subject: [PATCH 45/53] Add tree-sitter --- packages/common/kak-tree-sitter.nix | 2 + packages/common/nki-kakoune/default.nix | 7 +- packages/common/nki-kakoune/kakrc | 3 - packages/common/nki-kakoune/rc.nix | 11 +- .../nki-kakoune/tree-sitter/default.nix | 171 ++++++++++++++++++ .../nki-kakoune/tree-sitter/grammars.nix | 119 ++++++++++++ packages/common/nki-kakoune/utils.nix | 10 +- 7 files changed, 314 insertions(+), 9 deletions(-) create mode 100644 packages/common/nki-kakoune/tree-sitter/default.nix create mode 100644 packages/common/nki-kakoune/tree-sitter/grammars.nix diff --git a/packages/common/kak-tree-sitter.nix b/packages/common/kak-tree-sitter.nix index 3e0c6a9..9819e3a 100644 --- a/packages/common/kak-tree-sitter.nix +++ b/packages/common/kak-tree-sitter.nix @@ -35,6 +35,8 @@ let self.runtime_dir.join("sources").join(url_dir) '') ]; + + meta.mainProgram = "kak-tree-sitter"; }; in kak-tree-sitter diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index bb65355..0d48b06 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,13 +1,18 @@ { callPackage, kakoune, kakoune-unwrapped, ... }: let lsp = callPackage ./lsp.nix { }; + tree-sitter = callPackage ./tree-sitter { }; + rc = (callPackage ./rc.nix { + prependRc = tree-sitter.rc; + }); in (kakoune.override { plugins = callPackage ./plugins.nix { } ++ callPackage ./themes.nix { } ++ [ (callPackage ./kaktex { }) - (callPackage ./rc.nix { }) + rc + tree-sitter.plugin lsp.plugin ]; }).overrideAttrs (attrs: { diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc index aafa044..dc06ca3 100644 --- a/packages/common/nki-kakoune/kakrc +++ b/packages/common/nki-kakoune/kakrc @@ -1,6 +1,3 @@ -# Enable kak-tree-sitter -eval %sh{test -z "$WE_STARTED_KAK" && kak-tree-sitter --kakoune -d --server --init $kak_session} -map global normal ": enter-user-mode tree-sitter" # ## Set some color overrides # set global kts_yellow "rgb:e2b75e" # set global kts_teal "rgb:008080" diff --git a/packages/common/nki-kakoune/rc.nix b/packages/common/nki-kakoune/rc.nix index fa4c94d..ac579c9 100644 --- a/packages/common/nki-kakoune/rc.nix +++ b/packages/common/nki-kakoune/rc.nix @@ -1,4 +1,11 @@ -{ lib, fish, writeScript, writeTextDir, ... }: +{ lib +, fish +, writeScript +, writeTextDir +, prependRc ? "" +, appendRc ? "" +, ... +}: let source-pwd = writeScript "source-pwd" '' @@ -8,7 +15,9 @@ let ''; in writeTextDir "share/kak/kakrc.local" '' + ${prependRc} ${builtins.readFile ./kakrc} + ${appendRc} # Source any settings in the current working directory, # recursive upwards diff --git a/packages/common/nki-kakoune/tree-sitter/default.nix b/packages/common/nki-kakoune/tree-sitter/default.nix new file mode 100644 index 0000000..ce16343 --- /dev/null +++ b/packages/common/nki-kakoune/tree-sitter/default.nix @@ -0,0 +1,171 @@ +{ lib +, callPackage +, formats +, runCommandLocal +, kak-tree-sitter +, ... +}: +let + utils = callPackage ../utils.nix { }; + grammars = (callPackage ./grammars.nix { }).grammars; + # Highlighter groups to add to the `highlighterGroups`. Maps from group names to face names. + highlighterGroups = { + attribute = "@attribute"; + comment = "@comment"; + conceal = "%opt{mauve}+i"; + constant = "%opt{peach}"; + constant_builtin_boolean = "%opt{sky}"; + constant_character = "%opt{yellow}"; + constant_macro = "%opt{mauve}"; + constant_numeric = "%opt{peach}"; + constructor = "%opt{sapphire}"; + diff_plus = "%opt{green}"; + diff_minus = "%opt{red}"; + diff_delta = "%opt{blue}"; + diff_delta_moved = "%opt{mauve}"; + error = "%opt{red}+b"; + function = "@function"; + function_builtin = "@builtin"; + function_macro = "+i@ts_function"; + hint = "%opt{blue}+b"; + info = "%opt{green}+b"; + keyword = "keyword"; + keyword_conditional = "+i@ts_keyword"; + keyword_control_conditional = "+i@ts_keyword"; + keyword_control_directive = "+i@ts_keyword"; + keyword_control_import = "+i@ts_keyword"; + keyword_directive = "+i@ts_keyword"; + label = "%opt{sapphire}+i"; + markup_bold = "%opt{peach}+b"; + markup_heading = "%opt{red}"; + markup_heading_1 = "%opt{red}"; + markup_heading_2 = "%opt{mauve}"; + markup_heading_3 = "%opt{green}"; + markup_heading_4 = "%opt{yellow}"; + markup_heading_5 = "%opt{pink}"; + markup_heading_6 = "%opt{teal}"; + markup_heading_marker = "%opt{peach}+b"; + markup_italic = "%opt{pink}+i"; + markup_list_checked = "%opt{green}"; + markup_list_numbered = "%opt{blue}+i"; + markup_list_unchecked = "%opt{teal}"; + markup_list_unnumbered = "%opt{mauve}"; + markup_link_label = "%opt{blue}"; + markup_link_url = "%opt{teal}+u"; + markup_link_uri = "%opt{teal}+u"; + markup_link_text = "%opt{blue}"; + markup_quote = "%opt{crust}"; + markup_raw = "%opt{sky}"; + markup_raw_block = "%opt{sky}"; + markup_raw_inline = "%opt{green}"; + markup_strikethrough = "%opt{crust}+s"; + namespace = "@module"; + operator = "@operator"; + property = "%opt{sky}"; + punctuation = "%opt{overlay2}"; + punctuation_special = "%opt{sky}"; + special = "%opt{blue}"; + spell = "%opt{mauve}"; + string = "%opt{green}"; + string_regex = "%opt{peach}"; + string_regexp = "%opt{peach}"; + string_escape = "%opt{mauve}"; + string_special = "%opt{blue}"; + string_special_path = "%opt{green}"; + string_special_symbol = "%opt{mauve}"; + string_symbol = "%opt{red}"; + tag = "%opt{teal}"; + tag_error = "%opt{red}"; + text_title = "%opt{mauve}"; + type = "@type"; + type_enum_variant = "+i@ts_type"; + variable = "@variable"; + variable_builtin = "@builtin"; + variable_other_member = "%opt{teal}"; + variable_parameter = "+i@variable"; + warning = "%opt{peach}+b"; + }; + + # Highlighter groups to be aliased by other groups + aliases = { + comment_block = "comment"; + comment_line = "comment"; + constant_character_escape = "constant_character"; + constant_numeric_float = "constant_numeric"; + constant_numeric_integer = "constant_numeric"; + function_method = "function"; + function_special = "function"; + keyword_control = "keyword"; + keyword_control_repeat = "keyword"; + keyword_control_return = "keyword"; + keyword_control_except = "keyword"; + keyword_control_exception = "keyword"; + keyword_function = "keyword"; + keyword_operator = "keyword"; + keyword_special = "keyword"; + keyword_storage = "keyword"; + keyword_storage_modifier = "keyword"; + keyword_storage_modifier_mut = "keyword"; + keyword_storage_modifier_ref = "keyword"; + keyword_storage_type = "keyword"; + punctuation_bracket = "punctuation"; + punctuation_delimiter = "punctuation"; + text = "string"; + type_builtin = "type"; + + # Scala stuff + method = "function"; + module = "namespace"; + function_call = "function"; + method_call = "method"; + + boolean = "constant_builtin_boolean"; + number = "constant_numeric"; + float = "constant_numeric_float"; + + type_qualifier = "keyword_special"; + storageclass = "keyword_storage_modifier"; + conditional = "keyword_conditional"; + include = "keyword_control_import"; + }; + + configDir = + let + toScm = name: lib.concatStringsSep "." (lib.splitString "_" name); + + toml = formats.toml { }; + file = + toml.generate "config.toml" { + highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); + features = { + highlighting = true; + text_objects = true; + }; + language = grammars; + }; + in + runCommandLocal "kak-tree-sitter-config" { } '' + mkdir -p $out/kak-tree-sitter + ln -s ${file} $out/kak-tree-sitter/config.toml + ''; + + extraFaces = + let + toTs = name: "ts_${lib.concatStringsSep "_" (lib.splitString "." name)}"; + + definedFaces = lib.mapAttrs' (name: value: { inherit value; name = toTs name; }) highlighterGroups; + aliasFaces = lib.mapAttrs' (name: value: { name = toTs name; value = "@${toTs value}"; }) aliases; + faces = lib.recursiveUpdate definedFaces aliasFaces; + in + faces; +in +{ + rc = '' + # Enable kak-tree-sitter + eval %sh{env XDG_CONFIG_DIR=${configDir} ${lib.getExe' kak-tree-sitter "kak-tree-sitter"} --kakoune -d --server --init $kak_session} + map global normal ": enter-user-mode tree-sitter" + ''; + + plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces; +} + diff --git a/packages/common/nki-kakoune/tree-sitter/grammars.nix b/packages/common/nki-kakoune/tree-sitter/grammars.nix new file mode 100644 index 0000000..426edb3 --- /dev/null +++ b/packages/common/nki-kakoune/tree-sitter/grammars.nix @@ -0,0 +1,119 @@ +{ lib, stdenv, fetchFromGitHub, runCommandLocal, ... }: +let + mkGrammarPackage = + { name + , src + , grammarPath ? "src" + , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] + , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] + , ... + }: stdenv.mkDerivation { + inherit src; + name = "kak-tree-sitter-grammar-${name}"; + version = "latest"; + buildPhase = '' + mkdir ${grammarPath}/build + cd ${grammarPath}/build + $CC ${lib.concatStringsSep " " grammarCompileArgs} + $CC ${lib.concatStringsSep " " grammarLinkArgs} -o ${name}.so + ''; + installPhase = '' + mkdir $out + cp ${name}.so $out + ''; + }; + mkGrammar = + args @ { name + , src + , grammarPath ? "src" + , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] + , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] + , querySrc ? src + , queryPath ? "runtime/queries/${name}" + , + }: { + grammar.source.local.path = "${mkGrammarPackage args}"; + queries.source.local.path = querySrc; + queries.path = queryPath; + }; + + tree-sitter-go = fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-go"; + rev = "v0.20.0"; + hash = "sha256-G7d8CHCyKDAb9j6ijRfHk/HlgPqSI+uvkuRIRRvjkHI="; + }; +in +{ + grammars = builtins.mapAttrs (name: value: mkGrammar ({ inherit name; } // value)) { + scala = { + src = fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-scala"; + rev = "70afdd5632d57dd63a960972ab25945e353a52f6"; + hash = "sha256-bi0Lqo/Zs2Uaz1efuKAARpEDg5Hm59oUe7eSXgL1Wow="; + }; + queryPath = "queries/scala"; + }; + haskell = { + src = fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-haskell"; + rev = "ba0bfb0e5d8e9e31c160d287878c6f26add3ec08"; + hash = "sha256-ZSOF0CLOn82GwU3xgvFefmh/AD2j5zz8I0t5YPwfan0="; + }; + grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "../unicode.h" "-I" ".." ]; + queryPath = "queries"; + }; + yaml = { + src = fetchFromGitHub { + owner = "ikatyang"; + repo = "tree-sitter-yaml"; + rev = "0e36bed171768908f331ff7dff9d956bae016efb"; + hash = "sha256-bpiT3FraOZhJaoiFWAoVJX1O+plnIi8aXOW2LwyU23M="; + }; + grammarCompileArgs = [ "-c" "-fpic" "../scanner.cc" "../parser.c" "-I" ".." ]; + grammarLinkArgs = [ "-lstdc++" "-shared" "-fpic" "scanner.o" "parser.o" ]; + querySrc = fetchFromGitHub { + owner = "helix-editor"; + repo = "helix"; + rev = "dbd248fdfa680373d94fbc10094a160aafa0f7a7"; + hash = "sha256-wk8qVUDFXhAOi1Ibc6iBMzDCXb6t+YiWZcTd0IJybqc="; + }; + }; + templ = rec { + src = fetchFromGitHub { + owner = "vrischmann"; + repo = "tree-sitter-templ"; + rev = "044ad200092170727650fa6d368df66a8da98f9d"; + hash = "sha256-hJuB3h5pp+LLfP0/7bAYH0uLVo+OQk5jpzJb3J9BNkY="; + }; + querySrc = runCommandLocal "templ-tree-sitter-queries" { } '' + mkdir -p $out/queries + # copy most stuff from tree-sitter-templ + install -m644 ${src}/queries/templ/* $out/queries + # override inherited files + cat ${tree-sitter-go}/queries/highlights.scm ${src}/queries/templ/highlights.scm > $out/queries/highlights.scm + ''; + queryPath = "queries"; + }; + go = { + src = tree-sitter-go; + grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; + grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; + queryPath = "queries"; + }; + hylo = { + src = fetchFromGitHub { + owner = "natsukagami"; + repo = "tree-sitter-hylo"; + rev = "494cbdff0d13cbc67348316af2efa0286dbddf6f"; + hash = "sha256-R5UeoglCTl0do3VDJ/liCTeqbxU9slvmVKNRA/el2VY="; + }; + grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; + grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; + queryPath = "queries"; + }; + }; +} + diff --git a/packages/common/nki-kakoune/utils.nix b/packages/common/nki-kakoune/utils.nix index 47e7c75..4183aa6 100644 --- a/packages/common/nki-kakoune/utils.nix +++ b/packages/common/nki-kakoune/utils.nix @@ -1,5 +1,7 @@ -{ lib, writeFile, ... }: { - mkFacesScript = name: faces: writeFile "${name}-faces.kak" ( - lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") faces)) - ); +{ lib, writeTextDir, ... }: { + mkFacesScript = name: faces: writeTextDir "share/kak/autoload/${name}/faces.kak" '' + hook global KakBegin .* { + ${lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: " face global ${name} \"${face}\"") faces))} + } + ''; } From eb3d53b829efb2937d6f386f64f6d2359513b78b Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 21:11:48 +0200 Subject: [PATCH 46/53] Make tree-sitter kinda work --- home/common.nix | 2 +- overlay.nix | 2 +- .../default.nix} | 1 + .../common/kak-tree-sitter/user_config.patch | 129 ++++++++++++++++++ packages/common/nki-kakoune/default.nix | 4 +- packages/common/nki-kakoune/faces.nix | 31 +++++ packages/common/nki-kakoune/lsp.nix | 14 +- .../nki-kakoune/tree-sitter/default.nix | 28 ++-- .../nki-kakoune/tree-sitter/grammars.nix | 1 + packages/common/nki-kakoune/utils.nix | 2 +- 10 files changed, 187 insertions(+), 27 deletions(-) rename packages/common/{kak-tree-sitter.nix => kak-tree-sitter/default.nix} (98%) create mode 100644 packages/common/kak-tree-sitter/user_config.patch create mode 100644 packages/common/nki-kakoune/faces.nix diff --git a/home/common.nix b/home/common.nix index 3007565..ef73608 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,7 +2,7 @@ { imports = [ - ./kakoune/kak.nix + # ./kakoune/kak.nix ./fish/fish.nix ./modules/programs/my-broot.nix ./modules/programs/my-sway diff --git a/overlay.nix b/overlay.nix index e38f3a1..29a8c34 100644 --- a/overlay.nix +++ b/overlay.nix @@ -90,7 +90,7 @@ let }; overlay-packages = final: prev: { - kak-tree-sitter = final.callPackage ./packages/common/kak-tree-sitter.nix { rustPlatform = final.unstable.rustPlatform; }; + kak-tree-sitter = final.callPackage ./packages/common/kak-tree-sitter { rustPlatform = final.unstable.rustPlatform; }; kak-lsp = let diff --git a/packages/common/kak-tree-sitter.nix b/packages/common/kak-tree-sitter/default.nix similarity index 98% rename from packages/common/kak-tree-sitter.nix rename to packages/common/kak-tree-sitter/default.nix index 9819e3a..69da116 100644 --- a/packages/common/kak-tree-sitter.nix +++ b/packages/common/kak-tree-sitter/default.nix @@ -34,6 +34,7 @@ let self.runtime_dir.join("sources").join(url_dir) '') + ./user_config.patch ]; meta.mainProgram = "kak-tree-sitter"; diff --git a/packages/common/kak-tree-sitter/user_config.patch b/packages/common/kak-tree-sitter/user_config.patch new file mode 100644 index 0000000..b2b1b6a --- /dev/null +++ b/packages/common/kak-tree-sitter/user_config.patch @@ -0,0 +1,129 @@ +diff --git a/kak-tree-sitter-config/src/lib.rs b/kak-tree-sitter-config/src/lib.rs +index e4edc42..a9c92cb 100644 +--- a/kak-tree-sitter-config/src/lib.rs ++++ b/kak-tree-sitter-config/src/lib.rs +@@ -52,9 +52,13 @@ impl Config { + } + + /// Load the default configuration, the user configuration, and merge both. +- pub fn load_default_user() -> Result { ++ pub fn load_default_user(path: Option>) -> Result { + let mut config = Self::load_default_config()?; +- match UserConfig::load_from_xdg() { ++ let user_config = match path { ++ Some(p) => UserConfig::load(p), ++ None => UserConfig::load_from_xdg(), ++ }; ++ match user_config { + Ok(user_config) => { + config.merge_user_config(user_config)?; + } +@@ -448,7 +452,7 @@ impl UserConfig { + } + + /// Load the configuration from a given path. +- fn load(path: impl AsRef) -> Result { ++ pub fn load(path: impl AsRef) -> Result { + let path = path.as_ref(); + + log::debug!("loading configuration at {path}", path = path.display()); +diff --git a/kak-tree-sitter/src/cli.rs b/kak-tree-sitter/src/cli.rs +index b8102cd..923312c 100644 +--- a/kak-tree-sitter/src/cli.rs ++++ b/kak-tree-sitter/src/cli.rs +@@ -22,6 +22,10 @@ pub struct Cli { + #[clap(short, long)] + pub server: bool, + ++ /// Specify a custom path for the user config. ++ #[clap(short, long)] ++ pub user_config: Option, ++ + /// Try to daemonize, if not already done. + #[clap(short, long)] + pub daemonize: bool, +diff --git a/kak-tree-sitter/src/main.rs b/kak-tree-sitter/src/main.rs +index bee9698..cbd7b39 100644 +--- a/kak-tree-sitter/src/main.rs ++++ b/kak-tree-sitter/src/main.rs +@@ -43,7 +43,7 @@ fn start() -> Result<(), OhNo> { + } + } + +- let config = Config::load_default_user()?; ++ let config = Config::load_default_user(cli.user_config.as_ref())?; + + // inject rc if we start from Kakoune + if cli.kakoune && cli.init.is_some() { +diff --git a/kak-tree-sitter/src/server.rs b/kak-tree-sitter/src/server.rs +index f3b7723..000c81d 100644 +--- a/kak-tree-sitter/src/server.rs ++++ b/kak-tree-sitter/src/server.rs +@@ -73,6 +73,7 @@ impl Server { + log::debug!("creating IO handler"); + let io_handler = IOHandler::new( + config, ++ cli.user_config.clone(), + cli.is_standalone(), + cli.with_highlighting || config.features.highlighting, + resources, +@@ -165,6 +166,7 @@ struct IOHandler { + connections: HashMap, + enqueue_response: EnqueueResponse, + handler: Handler, ++ user_config_path: Option, + } + + impl IOHandler { +@@ -173,6 +175,7 @@ impl IOHandler { + + fn new( + config: &Config, ++ user_config_path: Option, + is_standalone: bool, + with_highlighting: bool, + resources: ServerResources, +@@ -203,6 +206,7 @@ impl IOHandler { + connections, + enqueue_response, + handler, ++ user_config_path, + }) + } + +@@ -450,7 +454,7 @@ impl IOHandler { + } + + fn reload(&mut self) { +- let config = match Config::load_default_user() { ++ let config = match Config::load_default_user(self.user_config_path.as_ref()) { + Ok(config) => config, + Err(err) => { + log::error!("reloading config failed: {err}"); +diff --git a/ktsctl/src/cli.rs b/ktsctl/src/cli.rs +index dfac5c3..09f86f3 100644 +--- a/ktsctl/src/cli.rs ++++ b/ktsctl/src/cli.rs +@@ -11,6 +11,9 @@ pub struct Cli { + #[clap(long)] + pub verbose: bool, + ++ #[clap(short, long)] ++ pub user_config: Option, ++ + #[clap(subcommand)] + pub cmd: Cmd, + } +diff --git a/ktsctl/src/main.rs b/ktsctl/src/main.rs +index f9a3499..f823633 100644 +--- a/ktsctl/src/main.rs ++++ b/ktsctl/src/main.rs +@@ -37,7 +37,7 @@ fn start() -> Result<(), HellNo> { + simple_logger::init_with_level(log::Level::Debug)?; + } + +- let config = Config::load_default_user()?; ++ let config = Config::load_default_user(cli.user_config.as_ref())?; + log::debug!("ktsctl configuration:\n{config:#?}"); + + match cli.cmd { diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 0d48b06..4cb34c7 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -11,6 +11,7 @@ in ++ callPackage ./themes.nix { } ++ [ (callPackage ./kaktex { }) + (callPackage ./faces.nix { }) rc tree-sitter.plugin lsp.plugin @@ -23,6 +24,7 @@ in rm "$out/bin/kak" makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ --set KAKOUNE_RUNTIME "$out/share/kak" \ - --suffix PATH ":" "${lsp.extraPaths}" + --suffix PATH ":" "${lsp.extraPaths}" \ + --suffix PATH ":" "${tree-sitter.extraPaths}" ''; }) diff --git a/packages/common/nki-kakoune/faces.nix b/packages/common/nki-kakoune/faces.nix new file mode 100644 index 0000000..367472c --- /dev/null +++ b/packages/common/nki-kakoune/faces.nix @@ -0,0 +1,31 @@ +{ callPackage, ... } : +let +utils = callPackage ./utils.nix { }; +faces = { + Default = "%opt{text},%opt{base}"; + BufferPadding = "%opt{base},%opt{base}"; + MenuForeground = "%opt{blue},white+bF"; + MenuBackground = "%opt{sky},white+F"; + Information = "%opt{sky},white"; + # Markdown help color scheme + InfoDefault = "Information"; + InfoBlock = "@block"; + InfoBlockQuote = "+i@block"; + InfoBullet = "@bullet"; + InfoHeader = "@header"; + InfoLink = "@link"; + InfoLinkMono = "+b@mono"; + InfoMono = "@mono"; + InfoRule = "+b@Information"; + InfoDiagnosticError = "@DiagnosticError"; + InfoDiagnosticHint = "@DiagnosticHint"; + InfoDiagnosticInformation = "@Information"; + InfoDiagnosticWarning = "@DiagnosticWarning"; + # Extra faces + macro = "+u@function"; + method = "@function"; + format_specifier = "+i@string"; + mutable_variable = "+i@variable"; + class = "+b@variable"; +}; +in utils.mkFacesScript "default-faces" faces diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix index 3712d6f..6511ee9 100644 --- a/packages/common/nki-kakoune/lsp.nix +++ b/packages/common/nki-kakoune/lsp.nix @@ -248,7 +248,7 @@ let kak-lsp-config = let toml = formats.toml { }; - toLspConfig = attrs: builtins.removeAttrs attrs [ "package" ]; + toLspConfig = builtins.mapAttrs (_: attrs: builtins.removeAttrs attrs [ "package" ]); in toml.generate "kak-lsp.toml" ({ semantic_tokens.faces = config.faces; @@ -265,16 +265,16 @@ in plugin = writeTextDir "share/kak/autoload/kak-lsp.kak" '' hook global KakBegin .* %{ try %{ - eval %sh{${lib.getExe kak-lsp} --config ${kak-lsp-config} -s $kak_session} + eval %sh{${lib.getExe kak-lsp} --kakoune --config ${kak-lsp-config} -s $kak_session} } lsp-enable - map window lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" - map window normal ": enter-user-mode lsp" - map window normal ": lsp-hover" - map window normal ": lsp-hover-buffer" + map global lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" + map global normal ": enter-user-mode lsp" + map global normal ": lsp-hover" + map global normal ": lsp-hover-buffer" # lsp-auto-hover-insert-mode-enable - set window lsp_hover_anchor true + set global lsp_hover_anchor true map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' map global object a 'lsp-object' -docstring 'LSP any symbol' map global object 'lsp-object' -docstring 'LSP any symbol' diff --git a/packages/common/nki-kakoune/tree-sitter/default.nix b/packages/common/nki-kakoune/tree-sitter/default.nix index ce16343..b94a771 100644 --- a/packages/common/nki-kakoune/tree-sitter/default.nix +++ b/packages/common/nki-kakoune/tree-sitter/default.nix @@ -129,25 +129,19 @@ let include = "keyword_control_import"; }; - configDir = + configFile = let toScm = name: lib.concatStringsSep "." (lib.splitString "_" name); - toml = formats.toml { }; - file = - toml.generate "config.toml" { - highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); - features = { - highlighting = true; - text_objects = true; - }; - language = grammars; - }; in - runCommandLocal "kak-tree-sitter-config" { } '' - mkdir -p $out/kak-tree-sitter - ln -s ${file} $out/kak-tree-sitter/config.toml - ''; + toml.generate "config.toml" { + highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); + features = { + highlighting = true; + text_objects = true; + }; + language = grammars; + }; extraFaces = let @@ -162,10 +156,12 @@ in { rc = '' # Enable kak-tree-sitter - eval %sh{env XDG_CONFIG_DIR=${configDir} ${lib.getExe' kak-tree-sitter "kak-tree-sitter"} --kakoune -d --server --init $kak_session} + eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session --user-config ${configFile}} map global normal ": enter-user-mode tree-sitter" ''; + extraPaths = "${kak-tree-sitter}/bin"; + plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces; } diff --git a/packages/common/nki-kakoune/tree-sitter/grammars.nix b/packages/common/nki-kakoune/tree-sitter/grammars.nix index 426edb3..d1f6417 100644 --- a/packages/common/nki-kakoune/tree-sitter/grammars.nix +++ b/packages/common/nki-kakoune/tree-sitter/grammars.nix @@ -33,6 +33,7 @@ let , }: { grammar.source.local.path = "${mkGrammarPackage args}"; + grammar.link_args = grammarLinkArgs ++ [ "-o" "${name}.so" ]; queries.source.local.path = querySrc; queries.path = queryPath; }; diff --git a/packages/common/nki-kakoune/utils.nix b/packages/common/nki-kakoune/utils.nix index 4183aa6..0307bc6 100644 --- a/packages/common/nki-kakoune/utils.nix +++ b/packages/common/nki-kakoune/utils.nix @@ -1,6 +1,6 @@ { lib, writeTextDir, ... }: { mkFacesScript = name: faces: writeTextDir "share/kak/autoload/${name}/faces.kak" '' - hook global KakBegin .* { + hook global KakBegin .* %{ ${lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: " face global ${name} \"${face}\"") faces))} } ''; From 8608362922eae578afd14d148cc5e1bf8d1f8422 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 22:25:59 +0200 Subject: [PATCH 47/53] Cleanup the home kakoune module, restore tree-sitter --- home/common.nix | 3 +- home/kakoune/kak.nix | 375 +----------------- home/modules/programs/my-kakoune/default.nix | 94 +---- home/modules/programs/my-kakoune/kak-lsp.nix | 213 ---------- .../programs/my-kakoune/tree-sitter.nix | 59 +-- packages/common/nki-kakoune/default.nix | 8 +- packages/common/nki-kakoune/kakrc | 1 + packages/common/nki-kakoune/lsp.nix | 2 +- 8 files changed, 59 insertions(+), 696 deletions(-) delete mode 100644 home/modules/programs/my-kakoune/kak-lsp.nix diff --git a/home/common.nix b/home/common.nix index ef73608..2034fce 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,7 +2,7 @@ { imports = [ - # ./kakoune/kak.nix + ./kakoune/kak.nix ./fish/fish.nix ./modules/programs/my-broot.nix ./modules/programs/my-sway @@ -42,7 +42,6 @@ unzip zstd atool - nki-kakoune ]; home.sessionVariables = { diff --git a/home/kakoune/kak.nix b/home/kakoune/kak.nix index aad934c..9a132ac 100644 --- a/home/kakoune/kak.nix +++ b/home/kakoune/kak.nix @@ -1,67 +1,9 @@ { pkgs, lib, ... }: - let - kak-lsp-frontend = { pkgs, lib, ... }: - let - langserver = name: { - name = "vscode-${name}-language-server"; - value = { - args = [ "--stdio" ]; - command = "vscode-${name}-language-server"; - filetypes = [ name ]; - roots = [ "package.json" ".git" ]; - }; - package = pkgs.nodePackages.vscode-langservers-extracted; - }; - - tailwind = { - command = "tailwindcss-language-server"; - args = [ "--stdio" ]; - filetypes = [ "html" "css" "javascript" "typescript" "templ" ]; - roots = [ "tailwind.config.{js,cjs,mjs,ts}" "package.json" ".git" ]; - settings_section = "tailwindCSS"; - settings.tailwindCSS = { - validate = "warning"; - userLanguages.templ = "html"; - }; - package = pkgs.tailwindcss-language-server; - }; - - templModule = { pkgs, lib, ... }: { - programs.kak-lsp.languageServers."vscode-html-language-server".filetypes = [ "templ" ]; - programs.kak-lsp.languageServers."tailwindcss-language-server".filetypes = [ "templ" ]; - programs.kak-lsp.languageServers.templ = { - command = "templ"; - args = [ "lsp" ]; - filetypes = [ "templ" ]; - roots = [ "go.mod" ".git" ]; - package = pkgs.unstable.templ; - }; - - }; - - in - { - imports = [ templModule ]; - - programs.kak-lsp.languageServers = (builtins.listToAttrs (map langserver [ "html" "css" "json" ])) // { - tailwindcss-language-server = tailwind; - }; - }; - - ltexLsp = { pkgs, lib, ... }: { - programs.kak-lsp.languageServers.ltex-ls = { - command = "ltex-ls"; - args = [ "--log-file=/tmp" ]; - filetypes = [ "latex" "typst" ]; - roots = [ "main.tex" "main.typ" ".git" ]; - package = pkgs.ltex-ls; - }; - }; in { - imports = [ ../modules/programs/my-kakoune ./kaktex.nix kak-lsp-frontend ltexLsp ]; + imports = [ ../modules/programs/my-kakoune ./kaktex.nix ]; home.packages = with pkgs; [ # ctags for peneira @@ -75,110 +17,6 @@ in # Enable the kakoune package. programs.my-kakoune.enable = true; programs.my-kakoune.enable-fish-session = true; - programs.kak-lsp.enable = true; - programs.kak-lsp.semanticTokens.additionalFaces = [ - # Typst - { face = "header"; token = "heading"; } - { face = "ts_markup_link_url"; token = "link"; } - { face = "ts_markup_link_uri"; token = "ref"; } - { face = "ts_markup_link_label"; token = "label"; } - { face = "ts_property"; token = "pol"; } - { face = "ts_markup_list_checked"; token = "marker"; } - { face = "ts_constant_builtin_boolean"; token = "bool"; } - { face = "ts_keyword_control"; token = "delim"; } - { face = "ts_number"; token = "text"; modifiers = [ "math" ]; } - { face = "ts_markup_bold"; token = "text"; modifiers = [ "strong" ]; } - { face = "ts_markup_italic"; token = "text"; modifiers = [ "emph" ]; } - ]; - - programs.kak-lsp.languageServers.elixir-ls = { - args = [ ]; - command = "elixir-ls"; - filetypes = [ "elixir" ]; - roots = [ "mix.exs" ]; - }; - programs.kak-lsp.languageServers.typescript-language-server = { - args = [ "--stdio" ]; - command = "typescript-language-server"; - filetypes = [ "typescript" "javascript" ]; - roots = [ "package.json" ]; - package = pkgs.nodePackages.typescript-language-server; - }; - programs.kak-lsp.languageServers.fsautocomplete = { - args = [ "--adaptive-lsp-server-enabled" "--project-graph-enabled" "--source-text-factory" "RoslynSourceText" ]; - command = "fsautocomplete"; - filetypes = [ "fsharp" ]; - roots = [ "*.fsproj" ]; - settings_section = "FSharp"; - settings.FSharp = { - AutomaticWorkspaceInit = true; - }; - }; - programs.kak-lsp.languageServers.metals = { - command = "metals"; - filetypes = [ "scala" ]; - roots = [ "build.sbt" "build.sc" "build.mill" ]; - settings_section = "metals"; - settings.metals = { - enableSemanticHighlighting = true; - showInferredType = true; - decorationProvider = true; - inlineDecorationProvider = true; - # From kakoune-lsp's own options - icons = "unicode"; - isHttpEnabled = true; - statusBarProvider = "log-message"; - compilerOptions = { overrideDefFormat = "unicode"; }; - }; - package = pkgs.metals; - }; - programs.kak-lsp.languageServers.texlab = { - command = "texlab"; - filetypes = [ "latex" ]; - roots = [ "main.tex" "all.tex" ".git" ]; - settings_section = "texlab"; - settings.texlab = { - build.executable = "latexmk"; - build.args = [ "-pdf" "-shell-escape" "-interaction=nonstopmode" "-synctex=1" "%f" ]; - - build.forwardSearchAfter = true; - build.onSave = true; - - forwardSearch = - (if pkgs.stdenv.isDarwin then { - executable = "/Applications/Skim.app/Contents/SharedSupport/displayline"; - args = [ "-r" "-g" "%l" "%p" "%f" ]; - } else - { - executable = "${pkgs.zathura}/bin/zathura"; - args = [ "--synctex-forward" "%l:1:%f" "%p" "-x" "${./kaktex} jump %%{input} %%{line} %%{column}" ]; - }); - }; - package = pkgs.texlab; - }; - programs.kak-lsp.languageServers.typst-lsp = { - command = "typst-lsp"; - filetypes = [ "typst" ]; - roots = [ "main.typ" ".git" ]; - settings_section = "typst-lsp"; - settings.typst-lsp = { - experimentalFormatterMode = "on"; - }; - }; - programs.kak-lsp.languageServers.marksman = { - command = "marksman"; - filetypes = [ "markdown" ]; - roots = [ ".marksman.toml" ".git" ]; - package = pkgs.marksman; - }; - programs.kak-lsp.languageServers.rust-analyzer = { - args = [ ]; - command = "rust-analyzer"; - filetypes = [ "rust" ]; - roots = [ "Cargo.toml" ]; - package = pkgs.rust-analyzer; - }; - programs.my-kakoune.tree-sitter.extraAliases = { # Scala stuff method = "function"; @@ -300,216 +138,5 @@ in queries.path = "queries"; }; }; - - programs.my-kakoune.package = pkgs.kakoune; - programs.my-kakoune.rc = - builtins.readFile ./kakrc + '' - - # Source any settings in the current working directory, - # recursive upwards - evaluate-commands %sh{ - ${pkgs.writeScript "source-pwd" (builtins.readFile ./source-pwd)} - } - ''; - - programs.my-kakoune.extraFaces = { - Default = "%opt{text},%opt{base}"; - BufferPadding = "%opt{base},%opt{base}"; - MenuForeground = "%opt{blue},white+bF"; - MenuBackground = "%opt{sky},white+F"; - Information = "%opt{sky},white"; - # Markdown help color scheme - InfoDefault = "Information"; - InfoBlock = "@block"; - InfoBlockQuote = "+i@block"; - InfoBullet = "@bullet"; - InfoHeader = "@header"; - InfoLink = "@link"; - InfoLinkMono = "+b@mono"; - InfoMono = "@mono"; - InfoRule = "+b@Information"; - InfoDiagnosticError = "@DiagnosticError"; - InfoDiagnosticHint = "@DiagnosticHint"; - InfoDiagnosticInformation = "@Information"; - InfoDiagnosticWarning = "@DiagnosticWarning"; - # Extra faces - macro = "+u@function"; - method = "@function"; - format_specifier = "+i@string"; - mutable_variable = "+i@variable"; - class = "+b@variable"; - }; - programs.my-kakoune.autoload = [ - # My own scripts - { - name = "latex.kak"; - src = ./autoload/latex.kak; - } - { - name = "markdown.kak"; - src = ./autoload/markdown.kak; - } - - # Plugins - { - name = "luar"; - src = pkgs.fetchFromGitHub { - owner = "gustavo-hms"; - repo = "luar"; - rev = "2f430316f8fc4d35db6c93165e2e77dc9f3d0450"; - sha256 = "sha256-vHn/V3sfzaxaxF8OpA5jPEuPstOVwOiQrogdSGtT6X4="; - }; - activationScript = '' - # Enable luar - require-module luar - # Use luajit - set-option global luar_interpreter ${pkgs.luajit}/bin/luajit - ''; - } - { - name = "peneira"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "peneira"; - rev = "743b9971472853a752475e7c070ce99089c6840c"; - sha256 = "sha256-E4ndbF9YC1p0KrvSuGgwmG1Y2IGTuGKJo/AuMixhzlM="; - }; - activationScript = '' - require-module peneira - - # Change selection color - set-face global PeneiraSelected @PrimarySelection - - # Buffers list - define-command -hidden peneira-buffers %{ - peneira 'buffers: ' %{ printf '%s\n' $kak_quoted_buflist } %{ - buffer %arg{1} - } - } - - # Grep in the current location - define-command peneira-grep %{ - peneira 'line: ' "rg -n ." %{ - lua %arg{1} %{ - local file, line = arg[1]:match("([^:]+):(%d+):") - kak.edit(file, line) - } - } - } - - # A peneira menu - declare-user-mode fuzzy-match-menu - - map -docstring "Switch to buffer" global fuzzy-match-menu b ": peneira-buffers" - map -docstring "Symbols" global fuzzy-match-menu s ": peneira-symbols" - map -docstring "Lines" global fuzzy-match-menu l ": peneira-lines" - map -docstring "Lines in the current directory" global fuzzy-match-menu g ": peneira-grep" - map -docstring "Files in project" global fuzzy-match-menu f ": peneira-files" - map -docstring "Files in currently opening file's directory" global fuzzy-match-menu F ": peneira-local-files" - - # Bind menu to user mode - map -docstring "Fuzzy matching" global user f ": enter-user-mode fuzzy-match-menu" - ''; - } - { - name = "kakoune-focus"; - src = pkgs.fetchFromGitHub { - owner = "caksoylar"; - repo = "kakoune-focus"; - rev = "949c0557cd4c476822acfa026ca3c50f3d38a3c0"; - sha256 = "sha256-ZV7jlLJQyL420YG++iC9rq1SMjo3WO5hR9KVvJNUiCs="; - }; - activationScript = '' - map global user ': focus-toggle' -docstring "toggle selections focus" - ''; - } - { - name = "kakoune-inc-dec"; - src = pkgs.fetchFromGitLab { - owner = "Screwtapello"; - repo = "kakoune-inc-dec"; - rev = "7bfe9c51"; - sha256 = "0f33wqxqbfygxypf348jf1fiscac161wf2xvnh8zwdd3rq5yybl0"; - }; - } - { - name = "racket.kak"; - src = (builtins.fetchTree { - type = "git"; - url = "https://bitbucket.org/KJ_Duncan/kakoune-racket.kak.git"; - rev = "e397042009b46916ff089d79166ec0e8ca813a18"; - narHash = "sha256-IcxFmvG0jqpMCG/dT9crVRgPgMGKkic6xwrnW5z4+bc="; - }) + "/rc"; - } - # { - # name = "kakoune-discord"; - # src = (builtins.getFlake "github:natsukagami/kakoune-discord/03f95e40d6efd8fd3de7bca31653d43de2dcfc5f").packages.${pkgs.system}.kakoune-discord-rc + "/rc"; - # } - rec { - name = "kakoune-mirror"; - src = pkgs.fetchFromGitHub - { - owner = "Delapouite"; - repo = "kakoune-mirror"; - rev = "5710635f440bcca914d55ff2ec1bfcba9efe0f15"; - sha256 = "sha256-uslx4zZhvjUylrPWvTOugsKYKKpF0EEz1drc1Ckrpjk="; - } + "/mirror.kak"; - wrapAsModule = true; - activationScript = '' - require-module ${name} - - # Bind to ${name} - map global normal ': enter-user-mode -lock mirror' - ''; - } - { - name = "unicode-math"; - src = pkgs.fetchFromGitHub { - owner = "natsukagami"; - repo = "kakoune-unicode-math"; - rev = "08dff25da2b86ee0b0777091992bc7fb28c3cb1d"; - # sha256 = lib.fakeSha256; - sha256 = "sha256-j0L1ARex1i2ma8sGLYwgkfAbh0jWKh/6QGHFaxPXIKc="; - fetchSubmodules = true; - }; - activationScript = '' - require-module unicode-math - - # Bind to the menu - map global insert ': insert-unicode ' - ''; - } - { - name = "kakoune-buffers"; - src = pkgs.fetchFromGitHub { - owner = "Delapouite"; - repo = "kakoune-buffers"; - rev = "6b2081f5b7d58c72de319a5cba7bf628b6802881"; - sha256 = "sha256-jOSrzGcLJjLK1GiTSsl2jLmQMPbPxjycR0pwF5t/eV0="; - }; - activationScript = '' - # Suggested hook - - hook global WinDisplay .* info-buffers - - # Suggested mappings - - map global user b ':enter-buffers-mode' -docstring 'buffers…' - map global normal ^ ':enter-buffers-mode' -docstring 'buffers…' - map global user B ':enter-user-mode -lock buffers' -docstring 'buffers (lock)…' - - # Suggested aliases - - alias global bd delete-buffer - alias global bf buffer-first - alias global bl buffer-last - alias global bo buffer-only - alias global bo! buffer-only-force - ''; - } - ]; - programs.my-kakoune.themes = { - catppuccin-latte = ./catppuccin-latte.kak; - }; } diff --git a/home/modules/programs/my-kakoune/default.nix b/home/modules/programs/my-kakoune/default.nix index 125484a..62a9cb1 100644 --- a/home/modules/programs/my-kakoune/default.nix +++ b/home/modules/programs/my-kakoune/default.nix @@ -1,40 +1,17 @@ -{ config, pkgs, lib, ... }: +{ config, options, pkgs, lib, ... }: with lib; let cfg = config.programs.my-kakoune; - - autoloadModule = types.submodule { - options = { - name = mkOption { - type = types.str; - description = "Name of the autoload script/folder. It might affect kakoune's load order."; - }; - src = mkOption { - type = types.path; - description = "Path to the autoload script/folder."; - }; - wrapAsModule = mkOption { - type = types.bool; - default = false; - description = "Wrap the given source file in a `provide-module` command. Fails if the `src` is not a single file."; - }; - activationScript = mkOption { - type = types.nullOr types.lines; - default = null; - description = "Add an activation script to the module. It will be wrapped in a `hook global KakBegin .*` wrapper."; - }; - }; - }; in { - imports = [ ./kak-lsp.nix ./fish-session.nix ./tree-sitter.nix ]; + imports = [ ./fish-session.nix ./tree-sitter.nix ]; options.programs.my-kakoune = { enable = mkEnableOption "My version of the kakoune configuration"; package = mkOption { type = types.package; - default = pkgs.kakoune; + default = pkgs.nki-kakoune; description = "The kakoune package to be installed"; }; rc = mkOption { @@ -42,22 +19,16 @@ in default = ""; description = "Content of the kakrc file. A line-concatenated string"; }; - autoload = mkOption { - type = types.listOf autoloadModule; - default = [ ]; - description = "Sources to autoload"; - }; - themes = mkOption { - type = types.attrsOf types.path; - default = { }; - description = "Themes to load"; - }; - extraFaces = mkOption { type = types.attrsOf types.str; default = { }; description = "Extra faces to include"; }; + autoloadFile = mkOption { + type = options.xdg.configFile.type; + default = { }; + description = "Extra autoload files"; + }; }; config = mkIf cfg.enable { @@ -65,37 +36,6 @@ in xdg.configFile = let - kakouneAutoload = { name, src, wrapAsModule ? false, activationScript ? null }: - [ - (if !wrapAsModule then { - name = "kak/autoload/${name}"; - value.source = src; - } else { - name = "kak/autoload/${name}/module.kak"; - value.text = '' - provide-module ${name} %◍ - ${readFile src} - ◍ - ''; - }) - ] ++ (if activationScript == null then [ ] else [{ - name = "kak/autoload/on-load/${name}.kak"; - value.text = '' - hook global KakBegin .* %{ - ${activationScript} - } - ''; - }]); - - kakouneThemes = builtins.listToAttrs (builtins.attrValues ( - builtins.mapAttrs - (name: src: { - name = "kak/colors/${name}.kak"; - value.source = src; - }) - cfg.themes - )); - kakouneFaces = let txt = strings.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") cfg.extraFaces)); @@ -103,6 +43,7 @@ in pkgs.writeText "faces.kak" txt; in { + "kak/autoload/builtin".source = "${cfg.package}/share/kak/autoload"; # kakrc "kak/kakrc".text = '' ${cfg.rc} @@ -110,15 +51,14 @@ in # Load faces source ${kakouneFaces} ''; - } // - (builtins.listToAttrs (lib.lists.flatten (map kakouneAutoload ([ - # include the original autoload files - { - name = "rc"; - src = "${cfg.package}/share/kak/autoload/rc"; - } - ] ++ cfg.autoload)))) - // kakouneThemes; + } // lib.mapAttrs' + (name: attrs: { + name = "kak/autoload/${name}"; + value = attrs // { + target = "kak/autoload/${name}"; + }; + }) + cfg.autoloadFile; }; } diff --git a/home/modules/programs/my-kakoune/kak-lsp.nix b/home/modules/programs/my-kakoune/kak-lsp.nix deleted file mode 100644 index eaf3b6b..0000000 --- a/home/modules/programs/my-kakoune/kak-lsp.nix +++ /dev/null @@ -1,213 +0,0 @@ -{ config, pkgs, lib, ... }: - -with lib; -let - lspConfig = - { - language_ids = { - c = "c_cpp"; - cpp = "c_cpp"; - javascript = "javascriptreact"; - typescript = "typescriptreact"; - protobuf = "proto"; - sh = "shellscript"; - }; - - language_servers = { - ccls = { - args = [ "-v=2" "-log-file=/tmp/ccls.log" ]; - command = "ccls"; - filetypes = [ "c" "cpp" ]; - roots = [ "compile_commands.json" ".cquery" ".git" ]; - }; - gopls = { - command = "gopls"; - filetypes = [ "go" ]; - offset_encoding = "utf-8"; - roots = [ "Gopkg.toml" "go.mod" ".git" ".hg" ]; - settings = { gopls = { hoverKind = "SynopsisDocumentation"; semanticTokens = true; }; }; - settings_section = "gopls"; - }; - haskell-language-server = { - args = [ "--lsp" ]; - command = "haskell-language-server-wrapper"; - filetypes = [ "haskell" ]; - roots = [ "Setup.hs" "stack.yaml" "*.cabal" "package.yaml" ]; - settings_section = "haskell"; - }; - nil = { - command = "${pkgs.nil}/bin/nil"; - filetypes = [ "nix" ]; - roots = [ "flake.nix" "shell.nix" ".git" ]; - settings.nil = { - formatting.command = [ "${getExe pkgs.nixpkgs-fmt}" ]; - }; - }; - pyls = { - command = "pyls"; - filetypes = [ "python" ]; - offset_encoding = "utf-8"; - roots = [ "requirements.txt" "setup.py" ".git" ".hg" ]; - }; - }; - semantic_tokens.faces = [ - ## Items - # (Rust) Macros - { face = "attribute"; token = "attribute"; } - { face = "attribute"; token = "derive"; } - { face = "macro"; token = "macro"; } # Function-like Macro - # Keyword and Fixed Tokens - { face = "keyword"; token = "keyword"; } - { face = "operator"; token = "operator"; } - # Functions and Methods - { face = "function"; token = "function"; } - { face = "method"; token = "method"; } - # Constants - { face = "string"; token = "string"; } - { face = "format_specifier"; token = "formatSpecifier"; } - # Variables - { face = "variable"; token = "variable"; modifiers = [ "readonly" ]; } - { face = "mutable_variable"; token = "variable"; } - { face = "module"; token = "namespace"; } - { face = "variable"; token = "type_parameter"; } - { face = "class"; token = "enum"; } - { face = "class"; token = "struct"; } - { face = "class"; token = "trait"; } - { face = "class"; token = "union"; } - { face = "class"; token = "class"; } - - ## Comments - { face = "documentation"; token = "comment"; modifiers = [ "documentation" ]; } - { face = "comment"; token = "comment"; } - ]; - server = { timeout = 1800; }; - snippet_support = false; - verbosity = 255; - }; - - languageServerOption = types.submodule { - options = { - filetypes = mkOption { - type = types.listOf types.str; - description = "The list of filetypes to assign the language to"; - }; - roots = mkOption { - type = types.listOf types.str; - description = "The list of root filenames that are used to determine the project root"; - }; - command = mkOption { - type = types.str; - description = "The LSP server command to be called."; - }; - args = mkOption { - type = types.listOf types.str; - default = [ ]; - description = "The arguments passed onto the LSP server."; - }; - offset_encoding = mkOption { - type = types.nullOr (types.enum [ "utf-8" ]); - default = null; - description = "The offset encoding used by the LSP server."; - }; - settings_section = mkOption { - type = types.nullOr types.str; - default = null; - description = "The settings section to be sent to LSP server."; - }; - settings = mkOption { - type = types.nullOr (types.attrsOf types.anything); - default = null; - description = "Additional settings to be passed to the LSP server."; - }; - package = mkOption { - type = types.nullOr types.package; - default = null; - description = "The default package of the language server. Will be appended as the ending segments of the PATH to kak-lsp"; - }; - }; - }; - - cfg = config.programs.kak-lsp; - - serverPackages = - filter (v: v != null) - (lib.mapAttrsToList (_: serv: serv.package) cfg.languageServers); - - wrappedPackage = pkgs.symlinkJoin { - name = "kak-lsp-wrapped"; - nativeBuildInputs = [ pkgs.makeWrapper ]; - paths = [ cfg.package ]; - postBuild = '' - wrapProgram $out/bin/kak-lsp --suffix PATH ":" ${lib.makeBinPath serverPackages} - ''; - }; -in -{ - options.programs.kak-lsp = { - enable = mkEnableOption "Enable kak-lsp support"; - - package = mkOption { - type = types.package; - default = pkgs.kak-lsp; - }; - - enableSnippets = mkOption { - type = types.bool; - default = false; - description = "Enable snippet support"; - }; - - semanticTokens.faces = mkOption { - type = types.listOf types.anything; - default = lspConfig.semantic_tokens.faces; - description = "The semantic tokens faces mapping given to kak"; - }; - semanticTokens.additionalFaces = mkOption { - type = types.listOf types.anything; - default = [ ]; - description = "The semantic tokens faces mapping given to kak"; - }; - - serverTimeout = mkOption { - type = types.int; - default = 1000; - description = "Server timeout"; - }; - - languageServers = mkOption { - type = types.attrsOf languageServerOption; - default = { }; - description = "The language options"; - }; - - languageIds = mkOption { - type = types.attrsOf types.str; - default = { }; - description = "Language IDs to be sent to the LSP"; - }; - }; - - config = mkIf cfg.enable - { - home.packages = [ wrappedPackage ]; - - # Configurations - xdg.configFile."kak-lsp/kak-lsp.toml" = - let - toml = pkgs.formats.toml { }; - toLspConfig = lib.filterAttrsRecursive (n: v: n != "package" && v != null); - in - { - source = toml.generate "config.toml" - { - semantic_tokens.faces = cfg.semanticTokens.faces ++ cfg.semanticTokens.additionalFaces; - server.timeout = cfg.serverTimeout; - snippet_support = cfg.enableSnippets; - verbosity = 255; - language_server = toLspConfig (lspConfig.language_servers // cfg.languageServers); - language_ids = lspConfig.language_ids // cfg.languageIds; - }; - }; - }; -} - diff --git a/home/modules/programs/my-kakoune/tree-sitter.nix b/home/modules/programs/my-kakoune/tree-sitter.nix index 4304ca5..07f12cf 100644 --- a/home/modules/programs/my-kakoune/tree-sitter.nix +++ b/home/modules/programs/my-kakoune/tree-sitter.nix @@ -33,6 +33,27 @@ let }; }; }; + mkGrammarPackage = + { name + , src + , grammarPath ? "src" + , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] + , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] + }: pkgs.stdenv.mkDerivation { + inherit src; + name = "kak-tree-sitter-grammar-${name}.so"; + version = "latest"; + buildPhase = '' + mkdir ${grammarPath}/build + cd ${grammarPath}/build + $CC ${lib.concatStringsSep " " grammarCompileArgs} + $CC ${lib.concatStringsSep " " grammarLinkArgs} -o ${name}.so + ''; + installPhase = '' + cp ${name}.so $out + ''; + }; + in { options.programs.my-kakoune.tree-sitter = { @@ -200,24 +221,15 @@ in toml = pkgs.formats.toml { }; - srcName = src: lib.removePrefix "/nix/store/" src.outPath; - mkGitRepo = src: pkgs.runCommandLocal "${src.name}-git" { } '' - cp -r --no-preserve=all ${src} $out - cd $out - if ! test -d $out/.git; then - ${lib.getExe pkgs.git} init -b ${srcName src} - ${lib.getExe pkgs.git} config user.email "a@b.com" - ${lib.getExe pkgs.git} config user.name "a" - ${lib.getExe pkgs.git} add . - ${lib.getExe pkgs.git} commit -m "Just making a git commit" - fi - ''; - toLanguageConf = name: lang: with lang; { grammar = { - inherit (grammar) path; - source.git.url = "${mkGitRepo grammar.src}"; - source.git.pin = "${srcName grammar.src}"; + source.local.path = mkGrammarPackage { + inherit name; + src = grammar.src; + grammarPath = grammar.path; + grammarCompileArgs = grammar.compile.flags ++ grammar.compile.args; + grammarLinkArgs = grammar.link.flags ++ grammar.link.args; + }; compile = grammar.compile.command; compile_args = grammar.compile.args; compile_flags = grammar.compile.flags; @@ -225,10 +237,9 @@ in link_args = grammar.link.args ++ [ "-o" "${name}.so" ]; link_flags = grammar.link.flags; }; - queries = { - source.git.url = "${mkGitRepo queries.src}"; - source.git.pin = "${srcName queries.src}"; + queries = rec { path = if queries.path == null then "runtime/queries/${name}" else queries.path; + source.local.path = "${queries.src}/${path}"; }; }; in @@ -249,14 +260,14 @@ in features = cfg.features; language = builtins.mapAttrs toLanguageConf cfg.languages; }; - - onChange = '' - export PATH=$PATH:${lib.getBin pkgs.gcc} - ${cfg.package}/bin/ktsctl sync -a - ''; }; programs.my-kakoune.extraFaces = faces; + programs.my-kakoune.autoloadFile."kak-tree-sitter.kak".text = '' + # Enable kak-tree-sitter + eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session} + map global normal ": enter-user-mode tree-sitter" + ''; }; } diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index 4cb34c7..c7d4324 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,9 +1,8 @@ { callPackage, kakoune, kakoune-unwrapped, ... }: let lsp = callPackage ./lsp.nix { }; - tree-sitter = callPackage ./tree-sitter { }; rc = (callPackage ./rc.nix { - prependRc = tree-sitter.rc; + # prependRc = tree-sitter.rc; }); in (kakoune.override { @@ -13,7 +12,7 @@ in (callPackage ./kaktex { }) (callPackage ./faces.nix { }) rc - tree-sitter.plugin + # tree-sitter.plugin lsp.plugin ]; }).overrideAttrs (attrs: { @@ -24,7 +23,6 @@ in rm "$out/bin/kak" makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \ --set KAKOUNE_RUNTIME "$out/share/kak" \ - --suffix PATH ":" "${lsp.extraPaths}" \ - --suffix PATH ":" "${tree-sitter.extraPaths}" + --suffix PATH ":" "${lsp.extraPaths}" ''; }) diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc index dc06ca3..0bc3dc0 100644 --- a/packages/common/nki-kakoune/kakrc +++ b/packages/common/nki-kakoune/kakrc @@ -5,6 +5,7 @@ # set global kts_sky "rgb:6aa622" # Color scheme colorscheme catppuccin-latte +set-face global module "%opt{sapphire}" set global base "default" # Set indentation guides diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix index 6511ee9..47e8259 100644 --- a/packages/common/nki-kakoune/lsp.nix +++ b/packages/common/nki-kakoune/lsp.nix @@ -130,7 +130,7 @@ let metals = { command = "metals"; filetypes = [ "scala" ]; - roots = [ "build.sbt" "build.sc" ]; + roots = [ "build.sbt" "build.sc" "build.mill" ]; settings_section = "metals"; settings.metals = { enableSemanticHighlighting = true; From 0f0c1649a290f49b3f89057e3cde19a118759719 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 22:26:49 +0200 Subject: [PATCH 48/53] Revert tree-sitter --- packages/common/kak-tree-sitter/default.nix | 1 - .../common/kak-tree-sitter/user_config.patch | 129 -------------- packages/common/nki-kakoune/default.nix | 5 +- .../nki-kakoune/tree-sitter/default.nix | 167 ------------------ .../nki-kakoune/tree-sitter/grammars.nix | 120 ------------- 5 files changed, 1 insertion(+), 421 deletions(-) delete mode 100644 packages/common/kak-tree-sitter/user_config.patch delete mode 100644 packages/common/nki-kakoune/tree-sitter/default.nix delete mode 100644 packages/common/nki-kakoune/tree-sitter/grammars.nix diff --git a/packages/common/kak-tree-sitter/default.nix b/packages/common/kak-tree-sitter/default.nix index 69da116..9819e3a 100644 --- a/packages/common/kak-tree-sitter/default.nix +++ b/packages/common/kak-tree-sitter/default.nix @@ -34,7 +34,6 @@ let self.runtime_dir.join("sources").join(url_dir) '') - ./user_config.patch ]; meta.mainProgram = "kak-tree-sitter"; diff --git a/packages/common/kak-tree-sitter/user_config.patch b/packages/common/kak-tree-sitter/user_config.patch deleted file mode 100644 index b2b1b6a..0000000 --- a/packages/common/kak-tree-sitter/user_config.patch +++ /dev/null @@ -1,129 +0,0 @@ -diff --git a/kak-tree-sitter-config/src/lib.rs b/kak-tree-sitter-config/src/lib.rs -index e4edc42..a9c92cb 100644 ---- a/kak-tree-sitter-config/src/lib.rs -+++ b/kak-tree-sitter-config/src/lib.rs -@@ -52,9 +52,13 @@ impl Config { - } - - /// Load the default configuration, the user configuration, and merge both. -- pub fn load_default_user() -> Result { -+ pub fn load_default_user(path: Option>) -> Result { - let mut config = Self::load_default_config()?; -- match UserConfig::load_from_xdg() { -+ let user_config = match path { -+ Some(p) => UserConfig::load(p), -+ None => UserConfig::load_from_xdg(), -+ }; -+ match user_config { - Ok(user_config) => { - config.merge_user_config(user_config)?; - } -@@ -448,7 +452,7 @@ impl UserConfig { - } - - /// Load the configuration from a given path. -- fn load(path: impl AsRef) -> Result { -+ pub fn load(path: impl AsRef) -> Result { - let path = path.as_ref(); - - log::debug!("loading configuration at {path}", path = path.display()); -diff --git a/kak-tree-sitter/src/cli.rs b/kak-tree-sitter/src/cli.rs -index b8102cd..923312c 100644 ---- a/kak-tree-sitter/src/cli.rs -+++ b/kak-tree-sitter/src/cli.rs -@@ -22,6 +22,10 @@ pub struct Cli { - #[clap(short, long)] - pub server: bool, - -+ /// Specify a custom path for the user config. -+ #[clap(short, long)] -+ pub user_config: Option, -+ - /// Try to daemonize, if not already done. - #[clap(short, long)] - pub daemonize: bool, -diff --git a/kak-tree-sitter/src/main.rs b/kak-tree-sitter/src/main.rs -index bee9698..cbd7b39 100644 ---- a/kak-tree-sitter/src/main.rs -+++ b/kak-tree-sitter/src/main.rs -@@ -43,7 +43,7 @@ fn start() -> Result<(), OhNo> { - } - } - -- let config = Config::load_default_user()?; -+ let config = Config::load_default_user(cli.user_config.as_ref())?; - - // inject rc if we start from Kakoune - if cli.kakoune && cli.init.is_some() { -diff --git a/kak-tree-sitter/src/server.rs b/kak-tree-sitter/src/server.rs -index f3b7723..000c81d 100644 ---- a/kak-tree-sitter/src/server.rs -+++ b/kak-tree-sitter/src/server.rs -@@ -73,6 +73,7 @@ impl Server { - log::debug!("creating IO handler"); - let io_handler = IOHandler::new( - config, -+ cli.user_config.clone(), - cli.is_standalone(), - cli.with_highlighting || config.features.highlighting, - resources, -@@ -165,6 +166,7 @@ struct IOHandler { - connections: HashMap, - enqueue_response: EnqueueResponse, - handler: Handler, -+ user_config_path: Option, - } - - impl IOHandler { -@@ -173,6 +175,7 @@ impl IOHandler { - - fn new( - config: &Config, -+ user_config_path: Option, - is_standalone: bool, - with_highlighting: bool, - resources: ServerResources, -@@ -203,6 +206,7 @@ impl IOHandler { - connections, - enqueue_response, - handler, -+ user_config_path, - }) - } - -@@ -450,7 +454,7 @@ impl IOHandler { - } - - fn reload(&mut self) { -- let config = match Config::load_default_user() { -+ let config = match Config::load_default_user(self.user_config_path.as_ref()) { - Ok(config) => config, - Err(err) => { - log::error!("reloading config failed: {err}"); -diff --git a/ktsctl/src/cli.rs b/ktsctl/src/cli.rs -index dfac5c3..09f86f3 100644 ---- a/ktsctl/src/cli.rs -+++ b/ktsctl/src/cli.rs -@@ -11,6 +11,9 @@ pub struct Cli { - #[clap(long)] - pub verbose: bool, - -+ #[clap(short, long)] -+ pub user_config: Option, -+ - #[clap(subcommand)] - pub cmd: Cmd, - } -diff --git a/ktsctl/src/main.rs b/ktsctl/src/main.rs -index f9a3499..f823633 100644 ---- a/ktsctl/src/main.rs -+++ b/ktsctl/src/main.rs -@@ -37,7 +37,7 @@ fn start() -> Result<(), HellNo> { - simple_logger::init_with_level(log::Level::Debug)?; - } - -- let config = Config::load_default_user()?; -+ let config = Config::load_default_user(cli.user_config.as_ref())?; - log::debug!("ktsctl configuration:\n{config:#?}"); - - match cli.cmd { diff --git a/packages/common/nki-kakoune/default.nix b/packages/common/nki-kakoune/default.nix index c7d4324..f4851af 100644 --- a/packages/common/nki-kakoune/default.nix +++ b/packages/common/nki-kakoune/default.nix @@ -1,9 +1,7 @@ { callPackage, kakoune, kakoune-unwrapped, ... }: let lsp = callPackage ./lsp.nix { }; - rc = (callPackage ./rc.nix { - # prependRc = tree-sitter.rc; - }); + rc = (callPackage ./rc.nix { }); in (kakoune.override { plugins = callPackage ./plugins.nix { } @@ -12,7 +10,6 @@ in (callPackage ./kaktex { }) (callPackage ./faces.nix { }) rc - # tree-sitter.plugin lsp.plugin ]; }).overrideAttrs (attrs: { diff --git a/packages/common/nki-kakoune/tree-sitter/default.nix b/packages/common/nki-kakoune/tree-sitter/default.nix deleted file mode 100644 index b94a771..0000000 --- a/packages/common/nki-kakoune/tree-sitter/default.nix +++ /dev/null @@ -1,167 +0,0 @@ -{ lib -, callPackage -, formats -, runCommandLocal -, kak-tree-sitter -, ... -}: -let - utils = callPackage ../utils.nix { }; - grammars = (callPackage ./grammars.nix { }).grammars; - # Highlighter groups to add to the `highlighterGroups`. Maps from group names to face names. - highlighterGroups = { - attribute = "@attribute"; - comment = "@comment"; - conceal = "%opt{mauve}+i"; - constant = "%opt{peach}"; - constant_builtin_boolean = "%opt{sky}"; - constant_character = "%opt{yellow}"; - constant_macro = "%opt{mauve}"; - constant_numeric = "%opt{peach}"; - constructor = "%opt{sapphire}"; - diff_plus = "%opt{green}"; - diff_minus = "%opt{red}"; - diff_delta = "%opt{blue}"; - diff_delta_moved = "%opt{mauve}"; - error = "%opt{red}+b"; - function = "@function"; - function_builtin = "@builtin"; - function_macro = "+i@ts_function"; - hint = "%opt{blue}+b"; - info = "%opt{green}+b"; - keyword = "keyword"; - keyword_conditional = "+i@ts_keyword"; - keyword_control_conditional = "+i@ts_keyword"; - keyword_control_directive = "+i@ts_keyword"; - keyword_control_import = "+i@ts_keyword"; - keyword_directive = "+i@ts_keyword"; - label = "%opt{sapphire}+i"; - markup_bold = "%opt{peach}+b"; - markup_heading = "%opt{red}"; - markup_heading_1 = "%opt{red}"; - markup_heading_2 = "%opt{mauve}"; - markup_heading_3 = "%opt{green}"; - markup_heading_4 = "%opt{yellow}"; - markup_heading_5 = "%opt{pink}"; - markup_heading_6 = "%opt{teal}"; - markup_heading_marker = "%opt{peach}+b"; - markup_italic = "%opt{pink}+i"; - markup_list_checked = "%opt{green}"; - markup_list_numbered = "%opt{blue}+i"; - markup_list_unchecked = "%opt{teal}"; - markup_list_unnumbered = "%opt{mauve}"; - markup_link_label = "%opt{blue}"; - markup_link_url = "%opt{teal}+u"; - markup_link_uri = "%opt{teal}+u"; - markup_link_text = "%opt{blue}"; - markup_quote = "%opt{crust}"; - markup_raw = "%opt{sky}"; - markup_raw_block = "%opt{sky}"; - markup_raw_inline = "%opt{green}"; - markup_strikethrough = "%opt{crust}+s"; - namespace = "@module"; - operator = "@operator"; - property = "%opt{sky}"; - punctuation = "%opt{overlay2}"; - punctuation_special = "%opt{sky}"; - special = "%opt{blue}"; - spell = "%opt{mauve}"; - string = "%opt{green}"; - string_regex = "%opt{peach}"; - string_regexp = "%opt{peach}"; - string_escape = "%opt{mauve}"; - string_special = "%opt{blue}"; - string_special_path = "%opt{green}"; - string_special_symbol = "%opt{mauve}"; - string_symbol = "%opt{red}"; - tag = "%opt{teal}"; - tag_error = "%opt{red}"; - text_title = "%opt{mauve}"; - type = "@type"; - type_enum_variant = "+i@ts_type"; - variable = "@variable"; - variable_builtin = "@builtin"; - variable_other_member = "%opt{teal}"; - variable_parameter = "+i@variable"; - warning = "%opt{peach}+b"; - }; - - # Highlighter groups to be aliased by other groups - aliases = { - comment_block = "comment"; - comment_line = "comment"; - constant_character_escape = "constant_character"; - constant_numeric_float = "constant_numeric"; - constant_numeric_integer = "constant_numeric"; - function_method = "function"; - function_special = "function"; - keyword_control = "keyword"; - keyword_control_repeat = "keyword"; - keyword_control_return = "keyword"; - keyword_control_except = "keyword"; - keyword_control_exception = "keyword"; - keyword_function = "keyword"; - keyword_operator = "keyword"; - keyword_special = "keyword"; - keyword_storage = "keyword"; - keyword_storage_modifier = "keyword"; - keyword_storage_modifier_mut = "keyword"; - keyword_storage_modifier_ref = "keyword"; - keyword_storage_type = "keyword"; - punctuation_bracket = "punctuation"; - punctuation_delimiter = "punctuation"; - text = "string"; - type_builtin = "type"; - - # Scala stuff - method = "function"; - module = "namespace"; - function_call = "function"; - method_call = "method"; - - boolean = "constant_builtin_boolean"; - number = "constant_numeric"; - float = "constant_numeric_float"; - - type_qualifier = "keyword_special"; - storageclass = "keyword_storage_modifier"; - conditional = "keyword_conditional"; - include = "keyword_control_import"; - }; - - configFile = - let - toScm = name: lib.concatStringsSep "." (lib.splitString "_" name); - toml = formats.toml { }; - in - toml.generate "config.toml" { - highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases); - features = { - highlighting = true; - text_objects = true; - }; - language = grammars; - }; - - extraFaces = - let - toTs = name: "ts_${lib.concatStringsSep "_" (lib.splitString "." name)}"; - - definedFaces = lib.mapAttrs' (name: value: { inherit value; name = toTs name; }) highlighterGroups; - aliasFaces = lib.mapAttrs' (name: value: { name = toTs name; value = "@${toTs value}"; }) aliases; - faces = lib.recursiveUpdate definedFaces aliasFaces; - in - faces; -in -{ - rc = '' - # Enable kak-tree-sitter - eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session --user-config ${configFile}} - map global normal ": enter-user-mode tree-sitter" - ''; - - extraPaths = "${kak-tree-sitter}/bin"; - - plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces; -} - diff --git a/packages/common/nki-kakoune/tree-sitter/grammars.nix b/packages/common/nki-kakoune/tree-sitter/grammars.nix deleted file mode 100644 index d1f6417..0000000 --- a/packages/common/nki-kakoune/tree-sitter/grammars.nix +++ /dev/null @@ -1,120 +0,0 @@ -{ lib, stdenv, fetchFromGitHub, runCommandLocal, ... }: -let - mkGrammarPackage = - { name - , src - , grammarPath ? "src" - , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] - , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] - , ... - }: stdenv.mkDerivation { - inherit src; - name = "kak-tree-sitter-grammar-${name}"; - version = "latest"; - buildPhase = '' - mkdir ${grammarPath}/build - cd ${grammarPath}/build - $CC ${lib.concatStringsSep " " grammarCompileArgs} - $CC ${lib.concatStringsSep " " grammarLinkArgs} -o ${name}.so - ''; - installPhase = '' - mkdir $out - cp ${name}.so $out - ''; - }; - mkGrammar = - args @ { name - , src - , grammarPath ? "src" - , grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] - , grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] - , querySrc ? src - , queryPath ? "runtime/queries/${name}" - , - }: { - grammar.source.local.path = "${mkGrammarPackage args}"; - grammar.link_args = grammarLinkArgs ++ [ "-o" "${name}.so" ]; - queries.source.local.path = querySrc; - queries.path = queryPath; - }; - - tree-sitter-go = fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-go"; - rev = "v0.20.0"; - hash = "sha256-G7d8CHCyKDAb9j6ijRfHk/HlgPqSI+uvkuRIRRvjkHI="; - }; -in -{ - grammars = builtins.mapAttrs (name: value: mkGrammar ({ inherit name; } // value)) { - scala = { - src = fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-scala"; - rev = "70afdd5632d57dd63a960972ab25945e353a52f6"; - hash = "sha256-bi0Lqo/Zs2Uaz1efuKAARpEDg5Hm59oUe7eSXgL1Wow="; - }; - queryPath = "queries/scala"; - }; - haskell = { - src = fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-haskell"; - rev = "ba0bfb0e5d8e9e31c160d287878c6f26add3ec08"; - hash = "sha256-ZSOF0CLOn82GwU3xgvFefmh/AD2j5zz8I0t5YPwfan0="; - }; - grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "../unicode.h" "-I" ".." ]; - queryPath = "queries"; - }; - yaml = { - src = fetchFromGitHub { - owner = "ikatyang"; - repo = "tree-sitter-yaml"; - rev = "0e36bed171768908f331ff7dff9d956bae016efb"; - hash = "sha256-bpiT3FraOZhJaoiFWAoVJX1O+plnIi8aXOW2LwyU23M="; - }; - grammarCompileArgs = [ "-c" "-fpic" "../scanner.cc" "../parser.c" "-I" ".." ]; - grammarLinkArgs = [ "-lstdc++" "-shared" "-fpic" "scanner.o" "parser.o" ]; - querySrc = fetchFromGitHub { - owner = "helix-editor"; - repo = "helix"; - rev = "dbd248fdfa680373d94fbc10094a160aafa0f7a7"; - hash = "sha256-wk8qVUDFXhAOi1Ibc6iBMzDCXb6t+YiWZcTd0IJybqc="; - }; - }; - templ = rec { - src = fetchFromGitHub { - owner = "vrischmann"; - repo = "tree-sitter-templ"; - rev = "044ad200092170727650fa6d368df66a8da98f9d"; - hash = "sha256-hJuB3h5pp+LLfP0/7bAYH0uLVo+OQk5jpzJb3J9BNkY="; - }; - querySrc = runCommandLocal "templ-tree-sitter-queries" { } '' - mkdir -p $out/queries - # copy most stuff from tree-sitter-templ - install -m644 ${src}/queries/templ/* $out/queries - # override inherited files - cat ${tree-sitter-go}/queries/highlights.scm ${src}/queries/templ/highlights.scm > $out/queries/highlights.scm - ''; - queryPath = "queries"; - }; - go = { - src = tree-sitter-go; - grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; - grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; - queryPath = "queries"; - }; - hylo = { - src = fetchFromGitHub { - owner = "natsukagami"; - repo = "tree-sitter-hylo"; - rev = "494cbdff0d13cbc67348316af2efa0286dbddf6f"; - hash = "sha256-R5UeoglCTl0do3VDJ/liCTeqbxU9slvmVKNRA/el2VY="; - }; - grammarCompileArgs = [ "-O3" "-c" "-fpic" "../parser.c" "-I" ".." ]; - grammarLinkArgs = [ "-shared" "-fpic" "parser.o" ]; - queryPath = "queries"; - }; - }; -} - From c6724e382be5720ef1226c8f881408ef542fb49f Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 7 Oct 2024 22:30:13 +0200 Subject: [PATCH 49/53] Further cleanup --- home/common.nix | 2 +- home/{kakoune/kak.nix => kakoune.nix} | 2 +- home/kakoune/autoload/latex.kak | 133 --------------- home/kakoune/autoload/markdown.kak | 29 ---- home/kakoune/catppuccin-latte.kak | 79 --------- home/kakoune/kakrc | 233 -------------------------- home/kakoune/kaktex | 28 ---- home/kakoune/kaktex.nix | 14 -- home/kakoune/source-pwd | 16 -- packages/common/nki-kakoune/kakrc | 2 +- 10 files changed, 3 insertions(+), 535 deletions(-) rename home/{kakoune/kak.nix => kakoune.nix} (98%) delete mode 100644 home/kakoune/autoload/latex.kak delete mode 100644 home/kakoune/autoload/markdown.kak delete mode 100644 home/kakoune/catppuccin-latte.kak delete mode 100644 home/kakoune/kakrc delete mode 100755 home/kakoune/kaktex delete mode 100644 home/kakoune/kaktex.nix delete mode 100755 home/kakoune/source-pwd diff --git a/home/common.nix b/home/common.nix index 2034fce..99f3511 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,7 +2,7 @@ { imports = [ - ./kakoune/kak.nix + ./kakoune.nix ./fish/fish.nix ./modules/programs/my-broot.nix ./modules/programs/my-sway diff --git a/home/kakoune/kak.nix b/home/kakoune.nix similarity index 98% rename from home/kakoune/kak.nix rename to home/kakoune.nix index 9a132ac..879b2b1 100644 --- a/home/kakoune/kak.nix +++ b/home/kakoune.nix @@ -3,7 +3,7 @@ let in { - imports = [ ../modules/programs/my-kakoune ./kaktex.nix ]; + imports = [ ./modules/programs/my-kakoune ]; home.packages = with pkgs; [ # ctags for peneira diff --git a/home/kakoune/autoload/latex.kak b/home/kakoune/autoload/latex.kak deleted file mode 100644 index 4bb9c9d..0000000 --- a/home/kakoune/autoload/latex.kak +++ /dev/null @@ -1,133 +0,0 @@ -## Author: @natsukagami (https://github.com/natsukagami) -## -## To activate, source the file into kakrc and add: -### require-module latex-kak -## -## NOTE: This overrides , so if you don't like it, remove it. - -# Create a simple begin block, put the cursors in and remove multi-cursor on exit. -define-command -hidden create-begin-block %{ - execute-keys "i\begin{b0}\end{b0}" - execute-keys "b0" - execute-keys -with-hooks -with-maps "c" - hook -once buffer ModeChange .*:normal %{ - execute-keys -with-maps ",gl" - } -} -# Create a begin block with the given parameter as block name. -define-command -params 1 create-begin-block-with %{ - execute-keys "i\begin{b0}\end{b0}" - execute-keys "b0c%arg{1}," - execute-keys "ok" - execute-keys -with-maps "gl" -} -# Create a \param{} block and put the cursor in the middle. -define-command -params 2 -hidden create-delims %{ - execute-keys "i%arg{1}hZa%arg{2}zl" - execute-keys -with-hooks -with-maps "i" -} -define-command -params 1 create-block-with %{ - create-delims "\%arg{1}{" "}" -} - -# The font-menu -declare-user-mode latex-font -## Semantics -map -docstring "Text" global latex-font t ": create-block-with text" -map -docstring "Emphasize (emph)" global latex-font e ": create-block-with emph" -## Shape -map -docstring "Italics (textit)" global latex-font i ": create-block-with textit" -map -docstring "Upright (textup)" global latex-font u ": create-block-with textup" -# map -docstring "Slanted (textsl)" global latex-font S ": create-block-with textsl" -# map -docstring "Swash font (textsw)" global latex-font W ": create-block-with textsw" -# map -docstring "Small caps (textsc)" global latex-font C ": create-block-with textsc" -# Weight -map -docstring "Bold text (textbf)" global latex-font b ": create-block-with textbf" -# map -docstring "Medium bold (textmd)" global latex-font M ": create-block-with textmd" -# map -docstring "Normal (textnormal)" global latex-font N ": create-block-with textnormal" -## Family -# map -docstring "Serif font (textsf)" global latex-font s ": create-block-with textsf" -# map -docstring "Roman text (textrm)" global latex-font r ": create-block-with textrm" -map -docstring "Monospace (texttt)" global latex-font m ": create-block-with texttt" -## Math styles -map -docstring "Math Calligraphic (mathcal)" global latex-font ": create-block-with mathcal" -map -docstring "Math Blackboard (mathbb)" global latex-font ": create-block-with mathbb" -# map -docstring "Math Fraktur (mathfr)" global latex-font ": create-block-with mathfr" -# map -docstring "Math Roman (mathrm)" global latex-font ": create-block-with mathrm" -# map -docstring "Math Italics (mathit)" global latex-font ": create-block-with mathit" -# map -docstring "Math Bold (mathbf)" global latex-font ": create-block-with mathbf" -# map -docstring "Serif font (mathsf)" global latex-font ": create-block-with mathsf" -map -docstring "Math Monospace (mathtt)" global latex-font ": create-block-with mathtt" -map -docstring "Math Fraktur (mathfrak)" global latex-font f ": create-block-with mathfrak" - -# "Insert block" menu -declare-user-mode latex-insert-block -## Common normal text blocks -map -docstring "Unordered list" global latex-insert-block u ": create-begin-block-with itemize" -map -docstring "Ordered list" global latex-insert-block o ": create-begin-block-with enumerate" -## Common math blocks -map -docstring "Theorem" global latex-insert-block t ": create-begin-block-with theorem" -map -docstring "Definition" global latex-insert-block d ": create-begin-block-with definition" -map -docstring "Lemma" global latex-insert-block l ": create-begin-block-with lemma" -map -docstring "Example" global latex-insert-block e ": create-begin-block-with example" -map -docstring "Proof" global latex-insert-block p ": create-begin-block-with proof" -map -docstring "Remark" global latex-insert-block r ": create-begin-block-with remark" -map -docstring "Proposition" global latex-insert-block ": create-begin-block-with proposition" -map -docstring "Corollary" global latex-insert-block C ": create-begin-block-with corollary" -## Common environments -map -docstring "align*" global latex-insert-block a ": create-begin-block-with align*" -map -docstring "align" global latex-insert-block ": create-begin-block-with align" -map -docstring "equation" global latex-insert-block E ": create-begin-block-with equation" -map -docstring "equation*" global latex-insert-block ": create-begin-block-with equation*" -map -docstring "Matrix" global latex-insert-block m ": create-begin-block-with bmatrix" -map -docstring "Cases" global latex-insert-block C ": create-begin-block-with cases" -map -docstring "Table" global latex-insert-block T ": create-begin-block-with tabular" -## Custom -map -docstring "Custom" global latex-insert-block c ": create-begin-block" - -# Pairs of delimiters -declare-user-mode latex-insert-delims -map -docstring "Grouping" global latex-insert-delims g ": create-delims { }" -map -docstring "Parentheses" global latex-insert-delims p ": create-delims ( )" -map -docstring "Large Parentheses" global latex-insert-delims P ": create-delims \left( \right)" -map -docstring "Brackets" global latex-insert-delims b ": create-delims \left[ \right]" -map -docstring "Sets" global latex-insert-delims s ": create-delims \{ \}" -map -docstring "Large Sets" global latex-insert-delims S ": create-delims \left\{ \right\}" - - -hook global WinSetOption filetype=(tex|latex) %{ - ## Create delims (shortcuts) - map buffer normal ": enter-user-mode latex-insert-delimsp" - map buffer insert ": enter-user-mode latex-insert-delimsp" - map buffer normal ": enter-user-mode latex-insert-delimsg" - map buffer insert ": enter-user-mode latex-insert-delimsg" - map buffer normal "i\(\)Zhhi" - map buffer insert "\(\)Z2h" - map buffer normal "i\[\]Zhhi" - map buffer insert "\[\]Z2h" - map buffer normal ": enter-user-mode latex-insert-delims" - map buffer insert ": enter-user-mode latex-insert-delims" - - ## Quickly create begin/end blocks - map buffer normal ": create-begin-block" - map buffer insert ": create-begin-block" - - ## Font menu - map buffer normal ": enter-user-mode latex-font" - map buffer insert ": enter-user-mode latex-font" - - ## Insert menu - map buffer normal ": enter-user-mode latex-insert-block" - map buffer insert ": enter-user-mode latex-insert-block" - - ## Select math equations and environment blocks - map buffer object e -docstring "Inline Math equation \( \)" "c\\\\\\(,\\\\\\)" - map buffer object E -docstring "Display Math equation \[ \]" "c\\\\\\[,\\\\\\]" - map buffer object v -docstring "Simple environment \env{}" "c\\\\\\w+\\{,\\}" - map buffer object V -docstring "Full environment \begin{env}\end{env}" "c\\\\begin\\{\\w+\\}(?:\\{[\\w\\s]*\\})*(?:\\[[\\w\\s]*\\])*,\\\\end\\{\\w+\\}" - - ## Quickly get a new item - map buffer normal "o\item " - map buffer insert "o\item " -} - diff --git a/home/kakoune/autoload/markdown.kak b/home/kakoune/autoload/markdown.kak deleted file mode 100644 index fb10581..0000000 --- a/home/kakoune/autoload/markdown.kak +++ /dev/null @@ -1,29 +0,0 @@ -hook global WinSetOption filetype=(markdown) %{ - map buffer normal ": enter-user-mode markdown-menu" -} - -# A menu for common markdown actions -declare-user-mode markdown-menu - -map -docstring "Toggle the checkboxes on the same line" global markdown-menu t ": markdown-toggle-checkbox" - -define-command -hidden markdown-toggle-checkbox %{ - try %{ - execute-keys -draft "xs^\s*- \[( |x)\]h: markdown-toggle-checkbox-selections" - } -} - -define-command -hidden markdown-toggle-checkbox-selections %{ - try %{ - execute-keys -draft -itersel ": markdown-toggle-checkbox-one" - } -} - -define-command -hidden markdown-toggle-checkbox-one %{ - try %{ - execute-keys -draft "sxr " - } catch %{ - execute-keys -draft "s rx" - } -} - diff --git a/home/kakoune/catppuccin-latte.kak b/home/kakoune/catppuccin-latte.kak deleted file mode 100644 index bd40ead..0000000 --- a/home/kakoune/catppuccin-latte.kak +++ /dev/null @@ -1,79 +0,0 @@ -# Catppuccin theme for Kakoune - -declare-option str rosewater "rgb:dc8a78" -declare-option str flamingo "rgb:dd7878" -declare-option str pink "rgb:ea76cb" -declare-option str mauve "rgb:8839ef" -declare-option str red "rgb:d20f39" -declare-option str maroon "rgb:e64553" -declare-option str peach "rgb:fe640b" -declare-option str yellow "rgb:df8e1d" -declare-option str green "rgb:40a02b" -declare-option str teal "rgb:179299" -declare-option str sky "rgb:04a5e5" -declare-option str sapphire "rgb:209fb5" -declare-option str blue "rgb:1e66f5" -declare-option str lavender "rgb:7287fd" -declare-option str text "rgb:4c4f69" -declare-option str subtext1 "rgb:5c5f77" -declare-option str subtext0 "rgb:6c6f85" -declare-option str overlay2 "rgb:7c7f93" -declare-option str overlay1 "rgb:8c8fa1" -declare-option str overlay0 "rgb:9ca0b0" -declare-option str surface2 "rgb:acb0be" -declare-option str surface1 "rgb:bcc0cc" -declare-option str surface0 "rgb:ccd0da" -declare-option str base "rgb:eff1f5" -declare-option str mantle "rgb:e6e9ef" -declare-option str crust "rgb:dce0e8" - - -set-face global title "%opt{text}+b" -set-face global header "%opt{subtext0}+b" -set-face global bold "%opt{maroon}+b" -set-face global italic "%opt{maroon}+i" -set-face global mono "%opt{green}" -set-face global block "%opt{sapphire}" -set-face global link "%opt{blue}" -set-face global bullet "%opt{peach}" -set-face global list "%opt{peach}" - -set-face global Default "%opt{text},%opt{base}" -set-face global PrimarySelection "%opt{text},%opt{surface2}" -set-face global SecondarySelection "%opt{text},%opt{surface2}" -set-face global PrimaryCursor "%opt{crust},%opt{rosewater}" -set-face global SecondaryCursor "%opt{text},%opt{overlay0}" -set-face global PrimaryCursorEol "%opt{surface2},%opt{lavender}" -set-face global SecondaryCursorEol "%opt{surface2},%opt{overlay1}" -set-face global LineNumbers "%opt{overlay1},%opt{base}" -set-face global LineNumberCursor "%opt{rosewater},%opt{surface2}+b" -set-face global LineNumbersWrapped "%opt{rosewater},%opt{surface2}+i" -set-face global MenuForeground "%opt{text},%opt{surface1}+b" -set-face global MenuBackground "%opt{text},%opt{surface0}" -set-face global MenuInfo "%opt{crust},%opt{teal}" -set-face global Information "%opt{crust},%opt{teal}" -set-face global Error "%opt{crust},%opt{red}" -set-face global StatusLine "%opt{text},%opt{mantle}" -set-face global StatusLineMode "%opt{crust},%opt{yellow}" -set-face global StatusLineInfo "%opt{crust},%opt{teal}" -set-face global StatusLineValue "%opt{crust},%opt{yellow}" -set-face global StatusCursor "%opt{crust},%opt{rosewater}" -set-face global Prompt "%opt{teal},%opt{base}+b" -set-face global MatchingChar "%opt{maroon},%opt{base}" -set-face global Whitespace "%opt{overlay1},%opt{base}+f" -set-face global WrapMarker "Whitespace" -set-face global BufferPadding "%opt{base},%opt{base}" - -set-face global value "%opt{peach}" -set-face global type "%opt{blue}" -set-face global variable "%opt{text}" -set-face global module "%opt{maroon}" -set-face global function "%opt{blue}" -set-face global string "%opt{green}" -set-face global keyword "%opt{mauve}" -set-face global operator "%opt{sky}" -set-face global attribute "%opt{green}" -set-face global comment "%opt{overlay0}" -set-face global documentation "comment" -set-face global meta "%opt{yellow}" -set-face global builtin "%opt{red}" diff --git a/home/kakoune/kakrc b/home/kakoune/kakrc deleted file mode 100644 index 7502c2a..0000000 --- a/home/kakoune/kakrc +++ /dev/null @@ -1,233 +0,0 @@ -# Enable kak-tree-sitter -eval %sh{test -z "$WE_STARTED_KAK" && kak-tree-sitter --kakoune -d --server --init $kak_session} -map global normal ": enter-user-mode tree-sitter" -# ## Set some color overrides -# set global kts_yellow "rgb:e2b75e" -# set global kts_teal "rgb:008080" -# set global kts_mauve "rgb:c264ff" -# set global kts_sky "rgb:6aa622" -# Color scheme -colorscheme catppuccin-latte -set global base "default" - -# Set indentation guides -add-highlighter global/indent-guides show-whitespaces -tab " " -spc " " -lf " " -nbsp " " -set-face global Whitespace default,default -set-face global WhitespaceIndent +d@comment - -# Assistant -set global ui_options terminal_assistant=cat - -# Enable line numbers -hook global WinCreate .* %{ - addhl window/number-lines number-lines -} - -set global grepcmd "rg --line-number --no-column --no-heading --color=never " - -# Kitty-specific options -hook -group windowing global KakBegin .* %{ - set global kitty_window_type os-window -} - -# Comment line and block -map global normal <#> ': comment-line' -map global normal ': comment-block' - -# Go to grep-jump -map global goto f -docstring "current grep-jump match" ': grep-jump' - -# System clipboard interactions -hook global RegisterModified '"' %{ nop %sh{ - printf "%s" "$kak_main_reg_dquote" | pbcopy >/dev/null 2>/dev/null & -}} -map global user P -docstring "Paste before cursor from clipboard" '! pbpaste -n | cat' -map global user p -docstring "Paste after cursor from clipboard" ' pbpaste -n | cat' -map global user R -docstring "Replace selection with text from clipboard" '! pbpaste -n | cat' -define-command -params 0 -docstring "Copy line down" copyline %{ - execute-keys -draft 'xy'%val{count}'P' -} -map global normal <+> -docstring "Copy line down" ': copyline' -define-command -params 0 -docstring "Delete current pair of brackets" delete-current-brackets %{ - execute-keys 'm' - execute-keys -draft 'd' - execute-keys 'H' -} -map global normal D ": delete-current-brackets" - -# Disable write-to -# unalias global w -# define-command -params 0 -docstring "Writes the current file" w "write" - -# Tab sizes -hook global InsertChar \t %{ exec -draft -itersel h@ } -set global tabstop 2 -set global indentwidth 2 - -# Language-specific tabstop with override -hook global WinSetOption filetype=(rust) %{ - set window tabstop 4 - set window indentwidth 4 -} - -# Ctrl + a in insert mode = esc -map global insert '' - -# Tab completion -hook global InsertCompletionShow .* %{ - try %{ - # this command temporarily removes cursors preceded by whitespace; - # if there are no cursors left, it raises an error, does not - # continue to execute the mapping commands, and the error is eaten - # by the `try` command so no warning appears. - execute-keys -draft 'h\h' - map window insert - map window insert - } -} -hook global InsertCompletionHide .* %{ - unmap window insert - unmap window insert -} - -# Enable LSP -try %{ - eval %sh{test -z "$WE_STARTED_KAK" && kak-lsp --kakoune -s $kak_session} - set-option global lsp_cmd "kak-lsp -s %val{session}" -} -hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|fsharp|ocaml|haskell|nix|scala|typst|html|css|json|markdown|templ|elixir) %{ - lsp-enable-window - map window lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" - map window normal ": enter-user-mode lsp" - map window normal ": lsp-hover" - map window normal ": lsp-hover-buffer" - # lsp-auto-hover-insert-mode-enable - set window lsp_hover_anchor true - map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' - map global object a 'lsp-object' -docstring 'LSP any symbol' - map global object 'lsp-object' -docstring 'LSP any symbol' - map global object f 'lsp-object Function Method' -docstring 'LSP function or method' - map global object t 'lsp-object Class Interface Struct' -docstring 'LSP class interface or struct' - map global object d 'lsp-diagnostic-object --include-warnings' -docstring 'LSP errors and warnings' - map global object D 'lsp-diagnostic-object' -docstring 'LSP errors' -} - -hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|haskell|nix|fsharp|templ) %{ - # Format the document if possible - hook window BufWritePre .* %{ lsp-formatting-sync } -} - -hook global WinSetOption filetype=(rust|scala|fsharp) %{ - # Enable inlay hints - lsp-inlay-hints-enable window -} - -hook global WinSetOption filetype=(rust|go|fsharp|typst|scala) %{ - hook window -group semantic-tokens BufReload .* lsp-semantic-tokens - hook window -group semantic-tokens NormalIdle .* lsp-semantic-tokens - hook window -group semantic-tokens InsertIdle .* lsp-semantic-tokens - hook -once -always window WinSetOption filetype=.* %{ - remove-hooks window semantic-tokens - } -} - -# in Insert mode moves to end of line. -map global insert 'A' - -hook global WinSetOption filetype=(fsharp) %{ - set-option window comment_line "//" - # Set up formatting - # set-option window formatcmd "~/.dotnet/tools/fantomas --stdin --stdout" - # hook window -group fsharp-format BufWritePre .* %{ format } -} - -hook global WinSetOption filetype=(ocaml) %{ - unset-option buffer comment_line - set-option buffer comment_block_begin "(*" - set-option buffer comment_block_end "*)" -} - -hook global WinSetOption filetype=(haskell) %{ - set-option buffer makecmd "cabal build" -} - -hook global WinSetOption filetype=(rust) %{ - set-option buffer makecmd "cargo check" -} - -hook global WinSetOption filetype=(scala) %{ - # Format the document if possible - hook -group scala-fmt window BufWritePre .* %{ lsp-formatting-sync } -} - -hook global WinSetOption filetype=(typst) %{ - set-option window comment_line "//" - set-option window comment_block_begin "/*" - set-option window comment_block_end "*/" - - # borrow markdown's hooks - require-module markdown - - hook window ModeChange pop:insert:.* -group markdown-trim-indent markdown-trim-indent - hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line - hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } -} - - -define-command -params 0 -docstring "Set up build" scala-build-connect %{ - lsp-execute-command 'build-connect' '"[]"' -} - -define-command -params 0 -docstring "Import build" scala-build-import %{ - lsp-execute-command 'build-import' '"[]"' -} - -def -hidden insert-c-n %{ - try %{ - lsp-snippets-select-next-placeholders - exec 'd' - } catch %{ - exec -with-hooks '' - } -} -map global insert ": insert-c-n" - -# Use C++ for .h headers -hook global BufCreate .*[.](h) %{ - set-option buffer filetype cpp -} - -hook global BufCreate .*[.]kakrc %{ - set-option buffer filetype kak -} - -hook global BufCreate .*[.]md %{ - add-highlighter buffer/ wrap -} - -hook global BufCreate .*[.](sc|sbt|mill) %{ - set-option buffer filetype scala -} - -hook global BufCreate .*[.]typ %{ - set-option buffer filetype typst - add-highlighter buffer/ wrap -} - -hook global BufCreate .*[.]templ %{ - set-option buffer filetype templ - set-option buffer comment_line "//" -} - -hook global BufCreate .*[.]hylo %{ - set-option buffer filetype hylo - set-option buffer comment_line "//" -} - -hook global BufOpenFile .* %{ - modeline-parse -} - -map global normal ':inc-dec-modify-numbers + %val{count}' -map global normal ':inc-dec-modify-numbers - %val{count}' diff --git a/home/kakoune/kaktex b/home/kakoune/kaktex deleted file mode 100755 index bdcf722..0000000 --- a/home/kakoune/kaktex +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env fish - -function usage - echo "Usage: " - echo " kaktex set [client] [session]" - echo " kaktex jump [file] [line] [column]" - exit 1 -end - -if test (count $argv) -lt 3 - usage -end - -switch $argv[1] - case "set" - set -U _kaktex_client $argv[2] - set -U _kaktex_session $argv[3] - case "jump" - echo " - evaluate-commands -client $_kaktex_client %{ - evaluate-commands -try-client $_kaktex_client %{ - edit -existing -- $argv[2] $(math $argv[3] + 1) $(math $argv[4] + 1) - } - } - " | kak -p $_kaktex_session - case '*' - usage -end diff --git a/home/kakoune/kaktex.nix b/home/kakoune/kaktex.nix deleted file mode 100644 index 1256c79..0000000 --- a/home/kakoune/kaktex.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - # Source kaktex whenever we have a tex file - programs.my-kakoune.rc = '' - hook global WinSetOption filetype=(tex|latex) %{ - hook window WinDisplay '.*' %{ - eval %sh{ - ${./kaktex} set $kak_client $kak_session - } - } - } - ''; -} diff --git a/home/kakoune/source-pwd b/home/kakoune/source-pwd deleted file mode 100755 index 35e5b0f..0000000 --- a/home/kakoune/source-pwd +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env fish - -if test (pwd) = "/home/natsukagami/.config/kak" - exit 0 -end - -while true - set kakrc (pwd)/.kakrc - if test -f $kakrc - echo source $kakrc - end - if test (pwd) = "/" - exit 0 - end - cd .. -end diff --git a/packages/common/nki-kakoune/kakrc b/packages/common/nki-kakoune/kakrc index 0bc3dc0..878869c 100644 --- a/packages/common/nki-kakoune/kakrc +++ b/packages/common/nki-kakoune/kakrc @@ -162,7 +162,7 @@ hook global BufCreate .*[.]md %{ add-highlighter buffer/ wrap } -hook global BufCreate .*[.](sc|sbt) %{ +hook global BufCreate .*[.](sc|sbt|mill) %{ set-option buffer filetype scala } From 281fcad46f92959c2ab788228db48c8e7222702e Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 22 Oct 2024 15:36:22 +0200 Subject: [PATCH 50/53] podman: add slirp4netns to the wrapper --- modules/common/linux/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/common/linux/default.nix b/modules/common/linux/default.nix index 3b53a0d..15b72bb 100644 --- a/modules/common/linux/default.nix +++ b/modules/common/linux/default.nix @@ -69,6 +69,7 @@ let virtualisation = { pkgs, ... }: mkIf cfg.enable { virtualisation.podman = { enable = true; + extraPackages = [ pkgs.slirp4netns ]; dockerCompat = true; defaultNetwork.settings.dns_enabled = true; }; From a6c34181b4cd1d55b813047daabd92c0b49f4fd5 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 4 Nov 2024 14:48:54 +0100 Subject: [PATCH 51/53] Update templ and vscode langservers --- home/kakoune.nix | 4 ++-- packages/common/nki-kakoune/lsp.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/home/kakoune.nix b/home/kakoune.nix index 879b2b1..09898c3 100644 --- a/home/kakoune.nix +++ b/home/kakoune.nix @@ -97,8 +97,8 @@ in src = pkgs.fetchFromGitHub { owner = "vrischmann"; repo = "tree-sitter-templ"; - rev = "044ad200092170727650fa6d368df66a8da98f9d"; - hash = "sha256-hJuB3h5pp+LLfP0/7bAYH0uLVo+OQk5jpzJb3J9BNkY="; + rev = "4519e3ec9ca92754ca25659bb1fd410d5e0f8d88"; + hash = "sha256-ic5SlqDEZoYakrJFe0H9GdzravqovlL5sTaHjyhe74M="; }; in { diff --git a/packages/common/nki-kakoune/lsp.nix b/packages/common/nki-kakoune/lsp.nix index 47e8259..92dca5a 100644 --- a/packages/common/nki-kakoune/lsp.nix +++ b/packages/common/nki-kakoune/lsp.nix @@ -39,8 +39,8 @@ let command = "vscode-${name}-language-server"; filetypes = [ name "templ" ]; roots = [ "package.json" ".git" ]; + package = nodePackages.vscode-langservers-extracted; }; - package = nodePackages.vscode-langservers-extracted; }; in { From 546d8fffb5b6406964e3c0343e5811d28a3c5980 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 30 Dec 2024 13:50:29 +0100 Subject: [PATCH 52/53] Use latest kernel on framework --- nki-framework/hardware-configuration.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/nki-framework/hardware-configuration.nix b/nki-framework/hardware-configuration.nix index e88c852..c814573 100644 --- a/nki-framework/hardware-configuration.nix +++ b/nki-framework/hardware-configuration.nix @@ -12,7 +12,6 @@ boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; - boot.kernelPackages = pkgs.linuxPackages; # until mesa fixed boot.kernelParams = [ # Hibernation "resume=UUID=fa8aaf51-b99f-4fb4-9230-8c0957d8af3f" From cb800c9fa49af40ab84a2d27f92d2028f5c444d0 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 30 Dec 2024 13:52:43 +0100 Subject: [PATCH 53/53] Add associations for telegram --- home/modules/linux/graphical/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/home/modules/linux/graphical/default.nix b/home/modules/linux/graphical/default.nix index 35a29eb..499088a 100644 --- a/home/modules/linux/graphical/default.nix +++ b/home/modules/linux/graphical/default.nix @@ -131,6 +131,8 @@ in "x-scheme-handler/feed" = [ "thunderbird.desktop" ]; "application/rss+xml" = [ "thunderbird.desktop" ]; "application/x-extension-rss" = [ "thunderbird.desktop" ]; + "x-scheme-handler/tg2" = [ "org.telegram.desktop.desktop" ]; + "x-scheme-handler/tonsite2" = [ "org.telegram.desktop.desktop" ]; }; xdg.mimeApps.defaultApplications = { # Email @@ -167,6 +169,10 @@ in # Files "inode/directory" = [ "dolphin.desktop" ]; + + # Telegram + "x-scheme-handler/tg2" = "org.telegram.desktop.desktop"; + "x-scheme-handler/tonsite2" = "org.telegram.desktop.desktop"; }; # Add one for kakoune