Compare commits

..

3 Commits

Author SHA1 Message Date
3d88a303bd
automaitcally select treefmt config 2024-05-16 11:59:05 +02:00
a791b41455
fmt support 2024-05-15 23:24:35 +02:00
7b2265b906
Add more lsp support, completions in nvim via coq 2024-05-15 17:49:05 +02:00
13 changed files with 341 additions and 64 deletions

View File

@ -13,7 +13,6 @@ let
getExe getExe
optionals optionals
mkIf mkIf
concatLines
; ;
in in
{ {
@ -22,6 +21,9 @@ in
./nix.nix ./nix.nix
./security.nix ./security.nix
./python.nix ./python.nix
./rust.nix
./nvim.nix
./lsp.nix
]; ];
config = mkIf (enable && tooling.enable) { config = mkIf (enable && tooling.enable) {
@ -34,15 +36,13 @@ in
(writeShellScriptBin "silent-add" "git add --intent-to-add $@ ; git update-index --assume-unchanged $@") (writeShellScriptBin "silent-add" "git add --intent-to-add $@ ; git update-index --assume-unchanged $@")
urlencode urlencode
rfindup
pstree pstree
dos2unix
treefmt
file file
wget wget
hyfetch hyfetch
util-linux util-linux
btop btop
neovim-remote
linuxPackages.perf linuxPackages.perf
eza eza
@ -82,7 +82,6 @@ in
config = { config = {
init.defaultBranch = "main"; init.defaultBranch = "main";
credential.username = tooling.git_user; credential.username = tooling.git_user;
core.editor = getExe pkgs.neovim;
user.name = tooling.git_user; user.name = tooling.git_user;
user.email = tooling.git_email; user.email = tooling.git_email;
push.autoSetupRemote = true; push.autoSetupRemote = true;
@ -113,46 +112,9 @@ in
services.dbus.implementation = "broker"; services.dbus.implementation = "broker";
grimmShared.tooling.nvim = {
plugins = with pkgs.vimPlugins; [
fugitive
nvim-lspconfig
];
};
boot.tmp.cleanOnBoot = true; boot.tmp.cleanOnBoot = true;
zramSwap.enable = true; zramSwap.enable = true;
programs.neovim = {
enable = true;
viAlias = true;
defaultEditor = true;
configure = {
customRC =
let
luarc = pkgs.writeText "init.lua" (concatLines tooling.nvim.extraLuaRC);
in
''
set number
set hidden
set fileencodings=utf-8
set nocompatible
set clipboard+=unnamedplus
set ff=unix
luafile ${luarc}
if filereadable($HOME . "/.vimrc")
source ~/.vimrc
endif
'';
packages.myVimPackage = {
start = tooling.nvim.plugins;
opt = [ ];
};
};
};
programs.ssh = { programs.ssh = {
startAgent = true; startAgent = true;
enableAskPassword = graphical; enableAskPassword = graphical;
@ -163,21 +125,6 @@ in
options.grimmShared.tooling = { options.grimmShared.tooling = {
enable = mkEnableOption "grimm-tooling"; enable = mkEnableOption "grimm-tooling";
nvim = {
plugins = mkOption {
type = types.listOf types.package;
default = [ ];
description = "Extra vim plugins to include";
};
extraLuaRC = mkOption {
type = types.listOf types.nonEmptyStr;
default = [ ];
description = "Extra init LUA scripts";
};
};
git_user = mkOption { git_user = mkOption {
type = types.str; type = types.str;
default = "Grimmauld"; default = "Grimmauld";

139
common/tooling/lsp.nix Normal file
View File

@ -0,0 +1,139 @@
{
pkgs,
config,
lib,
...
}:
let
inherit (config.grimmShared) enable tooling;
inherit (lib)
mkOption
types
mkIf
getName
mkEnableOption
getExe
filter
optionalString
concatLines
;
conf_def =
fmt:
(
''
[formatter.${getName fmt.package}]
command = "${getExe fmt.package}"
includes = ${builtins.toJSON fmt.includes}
''
+ (optionalString (fmt.options != [ ]) "options = ${builtins.toJSON fmt.options}\n")
);
treefmt_conf = pkgs.writeText "treefmt.toml" (
concatLines (map (v: (conf_def v.fmt)) (filter (v: !isNull v.fmt) tooling.lang_servers))
);
find_conf = pkgs.writeShellScriptBin "find-treefmt-conf" "(${getExe pkgs.rfindup} treefmt.toml -e 2>/dev/null || echo ${treefmt_conf}) | tr -d '\n'";
in
{
config = mkIf (enable && tooling.enable) {
environment.systemPackages =
[
pkgs.treefmt
pkgs.findup
pkgs.gnused
]
++ (map (v: v.lsp.package) (filter (v: !isNull v.lsp) tooling.lang_servers))
++ (map (v: v.fmt.package) (filter (v: !isNull v.fmt) tooling.lang_servers));
# environment.shellAliases."treefmt" = "${getExe pkgs.treefmt} --config-file ${treefmt_conf}";
environment.shellAliases."treefmt" = "${getExe pkgs.treefmt} --config-file $(${getExe find_conf})";
grimmShared.tooling.nvim.extraLuaRC =
[ "vim.g.coq_settings = { auto_start = 'shut-up' }" ]
++ (map (
v:
"require'lspconfig'.${v.lsp.lspconf_mod_name}.setup(require('coq').lsp_ensure_capabilities(${v.lsp.lspconf_config}))"
) (filter (v: !isNull v.lsp && v.lsp.vimIntegration) tooling.lang_servers));
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [
nvim-lspconfig
coq_nvim
coq-artifacts
];
};
options.grimmShared.tooling.lang_servers = mkOption {
type = types.listOf (
types.submodule {
options = {
lsp = mkOption {
type = types.nullOr (
types.submodule (
{ config, ... }:
{
options = {
lspconf_mod_name = mkOption {
type = types.nullOr types.nonEmptyStr;
default = getName config.package;
description = "lspconfig module name";
};
lspconf_config = mkOption {
type = types.nonEmptyStr;
default = "{}";
description = "options to pass to lspconfig";
};
package = mkOption {
type = types.package;
default = null;
description = "LSP package";
};
vimIntegration = mkEnableOption "Enable coq/nvim-lspconfig integration" // {
default = true;
};
};
}
)
);
};
fmt = mkOption {
type = types.nullOr (
types.submodule (
{ config, ... }:
{
options = {
package = mkOption {
type = types.package;
description = "FMT package";
};
options = mkOption {
type = types.listOf types.nonEmptyStr;
default = [ ];
};
includes = mkOption {
type = types.listOf types.nonEmptyStr;
default = [ ];
};
command = mkOption {
type = types.nonEmptyStr;
default = getExe config.package;
};
};
}
)
);
};
};
}
);
default = { };
description = "Language servers available on the system";
};
}

View File

@ -6,7 +6,6 @@
(writeShellScriptBin "rebuild" "bash -c \"nixos-rebuild switch |& nom\"") (writeShellScriptBin "rebuild" "bash -c \"nixos-rebuild switch |& nom\"")
nixpkgs-review nixpkgs-review
nixpkgs-fmt
nixfmt-rfc-style nixfmt-rfc-style
nixd nixd
nixpkgs-hammering nixpkgs-hammering
@ -18,9 +17,19 @@
environment.sessionVariables = lib.mkIf pkgs.config.allowUnfree { NIXPKGS_ALLOW_UNFREE = "1"; }; environment.sessionVariables = lib.mkIf pkgs.config.allowUnfree { NIXPKGS_ALLOW_UNFREE = "1"; };
grimmShared.tooling.nvim.extraLuaRC = lib.singleton '' grimmShared.tooling.nvim = {
require'lspconfig'.nixd.setup{} plugins = with pkgs.vimPlugins; [ vim-nix ];
''; };
grimmShared.tooling.lang_servers = [
{
lsp.package = pkgs.nixd;
fmt = {
package = pkgs.nixpkgs-fmt;
includes = [ "*.nix" ];
};
}
];
nix.settings = { nix.settings = {
experimental-features = [ experimental-features = [

73
common/tooling/nvim.nix Normal file
View File

@ -0,0 +1,73 @@
{
pkgs,
config,
lib,
...
}:
let
inherit (config.grimmShared) enable tooling;
inherit (lib)
mkOption
types
getExe
mkIf
concatLines
;
in
{
config = mkIf (enable && tooling.enable) {
environment.systemPackages = with pkgs; [
dos2unix
neovim-remote
];
programs.git.config.core.editor = getExe pkgs.neovim;
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ fugitive ];
programs.neovim = {
enable = true;
viAlias = true;
defaultEditor = true;
withPython3 = true;
configure = {
customRC =
let
luarc = pkgs.writeText "init.lua" (concatLines tooling.nvim.extraLuaRC);
in
''
set number
set hidden
set fileencodings=utf-8
set nocompatible
set clipboard+=unnamedplus
set ff=unix
luafile ${luarc}
if filereadable($HOME . "/.vimrc")
source ~/.vimrc
endif
'';
packages.myVimPackage = {
start = tooling.nvim.plugins;
opt = [ ];
};
};
};
};
options.grimmShared.tooling.nvim = {
plugins = mkOption {
type = types.listOf types.package;
default = [ ];
description = "Extra vim plugins to include";
};
extraLuaRC = mkOption {
type = types.listOf types.nonEmptyStr;
default = [ ];
description = "Extra init LUA scripts";
};
};
}

View File

@ -25,10 +25,21 @@ in
enable = true; enable = true;
config = lib.concatLines ( config = lib.concatLines (
lib.mapAttrsToList ( lib.mapAttrsToList (
name: value: ''aliases["${name}"] = "${value}"'' name: value: "aliases[\"${name}\"] = '''${value}'''"
) config.environment.shellAliases ) config.environment.shellAliases
); );
package = pkgs.xonsh.wrapper.override { extraPackages = pyLibs; }; package = pkgs.xonsh.wrapper.override { extraPackages = pyLibs; };
}; };
grimmShared.tooling.lang_servers = [
{
lsp.package = pkgs.pyright;
fmt = {
package = pkgs.yapf;
includes = [ "*.py" ];
options = [ "-i" ];
};
}
];
}; };
} }

29
common/tooling/rust.nix Normal file
View File

@ -0,0 +1,29 @@
{
pkgs,
lib,
config,
...
}:
let
inherit (config.grimmShared) enable tooling graphical;
in
{
config = lib.mkIf (enable && tooling.enable) {
environment.systemPackages =
with pkgs;
[ pkg-config ] ++ lib.optionals graphical [ jetbrains.clion ];
grimmShared.tooling.lang_servers = [
{
lsp = {
package = pkgs.rust-analyzer;
lspconf_mod_name = "rust_analyzer";
};
fmt = {
package = pkgs.rustfmt;
includes = [ "*.rs" ];
};
}
];
};
}

View File

@ -52,7 +52,10 @@ in
XDG_CONFIG_HOME = "$HOME/.config"; XDG_CONFIG_HOME = "$HOME/.config";
}; };
environment.systemPackages = with pkgs; [ xwaylandvideobridge ]; environment.systemPackages = with pkgs; [
xwaylandvideobridge
confwhich
];
}; };
options.grimmShared.portals = mkEnableOption "Enables portals for wlr, gtk and kde as well as fixes fonts"; options.grimmShared.portals = mkEnableOption "Enables portals for wlr, gtk and kde as well as fixes fonts";

View File

@ -0,0 +1,28 @@
{
lib,
rustPlatform,
fetchFromGitea,
}:
rustPlatform.buildRustPackage {
pname = "confwhich";
version = "unstable-2024-05-14";
src = fetchFromGitea {
domain = "git.grimmauld.de";
owner = "Grimmauld";
repo = "confwhich";
rev = "e561b82d1e2b0d0998ccbef316014297f3468fb6";
hash = "sha256-dMkUJMQjlKzmSsgtH0xOZ5Bk654+h84M1cTx8hVM5SQ=";
};
cargoHash = "sha256-cn9vtRO+negpIVs0rnp2y5q7L4w554dfBK9MtbWd8FA=";
meta = {
description = "tool to find the path of xdg config files";
homepage = "https://git.grimmauld.de/Grimmauld/confwhich";
license = lib.licenses.bsd3;
mainProgram = "confwhich";
maintainers = with lib.maintainers; [ grimmauld ];
platforms = lib.platforms.linux;
};
}

View File

@ -0,0 +1,28 @@
{
lib,
rustPlatform,
fetchFromGitea,
}:
rustPlatform.buildRustPackage {
pname = "rfindup";
version = "unstable-2024-05-16";
src = fetchFromGitea {
domain = "git.grimmauld.de";
owner = "Grimmauld";
repo = "rfindup";
rev = "fe2c39e74c667593896ce03033cccdffda6b288d";
hash = "sha256-N23sKOfir07WIFbjdHNku7nLTtRd7A5tfs7kvdeCyeU=";
};
cargoHash = "sha256-MD7ViPWkL/aYECWj1f+NdVrPVwwFTd8GyyKSUUgXXHE=";
meta = {
description = "tool to find files by name in parent directories";
homepage = "https://git.grimmauld.de/Grimmauld/rfindup";
license = lib.licenses.bsd3;
mainProgram = "rfindup";
maintainers = with lib.maintainers; [ grimmauld ];
platforms = lib.platforms.linux;
};
}

View File

@ -31,7 +31,7 @@ let
{ {
# xonsh update # xonsh update
url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/305316.patch"; url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/305316.patch";
hash = "sha256-/OSbAur16Q1XZ/Nhf8VAzaQ3gqbaxWkQlf5G4UWKnh8="; hash = "sha256-W3jh6qRA/7V1fImLm3vRmaT6h6gL5rlNBUuIidZHaZc=";
} }
]; ];

4
overlays/confwhich.nix Normal file
View File

@ -0,0 +1,4 @@
{ prev, ... }:
{
confwhich = prev.callPackage ../custom/confwhich/package.nix { };
}

View File

@ -28,5 +28,7 @@
./mcontrolcenter.nix ./mcontrolcenter.nix
./ccache-wrapper.nix ./ccache-wrapper.nix
./searchclip.nix ./searchclip.nix
./confwhich.nix
./rfindup.nix
]; ];
} }

4
overlays/rfindup.nix Normal file
View File

@ -0,0 +1,4 @@
{ prev, ... }:
{
rfindup = prev.callPackage ../custom/rfindup/package.nix { };
}