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

View file

@ -1,4 +1,4 @@
{
allowUnfree = true;
allowUnsupportedSystem = true;
# allowUnsupportedSystem = true;
}

15
environment.nix Normal file
View file

@ -0,0 +1,15 @@
values: {
enableCpp = false;
enableData = false;
enableGo = false;
enableHtml = false;
enableJava = false;
enableJavascript = false;
enableLatex = false;
enableNix = false;
enablePython = false;
enableRust = false;
enableShell = false;
enableSpelling = false;
enableOffice = true;
} // values

13
home.nix Normal file
View file

@ -0,0 +1,13 @@
{ pkgs, lib, cfg, ... }:
let
hostname = lib.fileContents /etc/hostname;
user = builtins.getEnv "USER";
host_config = builtins.toPath "/home/${user}/.config/nixpkgs/${hostname}.nix";
in
{
nixpkgs.overlays = [
(import ./rice.nix)
];
imports = [host_config ];
programs.home-manager.enable = true;
}

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
]);
}

View file

@ -244,7 +244,7 @@
services.clamav = { daemon.enable = true; updater.enable = true; };
# Power-profiles
services.power-profiles.daemon.enable = true;
services.power-profiles-daemon.enable = true;
# Virtualisation
virtualisation = {

View file

@ -1,22 +1,30 @@
{ pkgs, lib, ... }:
let
nord = import ./themes/nord.nix;
onedark = import ./themes/onedark.nix;
in
{
nixpkgs.overlays = [
(import ./overlays/rice.nix)
(
final: prev: {
cocktail-bar-cli = final.callPackage ./custom/cocktail-bar-cli { };
update-background = final.callPackage ./custom/update-background { backgrounds_directory = "$HOME/Immagini/Sfondi/1080+/1440+"; };
lockscreen = final.callPackage ./custom/lockscreen {
palette = final.rice.colorPalette;
font = final.rice.font.normal;
};
}
) # Custom packges
(final: prev: {
devEnvironment = (import ./environment.nix) {
enableCpp = true;
enableData = true;
enableGo = true;
enableHtml = true;
enableJavascript = true;
enableJava = true;
enableLatex = true;
enableNix = true;
enableOffice = true;
enablePython = true;
enableRust = true;
enableShell = true;
enableSpelling = true;
};
cocktail-bar-cli = final.callPackage ./custom/cocktail-bar-cli { };
update-background = final.callPackage ./custom/update-background { backgrounds_directory = "$HOME/Immagini/Sfondi/1080+/1440+"; };
lockscreen = final.callPackage ./custom/lockscreen {
palette = final.rice.colorPalette;
font = final.rice.font.normal;
};
})
];
home = {
@ -42,9 +50,8 @@ in
discord
# evolution
file
# firefox
firefox
gallery-dl
gitkraken
gnome.dconf-editor
gnome.eog
gnome.evince
@ -75,7 +82,6 @@ in
jetbrains.datagrip
keepassxc
krita
libreoffice-fresh
# lutris
megacmd
mpv
@ -103,18 +109,6 @@ in
zoom-us
zotero
hunspellDicts.en_GB-large
hunspellDicts.en_US-large
hunspellDicts.it_IT
# (
# dwarf-fortress-packages.dwarf-fortress-full.override {
# enableLegendsBrowser = false;
# enableTextMode = true;
# theme = "phoebus";
# }
# )
(
retroarch.override {
cores = with pkgs.libretro; [
@ -146,13 +140,14 @@ in
./modules/gpg.nix
./modules/grobi.nix
./modules/info.nix
./modules/java.nix
# ./modules/joystickwake.nix
./modules/jq.nix
./modules/kakoune.nix
./modules/keep.nix
# ./modules/keepassxc.nix
./modules/keychain.nix
# ./modules/kitty.nix
./modules/latex.nix
./modules/lf.nix
./modules/libinput-gestures.nix
./modules/lorri.nix
@ -162,8 +157,8 @@ in
./modules/nix-index.nix
./modules/noti.nix
./modules/obs-studio.nix
./modules/office.nix
./modules/onedrive.nix
# ./modules/pazi.nix
# ./modules/picom.nix
# ./modules/polybar.nix
./modules/gtk_theme.nix
@ -178,17 +173,15 @@ in
./modules/update_background.nix
./modules/whatsapp.nix
# ./modules/xidlehook.nix
# ./modules/zathura.nix
./modules/zoxide.nix
./modules/zsh.nix
./modules/pro_audio.nix
./modules/security.nix
# ./modules/pro_audio.nix
# ./modules/security.nix
./modules/shell_aliases.nix
];
programs.home-manager.enable = true;
services = {
# blueman-applet.enable = true;
@ -196,7 +189,7 @@ in
# cbatticon.enable = true;
gnome-keyring.enable = true;
# network-manager-applet.enable = true;
playerctld.enable = true;
# playerctld.enable = true;
# poweralertd.enable = true;
};

View file

@ -6,8 +6,8 @@ let
sha256 = "1is70gjf59sxccwhz1hl9hdxsd4z8vqsr2rdk3imnmxj9n3jf6j8";
}
) {};
nord = with nix-rice; palette.tPalette color.hexToRgba (import ../themes/nord.nix);
onedark = import ../themes/onedark.nix;
nord = with nix-rice; palette.tPalette color.hexToRgba (import ./themes/nord.nix);
# onedark = with nix-rice; palette.tPalette color.hexToRgba (import ./themes/onedark.nix);
in
(
rec {