diff --git a/flake.lock b/flake.lock index 85cb72e..975432d 100644 --- a/flake.lock +++ b/flake.lock @@ -1,25 +1,5 @@ { "nodes": { - "emacs-overlay": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "nixpkgs-stable": "nixpkgs-stable" - }, - "locked": { - "lastModified": 1694602127, - "narHash": "sha256-8lcpkk35COSkygePlvsOtSpR7tZx1SIgxdltZ0UZvXM=", - "owner": "nix-community", - "repo": "emacs-overlay", - "rev": "b99f00b0bc835dd490b455c8df0bab2acc16021c", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "emacs-overlay", - "type": "github" - } - }, "extra-package-agenix-el": { "flake": false, "locked": { @@ -84,22 +64,6 @@ "type": "github" } }, - "extra-package-dracula-theme": { - "flake": false, - "locked": { - "lastModified": 1695902551, - "narHash": "sha256-uP3icMS0MP4j1Y7ivpMQZv0jLRh7CaRpG8NCn3vLnbE=", - "owner": "aciceri", - "repo": "dracula-emacs", - "rev": "25c2623e65817b5902b7ef74d1e8bafafa9d5a48", - "type": "github" - }, - "original": { - "owner": "aciceri", - "repo": "dracula-emacs", - "type": "github" - } - }, "extra-package-indent-bars": { "flake": false, "locked": { @@ -133,6 +97,22 @@ "type": "github" } }, + "extra-package-notmuch-notify": { + "flake": false, + "locked": { + "lastModified": 1615303739, + "narHash": "sha256-7REFHQ5+cCK7EGIvs2CnoWu9a7WPxX4W6eFql2nNYP8=", + "owner": "firmart", + "repo": "notmuch-notify", + "rev": "c10012e38b0093bc3a304b90a30dd09c81b3eb75", + "type": "github" + }, + "original": { + "owner": "firmart", + "repo": "notmuch-notify", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -151,31 +131,13 @@ "type": "github" } }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1694422566, - "narHash": "sha256-lHJ+A9esOz9vln/3CJG23FV6Wd2OoOFbDeEs4cMGMqc=", + "lastModified": 1698318101, + "narHash": "sha256-gUihHt3yPD7bVqg+k/UVHgngyaJ3DMEBchbymBMvK1E=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3a2786eea085f040a66ecde1bc3ddc7099f6dbeb", + "rev": "63678e9f3d3afecfeafa0acead6239cdb447574c", "type": "github" }, "original": { @@ -203,65 +165,17 @@ "type": "github" } }, - "nixpkgs-stable": { - "locked": { - "lastModified": 1694499547, - "narHash": "sha256-R7xMz1Iia6JthWRHDn36s/E248WB1/je62ovC/dUVKI=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "e5f018cf150e29aac26c61dac0790ea023c46b24", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-23.05", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1694422566, - "narHash": "sha256-lHJ+A9esOz9vln/3CJG23FV6Wd2OoOFbDeEs4cMGMqc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "3a2786eea085f040a66ecde1bc3ddc7099f6dbeb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { - "emacs-overlay": "emacs-overlay", "extra-package-agenix-el": "extra-package-agenix-el", "extra-package-chatgpt": "extra-package-chatgpt", "extra-package-combobulate": "extra-package-combobulate", "extra-package-copilot": "extra-package-copilot", - "extra-package-dracula-theme": "extra-package-dracula-theme", "extra-package-indent-bars": "extra-package-indent-bars", "extra-package-nix-ts-mode": "extra-package-nix-ts-mode", + "extra-package-notmuch-notify": "extra-package-notmuch-notify", "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs_2" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 652621c..7d943d7 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,6 @@ inputs = { flake-parts.url = "github:hercules-ci/flake-parts"; - emacs-overlay.url = "github:nix-community/emacs-overlay"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; extra-package-indent-bars = { url = "github:jdtsmith/indent-bars"; @@ -15,17 +14,12 @@ }; extra-package-combobulate = { url = "github:mickeynp/combobulate"; - # url = "github:aciceri/combobulate/nix"; flake = false; }; extra-package-agenix-el = { url = "github:t4ccer/agenix.el"; flake = false; }; - extra-package-dracula-theme = { - url = "github:aciceri/dracula-emacs"; - flake = false; - }; extra-package-chatgpt = { url = "github:joshcho/ChatGPT.el"; flake = false; @@ -34,6 +28,10 @@ url = "github:zerolfx/copilot.el"; flake = false; }; + extra-package-notmuch-notify = { + url = "github:firmart/notmuch-notify"; + flake = false; + }; }; outputs = inputs @ {flake-parts, ...}: diff --git a/hmModules/default.nix b/hmModules/default.nix index 9b16100..878f1f2 100644 --- a/hmModules/default.nix +++ b/hmModules/default.nix @@ -1,8 +1,4 @@ -{ - self, - inputs, - ... -}: { +{self, ...}: { flake.hmModules = { default = self.hmModules.ccrEmacs; ccrEmacs = { @@ -21,11 +17,9 @@ }; config = let ccrEmacsConfig = config.ccrEmacs; + cfg = config.services.emacs; in lib.mkIf ccrEmacsConfig.enable { - nixpkgs.overlays = [ - inputs.emacs-overlay.overlays.default - ]; programs.emacs = { enable = true; package = ccrEmacsConfig.package; @@ -36,6 +30,7 @@ defaultEditor = true; socketActivation.enable = false; startWithUserSession = true; + package = ccrEmacsConfig.package; }; systemd.user.sessionVariables = { # TODO user `gpgconf --list-dirs agent-ssh-socket` diff --git a/init.el b/init.el index 711a50e..bf9f6db 100644 --- a/init.el +++ b/init.el @@ -80,37 +80,16 @@ ) (use-package dracula-theme - :init - ;; TODO find better colors (bright white and bright black should be different!) - ;; this is used by auto suggestions while typing in eat - (set-face-attribute 'ansi-color-bright-white nil :foreground "grey" :background "grey") - (set-face-attribute 'ansi-color-bright-black nil :foreground "grey" :background "grey") - ;; (set-face-attribute 'ansi-color-bright-magenta nil :foreground "magenta" :background "magenta") - ;; (set-face-background 'match (color-lighten-name (face-background 'menu) 30)) :config - ;; TODO abstract the following paradigm in a new use-package keyword :after-frame-one-time - (defvar ccr/theme-loaded nil "Indicate if the theme has already been loaded") - ;; load the theme only when a frame is created for the first time (not every time) - :hook (server-after-make-frame . (lambda () - (when (not ccr/theme-loaded) - (setq ccr/theme-loaded 't) - (load-theme 'dracula t) - (custom-theme-set-faces 'dracula '(default ((t (:background "black"))))) - (load-theme 'dracula t) - ;; HACK Since dracula doesn't directly expose colors as faces we load - ;; term in order to load them as term faces (which instead itq provides) - ;; Then we assign these faces to eat faces - ;; TODO shouldn't this be moved to eat's use-package section? - ;; (require 'term) - ;; (let ((colors '("black" "red" "green" "yellow" "blue" "magenta" "cyan" "white"))) - ;; (dolist (color colors) - ;; (set-face-attribute (intern (format "eat-term-color-%s" color)) nil :inherit (intern (format "term-color-%s" color))))) - )))) + (add-hook 'after-make-frame-functions (defun ccr/theme-init (_) + (load-theme 'dracula 't) + (meow--prepare-face) + (remove-hook 'after-make-frame-functions 'ccr/theme-init)))) -(use-package solaire-mode - :init - (solaire-global-mode +1) - :custom ((solaire-mode-themes-to-face-swap '(dracula)))) +;; (use-package solaire-mode +;; :init +;; (solaire-global-mode +1) +;; :custom ((solaire-mode-themes-to-face-swap '(dracula)))) (use-package ligature :config @@ -189,6 +168,14 @@ (use-package meow :hook (server-after-make-frame . (lambda () (meow--prepare-face))) + :config + (add-hook 'after-make-frame-functions (defun ccr/meow--prepare-face (_) + (meow--prepare-face) + (remove-hook 'after-make-frame-functions 'ccr/meow--prepare-face))) + (add-to-list 'meow-mode-state-list '(eshell-mode . insert)) + (add-to-list 'meow-mode-state-list '(eat-mode . insert)) + (add-to-list 'meow-mode-state-list '(notmuch-hello-mode . insert)) + (add-to-list 'meow-mode-state-list '(notmuch-search-mode . insert)) :init (meow-global-mode 1) (meow-motion-overwrite-define-key @@ -471,22 +458,35 @@ (nix-ts-mode . (lambda () (require 'eglot) (add-to-list 'eglot-server-programs - '(nix-ts-mode . ("nixd"))) - (eglot-ensure))) + '(nix-ts-mode . ("nil"))) + ;; FIXME `nixd' completion not working, will give it a second try in the future + ;; '(nix-ts-mode . ("nixd" :initializationOptions (:eval (:depth 10 :workers 4) + ;; :formatting (:command "alejandra") + ;; :options (:enable t :target (:installable "" :args ["--epxr" "(import \"${(builtins.getFlake \"n\")}/nixos\" {}).options" "--json"])))))) + (eglot-ensure))) (nix-ts-mode . electric-pair-mode) (nix-ts-mode . (lambda () (setq indent-bars-spacing-override 2) (indent-bars-mode))) ) :mode "\\.nix\\'" ) +(use-package dockerfile-ts-mode + :mode "Dockerfile\\'") + (use-package python-ts-mode :hook ((python-ts-mode . (lambda () - (require 'eglot) - (add-to-list 'eglot-server-programs - '(python-ts-mode . ("jedi-language-server"))) - (eglot-ensure)))) + (require 'eglot) + (add-to-list 'eglot-server-programs + '(python-ts-mode . ("jedi-language-server"))) + (eglot-ensure)))) :mode "\\.py\\'") +(use-package typescript-ts-mode + :hook ((typescript-ts-mode . (lambda () + (require 'eglot) + (eglot-ensure)))) + :mode "\\.ts\\'") + (use-package haskell-mode :hook ((haskell-mode . eglot-ensure) (haskell-mode . tree-sitter-hl-mode))) @@ -568,6 +568,7 @@ (add-to-list 'eat-semi-char-non-bound-keys '[?\e 108]) ; M-l (eat-update-semi-char-mode-map) (eat-reload) + :hook (eat-mode . (lambda () (setq-local scroll-margin 0))) :bind (("C-c o t" . eat-project)) ;; FIXME doesn't work well ;; ((eat-mode . compilation-shell-minor-mode)) @@ -595,21 +596,24 @@ (end-pos (line-end-position)) (input (buffer-substring-no-properties start-pos end-pos))) (message input) - (let* ((history (delete-dups (when (> (ring-size eshell-history-ring) 0) - (ring-elements eshell-history-ring)))) - (history-highlighted (mapcar #'(lambda (cmd) - (with-temp-buffer - (text-mode) - (insert cmd) - (forward-line 0) - ;; FIXME it breaks trying to highlight commands like `cd /ssh:host:~' - ;; (eshell-syntax-highlighting--parse-and-highlight 'command (point-max)) - (add-face-text-property (point-min) (point-max) '(:background nil)) - (buffer-string))) - history)) + (let* ( + (history-shell (split-string (shell-command-to-string "history") "\n")) + (history-eshell (delete-dups (when (> (ring-size eshell-history-ring) 0) + (ring-elements eshell-history-ring)))) + (history (append history-shell history-eshell)) + ;; (history-highlighted (mapcar #'(lambda (cmd) + ;; (with-temp-buffer + ;; (text-mode) + ;; (insert cmd) + ;; (forward-line 0) + ;; ;; FIXME it breaks trying to highlight commands like `cd /ssh:host:~' + ;; ;; (eshell-syntax-highlighting--parse-and-highlight 'command (point-max)) + ;; (add-face-text-property (point-min) (point-max) '(:background nil)) + ;; (buffer-string))) + ;; history)) (command (completing-read "Command: " - history-highlighted + history nil nil input @@ -628,6 +632,8 @@ (add-to-list 'eshell-modules-list 'eshell-tramp) ;; to use sudo in eshell ;; (add-to-list 'eshell-modules-list 'eshell-smart) ;; plan 9 style + + :hook (eshell-mode . (lambda () (setq-local scroll-margin 0))) :bind (("C-c o e" . project-eshell) :map eshell-mode-map ("C-r" . ccr/eshell-history))) ;; i.e. just C-r in semi-char-mode @@ -644,6 +650,10 @@ :config (eshell-syntax-highlighting-global-mode +1)) +(use-package eshell-prompt-extras + :custom ((eshell-highlight-prompt nil) + (eshell-prompt-function 'epe-theme-lambda))) + (use-package popper :custom (popper-reference-buffers '("\*Messages\*" @@ -653,9 +663,9 @@ help-mode compilation-mode "^\\*.+-eshell.*\\*$" eshell-mode ;eshell as a popup - "^\\*shell.*\\*$" shell-mode ;shell as a popup - "^\\*term.*\\*$" term-mode ;term as a popup - "^\\*eat.*\\*$" eat-mode ;eat as a popup + "^\\*shell.*\\*$" shell-mode ;shell as a popup + "^\\*term.*\\*$" term-mode ;term as a popup + "^\\*eat.*\\*$" eat-mode ;eat as a popup )) (popper-window-height 0.33) (popper-echo-lines 1) @@ -742,6 +752,30 @@ (use-package with-editor :init (shell-command-with-editor-mode +1)) +(use-package go-translate + :custom + (gts-translate-list '(("it" "en") ("en" "it"))) + (gts-default-translator + (gts-translator + :picker (gts-prompt-picker) + :engines `(,(gts-bing-engine) + ,(gts-google-engine :parser (gts-google-summary-parser))) + :render (gts-buffer-render))) + (gts-buffer-follow-p 't) + :bind (("C-c T t" . gts-do-translate))) + +(use-package notmuch + :custom + (notmuch-show-logo nil) + (send-mail-function 'sendmail-send-it)) + +(use-package notmuch-notify + :hook (notmuch-hello-refresh . notmuch-notify-hello-refresh-status-message) + :custom + (alert-default-style 'notifications) + :config + (notmuch-notify-set-refresh-timer)) + (provide 'init) ;;; init.el ends here ;; Local Variables: diff --git a/packages/default.nix b/packages/default.nix index 005bcff..6f11ccd 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -11,28 +11,30 @@ lib, system, ... - }: let - inherit (inputs.emacs-overlay.overlays.default pkgs pkgs) emacsPackagesFor; - in { - _module.args.pkgs = inputs.nixpkgs.legacyPackages.${system}.extend (self: super: { - extra-package-inputs = lib.mapAttrs' (inputName: input: { - name = builtins.head (builtins.match "extra-package-(.*)" inputName); - value = input; - }) (lib.filterAttrs (inputName: _: ! builtins.isNull (builtins.match "extra-package-.*" inputName)) inputs); - + }: { + _module.args.pkgs = lib.foldl (lp: lp.extend) inputs.nixpkgs.legacyPackages.${system} [ + (self: super: { + extra-package-inputs = lib.mapAttrs' (inputName: input: { + name = builtins.head (builtins.match "extra-package-(.*)" inputName); + value = input; + }) (lib.filterAttrs (inputName: _: ! builtins.isNull (builtins.match "extra-package-.*" inputName)) inputs); + }) # Some tree-sitter grammars in nixpksg are built with a too new ABI # https://github.com/NixOS/nixpkgs/issues/209114 - # tree-sitter-grammars = - # super.tree-sitter-grammars - # // { - # tree-sitter-rust = super.tree-sitter-grammars.tree-sitter-rust.overrideAttrs (_: { - # nativeBuildInputs = [self.nodejs self.tree-sitter]; - # configurePhase = '' - # tree-sitter generate --abi 13 src/grammar.json - # ''; - # }); - # }; - }); + # (_: _: { + # tree-sitter-grammars = + # super.tree-sitter-grammars + # // { + # tree-sitter-rust = super.tree-sitter-grammars.tree-sitter-rust.overrideAttrs (_: { + # nativeBuildInputs = [self.nodejs self.tree-sitter]; + # configurePhase = '' + # tree-sitter generate --abi 13 src/grammar.json + # ''; + # }); + # }; + # } + # ) + ]; packages = { treesitGrammars = let @@ -45,25 +47,19 @@ cp $f $out/"libtree-sitter-$(basename $f)" done ''; - ccrEmacsWithoutPackages = inputs'.emacs-overlay.packages.emacs-unstable.override { + ccrEmacsWithoutPackages = pkgs.emacs29.override { + withSQLite3 = true; + withWebP = true; withPgtk = true; }; - ccrEmacs = let - emacs = - (emacsPackagesFor self'.packages.ccrEmacsWithoutPackages).emacsWithPackages - (import ./packages.nix pkgs); - in - pkgs.runCommand "emacs" {} '' - cp -r ${emacs} emacs - chmod 700 -R emacs - mkdir emacs/share/emacs - cp -r emacs $out - ''; - default = self'.packages.ccrEmacs; + ccrEmacs = + (pkgs.emacsPackagesFor config.packages.ccrEmacsWithoutPackages).emacsWithPackages + (import ./packages.nix pkgs); + default = config.packages.ccrEmacs; }; apps = { - ccrEmacs.program = "${self'.packages.ccrEmacs}/bin/emacs"; + ccrEmacs.program = "${config.packages.ccrEmacs}/bin/emacs"; default = config.apps.ccrEmacs; }; }; diff --git a/packages/packages.nix b/packages/packages.nix index 7fd2f39..27b9319 100644 --- a/packages/packages.nix +++ b/packages/packages.nix @@ -6,6 +6,7 @@ with epkgs; let indent-bars = [compat]; chatgpt = [polymode]; copilot = [editorconfig dash s]; + notmuch-notify = [alert notmuch]; }; overrideAttrsPerPackage = { @@ -38,7 +39,7 @@ with epkgs; let [ meow dracula-theme - solaire-mode + # solaire-mode nerd-icons nerd-icons-completion nerd-icons-ibuffer @@ -48,6 +49,7 @@ with epkgs; let eat eshell-syntax-highlighting fish-completion # fish completion for eshell + eshell-prompt-extras esh-autosuggest clipetty sideline @@ -91,6 +93,8 @@ with epkgs; let password-store-otp vertico-posframe eldoc-box + go-translate + notmuch ]; in mainPackages ++ (builtins.attrValues extraPackages)