From c6523761ac2202632260ca8e60ef4fb5ad2d4d6a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 14 Apr 2021 01:01:25 -0400 Subject: [PATCH] Fix test/shell.nix Can now be used to deploy any version of Emacs between 25.3 and HEAD. --- test/shell.nix | 52 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/test/shell.nix b/test/shell.nix index f6c846983..c5348d12f 100644 --- a/test/shell.nix +++ b/test/shell.nix @@ -13,40 +13,64 @@ # # With a specific version of Emacs # -# nix-shell --arg emacs 26 # 26.3 -# nix-shell --arg emacs 27 # 27.1 -# nix-shell --arg emacs 28 # HEAD +# nix-shell --argstr emacs 26 # 26.3 +# nix-shell --argstr emacs 27 # 27.1 +# nix-shell --argstr emacs 28 # 28.0.50 +# nix-shell --argstr emacs gcc # 28.0.50 + native-comp +# nix-shell --argstr emacs pgtk+gcc # 28.0.50 + pgtk + native-comp +# nix-shell --argstr emacs ci-26.3 # 26.3 (barebones; no GUI) +# nix-shell --argstr emacs ci-27.1 # 27.1 (barebones; no GUI) +# nix-shell --argstr emacs ci-27.2 # 27.2 (barebones; no GUI) +# nix-shell --argstr emacs ci-HEAD # 28.0.50 (barebones; no GUI) -{ pkgs ? - import { +# nixpkgs: provides Emacs 26.3 and 27.1 +{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/20.09.tar.gz") + { overlays = [ - import (builtins.fetchTarball https://github.com/nix-community/emacs-overlay/archive/master.tar.gz) + # emacs-overlay: provides Emacs 28, native-comp, and pgtk + (import (fetchTarball "https://github.com/nix-community/emacs-overlay/archive/85cc3a1fd067440181a4902455912e7c08ec26c8.tar.gz")) + # nix-emacs-ci: provides CI versions of Emacs 26.3, 27.1, 27.2, and 28.0.50 + (_: _: (import (fetchTarball "https://github.com/purcell/nix-emacs-ci/archive/master.tar.gz"))) + # Pull Emacs 27.2 from later version of nixpkgs + (_: _: { emacs27-2 = (import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/4c87cb87a2db6b9eb43541c1cf83f2a2f725fa25.tar.gz") {}).emacs; }) ]; } -, emacs ? 26 +, emacs ? "27" , emacsdir ? "$(pwd)/.." , doomdir ? "$(pwd)" , doomlocaldir ? "$(pwd)/.local" }: -pkgs.stdenv.mkDerivation { +let emacsPkg = (if emacs == "26" then pkgs.emacs26 + else if emacs == "27" then pkgs.emacs27-2 + else if emacs == "27.1" then pkgs.emacs27 + else if emacs == "27.2" then pkgs.emacs27-2 + else if emacs == "28" then pkgs.emacsGit + else if emacs == "gcc" then pkgs.emacsGcc + else if emacs == "pgtk+gcc" then pkgs.emacsPgtkGcc + else if emacs == "ci-26.3" then pkgs.emacs-26-3 + else if emacs == "ci-27.1" then pkgs.emacs-27-1 + else if emacs == "ci-27.2" then pkgs.emacs-27-2 + else if emacs == "ci-28" then pkgs.emacs-snapshot + else pkgs.emacs); +in pkgs.stdenv.mkDerivation { name = "doom-emacs"; buildInputs = [ - (if emacs == 28 then pkgs.emacsGit - else if emacs == 27 then pkgs.emacsUnstable - else pkgs.emacs) + emacsPkg pkgs.git (pkgs.ripgrep.override {withPCRE2 = true;}) ]; shellHook = '' - export EMACSVERSION="$(emacs --no-site-file --batch --eval '(princ emacs-version)')" + export EMACS="${emacsPkg}/bin/emacs" + export EMACSVERSION="$($EMACS --no-site-file --batch --eval '(princ emacs-version)')" export EMACSDIR="$(readlink -f "${emacsdir}")/" export DOOMDIR="$(readlink -f "${doomdir}")/" export DOOMLOCALDIR="$(readlink -f "${doomlocaldir}").$EMACSVERSION/" + export DOOMNOCOMPILE=1 export PATH="$EMACSDIR/bin:$PATH" - echo "Running Emacs $EMACSVERSION" + echo "Running Emacs $EMACSVERSION (emacs=${emacs})" echo "EMACSDIR=$EMACSDIR" echo "DOOMDIR=$DOOMDIR" echo "DOOMLOCALDIR=$DOOMLOCALDIR" @@ -56,8 +80,10 @@ pkgs.stdenv.mkDerivation { mkdir -p "$DOOMLOCALDIR/straight" pushd "$DOOMLOCALDIR/straight" >/dev/null if [[ -d "$EMACSDIR/.local/straight/repos" && ! -d ./repos ]]; then + echo "Copying '$EMACSDIR/.local/straight/repos' to './$(basename $DOOMLOCALDIR)straight/repos' to save time" cp -r "$EMACSDIR/.local/straight/repos" ./repos fi popd >/dev/null + echo "Ready!" ''; }