Closed Arya-Elfren closed 4 months ago
The package
should be able to do that. You still have to construct the env
to pick the correct zig version. The package takes src
argument which isnt any different from typical nix package derivation.
Note that for sandboxed builds you will need a lock file, if the project uses build.zig.zon dependencies. You can provide this lock file from outside the project. See #11 https://github.com/Cloudef/zig2nix/blob/master/src%2Fpackage.nix#L32
Im currently on travels so i cant provide examples right now.
I currently have this working for hevi. Because of #14 I don't have this working with flow and zfe yet. (using flake-parts)
packages = {
hevi = let
env = inputs.zig2nix.outputs.zig-env.${system} {
zig = inputs.zig2nix.outputs.packages.${system}.zig.master.bin;
};
in
(pkgs.lib.genAttrs env.lib.allTargetTriples (target: env.packageForTarget target ({
src = pkgs.lib.cleanSource inputs.hevi;
zigBuildZonLock = ./packages/hevi/build.zig.zon2json-lock; # manually generated file
}))).${env.lib.zigTripleFromString system};
};
Anything I could improve about it?
Thanks, I'll track your issue in the #14 and close this.
Would it be possible / reasonable to have a function that just takes the source and returns the exe?
For example, I would like to add hevi and flow to my nixos config without forking and adding a flake. Is there a way to do that with this flake? Either as a snippet or a feature?