Skip to content

Commit 615e7e8

Browse files
authored
Merge pull request #40 from joelbenway/add-c-cpp
Add C/C++ development flake with some sane defaults.
2 parents d6bccb7 + a4a1c80 commit 615e7e8

File tree

5 files changed

+97
-0
lines changed

5 files changed

+97
-0
lines changed

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Once your preferred template has been initialized, you can use the provided shel
2929

3030
| Language/framework/tool | Template |
3131
| :----------------------- | :---------------------------- |
32+
| [C]/[C++] | [`c-cpp`](./c-cpp/) |
3233
| [Clojure] | [`clojure`](./clojure/) |
3334
| [C#][csharp] | [`csharp`](./csharp/) |
3435
| [Cue] | [`cue`](./cue/) |
@@ -64,6 +65,20 @@ Once your preferred template has been initialized, you can use the provided shel
6465

6566
The sections below list what each template includes. In all cases, you're free to add and remove packages as you see fit; the templates are just boilerplate.
6667

68+
### [`c-cpp`](./c-cpp/)
69+
70+
- [clang-tools] 17.0.6
71+
- [cmake] 3.28.3
72+
- [codespell] 2.2.6
73+
- [conan] 2.0.17
74+
- [cppcheck] 2.13.4
75+
- [doxygen] 1.10.0
76+
- [gdb] 14.1
77+
- [gtest] 1.12.1
78+
- [lcov] 1.0
79+
- [vcpkg]
80+
- [vcpkg-tool]
81+
6782
### [`clojure`](./clojure/)
6883

6984
- [Clojure] 1.11.1.1347
@@ -268,15 +283,22 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T
268283

269284
[boot]: https://www.boot-clj.com
270285
[buf]: https://github.com/bufbuild/buf
286+
[C]: https://www.open-std.org/jtc1/sc22/wg14
287+
[C++]: https://isocpp.org
271288
[cabal]: https://www.haskell.org/cabal
272289
[cachix]: https://www.cachix.org
273290
[cargo]: https://doc.rust-lang.org/cargo
274291
[cargo-audit]: https://crates.io/crates/cargo-audit
275292
[cargo-deny]: https://crates.io/crates/cargo-deny
293+
[clang-tools]: https://clang.llvm.org/
276294
[clippy]: https://github.com/rust-lang/rust-clippy
277295
[clojure]: https://clojure.org
296+
[cmake]: https://cmake.org/
297+
[codespell]: https://github.com/codespell-project/codespell
278298
[composer]: https://getcomposer.org/
299+
[conan]: https://conan.io/
279300
[conftest]: https://www.conftest.dev
301+
[cppcheck]: http://cppcheck.sourceforge.net/
280302
[csharp]: https://dotnet.microsoft.com/en-us/languages/csharp
281303
[cue]: https://cuelang.org
282304
[damon]: https://github.com/hashicorp/damon
@@ -292,18 +314,21 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T
292314
[dhall-toml]: https://github.com/dhall-lang/dhall-haskell/tree/master/dhall-toml
293315
[dhall-yaml]: https://github.com/dhall-lang/dhall-haskell/tree/master/dhall-yaml
294316
[dotnet]: https://dotnet.microsoft.com/en-us/
317+
[doxygen]: https://www.doxygen.nl/
295318
[dune]: https://dune.build
296319
[elixir]: https://elixir-lang.org
297320
[elm]: https://elm-lang.org
298321
[elm2nix]: https://github.com/cachix/elm2nix
299322
[flake-utils]: https://github.com/numtide/flake-utils
323+
[gdb]: https://www.gnu.org/software/gdb/
300324
[gigalixir]: https://www.gigalixir.com
301325
[gleam]: https://gleam.run
302326
[go]: https://go.dev
303327
[godoc]: https://pkg.go.dev/golang.org/x/tools/cmd/godoc
304328
[goimports]: https://pkg.go.dev/golang.org/x/tools/cmd/goimports
305329
[golangci-lint]: https://github.com/golangci/golangci-lint
306330
[gradle]: https://gradle.org
331+
[gtest]: https://github.com/google/googletest
307332
[hashicorp]: https://hashicorp.com
308333
[haskell]: https://haskell.org
309334
[haxe]: https://haxe.org/
@@ -313,6 +338,7 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T
313338
[jq]: https://jqlang.github.io/jq
314339
[kotlin]: https://kotlinlang.org
315340
[latex]: https://www.latex-project.org/
341+
[lcov]: https://ltp.sourceforge.net/coverage/lcov.php
316342
[leiningen]: https://leiningen.org
317343
[levant]: https://github.com/hashicorp/levant
318344
[lorri]: https://github.com/target/lorri
@@ -366,6 +392,8 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T
366392
[texlive]: https://www.tug.org/texlive/
367393
[tflint]: https://github.com/terraform-linters/tflint
368394
[vault]: https://www.vaultproject.io
395+
[vcpkg]: https://vcpkg.io/
396+
[vcpkg-tool]: https://github.com/microsoft/vcpkg-tool
369397
[vulnix]: https://github.com/flyingcircusio/vulnix
370398
[yarn]: https://yarnpkg.com
371399
[vlang]: https://vlang.io/

c-cpp/.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

c-cpp/flake.lock

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

c-cpp/flake.nix

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
description = "A Nix-flake-based C/C++ development environment";
3+
4+
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
5+
6+
outputs = { self, nixpkgs }:
7+
let
8+
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
9+
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
10+
pkgs = import nixpkgs { inherit system; };
11+
});
12+
in
13+
{
14+
devShells = forEachSupportedSystem ({ pkgs }: {
15+
default = pkgs.mkShell.override {
16+
# Override stdenv in order to change compiler:
17+
# stdenv = pkgs.clangStdenv;
18+
}
19+
{
20+
packages = with pkgs; [
21+
clang-tools
22+
cmake
23+
codespell
24+
conan
25+
cppcheck
26+
doxygen
27+
gtest
28+
lcov
29+
vcpkg
30+
vcpkg-tool
31+
] ++ (if system == "aarch64-darwin" then [ ] else [ gdb ]);
32+
};
33+
});
34+
};
35+
}
36+

flake.nix

+7
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@
9696

9797
{
9898
templates = rec {
99+
c-cpp = {
100+
path = ./c-cpp;
101+
description = "C/C++ development environment";
102+
};
103+
99104
clojure = {
100105
path = ./clojure;
101106
description = "Clojure development environment";
@@ -253,6 +258,8 @@
253258

254259
# Aliases
255260
rt = rust-toolchain;
261+
c = c-cpp;
262+
cpp = c-cpp;
256263
};
257264
};
258265
}

0 commit comments

Comments
 (0)