Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: Recent changes #35

Open
Cloudef opened this issue Mar 11, 2025 · 0 comments
Open

README: Recent changes #35

Cloudef opened this issue Mar 11, 2025 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@Cloudef
Copy link
Owner

Cloudef commented Mar 11, 2025

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 #33

The structure changes means package names are now different:

zig-master
zig-latest
zig-0_14_0
zig-0_13_0
zig-src-master
zig-src-latest
zig-src-0_14_0
zig-src-0_13_0

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:

Future changes

In future, I may introduce automatic zls/zigscient integration

@Cloudef Cloudef pinned this issue Mar 11, 2025
@Cloudef Cloudef added the documentation Improvements or additions to documentation label Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant