You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This documents migration steps required after commit b548020
Flake structure changes
Before this, the zig2nix wasn't a valid flake. It had rather weird structure. Now zig2nix doesn't use nested trees to hide its derivations, but rather all outputs can be seen with nix flake show github:Cloudef/zig2nix.
However while zig2nix is now a valid flake, projects using zig2nix may not pass nix flake check --all-systems due to zig2nix relying on IFD. The use of IFD may be removed in future see #33
The structure changes means package names are now different:
The flake no longer provides a default package. Refer to the version of the zig you need explicitly.
If your flake created zig-env with zig.bin.master it is now simply zig-master.
The src variants of zig may not build for every version yet. #34
Apps
The default app in the flake is now zig2nix (for zig-latest) which is a tool for bridging nix and zig together. It now merges all the tools zon2json, zon2json-lock and zon2nix into a single executable, plus offers some new functionality that simplifies zig2nix project as a whole.
zon2json, zon2json-lock and zon2nix aliases are still provided for backwards compatibility in the zig2nix main flake, but are removed from the templates.
To run a specific version of a zig compiler using the flake url, explicitly specify the zig version instead without the zig- prefix as seen in the packages: nix run github:Cloudef/zig2nix#latest version
The multimedia variants are prefixed with multimedia-: nix run github:Cloudef/zig2nix#multimedia-latest version
Devshells
Same changes as with apps.
Overlays
Overlays were never really tested and are removed. I don't personally use them, and such if overlays are required I'd ask from someone to contribute them back with a automated testing that they work.
Templates
The template flake is simplified. It no longer covers advanced use cases, but simply offers the typical zig project and packaging setup for nix.
zig-env
The following arguments from the constructors are removed:
customRuntimeDeps and customRuntimeLibs, instead provide nativeBuildInputs, zigWrapperBins and zigWrapperLibs directly to package or mkShell. deps given to app and app-no-root are automatically added to the correct search paths. This was very akward api and it required nixpkgs before the construction of zig-env, it also would add lots of implicit state which was ugly.
customAppHook, instead wrap the app helpers directly
customShellHook, give mkShell a shellHook instead
enableVulkan and friends. Removed, setup the nativeBuildInputs, zigWrapperBins and zigWrapperLibs yourself for your environment.
The following keys are removed from the attribute set:
packageForTarget, use zigTarget attribute for the package instead if you want to cross-compile from a flake. pkgsForTarget haven't been removed. This was removed, because cross-compiling within flakes like this is unusual. The package itself does correctly build using stdenvNoCC and uses targetPlatform as a target, so it should work even when using a cross-compiling stdenv.
lib, fromZon and deriveFromLockFile are now in the root of zig-env, other keys are removed. target is a new function that can be used to query target information (accepts zig target triple, nix target or crosstool toolchain target)
Zig 0.14 package management changes
Zig 0.14 changed its package hashes. If you are targeting a older zig version then make sure you are running the correct zig2nix when generating a lock file, otherwise the lock file generation will fail. You can use nix run github:Cloudef/zig2nix#zig2nix-0_13_0 -- zon2lock for 0.13 for example.
zon2json-lock changes
The format now stores a rev field for git packages. If you used git packages, remove your old zon2json-lock file and regenerate it.
Examples
Lastly, as always you can look for some example setups in here:
Are you a consumer of zig2nix? Getting errors?
This documents migration steps required after commit b548020
Flake structure changes
Before this, the zig2nix wasn't a valid flake. It had rather weird structure. Now zig2nix doesn't use nested trees to hide its derivations, but rather all outputs can be seen with
nix flake show github:Cloudef/zig2nix
.However while zig2nix is now a valid flake, projects using zig2nix may not pass
nix flake check --all-systems
due to zig2nix relying on IFD. The use of IFD may be removed in future see #33The structure changes means package names are now different:
The flake no longer provides a default package. Refer to the version of the zig you need explicitly.
If your flake created
zig-env
withzig.bin.master
it is now simplyzig-master
.The src variants of zig may not build for every version yet. #34
Apps
The default app in the flake is now
zig2nix
(forzig-latest
) which is a tool for bridging nix and zig together. It now merges all the toolszon2json
,zon2json-lock
andzon2nix
into a single executable, plus offers some new functionality that simplifies zig2nix project as a whole.zon2json
,zon2json-lock
andzon2nix
aliases are still provided for backwards compatibility in the zig2nix main flake, but are removed from the templates.To run a specific version of a zig compiler using the flake url, explicitly specify the zig version instead without the
zig-
prefix as seen in the packages:nix run github:Cloudef/zig2nix#latest version
The multimedia variants are prefixed with
multimedia-
:nix run github:Cloudef/zig2nix#multimedia-latest version
Devshells
Same changes as with apps.
Overlays
Overlays were never really tested and are removed. I don't personally use them, and such if overlays are required I'd ask from someone to contribute them back with a automated testing that they work.
Templates
The template flake is simplified. It no longer covers advanced use cases, but simply offers the typical zig project and packaging setup for nix.
zig-env
The following arguments from the constructors are removed:
customRuntimeDeps
andcustomRuntimeLibs
, instead providenativeBuildInputs
,zigWrapperBins
andzigWrapperLibs
directly topackage
ormkShell
.deps
given toapp
andapp-no-root
are automatically added to the correct search paths. This was very akward api and it requirednixpkgs
before the construction of zig-env, it also would add lots of implicit state which was ugly.customAppHook
, instead wrap the app helpers directlycustomShellHook
, givemkShell
a shellHook insteadenableVulkan
and friends. Removed, setup thenativeBuildInputs
,zigWrapperBins
andzigWrapperLibs
yourself for your environment.The following keys are removed from the attribute set:
packageForTarget
, usezigTarget
attribute for thepackage
instead if you want to cross-compile from a flake.pkgsForTarget
haven't been removed. This was removed, because cross-compiling within flakes like this is unusual. The package itself does correctly build usingstdenvNoCC
and usestargetPlatform
as a target, so it should work even when using a cross-compilingstdenv
.lib
,fromZon
andderiveFromLockFile
are now in the root of zig-env, other keys are removed.target
is a new function that can be used to querytarget
information (accepts zig target triple, nix target or crosstool toolchain target)Zig 0.14 package management changes
Zig 0.14 changed its package hashes. If you are targeting a older zig version then make sure you are running the correct
zig2nix
when generating a lock file, otherwise the lock file generation will fail. You can usenix run github:Cloudef/zig2nix#zig2nix-0_13_0 -- zon2lock
for 0.13 for example.zon2json-lock changes
The format now stores a
rev
field for git packages. If you used git packages, remove your old zon2json-lock file and regenerate it.Examples
Lastly, as always you can look for some example setups in here:
Future changes
In future, I may introduce automatic zls/zigscient integration
The text was updated successfully, but these errors were encountered: