Kirikae: A NixOS deployment tool written in Zig

kirikae


This is my first “larger” project in Zig. I’m fairly new to the language. The inspiration for the project came from colmena, which I used prior to writing this tool. I found colmena lacked features I really wanted/needed so I set out to write a similar tool myself and simultaneously further my understanding of Zig.

I am well aware the code quality is probably quite bad. I basically made a best effort of structuring and avoiding duplication, yet I am unhappy with the code’s readbility and how it is structured. The nix-side is definitely thought out more than the actual Zig code. Most importantly though, I have a logo ^^

The following will probably only make sense to people who are already familiar with Nix (flakes). The project works by mapping each kirikae.hosts entry to a nixosConfiguration with the same name. Refer to the project’s README.md for a more detailed example. It then offers a variety of subcommands, ranging from just building or applying a specific, or all configurations, to simply spawning a shell or running a command remotely. For a full list refer to the project’s README.md.

We currently use this project at our local hack space, to deploy NixOS-VMs and -LXCs.

While writing this project I learned more about how to hold the “new” Io a bit better. I hope to learn more about writing Zig, moving this project forward.

Feel free to leave feedback and suggestions for improvement, I’d love to hear it ^^

Supported Zig versions

Currently targeting 0.16.0.

Source

The source repo can be found on SourceHut or GitHub.

8 Likes

Nice project !

You made me remember I wanted to try nixos :wink:

2 Likes

Hello fellow Nix person :waving_hand:

The only suggestion I have is that the --on/--not-on syntax is a little ambiguous. When I pass those flags, is it saying to exclude the operand from the action that’s being applied, or is it saying the desired end state (“turn this machine on/off”)?

I never used colmena myself, so maybe it makes more sense to someone that has used it. I usually do the grug-brained thing and just do a rebuild/switch with a remote target.

1 Like

this reply was written using NixOS :wink:

good work

1 Like

Thanks for the feedback and sorry for the delayed answer. --on and --not-on only select which hosts a given subcommand applies to. They do not turn machines on or off. If --on and --not-on are both supplied, --not-on takes precedence.

I took over the naming from colmena, but I agree that it kinda sounds like power control. Something like --include and --exclude may also be clearer as flags…

Be careful, once you go NixOS, it’s extremely hard to go back xD

For me, it started with nix on Mac, and now my laptop, desktop, and server all run NixOS. The second I can get some quality hardware, it’s going on my router as well.

2 Likes