Subject: [PATCH v3] Build on Aarch64

From: phodina <[email-masked]>
Date: Sat, 15 Oct 2022 07:17:28 +0000

Hi Maxime,

could you please review the 2 patches for Alacritty?

First one is to build it on Aarch64 (disables one failing test).

The other enables HW support on devices like PineBook Pro - I remeber you use one Efraim. [1]

The rest is just for newer version.

I have to check the antioxidant system! It's been on my list for too long.

1 https://github.com/alacritty/alacritty/issues/128#issuecomment-880270507

Thanks!

----
Petr

From 40545268e803fa52727645e95c83705d2ed09e3a Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Sat, 23 Apr 2022 21:04:58 +0200
Subject: [PATCH v3 3/7] gnu: rust-structopt-derive-0.4: Update to 0.4.18.

* gnu/packages/crates-io.scm (rust-structopt-derive-0.4): Update to 0.4.18.

diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 538267c560..7a095701ba 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -61636,7 +61636,7 @@ (define-public rust-structopt-0.2
 (define-public rust-structopt-derive-0.4
   (package
    (name "rust-structopt-derive")
-   (version "0.4.14")
+   (version "0.4.18")
    (source
     (origin
      (method url-fetch)
@@ -61645,7 +61645,7 @@ (define-public rust-structopt-derive-0.4
       (string-append name "-" version ".tar.gz"))
      (sha256
       (base32
-       "143gjwvz3s86hwp070km83y25n8kqp5f01kb1dr19f4ilkywvaav"))))
+       "1q5gcigmvw0cinjxzpyrkflliq5r1ivljmrvfrl3phcwgwraxdfw"))))
    (build-system cargo-build-system)
    (arguments
     `(#:skip-build? #t
-- 
2.37.2

From 7cea824edfc410bcccbebd0c31ecd7f392648781 Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Fri, 5 Aug 2022 19:06:15 +0200
Subject: [PATCH v3 7/7] gnu: alacritty: Remove input labels.

* gnu/packages/terminals.scm (alacritty)[inputs]: Remove labels.

diff --git a/gnu/packages/terminals.scm b/gnu/packages/terminals.scm
index 665d8e073e..d0513c17cb 100644
--- a/gnu/packages/terminals.scm
+++ b/gnu/packages/terminals.scm
@@ -1459,30 +1459,25 @@ (define-public alacritty
                (install-file "extra/completions/alacritty.fish"
                              (string-append share "/fish/vendor_completions.d"))
                #t))))))
-    (native-inputs
-     `(("cmake" ,cmake)
-       ("ncurses" ,ncurses)
-       ("pkg-config" ,pkg-config)
-       ("python3" ,python)))
-    (inputs
-     `(("expat" ,expat)
-       ("fontconfig" ,fontconfig)
-       ("freetype" ,freetype)
-       ("libx11" ,libx11)
-       ("libxcb" ,libxcb)
-       ("libxcursor" ,libxcursor)
-       ("libxi" ,libxi)
-       ("libxkbcommon" ,libxkbcommon)
-       ("libxrandr" ,libxrandr)
-       ("libxxf86vm" ,libxxf86vm)
-       ("mesa" ,mesa)
-       ("rust-bitflags" ,rust-bitflags-1)
-       ("rust-dirs" ,rust-dirs-3)
-       ("rust-libc" ,rust-libc-0.2)
-       ("rust-unicode-width" ,rust-unicode-width-0.1)
-       ("rust-wayland-client" ,rust-wayland-client-0.28)
-       ("rust-winapi" ,rust-winapi-0.3)
-       ("wayland" ,wayland)))
+    (native-inputs (list cmake ncurses pkg-config python))
+    (inputs (list expat
+                  fontconfig
+                  freetype
+                  libx11
+                  libxcb
+                  libxcursor
+                  libxi
+                  libxkbcommon
+                  libxrandr
+                  libxxf86vm
+                  mesa
+                  rust-bitflags-1
+                  rust-dirs-3
+                  rust-libc-0.2
+                  rust-unicode-width-0.1
+                  rust-wayland-client-0.28
+                  rust-winapi-0.3
+                  wayland))
     (native-search-paths
      ;; FIXME: This should only be located in 'ncurses'.  Nonetheless it is
      ;; provided for usability reasons.  See <https://bugs.gnu.org/22138>.
-- 
2.37.2

From fd2101715dd10f021db8ee5989036c1024d9f03d Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Sun, 24 Apr 2022 11:06:41 +0200
Subject: [PATCH v3 6/7] gnu: alacritty: Update to 0.10.1.

* gnu/packages/terminals.scm (alacritty): Update to 0.10.1.
  [arguments]: Update to rust-alacritty-terminal-0.16, rust-glutin-0.28,
  rust-raw-window-handle-0.4 and rust-wayland-client-0.29. Add rust-dirs-3,
  rust-structopt-0.3 and rust-unicode-width-0.1. Remove rust-clap-2,
  rust-time-0.1, rust-urlocator-0.1 in cargo-inputs.
 Update version of packages in 'add-absolute-library-references phase.

diff --git a/gnu/packages/terminals.scm b/gnu/packages/terminals.scm
index ce096b1bc2..665d8e073e 100644
--- a/gnu/packages/terminals.scm
+++ b/gnu/packages/terminals.scm
@@ -29,7 +29,7 @@
 ;;; Copyright © 2021 ikasero <[email-masked]>
 ;;; Copyright © 2021 Brice Waegeneire <[email-masked]>
 ;;; Copyright © 2021 Solene Rapenne <[email-masked]>
-;;; Copyright © 2021 Petr Hodina <[email-masked]>
+;;; Copyright © 2021, 2022 Petr Hodina <[email-masked]>
 ;;; Copyright © 2022 Felipe Balbi <[email-masked]>
 ;;; Copyright © 2022 ( <[email-masked]>
 ;;;
@@ -1331,7 +1331,7 @@ (define-public tio
 (define-public alacritty
   (package
     (name "alacritty")
-    (version "0.9.0")
+    (version "0.10.1")
     (source
      (origin
        ;; XXX: The crate at "crates.io" has limited contents.  In particular,
@@ -1350,7 +1350,7 @@ (define-public alacritty
           "alacritty-use-OpenGL-3.1-with-extensions-instead-of-OpenGL-3.3.patch")
           '()))
        (sha256
-        (base32 "068y0b1a0m33r7a3j2xf6k602sc8062gm4d5568ynfx6w5n481lj"))))
+        (base32 "1s38gyx0ifcf1vcr6n8gzbk7rg1apxrz7js8cp8x5k1s0m3abys3"))))
     (build-system cargo-build-system)
     (arguments
      `(#:install-source? #f     ; virtual manifest
@@ -1360,46 +1360,42 @@ (define-public alacritty
                             '("--skip=mock_term") '()))
        #:cargo-inputs
        (("rust-alacritty-config-derive" ,rust-alacritty-config-derive-0.1)
-        ("rust-alacritty-terminal" ,rust-alacritty-terminal-0.15)
-        ("rust-clap" ,rust-clap-2)
+        ("rust-alacritty-terminal" ,rust-alacritty-terminal-0.16)
         ("rust-cocoa" ,rust-cocoa-0.24)
         ("rust-copypasta" ,rust-copypasta-0.7)
         ("rust-crossfont" ,rust-crossfont-0.3)
+        ("rust-dirs" ,rust-dirs-3)
         ("rust-embed-resource" ,rust-embed-resource-1)
         ("rust-fnv" ,rust-fnv-1)
         ("rust-gl-generator" ,rust-gl-generator-0.14)
         ;; XXX: Adjust `add-absolute-library-references' phase when updating
         ;; glutin input.
-        ("rust-glutin" ,rust-glutin-0.26)
+        ("rust-glutin" ,rust-glutin-0.28)
         ("rust-log" ,rust-log-0.4)
         ("rust-notify" ,rust-notify-4)
         ("rust-objc" ,rust-objc-0.2)
         ("rust-parking-lot" ,rust-parking-lot-0.11)
         ("rust-png" ,rust-png-0.16)
-        ("rust-raw-window-handle" ,rust-raw-window-handle-0.3)
+        ("rust-raw-window-handle" ,rust-raw-window-handle-0.4)
         ("rust-serde" ,rust-serde-1)
         ("rust-serde-json" ,rust-serde-json-1)
         ("rust-serde-yaml" ,rust-serde-yaml-0.8)
-        ("rust-time" ,rust-time-0.1)
-        ("rust-urlocator" ,rust-urlocator-0.1)
+        ("rust-structopt" ,rust-structopt-0.3)
+        ("rust-unicode-width" ,rust-unicode-width-0.1)
         ("rust-x11-dl" ,rust-x11-dl-2)
         ("rust-xdg" ,rust-xdg-2))
        #:phases
        (modify-phases %standard-phases
-         (add-after 'unpack 'use-new-nix
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             (substitute* "alacritty_terminal/Cargo.toml"
-               (("0.22.0") "^0.23.0"))))
          (add-after 'configure 'add-absolute-library-references
            (lambda* (#:key inputs cargo-inputs vendor-dir #:allow-other-keys)
-             (let* ((glutin-name ,(package-name rust-glutin-0.26))
-                    (glutin-version ,(package-version rust-glutin-0.26))
+             (let* ((glutin-name ,(package-name rust-glutin-0.28))
+                    (glutin-version ,(package-version rust-glutin-0.28))
                     (glutin-api (string-append glutin-name "-" glutin-version
                                                ".tar.gz/src/api/"))
                     (smithay-client-toolkit-name
-                     ,(package-name rust-smithay-client-toolkit-0.12))
+                     ,(package-name rust-smithay-client-toolkit-0.15))
                     (smithay-client-toolkit-version
-                     ,(package-version rust-smithay-client-toolkit-0.12))
+                     ,(package-version rust-smithay-client-toolkit-0.15))
                     (smithay-client-toolkit-src
                      (string-append smithay-client-toolkit-name "-"
                                     smithay-client-toolkit-version ".tar.gz/src"))
-- 
2.37.2

From 9d0448eb50f428179ae51b12f6af96f7652efa36 Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Sat, 15 Oct 2022 08:42:17 +0200
Subject: [PATCH v3 2/7] gnu: alacritty: Patch to run on OpenGL 3.1 on aarch64
 target.

* gnu/packages/terminals.scm (alacritty)[source]: Apply patch on aarch64
target.
* gnu/packages/patches/alacritty-use-OpenGL-3.1-with-extensions-instead-of-OpenGL-3.3.patch:
New file
* gnu/local.mk: Add patch.

diff --git a/gnu/local.mk b/gnu/local.mk
index 78bdc113ac..15c62d5c7f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -865,6 +865,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/akonadi-paths.patch		\
   %D%/packages/patches/akonadi-not-relocatable.patch		\
   %D%/packages/patches/akonadi-timestamps.patch		\
+  %D%/packages/patches/alacritty-use-OpenGL-3.1-with-extensions-instead-of-OpenGL-3.3.patch \
   %D%/packages/patches/allegro-mesa-18.2.5-and-later.patch	\
   %D%/packages/patches/anki-mpv-args.patch			\
   %D%/packages/patches/antiword-CVE-2014-8123.patch			\
diff --git a/gnu/packages/patches/alacritty-use-OpenGL-3.1-with-extensions-instead-of-OpenGL-3.3.patch b/gnu/packages/patches/alacritty-use-OpenGL-3.1-with-extensions-instead-of-OpenGL-3.3.patch
new file mode 100644
index 0000000000..92d72a83e7
--- /dev/null
+++ b/gnu/packages/patches/alacritty-use-OpenGL-3.1-with-extensions-instead-of-OpenGL-3.3.patch
@@ -0,0 +1,86 @@
+From cc6f303100075e286d09ca77d31749f7adcdffc6 Mon Sep 17 00:00:00 2001
+From: Autumn <[email-masked]>
+Date: Wed, 14 Jul 2021 04:37:03 -0700
+Subject: [PATCH] use OpenGL 3.1 with extensions instead of OpenGL 3.3
+
+---
+ alacritty/build.rs            | 2 +-
+ alacritty/res/rect.f.glsl     | 2 +-
+ alacritty/res/rect.v.glsl     | 3 ++-
+ alacritty/res/text.f.glsl     | 3 ++-
+ alacritty/res/text.v.glsl     | 3 ++-
+ alacritty/src/renderer/mod.rs | 2 +-
+ 6 files changed, 9 insertions(+), 6 deletions(-)
+
+diff --git a/alacritty/build.rs b/alacritty/build.rs
+index 48841ca..28c20e2 100644
+--- a/alacritty/build.rs
++++ b/alacritty/build.rs
+@@ -11,7 +11,7 @@ fn main() {
+     let dest = env::var("OUT_DIR").unwrap();
+     let mut file = File::create(&Path::new(&dest).join("gl_bindings.rs")).unwrap();
+ 
+-    Registry::new(Api::Gl, (3, 3), Profile::Core, Fallbacks::All, ["GL_ARB_blend_func_extended"])
++    Registry::new(Api::Gl, (3, 1), Profile::Core, Fallbacks::All, ["GL_ARB_blend_func_extended", "GL_ARB_instanced_arrays", "GL_ARB_explicit_attrib_location"])
+         .write_bindings(GlobalGenerator, &mut file)
+         .unwrap();
+ 
+diff --git a/alacritty/res/rect.f.glsl b/alacritty/res/rect.f.glsl
+index 945eaf2..9f84237 100644
+--- a/alacritty/res/rect.f.glsl
++++ b/alacritty/res/rect.f.glsl
+@@ -1,4 +1,4 @@
+-#version 330 core
++#version 140
+ 
+ flat in vec4 color;
+ 
+diff --git a/alacritty/res/rect.v.glsl b/alacritty/res/rect.v.glsl
+index bf9a97d..258bb36 100644
+--- a/alacritty/res/rect.v.glsl
++++ b/alacritty/res/rect.v.glsl
+@@ -1,4 +1,5 @@
+-#version 330 core
++#version 140
++#extension GL_ARB_explicit_attrib_location : require
+ layout (location = 0) in vec2 aPos;
+ layout (location = 1) in vec4 aColor;
+ 
+diff --git a/alacritty/res/text.f.glsl b/alacritty/res/text.f.glsl
+index d5e2688..d4d559c 100644
+--- a/alacritty/res/text.f.glsl
++++ b/alacritty/res/text.f.glsl
+@@ -1,4 +1,5 @@
+-#version 330 core
++#version 140
++#extension GL_ARB_explicit_attrib_location : require
+ in vec2 TexCoords;
+ flat in vec4 fg;
+ flat in vec4 bg;
+diff --git a/alacritty/res/text.v.glsl b/alacritty/res/text.v.glsl
+index 31e6f93..09c477a 100644
+--- a/alacritty/res/text.v.glsl
++++ b/alacritty/res/text.v.glsl
+@@ -1,4 +1,5 @@
+-#version 330 core
++#version 140
++#extension GL_ARB_explicit_attrib_location : require
+ // Cell properties.
+ layout(location = 0) in vec2 gridCoords;
+ 
+diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs
+index bac8225..3e170be 100644
+--- a/alacritty/src/renderer/mod.rs
++++ b/alacritty/src/renderer/mod.rs
+@@ -600,7 +600,7 @@ impl QuadRenderer {
+                         size as *const _,
+                     );
+                     gl::EnableVertexAttribArray(index);
+-                    gl::VertexAttribDivisor(index, 1);
++                    gl::VertexAttribDivisorARB(index, 1);
+ 
+                     #[allow(unused_assignments)]
+                     {
+-- 
+2.32.0
+
diff --git a/gnu/packages/terminals.scm b/gnu/packages/terminals.scm
index 1084cd2d7d..ce096b1bc2 100644
--- a/gnu/packages/terminals.scm
+++ b/gnu/packages/terminals.scm
@@ -1341,6 +1341,14 @@ (define-public alacritty
              (url "https://github.com/jwilm/alacritty")
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
+       ;; This patch enables to run Alacritty on aarch64 targets such as
+       ;; PineBook Pro which run Panfrost driver and support OpenGL 3.1
+       (patches
+         `,(if (string-prefix? "arch64" (or (%current-system)
+                                  (%current-target-system)))
+         (search-patches
+          "alacritty-use-OpenGL-3.1-with-extensions-instead-of-OpenGL-3.3.patch")
+          '()))
        (sha256
         (base32 "068y0b1a0m33r7a3j2xf6k602sc8062gm4d5568ynfx6w5n481lj"))))
     (build-system cargo-build-system)
-- 
2.37.2

From 1d0d0477fa095de4a8762007dcb7b18761903a0d Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Sat, 15 Oct 2022 08:39:59 +0200
Subject: [PATCH v3 1/7] gnu: alacritty: Fix build on aarch64 target.

* /gnu/packages/terminals.scm (alacritty)[arguments]: Disable failing test on
aarch64 target.

diff --git a/gnu/packages/terminals.scm b/gnu/packages/terminals.scm
index 9ece3043e0..1084cd2d7d 100644
--- a/gnu/packages/terminals.scm
+++ b/gnu/packages/terminals.scm
@@ -1346,7 +1346,10 @@ (define-public alacritty
     (build-system cargo-build-system)
     (arguments
      `(#:install-source? #f     ; virtual manifest
-       #:cargo-test-flags '("--release" "--" "--skip=config_read_eof")
+       #:cargo-test-flags '("--release" "--" "--skip=config_read_eof"
+         ,@(if (string-prefix? "aarch64" (or (%current-system)
+                                  (%current-target-system)))
+                            '("--skip=mock_term") '()))
        #:cargo-inputs
        (("rust-alacritty-config-derive" ,rust-alacritty-config-derive-0.1)
         ("rust-alacritty-terminal" ,rust-alacritty-terminal-0.15)
-- 
2.37.2

From 9abdeebac1889461ca4625359952d735f811d046 Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Sun, 24 Apr 2022 11:01:28 +0200
Subject: [PATCH v3 5/7] gnu: Add rust-alacritty-terminal-0.16.

* gnu/packages/crates-graphics.scm (rust-alacritty-terminal-0.16): New variable.
  (rust-alacritty-terminal-0.15): Remove variable.

diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 9d2d5a86f9..ad650e6c3e 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -2571,17 +2571,17 @@ (define-public rust-alacritty-config-derive-0.1
      "This package provides a failure resistant deserialization derive.")
     (license (list license:expat license:asl2.0))))
 
-(define-public rust-alacritty-terminal-0.15
+(define-public rust-alacritty-terminal-0.16
   (package
     (name "rust-alacritty-terminal")
-    (version "0.15.0")
+    (version "0.16.1")
     (source
      (origin
        (method url-fetch)
        (uri (crate-uri "alacritty_terminal" version))
        (file-name (string-append name "-" version ".tar.gz"))
        (sha256
-        (base32 "1qv8zv20qgn407v8m196p68yddvhalcppc21702698cj99b45ckc"))))
+        (base32 "0bvffvjmkran068p9bz0p9nrkj1k4bggd7q39mszjfafz155vyq2"))))
     (build-system cargo-build-system)
     (arguments
      `(#:skip-build? #t
@@ -2589,19 +2589,20 @@ (define-public rust-alacritty-terminal-0.15
        (("rust-alacritty-config-derive" ,rust-alacritty-config-derive-0.1)
         ("rust-base64" ,rust-base64-0.13)
         ("rust-bitflags" ,rust-bitflags-1)
-        ("rust-dirs" ,rust-dirs-2)
+        ("rust-dirs" ,rust-dirs-3)
         ("rust-libc" ,rust-libc-0.2)
         ("rust-log" ,rust-log-0.4)
         ("rust-mio" ,rust-mio-0.6)
         ("rust-mio-anonymous-pipes" ,rust-mio-anonymous-pipes-0.2)
         ("rust-mio-extras" ,rust-mio-extras-2)
         ("rust-miow" ,rust-miow-0.3)
-        ("rust-nix" ,rust-nix-0.23)
+        ("rust-nix" ,rust-nix-0.22)
         ("rust-parking-lot" ,rust-parking-lot-0.11)
         ("rust-regex-automata" ,rust-regex-automata-0.1)
         ("rust-serde" ,rust-serde-1)
         ("rust-serde-yaml" ,rust-serde-yaml-0.8)
-        ("rust-signal-hook" ,rust-signal-hook-0.1)
+        ("rust-signal-hook" ,rust-signal-hook-0.3)
+        ("rust-signal-hook-mio" ,rust-signal-hook-mio-0.2)
         ("rust-unicode-width" ,rust-unicode-width-0.1)
         ("rust-vte" ,rust-vte-0.10)
         ("rust-winapi" ,rust-winapi-0.3))))
-- 
2.37.2

From 86f63a6a845e10c569fab3cdf102b1bc01c2f598 Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Sun, 24 Apr 2022 01:27:08 +0200
Subject: [PATCH v3 4/7] gnu: rust-structopt-0.3: Update to 0.3.26.

* gnu/packages/crates-io.scm (rust-structopt): Update to 0.3.26.
  [arguments]: Add rust-paw-1 to cargo-inputs. Add cargo development inputs.
  Add phases to fix rust-clap-2 version and remove lints feature.

diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 7a095701ba..9d2d5a86f9 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -61585,7 +61585,7 @@ (define-public rust-strsim-0.5
 (define-public rust-structopt-0.3
   (package
     (name "rust-structopt")
-    (version "0.3.21")
+    (version "0.3.26")
     (source
      (origin
        (method url-fetch)
@@ -61594,14 +61594,27 @@ (define-public rust-structopt-0.3
         (string-append name "-" version ".tar.gz"))
        (sha256
         (base32
-         "136j0lvjmpv5syi751vxg8vb30gfyv4k81x8d18kxrj6xvbsqxsj"))))
+         "043sg3qxllann6q9i71d05qp3q13scmcvhxhd950ka2v8ij5qsqc"))))
     (build-system cargo-build-system)
     (arguments
      `(#:skip-build? #t
        #:cargo-inputs
        (("rust-structopt-derive" ,rust-structopt-derive-0.4)
         ("rust-lazy-static" ,rust-lazy-static-1)
-        ("rust-clap" ,rust-clap-2))))
+        ("rust-paw" ,rust-paw-1)
+        ("rust-clap" ,rust-clap-2))
+       #:cargo-development-inputs
+       (("rust-strum" ,rust-strum-0.21)
+        ("rust-trybuild" ,rust-trybuild-1)
+        ("rust-rustversion" ,rust-rustversion-1))
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'fixup-cargo-toml
+           (lambda _
+             (substitute* "Cargo.toml"
+               ;; feature does not exist
+               (("lints.*") "")
+               (("2.33") ,(package-version rust-clap-2))))))))
     (home-page "https://github.com/TeXitoi/structopt")
     (synopsis "Parse command line argument by defining a struct")
     (description
-- 
2.37.2