emacs: create one config file
This commit is contained in:
parent
cf3a2d98c7
commit
32c47479b1
|
@ -1,5 +1,8 @@
|
|||
{ config, lib, pkgs, materusArg, ... }:
|
||||
let
|
||||
configPath = "${materusArg.cfg.path}" + "/extraFiles/config/emacs/";
|
||||
|
||||
inits = import ./init.nix {path = configPath; inherit pkgs;};
|
||||
packages = epkgs: with epkgs; [
|
||||
load-relative
|
||||
elcord
|
||||
|
@ -61,61 +64,24 @@ let
|
|||
default-config = ''
|
||||
(defvar materus/nix-packages t)
|
||||
(defvar materus/init-from-home nil)
|
||||
(defvar materus/init-from-default nil)
|
||||
(when (not materus/init-from-home)
|
||||
(setq-default materus/home-dir (concat user-emacs-directory "materus/" ))
|
||||
(setq-default materus/init-from-default t)
|
||||
(message "Config loading not from homeDir, need "materus/init-from-home" variable in init.el")
|
||||
|
||||
(unless materus/init-from-home
|
||||
(message "Config loading not from homeDir, need \"materus/init-from-home\" variable in init.el")
|
||||
${setNixInit}
|
||||
(require 'materus-config)
|
||||
${inits.initText}
|
||||
)
|
||||
'';
|
||||
|
||||
|
||||
|
||||
materus-config = epkgs: epkgs.trivialBuild rec {
|
||||
pname = "materus-config";
|
||||
src = pkgs.symlinkJoin {
|
||||
name = "materus-emacs-config";
|
||||
paths = [
|
||||
configPath
|
||||
];
|
||||
};
|
||||
version = "1.0";
|
||||
packageRequires = (packages epkgs);
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
emacs -L . --batch -f batch-byte-compile **/*.el
|
||||
emacs -L . --batch -f batch-byte-compile *.el
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
LISPDIR=$out/share/emacs/site-lisp
|
||||
install -d $LISPDIR
|
||||
install **.el **.elc $LISPDIR
|
||||
cp -r materus $LISPDIR
|
||||
emacs --batch -l package --eval "(package-generate-autoloads \"${pname}\" \"$LISPDIR\")"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
|
||||
cfg = config.materus.profile.editor.emacs;
|
||||
configPath = "${materusArg.cfg.path}" + "/extraFiles/config/emacs/";
|
||||
emacsPkgs = with pkgs;[
|
||||
python3
|
||||
lua
|
||||
multimarkdown
|
||||
git
|
||||
];
|
||||
|
||||
|
||||
cfg = config.materus.profile.editor.emacs;
|
||||
|
||||
|
||||
setNixInit = ''
|
||||
(setenv "PATH" (concat (getenv "PATH") ":${lib.makeBinPath emacsPkgs}"))
|
||||
${builtins.concatStringsSep "\n" (builtins.map (x: "(setq exec-path (append exec-path '(\""+x+"/bin\")))" ) emacsPkgs)}
|
||||
|
@ -129,32 +95,26 @@ in
|
|||
home.activation.emacsCompile = lib.hm.dag.entryAfter [ "linkGeneration" ] ''
|
||||
${config.programs.emacs.finalPackage}/bin/emacs --batch \
|
||||
--eval '(setq warning-minimum-log-level :error)' \
|
||||
--eval '(byte-recompile-directory "${config.xdg.configHome}/emacs/materus" 0 t)' \
|
||||
--eval '(byte-recompile-file "${config.xdg.configHome}/emacs/init.el")'
|
||||
--eval '(byte-compile-file "${config.xdg.configHome}/emacs/early-init.el")' \
|
||||
--eval '(byte-compile-file "${config.xdg.configHome}/emacs/init.el")'
|
||||
'';
|
||||
xdg.configFile."emacs/init.el".text = ''
|
||||
(setq inhibit-defaul-init 1)
|
||||
(setq native-comp-speed 3)
|
||||
(defvar materus/nix-packages nil)
|
||||
(defvar materus/init-from-home t)
|
||||
(defvar materus/init-from-default nil)
|
||||
${setNixInit}
|
||||
(setq-default materus/init-from-home t)
|
||||
(setq-default materus/home-dir (concat user-emacs-directory "materus/" ))
|
||||
(setq-default materus/nix-packages (require 'materus-config nil 'noerror))
|
||||
(when (not materus/nix-packages)
|
||||
(load (concat user-emacs-directory "materus/init"))
|
||||
(message "Config loaded from user dir")
|
||||
)
|
||||
|
||||
${setNixInit}
|
||||
${inits.initText}
|
||||
'';
|
||||
xdg.configFile."emacs/materus" = {
|
||||
source = configPath + "materus";
|
||||
recursive = true;
|
||||
};
|
||||
|
||||
xdg.configFile."emacs/early-init.el".text = ''
|
||||
${inits.earlyInitText}
|
||||
'';
|
||||
|
||||
programs.emacs = {
|
||||
enable = true;
|
||||
package = with pkgs; lib.mkDefault (emacs29.override { withX = true; withGTK3 = true; withAlsaLib = true; withGconf = true; withImageMagick = true; withXwidgets = true; });
|
||||
extraPackages = epkgs: ((packages epkgs) ++ [(materus-config epkgs)]);
|
||||
extraPackages = epkgs: ((packages epkgs));
|
||||
extraConfig = default-config;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
{path, pkgs}:
|
||||
{
|
||||
|
||||
earlyInitText = ''
|
||||
${builtins.readFile (path + "early-init.el")}
|
||||
'';
|
||||
initText = ''
|
||||
(defvar materus/init-early nil)
|
||||
(unless materus/init-early
|
||||
(tool-bar-mode -1)
|
||||
(setq initial-major-mode 'fundamental-mode)
|
||||
(setq-default package-quickstart t)
|
||||
(setq native-comp-speed 3)
|
||||
)
|
||||
(defvar materus/init-from-home nil)
|
||||
(when materus/init-from-home
|
||||
(setq-default inhibit-defaul-init 1)
|
||||
)
|
||||
(setq-default materus/nix-packages (require 'doom-themes nil 'noerror))
|
||||
${builtins.readFile (path + "packages.el")}
|
||||
${builtins.readFile (path + "init.el")}
|
||||
'';
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
|
||||
|
||||
(defvar materus/init-early t)
|
||||
(setq materus/init-early t)
|
||||
|
||||
(tool-bar-mode -1)
|
||||
(setq initial-major-mode 'fundamental-mode)
|
||||
(setq-default package-quickstart t)
|
||||
(setq native-comp-speed 3)
|
||||
|
||||
(unless (daemonp)
|
||||
(setq gc-cons-threshold most-positive-fixnum ; 2^61 bytes
|
||||
gc-cons-percentage 0.6)
|
||||
(setq package-enable-at-startup nil)
|
||||
|
||||
(add-hook 'emacs-startup-hook (lambda () (package-initialize)
|
||||
(setq gc-cons-threshold 16777216 ; 16mb
|
||||
gc-cons-percentage 0.1)
|
||||
))
|
||||
|
||||
|
||||
(advice-add #'tty-run-terminal-initialization :override #'ignore)
|
||||
(add-hook 'window-setup-hook
|
||||
(lambda ()
|
||||
(advice-remove #'tty-run-terminal-initialization #'ignore)
|
||||
(tty-run-terminal-initialization (selected-frame) nil t)
|
||||
)
|
||||
)
|
||||
)
|
|
@ -1,31 +1,9 @@
|
|||
(defvar materus/nix-packages nil)
|
||||
(defvar materus/init-from-home nil)
|
||||
(defvar materus/home-dir (concat user-emacs-directory "materus/" ))
|
||||
|
||||
(setq native-comp-async-report-warnings-errors nil)
|
||||
(setq package-enable-at-startup nil)
|
||||
(setq frame-inhibit-implied-resize t)
|
||||
|
||||
|
||||
(when (not materus/nix-packages)
|
||||
(message "Not using config from nix packages, using straight")
|
||||
(defvar bootstrap-version)
|
||||
(let ((bootstrap-file
|
||||
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
|
||||
(bootstrap-version 6))
|
||||
(unless (file-exists-p bootstrap-file)
|
||||
(with-current-buffer
|
||||
(url-retrieve-synchronously
|
||||
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
|
||||
'silent 'inhibit-cookies)
|
||||
(goto-char (point-max))
|
||||
(eval-print-last-sexp)))
|
||||
(load bootstrap-file nil 'nomessage))
|
||||
(declare-function straight-use-package "straight" (&optional ARG))
|
||||
(declare-function load-relative "load-relative" (&optional ARG))
|
||||
(straight-use-package 'load-relative)
|
||||
(load-relative "packages")
|
||||
)
|
||||
|
||||
(require 'telephone-line)
|
||||
(require 'elcord)
|
||||
(require 'dashboard)
|
|
@ -1,5 +0,0 @@
|
|||
(message "Config loading from package")
|
||||
(setq-default materus/nix-packages t)
|
||||
(require 'load-relative)
|
||||
(load-relative "materus/init")
|
||||
(provide 'materus-config)
|
|
@ -1,11 +0,0 @@
|
|||
(straight-use-package 'use-package)
|
||||
(straight-use-package 'telephone-line)
|
||||
(straight-use-package 'elcord)
|
||||
(straight-use-package 'dashboard)
|
||||
(straight-use-package 'minions)
|
||||
(straight-use-package 'lsp-mode)
|
||||
(straight-use-package 'lsp-ui)
|
||||
|
||||
(straight-use-package 'moe-theme)
|
||||
(straight-use-package 'doom-themes)
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
(defvar materus/nix-packages nil)
|
||||
|
||||
|
||||
|
||||
(when (not materus/nix-packages)
|
||||
(message "Not using config from nix packages, using straight")
|
||||
(defvar bootstrap-version)
|
||||
(let ((bootstrap-file
|
||||
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
|
||||
(bootstrap-version 6))
|
||||
(unless (file-exists-p bootstrap-file)
|
||||
(with-current-buffer
|
||||
(url-retrieve-synchronously
|
||||
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
|
||||
'silent 'inhibit-cookies)
|
||||
(goto-char (point-max))
|
||||
(eval-print-last-sexp)))
|
||||
(load bootstrap-file nil 'nomessage))
|
||||
(declare-function straight-use-package "straight" (&optional ARG))
|
||||
(straight-use-package 'load-relative)
|
||||
|
||||
(straight-use-package 'use-package)
|
||||
(straight-use-package 'telephone-line)
|
||||
(straight-use-package 'elcord)
|
||||
(straight-use-package 'dashboard)
|
||||
(straight-use-package 'minions)
|
||||
(straight-use-package 'lsp-mode)
|
||||
(straight-use-package 'lsp-ui)
|
||||
|
||||
(straight-use-package 'moe-theme)
|
||||
(straight-use-package 'doom-themes)
|
||||
)
|
||||
|
Loading…
Reference in New Issue