NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.41k stars 13.63k forks source link

services.emacs.{enable, install} do not work #69287

Closed Anton-Latukha closed 4 years ago

Anton-Latukha commented 4 years ago

Description

(the cause of this report, was remains of soft link in ~/.config/systemd/user/ and leftovers of overrides in ~/.config/systemd/user/emacs.service.d/)

services.emacs.install used to provide me a systemd user service. Which was as such available by systemctl --user {cat, enable, start, edit} emacs.service.

After recent update (~a week ago), service dissapeared. I am on nixos-unstable, so the change causing this, is probably https://github.com/NixOS/nixpkgs/commit/cc125810cb4f305c5bcee937648ff3704f13c472#diff-754738b9bf80ce26b4b69e5e7216cb28

services.emacs.enable also does not work, does not provide me a user service.

Checked that there is also not any service for root.

Reproducing

Expected behavior

Keys services.emacs.{enable, install} to provide services as before, for which they was created & according to documentation.

Additional context Add any other context about the problem here.

Metadata

Maintainer information:

nixpkgs/nixos/modules/services/editors/emacs.nix
attribute:
  - services.emacs.install
  - services.emacs.enable
Anton-Latukha commented 4 years ago

@worldofpeace you recently changed these emacs options.

Anton-Latukha commented 4 years ago

Currently I am rebuilding into the previous commit, which is before marked above emacs options change. The prior master state is 5669b062356b5d5b8019ecc706a70d75ec30da0f. ... pycairo failed the build. Better lack next time.

worldofpeace commented 4 years ago

On d484f2b7fc0834a068e8ace851faa449a03963f5 I couldn't reproduce the systemd service not working or existing. And this was under a GTK environment.

https://github.com/NixOS/nixpkgs/commit/cc125810cb4f305c5bcee937648ff3704f13c472#diff-754738b9bf80ce26b4b69e5e7216cb28 should have been a no-op because that exact environment variable was set in a different module, just now globally https://github.com/NixOS/nixpkgs/blob/58f090cc7b92edfee8c390b5a131a1417273c590/nixos/modules/programs/environment.nix#L24.

What environment are you using emacs under?

Anton-Latukha commented 4 years ago

SDDM & KDE Plasma 5, as I mentioned in Reproducing.

I also right away thought that it must be GTK in Plasma thing.

But how variable can cause service to not appear.

worldofpeace commented 4 years ago

Thanks, I should have read better :smile: . I will try this in plasma 5.

Anton-Latukha commented 4 years ago

Also in commit what was deleted in emacs, was

      GTK_DATA_PREFIX = "${config.system.path}";
    } // (if cfg.defaultEditor then {
        EDITOR = mkOverride 900 "${editorScript}/bin/emacseditor";
      } else {}

I did not have that cfg.defaultEditor systemwide or in user (EDITOR == nano(facepalm shame)).

So that if results in {}.

Anton-Latukha commented 4 years ago

Seems I found the effect. Look at the full code replaced:

    environment.variables = {
      # This is required so that GTK applications launched from Emacs
      # get properly themed:
      GTK_DATA_PREFIX = "${config.system.path}";
    } // (if cfg.defaultEditor then {
        EDITOR = mkOverride 900 "${editorScript}/bin/emacseditor";
      } else {});

That means that to:

{
      # This is required so that GTK applications launched from Emacs
      # get properly themed:
      GTK_DATA_PREFIX = "${config.system.path}";
    }

if default editor is emacs => EDITOR = mkOverride 900 "${editorScript}/bin/emacseditor" Else - add to the set {}, aka add Nothing.

What got inserted:

environment.variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "${editorScript}/bin/emacseditor");

If cfg.defaultEditor - EDITOR = mkOverride 900 "${editorScript}/bin/emacseditor" Else - force EDITOR = [ ], aka force EDITOR = Empty list.

So before in else case - EDITOR war was not touched. And after this commit in else EDITOR becomes empty.

Since: https://github.com/NixOS/nixpkgs/blob/c277a508fceb086eb4e71682957d731447d08b74/lib/modules.nix#L408 Pam-pam pam.

So, seems like new code always modifies the EDITOR variable, it is or Emacs or nothing. Which I am keen for that BTW :slightly_smiling_face:. Or do I not know the Nix enough, and there some very strange case that the EDITOR = [ ] does not declare an empty value of a variable.

Anton-Latukha commented 4 years ago

Probably the proper thing is I just need to fix this moment and not talk about. And thank you for all your work.

Anton-Latukha commented 4 years ago

I troubleshooted this.

This was a mis-bugreport, changed the header.