added stuff

This commit is contained in:
Charlie Root 2024-04-09 23:11:33 +02:00
commit 9d0ebdfbd0
907 changed files with 70990 additions and 0 deletions

View file

@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.c]
ident_style = space
ident_size = 4
[Makefile*]
ident_style = tab
ident_size = 4

3
nyx/flake/templates/c/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
# ignore build artifacts
result
build

View file

@ -0,0 +1,9 @@
{clangStdenv}:
clangStdenv.mkDerivation {
pname = "sample-c-cpp";
version = "0.0.1";
src = ./.;
makeFlags = ["PREFIX=$(out)"];
}

View file

@ -0,0 +1,25 @@
{
description = "C/C++ Project Template";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
};
outputs = {
self,
nixpkgs,
...
}: let
systems = ["x86_64-linux" "aarch64-linux"];
forEachSystem = nixpkgs.lib.genAttrs systems;
pkgsForEach = nixpkgs.legacyPackages;
in {
packages = forEachSystem (system: {
default = pkgsForEach.${system}.callPackage ./default.nix {};
});
devShells = forEachSystem (system: {
default = pkgsForEach.${system}.callPackage ./shell.nix {};
});
};
}

View file

@ -0,0 +1,42 @@
PREFIX ?= /usr/local # this is overriden by the derivation makeFlags
BIN_DIR ?= $(PREFIX)/bin
TARGET_EXEC ?= foo-bar
BUILD_DIR ?= ./build
SRC_DIRS ?= ./src
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c)
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
$(CXX) $(OBJS) -o $@ $(LDFLAGS)
# c source
$(BUILD_DIR)/%.c.o: %.c
mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
# c++ source
$(BUILD_DIR)/%.cpp.o: %.cpp
mkdir -p $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
.PHONY: clean install run
clean:
rm -r $(BUILD_DIR)
install: $(BUILD_DIR)/$(TARGET_EXEC)
install -Dt $(BIN_DIR) $<
run: $(BUILD_DIR)/$(TARGET_EXEC)
./$<
-include $(DEPS)

View file

@ -0,0 +1,36 @@
{
callPackage,
clang-tools,
gnumake,
cmake,
bear,
libcxx,
cppcheck,
llvm,
gdb,
glm,
SDL2,
SDL2_gfx,
}: let
mainPkg = callPackage ./default.nix {};
in
mainPkg.overrideAttrs (oa: {
nativeBuildInputs =
[
clang-tools # fix headers not found
gnumake # builder
cmake # another builder
bear # bear.
libcxx # stdlib for cpp
cppcheck # static analysis
llvm.lldb # debugger
gdb # another debugger
llvm.libstdcxxClang # LSP and compiler
llvm.libcxx # stdlib for C++
# libs
glm
SDL2
SDL2_gfx
]
++ (oa.nativeBuildInputs or []);
})

View file

@ -0,0 +1,7 @@
#include <iostream>
int main() {
std::cout << "Hello, World!";
return 0;
}