parent
c6c255ff88
commit
ca81e960f7
348
config.nix
348
config.nix
|
@ -1,348 +0,0 @@
|
|||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
{
|
||||
ignore = [
|
||||
".idea/"
|
||||
"result"
|
||||
"node_modules/"
|
||||
"dist/"
|
||||
];
|
||||
settings = {
|
||||
theme = "catppuccin_mocha_transparent";
|
||||
editor = {
|
||||
line-number = "relative";
|
||||
mouse = false;
|
||||
bufferline = "always";
|
||||
color-modes = true;
|
||||
cursor-shape = {
|
||||
insert = "bar";
|
||||
normal = "block";
|
||||
select = "underline";
|
||||
};
|
||||
file-picker.hidden = false;
|
||||
indent-guides = {
|
||||
render = true;
|
||||
skip-levels = 1;
|
||||
};
|
||||
soft-wrap.enable = true;
|
||||
statusline = {
|
||||
right = [
|
||||
"version-control"
|
||||
"diagnostics"
|
||||
"selections"
|
||||
"position"
|
||||
"file-encoding"
|
||||
];
|
||||
};
|
||||
end-of-line-diagnostics = "hint";
|
||||
inline-diagnostics.cursor-line = "error";
|
||||
lsp.display-messages = true;
|
||||
};
|
||||
keys =
|
||||
let
|
||||
caseMenu = with pkgs; {
|
||||
p = ":pipe ${lib.getExe sttr} pascal";
|
||||
c = ":pipe ${lib.getExe sttr} camel";
|
||||
k = ":pipe ${lib.getExe sttr} kebab";
|
||||
K = ":pipe ${lib.getExe sttr} kebab | ${lib.getExe sttr} upper";
|
||||
s = ":pipe ${lib.getExe sttr} snake";
|
||||
S = ":pipe ${lib.getExe sttr} snake | ${lib.getExe sttr} upper";
|
||||
u = ":pipe ${lib.getExe sttr} upper";
|
||||
l = ":pipe ${lib.getExe sttr} lower";
|
||||
t = ":pipe ${lib.getExe sttr} title";
|
||||
};
|
||||
in
|
||||
{
|
||||
normal = {
|
||||
"~" = caseMenu;
|
||||
space = {
|
||||
q = ":quit";
|
||||
Q = ":quit!";
|
||||
w = ":write";
|
||||
W = ":write!";
|
||||
o = "file_picker_in_current_buffer_directory";
|
||||
};
|
||||
C-c = ":config-open";
|
||||
C-r = ":config-reload";
|
||||
"C-/" = "toggle_comments";
|
||||
S-right = "goto_next_buffer";
|
||||
S-left = "goto_previous_buffer";
|
||||
C-b = ":buffer-close";
|
||||
C-s = [
|
||||
"select_all"
|
||||
"select_regex"
|
||||
];
|
||||
|
||||
C-j = "shrink_selection";
|
||||
C-k = "expand_selection";
|
||||
C-l = "select_next_sibling";
|
||||
C-a = "select_all";
|
||||
C-u = [
|
||||
"half_page_up"
|
||||
"align_view_center"
|
||||
];
|
||||
C-d = [
|
||||
"half_page_down"
|
||||
"align_view_center"
|
||||
];
|
||||
|
||||
"{" = [
|
||||
"goto_prev_paragraph"
|
||||
"collapse_selection"
|
||||
];
|
||||
"}" = [
|
||||
"goto_next_paragraph"
|
||||
"collapse_selection"
|
||||
];
|
||||
"0" = "goto_line_start";
|
||||
"$" = "goto_line_end";
|
||||
"^" = "goto_first_nonwhitespace";
|
||||
G = "goto_file_end";
|
||||
"%" = "match_brackets";
|
||||
V = [
|
||||
"select_mode"
|
||||
"extend_to_line_bounds"
|
||||
];
|
||||
C = [
|
||||
"collapse_selection"
|
||||
"extend_to_line_end"
|
||||
"change_selection"
|
||||
];
|
||||
D = [
|
||||
"extend_to_line_end"
|
||||
"delete_selection"
|
||||
];
|
||||
S = "surround_add";
|
||||
|
||||
d = {
|
||||
d = [
|
||||
"extend_to_line_bounds"
|
||||
"delete_selection"
|
||||
];
|
||||
t = [ "extend_till_char" ];
|
||||
s = [ "surround_delete" ];
|
||||
i = [ "select_textobject_inner" ];
|
||||
a = [ "select_textobject_around" ];
|
||||
};
|
||||
|
||||
x = "delete_selection";
|
||||
p = "paste_clipboard_after";
|
||||
P = "paste_clipboard_before";
|
||||
y = [
|
||||
"yank_main_selection_to_clipboard"
|
||||
"normal_mode"
|
||||
"flip_selections"
|
||||
"collapse_selection"
|
||||
];
|
||||
Y = [
|
||||
"extend_to_line_bounds"
|
||||
"yank_main_selection_to_clipboard"
|
||||
"goto_line_start"
|
||||
"collapse_selection"
|
||||
];
|
||||
|
||||
w = [
|
||||
"move_next_word_start"
|
||||
"move_char_right"
|
||||
"collapse_selection"
|
||||
];
|
||||
e = [
|
||||
"move_next_word_end"
|
||||
"collapse_selection"
|
||||
];
|
||||
b = [
|
||||
"move_prev_word_start"
|
||||
"collapse_selection"
|
||||
];
|
||||
|
||||
i = [
|
||||
"insert_mode"
|
||||
"collapse_selection"
|
||||
];
|
||||
a = [
|
||||
"append_mode"
|
||||
"collapse_selection"
|
||||
];
|
||||
|
||||
esc = [
|
||||
"collapse_selection"
|
||||
"keep_primary_selection"
|
||||
];
|
||||
};
|
||||
insert = {
|
||||
esc = [
|
||||
"collapse_selection"
|
||||
"normal_mode"
|
||||
];
|
||||
};
|
||||
select = {
|
||||
"~" = caseMenu;
|
||||
space = {
|
||||
j = with pkgs; {
|
||||
e = ":pipe ${lib.getExe jq}";
|
||||
c = ":pipe ${lib.getExe jq} -c";
|
||||
};
|
||||
};
|
||||
"{" = [
|
||||
"extend_to_line_bounds"
|
||||
"goto_prev_paragraph"
|
||||
];
|
||||
"}" = [
|
||||
"extend_to_line_bounds"
|
||||
"goto_next_paragraph"
|
||||
];
|
||||
"0" = "goto_line_start";
|
||||
"$" = "goto_line_end";
|
||||
"^" = "goto_first_nonwhitespace";
|
||||
G = "goto_file_end";
|
||||
D = [
|
||||
"extend_to_line_bounds"
|
||||
"delete_selection"
|
||||
"normal_mode"
|
||||
];
|
||||
C = [
|
||||
"goto_line_start"
|
||||
"extend_to_line_bounds"
|
||||
"change_selection"
|
||||
];
|
||||
"%" = "match_brackets";
|
||||
S = "surround_add";
|
||||
|
||||
i = "select_textobject_inner";
|
||||
a = "select_textobject_around";
|
||||
|
||||
tab = [
|
||||
"insert_mode"
|
||||
"collapse_selection"
|
||||
];
|
||||
C-a = [
|
||||
"append_mode"
|
||||
"collapse_selection"
|
||||
];
|
||||
|
||||
k = [
|
||||
"extend_line_up"
|
||||
"extend_to_line_bounds"
|
||||
];
|
||||
j = [
|
||||
"extend_line_down"
|
||||
"extend_to_line_bounds"
|
||||
];
|
||||
|
||||
d = [
|
||||
"yank_main_selection_to_clipboard"
|
||||
"delete_selection"
|
||||
];
|
||||
x = [
|
||||
"yank_main_selection_to_clipboard"
|
||||
"delete_selection"
|
||||
];
|
||||
y = [
|
||||
"yank_main_selection_to_clipboard"
|
||||
"normal_mode"
|
||||
"flip_selections"
|
||||
"collapse_selection"
|
||||
];
|
||||
Y = [
|
||||
"extend_to_line_bounds"
|
||||
"yank_main_selection_to_clipboard"
|
||||
"goto_line_start"
|
||||
"collapse_selection"
|
||||
"normal_mode"
|
||||
];
|
||||
p = "replace_selections_with_clipboard";
|
||||
P = "paste_clipboard_before";
|
||||
|
||||
esc = [
|
||||
"collapse_selection"
|
||||
"keep_primary_selection"
|
||||
"normal_mode"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
languages = with pkgs; {
|
||||
language = [
|
||||
{
|
||||
name = "go";
|
||||
formatter = {
|
||||
command = "sh";
|
||||
args = [
|
||||
"-c"
|
||||
"set -o pipefail; ${lib.getExe' gotools "goimports"} | ${lib.getExe gofumpt}"
|
||||
];
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "nix";
|
||||
auto-format = true;
|
||||
formatter = {
|
||||
command = "${lib.getExe nixfmt-rfc-style}";
|
||||
args = [ "-q" ];
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "jsonnet";
|
||||
auto-format = true;
|
||||
formatter = {
|
||||
command = "${lib.getExe' jsonnet "jsonnetfmt"}";
|
||||
args = [ "-" ];
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "python";
|
||||
auto-format = true;
|
||||
formatter = {
|
||||
args = [
|
||||
"format"
|
||||
"--stdin-filename"
|
||||
"file.py"
|
||||
"-"
|
||||
];
|
||||
command = "${lib.getExe ruff}";
|
||||
};
|
||||
language-servers = [ "pylsp" ];
|
||||
}
|
||||
];
|
||||
language-server = {
|
||||
nil.config.nil.nix.flake.autoEvalInputs = true;
|
||||
pylsp.config.pylsp = {
|
||||
plugins = {
|
||||
flake8.enabled = false;
|
||||
mypy = {
|
||||
dmypy = true;
|
||||
enabled = true;
|
||||
report_progress = true;
|
||||
};
|
||||
pycodestyle.enabled = false;
|
||||
pyflakes.enabled = false;
|
||||
ruff = {
|
||||
enabled = true;
|
||||
extendSelect = [ "I" ];
|
||||
format = [ "I" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
themes = {
|
||||
catppuccin_frappe_transparent = {
|
||||
inherits = "catppuccin_frappe";
|
||||
"ui.background" = { };
|
||||
};
|
||||
catppuccin_latte_transparent = {
|
||||
inherits = "catppuccin_latte";
|
||||
"ui.background" = { };
|
||||
};
|
||||
catppuccin_macchiato_transparent = {
|
||||
inherits = "catppuccin_macchiato";
|
||||
"ui.background" = { };
|
||||
};
|
||||
catppuccin_mocha_transparent = {
|
||||
inherits = "catppuccin_mocha";
|
||||
"ui.background" = { };
|
||||
};
|
||||
};
|
||||
grammars = [ ];
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
{
|
||||
ignore = [
|
||||
".idea/"
|
||||
"result"
|
||||
"node_modules/"
|
||||
"dist/"
|
||||
];
|
||||
settings = {
|
||||
theme = "catppuccin_mocha_transparent";
|
||||
editor = {
|
||||
line-number = "relative";
|
||||
mouse = false;
|
||||
bufferline = "always";
|
||||
color-modes = true;
|
||||
cursor-shape = {
|
||||
insert = "bar";
|
||||
normal = "block";
|
||||
select = "underline";
|
||||
};
|
||||
file-picker.hidden = false;
|
||||
indent-guides = {
|
||||
render = true;
|
||||
skip-levels = 1;
|
||||
};
|
||||
soft-wrap.enable = true;
|
||||
statusline = {
|
||||
right = [
|
||||
"version-control"
|
||||
"diagnostics"
|
||||
"selections"
|
||||
"position"
|
||||
"file-encoding"
|
||||
];
|
||||
};
|
||||
end-of-line-diagnostics = "hint";
|
||||
inline-diagnostics.cursor-line = "error";
|
||||
lsp.display-messages = true;
|
||||
};
|
||||
keys = import ./keys.nix { inherit pkgs; };
|
||||
};
|
||||
languages = import ./languages.nix { inherit pkgs; };
|
||||
themes = import ./themes.nix { inherit pkgs; };
|
||||
grammars = import ./grammars.nix { inherit pkgs; };
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{ pkgs }: [ ]
|
|
@ -0,0 +1,222 @@
|
|||
{ pkgs }:
|
||||
let
|
||||
caseMenu = with pkgs; {
|
||||
p = ":pipe ${lib.getExe sttr} pascal";
|
||||
c = ":pipe ${lib.getExe sttr} camel";
|
||||
k = ":pipe ${lib.getExe sttr} kebab";
|
||||
K = ":pipe ${lib.getExe sttr} kebab | ${lib.getExe sttr} upper";
|
||||
s = ":pipe ${lib.getExe sttr} snake";
|
||||
S = ":pipe ${lib.getExe sttr} snake | ${lib.getExe sttr} upper";
|
||||
u = ":pipe ${lib.getExe sttr} upper";
|
||||
l = ":pipe ${lib.getExe sttr} lower";
|
||||
t = ":pipe ${lib.getExe sttr} title";
|
||||
};
|
||||
in
|
||||
{
|
||||
normal = {
|
||||
"~" = caseMenu;
|
||||
space = {
|
||||
q = ":quit";
|
||||
Q = ":quit!";
|
||||
w = ":write";
|
||||
W = ":write!";
|
||||
o = "file_picker_in_current_buffer_directory";
|
||||
};
|
||||
C-c = ":config-open";
|
||||
C-r = ":config-reload";
|
||||
"C-/" = "toggle_comments";
|
||||
S-right = "goto_next_buffer";
|
||||
S-left = "goto_previous_buffer";
|
||||
C-b = ":buffer-close";
|
||||
C-s = [
|
||||
"select_all"
|
||||
"select_regex"
|
||||
];
|
||||
|
||||
C-j = "shrink_selection";
|
||||
C-k = "expand_selection";
|
||||
C-l = "select_next_sibling";
|
||||
C-a = "select_all";
|
||||
C-u = [
|
||||
"half_page_up"
|
||||
"align_view_center"
|
||||
];
|
||||
C-d = [
|
||||
"half_page_down"
|
||||
"align_view_center"
|
||||
];
|
||||
|
||||
"{" = [
|
||||
"goto_prev_paragraph"
|
||||
"collapse_selection"
|
||||
];
|
||||
"}" = [
|
||||
"goto_next_paragraph"
|
||||
"collapse_selection"
|
||||
];
|
||||
"0" = "goto_line_start";
|
||||
"$" = "goto_line_end";
|
||||
"^" = "goto_first_nonwhitespace";
|
||||
G = "goto_file_end";
|
||||
"%" = "match_brackets";
|
||||
V = [
|
||||
"select_mode"
|
||||
"extend_to_line_bounds"
|
||||
];
|
||||
C = [
|
||||
"collapse_selection"
|
||||
"extend_to_line_end"
|
||||
"change_selection"
|
||||
];
|
||||
D = [
|
||||
"extend_to_line_end"
|
||||
"delete_selection"
|
||||
];
|
||||
S = "surround_add";
|
||||
|
||||
d = {
|
||||
d = [
|
||||
"extend_to_line_bounds"
|
||||
"delete_selection"
|
||||
];
|
||||
t = [ "extend_till_char" ];
|
||||
s = [ "surround_delete" ];
|
||||
i = [ "select_textobject_inner" ];
|
||||
a = [ "select_textobject_around" ];
|
||||
};
|
||||
|
||||
x = "delete_selection";
|
||||
p = "paste_clipboard_after";
|
||||
P = "paste_clipboard_before";
|
||||
y = [
|
||||
"yank_main_selection_to_clipboard"
|
||||
"normal_mode"
|
||||
"flip_selections"
|
||||
"collapse_selection"
|
||||
];
|
||||
Y = [
|
||||
"extend_to_line_bounds"
|
||||
"yank_main_selection_to_clipboard"
|
||||
"goto_line_start"
|
||||
"collapse_selection"
|
||||
];
|
||||
|
||||
w = [
|
||||
"move_next_word_start"
|
||||
"move_char_right"
|
||||
"collapse_selection"
|
||||
];
|
||||
e = [
|
||||
"move_next_word_end"
|
||||
"collapse_selection"
|
||||
];
|
||||
b = [
|
||||
"move_prev_word_start"
|
||||
"collapse_selection"
|
||||
];
|
||||
|
||||
i = [
|
||||
"insert_mode"
|
||||
"collapse_selection"
|
||||
];
|
||||
a = [
|
||||
"append_mode"
|
||||
"collapse_selection"
|
||||
];
|
||||
|
||||
esc = [
|
||||
"collapse_selection"
|
||||
"keep_primary_selection"
|
||||
];
|
||||
};
|
||||
insert = {
|
||||
esc = [
|
||||
"collapse_selection"
|
||||
"normal_mode"
|
||||
];
|
||||
};
|
||||
select = {
|
||||
"~" = caseMenu;
|
||||
space = {
|
||||
j = with pkgs; {
|
||||
e = ":pipe ${lib.getExe jq}";
|
||||
c = ":pipe ${lib.getExe jq} -c";
|
||||
};
|
||||
};
|
||||
"{" = [
|
||||
"extend_to_line_bounds"
|
||||
"goto_prev_paragraph"
|
||||
];
|
||||
"}" = [
|
||||
"extend_to_line_bounds"
|
||||
"goto_next_paragraph"
|
||||
];
|
||||
"0" = "goto_line_start";
|
||||
"$" = "goto_line_end";
|
||||
"^" = "goto_first_nonwhitespace";
|
||||
G = "goto_file_end";
|
||||
D = [
|
||||
"extend_to_line_bounds"
|
||||
"delete_selection"
|
||||
"normal_mode"
|
||||
];
|
||||
C = [
|
||||
"goto_line_start"
|
||||
"extend_to_line_bounds"
|
||||
"change_selection"
|
||||
];
|
||||
"%" = "match_brackets";
|
||||
S = "surround_add";
|
||||
|
||||
i = "select_textobject_inner";
|
||||
a = "select_textobject_around";
|
||||
|
||||
tab = [
|
||||
"insert_mode"
|
||||
"collapse_selection"
|
||||
];
|
||||
C-a = [
|
||||
"append_mode"
|
||||
"collapse_selection"
|
||||
];
|
||||
|
||||
k = [
|
||||
"extend_line_up"
|
||||
"extend_to_line_bounds"
|
||||
];
|
||||
j = [
|
||||
"extend_line_down"
|
||||
"extend_to_line_bounds"
|
||||
];
|
||||
|
||||
d = [
|
||||
"yank_main_selection_to_clipboard"
|
||||
"delete_selection"
|
||||
];
|
||||
x = [
|
||||
"yank_main_selection_to_clipboard"
|
||||
"delete_selection"
|
||||
];
|
||||
y = [
|
||||
"yank_main_selection_to_clipboard"
|
||||
"normal_mode"
|
||||
"flip_selections"
|
||||
"collapse_selection"
|
||||
];
|
||||
Y = [
|
||||
"extend_to_line_bounds"
|
||||
"yank_main_selection_to_clipboard"
|
||||
"goto_line_start"
|
||||
"collapse_selection"
|
||||
"normal_mode"
|
||||
];
|
||||
p = "replace_selections_with_clipboard";
|
||||
P = "paste_clipboard_before";
|
||||
|
||||
esc = [
|
||||
"collapse_selection"
|
||||
"keep_primary_selection"
|
||||
"normal_mode"
|
||||
];
|
||||
};
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
{ pkgs }:
|
||||
with pkgs;
|
||||
{
|
||||
language = [
|
||||
{
|
||||
name = "go";
|
||||
formatter = {
|
||||
command = "sh";
|
||||
args = [
|
||||
"-c"
|
||||
"set -o pipefail; ${lib.getExe' gotools "goimports"} | ${lib.getExe gofumpt}"
|
||||
];
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "nix";
|
||||
auto-format = true;
|
||||
formatter = {
|
||||
command = "${lib.getExe nixfmt-rfc-style}";
|
||||
args = [ "-q" ];
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "jsonnet";
|
||||
auto-format = true;
|
||||
formatter = {
|
||||
command = "${lib.getExe' jsonnet "jsonnetfmt"}";
|
||||
args = [ "-" ];
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "python";
|
||||
auto-format = true;
|
||||
formatter = {
|
||||
args = [
|
||||
"format"
|
||||
"--stdin-filename"
|
||||
"file.py"
|
||||
"-"
|
||||
];
|
||||
command = "${lib.getExe ruff}";
|
||||
};
|
||||
language-servers = [ "pylsp" ];
|
||||
}
|
||||
];
|
||||
language-server = {
|
||||
nil.config.nil.nix.flake.autoEvalInputs = true;
|
||||
pylsp.config.pylsp = {
|
||||
plugins = {
|
||||
flake8.enabled = false;
|
||||
mypy = {
|
||||
dmypy = true;
|
||||
enabled = true;
|
||||
report_progress = true;
|
||||
};
|
||||
pycodestyle.enabled = false;
|
||||
pyflakes.enabled = false;
|
||||
ruff = {
|
||||
enabled = true;
|
||||
extendSelect = [ "I" ];
|
||||
format = [ "I" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{ pkgs }:
|
||||
{
|
||||
catppuccin_frappe_transparent = {
|
||||
inherits = "catppuccin_frappe";
|
||||
"ui.background" = { };
|
||||
};
|
||||
catppuccin_latte_transparent = {
|
||||
inherits = "catppuccin_latte";
|
||||
"ui.background" = { };
|
||||
};
|
||||
catppuccin_macchiato_transparent = {
|
||||
inherits = "catppuccin_macchiato";
|
||||
"ui.background" = { };
|
||||
};
|
||||
catppuccin_mocha_transparent = {
|
||||
inherits = "catppuccin_mocha";
|
||||
"ui.background" = { };
|
||||
};
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
let
|
||||
tomlFormat = pkgs.formats.toml { };
|
||||
config = import ./config { pkgs = pkgs; };
|
||||
buildGrammar =
|
||||
grammar:
|
||||
let
|
||||
source = pkgs.fetchgit {
|
||||
inherit (grammar) url rev sha256;
|
||||
};
|
||||
linkQueries = pkgs.lib.optionalString (builtins.hasAttr "queries" grammar) "cp -r ${source}/${grammar.queries} $out/queries";
|
||||
in
|
||||
pkgs.stdenv.mkDerivation {
|
||||
pname = "helix-tree-sitter-grammar-${grammar.name}";
|
||||
version = grammar.rev;
|
||||
buildInputs = [
|
||||
pkgs.helix
|
||||
pkgs.git
|
||||
];
|
||||
src = source;
|
||||
dontInstall = true;
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
mkdir .helix
|
||||
cat << EOF > .helix/languages.toml
|
||||
use-grammars = { only = ["${grammar.name}"] }
|
||||
[[grammar]]
|
||||
name = "${grammar.name}"
|
||||
source = { git = "${grammar.url}", rev = "${grammar.rev}" }
|
||||
EOF
|
||||
|
||||
mkdir -p runtime/grammars/sources
|
||||
cp -r ${source} runtime/grammars/sources/${grammar.name}
|
||||
export CARGO_MANIFEST_DIR=$(pwd)/.helix
|
||||
|
||||
#hx -g fetch
|
||||
hx -g build
|
||||
|
||||
mkdir $out
|
||||
cp runtime/grammars/${grammar.name}.so $out/${grammar.name}.so
|
||||
${linkQueries}
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
};
|
||||
builtGrammars = builtins.map (grammar: {
|
||||
inherit (grammar) name;
|
||||
artifact = buildGrammar grammar;
|
||||
}) config.grammars;
|
||||
ignoreFile = pkgs.writeText "ignore" (builtins.concatStringsSep "\n" config.ignore);
|
||||
configFile = pkgs.writeText "config.toml" (
|
||||
builtins.readFile (tomlFormat.generate "helix-config" config.settings)
|
||||
);
|
||||
languageFile = pkgs.writeText "languages.toml" (
|
||||
builtins.readFile (tomlFormat.generate "helix-languages" config.languages)
|
||||
);
|
||||
themeFiles = pkgs.lib.mapAttrsToList (name: value: {
|
||||
inherit name;
|
||||
file = pkgs.writeText "${name}.toml" (
|
||||
builtins.readFile (tomlFormat.generate "helix-theme-${name}" value)
|
||||
);
|
||||
}) config.themes;
|
||||
themeLinks = builtins.map (
|
||||
theme: "ln -s ${theme.file} $out/home/helix/themes/${theme.name}.toml"
|
||||
) themeFiles;
|
||||
grammarLinks = builtins.map (
|
||||
grammar: "ln -s ${grammar.artifact}/${grammar.name}.so $out/lib/runtime/grammars/${grammar.name}.so"
|
||||
) builtGrammars;
|
||||
queryLinks = builtins.map (
|
||||
grammar: "ln -s ${grammar.artifact}/queries $out/lib/runtime/queries/${grammar.name}"
|
||||
) builtGrammars;
|
||||
helix =
|
||||
pkgs.runCommand "hx"
|
||||
{
|
||||
buildInputs = with pkgs; [
|
||||
makeWrapper
|
||||
];
|
||||
}
|
||||
''
|
||||
mkdir $out
|
||||
ln -s ${pkgs.helix}/* $out
|
||||
rm $out/bin
|
||||
|
||||
rm $out/lib
|
||||
mkdir -p $out/lib/runtime
|
||||
ln -s ${pkgs.helix}/lib/runtime/* $out/lib/runtime
|
||||
|
||||
rm $out/lib/runtime/grammars
|
||||
mkdir $out/lib/runtime/grammars
|
||||
ln -s ${pkgs.helix}/lib/runtime/grammars/* $out/lib/runtime/grammars
|
||||
${builtins.concatStringsSep "\n" grammarLinks}
|
||||
|
||||
rm $out/lib/runtime/queries
|
||||
mkdir $out/lib/runtime/queries
|
||||
ln -s ${pkgs.helix}/lib/runtime/queries/* $out/lib/runtime/queries
|
||||
${builtins.concatStringsSep "\n" queryLinks}
|
||||
|
||||
mkdir -p $out/home/helix/themes
|
||||
ln -s ${configFile} $out/home/helix/config.toml
|
||||
ln -s ${languageFile} $out/home/helix/languages.toml
|
||||
${builtins.concatStringsSep "\n" themeLinks}
|
||||
|
||||
mkdir -p $out/home/git
|
||||
ln -s ${ignoreFile} $out/home/git/ignore
|
||||
|
||||
makeWrapper ${pkgs.helix}/bin/hx $out/bin/hx \
|
||||
--set HELIX_RUNTIME $out/lib/runtime \
|
||||
--set XDG_CONFIG_HOME $out/home \
|
||||
'';
|
||||
in
|
||||
{
|
||||
inherit helix;
|
||||
default = helix;
|
||||
}
|
121
flake.nix
121
flake.nix
|
@ -7,116 +7,19 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
tomlFormat = pkgs.formats.toml { };
|
||||
config = import ./config.nix { pkgs = pkgs; };
|
||||
buildGrammar =
|
||||
grammar:
|
||||
let
|
||||
source = pkgs.fetchgit {
|
||||
inherit (grammar) url rev sha256;
|
||||
};
|
||||
linkQueries = pkgs.lib.optionalString (builtins.hasAttr "queries" grammar) "cp -r ${source}/${grammar.queries} $out/queries";
|
||||
in
|
||||
pkgs.stdenv.mkDerivation {
|
||||
pname = "helix-tree-sitter-grammar-${grammar.name}";
|
||||
version = grammar.rev;
|
||||
buildInputs = [
|
||||
pkgs.helix
|
||||
pkgs.git
|
||||
];
|
||||
src = source;
|
||||
dontInstall = true;
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
mkdir .helix
|
||||
cat << EOF > .helix/languages.toml
|
||||
use-grammars = { only = ["${grammar.name}"] }
|
||||
[[grammar]]
|
||||
name = "${grammar.name}"
|
||||
source = { git = "${grammar.url}", rev = "${grammar.rev}" }
|
||||
EOF
|
||||
|
||||
mkdir -p runtime/grammars/sources
|
||||
cp -r ${source} runtime/grammars/sources/${grammar.name}
|
||||
export CARGO_MANIFEST_DIR=$(pwd)/.helix
|
||||
|
||||
#hx -g fetch
|
||||
hx -g build
|
||||
|
||||
mkdir $out
|
||||
cp runtime/grammars/${grammar.name}.so $out/${grammar.name}.so
|
||||
${linkQueries}
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
};
|
||||
builtGrammars = builtins.map (grammar: {
|
||||
inherit (grammar) name;
|
||||
artifact = buildGrammar grammar;
|
||||
}) config.grammars;
|
||||
ignoreFile = pkgs.writeText "ignore" (builtins.concatStringsSep "\n" config.ignore);
|
||||
configFile = pkgs.writeText "config.toml" (
|
||||
builtins.readFile (tomlFormat.generate "helix-config" config.settings)
|
||||
);
|
||||
languageFile = pkgs.writeText "languages.toml" (
|
||||
builtins.readFile (tomlFormat.generate "helix-languages" config.languages)
|
||||
);
|
||||
themeFiles = pkgs.lib.mapAttrsToList (name: value: {
|
||||
inherit name;
|
||||
file = pkgs.writeText "${name}.toml" (
|
||||
builtins.readFile (tomlFormat.generate "helix-theme-${name}" value)
|
||||
);
|
||||
}) config.themes;
|
||||
themeLinks = builtins.map (
|
||||
theme: "ln -s ${theme.file} $out/home/helix/themes/${theme.name}.toml"
|
||||
) themeFiles;
|
||||
grammarLinks = builtins.map (
|
||||
grammar: "ln -s ${grammar.artifact}/${grammar.name}.so $out/lib/runtime/grammars/${grammar.name}.so"
|
||||
) builtGrammars;
|
||||
queryLinks = builtins.map (
|
||||
grammar: "ln -s ${grammar.artifact}/queries $out/lib/runtime/queries/${grammar.name}"
|
||||
) builtGrammars;
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"i686-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-linux"
|
||||
"armv6l-linux"
|
||||
"armv7l-linux"
|
||||
];
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs systems f;
|
||||
in
|
||||
{
|
||||
packages.x86_64-linux.default =
|
||||
pkgs.runCommand "hx"
|
||||
{
|
||||
buildInputs = with pkgs; [
|
||||
makeWrapper
|
||||
];
|
||||
}
|
||||
''
|
||||
mkdir $out
|
||||
ln -s ${pkgs.helix}/* $out
|
||||
rm $out/bin
|
||||
|
||||
rm $out/lib
|
||||
mkdir -p $out/lib/runtime
|
||||
ln -s ${pkgs.helix}/lib/runtime/* $out/lib/runtime
|
||||
|
||||
rm $out/lib/runtime/grammars
|
||||
mkdir $out/lib/runtime/grammars
|
||||
ln -s ${pkgs.helix}/lib/runtime/grammars/* $out/lib/runtime/grammars
|
||||
${builtins.concatStringsSep "\n" grammarLinks}
|
||||
|
||||
rm $out/lib/runtime/queries
|
||||
mkdir $out/lib/runtime/queries
|
||||
ln -s ${pkgs.helix}/lib/runtime/queries/* $out/lib/runtime/queries
|
||||
${builtins.concatStringsSep "\n" queryLinks}
|
||||
|
||||
mkdir -p $out/home/helix/themes
|
||||
ln -s ${configFile} $out/home/helix/config.toml
|
||||
ln -s ${languageFile} $out/home/helix/languages.toml
|
||||
${builtins.concatStringsSep "\n" themeLinks}
|
||||
|
||||
mkdir -p $out/home/git
|
||||
ln -s ${ignoreFile} $out/home/git/ignore
|
||||
|
||||
makeWrapper ${pkgs.helix}/bin/hx $out/bin/hx \
|
||||
--set HELIX_RUNTIME $out/lib/runtime \
|
||||
--set XDG_CONFIG_HOME $out/home \
|
||||
'';
|
||||
packages = forAllSystems (
|
||||
system: import ./default.nix { pkgs = import nixpkgs { inherit system; }; }
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue