2024-12-20 22:36:32 -05:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-12-20 13:12:27 -05:00
|
|
|
|
2024-12-20 13:59:09 -05:00
|
|
|
let
|
2025-01-22 21:26:14 -05:00
|
|
|
plainmacs =
|
|
|
|
emacs_package:
|
|
|
|
pkgs.writeShellScriptBin "plainmacs" ''
|
|
|
|
INIT_SCRIPT=$(cat <<EOF
|
|
|
|
(progn
|
|
|
|
(setq make-backup-files nil auto-save-default nil create-lockfiles nil)
|
|
|
|
(load-theme 'tango-dark t)
|
|
|
|
(set-face-attribute 'default nil :background "black")
|
|
|
|
;; Bright yellow highlighting for selected region
|
|
|
|
(set-face-attribute 'region nil :background "#ffff50" :foreground "black")
|
|
|
|
;; Bright green cursor to distinguish from yellow region
|
|
|
|
(set-cursor-color "#ccff66")
|
|
|
|
;; Hightlight the current line
|
|
|
|
(set-face-attribute 'line-number-current-line nil :foreground "white")
|
|
|
|
;; Set default font
|
|
|
|
(set-face-attribute 'default nil :height 100 :width 'regular :weight 'regular :family "Cascadia Mono")
|
|
|
|
;; Set fallback font for unicode glyphs
|
|
|
|
(when (display-graphic-p)
|
|
|
|
(set-fontset-font "fontset-default" nil (font-spec :name "Noto Color Emoji")))
|
|
|
|
(menu-bar-mode -1)
|
|
|
|
(when (fboundp 'tool-bar-mode)
|
|
|
|
(tool-bar-mode -1))
|
|
|
|
(when ( fboundp 'scroll-bar-mode)
|
|
|
|
(scroll-bar-mode -1))
|
|
|
|
(pixel-scroll-precision-mode)
|
|
|
|
(setq frame-resize-pixelwise t)
|
|
|
|
)
|
|
|
|
EOF
|
2024-12-20 22:36:32 -05:00
|
|
|
)
|
2024-12-20 13:59:09 -05:00
|
|
|
|
2025-01-22 21:26:14 -05:00
|
|
|
exec ${emacs_package}/bin/emacs -q --eval "$INIT_SCRIPT" "''${@}"
|
|
|
|
'';
|
|
|
|
e_shorthand =
|
|
|
|
emacs_package:
|
|
|
|
pkgs.writeShellScriptBin "e" ''
|
|
|
|
exec ${emacs_package}/bin/emacs "''${@}"
|
|
|
|
'';
|
2024-12-20 13:59:09 -05:00
|
|
|
in
|
2024-12-20 13:12:27 -05:00
|
|
|
{
|
2024-12-20 22:36:32 -05:00
|
|
|
imports = [ ];
|
2024-12-20 13:12:27 -05:00
|
|
|
|
2025-01-22 21:01:34 -05:00
|
|
|
options.me.emacs_flavor = lib.mkOption {
|
|
|
|
type = lib.types.nullOr (
|
|
|
|
lib.types.enum [
|
|
|
|
"full"
|
|
|
|
"plainmacs"
|
|
|
|
]
|
|
|
|
);
|
|
|
|
default = null;
|
|
|
|
example = "full";
|
|
|
|
description = "What flavor of emacs to set up.";
|
|
|
|
};
|
|
|
|
|
2025-01-22 21:26:14 -05:00
|
|
|
config = lib.mkIf (config.me.emacs_flavor != null) (
|
|
|
|
lib.mkMerge [
|
|
|
|
{
|
|
|
|
environment.systemPackages = with pkgs; [
|
2025-01-23 01:52:37 -05:00
|
|
|
my_emacs
|
|
|
|
(plainmacs my_emacs)
|
|
|
|
(e_shorthand my_emacs)
|
2025-01-22 21:26:14 -05:00
|
|
|
];
|
2024-12-20 13:12:27 -05:00
|
|
|
|
2025-01-22 21:26:14 -05:00
|
|
|
environment.persistence."/state" = lib.mkIf (!config.me.buildingIso) {
|
|
|
|
hideMounts = true;
|
|
|
|
users.talexander = {
|
|
|
|
directories = [
|
|
|
|
".config/emacs/eln-cache" # Installed packages
|
|
|
|
".config/emacs/elpa" # Installed packages
|
|
|
|
".config/emacs/private" # For recentf
|
|
|
|
".config/emacs/tree-sitter" # Compiled tree-sitter grammars
|
|
|
|
];
|
|
|
|
files = [
|
|
|
|
".config/emacs/history" # For savehist
|
|
|
|
".config/emacs/.last-package-update-day" # For use-package
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2025-01-22 21:01:34 -05:00
|
|
|
|
2025-01-23 21:06:11 -05:00
|
|
|
environment.variables.EDITOR = "plainmacs";
|
2025-01-22 21:26:14 -05:00
|
|
|
}
|
2025-01-23 01:52:37 -05:00
|
|
|
(lib.mkIf (config.me.graphical) {
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
(final: prev: {
|
|
|
|
my_emacs = final.emacs29-pgtk;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
})
|
|
|
|
(lib.mkIf (!config.me.graphical) {
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
(final: prev: {
|
|
|
|
my_emacs = final.emacs-nox;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
})
|
2025-01-22 21:26:14 -05:00
|
|
|
(lib.mkIf (config.me.emacs_flavor == "full") {
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
(final: prev: {
|
2025-01-23 01:52:37 -05:00
|
|
|
my_emacs = pkgs.buildEnv {
|
|
|
|
name = prev.my_emacs.name;
|
2025-01-22 21:26:14 -05:00
|
|
|
paths = with prev; [
|
2025-01-23 01:52:37 -05:00
|
|
|
my_emacs
|
2025-01-22 21:01:34 -05:00
|
|
|
];
|
2025-01-22 21:26:14 -05:00
|
|
|
extraOutputsToInstall = [
|
|
|
|
"man"
|
|
|
|
"doc"
|
|
|
|
"info"
|
2025-01-22 21:01:34 -05:00
|
|
|
];
|
2025-01-23 01:52:37 -05:00
|
|
|
buildInputs = [ final.makeWrapper ];
|
2025-01-22 21:26:14 -05:00
|
|
|
postBuild = ''
|
|
|
|
wrapProgram $out/bin/emacs --prefix PATH : ${
|
|
|
|
lib.makeBinPath [
|
2025-01-23 01:52:37 -05:00
|
|
|
(final.aspellWithDicts (
|
2025-01-22 21:26:14 -05:00
|
|
|
dicts: with dicts; [
|
|
|
|
en
|
|
|
|
en-computers
|
|
|
|
]
|
|
|
|
))
|
2025-01-23 01:52:37 -05:00
|
|
|
final.nixd # nix language server
|
|
|
|
final.nixfmt-rfc-style # auto-formatting nix files through nixd
|
|
|
|
final.clang # To compile tree-sitter grammars
|
|
|
|
final.shellcheck
|
2025-01-25 10:20:02 -05:00
|
|
|
final.cmake-language-server
|
|
|
|
final.cmake # Used by cmake-language-server
|
2025-01-22 21:26:14 -05:00
|
|
|
]
|
|
|
|
}
|
|
|
|
'';
|
2025-01-22 21:01:34 -05:00
|
|
|
};
|
2025-01-22 21:26:14 -05:00
|
|
|
})
|
|
|
|
];
|
2025-01-18 21:26:17 -05:00
|
|
|
|
2025-01-22 21:26:14 -05:00
|
|
|
home-manager.users.talexander =
|
|
|
|
{ pkgs, ... }:
|
|
|
|
{
|
|
|
|
home.file.".config/emacs" = {
|
|
|
|
source = ./files/emacs;
|
|
|
|
recursive = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
(lib.mkIf (config.me.emacs_flavor == "plainmacs") {
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
(final: prev: {
|
2025-01-23 01:52:37 -05:00
|
|
|
my_emacs = pkgs.buildEnv {
|
|
|
|
name = prev.my_emacs.name;
|
2025-01-22 21:26:14 -05:00
|
|
|
paths = with prev; [
|
2025-01-23 01:52:37 -05:00
|
|
|
my_emacs
|
2025-01-22 21:01:34 -05:00
|
|
|
];
|
2025-01-22 21:26:14 -05:00
|
|
|
extraOutputsToInstall = [
|
|
|
|
"man"
|
|
|
|
"doc"
|
|
|
|
"info"
|
2025-01-22 21:01:34 -05:00
|
|
|
];
|
|
|
|
};
|
2025-01-22 21:26:14 -05:00
|
|
|
})
|
|
|
|
];
|
|
|
|
})
|
|
|
|
]
|
|
|
|
);
|
2024-12-20 13:12:27 -05:00
|
|
|
}
|