grimm-nixos-laptop/common/tooling/c.nix
2024-05-30 22:12:15 +02:00

67 lines
1.2 KiB
Nix

{
pkgs,
config,
lib,
...
}:
let
lang_support_id = "c";
inherit (config.grimmShared) enable tooling graphical;
inherit (lib)
optionals
mkIf
getExe'
types
mkOption
elem
;
in
{
config = mkIf (enable && tooling.enable && (elem lang_support_id tooling.supportedLangs)) {
environment.systemPackages =
with pkgs;
[
util-linux
linuxPackages.perf
pkg-config
glib
glibc
clang
clang-tools
cmake
]
++ optionals graphical [
libva-utils
jetbrains.clion
];
environment.sessionVariables.CMAKE_EXPORT_COMPILE_COMMANDS = "1";
grimmShared.tooling.lang_servers = [
{
lsp = {
package = pkgs.clang-tools;
};
fmt = rec {
package = pkgs.clang-tools;
command = getExe' package "clang-format";
includes = [
"*.c"
"*.h"
"*.cpp"
"*.hpp"
];
};
}
{
lsp = {
package = pkgs.cmake-language-server;
};
}
];
};
options.grimmShared.tooling.supportedLangs = mkOption {
type = types.listOf (types.enum [ lang_support_id ]);
};
}