nixos/services.emacs: remove with lib;
This commit is contained in:
parent
260654677f
commit
facc95c0ce
@ -1,7 +1,4 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.emacs;
|
||||
@ -18,8 +15,8 @@ in
|
||||
{
|
||||
|
||||
options.services.emacs = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to enable a user service for the Emacs daemon. Use `emacsclient` to connect to the
|
||||
@ -28,8 +25,8 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
install = mkOption {
|
||||
type = types.bool;
|
||||
install = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to install a user service for the Emacs daemon. Once
|
||||
@ -43,10 +40,10 @@ in
|
||||
};
|
||||
|
||||
|
||||
package = mkPackageOption pkgs "emacs" { };
|
||||
package = lib.mkPackageOption pkgs "emacs" { };
|
||||
|
||||
defaultEditor = mkOption {
|
||||
type = types.bool;
|
||||
defaultEditor = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
When enabled, configures emacsclient to be the default editor
|
||||
@ -54,17 +51,17 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
startWithGraphical = mkOption {
|
||||
type = types.bool;
|
||||
startWithGraphical = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = config.services.xserver.enable;
|
||||
defaultText = literalExpression "config.services.xserver.enable";
|
||||
defaultText = lib.literalExpression "config.services.xserver.enable";
|
||||
description = ''
|
||||
Start emacs with the graphical session instead of any session. Without this, emacs clients will not be able to create frames in the graphical session.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable || cfg.install) {
|
||||
config = lib.mkIf (cfg.enable || cfg.install) {
|
||||
systemd.user.services.emacs = {
|
||||
description = "Emacs: the extensible, self-documenting text editor";
|
||||
|
||||
@ -75,16 +72,16 @@ in
|
||||
Restart = "always";
|
||||
};
|
||||
|
||||
unitConfig = optionalAttrs cfg.startWithGraphical {
|
||||
unitConfig = lib.optionalAttrs cfg.startWithGraphical {
|
||||
After = "graphical-session.target";
|
||||
};
|
||||
} // optionalAttrs cfg.enable {
|
||||
} // lib.optionalAttrs cfg.enable {
|
||||
wantedBy = if cfg.startWithGraphical then [ "graphical-session.target" ] else [ "default.target" ];
|
||||
};
|
||||
|
||||
environment.systemPackages = [ cfg.package editorScript ];
|
||||
|
||||
environment.variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "emacseditor");
|
||||
environment.variables.EDITOR = lib.mkIf cfg.defaultEditor (lib.mkOverride 900 "emacseditor");
|
||||
};
|
||||
|
||||
meta.doc = ./emacs.md;
|
||||
|
Loading…
Reference in New Issue
Block a user