diff --git a/nix/configuration/hosts/neelix/default.nix b/nix/configuration/hosts/neelix/default.nix index 926d60c..870e21e 100644 --- a/nix/configuration/hosts/neelix/default.nix +++ b/nix/configuration/hosts/neelix/default.nix @@ -28,4 +28,5 @@ me.kodi.enable = true; me.bluetooth.enable = true; + me.emacs_flavor = "plainmacs"; } diff --git a/nix/configuration/hosts/odo/default.nix b/nix/configuration/hosts/odo/default.nix index 5690f4d..defc7df 100644 --- a/nix/configuration/hosts/odo/default.nix +++ b/nix/configuration/hosts/odo/default.nix @@ -34,4 +34,5 @@ me.sway.enable = true; me.ansible.enable = true; + me.emacs_flavor = "full"; } diff --git a/nix/configuration/roles/emacs/default.nix b/nix/configuration/roles/emacs/default.nix index 86c862b..695ce9c 100644 --- a/nix/configuration/roles/emacs/default.nix +++ b/nix/configuration/roles/emacs/default.nix @@ -39,69 +39,113 @@ let e_shorthand = pkgs.writeShellScriptBin "e" '' exec ${pkgs.emacs_full}/bin/emacs "''${@}" ''; + plain_e_shorthand = pkgs.writeShellScriptBin "e" '' + exec ${pkgs.emacs29-pgtk}/bin/emacs "''${@}" + ''; in { imports = [ ]; - config = lib.mkMerge [ - { - environment.systemPackages = with pkgs; [ - plainmacs - e_shorthand - emacs_full - ]; + 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."; + }; - 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 + config = + lib.mkIf config.me.emacs_flavor != null ( + lib.mkMerge [ + (lib.mkIf (config.me.emacs_flavor == "full") { + environment.systemPackages = with pkgs; [ + plainmacs + e_shorthand + emacs_full + ]; + + 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 + pkgs.shellcheck ] - )) - 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) { + 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 + ]; + }; }; + + environment.variables.EDITOR = "${plainmacs}/bin/plainmacs"; }) - ]; + (lib.mkIf (config.me.emacs_flavor == "plainmacs") { + environment.systemPackages = with pkgs; [ + emacs29-pgtk + plainmacs + plain_e_shorthand + ]; - home-manager.users.talexander = - { pkgs, ... }: - { - home.file.".config/emacs" = { - source = ./files/emacs; - recursive = true; + 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 + ]; + }; }; - }; - 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 - ]; - }; - }; - - environment.variables.EDITOR = "${plainmacs}/bin/plainmacs"; - } - ]; + environment.variables.EDITOR = "${plainmacs}/bin/plainmacs"; + }) + ] + ); }