working helix module

This commit is contained in:
Charlie Root 2024-11-06 00:11:11 +01:00
commit 0f337213dc
Signed by: faukah
SSH key fingerprint: SHA256:jpYIt4Vkz1NBTQcks/N9OPTfTFxE6KF2W/rV7hrfrIw
4 changed files with 68 additions and 45 deletions

View file

@ -2,7 +2,7 @@
description = "My NixOS config flake"; description = "My NixOS config flake";
outputs = inputs: let outputs = inputs: let
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
user = import ./modules/user {inherit pkgs;}; user = import ./modules/user {inherit inputs pkgs;};
in { in {
nixosConfigurations = import ./hosts inputs; nixosConfigurations = import ./hosts inputs;
@ -11,13 +11,19 @@
formatter.x86_64-linux = pkgs.alejandra; formatter.x86_64-linux = pkgs.alejandra;
packages.x86_64-linux = user.packages; packages.x86_64-linux = user.packages;
apps.x86_64-linux.default = { apps.x86_64-linux = {
type = "app"; default = {
program = "${user.packages.fish}/bin/fish"; type = "app";
program = "${user.packages.fish}/bin/fish";
};
helix = {
type = "app";
program = "${user.packages.helix}/bin/hx";
};
}; };
nixosModules = { nixosModules = {
user = user.module; user = user.module;
shell = import ./modules/shell {inherit pkgs;}; # shell = import ./modules/shell {inherit pkgs;};
}; };
}; };
inputs = { inputs = {

View file

@ -28,6 +28,9 @@ inputs: let
modules = concatLists [ modules = concatLists [
# This is used to pre-emptively set the hostPlatform for nixpkgs. # This is used to pre-emptively set the hostPlatform for nixpkgs.
# Also, we set the system hostname here. # Also, we set the system hostname here.
[
self.nixosModules.user
]
(singleton { (singleton {
networking.hostName = args.hostname; networking.hostName = args.hostname;
nixpkgs.hostPlatform = mkDefault args.system; nixpkgs.hostPlatform = mkDefault args.system;

View file

@ -1,7 +1,11 @@
{pkgs, ...}: rec { {
inputs,
pkgs,
...
}: rec {
packages = { packages = {
fish = pkgs.callPackage ./shell {}; fish = pkgs.callPackage ./shell {};
# helix = pkgs.callPackge ./helix {}; helix = pkgs.callPackage ./helix {inherit (inputs.helix.packages.${pkgs.stdenv.system}) helix;};
kakoune = pkgs.callPackage ./kakoune {}; kakoune = pkgs.callPackage ./kakoune {};
}; };
shell = pkgs.mkShell { shell = pkgs.mkShell {
@ -10,8 +14,9 @@
}; };
module = { module = {
config = { config = {
environment.systemPackages = [ environment.systemPackages = with packages; [
shell fish
helix
]; ];
}; };
}; };

View file

@ -1,14 +1,32 @@
{ {
config, symlinkJoin,
inputs, makeWrapper,
helix,
gdb,
black,
cmake-format,
tinymist,
lib, lib,
pkgs, marksman,
lldb_19,
stdenv,
shellcheck,
formats,
lazygit,
deno,
shfmt,
bash-language-server,
clang-tools,
cmake-language-server,
dprint,
nil,
alejandra,
pyright,
typescript-language-server,
... ...
}: let }: let
cfg = config.modules.system.programs.editors.helix; inherit (lib) getExe;
inherit (lib) mkIf getExe; toml = formats.toml {};
inherit (inputs.helix.packages.${pkgs.stdenv.system}) helix;
toml = pkgs.formats.toml {};
helix-config = { helix-config = {
theme = "catppuccin_mocha"; theme = "catppuccin_mocha";
editor = { editor = {
@ -43,7 +61,7 @@
}; };
keys = { keys = {
normal = { normal = {
space.g = [":new" ":insert-output XDG_CONFIG_HOME=~/.config ${getExe pkgs.lazygit}" ":buffer-close!" ":redraw"]; space.g = [":new" ":insert-output XDG_CONFIG_HOME=~/.config ${getExe lazygit}" ":buffer-close!" ":redraw"];
esc = ["collapse_selection" "keep_primary_selection" "normal_mode"]; esc = ["collapse_selection" "keep_primary_selection" "normal_mode"];
A-H = "goto_previous_buffer"; A-H = "goto_previous_buffer";
A-L = "goto_next_buffer"; A-L = "goto_next_buffer";
@ -62,7 +80,7 @@
helix-languages = { helix-languages = {
language = let language = let
extraFormatter = lang: { extraFormatter = lang: {
command = getExe pkgs.deno; command = getExe deno;
args = ["fmt" "-" "--ext" lang]; args = ["fmt" "-" "--ext" lang];
}; };
in [ in [
@ -70,7 +88,7 @@
name = "bash"; name = "bash";
auto-format = true; auto-format = true;
formatter = { formatter = {
command = getExe pkgs.shfmt; command = getExe shfmt;
args = ["-i" "2"]; args = ["-i" "2"];
}; };
} }
@ -84,7 +102,7 @@
auto-format = true; auto-format = true;
language-servers = ["cmake-language-server"]; language-servers = ["cmake-language-server"];
formatter = { formatter = {
command = getExe pkgs.cmake-format; command = getExe cmake-format;
args = ["-"]; args = ["-"];
}; };
} }
@ -106,7 +124,7 @@
name = "python"; name = "python";
language-servers = ["pyright"]; language-servers = ["pyright"];
formatter = { formatter = {
command = getExe pkgs.black; command = getExe black;
args = ["-" "--quiet" "--line-length 100"]; args = ["-" "--quiet" "--line-length 100"];
}; };
} }
@ -118,7 +136,7 @@
{ {
name = "rust"; name = "rust";
debugger = { debugger = {
command = "${pkgs.lldb_19}/bin/lldb-dap"; command = "${lldb_19}/bin/lldb-dap";
name = "lldb"; name = "lldb";
transport = "stdio"; transport = "stdio";
templates = [ templates = [
@ -143,7 +161,7 @@
name = "c"; name = "c";
debugger = { debugger = {
name = "gdb"; name = "gdb";
command = "${pkgs.gdb}/bin/gdb"; command = getExe gdb;
transport = "stdio"; transport = "stdio";
templates = [ templates = [
{ {
@ -167,36 +185,32 @@
language-server = { language-server = {
bash-language-server = { bash-language-server = {
command = getExe pkgs.bash-language-server; command = getExe bash-language-server;
args = ["start"]; args = ["start"];
}; };
clangd = { clangd = {
command = "${pkgs.clang-tools}/bin/clangd"; command = "${clang-tools}/bin/clangd";
clangd.fallbackFlags = ["-std=c++2b"]; clangd.fallbackFlags = ["-std=c++2b"];
}; };
cmake-language-server = { cmake-language-server = {
command = getExe pkgs.cmake-language-server; command = getExe cmake-language-server;
}; };
dprint = { dprint = {
command = getExe pkgs.dprint; command = getExe dprint;
args = ["lsp"]; args = ["lsp"];
}; };
nil = { nil = {
command = getExe pkgs.nil; command = getExe nil;
# alejandro # alejandro
config.nil.formatting.command = ["${getExe pkgs.alejandra}" "-q"]; config.nil.formatting.command = ["${getExe alejandra}" "-q"];
};
qmlls = {
command = "${pkgs.kdePackages.full}/bin/qmlls";
}; };
pyright = { pyright = {
command = "${pkgs.pyright}/bin/pyright-langserver"; command = "${pyright}/bin/pyright-langserver";
args = ["--stdio"]; args = ["--stdio"];
config = { config = {
reportMissingTypeStubs = false; reportMissingTypeStubs = false;
@ -208,7 +222,7 @@
}; };
typescript-language-server = { typescript-language-server = {
command = getExe pkgs.typescript-language-server; command = getExe typescript-language-server;
args = ["--stdio"]; args = ["--stdio"];
config = let config = let
inlayHints = { inlayHints = {
@ -237,9 +251,9 @@
}; };
}; };
}; };
wrapped-helix = pkgs.symlinkJoin { wrapped-helix = symlinkJoin {
name = "helix-wrapped"; name = "helix-wrapped";
paths = with pkgs; [ paths = [
helix helix
# typst lsp # typst lsp
@ -260,7 +274,7 @@
# Shell # Shell
shellcheck shellcheck
]; ];
buildInputs = [pkgs.makeWrapper]; buildInputs = [makeWrapper];
postBuild = '' postBuild = ''
mkdir -p $out/config/helix mkdir -p $out/config/helix
cp "${toml.generate "config.toml" helix-config}" $out/config/helix/config.toml cp "${toml.generate "config.toml" helix-config}" $out/config/helix/config.toml
@ -269,10 +283,5 @@
XDG_CONFIG_HOME $out/config XDG_CONFIG_HOME $out/config
''; '';
}; };
in { in
config = mkIf cfg.enable { wrapped-helix
environment.systemPackages = [
wrapped-helix
];
};
}