From c1524d5bd9b8035d51107112c52066bb8ef5ea13 Mon Sep 17 00:00:00 2001 From: Sigmanificient Date: Mon, 6 May 2024 23:40:38 +0200 Subject: [PATCH] feat(c): add configuration files --- c/.editorconfig | 22 ++++++++++++++++++++++ c/.gitattributes | 2 ++ c/.gitignore | 15 +++++++++++++++ c/Dockerfile | 29 +++++++++++++++++++++++++++++ c/tokei.toml | 4 ++++ 5 files changed, 72 insertions(+) create mode 100644 c/.editorconfig create mode 100644 c/.gitattributes create mode 100644 c/.gitignore create mode 100644 c/Dockerfile create mode 100644 c/tokei.toml diff --git a/c/.editorconfig b/c/.editorconfig new file mode 100644 index 0000000..318b9fc --- /dev/null +++ b/c/.editorconfig @@ -0,0 +1,22 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +max_line_length = 80 +tab_width = 4 + +[{Makefile,*.mk}] +indent_style = tab + +[*.nix] +indent_style = space +tab_width = 2 +indent_size = 2 + +[*.lock] +indent_style = unset +insert_final_newline = unset diff --git a/c/.gitattributes b/c/.gitattributes new file mode 100644 index 0000000..1457a77 --- /dev/null +++ b/c/.gitattributes @@ -0,0 +1,2 @@ +* text=lf +* eol=lf diff --git a/c/.gitignore b/c/.gitignore new file mode 100644 index 0000000..fc5e2c9 --- /dev/null +++ b/c/.gitignore @@ -0,0 +1,15 @@ +# binaries +hello + +# build +*.[aod] + +# config +compile_commands.json +.pre-commit-config.yaml +.cache + +# nix +.direnv +.envrc +result diff --git a/c/Dockerfile b/c/Dockerfile new file mode 100644 index 0000000..4551ac5 --- /dev/null +++ b/c/Dockerfile @@ -0,0 +1,29 @@ +# Credit to Mitchell Hashimoto +# post: https://mitchellh.com/writing/nix-with-dockerfiles + +# Nix builder +FROM nixos/nix:latest AS builder + +# Copy our source and setup our working dir. +COPY . /tmp/build +WORKDIR /tmp/build + +# Build our Nix environment +RUN nix \ + --extra-experimental-features "nix-command flakes" \ + --option filter-syscalls false \ + build + +# Copy the Nix store closure into a directory. The Nix store closure is the +# entire set of Nix store values that we need for our build. +RUN mkdir /tmp/nix-store-closure +RUN cp -R $(nix-store -qR result/) /tmp/nix-store-closure + +# Final image is based on scratch. We copy a bunch of Nix dependencies +# but they're fully self-contained so we don't need Nix anymore. +FROM scratch + +# Copy /nix/store +COPY --from=builder /tmp/nix-store-closure /nix/store +COPY --from=builder /tmp/build/result /app +CMD ["/app/bin/hello"] diff --git a/c/tokei.toml b/c/tokei.toml new file mode 100644 index 0000000..8f7e17d --- /dev/null +++ b/c/tokei.toml @@ -0,0 +1,4 @@ +columns = 80 +sort = "lines" +types = ["C", "C Header", "Makefile", "Markdown"] +treat_doc_strings_as_comments = true