1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

emacs: make service package configurable

This commit is contained in:
Terje Larsen 2020-11-19 00:19:50 +01:00 committed by Robert Helgesson
parent 7b6ebf2785
commit a3a0f1289a
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -6,8 +6,8 @@ let
cfg = config.services.emacs; cfg = config.services.emacs;
emacsCfg = config.programs.emacs; emacsCfg = config.programs.emacs;
emacsBinPath = "${emacsCfg.finalPackage}/bin"; emacsBinPath = "${cfg.package}/bin";
emacsVersion = getVersion emacsCfg.finalPackage; emacsVersion = getVersion cfg.package;
# Adapted from upstream emacs.desktop # Adapted from upstream emacs.desktop
clientDesktopItem = pkgs.writeTextDir "share/applications/emacsclient.desktop" clientDesktopItem = pkgs.writeTextDir "share/applications/emacsclient.desktop"
@ -51,6 +51,16 @@ in {
options.services.emacs = { options.services.emacs = {
enable = mkEnableOption "the Emacs daemon"; enable = mkEnableOption "the Emacs daemon";
package = mkOption {
type = types.package;
default = if emacsCfg.enable then emacsCfg.finalPackage else pkgs.emacs;
defaultText = literalExample ''
if config.programs.emacs.enable then config.programs.emacs.finalPackage
else pkgs.emacs
'';
description = "The Emacs package to use.";
};
client = { client = {
enable = mkEnableOption "generation of Emacs client desktop file"; enable = mkEnableOption "generation of Emacs client desktop file";
arguments = mkOption { arguments = mkOption {
@ -72,18 +82,11 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
{ {
assertions = [ assertions = [{
{ assertion = cfg.socketActivation.enable
assertion = emacsCfg.enable; -> versionAtLeast emacsVersion "26";
message = "The Emacs service module requires" message = "Socket activation requires Emacs 26 or newer.";
+ " 'programs.emacs.enable = true'."; }];
}
{
assertion = cfg.socketActivation.enable
-> versionAtLeast emacsVersion "26";
message = "Socket activation requires Emacs 26 or newer.";
}
];
systemd.user.services.emacs = { systemd.user.services.emacs = {
Unit = { Unit = {