From 5fcabc204a878fa385450febf4eaabaa46386786 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 12 Nov 2017 19:00:49 +0100 Subject: [PATCH] feat(functions): Add functions to insert nix-store paths These can be useful - for example - while debugging nix things in eshell. --- init/functions.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/init/functions.el b/init/functions.el index a0f4d5945..af8ab51b4 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 {}; " 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 ): "))) + (insert-string (nix-store-path derivation)))) + (provide 'functions)