diff --git a/c/.envrc b/c/.envrc new file mode 100644 index 0000000..e31c306 --- /dev/null +++ b/c/.envrc @@ -0,0 +1,4 @@ +if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" +fi +use flake diff --git a/c/Makefile b/c/Makefile new file mode 100644 index 0000000..76ba218 --- /dev/null +++ b/c/Makefile @@ -0,0 +1,16 @@ +all: main + +CC = clang +override CFLAGS += -g -Wno-everything -pthread -lm + +SRCS = $(shell find . -name '.ccls-cache' -type d -prune -o -type f -name '*.c' -print) +HEADERS = $(shell find . -name '.ccls-cache' -type d -prune -o -type f -name '*.h' -print) + +main: $(SRCS) $(HEADERS) + $(CC) $(CFLAGS) $(SRCS) -o "$@" + +main-debug: $(SRCS) $(HEADERS) + $(CC) $(CFLAGS) -O0 $(SRCS) -o "$@" + +clean: + rm -f main main-debug \ No newline at end of file diff --git a/c/flake.nix b/c/flake.nix new file mode 100644 index 0000000..0d416ec --- /dev/null +++ b/c/flake.nix @@ -0,0 +1,13 @@ +{ + description = "Flake template for a devShell"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = import nixpkgs { inherit system; }; + in with pkgs; { devShells.default = mkShell { packages = [ clang_12 ccls gdb gnumake ]; }; }); +} diff --git a/flake.nix b/flake.nix index 9c77ef7..5b665fa 100644 --- a/flake.nix +++ b/flake.nix @@ -3,17 +3,21 @@ outputs = { self }: { templates = { + c = { + path = ./c; + description = "Template for a C project"; + }; package = { path = ./package; description = "Template for a nix package"; }; python = { path = ./python; - description = "Template to python project"; + description = "Template for a python project"; }; rust = { path = ./rust; - description = "Rust template, using oxalica/rust-overlay"; + description = "Template for a rust project, using oxalica/rust-overlay"; }; shell = { path = ./shell; diff --git a/python/.envrc b/python/.envrc new file mode 100644 index 0000000..e31c306 --- /dev/null +++ b/python/.envrc @@ -0,0 +1,4 @@ +if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" +fi +use flake