about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--c/.envrc1
-rw-r--r--c/.gitignore2
-rw-r--r--c/Makefile49
-rw-r--r--c/README.md5
-rw-r--r--c/cog.toml28
-rw-r--r--c/src/main.c3
-rwxr-xr-xc/test14
-rw-r--r--templates/c/.ccls (renamed from c/.ccls)0
-rw-r--r--templates/c/.envrc9
-rw-r--r--templates/c/.gitignore7
-rw-r--r--templates/c/.licensure.yml159
-rw-r--r--templates/c/COPYING (renamed from c/COPYING)0
-rw-r--r--templates/c/LICENSE.spdx7
-rw-r--r--templates/c/Makefile60
-rw-r--r--templates/c/README.md10
-rw-r--r--templates/c/cog.toml25
-rw-r--r--templates/c/docs/TODO.1.md70
-rw-r--r--templates/c/flake.lock102
-rw-r--r--templates/c/flake.nix (renamed from c/flake.nix)37
l---------templates/c/scripts/renew_copyright_header.sh1
-rwxr-xr-xtemplates/c/scripts/valgrind_test.sh29
-rw-r--r--templates/c/src/main.c10
l---------templates/c/treefmt.nix1
-rwxr-xr-xtemplates/c/update.sh3
24 files changed, 521 insertions, 111 deletions
diff --git a/c/.envrc b/c/.envrc
deleted file mode 100644
index 3550a30..0000000
--- a/c/.envrc
+++ /dev/null
@@ -1 +0,0 @@
-use flake
diff --git a/c/.gitignore b/c/.gitignore
deleted file mode 100644
index ee080b2..0000000
--- a/c/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-.direnv
-.ccls-cache
diff --git a/c/Makefile b/c/Makefile
deleted file mode 100644
index 57fa7cf..0000000
--- a/c/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-PREFIX    := /usr/local
-BINPREFIX := $(DESTDIR)$(PREFIX)/bin
-MANPREFIX := $(DESTDIR)$(PREFIX)/share/man/man1
-
-BIN_NAME := project_name
-
-SRC := $(wildcard src/*.c)
-OBJ := $(SRC:.c=.o)
-DEP := $(OBJ:.o=.d)
-
-LIBS :=
-
-ALL_CFLAGS  := -O3 -MMD -Wall -Wextra -Wno-unused-parameter $(CFLAGS) $(CPPFLAGS)
-ALL_LDFLAGS := $(addprefix -l,$(LIBS)) $(CFLAGS) $(LDFLAGS)
-
-
-
-$(BIN_NAME): $(OBJ)
-	$(CC) -o $@ $+ $(ALL_LDFLAGS)
-
-install: $(BIN_NAME)
-	install -d $(BINPREFIX)
-	install $^ $(BINPREFIX)
-
-.c.o:
-	$(CC) -o $@ $< -c $(ALL_CFLAGS)
-
-valgrind-out.txt: $(BIN_NAME)
-	valgrind --leak-check=full \
-         --show-leak-kinds=all \
-         --show-error-list=yes \
-         --track-origins=yes \
-         --log-file=valgrind-out.txt \
-         ./rename
-
-.PHONY : clean options install test
-options:
-	@echo "CC      = $(CC)"
-	@echo "CFLAGS  = $(ALL_CFLAGS)"
-	@echo "LDFLAGS = $(ALL_LDFLAGS)"
-	@echo "OBJ = $(OBJ)"
-	@echo "DEP = $(DEP)"
-	@echo ""
-
-clean :
-	rm $(BIN_NAME) valgrind-out.txt $(OBJ) $(DEP)
-
-test:
-	./test
diff --git a/c/README.md b/c/README.md
deleted file mode 100644
index 8f65521..0000000
--- a/c/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# PROJECT NAME
-
-
-## Licence
-This is licenced under the GNU Public License (GPL).
diff --git a/c/cog.toml b/c/cog.toml
deleted file mode 100644
index d920064..0000000
--- a/c/cog.toml
+++ /dev/null
@@ -1,28 +0,0 @@
-from_latest_tag = false
-tag_prefix = "v"
-ignore_merge_commits = false
-pre_package_bump_hooks = []
-post_package_bump_hooks = []
-
-branch_whitelist = [
-  "prime",
-]
-
-pre_bump_hooks = [
-    "nix build", # verify the project builds
-    "nix flake check",
-]
-post_bump_hooks = [
-    "git push",
-    "git push origin v{{version}}", # push the new tag to origin
-]
-
-[commit_types]
-
-[changelog]
-path = "NEWS.md"
-authors = []
-
-[bump_profiles]
-
-[packages]
diff --git a/c/src/main.c b/c/src/main.c
deleted file mode 100644
index 061a06a..0000000
--- a/c/src/main.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <stdio.h>
-
-int main() { printf("Hello World!"); }
diff --git a/c/test b/c/test
deleted file mode 100755
index 05d1fb5..0000000
--- a/c/test
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-
-CFLAGS=-ggdb3 make valgrind-out.txt
-
-printf "\n___RESULTS:___\n";
-if grep -q 'ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)' valgrind-out.txt; then
-     echo "No Memory leaks";
-else
-     echo "Memory leaks: " && tail valgrind-out.txt;
-     exit 1;
-fi
-
-
-# vim: ft=sh
diff --git a/c/.ccls b/templates/c/.ccls
index 90584dd..90584dd 100644
--- a/c/.ccls
+++ b/templates/c/.ccls
diff --git a/templates/c/.envrc b/templates/c/.envrc
new file mode 100644
index 0000000..77f9235
--- /dev/null
+++ b/templates/c/.envrc
@@ -0,0 +1,9 @@
+use flake || use nix
+watch_file flake.nix
+
+PATH_add ./target/
+
+if on_git_branch; then
+  echo && git status --short --branch &&
+  echo && git fetch --verbose
+fi
diff --git a/templates/c/.gitignore b/templates/c/.gitignore
new file mode 100644
index 0000000..8dad36b
--- /dev/null
+++ b/templates/c/.gitignore
@@ -0,0 +1,7 @@
+# build
+/target
+/result
+
+# dev env
+.direnv
+.ccls-cache
diff --git a/templates/c/.licensure.yml b/templates/c/.licensure.yml
new file mode 100644
index 0000000..6c8dcfc
--- /dev/null
+++ b/templates/c/.licensure.yml
@@ -0,0 +1,159 @@
+---
+# Regexes which if matched by a file path will always be excluded from
+# getting a license header
+excludes:
+  - .*lock
+  - \.git/.*
+  - LICENSE.spdx
+  - COPYING
+  - COPYING.LESSER
+  - .*\.(rst|txt|pdf)
+# Definition of the licenses used on this project and to what files
+# they should apply.
+#
+# No default license configuration is provided. This section must be
+# configured by the user.
+licenses:
+  # Either a regex or the string "any" to determine to what files this
+  # license should apply. It is common for projects to have files
+  # under multiple licenses or with multiple copyright holders. This
+  # provides the ability to automatically license files correctly
+  # based on their file paths.
+  #
+  # If "any" is provided all files will match this license.
+  - files: any
+    #
+    #   The license identifier, a list of common identifiers can be
+    #   found at: https://spdx.org/licenses/ but existence of the ident
+    #   in this list it is not enforced unless auto_template is set to
+    #   true.
+    ident: GPL-3.0-or-later
+    #
+    #   A list of authors who hold copyright over these files
+    authors:
+      # Provide either your full name or company name for copyright purposes
+      - name: Benedikt Peetz
+        # Optionally provide email for copyright purposes
+        email: "benedikt.peetz@b-peetz.de"
+
+    #   The template that will be rendered to generate the header before
+    #   comment characters are applied. Available variables are:
+    #    - [year]: substituted with the current year.
+    #    - [name of author]: Substituted with name of the author and email
+    #      if provided. If email is provided the output appears as Full
+    #      Name <email@example.com>. If multiple authors are provided the
+    #      list is concatenated together with commas.
+    template: |
+        Copyright (C) 2023 - [year]:
+        [name of author]
+        SPDX-License-Identifier: GPL-3.0-or-later
+
+        This file is part of the TODO.
+
+        Trixy is free software: you can redistribute it and/or modify
+        it under the terms of the Lesser GNU General Public License as
+        published by the Free Software Foundation, either version 3 of
+        the License, or (at your option) any later version.
+
+        This program is distributed in the hope that it will be useful,
+        but WITHOUT ANY WARRANTY; without even the implied warranty of
+        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        GNU General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        and the Lesser GNU General Public License along with this program.
+        If not, see <https://www.gnu.org/licenses/>.
+
+
+    #   If auto_template is true then template is ignored and the SPDX
+    #   API will be queried with the ident value to automatically
+    #   determine the license header template. auto_template works best
+    #   with licenses that have a standardLicenseHeader field defined in
+    #   their license info JSON, if it is not then we will use the full
+    #   licenseText to generate the header which works fine for short
+    #   licenses like MIT but can be quite lengthy for other licenses
+    #   like BSD-4-Clause. The above default template is valid for most
+    #   licenses and is recommended for MIT, and BSD licenses. Common
+    #   licenses that work well with the auto_template feature are GPL
+    #   variants, and the Apache 2.0 license.
+    #
+    #   Important Note: this means the ident must be a valid SPDX identifier
+    # auto_template: true
+
+    #   If true try to detect the text wrapping of the template, and unwrap it
+    unwrap_text: false
+
+# Define type of comment characters to apply based on file extensions.
+comments:
+  # The extensions (or singular extension) field defines which file
+  # extensions to apply the commenter to.
+  - extensions:
+      - js
+      - go
+    # The commenter field defines the kind of commenter to
+    # generate. There are two types of commenters: line and block.
+    #
+    # This demonstrates a line commenter configuration. A line
+    # commenter type will apply the comment_char to the beginning of
+    # each line in the license header. It will then apply a number of
+    # empty newlines to the end of the header equal to trailing_lines.
+    #
+    # If trailing_lines is omitted it is assumed to be 0.
+    commenter:
+      type: line
+      comment_char: "//"
+      trailing_lines: 1
+
+  - extensions:
+      - rs
+      - tri
+      - css
+      - cpp
+      - c
+      - h
+    # This demonstrates a block commenter configuration. A block
+    # commenter type will add start_block_char as the first character
+    # in the license header and add end_block_char as the last character
+    # in the license header. If per_line_char is provided each line of
+    # the header between the block start and end characters will be
+    # line commented with the per_line_char
+    #
+    # trailing_lines works the same for both block and line commenter
+    # types
+    commenter:
+      type: block
+      start_block_char: "/*\n"
+      end_block_char: "*/\n"
+      per_line_char: "*"
+      trailing_lines: 1
+
+  - extension:
+      - html
+      - md
+    commenter:
+      type: block
+      start_block_char: "<!--\n"
+      end_block_char: "-->\n"
+      trailing_lines: 1
+
+  - extensions:
+      - el
+      - lisp
+    commenter:
+      type: line
+      comment_char: ";;;"
+      trailing_lines: 1
+
+  # The extension string "any" is special and so will match any file
+  # extensions. Commenter configurations are always checked in the
+  # order they are defined, so if any is used it should be the last
+  # commenter configuration or else it will override all others.
+  #
+  # In this configuration if we can't match the file extension we fall
+  # back to the popular '#' line comment used in most scripting
+  # languages.
+  - extension: any
+    commenter:
+      type: line
+      comment_char: '#'
+      trailing_lines: 1
diff --git a/c/COPYING b/templates/c/COPYING
index f288702..f288702 100644
--- a/c/COPYING
+++ b/templates/c/COPYING
diff --git a/templates/c/LICENSE.spdx b/templates/c/LICENSE.spdx
new file mode 100644
index 0000000..ecb7d83
--- /dev/null
+++ b/templates/c/LICENSE.spdx
@@ -0,0 +1,7 @@
+SPDXVersion: SPDX-2.3
+DataLicense: CC0-1.0
+Creator: TODO
+PackageName: TODO
+PackageOriginator: TODO
+PackageHomePage: TODO
+PackageLicenseDeclared: GPL-3.0-or-later
diff --git a/templates/c/Makefile b/templates/c/Makefile
new file mode 100644
index 0000000..4a37b4b
--- /dev/null
+++ b/templates/c/Makefile
@@ -0,0 +1,60 @@
+PREFIX    := /usr/local
+BINPREFIX := $(DESTDIR)$(PREFIX)/bin
+MANPREFIX := $(DESTDIR)$(PREFIX)/share/man/man1
+
+BIN_NAME := TODO
+# The trailing slash is important
+BUILD_DIR := ./target/
+BIN_PATH := $(BUILD_DIR)$(BIN_NAME)
+
+
+SRC := $(wildcard src/*.c)
+OBJ := $(SRC:.c=.o)
+DEP := $(OBJ:.o=.d)
+
+LIBS :=
+
+ALL_CFLAGS  := -O3 -MMD -Wall -Wextra -Wno-unused-parameter $(CFLAGS) $(CPPFLAGS)
+ALL_LDFLAGS := $(addprefix -l,$(LIBS)) -L $(LD_LIBRARY_PATH) $(LDFLAGS)
+
+
+$(BIN_NAME): $(OBJ)
+	$(CC) $(addprefix $(BUILD_DIR),$(notdir $(OBJ))) -o $(addprefix $(BUILD_DIR),$(notdir $(BIN_NAME))) $(ALL_CFLAGS) $(ALL_LDFLAGS)
+
+$(OBJ): $(SRC)
+	mkdir --parents $(BUILD_DIR)
+	$(CC) -c $< -o $(addprefix $(BUILD_DIR),$(notdir $(OBJ))) $(ALL_CFLAGS)
+
+manual:
+	mkdir --parents $(BUILD_DIR)docs
+	pandoc "./docs/$(BIN_NAME).1.md" -s -t man > $(BUILD_DIR)docs/$(BIN_NAME).1
+
+.PHONY : clean options install memory_leak_test
+options:
+	@echo "PREFIX    = $(PREFIX)"
+	@echo "BINPREFIX = $(BINPREFIX)"
+	@echo "MANPREFIX = $(MANPREFIX)"
+	@echo ""
+	@echo "BIN_NAME = $(BIN_NAME)"
+	@echo "BUILD_DIR = $(BUILD_DIR)"
+	@echo "BIN_PATH = $(BIN_PATH)"
+	@echo ""
+	@echo "SRC = $(SRC)"
+	@echo "OBJ = $(OBJ)"
+	@echo "DEP = $(DEP)"
+	@echo ""
+	@echo "LIBS = $(LIBS)"
+	@echo ""
+	@echo "ALL_CFLAGS  = $(ALL_CFLAGS)"
+	@echo "ALL_LDFLAGS = $(ALL_LDFLAGS)"
+	@echo ""
+
+clean :
+	rm --recursive $(BUILD_DIR)
+
+install: $(BIN_NAME) manual
+	install -D $(BUILD_DIR)docs/$(BIN_NAME).1  $(MANPREFIX)/$(BIN_NAME);
+	install -D $(BUILD_DIR)$(BIN_NAME)  $(BINPREFIX)/$(BIN_NAME);
+
+memory_leak_test:
+	sh ./scripts/valgrind_test.sh $(BIN_NAME)
diff --git a/templates/c/README.md b/templates/c/README.md
new file mode 100644
index 0000000..5912c16
--- /dev/null
+++ b/templates/c/README.md
@@ -0,0 +1,10 @@
+# TODO
+
+Some text about the project.
+
+## Licence
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/templates/c/cog.toml b/templates/c/cog.toml
new file mode 100644
index 0000000..d34ced6
--- /dev/null
+++ b/templates/c/cog.toml
@@ -0,0 +1,25 @@
+tag_prefix = "v"
+branch_whitelist = ["main", "prime"]
+ignore_merge_commits = false
+
+[commit_types]
+
+pre_bump_hooks = [
+  "nix flake check",                # verify the project builds
+  "./scripts/renew_copyright_header.sh", # update the license header in each file
+  "nix fmt",                        # format
+]
+post_bump_hooks = [
+  "git push",
+  "git push origin v{{version}}", # push the new tag to origin
+]
+
+[bump_profiles]
+
+[changelog]
+path = "NEWS.md"
+template = "remote"
+remote = "TODO"
+repository = "TODO"
+owner = "TODO"
+authors = [{ signature = "Benedikt Peetz", username = "bpeetz" }]
diff --git a/templates/c/docs/TODO.1.md b/templates/c/docs/TODO.1.md
new file mode 100644
index 0000000..e14fec5
--- /dev/null
+++ b/templates/c/docs/TODO.1.md
@@ -0,0 +1,70 @@
+% FUPDATE(1) fupdate 1.0.0
+% Benedikt Peetz
+% May 2023
+
+# NAME
+
+fupdate - updates your flake, while checking for common mistakes
+
+# SYNOPSIS
+
+**fupdate** list of \[*flake*|*\<some word>*|*--help*|*-h*\]
+
+# DESCRIPTION
+
+Argument can be stacked, this makes it possible to specify multiple targets to be updated in succession. See the Examples section for further details.
+
+No argument or *flake*
+: **fupdate**, when executed without arguments or with *flake*, will update your *flake.lock*, check for duplicate flake inputs, i.e., an input has an input declared, which you have also declared as input, and will run a script called *update.sh*, if you allow it.
+The allowance for the script is asked, when you run **fupdate** and the found script is not yet allowed. Furthermore, the allowance is based on the concrete sha256 hash of the script, so any changes will require another allowance.
+
+**\<some word>** as argument
+: If the executable **update-\<some word>** is reachable thought the PATH variable, than this is run. Otherwise, the program will exit.
+
+# OPTIONS
+
+**--help**, **-h**
+: Displays a help message and exit.
+
+**--version**, **-v**
+: Displays the software version and exit.
+
+# EXAMPLES
+
+**fupdate** or **fupdate flake**
+: Updates your *flake.lock*. See the Description section for further details.
+
+**fupdate sys**
+: Run the executable **update-sys**, if it exists. See the Description section for further details.
+
+**fupdate flake sys docs**
+: First updates your flake, then, if the command succeeded, runs **update-sys**, afterweich **update-docs** is run.
+
+# FILES
+
+*update.sh*
+: This is supposed to be a shell script located in your flake base directory, i.e., the directory which contains both a *flake.nix* and a *flake.lock* file.
+
+*~/.local/share/flake-update/*
+: **fupdate** will store the hashes to the allowed *update.sh* files here.
+
+# BUGS
+
+Report bugs to <https://codeberg.org/soispha/flake_update/issues>.
+
+# COPYRIGHT
+
+Copyright (C) 2023  Benedikt Peetz
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <https://www.gnu.org/licenses/>.
diff --git a/templates/c/flake.lock b/templates/c/flake.lock
new file mode 100644
index 0000000..0f32b70
--- /dev/null
+++ b/templates/c/flake.lock
@@ -0,0 +1,102 @@
+{
+  "nodes": {
+    "flake-compat": {
+      "flake": false,
+      "locked": {
+        "lastModified": 1696426674,
+        "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
+        "owner": "edolstra",
+        "repo": "flake-compat",
+        "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
+        "type": "github"
+      },
+      "original": {
+        "owner": "edolstra",
+        "repo": "flake-compat",
+        "type": "github"
+      }
+    },
+    "flake-utils": {
+      "inputs": {
+        "systems": [
+          "systems"
+        ]
+      },
+      "locked": {
+        "lastModified": 1710146030,
+        "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1711715736,
+        "narHash": "sha256-9slQ609YqT9bT/MNX9+5k5jltL9zgpn36DpFB7TkttM=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "807c549feabce7eddbf259dbdcec9e0600a0660d",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixpkgs-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-compat": "flake-compat",
+        "flake-utils": "flake-utils",
+        "nixpkgs": "nixpkgs",
+        "systems": "systems",
+        "treefmt-nix": "treefmt-nix"
+      }
+    },
+    "systems": {
+      "locked": {
+        "lastModified": 1680978846,
+        "narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=",
+        "owner": "nix-systems",
+        "repo": "x86_64-linux",
+        "rev": "2ecfcac5e15790ba6ce360ceccddb15ad16d08a8",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "x86_64-linux",
+        "type": "github"
+      }
+    },
+    "treefmt-nix": {
+      "inputs": {
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1711803027,
+        "narHash": "sha256-Qic3OvsVLpetchzaIe2hJqgliWXACq2Oee6mBXa/IZQ=",
+        "owner": "numtide",
+        "repo": "treefmt-nix",
+        "rev": "1810d51a015c1730f2fe05a255258649799df416",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "treefmt-nix",
+        "type": "github"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/c/flake.nix b/templates/c/flake.nix
index 0eab217..cd4200c 100644
--- a/c/flake.nix
+++ b/templates/c/flake.nix
@@ -1,9 +1,16 @@
 {
-  description = "<Project description>";
+  description = "TODO";
 
   inputs = {
     nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
 
+    treefmt-nix = {
+      url = "github:numtide/treefmt-nix";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+      };
+    };
+
     # inputs for following
     systems = {
       url = "github:nix-systems/x86_64-linux"; # only evaluate for this system
@@ -24,29 +31,41 @@
     self,
     nixpkgs,
     flake-utils,
+    treefmt-nix,
     ...
   }:
     flake-utils.lib.eachDefaultSystem (system: let
       pkgs = nixpkgs.legacyPackages."${system}";
 
-      nativeBuildInputs = with pkgs; [valgrind];
-    in {
-      packages.default = pkgs.stdenv.mkDerivation {
+      nativeBuildInputs = with pkgs; [valgrind pandoc];
+      treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};
+
+      pname = "TODO";
+      version = "0.1";
+
+      build = pkgs.stdenv.mkDerivation {
+        inherit pname version;
+
         src = ./.;
-        pname = "<pkgs_name>";
-        version = "0.1";
         makeFlags = ["PREFIX=${placeholder "out"}"];
         inherit nativeBuildInputs;
       };
-      apps.default = {
-        type = "app";
-        program = "${self.packages.${system}.default}/bin/<pkgs_name>";
+    in {
+      packages.default = build;
+      checks = {
+        inherit build;
+        formatting = treefmtEval.config.build.check self;
       };
+      formatter = treefmtEval.config.build.wrapper;
+
       devShells.default = pkgs.mkShell {
         packages = with pkgs; [
           cocogitto
         ];
         inherit nativeBuildInputs;
+        env = {
+          GCC_COLORS = "error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01";
+        };
       };
     });
 }
diff --git a/templates/c/scripts/renew_copyright_header.sh b/templates/c/scripts/renew_copyright_header.sh
new file mode 120000
index 0000000..f286da9
--- /dev/null
+++ b/templates/c/scripts/renew_copyright_header.sh
@@ -0,0 +1 @@
+../../../common/renew_copyright_header.sh
\ No newline at end of file
diff --git a/templates/c/scripts/valgrind_test.sh b/templates/c/scripts/valgrind_test.sh
new file mode 100755
index 0000000..4d0d964
--- /dev/null
+++ b/templates/c/scripts/valgrind_test.sh
@@ -0,0 +1,29 @@
+#! /usr/bin/env sh
+
+for arg in "$@"; do
+    case "$arg" in
+    "--help" | "-h")
+        cat <<-EOF
+            valgrind_test.sh [BINARY_NAME] [ARGS_FOR_BINARY..]
+EOF
+        exit 0
+        ;;
+    esac
+done
+
+binary_name="${1-main}"
+[ -n "$1" ] && shift 1
+
+log_file="$(git rev-parse --show-toplevel)/target/valgrind_out.report"
+mkdir --parents "$(dirname "$log_file")"
+
+CFLAGS="-ggdb3" make "$binary_name"
+
+valgrind --leak-check=full \
+    --show-leak-kinds=all \
+    --show-error-list=yes \
+    --track-origins=yes \
+    --log-file="$log_file" \
+    "./target/$binary_name" "$@"
+
+cat "$log_file"
diff --git a/templates/c/src/main.c b/templates/c/src/main.c
new file mode 100644
index 0000000..f8d8fb7
--- /dev/null
+++ b/templates/c/src/main.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main ()
+{
+  printf ("Hello World!\n");
+
+  return EXIT_SUCCESS;
+}
diff --git a/templates/c/treefmt.nix b/templates/c/treefmt.nix
new file mode 120000
index 0000000..6a4fe7d
--- /dev/null
+++ b/templates/c/treefmt.nix
@@ -0,0 +1 @@
+../../treefmt.nix
\ No newline at end of file
diff --git a/templates/c/update.sh b/templates/c/update.sh
new file mode 100755
index 0000000..49216b8
--- /dev/null
+++ b/templates/c/update.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env sh
+
+nix flake update