This repository has been archived by the owner on Jun 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from Sigmanificient/c
- Loading branch information
Showing
6 changed files
with
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
max_line_length = 80 | ||
tab_width = 4 | ||
|
||
[{Makefile,*.mk}] | ||
indent_style = tab | ||
|
||
[*.nix] | ||
indent_style = space | ||
tab_width = 2 | ||
indent_size = 2 | ||
|
||
[*.lock] | ||
indent_style = unset | ||
insert_final_newline = unset |
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,64 @@ | ||
# binaries | ||
hello | ||
|
||
# language support | ||
compile_commands.json | ||
.cache | ||
|
||
# nix | ||
.direnv | ||
result* | ||
repl-result-* | ||
|
||
# Prerequisites | ||
*.d | ||
|
||
# Object files | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Linker output | ||
*.ilk | ||
*.map | ||
*.exp | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
# Debug files | ||
*.dSYM/ | ||
*.su | ||
*.idb | ||
*.pdb | ||
|
||
# Kernel Module Compile Results | ||
*.mod* | ||
*.cmd | ||
.tmp_versions/ | ||
modules.order | ||
Module.symvers | ||
Mkfile.old | ||
dkms.conf |
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,30 @@ | ||
CC ?= gcc | ||
CFLAGS += -pedantic -Wall -Wextra -O2 | ||
|
||
OUT := hello | ||
BINDIR ?= /usr/bin | ||
|
||
SRC += main.c | ||
OBJ := $(SRC:.c=.o) | ||
|
||
.PHONY: all | ||
all: $(OUT) | ||
|
||
$(OUT): $(OBJ) | ||
$(CC) -o $@ $< | ||
|
||
.PHONY: clean | ||
clean: | ||
$(RM) $(OBJ) | ||
|
||
.PHONY: fclean | ||
fclean: clean | ||
$(RM) -r $(OUT) | ||
|
||
.PHONY: re | ||
.NOTPARALLEL: re | ||
re: fclean all | ||
|
||
.PHONY: install | ||
install: | ||
install -D hello ${BINDIR}/hello --mode 0755 |
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 = "Aux template for C project"; | ||
|
||
inputs.nixpkgs.url = "github:auxolotl/nixpkgs/nixos-unstable"; | ||
|
||
outputs = | ||
{ self, nixpkgs }: | ||
let | ||
forAllSystems = | ||
function: | ||
nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed ( | ||
system: function nixpkgs.legacyPackages.${system} | ||
); | ||
in | ||
rec { | ||
devShells = forAllSystems (pkgs: { | ||
default = pkgs.mkShell { inputsFrom = [ packages.${pkgs.system}.hello ]; }; | ||
}); | ||
|
||
packages = forAllSystems (pkgs: rec { | ||
default = hello; | ||
hello = pkgs.callPackage ./hello.nix { }; | ||
}); | ||
|
||
overlays.default = final: prev: { hello = prev.callPackage ./default.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,7 @@ | ||
{ stdenv }: | ||
stdenv.mkDerivation { | ||
name = "hello"; | ||
src = ./.; | ||
|
||
env.BINDIR = "${placeholder "out"}/bin"; | ||
} |
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,11 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main(void) | ||
{ | ||
char greet[] = "hello, world!\n"; | ||
int written = printf("%s", greet); | ||
|
||
return written == (sizeof(greet) - 1) | ||
? EXIT_SUCCESS : EXIT_FAILURE; | ||
} |