grimm-nixos-laptop/common/tooling/helix.nix

78 lines
1.6 KiB
Nix
Raw Normal View History

2024-05-30 22:12:15 +02:00
{
pkgs,
config,
lib,
...
}:
let
inherit (config.grimmShared) enable tooling;
inherit (lib)
mkOption
types
getExe
2024-08-15 14:59:23 +02:00
getExe'
2024-05-30 22:12:15 +02:00
mkIf
;
inherit (pkgs)
helix
symlinkJoin
writeTextDir
concatTextFile
makeWrapper
;
inherit (pkgs.writers) writeTOML;
conf-file-name = "config.toml";
lang-file-name = "languages.toml";
helix-conf = symlinkJoin {
name = "helix-conf";
paths = [
(concatTextFile {
name = "helix-conf-partial";
destination = "/${conf-file-name}";
files = [ (writeTOML conf-file-name config.programs.helix.config) ];
})
(writeTextDir lang-file-name ''
[[language]]
language-servers = ["nixd"]
name = "nix"
[language-server.nixd]
command = "${getExe pkgs.nixd}"
'')
];
};
2024-08-15 14:59:23 +02:00
2024-05-30 22:12:15 +02:00
helix-wrapped = pkgs.symlinkJoin {
name = helix.pname;
paths = [ helix ];
buildInputs = [ makeWrapper ];
postBuild = ''
wrapProgram $out/bin/${helix.meta.mainProgram} --add-flags "-c ${helix-conf}/${conf-file-name}"
'';
};
in
{
config = mkIf (enable && tooling.enable) {
environment.systemPackages = [ helix-wrapped ];
2024-08-15 14:59:23 +02:00
environment.sessionVariables.EDITOR = getExe' helix-wrapped "hx";
2024-05-30 22:12:15 +02:00
programs.helix.config = {
2024-05-31 17:33:40 +02:00
editor.cursor-shape.insert = "bar";
theme = "base16_transparent";
# editor.commands.git = ":sh git";
# keys.normal.Delete = "delete_selection";
2024-05-30 22:12:15 +02:00
};
};
options.programs.helix = {
config = mkOption {
type = types.attrs;
default = { };
description = "Helix configuration";
};
};
}