This commit is contained in:
Andrea Ciceri 2023-11-08 14:30:47 +01:00
parent d977d7857a
commit c2dc6078f7
Signed by: aciceri
SSH key fingerprint: SHA256:/AagBweyV4Hlfg9u092n8hbHwD5fcB6A3qhDiDA65Rg
6 changed files with 148 additions and 207 deletions

128
flake.lock generated
View file

@ -1,25 +1,5 @@
{ {
"nodes": { "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": { "extra-package-agenix-el": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -84,22 +64,6 @@
"type": "github" "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": { "extra-package-indent-bars": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -133,6 +97,22 @@
"type": "github" "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": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
@ -151,31 +131,13 @@
"type": "github" "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1694422566, "lastModified": 1698318101,
"narHash": "sha256-lHJ+A9esOz9vln/3CJG23FV6Wd2OoOFbDeEs4cMGMqc=", "narHash": "sha256-gUihHt3yPD7bVqg+k/UVHgngyaJ3DMEBchbymBMvK1E=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "3a2786eea085f040a66ecde1bc3ddc7099f6dbeb", "rev": "63678e9f3d3afecfeafa0acead6239cdb447574c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -203,65 +165,17 @@
"type": "github" "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": { "root": {
"inputs": { "inputs": {
"emacs-overlay": "emacs-overlay",
"extra-package-agenix-el": "extra-package-agenix-el", "extra-package-agenix-el": "extra-package-agenix-el",
"extra-package-chatgpt": "extra-package-chatgpt", "extra-package-chatgpt": "extra-package-chatgpt",
"extra-package-combobulate": "extra-package-combobulate", "extra-package-combobulate": "extra-package-combobulate",
"extra-package-copilot": "extra-package-copilot", "extra-package-copilot": "extra-package-copilot",
"extra-package-dracula-theme": "extra-package-dracula-theme",
"extra-package-indent-bars": "extra-package-indent-bars", "extra-package-indent-bars": "extra-package-indent-bars",
"extra-package-nix-ts-mode": "extra-package-nix-ts-mode", "extra-package-nix-ts-mode": "extra-package-nix-ts-mode",
"extra-package-notmuch-notify": "extra-package-notmuch-notify",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
} }
} }
}, },

View file

@ -3,7 +3,6 @@
inputs = { inputs = {
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
emacs-overlay.url = "github:nix-community/emacs-overlay";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
extra-package-indent-bars = { extra-package-indent-bars = {
url = "github:jdtsmith/indent-bars"; url = "github:jdtsmith/indent-bars";
@ -15,17 +14,12 @@
}; };
extra-package-combobulate = { extra-package-combobulate = {
url = "github:mickeynp/combobulate"; url = "github:mickeynp/combobulate";
# url = "github:aciceri/combobulate/nix";
flake = false; flake = false;
}; };
extra-package-agenix-el = { extra-package-agenix-el = {
url = "github:t4ccer/agenix.el"; url = "github:t4ccer/agenix.el";
flake = false; flake = false;
}; };
extra-package-dracula-theme = {
url = "github:aciceri/dracula-emacs";
flake = false;
};
extra-package-chatgpt = { extra-package-chatgpt = {
url = "github:joshcho/ChatGPT.el"; url = "github:joshcho/ChatGPT.el";
flake = false; flake = false;
@ -34,6 +28,10 @@
url = "github:zerolfx/copilot.el"; url = "github:zerolfx/copilot.el";
flake = false; flake = false;
}; };
extra-package-notmuch-notify = {
url = "github:firmart/notmuch-notify";
flake = false;
};
}; };
outputs = inputs @ {flake-parts, ...}: outputs = inputs @ {flake-parts, ...}:

View file

@ -1,8 +1,4 @@
{ {self, ...}: {
self,
inputs,
...
}: {
flake.hmModules = { flake.hmModules = {
default = self.hmModules.ccrEmacs; default = self.hmModules.ccrEmacs;
ccrEmacs = { ccrEmacs = {
@ -21,11 +17,9 @@
}; };
config = let config = let
ccrEmacsConfig = config.ccrEmacs; ccrEmacsConfig = config.ccrEmacs;
cfg = config.services.emacs;
in in
lib.mkIf ccrEmacsConfig.enable { lib.mkIf ccrEmacsConfig.enable {
nixpkgs.overlays = [
inputs.emacs-overlay.overlays.default
];
programs.emacs = { programs.emacs = {
enable = true; enable = true;
package = ccrEmacsConfig.package; package = ccrEmacsConfig.package;
@ -36,6 +30,7 @@
defaultEditor = true; defaultEditor = true;
socketActivation.enable = false; socketActivation.enable = false;
startWithUserSession = true; startWithUserSession = true;
package = ccrEmacsConfig.package;
}; };
systemd.user.sessionVariables = { systemd.user.sessionVariables = {
# TODO user `gpgconf --list-dirs agent-ssh-socket` # TODO user `gpgconf --list-dirs agent-ssh-socket`

136
init.el
View file

@ -80,37 +80,16 @@
) )
(use-package dracula-theme (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 :config
;; TODO abstract the following paradigm in a new use-package keyword :after-frame-one-time (add-hook 'after-make-frame-functions (defun ccr/theme-init (_)
(defvar ccr/theme-loaded nil "Indicate if the theme has already been loaded") (load-theme 'dracula 't)
;; load the theme only when a frame is created for the first time (not every time) (meow--prepare-face)
:hook (server-after-make-frame . (lambda () (remove-hook 'after-make-frame-functions 'ccr/theme-init))))
(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)))))
))))
(use-package solaire-mode ;; (use-package solaire-mode
:init ;; :init
(solaire-global-mode +1) ;; (solaire-global-mode +1)
:custom ((solaire-mode-themes-to-face-swap '(dracula)))) ;; :custom ((solaire-mode-themes-to-face-swap '(dracula))))
(use-package ligature (use-package ligature
:config :config
@ -189,6 +168,14 @@
(use-package meow (use-package meow
:hook (server-after-make-frame . (lambda () (meow--prepare-face))) :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 :init
(meow-global-mode 1) (meow-global-mode 1)
(meow-motion-overwrite-define-key (meow-motion-overwrite-define-key
@ -471,22 +458,35 @@
(nix-ts-mode . (lambda () (nix-ts-mode . (lambda ()
(require 'eglot) (require 'eglot)
(add-to-list 'eglot-server-programs (add-to-list 'eglot-server-programs
'(nix-ts-mode . ("nixd"))) '(nix-ts-mode . ("nil")))
(eglot-ensure))) ;; 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 . electric-pair-mode)
(nix-ts-mode . (lambda () (setq indent-bars-spacing-override 2) (indent-bars-mode))) (nix-ts-mode . (lambda () (setq indent-bars-spacing-override 2) (indent-bars-mode)))
) )
:mode "\\.nix\\'" :mode "\\.nix\\'"
) )
(use-package dockerfile-ts-mode
:mode "Dockerfile\\'")
(use-package python-ts-mode (use-package python-ts-mode
:hook ((python-ts-mode . (lambda () :hook ((python-ts-mode . (lambda ()
(require 'eglot) (require 'eglot)
(add-to-list 'eglot-server-programs (add-to-list 'eglot-server-programs
'(python-ts-mode . ("jedi-language-server"))) '(python-ts-mode . ("jedi-language-server")))
(eglot-ensure)))) (eglot-ensure))))
:mode "\\.py\\'") :mode "\\.py\\'")
(use-package typescript-ts-mode
:hook ((typescript-ts-mode . (lambda ()
(require 'eglot)
(eglot-ensure))))
:mode "\\.ts\\'")
(use-package haskell-mode (use-package haskell-mode
:hook ((haskell-mode . eglot-ensure) :hook ((haskell-mode . eglot-ensure)
(haskell-mode . tree-sitter-hl-mode))) (haskell-mode . tree-sitter-hl-mode)))
@ -568,6 +568,7 @@
(add-to-list 'eat-semi-char-non-bound-keys '[?\e 108]) ; M-l (add-to-list 'eat-semi-char-non-bound-keys '[?\e 108]) ; M-l
(eat-update-semi-char-mode-map) (eat-update-semi-char-mode-map)
(eat-reload) (eat-reload)
:hook (eat-mode . (lambda () (setq-local scroll-margin 0)))
:bind (("C-c o t" . eat-project)) :bind (("C-c o t" . eat-project))
;; FIXME doesn't work well ;; FIXME doesn't work well
;; ((eat-mode . compilation-shell-minor-mode)) ;; ((eat-mode . compilation-shell-minor-mode))
@ -595,21 +596,24 @@
(end-pos (line-end-position)) (end-pos (line-end-position))
(input (buffer-substring-no-properties start-pos end-pos))) (input (buffer-substring-no-properties start-pos end-pos)))
(message input) (message input)
(let* ((history (delete-dups (when (> (ring-size eshell-history-ring) 0) (let* (
(ring-elements eshell-history-ring)))) (history-shell (split-string (shell-command-to-string "history") "\n"))
(history-highlighted (mapcar #'(lambda (cmd) (history-eshell (delete-dups (when (> (ring-size eshell-history-ring) 0)
(with-temp-buffer (ring-elements eshell-history-ring))))
(text-mode) (history (append history-shell history-eshell))
(insert cmd) ;; (history-highlighted (mapcar #'(lambda (cmd)
(forward-line 0) ;; (with-temp-buffer
;; FIXME it breaks trying to highlight commands like `cd /ssh:host:~' ;; (text-mode)
;; (eshell-syntax-highlighting--parse-and-highlight 'command (point-max)) ;; (insert cmd)
(add-face-text-property (point-min) (point-max) '(:background nil)) ;; (forward-line 0)
(buffer-string))) ;; ;; FIXME it breaks trying to highlight commands like `cd /ssh:host:~'
history)) ;; ;; (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 (completing-read
"Command: " "Command: "
history-highlighted history
nil nil
nil nil
input 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-tramp) ;; to use sudo in eshell
;; (add-to-list 'eshell-modules-list 'eshell-smart) ;; plan 9 style ;; (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) :bind (("C-c o e" . project-eshell)
:map eshell-mode-map :map eshell-mode-map
("C-r" . ccr/eshell-history))) ;; i.e. just C-r in semi-char-mode ("C-r" . ccr/eshell-history))) ;; i.e. just C-r in semi-char-mode
@ -644,6 +650,10 @@
:config :config
(eshell-syntax-highlighting-global-mode +1)) (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 (use-package popper
:custom :custom
(popper-reference-buffers '("\*Messages\*" (popper-reference-buffers '("\*Messages\*"
@ -653,9 +663,9 @@
help-mode help-mode
compilation-mode compilation-mode
"^\\*.+-eshell.*\\*$" eshell-mode ;eshell as a popup "^\\*.+-eshell.*\\*$" eshell-mode ;eshell as a popup
"^\\*shell.*\\*$" shell-mode ;shell as a popup "^\\*shell.*\\*$" shell-mode ;shell as a popup
"^\\*term.*\\*$" term-mode ;term as a popup "^\\*term.*\\*$" term-mode ;term as a popup
"^\\*eat.*\\*$" eat-mode ;eat as a popup "^\\*eat.*\\*$" eat-mode ;eat as a popup
)) ))
(popper-window-height 0.33) (popper-window-height 0.33)
(popper-echo-lines 1) (popper-echo-lines 1)
@ -742,6 +752,30 @@
(use-package with-editor (use-package with-editor
:init (shell-command-with-editor-mode +1)) :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) (provide 'init)
;;; init.el ends here ;;; init.el ends here
;; Local Variables: ;; Local Variables:

View file

@ -11,28 +11,30 @@
lib, lib,
system, system,
... ...
}: let }: {
inherit (inputs.emacs-overlay.overlays.default pkgs pkgs) emacsPackagesFor; _module.args.pkgs = lib.foldl (lp: lp.extend) inputs.nixpkgs.legacyPackages.${system} [
in { (self: super: {
_module.args.pkgs = inputs.nixpkgs.legacyPackages.${system}.extend (self: super: { extra-package-inputs = lib.mapAttrs' (inputName: input: {
extra-package-inputs = lib.mapAttrs' (inputName: input: { name = builtins.head (builtins.match "extra-package-(.*)" inputName);
name = builtins.head (builtins.match "extra-package-(.*)" inputName); value = input;
value = input; }) (lib.filterAttrs (inputName: _: ! builtins.isNull (builtins.match "extra-package-.*" inputName)) inputs);
}) (lib.filterAttrs (inputName: _: ! builtins.isNull (builtins.match "extra-package-.*" inputName)) inputs); })
# Some tree-sitter grammars in nixpksg are built with a too new ABI # Some tree-sitter grammars in nixpksg are built with a too new ABI
# https://github.com/NixOS/nixpkgs/issues/209114 # https://github.com/NixOS/nixpkgs/issues/209114
# tree-sitter-grammars = # (_: _: {
# super.tree-sitter-grammars # tree-sitter-grammars =
# // { # super.tree-sitter-grammars
# tree-sitter-rust = super.tree-sitter-grammars.tree-sitter-rust.overrideAttrs (_: { # // {
# nativeBuildInputs = [self.nodejs self.tree-sitter]; # tree-sitter-rust = super.tree-sitter-grammars.tree-sitter-rust.overrideAttrs (_: {
# configurePhase = '' # nativeBuildInputs = [self.nodejs self.tree-sitter];
# tree-sitter generate --abi 13 src/grammar.json # configurePhase = ''
# ''; # tree-sitter generate --abi 13 src/grammar.json
# }); # '';
# }; # });
}); # };
# }
# )
];
packages = { packages = {
treesitGrammars = let treesitGrammars = let
@ -45,25 +47,19 @@
cp $f $out/"libtree-sitter-$(basename $f)" cp $f $out/"libtree-sitter-$(basename $f)"
done done
''; '';
ccrEmacsWithoutPackages = inputs'.emacs-overlay.packages.emacs-unstable.override { ccrEmacsWithoutPackages = pkgs.emacs29.override {
withSQLite3 = true;
withWebP = true;
withPgtk = true; withPgtk = true;
}; };
ccrEmacs = let ccrEmacs =
emacs = (pkgs.emacsPackagesFor config.packages.ccrEmacsWithoutPackages).emacsWithPackages
(emacsPackagesFor self'.packages.ccrEmacsWithoutPackages).emacsWithPackages (import ./packages.nix pkgs);
(import ./packages.nix pkgs); default = config.packages.ccrEmacs;
in
pkgs.runCommand "emacs" {} ''
cp -r ${emacs} emacs
chmod 700 -R emacs
mkdir emacs/share/emacs
cp -r emacs $out
'';
default = self'.packages.ccrEmacs;
}; };
apps = { apps = {
ccrEmacs.program = "${self'.packages.ccrEmacs}/bin/emacs"; ccrEmacs.program = "${config.packages.ccrEmacs}/bin/emacs";
default = config.apps.ccrEmacs; default = config.apps.ccrEmacs;
}; };
}; };

View file

@ -6,6 +6,7 @@ with epkgs; let
indent-bars = [compat]; indent-bars = [compat];
chatgpt = [polymode]; chatgpt = [polymode];
copilot = [editorconfig dash s]; copilot = [editorconfig dash s];
notmuch-notify = [alert notmuch];
}; };
overrideAttrsPerPackage = { overrideAttrsPerPackage = {
@ -38,7 +39,7 @@ with epkgs; let
[ [
meow meow
dracula-theme dracula-theme
solaire-mode # solaire-mode
nerd-icons nerd-icons
nerd-icons-completion nerd-icons-completion
nerd-icons-ibuffer nerd-icons-ibuffer
@ -48,6 +49,7 @@ with epkgs; let
eat eat
eshell-syntax-highlighting eshell-syntax-highlighting
fish-completion # fish completion for eshell fish-completion # fish completion for eshell
eshell-prompt-extras
esh-autosuggest esh-autosuggest
clipetty clipetty
sideline sideline
@ -91,6 +93,8 @@ with epkgs; let
password-store-otp password-store-otp
vertico-posframe vertico-posframe
eldoc-box eldoc-box
go-translate
notmuch
]; ];
in in
mainPackages ++ (builtins.attrValues extraPackages) mainPackages ++ (builtins.attrValues extraPackages)