From b04cdae902398aa76fb81a0470e18fd527c6ba3d Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 5 Sep 2016 17:55:49 -0400 Subject: [PATCH] nixBufferBuilders.withPackages: Make more legible, special-case proof-general. There's some bigger changes coming, but thought I'd push this first... --- pkgs/build-support/emacs/buffer.nix | 31 ++++++++++++++++------------- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/pkgs/build-support/emacs/buffer.nix b/pkgs/build-support/emacs/buffer.nix index 2f7f536d5e75..5632eae944c0 100644 --- a/pkgs/build-support/emacs/buffer.nix +++ b/pkgs/build-support/emacs/buffer.nix @@ -1,20 +1,23 @@ # Functions to build elisp files to locally configure emcas buffers. # See https://github.com/shlevy/nix-buffer -{ runCommand }: +{ lib, writeText }: { - withPackages = pkgs: runCommand "dir-locals.el" { inherit pkgs; } '' - echo "(make-local-variable 'process-environment)" >> $out - echo "(setenv \"PATH\" (concat" >> $out - for pkg in $pkgs; do - echo " \"$pkg/bin:$pkg/sbin\"" >> $out - done - echo " (getenv \"PATH\")))" >> $out - echo -n "(setq-local exec-path (append '(" >> $out - for pkg in $pkgs; do - echo -en "\n \"$pkg/bin\" \"$pkg/sbin\"" >> $out - done - echo -e ")\\n exec-path))" >> $out - ''; + withPackages = pkgs: let + coqs = builtins.filter (x: (builtins.parseDrvName x.name).name == "coq") pkgs; + coq = builtins.head coqs; + pg-setup = if builtins.length coqs == 0 then "" else '' + (setq-local coq-prog-name "${coq}/bin/coqtop") + (setq-local coq-dependency-analyzer "${coq}/bin/coqdep") + (setq-local coq-compiler "${coq}/bin/coqc") + (setq-local coq-library-directory (get-coq-library-directory)) + (coq-prog-args) + ''; + in writeText "dir-locals.el" '' + (make-local-variable 'process-environment) + (setenv "PATH" (concat "${lib.makeSearchPath "bin" pkgs}:" (getenv "PATH"))) + (setq-local exec-path (append '(${builtins.concatStringsSep " " (map (p: "\"${p}/bin\"") pkgs)}) exec-path)) + ${pg-setup} + ''; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 48a28c169af6..654f49cb956e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -285,7 +285,7 @@ in inherit kernel rootModules allowMissing; }; - nixBufferBuilders = import ../build-support/emacs/buffer.nix { inherit (pkgs) runCommand; }; + nixBufferBuilders = import ../build-support/emacs/buffer.nix { inherit (pkgs) lib writeText; }; pathsFromGraph = ../build-support/kernel/paths-from-graph.pl;