Subject: [PATCH 4/9] gnu: Use ‘current-target-nix-system’ in pattern matches

From: Thiago Jung Bauermann <[email-masked]>
Date: Tue, 20 Jul 2021 22:00:38 -0300

Parts of the code try to match a Nix system identifier to either
‘%current-target-system’ or ‘%current-system’, but this won’t work for
cross-compiling because the former parameter contains a GNU triplet
identifier.

Fix the problem by matching against ‘current-target-nix-system’, which
always returns a Nix system identifier.

* gnu/packages/astronomy.scm (libpasastro)[arguments]<#:make-flags>: Use
‘current-target-nix-system’.
* gnu/packages/compression.scm (zpaq)[arguments]<#:make-flags>: Likewise.
* gnu/packages/digest.scm (xxhash)[arguments]<#:make-flags>: Likewise.
* gnu/packages/java.scm (java-swt)[source]: Likewise.
* gnu/packages/julia.scm (julia)[arguments]<#:make-flags>: Likewise.
* gnu/packages/make-bootstrap.scm (%bootstrap-tarballs)[inputs]: Likewise.
* gnu/packages/pascal.scm (fpc)[native-inputs]: Likewise.
[arguments]<#:phases>: Likewise.
* gnu/packages/video.scm (mplayer)[arguments]<#:phases>: Likewise.
* gnu/packages/web.scm (nginx)[arguments]<#:phases>: Likewise.
(nginx-accept-language-module)[arguments]<#:phases>: Likewise.
---
 gnu/packages/astronomy.scm      | 4 ++--
 gnu/packages/compression.scm    | 6 ++----
 gnu/packages/digest.scm         | 3 +--
 gnu/packages/java.scm           | 2 +-
 gnu/packages/julia.scm          | 3 +--
 gnu/packages/make-bootstrap.scm | 2 +-
 gnu/packages/pascal.scm         | 6 ++----
 gnu/packages/video.scm          | 3 +--
 gnu/packages/web.scm            | 6 ++----
 9 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/gnu/packages/astronomy.scm b/gnu/packages/astronomy.scm
