{ description = "C++ dev environment"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; outputs = { self, nixpkgs }: let systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f { pkgs = import nixpkgs { inherit system; }; }); in { packages = forAllSystems ({ pkgs }: { default = pkgs.stdenv.mkDerivation { pname = "hello-cpp"; version = "0.1.0"; src = ./.; buildPhase = '' $CXX -std=c++17 -O2 -Wall -Wextra -o hello hello.cpp ''; installPhase = '' mkdir -p $out/bin cp hello $out/bin/ ''; }; }); devShells = forAllSystems ({ pkgs }: { default = pkgs.mkShell { packages = with pkgs; [ gcc gdb clang-tools cmake ]; }; }); apps = forAllSystems ({ pkgs }: { default = { type = "app"; program = "${self.packages.${pkgs.system}.default}/bin/hello"; }; }); }; }