diff --git a/nix/modules/editor/default.nix b/nix/modules/editor/default.nix index 06f4467..cbc69f0 100644 --- a/nix/modules/editor/default.nix +++ b/nix/modules/editor/default.nix @@ -21,29 +21,37 @@ # A list of default FG42 modules to build FG42 with. { lib, config, pkgs, makeFG42Drv, ... }: let - deps = (with pkgs.emacsPackages; [ - origami - which-key - projectile - projectile-ripgrep - pkg-info - expand-region - helpful - envrc - pinentry - discover - exec-path-from-shell - avy - ace-window - yasnippet - yasnippet-snippets - flycheck - vertico - orderless - ctrlf - marginalia - base16-theme - ]); + deps = + (with pkgs.emacsPackages; [ + origami + which-key + projectile + projectile-ripgrep + pkg-info + expand-region + helpful + envrc + pinentry + discover + exec-path-from-shell + avy + ace-window + yasnippet + yasnippet-snippets + flycheck + vertico + orderless + ctrlf + marginalia + magit + forge + diff-hl + svg-tag-mode + all-the-icons + + base16-theme + ] ++ lib.optional (config.fg42.emojify) [ emojify ]); + drv = makeFG42Drv { pname = "editor"; version = config.fg42.version; @@ -54,21 +62,32 @@ let dicts = pkgs.aspellWithDicts (dicts: with dicts; [ en en-computers en-science ]); in { - fg42.elispPackages = [ drv ] ++ deps; - fg42.fonts = (with pkgs;[ - vazir-fonts - fira-code - fira-mono - noto-fonts - ]); + options = (with lib; { + fg42.emojify = mkOption { + type = types.bool; + default = true; + description = "Whether or not to use the `emojify' package."; + }; + }); - fg42.paths = (with pkgs;[ - ripgrep - dicts - ]); + config = { + fg42.elispPackages = [ drv ] ++ deps; - fg42.font = lib.mkDefault '''("Fira Mono" 11)''; - fg42.theme = lib.mkDefault "base16-eighties"; - fg42.theme-package-name = lib.mkDefault "base16-theme"; + fg42.fonts = (with pkgs;[ + vazir-fonts + fira-code + fira-mono + noto-fonts + ]); + + fg42.paths = (with pkgs;[ + ripgrep + dicts + ]); + + fg42.font = lib.mkDefault '''("Fira Mono" 11)''; + fg42.theme = lib.mkDefault "base16-eighties"; + fg42.theme-package-name = lib.mkDefault "base16-theme"; + }; } diff --git a/nix/modules/editor/lisp/fg42/config.el b/nix/modules/editor/lisp/fg42/config.el index f34c414..6d1fe60 100644 --- a/nix/modules/editor/lisp/fg42/config.el +++ b/nix/modules/editor/lisp/fg42/config.el @@ -36,5 +36,13 @@ `,sym `,default))) + +(defmacro with-config (name &rest body) + "Run the BODY only if the config NAME is set to t." + (declare (indent defun)) + `(when (fg42/config-get-or ,name) + ,@body)) + + (provide 'fg42/config) ;;; config.el ends here diff --git a/nix/modules/editor/lisp/fg42/editor.el b/nix/modules/editor/lisp/fg42/editor.el index c036dec..7cd62ff 100644 --- a/nix/modules/editor/lisp/fg42/editor.el +++ b/nix/modules/editor/lisp/fg42/editor.el @@ -37,11 +37,11 @@ ;; (require 'fg42/langs/elisp) ;; (require 'fg42/langs/nix) - ;; (require 'fg42/git) + (require 'fg42/git) ;; (require 'fg42/wm) - ;; (require 'fg42/org) + (require 'fg42/org) (require 'fg42/minibuffer) - ;; (require 'fg42/graphics) + (require 'fg42/graphics) ;; (require 'fg42/modeline) ) diff --git a/lisp/fg42/git.el b/nix/modules/editor/lisp/fg42/git.el similarity index 100% rename from lisp/fg42/git.el rename to nix/modules/editor/lisp/fg42/git.el diff --git a/lisp/fg42/graphics.el b/nix/modules/editor/lisp/fg42/graphics.el similarity index 90% rename from lisp/fg42/graphics.el rename to nix/modules/editor/lisp/fg42/graphics.el index 7dcbf17..94c0385 100644 --- a/lisp/fg42/graphics.el +++ b/nix/modules/editor/lisp/fg42/graphics.el @@ -22,9 +22,11 @@ ;;; Commentary: ;;; Code: (eval-when-compile - (require 'fpkg)) + (require 'fpkg) + (require 'fg42/config)) -(use! emojify + +(use-with-config! emojify "Adds support for emojis to `FG42'" :if (display-graphic-p) :hook (emacs-startup . global-emojify-mode)) @@ -34,11 +36,6 @@ Emacs." :if (display-graphic-p)) -(use! nerd-icons - "A utility package to collect various Icon Fonts and propertize them within -Emacs." - :if (display-graphic-p)) - (use! svg-tag-mode "A minor mode to replace keywords or regular expression with SVG tags." diff --git a/lisp/fg42/org.el b/nix/modules/editor/lisp/fg42/org.el similarity index 100% rename from lisp/fg42/org.el rename to nix/modules/editor/lisp/fg42/org.el diff --git a/nix/modules/editor/lisp/fpkg.el b/nix/modules/editor/lisp/fpkg.el index 56b2afe..72fa85f 100644 --- a/nix/modules/editor/lisp/fpkg.el +++ b/nix/modules/editor/lisp/fpkg.el @@ -25,6 +25,8 @@ ;; ;;; Code: (require 'map) +(eval-when-compile + (require 'fg42-config)) (defvar package-names ()) @@ -63,5 +65,14 @@ DOCS is the documentation of the package." `(use-package ,pkg ,@details)))) +(defmacro use-with-config! (name docs &rest details) + "A wrapper around `use!' that only activates if a config NAME is set. +It passes NAME, DOCS, and DETAILS to `use!' only if a config with the +same NAME is set to t." + (declare (indent defun) (doc-string 2)) + `(with-config ,name + (use! ,name ,docs ,@details))) + + (provide 'fpkg) ;;; fpkg.el ends here