Subject: [bug#64861] [PATCH] guix: Add lint check for guix as propagated-input

From: Karl Hallsby <[email-masked]>
Date: Tue, 25 Jul 2023 13:04:43 -0500

* guix/lint.scm (new check): Run lint check warning user if the provided
package uses guix as a propagated-input.

Passing guix as a propagated-input is problematic when users install a package
into their profiles. This can cause the guix propagated by the package to be
used in preference of the real one in $HOME/.config/. It was first noticed on
IRC with https://logs.guix.gnu.org/guix/2023-07-22.log#044534, and reproduced
with a different package https://logs.guix.gnu.org/guix/2023-07-25.log#054737.
---
 guix/lint.scm | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/guix/lint.scm b/guix/lint.scm
index d173563e51..5fae34ca22 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -575,6 +575,16 @@ (define (check-input-labels package)
                 (inputs ,package-inputs)
                 (propagated-inputs ,package-propagated-inputs))))
 
+(define (check-guix-propagated-inputs package)
+  (if (and (not (null? (package-propagated-inputs package)))
+           (not (memq (@ (gnu packages package-management) guix)
+                      (package-propagated-inputs package))))
+      (list
+       (make-warning package
+                     (G_ "are you sure guix should be a propagated-input?")
+                     #:field 'propagated-inputs))
+      '()))
+
 (define (report-wrap-program-error package wrapper-name)
   "Warn that \"bash-minimal\" is missing from 'inputs', while WRAPPER-NAME
 requires it."
@@ -1884,6 +1894,10 @@ (define %local-checkers
      (name        'input-labels)
      (description "Identify input labels that do not match package names")
      (check       check-input-labels))
+   (lint-checker
+     (name        'warn-guix-propagated-inputs)
+     (description "Emit warning if guix package is propagated-input")
+     (check       check-guix-propagated-inputs))
    (lint-checker
      (name        'wrapper-inputs)
      (description "Make sure 'wrap-program' can finds its interpreter.")

base-commit: 9ff1e7652a407b88a3eeeab6a67261f6fee40807
-- 
2.40.1