From b4571fbe53bbf8ed2c4c6791593c726e5fc5be04 Mon Sep 17 00:00:00 2001 From: Filippo Berto Date: Mon, 25 Oct 2021 23:29:23 +0200 Subject: [PATCH] Host based configuration --- config.nix | 2 +- environment.nix | 15 ++++++++ home.nix | 13 +++++++ modules/java.nix | 4 ++ modules/kakoune.nix | 59 +++++++++++------------------- modules/latex.nix | 6 +++ modules/office.nix | 11 ++++++ nixos/base.nix | 2 +- odin.nix | 69 ++++++++++++++++------------------- overlays/rice.nix => rice.nix | 4 +- 10 files changed, 106 insertions(+), 79 deletions(-) create mode 100644 environment.nix create mode 100644 home.nix create mode 100644 modules/java.nix create mode 100644 modules/latex.nix create mode 100644 modules/office.nix rename overlays/rice.nix => rice.nix (92%) diff --git a/config.nix b/config.nix index 7e0a949..e947658 100644 --- a/config.nix +++ b/config.nix @@ -1,4 +1,4 @@ { allowUnfree = true; - allowUnsupportedSystem = true; +# allowUnsupportedSystem = true; } diff --git a/environment.nix b/environment.nix new file mode 100644 index 0000000..112b4f8 --- /dev/null +++ b/environment.nix @@ -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 diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..1710386 --- /dev/null +++ b/home.nix @@ -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; +} diff --git a/modules/java.nix b/modules/java.nix new file mode 100644 index 0000000..0a78d8a --- /dev/null +++ b/modules/java.nix @@ -0,0 +1,4 @@ +{ pkgs, ...}: +{ + programs.java.enable = pkgs.devEnvironment.enableJava ? false; +} diff --git a/modules/kakoune.nix b/modules/kakoune.nix index fb52b9b..9677764 100644 --- a/modules/kakoune.nix +++ b/modules/kakoune.nix @@ -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"] diff --git a/modules/latex.nix b/modules/latex.nix new file mode 100644 index 0000000..8ef3b29 --- /dev/null +++ b/modules/latex.nix @@ -0,0 +1,6 @@ +{ pkgs, lib, ...}: +{ + home.packages = lib.optionals pkgs.devEnvironment.enableLatex [ + pkgs.texlive.combined.scheme-full + ]; +} diff --git a/modules/office.nix b/modules/office.nix new file mode 100644 index 0000000..4d82238 --- /dev/null +++ b/modules/office.nix @@ -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 + ]); +} diff --git a/nixos/base.nix b/nixos/base.nix index 175b1bf..e22e1fe 100644 --- a/nixos/base.nix +++ b/nixos/base.nix @@ -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 = { diff --git a/odin.nix b/odin.nix index b1f869c..1317069 100644 --- a/odin.nix +++ b/odin.nix @@ -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; }; diff --git a/overlays/rice.nix b/rice.nix similarity index 92% rename from overlays/rice.nix rename to rice.nix index 0709f0c..bed7ec7 100644 --- a/overlays/rice.nix +++ b/rice.nix @@ -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 {