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
nix run github:Cloudef/zig2nix#master -- versionnix run github:Cloudef/zig2nix#latest -- versionnix run github:Cloudef/zig2nix#0_8_0 -- version
Convenience zig for multimedia programs
This sets (DY)LD_LIBRARY_PATH and PKG_CONFIG_PATH so that common libs are available
nix run github:Cloudef/zig2nix#multimedia-master -- versionnix run github:Cloudef/zig2nix#multimedia-latest -- versionnix run github:Cloudef/zig2nix#multimedia-0_8_0 -- version
nix run github:Cloudef/zig2nix -- zon2json build.zig.zon
Convert build.zig.zon to a build.zig.zon2json-lock
nix run github:Cloudef/zig2nix -- zon2lock build.zig.zon
Convert build.zig.zon/2json-lock to a nix derivation
# calls zon2json-lock if build.zig.zon2json-lock does not exist (requires network access)nix run github:Cloudef/zig2nix -- zon2nix build.zig.zon# alternatively run against the lock file (no network access required)nix run github:Cloudef/zig2nix -- zon2nix build.zig.zon2json-lock
Crude documentation
Below is auto-generated dump of important outputs in this flake.
#! Structures.#:! Helper function for building and running Zig projects.zig-env={# Overrideable nixpkgs.nixpkgs ?self.inputs.nixpkgs,# Zig version to use.zig ?zigv.latest,}:{ ...};#! --- Outputs of zig-env {} function.#! access: (zig-env {}).thing#! Tools for bridging zig and nix#! The correct zig version is put into the PATHzig2nix=pkgs.writeShellApplication{name="zig2nix";runtimeInputs=[zig];text=''${zig2nix-zigless}/bin/zig2nix "$@"'';};#! Translates zig and nix compatible targetstarget=system:(exec-json"target"[system]);#! Reads zon file into a attribute setfromZON=path:exec-json-path"zon2json"path[];#! Creates derivation from zon2json-lock filederiveLockFile=path:pkgs.callPackage(exec-path"zon2nix"path["-"]);#! Returns true if target is nix flake compatible.#! <https://github.com/NixOS/nixpkgs/blob/master/lib/systems/flake-systems.nix>isFlakeTarget=any:pkgs.lib.any(s:(systems.elaborates).config==(targetany).config)systems.flakeExposed;#! Returns crossPkgs from nixpkgs for target string or system.#! This will always cross-compile the package.crossPkgsForTarget=any:letcrossPkgs=importnixpkgs{localSystem=system;crossSystem={config=(targetany).config;};};this-system=(systems.elaboratesystem).config==(targetany).config;inifthis-system thenpkgs elsecrossPkgs;#! Returns pkgs from nixpkgs for target string or system.#! This does not cross-compile and you'll get a error if package does not exist in binary cache.binaryPkgsForTarget=any:letbinaryPkgs=importnixpkgs{localSystem={config=(targetany).config;};};this-system=(systems.elaboratesystem).config==(targetany).config;inifthis-system thenpkgs elsebinaryPkgs;#! Returns either binaryPkgs or crossPkgs depending if the target is flake target or not.pkgsForTarget=any:ifisFlakeTargetany thenbinaryPkgsForTargetanyelsecrossPkgsForTargetany;#! Cross-compile nixpkgs using zig :)#! NOTE: This is an experimental feature, expect it not faring wellzigCrossPkgsForTarget=any:letcrossPkgs=pkgs.callPackage./src/cross{inheritzigzigPackagetarget;nixCrossPkgs=pkgsForTargetany;nixBinaryPkgs=binaryPkgsForTargetany;localSystem=system;crossSystem={config=(targetany).config;};};inwarn"zigCross:${(targetany).zig}"crossPkgs;#! Flake app helper (Without zig-env and root dir restriction).app-bare-no-root=deps:script:{type="app";program=toString(pkgs.writeShellApplication{name="app";runtimeInputs=[]++deps;text='' # shellcheck disable=SC2059 error() { printf -- "error: $1\n" "''${@:2}" 1>&2; exit 1; }${script} '';})+"/bin/app";};#! Flake app helper (Without zig-env).app-bare=deps:script:app-bare-no-rootdeps'' [[ -f ./flake.nix ]] || error 'Run this from the project root'${script}'';#! Flake app helper (without root dir restriction).app-no-root=deps:script:app-bare-no-root(deps++_deps)''${shell-runtimedeps}${script}'';#! Flake app helper.app=deps:script:app-bare(deps++_deps)''${shell-runtimedeps}${script}'';#! Creates dev shell.mkShell=pkgs.callPackage({nativeBuildInputs ?[], ...} @attrs:pkgs.mkShellNoCC(attrs//{nativeBuildInputs=nativeBuildInputs++_deps;shellHook=''${shell-runtimenativeBuildInputs}${attrs.shellHookor""} '';}));#! Packages zig project.#! NOTE: If your project has build.zig.zon you must first generate build.zig.zon2json-lock using zon2json-lock.#! It is recommended to commit the build.zig.zon2json-lock to your repo.#!#! Additional attributes:#! zigTarget: Specify target for zig compiler, defaults to stdenv.targetPlatform of given target.#! zigPreferMusl: Prefer musl libc without specifying the target.#! zigWrapperBins: Binaries available to the binary during runtime (PATH)#! zigWrapperLibs: Libraries available to the binary during runtime (LD_LIBRARY_PATH)#! zigWrapperArgs: Additional arguments to makeWrapper.#! zigBuildZon: Path to build.zig.zon file, defaults to build.zig.zon.#! zigBuildZonLock: Path to build.zig.zon2json-lock file, defaults to build.zig.zon2json-lock.#!#! <https://github.com/NixOS/nixpkgs/blob/master/doc/hooks/zig.section.md>package=zigPackage;#! Bundle a package into a zipbundle.zip=pkgs.callPackage./src/bundle/zip.nix{inheritzigPackage;};#! Bundle a package for running in AWS lambdabundle.aws.lambda=pkgs.callPackage./src/bundle/lambda.nix{bundleZip=bundle.zip;};#! --- Architecture dependent flake outputs.#! access: `zig2nix.outputs.thing.${system}`#! Helper functions for building and running Zig projects.inheritzig-env;#! Versioned Zig packages.#! nix build .#zig-master#! nix build .#zig-latest#! nix run .#zig-0_13_0packages=mapAttrs'(k:v:nameValuePair("zig-"+k)v)zigv;#! Develop shell for building and running Zig projects.#! nix develop .#zig_version#! example: nix develop .#master#! example: nix develop .#defaultdevShells=flake-outputs.devShells//{default=flake-outputs.devShells.latest;};#! --- Generic flake outputs.#! access: `zig2nix.outputs.thing`#! Default project template#! nix flake init -t templatestemplates.default=rec{path=./templates/default;description="Default Zig project template";welcomeText=welcome-templatedescription;};#! Master project template#! nix flake init -t templates#mastertemplates.master=rec{path=./templates/master;description="Master Zig project template";welcomeText=welcome-templatedescription;};
About
Flake for packaging, building and running Zig projects.