diff --git a/README.org b/README.org index 9b48cce..63c892b 100755 --- a/README.org +++ b/README.org @@ -364,3 +364,4 @@ Following is a subset of the many places I've learnt from. - [cite:@zaynetdinov2024you] - [[https://prelude.emacsredux.com/en/stable/][Emacs Prelude]] - [[https://github.com/doomemacs/doomemacs][Doom Emacs]] +- [[https://cce.whatthefuck.computer/cce][Ryan Rix's Complete Computing Environment]] diff --git a/modules/home/impermanence.nix b/modules/home/impermanence.nix index 564d31d..0280994 100755 --- a/modules/home/impermanence.nix +++ b/modules/home/impermanence.nix @@ -18,6 +18,28 @@ in { default = []; type = types.listOf types.anything; }; + + cache = { + directories = mkOption { + description = '' + While functionally identical to `directories` (at the moment), + `cache.directories` carries additional semantics: these directories + /can/ be erased, but typically /shouldn't/ be. + ''; + default = []; + type = types.listOf types.anything; + }; + + files = mkOption { + description = '' + While functionally identical to `files` (at the moment), + `cache.files` carries additional semantics: these files /can/ be + erased, but typically /shouldn't/ be. + ''; + default = []; + type = types.listOf types.anything; + }; + }; }; }; @@ -25,8 +47,8 @@ in { home.persistence = { "/persist/home/${config.home.username}" = { allowOther = true; - directories = cfg.directories; - files = cfg.files; + directories = cfg.directories ++ cfg.cache.directories; + files = cfg.files ++ cfg.cache.files; }; }; }; diff --git a/users/crumb/programs/emacs.nix b/users/crumb/programs/emacs.nix index 672a5bb..15525eb 100644 --- a/users/crumb/programs/emacs.nix +++ b/users/crumb/programs/emacs.nix @@ -17,8 +17,8 @@ let # Create a new instance of nixpkgs with emacs-overlay applied. This is a # little unorthodox, but we do it - # 1. for the sake of organisation — For pure aesthetics and a clean codebase, I want - # everything Emacs to stay in this file; + # 1. for the sake of organisation — For pure aesthetics and a clean + # codebase, I want everything Emacs to stay in this file; # 2. and, there's simply no need to leak emacs-overlay's packages into the # global nixpkgs instance when nothing else is using it! pkgs' = import inputs.nixpkgs { @@ -26,20 +26,32 @@ let overlays = [ emacs-overlay ]; }; - my-emacs = pkgs'.emacsWithPackagesFromUsePackage { - config = ./emacs/init.el; - defaultInitFile = false; - package = emacsPackage; - alwaysEnsure = true; - }; -in { - programs.emacs = { - enable = true; - package = my-emacs; - extraConfig = '' - (load (file-name-concat "${emacsConfigDir}" "init")) + straightBaseDir = "${config.xdg.dataHome}/straight"; + + emacsWrapper = pkgs.symlinkJoin { + name = "emacs-wrapper"; + paths = [ emacsPackage ]; + buildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + for i in $out/bin/emacs-*; do + wrapProgram "$i" \ + --add-flags "--init-directory \"${emacsConfigDir}\"" + done ''; }; +in { + sydnix.impermanence.cache.directories = [ straightBaseDir ]; + home.packages = [ emacsWrapper ]; + + home.sessionVariables.EMACS_STRAIGHT_BASE_DIR = straightBaseDir; + + # programs.emacs = { + # enable = true; + # package = emacsPackage; + # # extraConfig = '' + # # (load (file-name-concat "${emacsConfigDir}" "init")) + # # ''; + # }; services.emacs = { enable = true; diff --git a/users/crumb/programs/emacs/early-init.el b/users/crumb/programs/emacs/early-init.el new file mode 100644 index 0000000..06022ac --- /dev/null +++ b/users/crumb/programs/emacs/early-init.el @@ -0,0 +1,3 @@ +;;; early-init.el -*- lexical-binding: t; -*- + +(setq package-enable-at-startup nil) diff --git a/users/crumb/programs/emacs/init.el b/users/crumb/programs/emacs/init.el index 848f08b..01bac4a 100644 --- a/users/crumb/programs/emacs/init.el +++ b/users/crumb/programs/emacs/init.el @@ -1,6 +1,32 @@ ;; -*- lexical-binding: t; -*- -(require 'use-package-ensure) -(setq use-package-always-ensure t) +(defvar bootstrap-version) -(use-package evil) +(setq straight-base-dir + (or (getenv "EMACS_STRAIGHT_BASE_DIR") + (error "Cannot initialise straight: $EMACS_STRAIGHT_BASE_DIR is undefined!"))) + +(let ((bootstrap-file + (file-name-concat straight-base-dir + "repos/straight.el/bootstrap.el")) + (bootstrap-version 7)) + (unless (file-exists-p bootstrap-file) + (let* ((url "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el") + (url-buffer (url-retrieve-synchronously + url 'silent 'inhibit-cookies))) + (with-current-buffer url-buffer + (goto-char (point-max)) + (eval-print-last-sexp)))) + (load bootstrap-file nil 'nomessage)) + +(setq straight-use-package-by-default t) + +(use-package evil + :init + (setq evil-want-minibuffer t) + :config + (evil-mode 1)) + +(use-package which-key + :config + (which-key-mode 1))