Skip to content

Commit

Permalink
expose zig-hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloudef committed Jan 15, 2024
1 parent 9721ccf commit 52db410
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ zig-env = {
#! access: (zig-env {}).thing
#! Inherit given pkgs and zig version
inherit pkgs zig zon2json zon2json-lock zon2nix;
inherit pkgs zig zon2json zon2json-lock zon2nix zig-hook;
#! Tools for bridging zig and nix
lib = zig2nix-lib;
Expand Down Expand Up @@ -152,7 +152,7 @@ package = pkgs.callPackage (pkgs.callPackage ./package.nix {
#! access: `zig2nix.outputs.thing.${system}`
#! Helper functions for building and running Zig projects.
inherit zig-env zig2nix-lib;
inherit zig-env zig2nix-lib zig-hook;
#! Versioned Zig packages.
packages.zig = zigv;
Expand Down
26 changes: 14 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@

zig2nix-lib-base = _pkgs.callPackage ./lib.nix {};

# Use our own zig hook, but reuse the setup-hook.sh.
# The nixpkgs one forces flags which can't be overridden.
# Also -target is recommended over use of -Dcpu=baseline.
# https://ziggit.dev/t/exe-files-not-interchangeable-among-identical-linux-systems/2708/6
zig-hook = { makeSetupHook, zig }: makeSetupHook {
name = "zig-hook";
propagatedBuildInputs = [ zig ];
substitutions.zig_default_flags = [];
passthru = { inherit zig; };
} "${nixpkgs.outPath}/pkgs/development/compilers/zig/setup-hook.sh";

# Zig versions.
# <https://ziglang.org/download/index.json>
zigv = _pkgs.callPackage ./versions.nix {
zigSystem = zig2nix-lib.resolveSystem system;
# Use our own zig hook, but reuse the setup-hook.sh.
# The nixpkgs one forces flags which can't be overridden.
# Also -target is recommended over use of -Dcpu=baseline.
# https://ziggit.dev/t/exe-files-not-interchangeable-among-identical-linux-systems/2708/6
zigHook = { makeSetupHook, zig }: makeSetupHook {
name = "zig-hook";
propagatedBuildInputs = [ zig ];
substitutions.zig_default_flags = [];
passthru = { inherit zig; };
} "${nixpkgs.outPath}/pkgs/development/compilers/zig/setup-hook.sh";
zigHook = zig-hook;
};

# Converts zon files to json
Expand Down Expand Up @@ -135,7 +137,7 @@
+ nlib.optionalString (pkgs.stdenv.isDarwin) _darwin_extra;
in rec {
#! Inherit given pkgs and zig version
inherit pkgs zig zon2json zon2json-lock zon2nix;
inherit pkgs zig zon2json zon2json-lock zon2nix zig-hook;

#! Tools for bridging zig and nix
lib = zig2nix-lib;
Expand Down Expand Up @@ -204,7 +206,7 @@
#! access: `zig2nix.outputs.thing.${system}`

#! Helper functions for building and running Zig projects.
inherit zig-env zig2nix-lib;
inherit zig-env zig2nix-lib zig-hook;

#! Versioned Zig packages.
packages.zig = zigv;
Expand Down

0 comments on commit 52db410

Please sign in to comment.