index a3f7d5cbf456..8c4a759718e7 100644
--- a/gnu/packages/astronomy.scm
+++ b/gnu/packages/astronomy.scm
@@ -645,11 +645,11 @@ low quality ones")
        `(#:tests? #f
          #:make-flags
          (list
-          ,(match (or (%current-target-system) (%current-system))
+          ,(match (current-target-nix-system)
              ((or "aarch64-linux" "armhf-linux" "i686-linux" "x86_64-linux")
               "OS_TARGET=linux")
              (_ #f))
-          ,(match (or (%current-target-system) (%current-system))
+          ,(match (current-target-nix-system)
              ("i686-linux" "CPU_TARGET=i386")
              ("x86_64-linux" "CPU_TARGET=x86_64")
              ((or "armhf-linux" "aarch64-linux") "CPU_TARGET=armv7l")
diff --git a/gnu/packages/compression.scm b/gnu/packages/compression.scm
index cf4ec4e644a3..ac217e663f4c 100644
--- a/gnu/packages/compression.scm
+++ b/gnu/packages/compression.scm
@@ -1434,16 +1434,14 @@ functionality in a C++ iostream.")
        #:make-flags
        (list
         (string-append "CPPFLAGS=-Dunix"
-                       ,(match (or (%current-target-system)
-                                   (%current-system))
+                       ,(match (current-target-nix-system)
                                ("x86_64-linux"  "")
                                ("i686-linux"    "")
                                (_               " -DNOJIT")))
         ;; These should be safe, lowest-common-denominator instruction sets,
         ;; allowing for some optimisation while remaining reproducible.
         (string-append "CXXFLAGS=-O3 -DNDEBUG"
-                       ,(match (or (%current-target-system)
-                                   (%current-system))
+                       ,(match (current-target-nix-system)
                                ("x86_64-linux"  " -march=nocona -mtune=generic")
                                ("i686-linux"    " -march=i686 -mtune=generic")
                                ("armhf-linux"   " -mtune=generic-armv7-a")
diff --git a/gnu/packages/digest.scm b/gnu/packages/digest.scm
index 986e33586133..b1954221f261 100644
--- a/gnu/packages/digest.scm
+++ b/gnu/packages/digest.scm
@@ -77,8 +77,7 @@ Zig, V, and Nim programming language standard libraries.")
     (arguments
      `(#:make-flags
        (list ,(string-append "CC=" (cc-for-target))
-             ,(match (or (%current-target-system)
-                         (%current-system))
+             ,(match (current-target-nix-system)
                 ;; Detect vector instruction set at run time.
                 ((or "i686-linux" "x86_64-linux") "DISPATCH=1")
                 (_ "DISPATCH=0"))
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index e69d62be0802..1c62f5d358e2 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -3715,7 +3715,7 @@ specification.")
            (file32 "x86")
            (file64 "x86_64"))
        (let-values (((hash file)
-                     (match (or (%current-target-system) (%current-system))
+                     (match (current-target-nix-system)
                        ("x86_64-linux" (values hash64 file64))
                        (_              (values hash32 file32)))))
          (origin
diff --git a/gnu/packages/julia.scm b/gnu/packages/julia.scm
index abefc388bc6e..b5e29c394532 100644
--- a/gnu/packages/julia.scm
+++ b/gnu/packages/julia.scm
@@ -373,8 +373,7 @@ libraries.  It is also a bit like @code{ldd} and @code{otool -L}.")
 
          ;; Passing the MARCH flag is necessary to build binary substitutes for
          ;; the supported architectures.
-         ,(match (or (%current-target-system)
-                     (%current-system))
+         ,(match (current-target-nix-system)
                  ("x86_64-linux" "MARCH=x86-64")
                  ("i686-linux" "MARCH=pentium4")
                  ("armhf-linux" "JULIA_CPU_TARGET=armv7-a,neon")
diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm
index cdcb1dcaa295..fd656f9b8bfd 100644
--- a/gnu/packages/make-bootstrap.scm
+++ b/gnu/packages/make-bootstrap.scm
@@ -902,7 +902,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
                    %build-inputs)
          #t)))
     (inputs `(("guile-tarball" ,%guile-bootstrap-tarball)
-              ,@(match (or (%current-target-system) (%current-system))
+              ,@(match (current-target-nix-system)
                   ((or "i686-linux" "x86_64-linux")
                    `(("bootstrap-mescc-tools" ,%mescc-tools-bootstrap-tarball)
                      ("bootstrap-mes" ,%mes-bootstrap-tarball)
diff --git a/gnu/packages/pascal.scm b/gnu/packages/pascal.scm
index 0fdbecf05c20..9169584558b0 100644
--- a/gnu/packages/pascal.scm
+++ b/gnu/packages/pascal.scm
@@ -89,8 +89,7 @@
     (native-inputs
      ;; FPC is built with FPC, so we need bootstrap binaries.
      `(("fpc-binary"
-        ,(match (or (%current-target-system)
-                    (%current-system))
+        ,(match (current-target-nix-system)
           ("i686-linux" fpc-bootstrap-i386-3.0.4)
           ;("powerpc64le-linux" fpc-bootstrap-ppc64le-3.0.4)
           ;("powerpc-linux" fpc-bootstrap-ppc-3.0.4)
@@ -101,8 +100,7 @@
        #:phases
        (let ((fpc-bootstrap-path
               (string-append (getcwd) "/" ,name "-" ,version "/fpc-bin"))
-             (arch ,(match (or (%current-target-system)
-                               (%current-system))
+             (arch ,(match (current-target-nix-system)
                      ("i686-linux" "i386")
                      ("x86_64-linux" "x86_64")
                      (_ "unknown"))))
diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm
index 399327741f6b..6cf8b90ffa95 100644
--- a/gnu/packages/video.scm
+++ b/gnu/packages/video.scm
@@ -2021,8 +2021,7 @@ streaming protocols.")
                       (string-append "--prefix=" out)
                       ;; Enable runtime cpu detection where supported,
                       ;; and choose a suitable target.
-                      ,@(match (or (%current-target-system)
-                                   (%current-system))
+                      ,@(match (current-target-nix-system)
                           ("x86_64-linux"
                            '("--enable-runtime-cpudetection"
                              "--target=x86_64-linux"))
diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index 2cc8619b19d9..b00c9aa3db5b 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -413,8 +413,7 @@ the same, being completely separated from the Internet.")
                                   ,(let ((system "Linux")    ; uname -s
                                          (release "3.2.0")   ; uname -r
                                          ;; uname -m
-                                         (machine (match (or (%current-target-system)
-                                                             (%current-system))
+                                         (machine (match (current-target-nix-system)
                                                     ("x86_64-linux"   "x86_64")
                                                     ("i686-linux"     "i686")
                                                     ("mips64el-linux" "mips64")
@@ -605,8 +604,7 @@ ngx_http_accept_language_module~%")
                        ,(let ((system "Linux")    ; uname -s
                               (release "3.2.0")   ; uname -r
                               ;; uname -m
-                              (machine (match (or (%current-target-system)
-                                                  (%current-system))
+                              (machine (match (current-target-nix-system)
                                          ("x86_64-linux"   "x86_64")
                                          ("i686-linux"     "i686")
                                          ("mips64el-linux" "mips64")