From 1f256dc86ba198614e4d90cc0ff6caebd4ed5090 Mon Sep 17 00:00:00 2001 From: Crazazy Date: Wed, 27 Apr 2022 10:02:43 +0200 Subject: fix loading order of nix-env-from-packages for haskell --- emacs.org | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/emacs.org b/emacs.org index 649b0e7..9d76288 100644 --- a/emacs.org +++ b/emacs.org @@ -373,32 +373,34 @@ Also, if you just stumbled accross this at random, there is an easy tangle butto I use nix-sandbox for managing nix package for other languages. One of the functions doesn't work that well for me so I replaced it with something that does #+begin_src emacs-lisp :tangle emacsconfig/nix.el - (use-package nix-sandbox - :config - (defun nix-executable-find (sandbox executable) - "finds an EXECUTABLE in SANDBOX" - (set (make-local-variable 'exec-path) (nix-exec-path sandbox)) - (executable-find executable))) + (use-package nix-sandbox + :demand + :config + (defun nix-executable-find (sandbox executable) + "finds an EXECUTABLE in SANDBOX" + (set (make-local-variable 'exec-path) (nix-exec-path sandbox)) + (executable-find executable)) #+end_src Beyond that, there is a helper function that makes it easy to quickly define environments with the required packages for a programming language #+begin_src emacs-lisp :tangle emacsconfig/nix.el - (defun nix-env-from-packages (name &rest packages) - "create a nix environment from nix packages. returns the location of the environment" - (interactive (append - (list (read-string "Environment name: " nil nil "nameless")) - (split-string (read-string "Packages: ")))) - (with-temp-buffer - (insert (format " - { pkgs ? import %s {}}: - pkgs.mkShell { - buildInputs = with pkgs;[ - %s - ]; - } - " (or nix-nixpkgs-path "") (apply 'concat (intersperse "\n" packages)))) - (write-file (concat temporary-file-directory name "-env/shell.nix")) - (nix-find-sandbox (concat temporary-file-directory name "-env")))) + (defun intersperse (el ls) (if (cdr ls) `(,(car ls) ,el . ,(intersperse el (cdr ls))) ls)) + (defun nix-env-from-packages (name &rest packages) + "create a nix environment from nix packages. returns the location of the environment" + (interactive (append + (list (read-string "Environment name: " nil nil "nameless")) + (split-string (read-string "Packages: ")))) + (with-temp-buffer + (insert (format " + { pkgs ? import %s {}}: + pkgs.mkShell { + buildInputs = with pkgs;[ + %s + ]; + } + " (or nix-nixpkgs-path "") (apply 'concat (intersperse "\n" packages)))) + (write-file (concat temporary-file-directory name "-env/shell.nix")) + (nix-find-sandbox (concat temporary-file-directory name "-env"))))) #+end_src **** Python Python is a bit weird. It had no intentions at all to do things the way I wanted it to do things with -- cgit 1.4.1-2-gfad0