Skip to content

jpnt/modern-c-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Modern C Development Environment Project Template

Problem: C project setup SUCKS

  • Confusing dependency management
  • Environment setup varies per machine
  • Toolchain configuration is complex
  • Onboarding new devs takes hours/days

Solution: Nix + Zig + Containers

  • Nix is a real (not C only) package manager with the biggest package library of all Linux distros!
  • Zig has a build system and built-in compiler that cross-compiles better than gcc or clang!
  • Containers isolate complex environments, no more setting up environment variables and installing a dozen dependencies!

Compiling Project

$ zig build

Design Principles

  • Robust simplicity: default to simple and robust stack of components
  • Container first: containers and nix coexist together to form the best of both worlds: reproducible environment setup and isolation
  • Optionality: more complex components are included only if explicitly enabled
  • Explicit configuration: options are configured by editing build.zig (a real programming language, not some DSL)
  • Clear responsibility: each component does exactly one thing (well)
  • Bootstrapability: builds and runs on minimal systems
  • Reproducibility: builds should behave identically across machines
  • No compromises: zero tolerance for sub-optimal tools

Software Stack

  • Version control: git
  • Build system: zig (build.zig)
  • Compiler: zig cc
  • (Optional) Dependency management (and container image generation): nix or lix (flake.nix)
  • (Optional) Testing: non-opinionated; in this example: csds_test.h
  • (Optional) Container engine: Podman or Docker
  • (Optional) Documentation: doxygen
  • (Optional) Error detection: valgrind + cppcheck
  • (Optional) CI/CD: non-opinionated; in this example: GitHub Actions
  • (Optional) Code formatting:
    • C: clang-format, astyle
    • Nix: alejandra

Targets

  • zig build
  • zig build env
  • zig build ctr_img ??? study first
  • zig build test
  • zig build cicd
  • zig build docs
  • zig build valgrind
  • zig build cppcheck
  • zig build format

For more information:

$ zig build --help

Notes

  • This template favors simplicity, explicitness, and minimal tooling.
  • Integrations like LSP, CI/CD, containerization, or Nix shells are modular and optional.
  • Ideal for systems programming, libraries, CLI tools, and embedded.

About

Zig ⚑ + Nix πŸ› οΈ + Containers πŸ—οΈ = πŸš€

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published