diff mbox series

[bug#47006,WIP,v2,2/2] gnu: Add zig.

Message ID aa1961beb099e50fd87a41bcfd7f26010f8eaec6.1631226695.git.liliana.prikler@gmail.com
State Accepted
Headers show
Series None | expand

Commit Message

Liliana Marie Prikler Sept. 9, 2021, 1:32 p.m. UTC
* gnu/packages/patches/zig-use-explicit-paths.patch: New file.
* gnu/packages/zig.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES, dist_patch_DATA): Adjust accordingly.
---
I've added a patch to use explicit search paths rather than whatever Zig used
before and tried fixing some (syntactic) errors with the tests, but was
unsuccesful, as there appear to be failing tests in the suite itself.  Could
you have a look at the revised patch and check what flags you could add to
the check phase to make it meaningful?

Btw. I haven't checked whether my cosmetic changes to #:configure-flags break
things or not.  The end of the build phase puts a large amount of stress onto
my system that I'd like to avoid at this hour.

 gnu/local.mk                                  |   2 +
 .../patches/zig-use-explicit-paths.patch      | 132 ++++++++++++++++++
 gnu/packages/zig.scm                          | 100 +++++++++++++
 3 files changed, 234 insertions(+)
 create mode 100644 gnu/packages/patches/zig-use-explicit-paths.patch
 create mode 100644 gnu/packages/zig.scm

Comments

Sarah Morgensen Sept. 11, 2021, 9:52 a.m. UTC | #1
Hi Liliana,

September 9, 2021 6:32 AM, "Liliana Prikler" <liliana.prikler@gmail.com> wrote:

> I've added a patch to use explicit search paths rather than whatever Zig used
> before and tried fixing some (syntactic) errors with the tests, but was
> unsuccesful, as there appear to be failing tests in the suite itself. Could
> you have a look at the revised patch and check what flags you could add to
> the check phase to make it meaningful?

I'm

