From ebdb09b5287627ea7d1d0091ca73fe58c6fc8845 Mon Sep 17 00:00:00 2001 From: Evan Fiordeliso Date: Tue, 28 Nov 2023 11:17:34 -0500 Subject: [PATCH] Initial commit --- .envrc | 3 + .gitea/template | 3 + .gitignore | 72 +++++++++++++++++++ .vscode/extensions.json | 6 ++ .vscode/settings.json | 4 ++ WORKSPACE | 21 ++++++ devenv.lock | 156 ++++++++++++++++++++++++++++++++++++++++ devenv.nix | 44 ++++++++++++ devenv.yaml | 3 + main/$REPO_NAME.c | 5 ++ main/BUILD | 6 ++ 11 files changed, 323 insertions(+) create mode 100644 .envrc create mode 100644 .gitea/template create mode 100644 .gitignore create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 WORKSPACE create mode 100644 devenv.lock create mode 100644 devenv.nix create mode 100644 devenv.yaml create mode 100644 main/$REPO_NAME.c create mode 100644 main/BUILD diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..6de8a8a --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0=" + +use devenv \ No newline at end of file diff --git a/.gitea/template b/.gitea/template new file mode 100644 index 0000000..64f6481 --- /dev/null +++ b/.gitea/template @@ -0,0 +1,3 @@ +**.c +**.nix +main/BUILD \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b0669b --- /dev/null +++ b/.gitignore @@ -0,0 +1,72 @@ +# Created by https://www.toptal.com/developers/gitignore/api/c +# Edit at https://www.toptal.com/developers/gitignore?templates=c + +### C ### +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +# End of https://www.toptal.com/developers/gitignore/api/c + +# Ignore all bazel-* symlinks. There is no full list since this can change +# based on the name of the directory bazel is cloned into. +/bazel-* + +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..3c31087 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "bazelbuild.vscode-bazel", + "ms-vscode.cpptools" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..8c228c4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "bazel.buildifierExecutable": ".devenv/profile/bin/buildifier", + "bazel.executable": ".devenv/profile/bin/bazel" +} \ No newline at end of file diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..314a00f --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,21 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "aspect_gcc_toolchain", + sha256 = "3341394b1376fb96a87ac3ca01c582f7f18e7dc5e16e8cf40880a31dd7ac0e1e", + strip_prefix = "gcc-toolchain-0.4.2", + urls = [ + "https://github.com/aspect-build/gcc-toolchain/archive/refs/tags/0.4.2.tar.gz", + ], +) + +load("@aspect_gcc_toolchain//toolchain:repositories.bzl", "gcc_toolchain_dependencies") + +gcc_toolchain_dependencies() + +load("@aspect_gcc_toolchain//toolchain:defs.bzl", "gcc_register_toolchain", "ARCHS") + +gcc_register_toolchain( + name = "gcc_toolchain_x86_64", + target_arch = ARCHS.x86_64, +) \ No newline at end of file diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..a0c5c8c --- /dev/null +++ b/devenv.lock @@ -0,0 +1,156 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1701106322, + "narHash": "sha256-Xgl3mNDpW6MNCmtmP5R6FqEe6B/zI/kCSTgHlXzDyyE=", + "owner": "cachix", + "repo": "devenv", + "rev": "263efe1290b8481cd6d5d814b4655ce332b7f8b1", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1701040486, + "narHash": "sha256-vawYwoHA5CwvjfqaT3A5CT9V36Eq43gxdwpux32Qkjw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "45827faa2132b8eade424f6bdd48d8828754341a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1685801374, + "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1700922917, + "narHash": "sha256-ej2fch/T584b5K9sk1UhmZF7W6wEfDHuoUYpFN8dtvM=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "e5ee5c5f3844550c01d2131096c7271cec5e9b78", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..953bc33 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,44 @@ +{ pkgs, ... }: + +{ + # https://devenv.sh/basics/ + env.NAME = "$REPO_NAME"; + + # https://devenv.sh/packages/ + packages = with pkgs; [ + git + bazel + bazel-buildtools + ]; + + # https://devenv.sh/scripts/ + scripts.welcome-banner.exec = '' + echo "Welcome to the $NAME development environment." + echo "Bazel version: $(bazel --version | cut -d ' ' -f 2)" + ''; + + scripts.build.exec = '' + bazel build //main:$NAME + ''; + + scripts.clean.exec = '' + bazel clean + ''; + + scripts.clean-build.exec = "clean && build"; + + enterShell = '' + welcome-banner + ''; + + # https://devenv.sh/languages/ + # languages.nix.enable = true; + + # https://devenv.sh/pre-commit-hooks/ + # pre-commit.hooks.shellcheck.enable = true; + + # https://devenv.sh/processes/ + # processes.ping.exec = "ping example.com"; + + # See full reference at https://devenv.sh/reference/options/ +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..c7cb5ce --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,3 @@ +inputs: + nixpkgs: + url: github:NixOS/nixpkgs/nixpkgs-unstable diff --git a/main/$REPO_NAME.c b/main/$REPO_NAME.c new file mode 100644 index 0000000..aa2373d --- /dev/null +++ b/main/$REPO_NAME.c @@ -0,0 +1,5 @@ +#include + +int main(int argc, char **argv) { + printf("Hello, World!\n"); +} \ No newline at end of file diff --git a/main/BUILD b/main/BUILD new file mode 100644 index 0000000..800b14d --- /dev/null +++ b/main/BUILD @@ -0,0 +1,6 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") + +cc_binary( + name = "$REPO_NAME", + srcs = ["$REPO_NAME.c"], +) \ No newline at end of file