-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy a bunch of templates over. Would like to take advantage of this more.
- Loading branch information
1 parent
ad0e40f
commit 161ec53
Showing
54 changed files
with
3,318 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
prefix = @prefix@ | ||
exec_prefix = @exec_prefix@ | ||
bindir = @bindir@ | ||
|
||
hello: hello.c | ||
$(CC) -Wall -O3 -o hello hello.c | ||
|
||
clean: | ||
rm -f hello | ||
|
||
install: hello | ||
install -d $(bindir) | ||
install -t $(bindir) hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AC_INIT([Hello], 1.0) | ||
AC_PROG_CC | ||
AC_CONFIG_FILES(Makefile) | ||
AC_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
{ | ||
description = "An over-engineered Hello World in C"; | ||
|
||
# Nixpkgs / NixOS version to use. | ||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; | ||
|
||
outputs = | ||
{ self, nixpkgs }: | ||
let | ||
|
||
# to work with older version of flakes | ||
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101"; | ||
|
||
# Generate a user-friendly version number. | ||
version = builtins.substring 0 8 lastModifiedDate; | ||
|
||
# System types to support. | ||
supportedSystems = [ | ||
"x86_64-linux" | ||
"x86_64-darwin" | ||
"aarch64-linux" | ||
"aarch64-darwin" | ||
]; | ||
|
||
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. | ||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; | ||
|
||
# Nixpkgs instantiated for supported system types. | ||
nixpkgsFor = forAllSystems ( | ||
system: | ||
import nixpkgs { | ||
inherit system; | ||
overlays = [ self.overlay ]; | ||
} | ||
); | ||
in | ||
|
||
{ | ||
|
||
# A Nixpkgs overlay. | ||
overlay = final: _prev: { | ||
|
||
hello = | ||
with final; | ||
stdenv.mkDerivation rec { | ||
pname = "hello"; | ||
inherit version; | ||
|
||
src = ./.; | ||
|
||
nativeBuildInputs = [ autoreconfHook ]; | ||
}; | ||
}; | ||
|
||
# Provide some binary packages for selected system types. | ||
packages = forAllSystems (system: { | ||
inherit (nixpkgsFor.${system}) hello; | ||
}); | ||
|
||
# The default package for 'nix build'. This makes sense if the | ||
# flake provides only one package or there is a clear "main" | ||
# package. | ||
defaultPackage = forAllSystems (system: self.packages.${system}.hello); | ||
|
||
# A NixOS module, if applicable (e.g. if the package provides a system service). | ||
nixosModules.hello = | ||
{ pkgs, ... }: | ||
{ | ||
nixpkgs.overlays = [ self.overlay ]; | ||
|
||
environment.systemPackages = [ pkgs.hello ]; | ||
|
||
#systemd.services = { ... }; | ||
}; | ||
|
||
# Tests run by 'nix flake check' and by Hydra. | ||
checks = forAllSystems ( | ||
system: | ||
with nixpkgsFor.${system}; | ||
|
||
{ | ||
inherit (self.packages.${system}) hello; | ||
|
||
# Additional tests, if applicable. | ||
test = stdenv.mkDerivation { | ||
pname = "hello-test"; | ||
inherit version; | ||
|
||
buildInputs = [ hello ]; | ||
|
||
dontUnpack = true; | ||
|
||
buildPhase = '' | ||
echo 'running some integration tests' | ||
[[ $(hello) = 'Hello Nixers!' ]] | ||
''; | ||
|
||
installPhase = "mkdir -p $out"; | ||
}; | ||
} | ||
|
||
// lib.optionalAttrs stdenv.isLinux { | ||
# A VM test of the NixOS module. | ||
vmTest = | ||
with import (nixpkgs + "/nixos/lib/testing-python.nix") { inherit system; }; | ||
|
||
makeTest { | ||
nodes = { | ||
client = | ||
{ ... }: | ||
{ | ||
imports = [ self.nixosModules.hello ]; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
start_all() | ||
client.wait_for_unit("multi-user.target") | ||
client.succeed("hello") | ||
''; | ||
}; | ||
} | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "stdio.h" | ||
|
||
int main(int argc, char **argv) { printf("Hello Nixers!\n"); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; | ||
|
||
outputs = | ||
{ self, nixpkgs }: | ||
{ | ||
|
||
nixosConfigurations.container = nixpkgs.lib.nixosSystem { | ||
system = "x86_64-linux"; | ||
modules = [ | ||
(_: { | ||
boot.isContainer = true; | ||
|
||
# Let 'nixos-version --json' know about the Git revision | ||
# of this flake. | ||
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; | ||
|
||
# Network configuration. | ||
networking.useDHCP = false; | ||
networking.firewall.allowedTCPPorts = [ 80 ]; | ||
|
||
# Enable a web server. | ||
services.httpd = { | ||
enable = true; | ||
adminAddr = "[email protected]"; | ||
}; | ||
}) | ||
]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ignore build artifacts | ||
result | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
PREFIX ?= /usr/local # this is overridden 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ clangStdenv }: | ||
clangStdenv.mkDerivation { | ||
pname = "sample-c-cpp"; | ||
version = "0.0.1"; | ||
|
||
src = ./.; | ||
|
||
makeFlags = [ "PREFIX=$(out)" ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
description = "C/C++ Project Template"; | ||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; | ||
}; | ||
|
||
outputs = | ||
{ 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 { }; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
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 [ ]); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <iostream> | ||
|
||
int main() { | ||
std::cout << "Hello, World!"; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
root=true | ||
|
||
[*] | ||
charset=utf-8 | ||
trim_trailing_whitespace=true | ||
insert_final_newline=true | ||
indent_style=space | ||
indent_size=4 | ||
|
||
# ReSharper properties | ||
resharper_xml_indent_size=2 | ||
resharper_xml_max_line_length=100 | ||
resharper_xml_tab_width=2 | ||
|
||
[*.{csproj,fsproj,sqlproj,targets,props,ts,tsx,css,json}] | ||
indent_size=2 | ||
|
||
[*.{fs,fsi}] | ||
fsharp_bar_before_discriminated_union_declaration=true | ||
fsharp_space_before_uppercase_invocation=true | ||
fsharp_space_before_class_constructor=true | ||
fsharp_space_before_member=true | ||
fsharp_space_before_colon=true | ||
fsharp_space_before_semicolon=true | ||
fsharp_multiline_block_brackets_on_same_column=true | ||
fsharp_newline_between_type_definition_and_members=true | ||
fsharp_align_function_signature_to_indentation=true | ||
fsharp_alternative_long_member_definitions=true | ||
fsharp_multi_line_lambda_closing_newline=true | ||
fsharp_experimental_keep_indent_in_branch=true | ||
fsharp_max_value_binding_width=80 | ||
fsharp_max_record_width=0 | ||
max_line_length=120 | ||
|
||
[*.{appxmanifest,build,dtd,nuspec,xaml,xamlx,xoml,xsd}] | ||
indent_size=2 | ||
tab_width=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* eol=auto | ||
*.sh eol=lf | ||
*.nix eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bin/ | ||
obj/ | ||
result | ||
*.DotSettings.user | ||
.idea/ |
Oops, something went wrong.