From a34c9e4ef5e261a54a8ddbe1c23f7010ff5dfd0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 30 Mar 2022 10:55:57 +0200 Subject: [PATCH] :sparkles: make editors more modular --- flake.nix | 3 +++ modules/editors/code.nix | 31 ++++++++++++++++++------------- modules/editors/default.nix | 25 +------------------------ modules/editors/emacs.nix | 29 +++++++++++++++++++++++------ modules/editors/idea.nix | 10 +++++++++- modules/editors/vim.nix | 17 ++++++++++++++++- overlays/default.nix | 1 + 7 files changed, 71 insertions(+), 45 deletions(-) diff --git a/flake.nix b/flake.nix index e8a38ce..9273df7 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,9 @@ url = "github:wfxr/forgit"; flake = false; }; + + # VSCode plugin + nix-flake-tools.url = "github:rastertail/nix-flake-tools"; }; outputs = inputs@{ self, agenix, home-manager, nixpkgs, utils, ... }: diff --git a/modules/editors/code.nix b/modules/editors/code.nix index 3eb00e6..18f720f 100644 --- a/modules/editors/code.nix +++ b/modules/editors/code.nix @@ -1,24 +1,29 @@ { config, lib, pkgs, ... }: +with lib; let cfg = config.modules.editors; in { - config = lib.mkIf cfg.code { + options.modules.editors = { + code = mkOption { + default = false; + type = types.bool; + example = true; + }; + }; + config = mkIf cfg.code { home-manager.users.moritz = { programs.vscode = { enable = true; package = pkgs.vscode-fhsWithPackages (ps: with ps; [ git ]); - extensions = with pkgs.vscode-extensions; - [ - vscodevim.vim - dracula-theme.theme-dracula - esbenp.prettier-vscode - pkief.material-icon-theme - ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [{ - name = "copilot"; - publisher = "GitHub"; - version = "1.7.3689"; - sha256 = "16zrrymxfymc0039zf48vm22rxjs22mh9zkvkpg45grx2a2m19zh"; - }]; + extensions = with pkgs.vscode-extensions; [ + bbenoist.nix + dracula-theme.theme-dracula + esbenp.prettier-vscode + github.copilot + pkgs.nix-flake-tools + pkief.material-icon-theme + vscodevim.vim + ]; }; }; }; diff --git a/modules/editors/default.nix b/modules/editors/default.nix index b85cb82..dd92672 100644 --- a/modules/editors/default.nix +++ b/modules/editors/default.nix @@ -1,28 +1,5 @@ { config, lib, pkgs, ... }: -with lib; { +{ imports = [ ./emacs.nix ./idea.nix ./vim.nix ./code.nix ]; - - options.modules.editors = { - emacs = mkOption { - default = true; - type = types.bool; - example = false; - }; - idea = mkOption { - default = false; - type = types.bool; - example = true; - }; - vim = mkOption { - default = true; - type = types.bool; - example = false; - }; - code = mkOption { - default = false; - type = types.bool; - example = true; - }; - }; } diff --git a/modules/editors/emacs.nix b/modules/editors/emacs.nix index d69cb40..d940025 100644 --- a/modules/editors/emacs.nix +++ b/modules/editors/emacs.nix @@ -1,12 +1,20 @@ { config, lib, pkgs, inputs, ... }: +with lib; let emacs = with pkgs; ((emacsPackagesFor emacsGcc).emacsWithPackages (epkgs: [ epkgs.vterm epkgs.emacsql-sqlite3 ])); - cfg = config.modules.editors; + cfg = config.modules.editors.emacs; in { - config = lib.mkIf cfg.emacs { + options.modules.editors = { + emacs = mkOption { + default = true; + type = types.bool; + example = false; + }; + }; + config = mkIf cfg { fonts.fonts = [ pkgs.emacs-all-the-icons-fonts ]; home-manager.users.moritz = { @@ -34,10 +42,11 @@ in { ## Module dependencies # :checkers spell # (aspellWithDicts (ds: with ds; [ en en-computers en-science de ])) - hunspell - hunspellDicts.en_GB-ize - hunspellDicts.en_US - hunspellDicts.de_DE + (hunspellWithDicts [ + hunspellDicts.en_GB-ize + hunspellDicts.en_US + hunspellDicts.de_DE + ]) # :checkers grammar languagetool @@ -71,6 +80,14 @@ in { # :email mu isync + + # :lang haskell + haskell-language-server + (haskellPackages.ghcWithPackages (p: + # general + [ p.brittany ] ++ + # xmonad + [ p.xmonad p.xmonad-contrib p.xmonad-extras p.xmobar ])) ]; }; }; diff --git a/modules/editors/idea.nix b/modules/editors/idea.nix index 91e301d..05a5052 100644 --- a/modules/editors/idea.nix +++ b/modules/editors/idea.nix @@ -1,8 +1,16 @@ { config, lib, pkgs, ... }: +with lib; let cfg = config.modules.editors; in { - config = lib.mkIf cfg.idea { + options.modules.editors = { + idea = mkOption { + default = false; + type = types.bool; + example = true; + }; + }; + config = mkIf cfg.idea { home-manager.users.moritz = { home.packages = with pkgs; [ jdk jetbrains.idea-ultimate ]; }; diff --git a/modules/editors/vim.nix b/modules/editors/vim.nix index f92d88f..c12893e 100644 --- a/modules/editors/vim.nix +++ b/modules/editors/vim.nix @@ -1,12 +1,27 @@ { config, lib, pkgs, ... }: +with lib; let cfg = config.modules.editors; in { - config = lib.mkIf cfg.vim { + options.modules.editors = { + vim = mkOption { + default = true; + type = types.bool; + example = false; + }; + }; + config = mkIf cfg.vim { home-manager.users.moritz.programs.neovim = { enable = true; vimAlias = true; vimdiffAlias = true; + plugins = with pkgs.vimPlugins; [ + (nvim-treesitter.withPlugins (p: pkgs.tree-sitter.allGrammars)) + coc-nvim + dracula-vim + ]; + withNodeJs = true; + withPython3 = true; }; }; } diff --git a/overlays/default.nix b/overlays/default.nix index 83f8536..3b1379f 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -3,6 +3,7 @@ final: prev: { python-dev = import ./python.nix final prev; fish = final.master.fish; + nix-flake-tools = inputs.nix-flake-tools.packages.${prev.system}.extension; master = import inputs.master { inherit (prev) system; config.allowUnfree = true;