added stuff
This commit is contained in:
parent
6d31f5b5a1
commit
7d4f626b7d
907 changed files with 70990 additions and 0 deletions
15
nyx/flake/templates/c/.editorconfig
Normal file
15
nyx/flake/templates/c/.editorconfig
Normal 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
3
nyx/flake/templates/c/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# ignore build artifacts
|
||||
result
|
||||
build
|
9
nyx/flake/templates/c/default.nix
Normal file
9
nyx/flake/templates/c/default.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
{clangStdenv}:
|
||||
clangStdenv.mkDerivation {
|
||||
pname = "sample-c-cpp";
|
||||
version = "0.0.1";
|
||||
|
||||
src = ./.;
|
||||
|
||||
makeFlags = ["PREFIX=$(out)"];
|
||||
}
|
25
nyx/flake/templates/c/flake.nix
Normal file
25
nyx/flake/templates/c/flake.nix
Normal 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 {};
|
||||
});
|
||||
};
|
||||
}
|
42
nyx/flake/templates/c/makefile
Normal file
42
nyx/flake/templates/c/makefile
Normal 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)
|
36
nyx/flake/templates/c/shell.nix
Normal file
36
nyx/flake/templates/c/shell.nix
Normal 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 []);
|
||||
})
|
7
nyx/flake/templates/c/src/main.cpp
Normal file
7
nyx/flake/templates/c/src/main.cpp
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello, World!";
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue