about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-11-12T18·00+0100
committerVincent Ambo <tazjin@gmail.com>2017-11-12T18·00+0100
commit5fcabc204a878fa385450febf4eaabaa46386786 (patch)
tree1486de427e2a1c791856beee09ec013045bf6032
parentac5b34e131abecbda9c2c039adab38a2dca64224 (diff)
feat(functions): Add functions to insert nix-store paths
These can be useful - for example - while debugging nix things in eshell.
-rw-r--r--init/functions.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/init/functions.el b/init/functions.el
index a0f4d59456f5..af8ab51b45ff 100644
--- a/init/functions.el
+++ b/init/functions.el
@@ -116,4 +116,15 @@ Including indent-buffer, which should not be called automatically on save."
   (interactive)
   (find-file "/etc/nixos/configuration.nix"))
 
+;; Get the nix store path for a given derivation.
+;; If the derivation has not been built before, this will trigger a build.
+(defun nix-store-path (derivation)
+  (let ((expr (concat "with import <nixos> {}; " derivation)))
+    (s-chomp (shell-command-to-string (concat "nix-build -E '" expr "'")))))
+
+(defun insert-nix-store-path ()
+  (interactive)
+  (let ((derivation (read-string "Derivation name (in <nixos>): ")))
+    (insert-string (nix-store-path derivation))))
+
 (provide 'functions)