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,7 +6,9 @@
}: }:
let let
plainmacs = pkgs.writeShellScriptBin "plainmacs" '' plainmacs =
emacs_package:
pkgs.writeShellScriptBin "plainmacs" ''
INIT_SCRIPT=$(cat <<EOF INIT_SCRIPT=$(cat <<EOF
(progn (progn
(setq make-backup-files nil auto-save-default nil create-lockfiles nil) (setq make-backup-files nil auto-save-default nil create-lockfiles nil)
@ -34,57 +36,38 @@ let
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 (
lib.types.enum [
"full"
"plainmacs"
]
);
default = null;
example = "full";
description = "What flavor of emacs to set up.";
};
config = lib.mkIf (config.me.emacs_flavor != null) (
lib.mkMerge [
{ {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
plainmacs my_emacs
e_shorthand (plainmacs my_emacs)
emacs_full (e_shorthand my_emacs)
]; ];
nixpkgs.overlays = [
(final: prev: {
emacs_full = pkgs.symlinkJoin {
name = "emacs_full";
paths = [ pkgs.emacs29-pgtk ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
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 =
{ pkgs, ... }:
{
home.file.".config/emacs" = {
source = ./files/emacs;
recursive = true;
};
};
environment.persistence."/state" = lib.mkIf (!config.me.buildingIso) { environment.persistence."/state" = lib.mkIf (!config.me.buildingIso) {
hideMounts = true; hideMounts = true;
users.talexander = { users.talexander = {
@ -101,7 +84,82 @@ in
}; };
}; };
environment.variables.EDITOR = "${plainmacs}/bin/plainmacs"; environment.variables.EDITOR = "${pkgs.my_emacs}/bin/plainmacs";
} }
(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;
})
];
})
(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
]
}
'';
};
})
];
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"
];
};
})
];
})
]
);
} }