Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document embedding Emacs configuration inside of an emacsWithPackages #24243

Closed
grahamc opened this issue Mar 23, 2017 · 3 comments
Closed

Document embedding Emacs configuration inside of an emacsWithPackages #24243

grahamc opened this issue Mar 23, 2017 · 3 comments

Comments

@grahamc
Copy link
Member

grahamc commented Mar 23, 2017

Issue description

I spent a long time trying to figure out how to make an emacsWithPackages that contained my personal configuration. I wanted to avoid having an ~/.emacs.d/init.el`. I don't know where else to put this sort of knowledge, and it may not be idiomatic emacs, but I think it is worth documenting:

{ pkgs ? import <nixpkgs> {} }:
let
  stdenv = pkgs.stdenv;

  emacsEcosystem = pkgs.emacsPackagesNg;
  trivialBuild = pkgs.callPackage <nixpkgs/pkgs/build-support/emacs/trivial.nix> {
    emacs = pkgs.emacs;
  };

  my-mode = emacsEcosystem.trivialBuild {
    pname = "my-mode";
    version = "1970-01-01";
    src = pkgs.writeText "default.el" ''
      ;; You can put global config here, especially things that don't
      ;; symbols from plugins to be defined
      (global-set-key (kbd "<end>") 'end-of-line)
      (global-set-key (kbd "<home>") 'beginning-of-line)
      (add-hook 'before-save-hook 'delete-trailing-whitespace)
      (setq graphviz-dot-dot-program "${pkgs.graphviz}/bin/dot")
      (setq graphviz-dot-view-edit-command nil)


      (defun my-moode-delayed-load ()
            (editorconfig-mode 1)
      )
      (add-hook 'after-init-hook #'my-mode-delayed-load)
    '';
  };
in
(emacsEcosystem.emacsWithPackages (epkgs: with epkgs.melpaPackages; [
  editorconfig
  graphviz-dot-mode
] ++ [my-mode]))
@rlupton20
Copy link
Contributor

rlupton20 commented Mar 23, 2017

Agree - I have a completely different way to do this, which I'm not sure is particularly nice. I chuck my .emacs into site-start.el...

Could probably write a nice wrapper for this kind of thing to make it cleaner.

@matthewbauer
Copy link
Member

Similar issue: #19956

@rlupton20
Copy link
Contributor

@matthewbauer looks like you solved this similarly to me (except properly). Lets chase up the pull request rejection, and see what we can do.

matthewbauer added a commit to matthewbauer/nixpkgs that referenced this issue May 21, 2017
This gives some basics on configuring Emacs within Nix. The
configuration is fairly long just to give a good idea of what’s going
on. I can trim out some of it if it’s not necessary. Note that there
is already a section for Emacs in the NixOS manual. However, this is
aimed at avoiding using modules altogether to make things easier for
non-NixOS users. This configuration should work on NixOS anyway,
however.

Fixes NixOS#24243
Fixes NixOS#19956
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants