diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index c6127b3..d62ec78 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.direnv +.ccls-cache +compile_commands.json # Prerequisites *.d diff --git a/Makefile b/Makefile index a4b8202..7fa9ed9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # ----- Variables for customization ----- CC = gcc # Compiler (you can change to clang if desired) -CFLAGS = -g3 -Wall -Wextra -fsanitize=address,undefined # Standard flags + debugging & warnings +CFLAGS = -g2 -Wall -Wextra #-fsanitize=address # Standard flags + debugging & warnings LDFLAGS = # Linker flags, if any # ----- Automatic dependency tracking ----- @@ -9,14 +9,14 @@ OBJS := $(SRCS:.c=.o) # Corresponding object files (.o) HDRS := $(SRCS:.c=.h) # ----- Targets ----- -server: $(OBJS) - $(CC) $(CFLAGS) $(OBJS) -o server $(LDFLAGS) +server: $(OBJS) + $(CC) $(CFLAGS) $(OBJS) -o server $(LDFLAGS) # Create object files from source files %.o: %.c %.h $(CC) $(CFLAGS) -c $< -o $@ -# Phony target for cleaning +# Phony target for cleaning .PHONY: clean clean: - rm -f $(OBJS) server + rm -f $(OBJS) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..86ed220 --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1721379653, + "narHash": "sha256-8MUgifkJ7lkZs3u99UDZMB4kbOxvMEXQZ31FO3SopZ0=", + "rev": "1d9c2c9b3e71b9ee663d11c5d298727dace8d374", + "revCount": 655136, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.655136%2Brev-1d9c2c9b3e71b9ee663d11c5d298727dace8d374/0190cd4f-c0eb-72cb-834b-ac854aa282dc/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7b99041 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + description = "A Nix-flake-based C/C++ development environment"; + + inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz"; + + outputs = { self, nixpkgs }: + let + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { inherit system; }; + }); + in + { + devShells = forEachSupportedSystem ({ pkgs }: { + default = pkgs.mkShell.override + { + # Override stdenv in order to change compiler: + # stdenv = pkgs.clangStdenv; + } + { + packages = with pkgs; [ + clang-tools + cmake + codespell + conan + cppcheck + doxygen + gtest + lcov + vcpkg + vcpkg-tool + ccls + bear + ] ++ (if system == "aarch64-darwin" then [ ] else [ gdb ]); + }; + }); + }; +} + diff --git a/server b/server index 2acf998..b9198f5 100755 Binary files a/server and b/server differ