From ad3729536ab4fe233b32017ac889f026a4bad43e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 11 Feb 2015 22:58:53 +0100 Subject: store: Add optional 'references' parameter to 'text-file'. * guix/store.scm (text-file): Add optional 'references' parameter. Pass it to 'add-text-to-store'. * doc/guix.texi (The Store Monad): Adjust accordingly. --- doc/guix.texi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 0c6b1e4384..04b9b4aaae 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2358,9 +2358,10 @@ Run @var{mval}, a monadic value in the store monad, in @var{store}, an open store connection. @end deffn -@deffn {Monadic Procedure} text-file @var{name} @var{text} +@deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}] Return as a monadic value the absolute file name in the store of the file -containing @var{text}, a string. +containing @var{text}, a string. @var{references} is a list of store items that the +resulting text file refers to; it defaults to the empty list. @end deffn @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @ -- cgit v1.2.3 From ce45eb4c385e3b473bc6746a8b58452865f69977 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 13 Feb 2015 23:14:05 +0100 Subject: gexp: Add #:graft? parameter to 'gexp->derivation'. * guix/gexp.scm (gexp->derivation): Add #:graft? parameter and honor it. * tests/gexp.scm ("gexp->derivation vs. grafts"): New test. * doc/guix.texi (G-Expressions): Update 'gexp->derivation' documentation. --- doc/guix.texi | 11 +++++++---- guix/gexp.scm | 62 ++++++++++++++++++++++++++++++++-------------------------- tests/gexp.scm | 17 ++++++++++++++++ 3 files changed, 58 insertions(+), 32 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 04b9b4aaae..50a7084fec 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2580,7 +2580,7 @@ below allow you to do that (@pxref{The Store Monad}, for more information about monads.) @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @ - [#:system (%current-system)] [#:target #f] [#:inputs '()] @ + [#:system (%current-system)] [#:target #f] [#:graft? #t] @ [#:hash #f] [#:hash-algo #f] @ [#:recursive? #f] [#:env-vars '()] [#:modules '()] @ [#:module-path @var{%load-path}] @ @@ -2591,12 +2591,15 @@ Return a derivation @var{name} that runs @var{exp} (a gexp) with is true, it is used as the cross-compilation target triplet for packages referred to by @var{exp}. -Make @var{modules} available in the evaluation context of @var{EXP}; -@var{MODULES} is a list of names of Guile modules searched in -@var{MODULE-PATH} to be copied in the store, compiled, and made available in +Make @var{modules} available in the evaluation context of @var{exp}; +@var{modules} is a list of names of Guile modules searched in +@var{module-path} to be copied in the store, compiled, and made available in the load path during the execution of @var{exp}---e.g., @code{((guix build utils) (guix build gnu-build-system))}. +@var{graft?} determines whether packages referred to by @var{exp} should be grafted when +applicable. + When @var{references-graphs} is true, it must be a list of tuples of one of the following forms: diff --git a/guix/gexp.scm b/guix/gexp.scm index 0620683078..a8349c7d6e 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -153,6 +153,7 @@ names and file names suitable for the #:allowed-references argument to (modules '()) (module-path %load-path) (guile-for-build (%guile-for-build)) + (graft? (%graft?)) references-graphs allowed-references local-build?) @@ -165,6 +166,9 @@ names of Guile modules searched in MODULE-PATH to be copied in the store, compiled, and made available in the load path during the execution of EXP---e.g., '((guix build utils) (guix build gnu-build-system)). +GRAFT? determines whether packages referred to by EXP should be grafted when +applicable. + When REFERENCES-GRAPHS is true, it must be a list of tuples of one of the following forms: @@ -198,10 +202,10 @@ The other arguments are as for 'derivation'." (cons file-name thing))) graphs)) - (mlet* %store-monad (;; The following binding is here to force - ;; '%current-system' and '%current-target-system' to be - ;; looked up at >>= time. - (unused (return #f)) + (mlet* %store-monad (;; The following binding forces '%current-system' and + ;; '%current-target-system' to be looked up at >>= + ;; time. + (graft? (set-grafting graft?)) (system -> (or system (%current-system))) (target -> (if (eq? target 'current) @@ -245,30 +249,32 @@ The other arguments are as for 'derivation'." (return guile-for-build) (package->derivation (default-guile) system)))) - (raw-derivation name - (string-append (derivation->output-path guile) - "/bin/guile") - `("--no-auto-compile" - ,@(if (pair? %modules) - `("-L" ,(derivation->output-path modules) - "-C" ,(derivation->output-path compiled)) - '()) - ,builder) - #:outputs outputs - #:env-vars env-vars - #:system system - #:inputs `((,guile) - (,builder) - ,@(if modules - `((,modules) (,compiled) ,@inputs) - inputs) - ,@(match graphs - (((_ . inputs) ...) inputs) - (_ '()))) - #:hash hash #:hash-algo hash-algo #:recursive? recursive? - #:references-graphs (and=> graphs graphs-file-names) - #:allowed-references allowed - #:local-build? local-build?))) + (mbegin %store-monad + (set-grafting graft?) ;restore the initial setting + (raw-derivation name + (string-append (derivation->output-path guile) + "/bin/guile") + `("--no-auto-compile" + ,@(if (pair? %modules) + `("-L" ,(derivation->output-path modules) + "-C" ,(derivation->output-path compiled)) + '()) + ,builder) + #:outputs outputs + #:env-vars env-vars + #:system system + #:inputs `((,guile) + (,builder) + ,@(if modules + `((,modules) (,compiled) ,@inputs) + inputs) + ,@(match graphs + (((_ . inputs) ...) inputs) + (_ '()))) + #:hash hash #:hash-algo hash-algo #:recursive? recursive? + #:references-graphs (and=> graphs graphs-file-names) + #:allowed-references allowed + #:local-build? local-build?)))) (define* (gexp-inputs exp #:optional (references gexp-references)) "Return the input list for EXP, using REFERENCES to get its list of diff --git a/tests/gexp.scm b/tests/gexp.scm index 68c470d3b6..0b189b570b 100644 --- a/tests/gexp.scm +++ b/tests/gexp.scm @@ -249,6 +249,23 @@ (equal? refs (list (dirname (dirname guile)))) (equal? refs2 (list file)))))) +(test-assertm "gexp->derivation vs. grafts" + (mlet* %store-monad ((p0 -> (dummy-package "dummy" + (arguments + '(#:implicit-inputs? #f)))) + (r -> (package (inherit p0) (name "DuMMY"))) + (p1 -> (package (inherit p0) (replacement r))) + (exp0 -> (gexp (frob (ungexp p0) (ungexp output)))) + (exp1 -> (gexp (frob (ungexp p1) (ungexp output)))) + (void (set-guile-for-build %bootstrap-guile)) + (drv0 (gexp->derivation "t" exp0)) + (drv1 (gexp->derivation "t" exp1)) + (drv1* (gexp->derivation "t" exp1 #:graft? #f))) + (return (and (not (string=? (derivation->output-path drv0) + (derivation->output-path drv1))) + (string=? (derivation->output-path drv0) + (derivation->output-path drv1*)))))) + (test-assertm "gexp->derivation, composed gexps" (mlet* %store-monad ((exp0 -> (gexp (begin (mkdir (ungexp output)) -- cgit v1.2.3 From 2d2a53fc24a3feb723772dfc45bb438256de41f9 Mon Sep 17 00:00:00 2001 From: Eric Bavier Date: Thu, 22 Jan 2015 23:18:57 -0600 Subject: build-system/perl: Use Build.PL for builds if present. * guix/build/perl-build-system.scm (configure): Use Build.PL if present. (build, check, install): New procedures. (%standard-phases): Replace build, check, and install phases. * guix/build-system/perl (perl-build): Add make-maker? and module-build-flags arguments. * doc/guix.texi (Build Systems)[perl-build-system]: Document behavior rsp. Build.PL and new arguments. --- doc/guix.texi | 20 ++++++++++---- guix/build-system/perl.scm | 4 +++ guix/build/perl-build-system.scm | 59 ++++++++++++++++++++++++++++++++-------- 3 files changed, 65 insertions(+), 18 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 50a7084fec..ccb87c9443 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -1894,12 +1894,20 @@ parameter. @defvr {Scheme Variable} perl-build-system This variable is exported by @code{(guix build-system perl)}. It -implements the standard build procedure for Perl packages, which -consists in running @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, -followed by @code{make} and @code{make install}. - -The initial @code{perl Makefile.PL} invocation passes flags specified by -the @code{#:make-maker-flags} parameter. +implements the standard build procedure for Perl packages, which either +consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}}, +followed by @code{Build} and @code{Build install}; or in running +@code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by +@code{make} and @code{make install}; depending on which of +@code{Build.PL} or @code{Makefile.PL} is present in the package +distribution. Preference is given to the former if both @code{Build.PL} +and @code{Makefile.PL} exist in the package distribution. This +preference can be reversed by specifying @code{#t} for the +@code{#:make-maker?} parameter. + +The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation +passes flags specified by the @code{#:make-maker-flags} or +@code{#:module-build-flags} parameter, respectively. Which Perl package is used can be specified with @code{#:perl}. @end defvr diff --git a/guix/build-system/perl.scm b/guix/build-system/perl.scm index c488adb500..e0f86438a8 100644 --- a/guix/build-system/perl.scm +++ b/guix/build-system/perl.scm @@ -75,7 +75,9 @@ (tests? #t) (parallel-build? #t) (parallel-tests? #t) + (make-maker? #f) (make-maker-flags ''()) + (module-build-flags ''()) (phases '(@ (guix build perl-build-system) %standard-phases)) (outputs '("out")) @@ -101,7 +103,9 @@ provides a `Makefile.PL' file as its build system." source)) #:search-paths ',(map search-path-specification->sexp search-paths) + #:make-maker? ,make-maker? #:make-maker-flags ,make-maker-flags + #:module-build-flags ,module-build-flags #:phases ,phases #:system ,system #:test-target "test" diff --git a/guix/build/perl-build-system.scm b/guix/build/perl-build-system.scm index 904daf7ac2..7eb944ccd1 100644 --- a/guix/build/perl-build-system.scm +++ b/guix/build/perl-build-system.scm @@ -29,22 +29,57 @@ ;; ;; Code: -(define* (configure #:key outputs (make-maker-flags '()) +(define* (configure #:key outputs make-maker? + (make-maker-flags '()) (module-build-flags '()) #:allow-other-keys) "Configure the given Perl package." - (let ((out (assoc-ref outputs "out"))) - (if (file-exists? "Makefile.PL") - (let ((args `("Makefile.PL" ,(string-append "PREFIX=" out) - "INSTALLDIRS=site" ,@make-maker-flags))) - (format #t "running `perl' with arguments ~s~%" args) - (zero? (apply system* "perl" args))) - (error "no Makefile.PL found")))) + (let* ((out (assoc-ref outputs "out")) + (args (cond + ;; Prefer to use Module::Build unless otherwise told + ((and (file-exists? "Build.PL") + (not make-maker?)) + `("Build.PL" ,(string-append "--prefix=" out) + "--installdirs=site" ,@module-build-flags)) + ((file-exists? "Makefile.PL") + `("Makefile.PL" ,(string-append "PREFIX=" out) + "INSTALLDIRS=site" ,@make-maker-flags)) + (else (error "no Build.PL or Makefile.PL found"))))) + (format #t "running `perl' with arguments ~s~%" args) + (zero? (apply system* "perl" args)))) + +(define-syntax-rule (define-w/gnu-fallback* (name args ...) body ...) + (define* (name args ... #:rest rest) + (if (access? "Build" X_OK) + (begin body ...) + (apply (assoc-ref gnu:%standard-phases 'name) rest)))) + +(define-w/gnu-fallback* (build) + (zero? (system* "./Build"))) + +(define-w/gnu-fallback* (check #:key target + (tests? (not target)) (test-flags '()) + #:allow-other-keys) + (if tests? + (zero? (apply system* "./Build" "test" test-flags)) + (begin + (format #t "test suite not run~%") + #t))) + +(define-w/gnu-fallback* (install) + (zero? (system* "./Build" "install"))) (define %standard-phases - ;; Everything is as with the GNU Build System except for the `configure' - ;; phase. - (alist-replace 'configure configure - gnu:%standard-phases)) + ;; Everything is as with the GNU Build System except for the `configure', + ;; `build', `check', and `install' phases. + (alist-replace + 'configure configure + (alist-replace + 'build build + (alist-replace + 'check check + (alist-replace + 'install install + gnu:%standard-phases))))) (define* (perl-build #:key inputs (phases %standard-phases) #:allow-other-keys #:rest args) -- cgit v1.2.3 From 66392e475d4fa89760ec64d62c5d0c203e853866 Mon Sep 17 00:00:00 2001 From: Eric Bavier Date: Thu, 12 Feb 2015 08:39:09 -0600 Subject: import: cpan: Use corelist to filter dependencies. * guix/import/cpan.scm (%corelist): New variable. (module->dist-name, core-module?): New procedures. (cpan-module->sexp)[convert-inputs]: Use them. Include "test" dependencies in converted inputs. * doc/guix.texi (Invoking guix import)[cpan]: Mention corelist filtering. --- doc/guix.texi | 7 ++++--- guix/import/cpan.scm | 50 ++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 44 insertions(+), 13 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index ccb87c9443..81b9353f1d 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3089,9 +3089,10 @@ guix import pypi itsdangerous Import meta-data from @uref{https://www.metacpan.org/, MetaCPAN}. Information is taken from the JSON-formatted meta-data provided through @uref{https://api.metacpan.org/, MetaCPAN's API} and includes most -relevant information. License information should be checked closely. -Package dependencies are included but may in some cases needlessly -include core Perl modules. +relevant information, such as module dependencies. License information +should be checked closely. If Perl is available in the store, then the +@code{corelist} utility will be used to filter core modules out of the +list of dependencies. The command command below imports meta-data for the @code{Acme::Boolean} Perl module: diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm index 5f4602a8d2..c1b0006e8c 100644 --- a/guix/import/cpan.scm +++ b/guix/import/cpan.scm @@ -19,6 +19,8 @@ (define-module (guix import cpan) #:use-module (ice-9 match) #:use-module (ice-9 regex) + #:use-module ((ice-9 popen) #:select (open-pipe* close-pipe)) + #:use-module ((ice-9 rdelim) #:select (read-line)) #:use-module (srfi srfi-1) #:use-module (json) #:use-module (guix hash) @@ -27,6 +29,9 @@ #:use-module ((guix download) #:select (download-to-store)) #:use-module (guix import utils) #:use-module (guix import json) + #:use-module (guix packages) + #:use-module (guix derivations) + #:use-module (gnu packages perl) #:export (cpan->guix-package)) ;;; Commentary: @@ -71,6 +76,14 @@ "Transform a 'module' name into a 'release' name" (regexp-substitute/global #f "::" module 'pre "-" 'post)) +(define (module->dist-name module) + "Return the base distribution module for a given module. E.g. the 'ok' +module is distributed with 'Test::Simple', so (module->dist-name \"ok\") would +return \"Test-Simple\"" + (assoc-ref (json-fetch (string-append "http://api.metacpan.org/module/" + module)) + "distribution")) + (define (cpan-fetch module) "Return an alist representation of the CPAN metadata for the perl module MODULE, or #f on failure. MODULE should be e.g. \"Test::Script\"" @@ -84,6 +97,14 @@ or #f on failure. MODULE should be e.g. \"Test::Script\"" (define (cpan-home name) (string-append "http://search.cpan.org/dist/" name)) +(define %corelist + (let* ((perl (with-store store + (derivation->output-path + (package-derivation store perl)))) + (core (string-append perl "/bin/corelist"))) + (and (access? core X_OK) + core))) + (define (cpan-module->sexp meta) "Return the `package' s-expression for a CPAN module from the metadata in META." @@ -98,6 +119,17 @@ META." (define version (assoc-ref meta "version")) + (define (core-module? name) + (and %corelist + (parameterize ((current-error-port (%make-void-port "w"))) + (let* ((corelist (open-pipe* OPEN_READ %corelist name))) + (let loop ((line (read-line corelist))) + (if (eof-object? line) + (begin (close-pipe corelist) #f) + (if (string-contains line "first released with perl") + (begin (close-pipe corelist) #t) + (loop (read-line corelist))))))))) + (define (convert-inputs phases) ;; Convert phase dependencies into a list of name/variable pairs. (match (flatten @@ -112,15 +144,13 @@ META." (delete-duplicates ;; Listed dependencies may include core modules. Filter those out. (filter-map (match-lambda - ((or (module . "0") ("perl" . _)) - ;; TODO: A stronger test might to run MODULE through - ;; `corelist' from our perl package. This current test - ;; seems to be only a loose convention. + (("perl" . _) ;implicit dependency #f) ((module . _) - (let ((name (guix-name (module->name module)))) - (list name - (list 'unquote (string->symbol name)))))) + (and (not (core-module? module)) + (let ((name (guix-name (module->dist-name module)))) + (list name + (list 'unquote (string->symbol name))))))) inputs))))) (define (maybe-inputs guix-name inputs) @@ -147,12 +177,12 @@ META." ,(bytevector->nix-base32-string (file-sha256 tarball)))))) (build-system perl-build-system) ,@(maybe-inputs 'native-inputs - ;; "runtime" and "test" may also be needed here. See + ;; "runtime" may also be needed here. See ;; https://metacpan.org/pod/CPAN::Meta::Spec#Phases, ;; which says they are required during building. We ;; have not yet had a need for cross-compiled perl - ;; modules, however, so we leave them out. - (convert-inputs '("configure" "build"))) + ;; modules, however, so we leave it out. + (convert-inputs '("configure" "build" "test"))) ,@(maybe-inputs 'inputs (convert-inputs '("runtime"))) (home-page ,(string-append "http://search.cpan.org/dist/" name)) -- cgit v1.2.3 From a21b23d34a68fda0a57b5be67f61cffae8db59cd Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 26 Feb 2015 22:17:21 +0100 Subject: services: slim: Preserve the order of session types. That makes WindowMaker the default session, by default. * gnu/services/xorg.scm (xsessions-directory)[builder]: Prepend a number in the file name to preserve the order of SESSIONS. (slim-service): Augment docstring. * doc/guix.texi (X Window): Adjust accordingly. --- doc/guix.texi | 3 ++- gnu/services/xorg.scm | 33 ++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 12 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 81b9353f1d..bd8091ae51 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -4634,7 +4634,8 @@ theme to use. In that case, @var{theme-name} specifies the name of the theme. Last, @var{session} is a list of @code{} objects denoting the -available session types that can be chosen from the log-in screen. +available session types that can be chosen from the log-in screen. The first +one is chosen by default. @end deffn @defvr {Scheme Variable} %default-sessions diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm index 7cb9012b68..f990d1a2cc 100644 --- a/gnu/services/xorg.scm +++ b/gnu/services/xorg.scm @@ -207,23 +207,33 @@ which should be passed to this script as the first argument. If not, the (list %windowmaker-session-type %ratpoison-session-type)) (define (xsessions-directory sessions) - "Return a directory containing SESSIONS, a list of objects." + "Return a directory containing SESSIONS, a list of objects. +The alphabetical order of the files in that directory match the order of the +elements in SESSIONS." (define builder #~(begin + (use-modules (srfi srfi-1) + (ice-9 format)) + (mkdir #$output) (chdir #$output) - (for-each (lambda (name executable) - (let ((file (string-append (string-downcase name) - ".desktop"))) - (call-with-output-file file - (lambda (port) - (format port "[Desktop Entry] + (fold (lambda (name executable number) + ;; Create file names such that the order of the items in + ;; SESSION is respected. SLiM gets them in lexicographic + ;; order and uses the first one as the default session. + (let ((file (format #f "~2,'0d-~a.desktop" + number (string-downcase name)))) + (call-with-output-file file + (lambda (port) + (format port "[Desktop Entry] Name=~a Exec=~a Type=Application~%" - name executable))))) - '#$(map session-type-name sessions) - (list #$@(map session-type-executable sessions))))) + name executable))) + (+ 1 number))) + 1 + '#$(map session-type-name sessions) + (list #$@(map session-type-executable sessions))))) (gexp->derivation "xsessions-dir" builder)) @@ -260,7 +270,8 @@ theme to use. In that case, @var{theme-name} specifies the name of the theme. Last, @var{session} is a list of @code{} objects denoting the -available session types that can be chosen from the log-in screen." +available session types that can be chosen from the log-in screen. The first +one is chosen by default." (define (slim.cfg) (mlet %store-monad ((startx (or startx (xorg-start-command))) -- cgit v1.2.3