> Btw. I haven't checked whether my cosmetic changes to #:configure-flags break
> things or not. The end of the build phase puts a large amount of stress onto
> my system that I'd like to avoid at this hour.
> 
> gnu/local.mk | 2 +
> .../patches/zig-use-explicit-paths.patch | 132 ++++++++++++++++++
> gnu/packages/zig.scm | 100 +++++++++++++
> 3 files changed, 234 insertions(+)
> create mode 100644 gnu/packages/patches/zig-use-explicit-paths.patch
> create mode 100644 gnu/packages/zig.scm
> 
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 2a56c4a9e2..4503b4b2e2 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -598,6 +598,7 @@ GNU_SYSTEM_MODULES = \
> %D%/packages/xdisorg.scm \
> %D%/packages/xorg.scm \
> %D%/packages/xfce.scm \
> + %D%/packages/zig.scm \
> %D%/packages/zile.scm \
> %D%/packages/zwave.scm \
> \
> @@ -1903,6 +1904,7 @@ dist_patch_DATA = \
> %D%/packages/patches/ytfzf-updates.patch \
> %D%/packages/patches/ytnef-CVE-2021-3403.patch \
> %D%/packages/patches/ytnef-CVE-2021-3404.patch \
> + %D%/packages/patches/zig-use-explicit-paths.patch \
> %D%/packages/patches/zstd-CVE-2021-24031_CVE-2021-24032.patch \
> %D%/packages/patches/zziplib-CVE-2018-16548.patch
> 
> diff --git a/gnu/packages/patches/zig-use-explicit-paths.patch
> b/gnu/packages/patches/zig-use-explicit-paths.patch
> new file mode 100644
> index 0000000000..ab0d2c7f8b
> --- /dev/null
> +++ b/gnu/packages/patches/zig-use-explicit-paths.patch
> @@ -0,0 +1,132 @@
> +This patch replaces the OS-specific detection mechanism by one that solely
> +relies on environment variables. This has the benefit that said environment
> +variables can be used as search paths in Guix.
> +
> +Index: zig-0.8.1/lib/std/zig/system.zig
> +===================================================================
> +--- zig-0.8.1.orig/lib/std/zig/system.zig
> ++++ zig-0.8.1/lib/std/zig/system.zig
> +@@ -39,101 +39,44 @@ pub const NativePaths = struct {
> + };
> + errdefer self.deinit();
> +
> +- var is_nix = false;
> +- if (process.getEnvVarOwned(allocator, "NIX_CFLAGS_COMPILE")) |nix_cflags_compile| {
> +- defer allocator.free(nix_cflags_compile);
> +-
> +- is_nix = true;
> +- var it = mem.tokenize(nix_cflags_compile, " ");
> ++ // TODO: Support cross-compile paths?
> ++ if (process.getEnvVarOwned(allocator, "ZIG_INCLUDE_DIRS")) |zig_include_dirs| {
> ++ defer allocator.free(zig_include_dirs);
> ++ var it = mem.tokenize(zig_include_dirs, ":");
> + while (true) {
> +- const word = it.next() orelse break;
> +- if (mem.eql(u8, word, "-isystem")) {
> +- const include_path = it.next() orelse {
> +- try self.addWarning("Expected argument after -isystem in NIX_CFLAGS_COMPILE");
> +- break;
> +- };
> +- try self.addIncludeDir(include_path);
> +- } else {
> +- if (mem.startsWith(u8, word, "-frandom-seed=")) {
> +- continue;
> +- }
> +- try self.addWarningFmt("Unrecognized C flag from NIX_CFLAGS_COMPILE: {s}", .{word});
> +- }
> ++ const dir = it.next() orelse break;
> ++ try self.addIncludeDir(dir);
> + }
> + } else |err| switch (err) {
> + error.InvalidUtf8 => {},
> + error.EnvironmentVariableNotFound => {},
> + error.OutOfMemory => |e| return e,
> + }
> +- if (process.getEnvVarOwned(allocator, "NIX_LDFLAGS")) |nix_ldflags| {
> +- defer allocator.free(nix_ldflags);
> +
> +- is_nix = true;
> +- var it = mem.tokenize(nix_ldflags, " ");
> ++ if (process.getEnvVarOwned(allocator, "ZIG_LIB_DIRS")) |zig_lib_dirs| {
> ++ defer allocator.free(zig_lib_dirs);
> ++ var it = mem.tokenize(zig_lib_dirs, ":");
> + while (true) {
> +- const word = it.next() orelse break;
> +- if (mem.eql(u8, word, "-rpath")) {
> +- const rpath = it.next() orelse {
> +- try self.addWarning("Expected argument after -rpath in NIX_LDFLAGS");
> +- break;
> +- };
> +- try self.addRPath(rpath);
> +- } else if (word.len > 2 and word[0] == '-' and word[1] == 'L') {
> +- const lib_path = word[2..];
> +- try self.addLibDir(lib_path);
> +- } else {
> +- try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word});
> +- break;
> +- }
> ++ const dir = it.next() orelse break;
> ++ try self.addLibDir(dir);
> + }
> + } else |err| switch (err) {
> + error.InvalidUtf8 => {},
> + error.EnvironmentVariableNotFound => {},
> + error.OutOfMemory => |e| return e,
> + }
> +- if (is_nix) {
> +- return self;
> +- }
> +-
> +- if (comptime Target.current.isDarwin()) {
> +- try self.addIncludeDir("/usr/include");
> +- try self.addIncludeDir("/usr/local/include");
> +-
> +- try self.addLibDir("/usr/lib");
> +- try self.addLibDir("/usr/local/lib");
> +-
> +- try self.addFrameworkDir("/Library/Frameworks");
> +- try self.addFrameworkDir("/System/Library/Frameworks");
> +-
> +- return self;
> +- }
> +-
> +- if (native_target.os.tag != .windows) {
> +- const triple = try native_target.linuxTriple(allocator);
> +- const qual = native_target.cpu.arch.ptrBitWidth();
> +-
> +- // TODO: $ ld --verbose | grep SEARCH_DIR
> +- // the output contains some paths that end with lib64, maybe include them too?
> +- // TODO: what is the best possible order of things?
> +- // TODO: some of these are suspect and should only be added on some systems. audit needed.
> +
> +- try self.addIncludeDir("/usr/local/include");
> +- try self.addLibDirFmt("/usr/local/lib{d}", .{qual});
> +- try self.addLibDir("/usr/local/lib");
> +-
> +- try self.addIncludeDirFmt("/usr/include/{s}", .{triple});
> +- try self.addLibDirFmt("/usr/lib/{s}", .{triple});
> +-
> +- try self.addIncludeDir("/usr/include");
> +- try self.addLibDirFmt("/lib{d}", .{qual});
> +- try self.addLibDir("/lib");
> +- try self.addLibDirFmt("/usr/lib{d}", .{qual});
> +- try self.addLibDir("/usr/lib");
> +-
> +- // example: on a 64-bit debian-based linux distro, with zlib installed from apt:
> +- // zlib.h is in /usr/include (added above)
> +- // libz.so.1 is in /lib/x86_64-linux-gnu (added here)
> +- try self.addLibDirFmt("/lib/{s}", .{triple});
> ++ if (process.getEnvVarOwned(allocator, "ZIG_FRAMEWORK_DIRS")) |zig_framework_dirs| {
> ++ defer allocator.free(zig_framework_dirs);
> ++ var it = mem.tokenize(zig_framework_dirs, ":");
> ++ while (true) {
> ++ const dir = it.next() orelse break;
> ++ try self.addFrameworkDir(dir);
> ++ }
> ++ } else |err| switch (err) {
> ++ error.InvalidUtf8 => {},
> ++ error.EnvironmentVariableNotFound => {},
> ++ error.OutOfMemory => |e| return e,
> + }
> +
> + return self;
> diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
> new file mode 100644
> index 0000000000..aae095b747
> --- /dev/null
> +++ b/gnu/packages/zig.scm
> @@ -0,0 +1,100 @@
> +;;; GNU Guix --- Functional package management for GNU
> +;;; Copyright © 2021 Liliana Prikler <liliana.prikler@gmail.com>
> +;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
> +;;;
> +;;; This file is part of GNU Guix.
> +;;;
> +;;; GNU Guix is free software; you can redistribute it and/or modify it
> +;;; under the terms of the GNU General Public License as published by
> +;;; the Free Software Foundation; either version 3 of the License, or (at
> +;;; your option) any later version.
> +;;;
> +;;; GNU Guix is distributed in the hope that it will be useful, but
> +;;; WITHOUT ANY WARRANTY; without even the implied warranty of
> +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +;;; GNU General Public License for more details.
> +;;;
> +;;; You should have received a copy of the GNU General Public License
> +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses>.
> +
> +(define-module (gnu packages zig)
> + #:use-module (guix packages)
> + #:use-module (guix git-download)
> + #:use-module ((guix licenses) #:prefix license:)
> + #:use-module (guix build-system cmake)
> + #:use-module (gnu packages)
> + #:use-module (gnu packages llvm))
> +
> +(define-public zig
> + (package
> + (name "zig")
> + (version "0.8.1")
> + (source
> + (origin
> + (method git-fetch)
> + (uri (git-reference
> + (url "https://github.com/ziglang/zig.git")
> + (commit version)))
> + (file-name (git-file-name name version))
> + (sha256
> + (base32 "147qx7xgj0r353wh5ragzn6kmm1vrf31i8038z3zqwjnqqgqxi6c"))
> + (patches
> + (search-patches
> + "zig-use-explicit-paths.patch"))))
> + (build-system cmake-build-system)
> + ;; Zig uses Clang and LLVM libraries, and (may) use LLVM to compile along
> + ;; with GCC.
> + (inputs
> + `(("clang" ,clang-12)
> + ("lld" ,lld-12)
> + ("llvm" ,llvm-12)))
> + (native-inputs
> + `(("llvm" ,llvm-12)))
> + (arguments
> + `(#:configure-flags
> + (list ,@(if (%current-target-system)
> + (string-append "-DZIG_TARGET_TRIPLE="
> + (%current-target-system))
> + '()))
> + #:tests? #f ;;; XXX: tests result in a FileNotFound
> + #:phases
> + (modify-phases %standard-phases
> + (add-after 'unpack 'save-unpack-dir
> + (lambda _
> + ;; HACK: Passing unpacked source directory to 'check phase.
> + (setenv "ZIG_SOURCE_DIR" (getcwd))
> + #t))
> + (add-after 'configure 'set-home
> + (lambda _
> + (setenv "HOME" (getcwd)) ; zig writes to $HOME/.cache
> + #t))
> + (delete 'check)
> + (add-after 'install 'check
> + (lambda* (#:key outputs tests? #:allow-other-keys)
> + (when tests?
> + (with-directory-excursion (getenv "ZIG_SOURCE_DIR")
> + (invoke (string-append (assoc-ref outputs "out") "/bin/zig")
> + "build" "test"))))))))
> + (native-search-paths
> + (list
> + (search-path-specification
> + (variable "ZIG_INCLUDE_DIRS")
> + ;; XXX: It doesn't seem as though Zig can distinguish between C and C++
> + ;; include paths, so provide both.
> + (files '("include/c++" "include")))
> + (search-path-specification
> + (variable "ZIG_LIB_DIRS")
> + (files '("lib" "lib64")))))
> + (synopsis "General purpose programming language and toolchain")
> + (description "Zig is a general-purpose programming language and
> +toolchain. Among other features it provides
> +@itemize
> +@item an Optional type instead of null pointers,
> +@item manual memory management,
> +@item generic data structures and functions,
> +@item compile-time reflection and compile-time code execution,
> +@item integration with C using zig as a C compiler, and
> +@item concurrency via async functions.
> +@end itemize")
> + (home-page "https://github.com/ziglang/zig")
> + (license license:expat)))
> --
> 2.33.0
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 2a56c4a9e2..4503b4b2e2 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -598,6 +598,7 @@  GNU_SYSTEM_MODULES =				\
   %D%/packages/xdisorg.scm			\
   %D%/packages/xorg.scm				\
   %D%/packages/xfce.scm				\
+  %D%/packages/zig.scm				\
   %D%/packages/zile.scm				\
   %D%/packages/zwave.scm			\
 						\
@@ -1903,6 +1904,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/ytfzf-updates.patch        \
   %D%/packages/patches/ytnef-CVE-2021-3403.patch	\
   %D%/packages/patches/ytnef-CVE-2021-3404.patch	\
+  %D%/packages/patches/zig-use-explicit-paths.patch	\
   %D%/packages/patches/zstd-CVE-2021-24031_CVE-2021-24032.patch	\
   %D%/packages/patches/zziplib-CVE-2018-16548.patch
 
diff --git a/gnu/packages/patches/zig-use-explicit-paths.patch b/gnu/packages/patches/zig-use-explicit-paths.patch
new file mode 100644
index 0000000000..ab0d2c7f8b
--- /dev/null
+++ b/gnu/packages/patches/zig-use-explicit-paths.patch
@@ -0,0 +1,132 @@ 
+This patch replaces the OS-specific detection mechanism by one that solely
+relies on environment variables.  This has the benefit that said environment
+variables can be used as search paths in Guix.
+
+Index: zig-0.8.1/lib/std/zig/system.zig
+===================================================================
+--- zig-0.8.1.orig/lib/std/zig/system.zig
++++ zig-0.8.1/lib/std/zig/system.zig
+@@ -39,101 +39,44 @@ pub const NativePaths = struct {
+         };
+         errdefer self.deinit();
+ 
+-        var is_nix = false;
+-        if (process.getEnvVarOwned(allocator, "NIX_CFLAGS_COMPILE")) |nix_cflags_compile| {
+-            defer allocator.free(nix_cflags_compile);
+-
+-            is_nix = true;
+-            var it = mem.tokenize(nix_cflags_compile, " ");
++        // TODO: Support cross-compile paths?
++        if (process.getEnvVarOwned(allocator, "ZIG_INCLUDE_DIRS")) |zig_include_dirs| {
++            defer allocator.free(zig_include_dirs);
++            var it = mem.tokenize(zig_include_dirs, ":");
+             while (true) {
+-                const word = it.next() orelse break;
+-                if (mem.eql(u8, word, "-isystem")) {
+-                    const include_path = it.next() orelse {
+-                        try self.addWarning("Expected argument after -isystem in NIX_CFLAGS_COMPILE");
+-                        break;
+-                    };
+-                    try self.addIncludeDir(include_path);
+-                } else {
+-                    if (mem.startsWith(u8, word, "-frandom-seed=")) {
+-                        continue;
+-                    }
+-                    try self.addWarningFmt("Unrecognized C flag from NIX_CFLAGS_COMPILE: {s}", .{word});
+-                }
++                const dir = it.next() orelse break;
++                try self.addIncludeDir(dir);
+             }
+         } else |err| switch (err) {
+             error.InvalidUtf8 => {},
+             error.EnvironmentVariableNotFound => {},
+             error.OutOfMemory => |e| return e,
+         }
+-        if (process.getEnvVarOwned(allocator, "NIX_LDFLAGS")) |nix_ldflags| {
+-            defer allocator.free(nix_ldflags);
+ 
+-            is_nix = true;
+-            var it = mem.tokenize(nix_ldflags, " ");
++        if (process.getEnvVarOwned(allocator, "ZIG_LIB_DIRS")) |zig_lib_dirs| {
++            defer allocator.free(zig_lib_dirs);
++            var it = mem.tokenize(zig_lib_dirs, ":");
+             while (true) {
+-                const word = it.next() orelse break;
+-                if (mem.eql(u8, word, "-rpath")) {
+-                    const rpath = it.next() orelse {
+-                        try self.addWarning("Expected argument after -rpath in NIX_LDFLAGS");
+-                        break;
+-                    };
+-                    try self.addRPath(rpath);
+-                } else if (word.len > 2 and word[0] == '-' and word[1] == 'L') {
+-                    const lib_path = word[2..];
+-                    try self.addLibDir(lib_path);
+-                } else {
+-                    try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word});
+-                    break;
+-                }
++                const dir = it.next() orelse break;
++                try self.addLibDir(dir);
+             }
+         } else |err| switch (err) {
+             error.InvalidUtf8 => {},
+             error.EnvironmentVariableNotFound => {},
+             error.OutOfMemory => |e| return e,
+         }
+-        if (is_nix) {
+-            return self;
+-        }
+-
+-        if (comptime Target.current.isDarwin()) {
+-            try self.addIncludeDir("/usr/include");
+-            try self.addIncludeDir("/usr/local/include");
+-
+-            try self.addLibDir("/usr/lib");
+-            try self.addLibDir("/usr/local/lib");
+-
+-            try self.addFrameworkDir("/Library/Frameworks");
+-            try self.addFrameworkDir("/System/Library/Frameworks");
+-
+-            return self;
+-        }
+-
+-        if (native_target.os.tag != .windows) {
+-            const triple = try native_target.linuxTriple(allocator);
+-            const qual = native_target.cpu.arch.ptrBitWidth();
+-
+-            // TODO: $ ld --verbose | grep SEARCH_DIR
+-            // the output contains some paths that end with lib64, maybe include them too?
+-            // TODO: what is the best possible order of things?
+-            // TODO: some of these are suspect and should only be added on some systems. audit needed.
+ 
+-            try self.addIncludeDir("/usr/local/include");
+-            try self.addLibDirFmt("/usr/local/lib{d}", .{qual});
+-            try self.addLibDir("/usr/local/lib");
+-
+-            try self.addIncludeDirFmt("/usr/include/{s}", .{triple});
+-            try self.addLibDirFmt("/usr/lib/{s}", .{triple});
+-
+-            try self.addIncludeDir("/usr/include");
+-            try self.addLibDirFmt("/lib{d}", .{qual});
+-            try self.addLibDir("/lib");
+-            try self.addLibDirFmt("/usr/lib{d}", .{qual});
+-            try self.addLibDir("/usr/lib");
+-
+-            // example: on a 64-bit debian-based linux distro, with zlib installed from apt:
+-            // zlib.h is in /usr/include (added above)
+-            // libz.so.1 is in /lib/x86_64-linux-gnu (added here)
+-            try self.addLibDirFmt("/lib/{s}", .{triple});
++        if (process.getEnvVarOwned(allocator, "ZIG_FRAMEWORK_DIRS")) |zig_framework_dirs| {
++            defer allocator.free(zig_framework_dirs);
++            var it = mem.tokenize(zig_framework_dirs, ":");
++            while (true) {
++                const dir = it.next() orelse break;
++                try self.addFrameworkDir(dir);
++            }
++        } else |err| switch (err) {
++            error.InvalidUtf8 => {},
++            error.EnvironmentVariableNotFound => {},
++            error.OutOfMemory => |e| return e,
+         }
+ 
+         return self;
diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
new file mode 100644
index 0000000000..aae095b747
--- /dev/null
+++ b/gnu/packages/zig.scm
@@ -0,0 +1,100 @@ 
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Liliana Prikler <liliana.prikler@gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages zig)
+  #:use-module (guix packages)
+  #:use-module (guix git-download)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix build-system cmake)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages llvm))
+
+(define-public zig
+  (package
+    (name "zig")
+    (version "0.8.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ziglang/zig.git")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "147qx7xgj0r353wh5ragzn6kmm1vrf31i8038z3zqwjnqqgqxi6c"))
+       (patches
+        (search-patches
+         "zig-use-explicit-paths.patch"))))
+    (build-system cmake-build-system)
+    ;; Zig uses Clang and LLVM libraries, and (may) use LLVM to compile along
+    ;; with GCC.
+    (inputs
+     `(("clang" ,clang-12)
+       ("lld" ,lld-12)
+       ("llvm" ,llvm-12)))
+    (native-inputs
+     `(("llvm" ,llvm-12)))
+    (arguments
+     `(#:configure-flags
+       (list ,@(if (%current-target-system)
+                   (string-append "-DZIG_TARGET_TRIPLE="
+                                  (%current-target-system))
+                   '()))
+       #:tests? #f ;;; XXX: tests result in a FileNotFound
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'save-unpack-dir
+           (lambda _
+             ;; HACK: Passing unpacked source directory to 'check phase.
+             (setenv "ZIG_SOURCE_DIR" (getcwd))
+             #t))
+         (add-after 'configure 'set-home
+           (lambda _
+             (setenv "HOME" (getcwd))    ; zig writes to $HOME/.cache
+             #t))
+         (delete 'check)
+         (add-after 'install 'check
+           (lambda* (#:key outputs tests? #:allow-other-keys)
+             (when tests?
+               (with-directory-excursion (getenv "ZIG_SOURCE_DIR")
+                 (invoke (string-append (assoc-ref outputs "out") "/bin/zig")
+                         "build" "test"))))))))
+    (native-search-paths
+     (list
+      (search-path-specification
+       (variable "ZIG_INCLUDE_DIRS")
+       ;; XXX: It doesn't seem as though Zig can distinguish between C and C++
+       ;;      include paths, so provide both.
+       (files '("include/c++" "include")))
+      (search-path-specification
+       (variable "ZIG_LIB_DIRS")
+       (files '("lib" "lib64")))))
+    (synopsis "General purpose programming language and toolchain")
+    (description "Zig is a general-purpose programming language and
+toolchain.  Among other features it provides
+@itemize
+@item an Optional type instead of null pointers,
+@item manual memory management,
+@item generic data structures and functions,
+@item compile-time reflection and compile-time code execution,
+@item integration with C using zig as a C compiler, and
+@item concurrency via async functions.
+@end itemize")
+    (home-page "https://github.com/ziglang/zig")
+    (license license:expat)))