c++ devshell flake woop woop

This commit is contained in:
lucy 2025-12-08 12:14:23 +01:00
commit bbcb6c3fd6
3 changed files with 64 additions and 0 deletions

51
flake.nix Executable file
View File

@ -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"
'';
};
}
);
};
}

10
main.cpp Executable file
View File

@ -0,0 +1,10 @@
#include <iostream>
#include <string>
using namespace std;
int main() {
string bla = "hello world";
cout << bla << std::endl;
return 0;
}

3
meson.build Executable file
View File

@ -0,0 +1,3 @@
project('flake', 'cpp',
default_options: ['cpp_std=c++20'])
executable('flake', 'main.cpp')