diff options
| author | Miran Bastaja <miran.bastaja04@gmail.com> | 2024-09-11 22:47:26 +0200 |
|---|---|---|
| committer | Miran Bastaja <miran.bastaja04@gmail.com> | 2024-09-11 23:38:43 +0200 |
| commit | 7889a68eb0327f21175bc5abc187d68763fced64 (patch) | |
| tree | b28d4742b26c84ae2de08f8a83a22c7eefb39da8 | |
| parent | 98e24a0e287d07ab2e0e0cab2cb343ed23b97cf4 (diff) | |
Set up basic emacs config
| -rw-r--r-- | flake.lock | 80 | ||||
| -rw-r--r-- | flake.nix | 4 | ||||
| -rw-r--r-- | share/overlay.nix | 2 | ||||
| -rw-r--r-- | share/system/client-common.nix | 6 | ||||
| -rw-r--r-- | share/system/emacs.nix | 10 | ||||
| -rw-r--r-- | share/xpkgs/emacs/default.nix | 12 | ||||
| -rw-r--r-- | share/xpkgs/emacs/emacs.el | 119 |
7 files changed, 228 insertions, 5 deletions
@@ -40,6 +40,28 @@ "type": "github" } }, + "emacs-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1726076326, + "narHash": "sha256-yilQd6wvHDcNFlGJqmKCRCRO/qd8qQCIrDXiKtRewNU=", + "owner": "nix-community", + "repo": "emacs-overlay", + "rev": "ba0b7636b47b5423ec09f89bcba06aadb68a607d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "emacs-overlay", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -74,11 +96,29 @@ "type": "github" } }, - "futils": { + "flake-utils": { "inputs": { "systems": "systems" }, "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "futils": { + "inputs": { + "systems": "systems_2" + }, + "locked": { "lastModified": 1722472559, "narHash": "sha256-HqzEdURUwgCNDpopDC38NbChC0cOyj1L47EP+1aco8k=", "ref": "refs/heads/main", @@ -247,6 +287,22 @@ }, "nixpkgs-stable": { "locked": { + "lastModified": 1725930920, + "narHash": "sha256-RVhD9hnlTT2nJzPHlAqrWqCkA7T6CYrP41IoVRkciZM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "44a71ff39c182edaf25a7ace5c9454e7cba2c658", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable_2": { + "locked": { "lastModified": 1725762081, "narHash": "sha256-vNv+aJUW5/YurRy1ocfvs4q/48yVESwlC/yHzjkZSP8=", "owner": "NixOS", @@ -261,7 +317,7 @@ "type": "github" } }, - "nixpkgs-stable_2": { + "nixpkgs-stable_3": { "locked": { "lastModified": 1720386169, "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", @@ -355,7 +411,7 @@ "sorre-website", "nixpkgs" ], - "nixpkgs-stable": "nixpkgs-stable_2" + "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { "lastModified": 1724857454, @@ -375,6 +431,7 @@ "inputs": { "comin": "comin", "disko": "disko", + "emacs-overlay": "emacs-overlay", "futils": "futils", "home-manager": "home-manager", "nix-on-droid": "nix-on-droid", @@ -447,7 +504,7 @@ "nixpkgs": [ "nixpkgs" ], - "nixpkgs-stable": "nixpkgs-stable" + "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { "lastModified": 1725922448, @@ -502,6 +559,21 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ @@ -37,6 +37,10 @@ url = "github:nlewo/comin"; inputs.nixpkgs.follows = "nixpkgs"; }; + emacs-overlay = { + url = "github:nix-community/emacs-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; # development stuff treefmt-nix = { diff --git a/share/overlay.nix b/share/overlay.nix index a9aacff..00dc6a5 100644 --- a/share/overlay.nix +++ b/share/overlay.nix @@ -14,4 +14,6 @@ in wget = writeShellScriptBinAndSymlink "wget" '' wget --hsts-file="$XDG_DATA_HOME/wget-hsts" ''; + + sorremacs = prev.callPackage ./xpkgs/emacs { }; } diff --git a/share/system/client-common.nix b/share/system/client-common.nix index 49e2472..aa8550f 100644 --- a/share/system/client-common.nix +++ b/share/system/client-common.nix @@ -1,10 +1,14 @@ # Common configuration options for client machines (i.e. not servers) { inputs, pkgs, ... }: { - imports = [ ./steam.nix ]; + imports = [ + ./steam.nix + ./emacs.nix + ]; nixpkgs = { overlays = [ inputs.rust-overlay.overlays.default + inputs.emacs-overlay.overlays.default (import ../overlay.nix) ]; config = { diff --git a/share/system/emacs.nix b/share/system/emacs.nix new file mode 100644 index 0000000..c846ad7 --- /dev/null +++ b/share/system/emacs.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: +{ + services.emacs = { + enable = true; + install = true; + package = pkgs.sorremacs; + }; + + environment.systemPackages = [ pkgs.sorremacs ]; +} diff --git a/share/xpkgs/emacs/default.nix b/share/xpkgs/emacs/default.nix new file mode 100644 index 0000000..eea70f5 --- /dev/null +++ b/share/xpkgs/emacs/default.nix @@ -0,0 +1,12 @@ +{ emacsWithPackagesFromUsePackage, ... }: +emacsWithPackagesFromUsePackage { + config = ./emacs.el; + defaultInitFile = true; + alwaysEnsure = true; + alwaysTangle = true; + + # Optionally provide extra packages not in the configuration file. + extraEmacsPackages = epkgs: [ + epkgs.cask + ]; +} diff --git a/share/xpkgs/emacs/emacs.el b/share/xpkgs/emacs/emacs.el new file mode 100644 index 0000000..51c0314 --- /dev/null +++ b/share/xpkgs/emacs/emacs.el @@ -0,0 +1,119 @@ +;;; For performance +(setq gc-cons-threshold 100000000) +(setq read-process-output-max (* 1024 1024)) ;; 1mb + +(add-hook 'after-init-hook #'(lambda () + ;; restore after startup + (setq gc-cons-threshold 800000))) + +;;; Disable menu-bar, tool-bar, and scroll-bar. +(if (fboundp 'menu-bar-mode) + (menu-bar-mode -1)) +(if (fboundp 'tool-bar-mode) + (tool-bar-mode -1)) +(if (fboundp 'scroll-bar-mode) + (scroll-bar-mode -1)) + +;;; Fix this bug: +;;; https://www.reddit.com/r/emacs/comments/cueoug/the_failed_to_download_gnu_archive_is_a_pretty/ +(when (version< emacs-version "26.3") + (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")) + +(setq-default cursor-type 'bar) ; Line-style cursor similar to other text editors +(setq inhibit-startup-screen t) ; Disable startup screen +(setq initial-scratch-message "") ; Make *scratch* buffer blank +(setq-default frame-title-format '("%b")) ; Make window title the buffer name +(setq ring-bell-function 'ignore) ; Disable bell sound +(fset 'yes-or-no-p 'y-or-n-p) ; y-or-n-p makes answering questions faster +(show-paren-mode 1) ; Show closing parens by default +(setq linum-format "%4d ") ; Line number format +(delete-selection-mode 1) ; Selected text will be overwritten when you start typing +(global-auto-revert-mode t) ; Auto-update buffer if file has changed on disk + +;; Show line numbers in programming modes +(add-hook 'prog-mode-hook + (if (or + ; If linum-mode doesn't exist... + (not (fboundp 'linum-mode)) + ; ...or Emacs has display-line-numbers-mode capability + (and (fboundp 'display-line-numbers-mode) (display-graphic-p))) + ; ...then use display-line-numbers-mode! + 'display-line-numbers-mode + ; Otherwise, use linum-mode + 'linum-mode)) + +(global-display-line-numbers-mode) + +;; Define the whitespace style. +(setq-default whitespace-style + '(face spaces empty tabs newline trailing space-mark tab-mark newline-mark)) + +;; Whitespace color corrections. +(require 'color) +(let* ((ws-lighten 30) ;; Amount in percentage to lighten up black. + (ws-color (color-lighten-name "#000000" ws-lighten))) + (custom-set-faces + `(whitespace-newline ((t (:foreground ,ws-color)))) + `(whitespace-missing-newline-at-eof ((t (:foreground ,ws-color)))) + `(whitespace-space ((t (:foreground ,ws-color)))) + `(whitespace-space-after-tab ((t (:foreground ,ws-color)))) + `(whitespace-space-before-tab ((t (:foreground ,ws-color)))) + `(whitespace-tab ((t (:foreground ,ws-color)))) + `(whitespace-trailing ((t (:foreground ,ws-color)))))) + +;; Make these characters represent whitespace. +(setq-default whitespace-display-mappings + '( + (space-mark 32 [183] [46]) + (newline-mark ?\n [172 ?\n] [36 ?\n]) + (newline-mark ?\r [182] [35]) + (tab-mark ?\t [187 ?\t] [62 ?\t]))) + +;; Don't enable whitespace for. +(setq-default whitespace-global-modes + '(not shell-mode + help-mode + magit-mode + magit-diff-mode + ibuffer-mode + dired-mode + occur-mode)) + +;; Set whitespace actions. +(setq-default whitespace-action + '(cleanup auto-cleanup)) + +;;; Put Emacs auto-save and backup files to /tmp/ or C:/Temp/ +(defconst emacs-tmp-dir (expand-file-name (format "emacs%d" (user-uid)) temporary-file-directory)) +(setq + backup-by-copying t ; Avoid symlinks + delete-old-versions t + kept-new-versions 6 + kept-old-versions 2 + version-control t + auto-save-list-file-prefix emacs-tmp-dir + auto-save-file-name-transforms `((".*" ,emacs-tmp-dir t)) ; Change autosave dir to tmp + backup-directory-alist `((".*" . ,emacs-tmp-dir))) + +;;; Lockfiles unfortunately cause more pain than benefit +(setq create-lockfiles nil) + +;;; Load wheatgrass as the default theme if one is not loaded already + +(if (not custom-enabled-themes) + (load-theme 'wheatgrass t)) + +(defun reload-config () + (interactive) + (load-file (expand-file-name "init.el" user-emacs-directory))) + + +;; Make a single ESC quit the current action +(global-set-key (kbd "<escape>" 'keyboard-escape-quit)) + +(add-hook 'prog-mode-hook + (lambda () + (electric-pair-local-mode))) + +;; Org mode config +(setq-default org-startup-indented t) |
