unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] gnu: Add direnv
@ 2016-09-10 16:39 Christopher Baines
  2016-09-10 16:39 ` Christopher Baines
  2016-09-14  7:49 ` 宋文武
  0 siblings, 2 replies; 3+ messages in thread
From: Christopher Baines @ 2016-09-10 16:39 UTC (permalink / raw
  To: guix-devel

direnv is an environment switcher for the shell. direnv can be used with many
tools, including Guix environments.

I was lucky enough to meet the original author in London, who showed me direnv,
and helped me write a function for my .direnvrc file to make it easy to use
with Guix.

I have the following in my .direnvrc file (in my home directory).

    use_guix() {
      eval "$(guix environment "$@" --search-paths)"
    }

This means that I can have something like the following in my .envrc files

    use_guix --ad-hoc guile

You need to add a shell hook, and "allow" this file, but after that is done,
just changing in and out of the directory with the .envrc file in it will
adjust the environmental variables in your shell.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] gnu: Add direnv
  2016-09-10 16:39 [PATCH] gnu: Add direnv Christopher Baines
@ 2016-09-10 16:39 ` Christopher Baines
  2016-09-14  7:49 ` 宋文武
  1 sibling, 0 replies; 3+ messages in thread
From: Christopher Baines @ 2016-09-10 16:39 UTC (permalink / raw
  To: guix-devel

* gnu/packages/shellutils.scm (direnv): New variable.
---
 gnu/packages/shellutils.scm | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/gnu/packages/shellutils.scm b/gnu/packages/shellutils.scm
index 27f45ba..e582186 100644
--- a/gnu/packages/shellutils.scm
+++ b/gnu/packages/shellutils.scm
@@ -19,6 +19,7 @@
 
 (define-module (gnu packages shellutils)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages golang)
   #:use-module (gnu packages python)
   #:use-module (guix licenses)
   #:use-module (guix packages)
@@ -88,3 +89,35 @@ FreeDesktop.org trash can used by GNOME, KDE, XFCE, and other common desktop
 environments.  It can move files to the trash, and remove or list files that
 are already there.")
     (license gpl2+)))
+
+(define-public direnv
+  (package
+    (name "direnv")
+    (version "2.9.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://github.com/direnv/" name
+                           "/archive/v" version ".tar.gz"))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32 "04v3v2sz9m6ivgbxcplxscj1dsvpaqpqnxgls4060naj3iz9sg82"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:test-target "test"
+       #:make-flags (list (string-append "DESTDIR=" (assoc-ref %outputs "out")))
+       #:phases (modify-phases %standard-phases (delete 'configure))))
+    (native-inputs
+      `(("go" ,go)
+        ("which" ,which)))
+    (home-page "http://direnv.net/")
+    (synopsis "Environment switcher for the shell")
+    (description "direnv can hook into bash, zsh, tcsh and fish shell to load
+or unload environment variables depending on the current directory.  This
+allows project-specific environment variables without using the ~/.profile
+file.
+
+Before each prompt, direnv checks for the existence of a .envrc file in the
+current and parent directories.  This file is then used to alter the
+environmental variables of the current shell.")
+    (license expat)))
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gnu: Add direnv
  2016-09-10 16:39 [PATCH] gnu: Add direnv Christopher Baines
  2016-09-10 16:39 ` Christopher Baines
@ 2016-09-14  7:49 ` 宋文武
  1 sibling, 0 replies; 3+ messages in thread
From: 宋文武 @ 2016-09-14  7:49 UTC (permalink / raw
  To: Christopher Baines; +Cc: guix-devel

Christopher Baines <mail@cbaines.net> writes:

> direnv is an environment switcher for the shell. direnv can be used with many
> tools, including Guix environments.
>
> I was lucky enough to meet the original author in London, who showed me direnv,
> and helped me write a function for my .direnvrc file to make it easy to use
> with Guix.
>
> I have the following in my .direnvrc file (in my home directory).
>
>     use_guix() {
>       eval "$(guix environment "$@" --search-paths)"
>     }
>
> This means that I can have something like the following in my .envrc files
>
>     use_guix --ad-hoc guile
>
> You need to add a shell hook, and "allow" this file, but after that is done,
> just changing in and out of the directory with the .envrc file in it will
> adjust the environmental variables in your shell.

Cool, applied, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-14  7:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-10 16:39 [PATCH] gnu: Add direnv Christopher Baines
2016-09-10 16:39 ` Christopher Baines
2016-09-14  7:49 ` 宋文武

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).