Skip to content

Commit 02e31ca

Browse files
committed
Update README.md
1 parent f758539 commit 02e31ca

File tree

1 file changed

+68
-45
lines changed

1 file changed

+68
-45
lines changed

README.md

Lines changed: 68 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,60 @@
11
# perfect-helloworld
22

3-
A reference-grade C helloworld project.
3+
A _(deliberately over-engineered)_ reference-grade C "Hello World" project.
44

5-
Prints "Hello, World!" with maximal engineering discipline!
5+
This is what a modern, best practice-oriented C project might look like in 2026.
6+
The project is aimed at developers looking for a opinionated and modern starting
7+
point.
8+
9+
Feedback and constructive criticism are welcomed!
10+
11+
## Non-goals
12+
13+
- Being the smallest or simplest C "Hello World" example
14+
- Avoiding modern tooling for portability
615

716
## Features
817

9-
- Meson build system;
10-
- Cross-compilation support;
11-
- Nix flake for dependency management;
12-
- MIT license;
13-
- GitHub Actions CI;
14-
- Standard project structure (`docs/`, `include/`, `src/`, `tests/`, `scripts/`);
15-
- Supports `llvm-vs-code-extensions.vscode-clangd` instead of `ms-vscode.cpptools`;
16-
- Doxygen support;
17-
- Pkg-config (generates `.pc` file);
18-
- Unit testing support via [Unity] testing framework;
19-
- Pre-commit hooks:
20-
- `clang-format`
21-
- `clang-tidy`
22-
- `meson format`
23-
- `nix flake check`
24-
- `nix fmt`
25-
- [IWYU]
26-
- [cppcheck]
27-
- [REUSE]
28-
- Formatting JSON files with [jq];
18+
- Meson build system
19+
- Prioritizes Clang instead of GCC
20+
- Cross-compilation support
21+
- Nix flake for dependency management
22+
- MIT license
23+
- GitHub Actions CI
24+
- Standard project structure (`docs/`, `include/`, `src/`, `tests/`, `scripts/`)
25+
- Uses `llvm-vs-code-extensions.vscode-clangd` instead of `ms-vscode.cpptools`
26+
- Doxygen support
27+
- Pkg-config (generates `.pc` file)
28+
- Unit testing support via [Unity](https://www.throwtheswitch.org/unity) testing
29+
framework
30+
31+
### Pre-commit hooks
32+
33+
The following checks are enforced via [prek](https://github.com/j178/prek) (a
34+
lightweight alternative to [pre-commit](https://pre-commit.com/)):
35+
36+
- `clang-format`
37+
- `clang-tidy`
38+
- `meson format`
39+
- `nix flake check`
40+
- `nix fmt`
41+
- [IWYU](https://include-what-you-use.org/)
42+
- [cppcheck](https://en.wikipedia.org/wiki/Cppcheck)
43+
- [REUSE](https://reuse.software/)
44+
- [jq](https://jqlang.org/) (for JSON formatting);
2945

3046
## Getting started
3147

32-
To setup your environment for developing this project run these commands:
48+
To set up your development environment, run the following commands:
3349

34-
1. Install [Nix] and [direnv].
35-
1. Clone and cd into the repository.
50+
1. Install [Nix](https://nixos.org/download).
51+
1. Clone the repository and cd into the project directory.
3652

3753
```bash
3854
git clone https://github.com/synalice/perfect-helloworld
3955
cd perfect-helloworld
4056
```
4157

42-
1. Enable direnv.
43-
44-
```bash
45-
direnv allow
46-
```
47-
4858
1. Enter Nix `devShell` (installs the toolchain and dependencies).
4959

5060
```bash
@@ -65,6 +75,23 @@ To setup your environment for developing this project run these commands:
6575

6676
You are good to go!
6777

78+
### (Optional) Use direnv
79+
80+
1. Install [direnv](https://direnv.net/).
81+
1. cd into the project directory.
82+
83+
```bash
84+
cd perfect-helloworld
85+
```
86+
87+
1. Enable direnv.
88+
89+
```bash
90+
direnv allow
91+
```
92+
93+
Now `nix develop` will run automatically when you cd into the project directory!
94+
6895
## Cross-compilation
6996

7097
To cross-compile the project, run this script:
@@ -74,26 +101,22 @@ To cross-compile the project, run this script:
74101
```
75102

76103
> [!WARNING]\
77-
> Invoking it for the first time make take some time, because Nix will download or
78-
> build some parts of the cross toolchain.
104+
> Invoking it for the first time may take some time, because Nix will download
105+
> or build some parts of the cross toolchain.
79106

80107
> [!TIP]\
81-
> To cross-compile for different host architectures replace
108+
> To cross-compile for different host architectures, replace
82109
> `aarch64-multiplatform` with `riscv64` or something else. [Read more
83110
> here](https://nix.dev/tutorials/cross-compilation.html#choosing-the-host-platform-with-nix).
84111

85112
> [!TIP]\
86-
> To build dev or doc derivation (package) replace `out` with `dev` or `doc`.
113+
> To build the `dev` or `doc` derivation, replace `out` with `dev` or `doc`.
87114

88-
## License
115+
## Known issues
116+
117+
- No cross-compilation in CI, as downloading cross toolchains from Nix binary
118+
caches significantly increases CI time.
89119

90-
This project is under the [MIT] license.
120+
## License
91121

92-
[jq]: https://jqlang.org/
93-
[Nix]: https://nixos.org/download
94-
[MIT]: https://opensource.org/license/mit
95-
[IWYU]: https://include-what-you-use.org/
96-
[Unity]: https://www.throwtheswitch.org/unity
97-
[REUSE]: https://reuse.software/
98-
[direnv]: https://direnv.net/#getting-started
99-
[cppcheck]: https://en.wikipedia.org/wiki/Cppcheck
122+
This project is under the [MIT](https://opensource.org/license/mit) license.

0 commit comments

Comments
 (0)