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:
parent
7b6ebf2785
commit
a3a0f1289a
1 changed files with 17 additions and 14 deletions
|
@ -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 = {
|
||||||
|
|
Loading…
Reference in a new issue