init(nix): adding the direnv for nix proposes
This commit is contained in:
parent
912d36b421
commit
49defbc453
5 changed files with 188 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
|||
use flake
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -34,5 +34,7 @@
|
|||
# Nix files
|
||||
flake.lock
|
||||
.direnv/
|
||||
|
||||
# Editor files
|
||||
.clangd
|
||||
.vscode/
|
||||
|
|
|
|||
138
Makefile
Normal file
138
Makefile
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# Makefile :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||
# Updated: 2025/05/02 15:40:00 by rparodi ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
# Variables
|
||||
|
||||
# Name
|
||||
NAME = ircserv
|
||||
|
||||
# Commands
|
||||
CXX = c++
|
||||
RM = rm -rf
|
||||
|
||||
# Flags
|
||||
# Mandatory flags for 42
|
||||
CXXFLAGS = -Werror -Wextra -Wall -std=c++98
|
||||
# Flags to have the dependences (can be removed for correction)
|
||||
# Flags to have the debug (can be removed for correction)
|
||||
DEBUG = -g3
|
||||
# DEBUG += -fsanitize=address
|
||||
CXXFLAGS += $(DEBUG)
|
||||
|
||||
# Sources
|
||||
SRC = main.cpp
|
||||
|
||||
INC_DIR =
|
||||
|
||||
CPPFLAGS = $(addprefix -I, $(INC_DIR)) -MMD -MP
|
||||
|
||||
# Flags to have the dependences (can be removed for correction)
|
||||
# DEBUG = -g3
|
||||
# CPPFLAGS += $(DEBUG)
|
||||
|
||||
# Objects
|
||||
OBJDIRNAME = ./build
|
||||
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.cpp=.o))
|
||||
|
||||
# Colors
|
||||
GREEN = \033[32m
|
||||
GREY = \033[0;90m
|
||||
RED = \033[0;31m
|
||||
GOLD = \033[38;5;220m
|
||||
END = \033[0m
|
||||
|
||||
# Rules
|
||||
|
||||
# All (make all)
|
||||
all: header $(NAME) footer
|
||||
|
||||
# Clean (make clean)
|
||||
clean:
|
||||
@printf '$(GREY) Removing $(END)$(RED)Objects$(END)\n'
|
||||
@printf '$(GREY) Removing $(END)$(RED)Objects Folder$(END)\n'
|
||||
@$(RM) $(OBJDIRNAME)
|
||||
|
||||
# Clean (make fclean)
|
||||
fclean: clean
|
||||
@printf '$(GREY) Removing $(END)$(RED)Program$(END)\n'
|
||||
@$(RM) $(NAME)
|
||||
@echo ""
|
||||
|
||||
# Restart (make re)
|
||||
re: header fclean all
|
||||
|
||||
# Dependences for all
|
||||
$(NAME): $(OBJ)
|
||||
@mkdir -p $(OBJDIRNAME)
|
||||
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
||||
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(NAME) $(OBJ)
|
||||
|
||||
# Creating the objects
|
||||
$(OBJDIRNAME)/%.o: %.cpp
|
||||
@mkdir -p $(dir $@)
|
||||
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
|
||||
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||
|
||||
debug: CPPFLAGS += -D DEBUG=1
|
||||
debug: re
|
||||
|
||||
test: debug
|
||||
@printf '$(GREY) now running with\n\t- Port:\t$(GREEN)4243$(GREY)\n\t-Password:\t$(GREEN)irc$(END)\n'
|
||||
@./$(NAME) 4243 irc
|
||||
|
||||
# Header
|
||||
header:
|
||||
@clear
|
||||
@printf '\n\n'
|
||||
@printf '$(GOLD) ******* ****** ******* $(END)\n'
|
||||
@printf '$(GOLD) ****** *** ******* $(END)\n'
|
||||
@printf '$(GOLD) ******* * ******* $(END)\n'
|
||||
@printf '$(GOLD) ****** ******* $(END)\n'
|
||||
@printf '$(GOLD) ******* ******* $(END)\n'
|
||||
@printf '$(GOLD) ******************* ******* * $(END)\n'
|
||||
@printf '$(GOLD) ******************* ******* *** $(END)\n'
|
||||
@printf '$(GOLD) ****** ******* ****** $(END)\n'
|
||||
@printf '$(GOLD) ****** $(END)\n'
|
||||
@printf '$(GOLD) ****** $(END)\n'
|
||||
@printf '$(GREY) Made by rparodi$(END)\n\n'
|
||||
|
||||
# Footer
|
||||
footer:
|
||||
@printf "\n"
|
||||
@printf "$(GOLD) ,_ _,$(END)\n"
|
||||
@printf "$(GOLD) | \\___//|$(END)\n"
|
||||
@printf "$(GOLD) |=6 6=|$(END)\n"
|
||||
@printf "$(GOLD) \\=._Y_.=/$(END)\n"
|
||||
@printf "$(GOLD) ) \` ( ,$(END)\n"
|
||||
@printf "$(GOLD) / \\ (('$(END)\n"
|
||||
@printf "$(GOLD) | | ))$(END)\n"
|
||||
@printf "$(GOLD) /| | | |\\_//$(END)\n"
|
||||
@printf "$(GOLD) \\| |._.| |/-\`$(END)\n"
|
||||
@printf "$(GOLD) '\"' '\"'$(END)\n"
|
||||
@printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
|
||||
|
||||
clangd:
|
||||
@printf "CompileFlags:\n" > ./.clangd
|
||||
@printf " Add:\n" >> ./.clangd
|
||||
@printf " - \"-xc++\"\n" >> ./.clangd
|
||||
@for FLAG in $(CXXFLAGS); do \
|
||||
printf " - \"$$FLAG\"\n" >> ./.clangd; \
|
||||
done
|
||||
@printf " - \"-I"$(shell pwd)"/\"\n" >> .clangd;
|
||||
@for file in $(INC_DIR); do \
|
||||
printf " - \"-I"$(shell pwd)"/"$$file"\"" >> .clangd; \
|
||||
done
|
||||
@printf "\n" >> ./.clangd
|
||||
@printf '$(GREY) Now parsing settings is set in $(END)$(GREEN)./.clangd$(END)\n'
|
||||
|
||||
# Phony
|
||||
.PHONY: all clean fclean re clangd debug test
|
||||
-include ${OBJ:.o=.d}
|
||||
36
flake.nix
Normal file
36
flake.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
description = "Shell for ft_irc 42 project";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
in {
|
||||
devShells.default = pkgs.mkShell {
|
||||
name = "cpp-42";
|
||||
buildInputs = with pkgs; [
|
||||
clang
|
||||
clang-tools
|
||||
irssi
|
||||
] ++ (
|
||||
if pkgs.stdenv.isLinux then [
|
||||
valgrind
|
||||
] else []
|
||||
);
|
||||
|
||||
shellHook = ''
|
||||
export NIX_SHOW_STATS=0
|
||||
export NIX_HIDE_STATS=1
|
||||
export CXX=clang++
|
||||
export CXXFLAGS="-std=cpp98 -Wall -Werror -Wextra"
|
||||
printf "\n\033[0;90mCPP env loaded for: \033[38;5;220m${system}\033[0m\n"
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
11
main.cpp
Normal file
11
main.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc != 3) {
|
||||
std::cerr << "Usage: " << argv[0] << " <port> <password>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Port:" << argv[1] << std::endl;
|
||||
std::cout << "Password:" << argv[2] << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue