summaryrefslogtreecommitdiff
path: root/guix/ui.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-02-20 23:46:38 +0100
committerLudovic Courtès <ludo@gnu.org>2013-02-20 23:47:16 +0100
commitf651b477b701d086402c18665eca68b26c3bec6b (patch)
treee0d9d10df8488ddd63eff3be5c3f9d3c1d66b290 /guix/ui.scm
parent9bb2b96aabdbb245c4a409e96b25df2954cfe385 (diff)
Add "guix pull".
* guix/scripts/pull.scm: New file. * Makefile.am (MODULES): Add it. * doc/guix.texi (Invoking guix pull): New node. (Invoking guix package): Add cross-ref to it. * guix/ui.scm (config-directory): New procedure. * scripts/guix.in: When `GUIX_UNINSTALLED' is undefined, add $XDG_CONFIG_HOME/guix/latest to the search path. * po/POTFILES.in: Add guix/scripts/pull.scm.
Diffstat (limited to 'guix/ui.scm')
-rw-r--r--guix/ui.scm21
1 files changed, 21 insertions, 0 deletions
diff --git a/guix/ui.scm b/guix/ui.scm
index 2b75504573..7d1ea2bcbd 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -41,6 +41,7 @@
location->string
call-with-temporary-output-file
switch-symlinks
+ config-directory
fill-paragraph
string->recutils
package->recutils
@@ -178,6 +179,26 @@ both when LINK already exists and when it does not."
(symlink target pivot)
(rename-file pivot link)))
+(define (config-directory)
+ "Return the name of the configuration directory, after making sure that it
+exists. Honor the XDG specs,
+<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>."
+ (let ((dir (and=> (or (getenv "XDG_CONFIG_HOME")
+ (and=> (getenv "HOME")
+ (cut string-append <> "/.config")))
+ (cut string-append <> "/guix"))))
+ (catch 'system-error
+ (lambda ()
+ (mkdir dir)
+ dir)
+ (lambda args
+ (match (system-error-errno args)
+ ((or EEXIST 0)
+ dir)
+ (err
+ (leave (_ "failed to create configuration directory `~a': ~a~%")
+ dir (strerror err))))))))
+
(define* (fill-paragraph str width #:optional (column 0))
"Fill STR such that each line contains at most WIDTH characters, assuming
that the first character is at COLUMN.