Skip to content

Commit

Permalink
update zig to 0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dermetfan committed May 8, 2024
1 parent 170864f commit 8f25396
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 55 deletions.
10 changes: 5 additions & 5 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ pub fn build(b: *Build) !void {
};

const lib_mod = b.addModule("lib", .{
.root_source_file = Build.LazyPath.relative("src/lib.zig"),
.root_source_file = b.path("src/lib.zig"),
.target = opts.target,
.optimize = opts.optimize,
});
configureModule(b, lib_mod, false, opts);

const cizero_mod = b.addModule("cizero", .{
.root_source_file = Build.LazyPath.relative("src/Cizero.zig"),
.root_source_file = b.path("src/Cizero.zig"),
.target = opts.target,
.optimize = opts.optimize,
});
Expand All @@ -26,7 +26,7 @@ pub fn build(b: *Build) !void {

const cizero_exe = b.addExecutable(.{
.name = "cizero",
.root_source_file = Build.LazyPath.relative("src/main.zig"),
.root_source_file = b.path("src/main.zig"),
.target = opts.target,
.optimize = opts.optimize,
});
Expand All @@ -37,7 +37,7 @@ pub fn build(b: *Build) !void {
{
const nix_build_hook_exe = b.addExecutable(.{
.name = "build-hook",
.root_source_file = Build.LazyPath.relative("src/components/nix/build-hook/main.zig"),
.root_source_file = b.path("src/components/nix/build-hook/main.zig"),
.target = opts.target,
.optimize = opts.optimize,
});
Expand Down Expand Up @@ -102,7 +102,7 @@ pub fn build(b: *Build) !void {

const pdk_test = b.addTest(.{
.name = "PDK",
.root_source_file = Build.LazyPath.relative("src/plugin/pdk-test.zig"),
.root_source_file = b.path("src/plugin/pdk-test.zig"),
.target = opts.target,
.optimize = opts.optimize,
});
Expand Down
12 changes: 6 additions & 6 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
.hash = "122038b4b5df08d2af6daf81e5f18d4c244d807c9323224db826cc107ce3894f6fa9",
},
.httpz = .{
.url = "https://github.com/karlseguin/http.zig/archive/6e15856ec41befddd9906052fd44d7ec7607693b.tar.gz",
.hash = "122006341428528cd9def40a3009f4650d312832f12249ecfe2b6c89f451090a641d",
.url = "https://github.com/karlseguin/http.zig/archive/0d4a5cd520a54eaf800438e0b9093c77c90dcf11.tar.gz",
.hash = "12209b8216a80f21be12d43e588811150bdbbb53d35eac6a2a61c460f197350e19ad",
},
.@"known-folders" = .{
.url = "https://github.com/ziglibs/known-folders/archive/055c95a717c5b54a0fc52ff5f370439c28eb2e73.tar.gz",
.hash = "12204a8a7e9184a77f70795b1fc8a9f94dff5cce208c20c5c6452967dddc498e0b64",
.url = "https://github.com/ziglibs/known-folders/archive/bf79988adcfce166f848e4b11e718c1966365329.tar.gz",
.hash = "12201314cffeb40c5e4e3da166217d2c74628c74486414aaf97422bcd2279915b9fd",
},
.trait = .{
.url = "https://github.com/wrongnull/zigtrait/archive/327d916b522676e6440df7f831d049001fa24dfd.tar.gz",
.hash = "12209e2e8b61415ca4e12d08cf6e7e0fe514ac83a2659f497c033be19c331cef408d",
},
.zqlite = .{
.url = "https://github.com/karlseguin/zqlite.zig/archive/5f0379ea624bf8f67e9a91474f780a35db8695d5.tar.gz",
.hash = "1220a173f2ca69317180fb421725f43d86b71cbdd51a9a4aab96d9ee71850ec1cd44",
.url = "https://github.com/karlseguin/zqlite.zig/archive/2415644448f878fc6c79a2c2e40498616361ef5c.tar.gz",
.hash = "12206659ecd84862173c7ea89f32904f2416dabe4aaf84a9d12f34eb266c5e2a7797",
},
},
.paths = .{
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nix/checks/cizero-pdk-zig.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

buildZigZon = "pdk/zig/build.zig.zon";

zigDepsHash = "sha256-I7ImYz7MMk8nLHW+ONWc+mOr8WsX3ui7uV1JjS+j1rQ=";
zigDepsHash = "sha256-OJvViRJjsMMscjXcs0v0EqD/ad3WaGoOGBfy/+2rFTw=";

nativeCheckInputs = with pkgs; [
wasmtime
Expand Down
2 changes: 1 addition & 1 deletion nix/packages/cizero/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
whereami
];

zigDepsHash = "sha256-evn5NMPQAOnDIC/1ASLhXOe35qRNlqVKJ2kiCu3QZgg=";
zigDepsHash = "sha256-wsCEw5wvFeLfAnLD4+wiebwR7t5VsWO06O+o4Ef5RYs=";

preCheck = ''
# for wasmtime cache
Expand Down
2 changes: 1 addition & 1 deletion nix/packages/cizero/plugins/hello-zig.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

buildZigZon = "plugins/hello-zig/build.zig.zon";

zigDepsHash = "sha256-I7ImYz7MMk8nLHW+ONWc+mOr8WsX3ui7uV1JjS+j1rQ=";
zigDepsHash = "sha256-OJvViRJjsMMscjXcs0v0EqD/ad3WaGoOGBfy/+2rFTw=";

nativeCheckInputs = with pkgs; [
wasmtime
Expand Down
2 changes: 1 addition & 1 deletion nix/packages/cizero/plugins/hydra-eval-jobs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

buildZigZon = "plugins/hydra-eval-jobs/build.zig.zon";

zigDepsHash = "sha256-I7ImYz7MMk8nLHW+ONWc+mOr8WsX3ui7uV1JjS+j1rQ=";
zigDepsHash = "sha256-OJvViRJjsMMscjXcs0v0EqD/ad3WaGoOGBfy/+2rFTw=";

nativeCheckInputs = with pkgs; [
wasmtime
Expand Down
23 changes: 4 additions & 19 deletions nix/packages/zig/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
version = src.rev;

src = oldAttrs.src.override {
rev = "31a7f22b800c091962726de2dd29f10a8eb25b78";
hash = "sha256-zVD+1MYrp5kgib7O0xygMPv6cOAdBK7ggTYojbZoOao=";
rev = "0.12.0";
hash = "sha256-RNZiUZtaKXoab5kFrDij6YCAospeVvlLWheTc3FGMks=";
};

postPatch = ''
Expand All @@ -28,26 +28,11 @@
src = pkgs.fetchFromGitHub {
owner = "zigtools";
repo = "zls";
rev = "96eddd067615efd9a88fa596dfa4c75943302885";
hash = "sha256-mXdiiWofQEzOP4o8ZrS9NtZ3gzwxLkr/4dLOGYBrlTQ=";
rev = config.packages.zig.version;
hash = "sha256-2iVDPUj9ExgTooDQmCCtZs3wxBe2be9xjzAk9HedPNY=";
fetchSubmodules = true;
};

patches = [
# The issue linked in the diff has been fixed so we can remove the check until upstream catches up.
# We need to do this to allow compilation with nightly zig.
(builtins.toFile "19071.diff" ''
diff --git a/src/config_gen/config_gen.zig b/src/config_gen/config_gen.zig
index 95ad1d7..6e41cca 100644
--- a/src/config_gen/config_gen.zig
+++ b/src/config_gen/config_gen.zig
@@ -943,3 +942,0 @@ fn httpGET(allocator: std.mem.Allocator, uri: std.Uri) !Response {
- // TODO remove duplicate logic once https://github.com/ziglang/zig/issues/19071 has been fixed
- comptime std.debug.assert(zig_builtin.zig_version.order(.{ .major = 0, .minor = 12, .patch = 0 }) == .lt);
-
'')
];

zigDepsHash = "sha256-qhC7BvIVJMOEBdbJ9NaK+Xngjs+PfopwZimuPc58xhU=";

zigBuildFlags = [
Expand Down
2 changes: 1 addition & 1 deletion pdk/zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn build(b: *std.Build) !void {
.optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseSmall }),
};

const module = b.addModule("cizero-pdk", .{ .root_source_file = std.Build.LazyPath.relative("main.zig") });
const module = b.addModule("cizero-pdk", .{ .root_source_file = b.path("main.zig") });
configureModule(b, module, opts);

const test_step = b.step("test", "Run unit tests");
Expand Down
2 changes: 1 addition & 1 deletion plugins/hello-zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn build(b: *Build) !void {
.optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseSmall }),
};

const source = Build.LazyPath.relative("main.zig");
const source = b.path("main.zig");

{
const exe = b.addExecutable(.{
Expand Down
2 changes: 1 addition & 1 deletion plugins/hydra-eval-jobs/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn build(b: *Build) !void {
.optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseSmall }),
};

const source = Build.LazyPath.relative("main.zig");
const source = b.path("main.zig");

{
const exe = b.addExecutable(.{
Expand Down
2 changes: 1 addition & 1 deletion plugins/hydra-eval-jobs/hydra-eval-jobs/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn build(b: *std.Build) void {

const exe = b.addExecutable(.{
.name = "hydra-eval-jobs",
.root_source_file = .{ .path = "main.zig" },
.root_source_file = b.path("main.zig"),
.target = opts.target,
.optimize = opts.optimize,
});
Expand Down
4 changes: 2 additions & 2 deletions plugins/hydra-eval-jobs/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn onWebhook(
const flake_z = try allocator.dupeZ(u8, flake);
defer allocator.free(flake_z);

if (cizero.nix.evalState(flake_z, nix.hydraEvalJobs, .json) == null) try cizero.nix.onEval(
if (cizero.nix.evalState(flake_z, &nix.hydraEvalJobs, .json) == null) try cizero.nix.onEval(
cizero.user_data.Shallow([]const u8),
allocator,
struct {
Expand All @@ -74,7 +74,7 @@ fn onWebhook(
}.callback,
file_name,
flake_z,
nix.hydraEvalJobs,
&nix.hydraEvalJobs,
.json,
);

Expand Down
27 changes: 16 additions & 11 deletions src/lib/nix.zig
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ pub const hydraEvalJobs = expr: {
const allocator = fba.allocator();

var expr = libLeaf(allocator, "hydra-eval-jobs", &.{}) catch |err| @compileError(@errorName(err));
break :expr expr.toOwnedSliceSentinel(allocator, 0) catch |err| @compileError(@errorName(err));
defer expr.deinit(allocator);

var expr_buf: [expr.items.len:0]u8 = undefined;
@memcpy(&expr_buf, expr.items);

break :expr expr_buf;
};

/// Returns a new expression that evaluates to a list of derivations
Expand Down Expand Up @@ -202,7 +207,7 @@ pub const FlakeMetadata = struct {

const url = if (self.url) |url| try std.Uri.parse(url) else null;

var result = if (url) |u| u else std.Uri{ .scheme = "", .path = "" };
var result = if (url) |u| u else std.Uri{ .scheme = "" };

result.scheme = switch (self.type) {
.indirect => "flake",
Expand All @@ -219,10 +224,10 @@ pub const FlakeMetadata = struct {
if (self.ref) |ref| try parts.append(alloc, ref);
if (self.rev) |rev| try parts.append(alloc, rev);

break :path try std.mem.join(alloc, "/", parts.items);
break :path .{ .percent_encoded = try std.mem.join(alloc, "/", parts.items) };
},
.path, .tarball, .file => self.path.?,
.github, .gitlab, .sourcehut => try std.mem.join(
.path, .tarball, .file => .{ .percent_encoded = self.path.? },
.github, .gitlab, .sourcehut => .{ .percent_encoded = try std.mem.join(
alloc,
"/",
if (self.ref) |ref|
Expand All @@ -231,7 +236,7 @@ pub const FlakeMetadata = struct {
&.{ self.owner.?, self.repo.?, rev }
else
&.{ self.owner.?, self.repo.? },
),
) },
.git, .mercurial => url.?.path,
};
result.query = query: {
Expand All @@ -255,7 +260,7 @@ pub const FlakeMetadata = struct {
errdefer query.deinit(alloc);

if (url) |u| if (u.query) |url_query| {
try query.appendSlice(alloc, url_query);
try url_query.format("raw", .{}, query.writer(alloc));
try query.append(alloc, '&');
};

Expand All @@ -274,7 +279,7 @@ pub const FlakeMetadata = struct {
}
}

break :query try query.toOwnedSlice(alloc);
break :query .{ .percent_encoded = try query.toOwnedSlice(alloc) };
};

return result;
Expand Down Expand Up @@ -388,8 +393,8 @@ pub const FlakeMetadata = struct {
if (switch (self.type) {
.github => std.Uri{
.scheme = "https",
.host = self.host orelse "github.com",
.path = try std.mem.concat(arena_allocator, u8, &.{
.host = .{ .percent_encoded = self.host orelse "github.com" },
.path = .{ .percent_encoded = try std.mem.concat(arena_allocator, u8, &.{
"/",
self.owner.?,
"/",
Expand All @@ -399,7 +404,7 @@ pub const FlakeMetadata = struct {
"/",
self.ref orelse self.rev.?,
".tar.gz",
}),
}) },
},
// TODO gitlab
// TODO sourcehut
Expand Down
2 changes: 1 addition & 1 deletion src/sql.zig
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ fn columnList(comptime table: ?[]const u8, comptime columns: anytype) []const u8
select.* = "\"" ++ column_name ++ "\"";
if (table) |t| select.* = "\"" ++ t ++ "\"." ++ select.*;
}
return comptimeJoin(&selects, ", ");
return comptime comptimeJoin(&selects, ", ");
}

test columnList {
Expand Down

0 comments on commit 8f25396

Please sign in to comment.