All of this information is also included in the README.md
Initialize using
nix flake init --template "github:nulladmin1/nix-flake-templates#zig"
This is how to structure of the template looks like:
📦 zig
├── ⚙️ .envrc
├── ⚙️ build.zig
├── ⚙️ build.zig.zon
├── ❄️ default.nix
├── 📃 README.md
├── ❄️ flake.nix
└── 📁 src
└── 📝 main.zig
The flake is able to run in the specified systems listed in the flake. It contains a devShells
as an output with Zig
, a package that runs hello
by building it with Nixpkgs' zig.hook
, and an app that runs the previously mentioned package.
nix run
nix develop
(Optional) Format flake.nix
using Alejandra
nix fmt
-
In 'flake.nix'
-
Edit description
{ description = "project_name"; }
-
Change details in
mkDerivation
default = pkgsFor.${system}.stdenv.mkDerivation { pname = "project_name"; version = "0.1.0"; src = ./.; nativeBuildInputs = with pkgsFor.${system}; [ zig.hook ]; };
-
-
In
build.zig
- Configure main executable details
const exe = b.addExecutable(.{ .name = "project_name", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, });
- Configure main executable details
-
- Configure package details
.name = "project_name", .version = "0.1.0",
- Configure package details
-
For the structure and code
- Add necessary code into the
src/
directory. Reflect changes inbuild.zig
- Add necessary code into the