Generalize emacs argument in shell.nix

This commit is contained in:
Henrik Lissner 2020-08-11 20:53:27 -04:00
parent 8fc82cacdb
commit 132b8390d0
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -13,29 +13,40 @@
# #
# With a specific version of Emacs # With a specific version of Emacs
# #
# nix-shell --arg emacs pkgs.emacs # 26.3 # nix-shell --arg emacs 26 # 26.3
# nix-shell --arg emacs pkgs.emacsUnstable # 27.x # nix-shell --arg emacs 27 # 27.1
# nix-shell --arg emacs pkgs.emacs # 28+ # nix-shell --arg emacs 28 # HEAD
{ pkgs ? (import <nixpkgs> {}) { pkgs ?
, emacs ? pkgs.emacs import <nixpkgs> {
overlays = [
import (builtins.fetchTarball https://github.com/nix-community/emacs-overlay/archive/master.tar.gz)
];
}
, emacs ? 26
, emacsdir ? "$(pwd)/.." , emacsdir ? "$(pwd)/.."
, doomdir ? "$(pwd)" , doomdir ? "$(pwd)"
, doomlocaldir ? "$(pwd)/.local" }: , doomlocaldir ? "$(pwd)/.local" }:
pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {
name = "doom-emacs"; name = "doom-emacs";
buildInputs = [ buildInputs = [
emacs (if emacs == 28 then pkgs.emacsGit
else if emacs == 27 then pkgs.emacsUnstable
else pkgs.emacs)
pkgs.git pkgs.git
(pkgs.ripgrep.override {withPCRE2 = true;}) (pkgs.ripgrep.override {withPCRE2 = true;})
]; ];
shellHook = '' shellHook = ''
export EMACSVERSION="$(emacs --no-site-file --batch --eval '(princ emacs-version)')" export EMACSVERSION="$(emacs --no-site-file --batch --eval '(princ emacs-version)')"
export EMACSDIR="$(readlink -f "${emacsdir}")/" export EMACSDIR="$(readlink -f "${emacsdir}")/"
export DOOMDIR="$(readlink -f "${doomdir}")/" export DOOMDIR="$(readlink -f "${doomdir}")/"
export DOOMLOCALDIR="$(readlink -f "${doomlocaldir}").$EMACSVERSION/" export DOOMLOCALDIR="$(readlink -f "${doomlocaldir}").$EMACSVERSION/"
export PATH="$EMACSDIR/bin:$PATH" export PATH="$EMACSDIR/bin:$PATH"
echo "Running Emacs $EMACSVERSION"
echo "EMACSDIR=$EMACSDIR" echo "EMACSDIR=$EMACSDIR"
echo "DOOMDIR=$DOOMDIR" echo "DOOMDIR=$DOOMDIR"
echo "DOOMLOCALDIR=$DOOMLOCALDIR" echo "DOOMLOCALDIR=$DOOMLOCALDIR"