emacs: Manage packages using nix instead of straight.el

This commit is contained in:
2021-11-06 18:48:40 +01:00
parent 880c11792f
commit 5a84c7e02c
4 changed files with 55 additions and 391 deletions

View File

@@ -17,36 +17,7 @@
;; restore after startup
(setq gc-cons-threshold 800000)))
(defun http-download-verify-and-exec (url sha256-hash name func)
(let ((actual-hash ""))
(with-temp-buffer
;; Somewhat not documented function. Based on https://emacs.stackexchange.com/a/38482
;; The problem is that url-retrieve-synchronously prints the HTTP headers at
;; the top, which are, since they include time, non-deterministic and thus cannot
;; be used for hashing.
(url-insert-file-contents url)
(setq actual-hash (secure-hash 'sha256 (current-buffer)))
(unless (string= sha256-hash actual-hash)
(error "Unexpected hash for %s: Got %s, expected %s" name actual-hash sha256-hash))
func)))
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5)
(install-hash ""))
(unless (file-exists-p bootstrap-file)
(http-download-verify-and-exec
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
"5bbeee903a90a0fda88a6b8516697c121400facb36a2c349e9447a53baef154e"
"straight's install.el"
(lambda ()
(goto-char (point-max))
(eval-print-last-sexp))))
(load bootstrap-file nil 'nomessage))
(setq straight-use-package-by-default t)
(straight-use-package 'use-package)
(require 'package)
; Visual things
(defvar emacs-font "SourceCodePro:style=Light-7")
@@ -56,35 +27,19 @@
(menu-bar-mode -1)
(toggle-scroll-bar -1)
(setq inhibit-startup-screen t)
;; We cannot exactly use use-package, so we just download it "manually".
(let* ((theme-dir (expand-file-name "themes" user-emacs-directory))
(theme-file (expand-file-name "weyland-yutani-theme.el" theme-dir)))
(unless (file-exists-p theme-file)
(unless (file-exists-p theme-dir)
(make-directory theme-dir))
(http-download-verify-and-exec
"https://raw.githubusercontent.com/jstaursky/weyland-yutani-theme/246410e1c03f7d8d8e76102f7c5e3cda83acb36b/weyland-yutani-theme.el"
"6593a0a7e46710e25f9b9caf9888106c93230bd20f9af87c5fc883a98b187253"
"weyland-yutani-theme.el"
(lambda ()
(write-file theme-file))))
(add-to-list 'custom-theme-load-path theme-dir)
(load-theme 'weyland-yutani t))
(add-to-list 'custom-theme-load-path (expand-file-name "themes" user-emacs-directory))
(load-theme 'weyland-yutani t)
(use-package rainbow-delimiters
:straight t
:config
(add-hook 'prog-mode-hook
#'rainbow-delimiters-mode))
(use-package hl-todo
:straight t
:config
(add-hook 'prog-mode-hook
#'hl-todo-mode))
(global-hl-line-mode 1)
(use-package nlinum
:straight t
:config
(add-hook 'prog-mode-hook
(lambda ()
@@ -95,7 +50,6 @@
(setq show-parens-delay 0)))
(use-package ivy
:straight t
:config
(defvar ivy-use-virtual-buffers t)
(ivy-mode 1))
@@ -129,24 +83,15 @@
(add-hook 'prog-mode-hook
#'rainbow-delimiters-mode))
(use-package highlight-parentheses
:straight t
:config
(highlight-parentheses-mode))
(use-package smartparens
:straight t
:config
(smartparens-global-mode t))
(use-package undo-tree
:straight t
:config
(global-undo-tree-mode))
(use-package hl-todo
:config
(add-hook 'prog-mode-hook
#'hl-todo-mode))
(global-hl-line-mode 1)
(setq-default indent-tab-mode t)
(setq tab-width 4)
@@ -166,23 +111,13 @@
; I don't need mu4e on my desktop
(load-file (expand-file-name "mu4e.el" user-emacs-directory))
(use-package mu4e
:straight t
:config
(ptw/init-mu4e)))
(use-package calfw
:straight (calfw
:host github
:repo "kiwanami/emacs-calfw"
:files ("calfw.el" "calfw-cal.el")))
;; Org mode stuff
;(use-package org-evil
; :straight t)
(use-package graphviz-dot-mode
:straight t)
;(use-package org-evil)
(use-package graphviz-dot-mode)
(use-package org
:straight t
:bind
("C-x P" . (lambda ()
(interactive)
@@ -205,10 +140,6 @@
(interactive)
(org-present))))))
(use-package org-present
:straight (org-present
:host github
:repo "rlister/org-present"
:files ("org-present.el"))
:config
(add-hook 'org-present-mode-hook
(lambda ()
@@ -261,7 +192,6 @@
;; Development
(use-package tide
:straight t
:config
(defun setup-tide-mode ()
(interactive)
@@ -273,23 +203,17 @@
(when (string-equal "tsx" (file-name-extension buffer-file-name))
(setup-tide-mode))))
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode)))
(use-package nix-mode
:straight t)
(use-package go-mode
:straight t)
(use-package json-mode
:straight t)
(use-package rust-mode
:straight t)
(use-package nix-mode)
(use-package go-mode)
(use-package json-mode)
(use-package rust-mode)
;; Debugging
(use-package explain-pause-mode
:straight
(explain-pause-mode
:type git
:host github
:repo "lastquestion/explain-pause-mode")
:config
(explain-pause-mode))
;(use-package explain-pause-mode
; :straight
; (explain-pause-mode
; :type git
; :host github
; :repo "lastquestion/explain-pause-mode")
; :config
; (explain-pause-mode))