about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-31T00·16+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-31T00·16+0100
commite166e74c2c9c5ad111d4f0050f1ccf1de9ce0d21 (patch)
tree4a4cde6512c254b62bdd88e23e6e7833af87a73c
parent8f46684c234db9ee27136dafe57d77aa27df0c25 (diff)
Allow configurable BRIEFCASE env var for CI
These were hard-coded as $HOME/BRIEFCASE, which won't work in CI, since CI runs
as the user buildkite-agent-socrates, whose $HOME directory doesn't exist.
-rw-r--r--ci/pipelines/post-receive.nix33
-rw-r--r--emacs/default.nix60
2 files changed, 55 insertions, 38 deletions
diff --git a/ci/pipelines/post-receive.nix b/ci/pipelines/post-receive.nix
index a9c35e1f7d5f..ad7281d99b8e 100644
--- a/ci/pipelines/post-receive.nix
+++ b/ci/pipelines/post-receive.nix
@@ -1,16 +1,14 @@
 { briefcase, pkgs, ... }:
 
 let
-  elispLintSrc = builtins.fetchGit {
+  inherit (builtins) fetchGit path toJSON;
+  inherit (briefcase.emacs) initEl runScript;
+
+  elispLintSrc = fetchGit {
     url = "https://github.com/gonewest818/elisp-lint";
     rev = "2b645266be8010a6a49c6d0ebf6a3ad5bd290ff4";
   };
 
-  scriptEl = builtins.path {
-    path = ./script.el;
-    name = "script.el";
-  };
-
   pipeline.steps = [
     {
       key = "lint-secrets";
@@ -27,16 +25,27 @@ let
     }
     {
       key = "init-emacs";
-      command = ''
-        ${briefcase.emacs.runScript scriptEl} ${briefcase.emacs.initEl}
-      '';
+      command = let
+        scriptEl = path {
+          path = ./script.el;
+          name = "script.el";
+        };
+        runScriptEl = runScript {
+          script = scriptEl;
+          briefcasePath = "$(pwd)";
+        };
+      in "${runScriptEl} ${initEl}";
       label = ":gnu: initialize Emacs";
       depends_on = "build-briefcase";
     }
     {
       key = "lint-emacs";
-      command = ''
-        ${briefcase.emacs.nixos}/bin/wpcarros-emacs \
+      command = let
+        nixosEmacs = briefcase.emacs.nixos {
+          briefcasePath = "$(pwd)";
+        };
+      in ''
+        ${nixosEmacs}/bin/wpcarros-emacs \
           --quick \
           --batch \
           --load ${elispLintSrc}/elisp-lint.el \
@@ -61,4 +70,4 @@ let
       depends_on = "build-briefcase";
     }
   ];
-in pkgs.writeText "pipeline.yaml" (builtins.toJSON pipeline)
+in pkgs.writeText "pipeline.yaml" (toJSON pipeline)
diff --git a/emacs/default.nix b/emacs/default.nix
index 126894a8fc3a..439f66396734 100644
--- a/emacs/default.nix
+++ b/emacs/default.nix
@@ -134,40 +134,48 @@ let
     name = "init.el";
   };
 
-  withEmacsPath = emacsBin: pkgs.writeShellScriptBin "wpcarros-emacs" ''
-    export XMODIFIERS=emacs
-    export BRIEFCASE=$HOME/briefcase
-    export PATH="${emacsBinPath}:$PATH"
-    export EMACSLOADPATH="${wpcDir}:${vendorDir}:${wpcarrosEmacs.deps}/share/emacs/site-lisp:"
-    exec ${emacsBin} \
-      --debug-init \
-      --no-site-file \
-      --no-site-lisp \
-      --load ${initEl} \
-      --no-init-file \
-      "$@"
-  '';
+  withEmacsPath = { emacsBin, briefcasePath }:
+    pkgs.writeShellScriptBin "wpcarros-emacs" ''
+      export XMODIFIERS=emacs
+      export BRIEFCASE=${briefcasePath}
+      export PATH="${emacsBinPath}:$PATH"
+      export EMACSLOADPATH="${wpcDir}:${vendorDir}:${wpcarrosEmacs.deps}/share/emacs/site-lisp:"
+      exec ${emacsBin} \
+        --debug-init \
+        --no-site-file \
+        --no-site-lisp \
+        --load ${initEl} \
+        --no-init-file \
+        "$@"
+    '';
 in {
   inherit initEl;
 
   # I need to start my Emacs from CI without the call to `--load ${initEl}`.
-  runScript = script: pkgs.writeShellScript "run-emacs-script" ''
-    export BRIEFCASE=$HOME/briefcase
-    export PATH="${emacsBinPath}:$PATH"
-    export EMACSLOADPATH="${wpcDir}:${vendorDir}:${wpcarrosEmacs.deps}/share/emacs/site-lisp"
-    exec ${wpcarrosEmacs}/bin/emacs \
-      --no-site-file \
-      --no-site-lisp \
-      --no-init-file \
-      --script ${script} \
-      "$@"
-  '';
+  runScript = { script, briefcasePath }:
+    pkgs.writeShellScript "run-emacs-script" ''
+      export BRIEFCASE=${briefcasePath}
+      export PATH="${emacsBinPath}:$PATH"
+      export EMACSLOADPATH="${wpcDir}:${vendorDir}:${wpcarrosEmacs.deps}/share/emacs/site-lisp"
+      exec ${wpcarrosEmacs}/bin/emacs \
+        --no-site-file \
+        --no-site-lisp \
+        --no-init-file \
+        --script ${script} \
+        "$@"
+    '';
 
   # Use `nix-env -f '<briefcase>' emacs.glinux` to install `wpcarro-emacs` on
   # gLinux machines. This will ensure that X and GL linkage behaves as expected.
-  glinux = withEmacsPath "/usr/bin/google-emacs";
+  glinux = { briefcasePath ? "$HOME/briefcase" }: withEmacsPath {
+    inherit briefcasePath;
+    emacsBin = "/usr/bin/google-emacs";
+  };
 
   # Use `nix-env -f '<briefcase>' emacs.nixos` to install `wpcarros-emacs` on
   # NixOS machines.
-  nixos = withEmacsPath "${wpcarrosEmacs}/bin/emacs";
+  nixos = { briefcasePath ? "$HOME/briefcase" }: withEmacsPath {
+    inherit briefcasePath;
+    emacsBin = "${wpcarrosEmacs}/bin/emacs";
+  };
 }