Finally a dendritic structure that will give me a way to builkd my
system in a logical and consistent way.
This commit is contained in:
-299
@@ -1,299 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Droidnix: Emacs configuration setup for Nix/Org tangling, HTML export
|
||||
# For NixOS systems - assumes Emacs is already installed via Nix/NixOS
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Create a minimal Emacs config for package installation
|
||||
TEMP_CONFIG=$(mktemp /tmp/droidnix-emacs-setup.XXXXXX.el)
|
||||
cat > "$TEMP_CONFIG" << 'EOF'
|
||||
;; Minimal config for installing packages
|
||||
(require 'package)
|
||||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
|
||||
(package-initialize)
|
||||
EOF
|
||||
|
||||
# Install packages in batch mode with error handling
|
||||
echo "Installing Emacs packages..."
|
||||
emacs --batch \
|
||||
--load "$TEMP_CONFIG" \
|
||||
--eval "(package-refresh-contents)" \
|
||||
--eval "(package-install 'use-package)" \
|
||||
--eval "(package-install 'org)" \
|
||||
--eval "(package-install 'org-plus-contrib)" \
|
||||
--eval "(package-install 'nix-mode)" \
|
||||
--eval "(package-install 'htmlize)" \
|
||||
--eval "(package-install 'catppuccin-theme)" \
|
||||
--eval "(package-install 'org-bullets)" \
|
||||
--eval "(package-install 'magit)" \
|
||||
--eval "(package-install 'company)" \
|
||||
--eval "(package-install 'flycheck)" \
|
||||
--eval "(package-install 'doom-modeline)" \
|
||||
--eval "(package-install 'which-key)" \
|
||||
--eval "(package-install 'projectile)" \
|
||||
--eval "(package-install 'ivy)" \
|
||||
--eval "(package-install 'counsel)" \
|
||||
--eval "(package-install 'all-the-icons)" \
|
||||
--eval "(package-install 'doom-themes)" \
|
||||
--eval "(package-install 'treemacs)" \
|
||||
--eval "(package-install 'lsp-mode)" \
|
||||
--eval "(package-install 'ob-shell)" \
|
||||
--eval "(package-install 'ob-nix)" \
|
||||
--eval "(package-install 'dashboard)"
|
||||
|
||||
# Create a post-install config for interactive use
|
||||
USER_EMACSCONFIG="${HOME}/.emacs.d/init.el"
|
||||
if [ ! -f "$USER_EMACSCONFIG" ]; then
|
||||
mkdir -p "${HOME}/.emacs.d"
|
||||
cat > "$USER_EMACSCONFIG" << 'EOF'
|
||||
;; Droidnix Emacs Configuration for NixOS
|
||||
(require 'package)
|
||||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
|
||||
(package-initialize)
|
||||
|
||||
;; Basic UI improvements
|
||||
(tool-bar-mode -1) ; Disable toolbar
|
||||
(menu-bar-mode -1) ; Disable menu bar
|
||||
(scroll-bar-mode -1) ; Disable scroll bar
|
||||
(setq inhibit-startup-message t) ; Disable startup message
|
||||
(setq make-backup-files nil) ; Disable backup files
|
||||
(setq auto-save-default nil) ; Disable auto-save files
|
||||
|
||||
;; Enable Catppuccin Mocha theme
|
||||
(when (fboundp 'load-theme)
|
||||
(ignore-errors
|
||||
(load-theme 'catppuccin-mocha t)
|
||||
(setq catppuccin-disable-term-colors nil)
|
||||
(setq catppuccin-enable-bold t)
|
||||
(setq catppuccin-enable-italic t)))
|
||||
|
||||
;; Enable Doom Modeline
|
||||
(when (fboundp 'doom-modeline-mode)
|
||||
(doom-modeline-mode 1))
|
||||
|
||||
;; Enable All The Icons
|
||||
(when (fboundp 'all-the-icons-install-fonts)
|
||||
(all-the-icons-install-fonts)
|
||||
(global-all-the-icons-mode))
|
||||
|
||||
;; Enable Treemacs
|
||||
(when (fboundp 'treemacs)
|
||||
(treemacs-mode)
|
||||
(setq treemacs-width 30)
|
||||
(setq treemacs-position 'left)
|
||||
(setq treemacs-space-between-root-nodes nil)
|
||||
(setq treemacs-indent-level 2)
|
||||
(setq treemacs-file-follow-delay 0.1)
|
||||
(setq treemacs-git-icon-enabled t)
|
||||
(setq treemacs-project-follow t)
|
||||
(setq treemacs-display-project-root t)
|
||||
(setq treemacs-show-hidden-files t))
|
||||
|
||||
;; Enable Company for autocomplete
|
||||
(when (fboundp 'company-mode)
|
||||
(global-company-mode)
|
||||
(setq company-idle-delay 0.1)
|
||||
(setq company-minimum-prefix-length 1))
|
||||
|
||||
;; Enable Flycheck for syntax checking
|
||||
(when (fboundp 'flycheck-mode)
|
||||
(global-flycheck-mode)
|
||||
(setq flycheck-check-syntax-automatically '(save mode-enabled))
|
||||
(setq flycheck-display-errors-delay 0.5))
|
||||
|
||||
;; Enable Ivy + Counsel for better completion
|
||||
(when (fboundp 'ivy-mode)
|
||||
(ivy-mode 1)
|
||||
(setq ivy-use-virtual-buffers t)
|
||||
(setq ivy-count-format "(%d/%d) ")
|
||||
(setq ivy-height 10)
|
||||
(when (fboundp 'counsel-mode)
|
||||
(counsel-mode 1)))
|
||||
|
||||
;; Enable Projectile for project management
|
||||
(when (fboundp 'projectile-mode)
|
||||
(projectile-mode +1)
|
||||
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
|
||||
(setq projectile-completion-system 'ivy)
|
||||
(setq projectile-switch-project-action 'projectile-dired))
|
||||
|
||||
;; Enable Which Key for keybindings help
|
||||
(when (fboundp 'which-key-mode)
|
||||
(which-key-mode 1)
|
||||
(setq which-key-idle-delay 0.5)
|
||||
(setq which-key-show-major-modes nil))
|
||||
|
||||
;; Configure Org Mode
|
||||
(require 'org)
|
||||
(require 'ob-shell) ; Required for shell code blocks
|
||||
(require 'ob-nix) ; Required for nix code blocks
|
||||
(org-babel-do-load-languages
|
||||
'org-babel-load-languages
|
||||
'((emacs-lisp . t)
|
||||
(nix . t)
|
||||
(shell . t)
|
||||
(python . t)
|
||||
(dockerfile . t)))
|
||||
(setq org-babel-tangle-lang-exts '(("nix" . "nix")))
|
||||
(setq org-src-fontify-natively t)
|
||||
(setq org-src-tab-act-as-tab t)
|
||||
(setq org-edit-src-content-indentation 0)
|
||||
(setq org-startup-indented t)
|
||||
(setq org-startup-folded nil)
|
||||
(setq org-ellipsis "⤵")
|
||||
(setq org-hide-emphasis-markers t)
|
||||
(setq org-image-actual-width nil)
|
||||
(setq org-html-htmlize-output-type 'css)
|
||||
(setq org-export-with-toc nil)
|
||||
(setq org-todo-keywords '("TODO" "DOING" "|" "DONE" "CANCELED"))
|
||||
(setq org-log-done 'time)
|
||||
(setq org-directory "~/org")
|
||||
(when (fboundp 'org-bullets-mode)
|
||||
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
|
||||
|
||||
;; Enable Magit for Git
|
||||
(when (fboundp 'magit-version)
|
||||
(setq magit-display-buffer-function 'magit-display-buffer-fullscreen)
|
||||
(setq magit-last-seen-setup-instruction "1.4.0"))
|
||||
|
||||
;; Enable LSP Mode for language server support
|
||||
(when (fboundp 'lsp-mode)
|
||||
(lsp-mode 1)
|
||||
(setq lsp-keymap-prefix "C-c l")
|
||||
(setq lsp-enable-snippets nil)
|
||||
(setq lsp-enable-indentation nil)
|
||||
(setq lsp-enable-on-type-formatting nil)
|
||||
(setq lsp-lens-enable nil)
|
||||
(setq lsp-signature-auto-activate nil))
|
||||
|
||||
;; Enable Dashboard
|
||||
(when (fboundp 'dashboard-refresh-buffer)
|
||||
(dashboard-mode 1)
|
||||
(setq dashboard-items '((recents . 5)
|
||||
(projects . 5)
|
||||
(agenda . 5)
|
||||
(bookmarks . 5)))
|
||||
(setq dashboard-center-content t)
|
||||
(setq dashboard-banner-logo-title "Droidnix Configuration"))
|
||||
|
||||
;; Enable Nix Mode
|
||||
(when (fboundp 'nix-mode)
|
||||
(setq auto-mode-alist (cons '("\\.nix\\'" . nix-mode) auto-mode-alist))
|
||||
(add-to-list 'auto-mode-alist '("\\.nix\\'" . nix-mode)))
|
||||
|
||||
;; Custom keybindings
|
||||
(global-set-key (kbd "C-c t") 'treemacs)
|
||||
(global-set-key (kbd "C-c p") 'projectile-command-map)
|
||||
(global-set-key (kbd "C-c g") 'magit-status)
|
||||
(global-set-key (kbd "C-c d") 'dashboard-refresh-buffer)
|
||||
(global-set-key (kbd "C-c b") 'ivy-switch-buffer)
|
||||
(global-set-key (kbd "C-c f") 'find-file)
|
||||
(global-set-key (kbd "C-c s") 'save-buffer)
|
||||
(global-set-key (kbd "C-c q") 'kill-buffer)
|
||||
(global-set-key (kbd "C-c w") 'widen)
|
||||
(global-set-key (kbd "C-c n") 'narrow-to-region)
|
||||
|
||||
;; Nix-specific configurations
|
||||
(setq nix-indent-width 2)
|
||||
(setq nix-continuation-indent-width 4)
|
||||
|
||||
;; HTML export settings for Org
|
||||
(setq org-html-head-include-default-style nil)
|
||||
(setq org-html-head-extra "
|
||||
<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/tree.js@1.0.0/dist/tree.min.css\">
|
||||
<script src=\"https://cdn.jsdelivr.net/npm/tree.js@1.0.0/dist/tree.min.js\"></script>
|
||||
<style>
|
||||
.tree { font-family: monospace; white-space: pre; }
|
||||
#table-of-contents { display: none; }
|
||||
.org-src-container { background-color: #313244; color: #cdd6f4; padding: 1em; border-radius: 5px; }
|
||||
pre.src { background-color: #313244; padding: 1em; border-radius: 5px; }
|
||||
</style>")
|
||||
|
||||
;; Function to wrap tree output in div for HTML export
|
||||
(defun my/org-wrap-tree-in-div ()
|
||||
"Wrap the Nix tree output in a div with class 'tree' for HTML export."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward "#+RESULTS:\n#+BEGIN_EXAMPLE\n\\(.*?\n\\)#+END_EXAMPLE" nil t)
|
||||
(goto-char (match-beginning 1))
|
||||
(insert "#+HTML: <div class=\"tree\">\n")
|
||||
(goto-char (match-end 1))
|
||||
(insert "#+HTML: </div>\n"))))
|
||||
|
||||
;; Add hook to automatically wrap tree output on export
|
||||
(add-hook 'org-export-before-processing-hook 'my/org-wrap-tree-in-div)
|
||||
|
||||
;; Set default mode for new buffers
|
||||
(setq-default major-mode 'text-mode)
|
||||
(setq-default indent-tabs-mode nil)
|
||||
(setq default-tab-width 2)
|
||||
(setq tab-width 2)
|
||||
|
||||
;; Enable line numbers globally
|
||||
(global-display-line-numbers-mode 1)
|
||||
(setq display-line-numbers-type 'relative)
|
||||
|
||||
;; Configure fill column indicator
|
||||
(setq display-fill-column-indicator t)
|
||||
(setq display-fill-column-indicator-character ?│)
|
||||
(setq fill-column 80)
|
||||
|
||||
;; Enable delete-selection-mode for more intuitive editing
|
||||
(delete-selection-mode 1)
|
||||
|
||||
;; Configure modeline
|
||||
(setq display-time-day-and-date t)
|
||||
(setq display-time-24hr-format t)
|
||||
|
||||
;; Configure frame appearance
|
||||
(setq default-frame-alist '((fullscreen . maximized)
|
||||
(alpha . (95 95))
|
||||
(vertical-scroll-bars . nil)
|
||||
(tool-bar-lines . 0)
|
||||
(menu-bar-lines . 0)
|
||||
(line-spacing . 3)
|
||||
(font . "Fira Code-12")))
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Clean up
|
||||
rm "$TEMP_CONFIG"
|
||||
|
||||
echo ""
|
||||
echo "Emacs configuration setup complete with Catppuccin Mocha and all plugins!"
|
||||
echo ""
|
||||
echo "Installed packages:"
|
||||
echo " ✅ Catppuccin Mocha (theme)"
|
||||
echo " ✅ Org mode + Org Plus Contrib + Org Bullets"
|
||||
echo " ✅ Magit (Git interface)"
|
||||
echo " ✅ Company (autocomplete)"
|
||||
echo " ✅ Flycheck (syntax checking)"
|
||||
echo " ✅ Doom Modeline (status bar)"
|
||||
echo " ✅ Which Key (keybindings help)"
|
||||
echo " ✅ Projectile (project management)"
|
||||
echo " ✅ Ivy + Counsel (completion framework)"
|
||||
echo " ✅ All The Icons (pretty icons)"
|
||||
echo " ✅ Treemacs (file tree)"
|
||||
echo " ✅ LSP Mode (language server)"
|
||||
echo " ✅ ob-shell (shell support for Org Babel)"
|
||||
echo " ✅ ob-nix (Nix support for Org Babel)"
|
||||
echo " ✅ Dashboard (start page)"
|
||||
echo " ✅ tree (for directory visualization)"
|
||||
echo ""
|
||||
echo "You can now:"
|
||||
echo "1. Tangle Org files: emacs README.org --batch -f org-babel-tangle"
|
||||
echo "2. Export to HTML: emacs -Q --batch README.org -f org-html-export-to-html"
|
||||
echo "3. Open Emacs: emacs"
|
||||
echo ""
|
||||
echo "The configuration includes:"
|
||||
echo "- Proper Org Babel support for shell and Nix"
|
||||
echo "- Tree.js integration for collapsible directory trees in HTML export"
|
||||
echo "- Custom keybindings for common operations"
|
||||
echo "- Enhanced UI with Treemacs, Doom Modeline, and Catppuccin theme"
|
||||
echo "- Optimized settings for Nix development"
|
||||
echo "- HTML export with embedded CSS for better styling"
|
||||
echo ""
|
||||
echo "For a more permanent solution, add Emacs with these packages to your"
|
||||
echo "NixOS configuration.nix or home-manager configuration."
|
||||
|
||||
Reference in New Issue
Block a user