From ca465a9c8454289b7aded22719cd5d919e441780 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 5 Nov 2020 14:52:29 +0100 Subject: gexp: Warn when importing (guix config) or (ice-9 …). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While importing those modules from the host system is valid, it is often a mistake that introduces non-reproducibility. This patch prints a warning when that happens. * guix/gexp.scm (gexp-attribute): Add #:validate parameter and honor it. (gexp-modules)[validate-modules]: New procedure. Pass it to 'gexp-attribute'. * tests/gexp.scm ("gexp-modules, warning"): New test. --- tests/gexp.scm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/gexp.scm') diff --git a/tests/gexp.scm b/tests/gexp.scm index 0487f2a96d..686334af61 100644 --- a/tests/gexp.scm +++ b/tests/gexp.scm @@ -30,6 +30,7 @@ (define-module (test-gexp) #:use-module (gnu packages) #:use-module (gnu packages base) #:use-module (gnu packages bootstrap) + #:use-module ((guix diagnostics) #:select (guix-warning-port)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-34) #:use-module (srfi srfi-64) @@ -818,6 +819,17 @@ (define result '() (gexp-modules #t)) +(test-assert "gexp-modules, warning" + (string-match "tests/gexp.scm:[0-9]+:[0-9]+: warning: \ +importing.* \\(guix config\\) from the host" + (call-with-output-string + (lambda (port) + (parameterize ((guix-warning-port port)) + (let* ((x (with-imported-modules '((guix config)) + #~(+ 1 2 3))) + (y #~(+ 39 #$x))) + (gexp-modules y))))))) + (test-assertm "gexp->derivation #:modules" (mlet* %store-monad ((build -> #~(begin -- cgit v1.2.3