[Nix-dev] Announcing nix-buffer, nix-shell for emacs

Bas van Dijk v.dijk.bas at gmail.com
Mon Sep 5 16:51:24 CEST 2016


Hi Shea,

As a Nix and Emacs user this looks very interesting. I didn't know about
Buffer-Local Variables before.

Can you share some applications of nix-buffer / how you are using it?

Thanks!

Bas

On 5 September 2016 at 08:06, Shea Levy <shea at shealevy.com> wrote:

> Hi all,
>
> I've just pushed the initial version of nix-buffer[1], and opened a PR
> for adding it to melpa[2]. The description of the 'nix-buffer-enter'
> command this library defines:
>
> > Set up the buffer according to the directory-local nix expression.
> >
> > Looks for dir-locals.nix upward from the current directory.  If found,
> > builds the derivation defined there with the 'root' arg set to the
> > current buffer file name or directory and evaluates the resulting
> > elisp if safe to do so.
> >
> > Because in practice dir-locals.nix will always want to do things that
> > are unsafe in dir-locals.el (e.g. append to 'exec-path'), we don't
> > reuse that mechanism and instead just load the file as elisp.  Because
> > this allows arbitrary code execution, the first time we're asked to
> > load a particular store path we query the user to verify if it's safe
> > to load beforehand.
> >
> > The Lisp code generated by dir-locals.nix should limit itself to
> > modifying buffer-local variables, but there is no actual enforcement
> > of this.  'setq-local' is your friend.
>
> It may be useful to advise the 'normal-mode' function to call
> 'nix-buffer-enter' beforehand for local files, so that all visited files
> have their environments set up before modes are loaded.
>
> Note that this is my first elisp package, so feedback definitely
> welcome!
>
> In addition to the elisp work mentioned in the TODO[3], it would be
> useful to add some functions to nixpkgs to build elisp files,
> especially:
>
> * A function taking a derivation and building an elisp file that sets up
>   the buffer environment analogous to the build environment specified by
>   that derivation
> * A function taking a list of packages and building an elisp file that
>   sets up the buffer environment with all of those packages available
>   (in PATH, in the emacs load path, etc.).
>
> Happy hacking!
>
> ~Shea
>
> [1]: https://github.com/shlevy/nix-buffer/tree/v1.0
> [2]: https://github.com/melpa/melpa/pull/4204
> [3]: https://github.com/shlevy/nix-buffer/blob/v1.0/TODO.md
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160905/bc4f6c84/attachment.html>


More information about the nix-dev mailing list