Host based configuration

This commit is contained in:
Filippo Berto 2021-10-25 23:29:23 +02:00
parent 1502fa1e36
commit b4571fbe53
10 changed files with 106 additions and 79 deletions

4
modules/java.nix Normal file
View file

@ -0,0 +1,4 @@
{ pkgs, ...}:
{
programs.java.enable = pkgs.devEnvironment.enableJava ? false;
}

View file

@ -1,21 +1,6 @@
{ config, lib, pkgs, ... }:
let
strPalette = with pkgs.rice; palette.toRgbShortHex colorPalette;
cfg = {
enableCppSupport = true;
enableDataSupport = true;
enableGoSupport = true;
enableHtmlSupport = true;
enableJavascriptSupport = true;
enableLatexSupport = true;
enableNixSupport = true;
enablePythonSupport = true;
enableRustSupport = true;
enableShellSupport = true;
enableSpellingSupport = true;
};
packages = with pkgs; [
(makeDesktopItem
{
@ -33,32 +18,32 @@ let
# editorconfig-core-c
python3.pkgs.editorconfig
] ++ (
lib.optionals cfg.enableCppSupport [
lib.optionals (pkgs.devEnvironment.enableCpp) [
clang-tools
]
) ++ (
lib.optionals cfg.enableDataSupport [
lib.optionals (pkgs.devEnvironment.enableData) [
yaml-language-server
nodePackages.vscode-langservers-extracted
]
) ++ (
lib.optionals cfg.enableHtmlSupport [
lib.optionals (pkgs.devEnvironment.enableHtml) [
nodePackages.vscode-langservers-extracted
]
) ++ (
lib.optionals cfg.enableJavascriptSupport [
lib.optionals (pkgs.devEnvironment.enableJavascript) [
flow
]
) ++ (
lib.optionals cfg.enableLatexSupport [
lib.optionals (pkgs.devEnvironment.enableLatex) [
texlab
]
) ++ (
lib.optionals cfg.enableNixSupport [
lib.optionals (pkgs.devEnvironment.enableNix) [
rnix-lsp
]
) ++ (
with python3.pkgs; lib.optionals cfg.enablePythonSupport [
with python3.pkgs; lib.optionals (pkgs.devEnvironment.enablePython) [
black
# pyls-black
pyls-flake8
@ -67,7 +52,7 @@ let
python-lsp-server
]
) ++ (
lib.optionals cfg.enableRustSupport [
lib.optionals (pkgs.devEnvironment.enableRust) [
cargo
cargo-watch
clippy
@ -76,11 +61,11 @@ let
rustfmt
]
) ++ (
lib.optionals cfg.enableShellSupport [
lib.optionals (pkgs.devEnvironment.enableShell) [
nodePackages.bash-language-server
]
) ++ (
lib.optionals cfg.enableSpellingSupport [
lib.optionals (pkgs.devEnvironment.enableSpelling) [
aspell
aspellDicts.en
aspellDicts.en-computers
@ -154,12 +139,12 @@ in
{ name = "ModuleLoaded"; option = "powerline"; commands = builtins.concatStringsSep "\n" [ "powerline-enable" ]; }
# { name = "WinSetOption"; option = "filetype=(rust|python|c|cpp|latex|javascript|go|nix)"; commands = builtins.concatStringsSep "\n" [ "lsp-enable-window" ]; }
] ++ (
lib.optionals cfg.enableLatexSupport [
lib.optionals (pkgs.devEnvironment.enableLatex) [
{ name = "BufSetOption"; option = "filetype=latex"; commands = "set-option buffer formatcmd ${texlive.bin.latexindent}/bin/latexindent"; }
]
) ++ (
lib.optionals cfg.enableDataSupport [
lib.optionals (pkgs.devEnvironment.enableData) [
{ name = "BufSetOption"; option = "filetype=(markdown|html|json|yaml|css|scss|less)"; commands = "set-option buffer formatcmd ${nodePackages.prettier}/bin/prettier"; }
]
);
@ -232,7 +217,7 @@ in
''
]
++ (
lib.optional cfg.enableCppSupport ''
lib.optional (pkgs.devEnvironment.enableCpp) ''
[language.c_cpp]
filetypes = ["c", "cpp"]
roots = ["compile_commands.json", ".clangd"]
@ -240,7 +225,7 @@ in
offset_encoding = "utf-8"
''
) ++ (
lib.optional cfg.enableDataSupport ''
lib.optional (pkgs.devEnvironment.enableData) ''
[language.json]
filetypes = ["json"]
roots = ["package.json"]
@ -258,7 +243,7 @@ in
yaml.format.enable = true
''
) ++ (
lib.optional cfg.enableGoSupport ''
lib.optional (pkgs.devEnvironment.enableGo) ''
[language.go]
filetypes = ["go"]
roots = ["Gopkg.toml", "go.mod", ".git", ".hg"]
@ -271,7 +256,7 @@ in
''
)
++ (
lib.optional cfg.enableHtmlSupport ''
lib.optional (pkgs.devEnvironment.enableHtml) ''
[language.html]
filetypes = ["html"]
roots = ["package.json"]
@ -297,7 +282,7 @@ in
args = ["--stdio"]
''
) ++ (
lib.optional cfg.enableJavascriptSupport ''
lib.optional (pkgs.devEnvironment.enableJavascript) ''
[language.javascript]
filetypes = ["javascript"]
roots = [".flowconfig"]
@ -305,7 +290,7 @@ in
args = ["lsp"]
''
) ++ (
lib.optional cfg.enableLatexSupport ''
lib.optional (pkgs.devEnvironment.enableLatex) ''
[language.latex]
filetypes = ["latex"]
roots = [".git"]
@ -316,14 +301,14 @@ in
bibtexFormatter = "${texlab}/bin/texlab"
''
) ++ (
lib.optional cfg.enableNixSupport ''
lib.optional (pkgs.devEnvironment.enableNix) ''
[language.nix]
filetypes = ["nix"]
roots = ["flake.nix", "shell.nix", ".git"]
command = "${rnix-lsp}/bin/rnix-lsp"
''
) ++ (
lib.optional cfg.enablePythonSupport ''
lib.optional (pkgs.devEnvironment.enablePython) ''
[language.python]
filetypes = ["python"]
roots = ["requirements.txt", "setup.py", ".git", ".hg"]
@ -335,7 +320,7 @@ in
# "pyls.configurationSources" = ["flake8"]
''
) ++ (
lib.optional cfg.enableRustSupport ''
lib.optional (pkgs.devEnvironment.enableRust) ''
[language.rust]
filetypes = ["rust"]
roots = ["Cargo.toml"]
@ -354,7 +339,7 @@ in
# See https://github.com/rust-analyzer/rust-analyzer/issues/6448
''
) ++ (
lib.optional cfg.enableShellSupport ''
lib.optional (pkgs.devEnvironment.enableShell) ''
[language.bash]
filetypes = ["sh"]
roots = [".git", ".hg"]

6
modules/latex.nix Normal file
View file

@ -0,0 +1,6 @@
{ pkgs, lib, ...}:
{
home.packages = lib.optionals pkgs.devEnvironment.enableLatex [
pkgs.texlive.combined.scheme-full
];
}

11
modules/office.nix Normal file
View file

@ -0,0 +1,11 @@
{pkgs, lib,...}:
with pkgs;
{
home.packages = (lib.optionals pkgs.devEnvironment.enableOffice [
libreoffice-fresh
]) ++ (lib.optionals pkgs.devEnvironment.enableSpelling [
hunspellDicts.en_GB-large
hunspellDicts.en_US-large
hunspellDicts.it_IT
]);
}