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)