Compare commits

..

5 Commits

Author SHA1 Message Date
Tom Alexander
df2efb728d
Don't install alacritty on neelix or non-graphical installs. 2025-01-23 18:47:03 -05:00
Tom Alexander
62fc955b68
Merge branch 'plainmacs' into nix 2025-01-23 18:44:30 -05:00
Tom Alexander
e0644a069d
Add support for non-graphical emacs. 2025-01-23 01:52:56 -05:00
Tom Alexander
054e056d00
Switch to buildEnv instead of symlinkJoin for better control over the joining process. 2025-01-23 01:52:56 -05:00
Tom Alexander
d3ea8b3667
Introduce a plainmacs emacs install flavor. 2025-01-22 21:01:34 -05:00
4 changed files with 175 additions and 102 deletions

View File

@ -23,9 +23,9 @@
# Mount tmpfs at /tmp # Mount tmpfs at /tmp
boot.tmp.useTmpfs = true; boot.tmp.useTmpfs = true;
me.bluetooth.enable = true;
me.emacs_flavor = "plainmacs";
me.graphical = true; me.graphical = true;
me.graphicsCardType = "intel"; me.graphicsCardType = "intel";
me.kodi.enable = true; me.kodi.enable = true;
me.bluetooth.enable = true;
} }

View File

@ -29,9 +29,10 @@
fw-ectool fw-ectool
]; ];
me.alacritty.enable = true;
me.ansible.enable = true;
me.emacs_flavor = "full";
me.graphical = true; me.graphical = true;
me.graphicsCardType = "amd"; me.graphicsCardType = "amd";
me.sway.enable = true; me.sway.enable = true;
me.ansible.enable = true;
} }

View File

@ -7,7 +7,18 @@
{ {
imports = [ ]; imports = [ ];
options.me = {
alacritty.enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "Whether we want to install alacritty.";
};
};
config = lib.mkIf config.me.alacritty.enable (
lib.mkMerge [
(lib.mkIf config.me.graphical {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
alacritty alacritty
xdg-utils # for xdg-open xdg-utils # for xdg-open
@ -20,5 +31,8 @@
source = ./files/alacritty.toml; source = ./files/alacritty.toml;
}; };
}; };
})
]
);
} }

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"
];
};
})
];
})
]
);
} }