diff --git a/guix-config/home/emacs/config.el b/guix-config/home/emacs/config.el index 8467fa3..aa8d658 100644 --- a/guix-config/home/emacs/config.el +++ b/guix-config/home/emacs/config.el @@ -74,50 +74,19 @@ (and (eq system-type 'gnu/linux) (file-exists-p "/proc/sys/fs/binfmt_misc/WSLInterop"))) -(defun kylekrein/is-android () - (string-equal system-type "android")) - (use-package alert :ensure t ) -(require 'alert) - -(defun alert-android-notifications-notify (info) - (unless (kylekrein/is-android) - (error "Android notifications are only supported on Android systems")) - - "Send INFO using android-notifications-notify." - (let ((title (or (plist-get info :title) "Org Alert Reminder")) - (body (or (plist-get info :message) "")) - (urgency (let ((severity (plist-get info :severity))) - (cond ((eq severity 'urgent) 'critical) - ((eq severity 'high) 'critical) - ((eq severity 'moderate) 'normal) - ((eq severity 'low) 'low) - ((eq severity 'trivial) 'low) - (t 'normal)))) - (icon (or (plist-get info :icon) alert-default-icon))) - (android-notifications-notify - :title title - :body body - :urgency urgency - :icon icon - ))) - -(alert-define-style 'android-notifications :title "Android Notifications" - :notifier #'alert-android-notifications-notify - ) - (use-package alert-toast :ensure t :after alert) (setq alert-default-style (cond - ((kylekrein/is-android) 'android-notifications) ((kylekrein/detect-wsl) 'toast) (t 'libnotify))) -(setq backup-directory-alist '((".*" . "~/.emacs.d/tildafiles"))) +(make-directory "~/.cache/emacs/tildafiles") +(setq backup-directory-alist '((".*" . "~/.cache/emacs/tildafiles"))) (use-package diminish :ensure t) @@ -196,12 +165,6 @@ (save-place-mode t) ;; Restore cursor place in file -(unless (or - (equal "Battery status not available" (battery)) - (equal "Power N/A, battery Charging (N/A% load, remaining time N/A)" (battery)) - (equal "Power N/A, battery Discharging (N/A% load, remaining time N/A)" (battery))) - (display-battery-mode 1)) - (use-package nov :ensure t) (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode)) @@ -447,32 +410,29 @@ :config (eshell-syntax-highlighting-global-mode +1)) -(unless (kylekrein/is-android) ;;Fails to compile - (use-package vterm +(use-package vterm :ensure t - ;;:config -)) +) -(unless (kylekrein/is-android) - (use-package vterm-toggle - :ensure t - :after vterm - :config - (setq vterm-toggle-fullscreen-p nil) - (setq vterm-toggle-scope 'project) - (add-to-list 'display-buffer-alist - '((lambda (buffer-or-name _) - (let ((buffer (get-buffer buffer-or-name))) - (with-current-buffer buffer - (or (equal major-mode 'vterm-mode) - (string-prefix-p vterm-buffer-name (buffer-name buffer)))))) - (display-buffer-reuse-window display-buffer-at-bottom) - ;;(display-buffer-reuse-window display-buffer-in-direction) - ;;display-buffer-in-direction/direction/dedicated is added in emacs27 - ;;(direction . bottom) - ;;(dedicated . t) ;dedicated is supported in emacs27 - (reusable-frames . visible) - (window-height . 0.3))))) +(use-package vterm-toggle + :ensure t + :after vterm + :config + (setq vterm-toggle-fullscreen-p nil) + (setq vterm-toggle-scope 'project) + (add-to-list 'display-buffer-alist + '((lambda (buffer-or-name _) + (let ((buffer (get-buffer buffer-or-name))) + (with-current-buffer buffer + (or (equal major-mode 'vterm-mode) + (string-prefix-p vterm-buffer-name (buffer-name buffer)))))) + (display-buffer-reuse-window display-buffer-at-bottom) + ;;(display-buffer-reuse-window display-buffer-in-direction) + ;;display-buffer-in-direction/direction/dedicated is added in emacs27 + ;;(direction . bottom) + ;;(dedicated . t) ;dedicated is supported in emacs27 + (reusable-frames . visible) + (window-height . 0.3)))) (git-package "https://github.com/darcamo/cmake-integration.git") (use-package cmake-integration @@ -577,20 +537,6 @@ DIR must include a .project file to be considered a project." (direnv-allow)) (message "Added 'use flake' to .envrc and ran direnv allow in %s" root))) -(use-package nix-ts-mode - :ensure t - :mode "\\.nix\\'" - :hook - (nix-ts-mode . lsp-deferred) ;; So that envrc mode will work - :custom - (lsp-disabled-clients '((nix-ts-mode . nix-nil))) ;; Disable nil so that nixd will be used as lsp-server - :config - (setq lsp-nix-nixd-server-path "nixd" - lsp-nix-nixd-formatting-command [ "alejandra" ] - lsp-nix-nixd-nixpkgs-expr "import { }" - lsp-nix-nixd-nixos-options-expr "(builtins.getFlake \"github:kylekrein/nixos-config\".nixosConfigurations.kylekrein-homepc.options" - lsp-nix-nixd-home-manager-options-expr "(builtins.getFlake \"github:kylekrein/nixos-config\".nixosConfigurations.kylekrein-homepc.options.home-manager.users.type.getSubOptions []")) - (use-package glsl-mode :ensure t) @@ -1085,20 +1031,6 @@ one, an error is signaled." which-key-allow-imprecise-window-fit nil which-key-separator " → " )) -(when (kylekrein/is-android) - ;;Write all android settings here - (setq touch-screen-keyboard-function t) - (setq touch-screen-display-keyboard t) - - (menu-bar-mode 1) ;; Enable the menu bar - (scroll-bar-mode 1) ;; Enable the scroll bar - (tool-bar-mode 1) ;;Enable the tool bar - (setq use-file-dialog t) ;; file dialog - (setq use-dialog-box t) ;; dialog box - (setq pop-up-windows t) ;; popup windows - (server-start) -) - (when (kylekrein/detect-wsl) (setq select-active-regions nil) (setq select-enable-clipboard 't) diff --git a/guix-config/home/emacs/init.el b/guix-config/home/emacs/init.el index f507065..4fccf98 100644 --- a/guix-config/home/emacs/init.el +++ b/guix-config/home/emacs/init.el @@ -4,3 +4,4 @@ (setenv "PATH" (mapconcat 'identity exec-path ":")) ;;fixes direnv losing nix pkgs (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize) +(package-refresh-contents) diff --git a/guix-config/home/services/emacs.scm b/guix-config/home/services/emacs.scm index 4c09758..1ccaad3 100644 --- a/guix-config/home/services/emacs.scm +++ b/guix-config/home/services/emacs.scm @@ -32,10 +32,13 @@ `(".config/emacs/init.el" ,(mixed-text-file "early-config.el" ";; Emacs Early Config from Guix Home\n" + "(setq custom-file \"~/.config/emacs/custom.el\")\n" + "(when (file-exists-p custom-file)\n" + "(load custom-file))\n" (string-append "(make-directory \"" package-user-dir "\" t)\n") (string-append "(setq package-user-dir \"" package-user-dir "\")\n") "(load-file \"" (home-emacs-configuration-early-config-file config) "\")\n" - "(load-file \"~/.config/emacs/config.el\")")))) + "(load-file \"~/.config/emacs/config.el\")\n")))) (define (home-emacs-profile-service config) (list (home-emacs-configuration-emacs config))) diff --git a/guix-config/packages/emacs-test.scm b/guix-config/packages/emacs-test.scm new file mode 100644 index 0000000..f28eaf3 --- /dev/null +++ b/guix-config/packages/emacs-test.scm @@ -0,0 +1,81 @@ +(define-module (guix-config packages emacs) + #:use-module (gnu packages emacs) + #:use-module (gnu packages emacs-xyz) + #:use-module (gnu packages rust-apps) + #:use-module (gnu packages bash) + #:use-module (guix build utils) + #:use-module (guix packages) + #:use-module (guix utils) + #:use-module (guix gexp) + #:use-module (guix licenses) + #:use-module (guix build-system trivial) + #:export (guixmacs)) + +(define emacs-config + (local-file "./config.org")) + +(define emacs-init + (mixed-text-file "init.el" +";;; -*- lexical-binding: t; -*- +(require 'package) +;;https://github.com/wbolster/emacs-direnv/issues/85 +(setenv \"PATH\" (mapconcat 'identity exec-path \":\")) ;;fixes direnv losing nix/guix pkgs +(add-to-list 'package-archives '(\"melpa\" . \"https://melpa.org/packages/\") t) +(package-initialize) +(org-babel-load-file + \"" emacs-config "\") +")) + +(define emacs-pkgs + (list emacs-guix ripgrep)) + +(define guixmacs + (package + (name "guixmacs") + (version (package-version emacs-pgtk)) + (source #f) + (synopsis "KyleKrein’s Emacs config wrapper") + (description "Emacs PGTK wrapped with useful Guix packages in PATH and EMACSLOADPATH.") + (license gpl3+) + (home-page "https://git.kylekrein.com/kylekrein/dotfiles") + (build-system trivial-build-system) + (propagated-inputs (append (list emacs-pgtk + bash-minimal) + emacs-pkgs)) + (arguments + (list + #:modules '((guix build utils)) + #:builder + #~(begin + (use-modules (guix build utils)) + (define (wrap-external-program target out-bin env-vars) + (let ((script (open-output-file out-bin))) + (display (string-append "#!" #$bash-minimal "/bin/bash" "\n") script) + (for-each + (lambda (pair) + (display (string-append "export " (car pair) "=\"" (cdr pair) "\"\n") script)) + env-vars) + (display (string-append target " -l " #$emacs-init " $@\n") script) + (close-output-port script)) + (chmod out-bin #o755)) + (let* ((out #$output) + (emacs #$(this-package-input "emacs-pgtk")) + (dep-paths '#$emacs-pkgs) + (site-lisps (map (lambda (p) + (string-append p "/share/emacs/site-lisp")) + dep-paths)) + (bins (map (lambda (p) + (string-append p "/bin")) + dep-paths)) + (bin (string-append out "/bin")) + (emacsloadpath (string-join site-lisps ":")) + (path (string-join (append (list "$PATH") bins) ":"))) + (mkdir-p bin) + ;(mkdir-p (string-append out "/native-lisp")) + (symlink (string-append emacs "/share") (string-append out "/share")) + (symlink (string-append emacs "/native-lisp") (string-append out "/native-lisp")) + (wrap-external-program + (string-append emacs "/bin/emacs") + (string-append out "/bin/emacs") + (list (cons "EMACSLOADPATH" emacsloadpath) + (cons "PATH" path))))))))) diff --git a/guix-config/packages/emacs.scm b/guix-config/packages/emacs.scm index 12a6ca0..c392a71 100644 --- a/guix-config/packages/emacs.scm +++ b/guix-config/packages/emacs.scm @@ -9,55 +9,61 @@ #:use-module (guix gexp) #:use-module (guix licenses) #:use-module (guix build-system trivial) + #:use-module (gnu packages fonts) + #:use-module (gnu packages llvm) + #:use-module (gnu packages tree-sitter) #:export (guixmacs)) (define emacs-pkgs - (list emacs-guix ripgrep)) + (list + emacs-guix + emacs-golden-ratio + emacs-alert + emacs-diminish + emacs-nov-el + emacs-magit + emacs-doom-modeline + emacs-doom-themes + emacs-rainbow-delimiters + emacs-org-bullets + emacs-org-transclusion + emacs-org-roam + emacs-consult + emacs-rainbow-mode + emacs-gptel + emacs-eshell-syntax-highlighting + emacs-vterm + emacs-vterm-toggle + emacs-direnv + emacs-glsl-mode + emacs-treesit-auto + emacs-nerd-icons + emacs-marginalia + emacs-multiple-cursors + emacs-corfu + emacs-cape + emacs-vertico + emacs-orderless + + font-iosevka + + ripgrep + clang-toolchain + tree-sitter + + + )) (define guixmacs (package + (inherit emacs-pgtk) (name "guixmacs") - (version (package-version emacs-pgtk)) - (source #f) - (synopsis "KyleKrein’s Emacs config wrapper") - (description "Emacs PGTK wrapped with useful Guix packages in PATH and EMACSLOADPATH.") - (license gpl3+) (home-page "https://git.kylekrein.com/kylekrein/dotfiles") - (build-system trivial-build-system) - (propagated-inputs (append (list emacs-pgtk - bash-minimal) - emacs-pkgs)) + (properties '((tunable? . #t))) (arguments + (append + (package-arguments emacs-pgtk) (list - #:modules '((guix build utils)) - #:builder - #~(begin - (use-modules (guix build utils)) - (define (wrap-external-program target out-bin env-vars) - (let ((script (open-output-file out-bin))) - (display (string-append "#!" #$bash-minimal "/bin/bash" "\n") script) - (for-each - (lambda (pair) - (display (string-append "export " (car pair) "=\"" (cdr pair) "\"\n") script)) - env-vars) - (display (string-append "\"" target "\" \"$@\"\n") script) - (close-output-port script)) - (chmod out-bin #o755)) - (let* ((out #$output) - (emacs #$(this-package-input "emacs-pgtk")) - (dep-paths '#$emacs-pkgs) - (site-lisps (map (lambda (p) - (string-append p "/share/emacs/site-lisp")) - dep-paths)) - (bins (map (lambda (p) - (string-append p "/bin")) - dep-paths)) - (bin (string-append out "/bin")) - (emacsloadpath (string-join site-lisps ":")) - (path (string-join (append (list "$PATH") bins) ":"))) - (mkdir-p bin) - (wrap-external-program - (string-append emacs "/bin/emacs") - (string-append out "/bin/emacs") - (list (cons "EMACSLOADPATH" emacsloadpath) - (cons "PATH" path))))))))) + #:tests? #f))) + (propagated-inputs (append (package-propagated-inputs emacs-pgtk) + emacs-pkgs))))