literate-config

Literate config. See <a href="../readme.org">readme.org</a> for a better-formatted version
Log | Files | Refs

commit 1f256dc86ba198614e4d90cc0ff6caebd4ed5090
parent 184aaf51d5b5b16b90701889580cb26a48189a46
Author: Crazazy <crazazy@tilde.cafe>
Date:   Wed, 27 Apr 2022 10:02:43 +0200

fix loading order of nix-env-from-packages for haskell

Diffstat:
Memacs.org | 46++++++++++++++++++++++++----------------------
1 file changed, 24 insertions(+), 22 deletions(-)

diff --git 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 "<nixpkgs>") (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 "<nixpkgs>") (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