Closed Arya-Elfren closed 4 months ago
I think it's a problem that vaxis is referencing a main branch for gapbuffer which will break if any commits are pushed to there. But I think zon2json-lock should still handle this case.
https://github.com/Cloudef/zig2nix/commit/77a253890d18a19f9d64ab1c330bdbc6eb5e4577 Should fix this. I also pinged @rockorager about the gapbuffer dep.
Fixed in libvaxis here
zon2json-lock now works on these repos, but building them doesn't as they still reference older commits than the fix above. I assume this just requires waiting for them to update the dependencies?
@Arya-Elfren can you share your work somewhere so I can check it out?
hm, it seems like it's working when I try to reproduce it separately from my nixos config? (other than the zig compile error...) Anyway, I think it's fixed, thanks!
I could check it still in case if you want
I wrote the below process whilst researching it, but I think the problem is just that zig master had a breaking build.zig
change recently merged. Now just to find which commit so I can pin to the zig before that...
Which made me run nix run github:Cloudef/zig2nix/master#versions
which errors with:
master
default
jq: error (at /nix/store/5rj4q356xpyrj5i41nmv4frjayy7r32g-versions.json:865): Invalid numeric literal at EOF at line 1, column 3 (while parsing 'git')
uh, ok yeah, both zfe and flow have the same compiler error which is suspicious.
This process worked for hevi but fails with the same compiler error for flow and zfe. I would naively guess that you're not making zig verify the download hash compared to the .zon hash?
/tmp/zconv > git clone git@github.com:BrookJeynes/zfe.git
Cloning into 'zfe'...
remote: Enumerating objects: 274, done.
remote: Counting objects: 100% (13/13), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 274 (delta 3), reused 6 (delta 3), pack-reused 261
Receiving objects: 100% (274/274), 65.04 KiB | 600.00 KiB/s, done.
Resolving deltas: 100% (173/173), done.
/tmp/zconv > cd zfe
/tmp/zconv/zfe main > nix run github:Cloudef/zig2nix/master#zon2json-lock
fetching (nix hash): git+https://github.com/rockorager/libvaxis#75ac36ca61999c2f29467e02016322551e98bbd7
fetching (nix hash): git+https://github.com/zigimg/zigimg#3a667bdb3d7f0955a5a51c8468eac83210c1439e
fetching (nix hash): git+https://github.com/ryleelyman/GapBuffer.zig#main
fetching (nix hash): git+https://github.com/jinzhongjia/znvim#515fb2784f7b0db2ea7a0021aada8d4aa89a08fe
fetching (nix hash): https://github.com/zigcc/zig-msgpack/archive/refs/tags/0.0.5.tar.gz
fetching (nix hash): git+https://codeberg.org/dude_the_builder/zg#6d2ba3ff8f3cb7c86cef2b2176fb5b4a72c104dc
fetching (nix hash): git+https://github.com/mitchellh/libxev#f6a672a78436d8efee1aa847a43a900ad773618b
fetching (nix hash): git+https://github.com/fjebaker/fuzzig#0fd156d5097365151e85a85eef9d8cf0eebe7b00
fetching (nix hash): git+https://github.com/KeithBrown39423/zuid#49e5980ba83f7d9ae967fa7ce4d54384c1c0f82b
/tmp/zconv/zfe main ?1 > kak flake.nix
/tmp/zconv/zfe main ?2 > git add .
/tmp/zconv/zfe main +2 > nix run .#zfe 14:50:39
warning: Git tree '/tmp/zconv/zfe' is dirty
warning: creating lock file '/tmp/zconv/zfe/flake.lock'
warning: Git tree '/tmp/zconv/zfe' is dirty
error: builder for '/nix/store/g75bapq4gkghmi1lybqc7bf65p7j12vi-zfe-0.4.0.drv' failed with exit code 2;
last 10 log lines:
> /nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Progress.zig:80:18: note: struct declared here
> /build/tmp.EAMLdgyT6J/p/12207b7a5b538ffb7fb18f954ae17d2f8490b6e3778a9e30564ad82c58ee8da52361/src/build/ScdocStep.zig:123:25: error: expected type '*const fn (*Build.Step, Build.Step.MakeOptions) anyerror!void', found '*const fn (*Build.Step, Progress.Node) @typeInfo(@typeInfo(@TypeOf(src.build.ScdocStep.InstallStep.make)).Fn.return_type.?).ErrorUnion.error_set!void'
> /build/tmp.EAMLdgyT6J/p/12207b7a5b538ffb7fb18f954ae17d2f8490b6e3778a9e30564ad82c58ee8da52361/src/build/ScdocStep.zig:123:25: note: pointer type child 'fn (*Build.Step, Progress.Node) @typeInfo(@typeInfo(@TypeOf(src.build.ScdocStep.InstallStep.make)).Fn.return_type.?).ErrorUnion.error_set!void' cannot cast into pointer type child 'fn (*Build.Step, Build.Step.MakeOptions) anyerror!void'
> /build/tmp.EAMLdgyT6J/p/12207b7a5b538ffb7fb18f954ae17d2f8490b6e3778a9e30564ad82c58ee8da52361/src/build/ScdocStep.zig:123:25: note: parameter 1 'Progress.Node' cannot cast into 'Build.Step.MakeOptions'
> /nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Build/Step.zig:71:25: note: struct declared here
> /nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Progress.zig:80:18: note: struct declared here
> /build/tmp.EAMLdgyT6J/p/12207b7a5b538ffb7fb18f954ae17d2f8490b6e3778a9e30564ad82c58ee8da52361/src/build/ScdocStep.zig:160:36: error: expected type 'Build.Step.MakeOptions', found 'Progress.Node'
> /nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Progress.zig:80:18: note: struct declared here
> /nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Build/Step.zig:71:25: note: struct declared here
> /nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Build/Step.zig:228:32: note: parameter type declared here
For full logs, run 'nix log /nix/store/g75bapq4gkghmi1lybqc7bf65p7j12vi-zfe-0.4.0.drv'.
/tmp/zconv/zfe main +2 !1 >
In the kak flake.nix
I just paste in the following flake:
{
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOs/nixpkgs/nixos-unstable-small";
zfe.flake = false;
zfe.url = "github:BrookJeynes/zfe";
zig2nix.inputs.nixpkgs.follows = "nixpkgs";
zig2nix.url = "github:Cloudef/zig2nix";
};
outputs = { self, ... }@inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } rec {
systems = inputs.nixpkgs.lib.systems.flakeExposed;
perSystem = { pkgs, config, system, ... }: {
packages = let
zenv = inputs.zig2nix.outputs.zig-env.${system} {
zig = inputs.zig2nix.outputs.packages.${system}.zig.master.bin;
};
build-zig = src: lock:
(pkgs.lib.genAttrs zenv.lib.allTargetTriples (target: zenv.packageForTarget target ({
src = src; zigBuildZonLock = lock;
}))).${zenv.lib.zigTripleFromString system};
in {
zfe = build-zig (pkgs.lib.cleanSource inputs.zfe) ./build.zig.zon2json-lock;
};
};
};
}
The full logs from the build phase of nix log /nix/store/g75bapq4gkghmi1lybqc7bf65p7j12vi-zfe-0.4.0.drv
are:
Running phase: buildPhase
zig build flags: -Doptimize=ReleaseSafe -Dtarget=x86_64-linux-gnu
warning: Encountered error: FileNotFound, falling back to default ABI and dynamic linker.
/build/tmp.EAMLdgyT6J/p/12207b7a5b538ffb7fb18f954ae17d2f8490b6e3778a9e30564ad82c58ee8da52361/src/build/ScdocStep.zig:40:14: error: expected type '*const fn (*Build.Step, Build.Step.MakeOptions) anyerror!void', found '*const >
/build/tmp.EAMLdgyT6J/p/12207b7a5b538ffb7fb18f954ae17d2f8490b6e3778a9e30564ad82c58ee8da52361/src/build/ScdocStep.zig:40:14: note: pointer type child 'fn (*Build.Step, Progress.Node) @typeInfo(@typeInfo(@TypeOf(src.build.Scdo>
/build/tmp.EAMLdgyT6J/p/12207b7a5b538ffb7fb18f954ae17d2f8490b6e3778a9e30564ad82c58ee8da52361/src/build/ScdocStep.zig:40:14: note: parameter 1 'Progress.Node' cannot cast into 'Build.Step.MakeOptions'
/nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Build/Step.zig:71:25: note: struct declared here
/nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Progress.zig:80:18: note: struct declared here
/build/tmp.EAMLdgyT6J/p/12207b7a5b538ffb7fb18f954ae17d2f8490b6e3778a9e30564ad82c58ee8da52361/src/build/ScdocStep.zig:123:25: error: expected type '*const fn (*Build.Step, Build.Step.MakeOptions) anyerror!void', found '*const>
/build/tmp.EAMLdgyT6J/p/12207b7a5b538ffb7fb18f954ae17d2f8490b6e3778a9e30564ad82c58ee8da52361/src/build/ScdocStep.zig:123:25: note: pointer type child 'fn (*Build.Step, Progress.Node) @typeInfo(@typeInfo(@TypeOf(src.build.Scd>
/build/tmp.EAMLdgyT6J/p/12207b7a5b538ffb7fb18f954ae17d2f8490b6e3778a9e30564ad82c58ee8da52361/src/build/ScdocStep.zig:123:25: note: parameter 1 'Progress.Node' cannot cast into 'Build.Step.MakeOptions'
/nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Build/Step.zig:71:25: note: struct declared here
/nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Progress.zig:80:18: note: struct declared here
/build/tmp.EAMLdgyT6J/p/12207b7a5b538ffb7fb18f954ae17d2f8490b6e3778a9e30564ad82c58ee8da52361/src/build/ScdocStep.zig:160:36: error: expected type 'Build.Step.MakeOptions', found 'Progress.Node'
/nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Progress.zig:80:18: note: struct declared here
/nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Build/Step.zig:71:25: note: struct declared here
/nix/store/wp3lc963r8mzh7igs4xa3zyqa4q0xmim-zig-0.14.0-dev.364+8ab70f80c/lib/std/Build/Step.zig:228:32: note: parameter type declared here
Thanks, I fixed the .#versions
. I can reproduce your build issue. Not sure what's going on there, but I'll check around.
Btw, you can simply call zenv.package
in your flake, as that already defaults to the current system. Or alternatively zenv.packageForTarget system
the zigTripleFromString is not required as package.nix calls it already implicitly.
Changing the zig version to zig = inputs.zig2nix.outputs.packages.${system}.zig."0.13.0".bin;
seems to fix zfe. Probably you just need to pin the correct zig for flow too.
Anyhow, here's corrected flake
{
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOs/nixpkgs/nixos-unstable-small";
zfe.flake = false;
zfe.url = "github:BrookJeynes/zfe";
zig2nix.inputs.nixpkgs.follows = "nixpkgs";
zig2nix.url = "github:Cloudef/zig2nix";
};
outputs = { self, ... }@inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = inputs.nixpkgs.lib.systems.flakeExposed;
perSystem = { pkgs, system, ... }: {
packages = let
zenv = inputs.zig2nix.outputs.zig-env.${system} {
zig = inputs.zig2nix.outputs.packages.${system}.zig."0.13.0".bin;
};
build-zig = src: zigBuildZonLock: zenv.package { inherit src zigBuildZonLock; };
in {
zfe = build-zig (pkgs.lib.cleanSource inputs.zfe) ./build.zig.zon2json-lock;
};
};
};
}
When running it on zfe:
When running it on flow: