From bbcb6c3fd6cfe3d92928d95685ce5706641cb04e Mon Sep 17 00:00:00 2001 From: lucy Date: Mon, 8 Dec 2025 12:14:23 +0100 Subject: [PATCH] c++ devshell flake woop woop --- flake.nix | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ main.cpp | 10 ++++++++++ meson.build | 3 +++ 3 files changed, 64 insertions(+) create mode 100755 flake.nix create mode 100755 main.cpp create mode 100755 meson.build diff --git a/flake.nix b/flake.nix new file mode 100755 index 0000000..42079f6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + description = "A Nix-flake-based C/C++ development environment"; + + inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0"; # stable Nixpkgs + + outputs = + { self, ... }@inputs: + + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forEachSupportedSystem = + f: + inputs.nixpkgs.lib.genAttrs supportedSystems ( + system: + f { + pkgs = import inputs.nixpkgs { inherit system; }; + } + ); + in + { + devShells = forEachSupportedSystem ( + { pkgs }: + { + default = + pkgs.mkShell.override + { + # Override stdenv in order to change compiler: + stdenv = pkgs.clangStdenv; + } + { + packages = with pkgs; [ + clang-tools + clang + ninja + meson + pkg-config + libcxx + ]; + shellHook = '' + echo "welcome to c++ devshell nyaaa :3" + ''; + }; + } + ); + }; +} diff --git a/main.cpp b/main.cpp new file mode 100755 index 0000000..751a3d3 --- /dev/null +++ b/main.cpp @@ -0,0 +1,10 @@ +#include +#include + +using namespace std; + +int main() { + string bla = "hello world"; + cout << bla << std::endl; + return 0; +} diff --git a/meson.build b/meson.build new file mode 100755 index 0000000..5476024 --- /dev/null +++ b/meson.build @@ -0,0 +1,3 @@ +project('flake', 'cpp', +default_options: ['cpp_std=c++20']) +executable('flake', 'main.cpp')