rekado pushed a commit to branch core-updates
in repository guix.

commit baecf6ab707282b07511340bc460e575bf3433d9
Author: Zheng Junjie <[email protected]>
AuthorDate: Tue Jul 16 01:20:44 2024 +0800

    gnu: Add nss-certs-for-test.
    
    * gnu/packages/certs.scm (nss-certs-for-test): New variable.
    * gnu/packages/python-web.scm (python-requests-next)[native-inputs]: Add it.
    
    Change-Id: Id808e058835556717a6585ecd86dd14d0d2a5039
---
 gnu/packages/certs.scm      | 45 +++++++++++++++++++++++++++++++++++++++++++++
 gnu/packages/python-web.scm |  4 ++++
 2 files changed, 49 insertions(+)

diff --git a/gnu/packages/certs.scm b/gnu/packages/certs.scm
index 449be0b35a..e2de6b168b 100644
--- a/gnu/packages/certs.scm
+++ b/gnu/packages/certs.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2021 Maxim Cournoyer <[email protected]>
 ;;; Copyright © 2021 Efraim Flashner <[email protected]>
 ;;; Copyright © 2021 Raghav Gururajan <[email protected]>
+;;; Copyright © 2024 Zheng Junjie <[email protected]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -25,6 +26,7 @@
 
 (define-module (gnu packages certs)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module ((guix search-paths) #:select ($SSL_CERT_DIR $SSL_CERT_FILE))
   #:use-module (guix packages)
   #:use-module (guix utils)
   #:use-module (guix download)
@@ -188,6 +190,49 @@ taken from the NSS package and thus ultimately from the 
Mozilla project.")
     (home-page "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS";)
     (license license:mpl2.0)))
 
+(define-public nss-certs-for-test
+  (hidden-package
+   (package
+     (inherit nss-certs)
+     (name "nss-certs-for-test")
+     (source #f)
+     (build-system trivial-build-system)
+     (native-inputs (list nss-certs))
+     (inputs '())
+     (propagated-inputs '())
+     (arguments
+      (list #:modules '((guix build utils)
+                        (rnrs io ports)
+                        (srfi srfi-26))
+            #:builder
+            #~(begin
+                (use-modules (guix build utils)
+                             (rnrs io ports)
+                             (srfi srfi-26))
+                (define certs-dir (string-append #$output "/etc/ssl/certs/"))
+                (define ca-files
+                  (find-files (string-append #+(this-package-native-input
+                                                "nss-certs")
+                                             "/etc/ssl/certs")
+                              (lambda (file stat)
+                                (string-suffix? ".pem" file))))
+                (define (concatenate-files files result)
+                  "Make RESULT the concatenation of all of FILES."
+                  (define (dump file port)
+                    (display (call-with-input-file file get-string-all) port)
+                    (newline port))
+                  (call-with-output-file result
+                    (lambda (port)
+                      (for-each (cut dump <> port) files))))
+
+                (mkdir-p certs-dir)
+                (concatenate-files
+                 ca-files (string-append certs-dir "/ca-certificates.crt"))
+                (for-each (cut install-file <> certs-dir) ca-files))))
+     (native-search-paths
+      (list $SSL_CERT_DIR
+            $SSL_CERT_FILE)))))
+
 (define-public le-certs
   (package
     (name "le-certs")
diff --git a/gnu/packages/python-web.scm b/gnu/packages/python-web.scm
index bca7da9139..9367dfba34 100644
--- a/gnu/packages/python-web.scm
+++ b/gnu/packages/python-web.scm
@@ -65,6 +65,7 @@
 ;;; Copyright © 2024 Sharlatan Hellseher <[email protected]>
 ;;; Copyright © 2024 normally_js <[email protected]>
 ;;; Copyright © 2024 Markku Korkeala <[email protected]>
+;;; Copyright © 2024 Zheng Junjie <[email protected]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -94,6 +95,7 @@
   #:use-module (gnu packages admin)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
+  #:use-module (gnu packages certs)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages curl)
@@ -3614,6 +3616,8 @@ than Python’s urllib2 library.")
               (base32
                "0q5742pnibwy74169kacin3dmqg9jzmzk7qab5aq5caffcbm8djm"))))
     (build-system python-build-system)
+    (native-inputs
+     (list nss-certs-for-test))
     (propagated-inputs
      (list python-certifi
            python-charset-normalizer

Reply via email to