From 0876e9c116125b28806286b0313ff78de5948562 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 25 Sep 2019 10:45:38 +0200 Subject: colors: Add 'dim'. * guix/colors.scm (coloring-procedure): New procedure. (%highlight-color): Remove. (highlight): Define in terms of 'coloring-procedure'. (dim): New procedure. --- guix/colors.scm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'guix') diff --git a/guix/colors.scm b/guix/colors.scm index 7949cf5763..b63ac37027 100644 --- a/guix/colors.scm +++ b/guix/colors.scm @@ -31,6 +31,8 @@ colorize-string highlight + dim + color-rules color-output? isatty?*)) @@ -133,14 +135,16 @@ that subsequent output will not have any colors in effect." (not (getenv "NO_COLOR")) (isatty?* port))) -(define %highlight-color (color BOLD)) +(define (coloring-procedure color) + "Return a procedure that applies COLOR to the given string." + (lambda* (str #:optional (port (current-output-port))) + "Return STR with extra ANSI color attributes if PORT supports it." + (if (color-output? port) + (colorize-string str color) + str))) -(define* (highlight str #:optional (port (current-output-port))) - "Return STR with extra ANSI color attributes to highlight it if PORT -supports it." - (if (color-output? port) - (colorize-string str %highlight-color) - str)) +(define highlight (coloring-procedure (color BOLD))) +(define dim (coloring-procedure (color DARK))) (define (colorize-matches rules) "Return a procedure that, when passed a string, returns that string -- cgit v1.2.3 From d26c290b7dac642c39f23fd65b4eb0d10534d58d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 25 Sep 2019 10:48:50 +0200 Subject: pull: Dim the commit ID when displaying news. * guix/scripts/pull.scm (display-news-entry): Dim the commit line. --- guix/scripts/pull.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 2b7b991b50..0372278705 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -249,7 +249,7 @@ PORT." (channel-news-entry-body entry)) (display-news-entry-title entry language port) - (format port (G_ " commit ~a~%") + (format port (dim (G_ " commit ~a~%")) (channel-news-entry-commit entry)) (newline port) (format port " ~a~%" -- cgit v1.2.3 From 3972dc5d43ea824ee4ab78592e759f62ce90bf6a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 24 Sep 2019 17:50:48 +0200 Subject: guix package: Add '--list-profiles'. * guix/scripts/package.scm (show-help, %options): Add '--list-profiles'. (process-query): Honor it. * tests/guix-package.sh: Add test. --- doc/guix.texi | 13 +++++++++++++ guix/scripts/package.scm | 21 +++++++++++++++++++++ tests/guix-package.sh | 6 +++++- 3 files changed, 39 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index 4ffffcdc81..14c4514b31 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2933,6 +2933,19 @@ siblings that point to specific generations: $ rm ~/code/my-profile ~/code/my-profile-*-link @end example +@item --list-profiles +List all the user's profiles: + +@example +$ guix package --list-profiles +/home/charlie/.guix-profile +/home/charlie/code/my-profile +/home/charlie/code/devel-profile +/home/charlie/tmp/test +@end example + +When running as root, list all the profiles of all the users. + @cindex collisions, in a profile @cindex colliding packages in profiles @cindex profile collisions diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index f03741aa9e..1a58d43e5c 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -39,6 +39,7 @@ #:use-module (guix scripts) #:use-module (guix scripts build) #:autoload (guix describe) (package-provenance) + #:autoload (guix store roots) (gc-roots) #:use-module ((guix build utils) #:select (directory-exists? mkdir-p)) #:use-module (ice-9 format) @@ -359,6 +360,8 @@ Install, remove, or upgrade packages in a single transaction.\n")) switch to a generation matching PATTERN")) (display (G_ " -p, --profile=PROFILE use PROFILE instead of the user's default profile")) + (display (G_ " + --list-profiles list the user's profiles")) (newline) (display (G_ " --allow-collisions do not treat collisions in the profile as an error")) @@ -458,6 +461,11 @@ command-line option~%") (values (cons `(query list-generations ,arg) result) #f))) + (option '("list-profiles") #f #f + (lambda (opt name arg result arg-handler) + (values (cons `(query list-profiles #t) + result) + #f))) (option '(#\d "delete-generations") #f #t (lambda (opt name arg result arg-handler) (values (alist-cons 'delete-generations arg @@ -750,6 +758,19 @@ processed, #f otherwise." (string "$module_dir/foo.scm"< /tmp/out test "`guix package -L "$module_dir" -s dummy-output | grep ^name:`" = "name: dummy-package" rm -rf "$module_dir" + +# Make sure we can see user profiles. +guix package --list-profiles | grep "$profile" +guix package --list-profiles | grep '\.guix-profile' -- cgit v1.2.3 From dec845606d2d184da31065fa26cd951b84b3ce2d Mon Sep 17 00:00:00 2001 From: Hartmut Goebel Date: Thu, 8 Aug 2019 16:43:15 +0200 Subject: guix download: Ensure destination file-name is valid in the store. Avoid invalid store-file-name by explicitly passing the destination name, replacing any character not allowed in the store-file-name by an underscore. Fixes * guix/scripts/download.scm (safe-naensure-valid-store-file-nameme): New function. (download-to-store*): Use it to generate a "safe" basename of URL. --- guix/scripts/download.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'guix') diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm index d8fe71ce12..22cd75ea0b 100644 --- a/guix/scripts/download.scm +++ b/guix/scripts/download.scm @@ -33,6 +33,7 @@ #:use-module (web uri) #:use-module (ice-9 match) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-14) #:use-module (srfi srfi-26) #:use-module (srfi srfi-37) #:use-module (rnrs bytevectors) @@ -54,9 +55,23 @@ (url-fetch url file #:mirrors %mirrors))) file)) +(define (ensure-valid-store-file-name name) + "Replace any character not allowed in a stror name by an underscore." + + (define valid + ;; according to nix/libstore/store-api.cc + (string->char-set (string-append "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" "+-._?="))) + (string-map (lambda (c) + (if (char-set-contains? valid c) c #\_)) + name)) + + (define* (download-to-store* url #:key (verify-certificate? #t)) (with-store store (download-to-store store url + (ensure-valid-store-file-name (basename url)) #:verify-certificate? verify-certificate?))) (define %default-options -- cgit v1.2.3 From 8727e0304b68cd22e827331bb40ea269f243c6ab Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 26 Sep 2019 18:49:25 +0200 Subject: self: Mark trivial "-modules" derivations as non-substitutable. The resulting nar takes ~500KiB and it's quicker to build it locally than to download it. * guix/self.scm (node-source+compiled): Pass #:options to 'computed-file'. --- guix/self.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/self.scm b/guix/self.scm index f03fe01d0c..142c834137 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -124,7 +124,11 @@ NODE's modules, under their FHS directories: share/guile/site and lib/guile." (symlink #$(node-compiled node) object)))) (computed-file (string-append (node-name node) "-modules") - build)) + build + #:options '(#:local-build? #t + + ;; "Building" it locally is faster. + #:substitutable? #f))) (define (node-fold proc init nodes) (let loop ((nodes nodes) -- cgit v1.2.3