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

View file

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

View file

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