diff options
Diffstat (limited to 'init')
-rw-r--r-- | init/functions.el | 11 |
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) |