mitchellh/zig-overlay

Please expand on usage documentation

Opened this issue · 7 comments

For me(and I assume others new to Nix), adding the flake as an input is fine, but I don't understand how to actually add and use the Zig package.

For me(and I assume others new to Nix), adding the flake as an input is fine, but I don't understand how to actually add and use the Zig package.

You can check my latest pull request, I described in the README on how to add zig as a package

I'm trying to use this in a flake like this:

{
  description = "A devShell example";

  inputs = {
    nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";

    flake-utils.url = "github:numtide/flake-utils";
    zig-overlay = {
      url = "github:mitchellh/zig-overlay";
    };
  };

  outputs = {
    self,
    nixpkgs,
    zig-overlay,
    flake-utils,
    ...
  }:
    flake-utils.lib.eachDefaultSystem (
      system: let
        overlays = [(import zig-overlay)];
        pkgs = import nixpkgs {
          inherit system overlays;
        };
      in {
        devShells.default = with pkgs;
          mkShell {
            buildInputs = [
              openssl
              pkg-config
              eza
              fd
              zig
            ];

            shellHook = ''
              alias ls=eza
              alias find=fd
            '';
          };
      }
    );
}

This is the error I get when I do nix develop :

error:
       … <borked>

         at «none»:0: (source not available)

       … while evaluating a branch condition

         at /nix/store/bi5zxc0v5g6ylygdwyqzh280sccg3ykb-source/pkgs/stdenv/booter.nix:99:7:

           98|     thisStage =
           99|       if args.__raw or false
             |       ^
          100|       then args'

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: infinite recursion encountered

       at «none»:0: (source not available)

I really can't figure out what I'm doing wrong, I took this rust overlay as a model.

Can't tell about infinite recursion problem, but shouldn't you use zig instead of zig-overlay in the outputs section?

Is the infinite recursion due to overlays being [(import zig-overlay)] instead of

overlays = [
  (final: prev: {
    zigpkgs = inputs.zig.packages.${prev.system};
  })
];

? That's what fixed it when I ran into a similar problem on my end but idk if it's diff

Use in flakes works with

overlays = [
  zig-overlay.overlays.default
];

Naming the input zig or zig-overlay does not affect this but it does feel redundant imho.

Source #56.

xsova commented

To import rust-overlay, I have outputs.darwinConfigurations.system.modules = [ inputs.rust-overlay.overlays.default ]; is that how this is supposed to be added?

i.e., outputs.darwinConfigurations.system.modules = [ inputs.zig-overlay.overlays.default ]; ? I tried this but it didn't seem to work.. But since my outputs = inputs: {}; I don't specify inputs that are included in outputs- so I'm a little confused about how to make sure it's added correctly. I ended up here because I am getting build failure on zig 0.12.1.

error: builder for '/nix/store/3rk0087834db989abrfi2rmkarr20132-zig-0.12.1.drv' failed with exit code 2;
       last 25 log lines:
       >     note: tried /nix/store/4s8z8il6zyq77ixy4b8kfzwsnz90vsrm-apple-sdk-11.3/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/lib/system/libsystem_symptoms.dylib
       > error: unable to resolve dependency

so I was hoping this would fix it lol

@xsova After doing an import do you call zig package by zigpkgs?

From the official README:

overlays.default is an overlay that adds zigpkgs to be the packages exposed by this flake