1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-28 20:59:47 +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;
emacsCfg = config.programs.emacs;
emacsBinPath = "${emacsCfg.finalPackage}/bin";
emacsVersion = getVersion emacsCfg.finalPackage;
emacsBinPath = "${cfg.package}/bin";
emacsVersion = getVersion cfg.package;
# Adapted from upstream emacs.desktop
clientDesktopItem = pkgs.writeTextDir "share/applications/emacsclient.desktop"
@ -51,6 +51,16 @@ in {
options.services.emacs = {
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 = {
enable = mkEnableOption "generation of Emacs client desktop file";
arguments = mkOption {
@ -72,18 +82,11 @@ in {
config = mkIf cfg.enable (mkMerge [
{
assertions = [
{
assertion = emacsCfg.enable;
message = "The Emacs service module requires"
+ " 'programs.emacs.enable = true'.";
}
{
assertion = cfg.socketActivation.enable
-> versionAtLeast emacsVersion "26";
message = "Socket activation requires Emacs 26 or newer.";
}
];
assertions = [{
assertion = cfg.socketActivation.enable
-> versionAtLeast emacsVersion "26";
message = "Socket activation requires Emacs 26 or newer.";
}];
systemd.user.services.emacs = {
Unit = {