WARNING: THIS GIST IS OUT OF DATE AND NO LONGER RELEVANT
- Native-comp was enabled by default in nixpgks
- Pgtk is not enabled by default, for that you can either override the derivation or use emacsPgtk from the nix-community emacs overlay if you don't want to build it yourself
Add the nix-community overlay to your nixpkgs. You can add the following to your configuration.nix (NixOS, non-user specific) or to your home-manager's home.nix. Note in the case of the latter, this will not be available for installation via nix-env.
{
nixpkgs.overlays = [
(import (builtins.fetchTarball {
url = https://github.com/nix-community/emacs-overlay/archive/master.tar.gz;
}))
];
}
See nixos or home-manager options for more information on adding overlays.
echo "import (builtins.fetchTarball {
url = https://github.com/nix-community/emacs-overlay/archive/master.tar.gz;
})" >> $HOME/.config/nixpkgs/overlays/emacs.nix
As this package is installed via an overlay, it is not built by the Hydra CI/CD pipeline that underlies nixpkgs. Instead, the binary is built by the nix-community hydra and pushed to Cachix. Follow the instructions here to add the nix-community cachix.
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use nix-community
You will need to ensure that you are are installing the emacs overlay from the nixos-unstable unstable channel, not the nixpkgs-unstable channel. If you are using home-manager, you will need to set your default channel to nixos-unstable (you can do this on non-NixOS systems, the difference is that nixos-unstable lags behind nixpkgs-unstable due to requiring more comprehensive tests before deployment). Alternatively, you can separately import nixos-unstable import <nixos-unstable> { overlays = [ overlay1 overlay2 ]; }
separately, and use a separate channel specifically for emacs.
If you followed option 2, the following will work.
nix-env -iA nixpkgs.emacsGcc
More likely, you will want to declaratively install in your configuration.nix or home.nix.
Home-manager provides a handy module, you can also add extra packages such as vterm.
{
programs.emacs = {
enable = true;
package = pkgs.emacsGcc;
extraPackages = (epkgs: [ epkgs.vterm ] );
};
}
Alternatively you can add something like the following to you configuration.nix system packages
{
emacsWithPackages = (pkgs.emacsPackagesGen pkgs.emacsGcc).emacsWithPackages (epkgs: ([epkgs.vterm]));
}
As of 2020-08-03 the above works on fedora/ubuntu/debian and under NixOS. If you get an immediate segfault upon starting emacs, please ensure that your font is appropriately configured.
@collares Thanks! I tried that, but got an error message saying that
From what I gather, that's because user channels aren't included in the nix search path by default (according to this issue). I'm trying to see if I can figure out how to add them, but in the meantime:
Instead, I tried doing importing the unstable channel instead via a url (inspired by this post on functor.tokyo:
Now it builds, but it still has compiles Emacs from the ground up. Should this work? I wonder whether there's something wrong with my Cachix setup. There's nothing else that needs to be done than install it and run the
cachix use nix-community
command, right?Update
Wait, I managed to figure something out: I had to add the unstable channel as the root user and then run
sudo nix-channel --update nixos-unstable
. Is that the right approach?At this point the caching looks like it works. I still have to manually compile EXWM it seems, but at least that's only about a minute as opposed to fifteen, so that's better.
Still, if it's possible to use the cache and the unstable channel without needing to have a stable channel set up (such as by using
fetchTarball
to get the channel, for instance), I'd be very interested in hearing about that. And if it isn't, why isn't it?