Merge branch 'plainmacs' into nix

This commit is contained in:
Tom Alexander 2025-01-23 18:44:30 -05:00
commit 62fc955b68
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 146 additions and 86 deletions

View File

@ -28,4 +28,5 @@
me.kodi.enable = true; me.kodi.enable = true;
me.bluetooth.enable = true; me.bluetooth.enable = true;
me.emacs_flavor = "plainmacs";
} }

View File

@ -34,4 +34,5 @@
me.sway.enable = true; me.sway.enable = true;
me.ansible.enable = true; me.ansible.enable = true;
me.emacs_flavor = "full";
} }

View File

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