From 669ab480e0ec7153f7b3b0950396c3e432a5f328 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 5 May 2025 16:27:09 +0200 Subject: [PATCH] build(nix): updating the flake for nix build propose --- flake.nix | 71 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/flake.nix b/flake.nix index 044c71e..6617683 100644 --- a/flake.nix +++ b/flake.nix @@ -1,31 +1,46 @@ { - description = "Flake utils demo"; + description = "Shell for 42 cpp"; - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - c_formatter_42.url = "github:maix0/c_formatter_42-flake"; - }; - outputs = { - self, - nixpkgs, - flake-utils, - c_formatter_42, - }: - flake-utils.lib.eachDefaultSystem ( - system: let - pkgs = nixpkgs.legacyPackages.${system}; - in { - devShell = pkgs.mkShell { - packages = [ - pkgs.xorg.libX11 - pkgs.xorg.libXext - pkgs.clang - pkgs.clang-tools - pkgs.norminette - c_formatter_42.packages.${system}.default - ]; - }; - } - ); + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + c_formatter_42.url = "github:maix0/c_formatter_42-flake"; + }; + outputs = { + self, + nixpkgs, + flake-utils, + c_formatter_42 + }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + in { + devShells.default = pkgs.mkShell { + name = "cpp-42"; + buildInputs = with pkgs; [ + c_formatter_42.packages.${system}.default + clang + clang-tools + norminette + xorg.libX11 + xorg.libXext + ] ++ ( + if pkgs.stdenv.isLinux then [ + valgrind + ] else [] + ); + + shellHook = '' + export NIX_SHOW_STATS=0 + export NIX_HIDE_STATS=1 + export C=clang + export CFLAGS="-std=c89 -Wall -Werror -Wextra" + printf "\n\033[0;90mC w/MLX env loaded for: \033[38;5;220m${system}\033[0m\n" + ''; + }; + } + ); }