mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2025-12-06 17:17:22 +01:00
feat: add cpp template
This commit is contained in:
parent
6da0fcbb1b
commit
baeb65234b
10 changed files with 94 additions and 86 deletions
|
|
@ -487,6 +487,7 @@ This file defines the templates that are being exposed by the flake. These can b
|
||||||
"python"
|
"python"
|
||||||
"rust"
|
"rust"
|
||||||
"go"
|
"go"
|
||||||
|
"cpp"
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
lib.swarselsystems.mkTemplates templateNames
|
lib.swarselsystems.mkTemplates templateNames
|
||||||
|
|
|
||||||
1
templates/cpp/.envrc
Normal file
1
templates/cpp/.envrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
use flake
|
||||||
12
templates/cpp/.gitignore
vendored
Normal file
12
templates/cpp/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
CMakeLists.txt.user
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles
|
||||||
|
CMakeScripts
|
||||||
|
Testing
|
||||||
|
Makefile
|
||||||
|
cmake_install.cmake
|
||||||
|
install_manifest.txt
|
||||||
|
compile_commands.json
|
||||||
|
CTestTestfile.cmake
|
||||||
|
_deps
|
||||||
|
CMakeUserPresets.json
|
||||||
9
templates/cpp/CMakeLists.txt
Normal file
9
templates/cpp/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
|
project(name)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
install(TARGETS name DESTINATION bin)
|
||||||
62
templates/cpp/flake.nix
Normal file
62
templates/cpp/flake.nix
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
# heavily inspired by https://github.com/nulladmin1/nix-flake-templates/blob/main/cpp-cmake/flake.nix
|
||||||
|
{
|
||||||
|
description = "C++ Flake";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||||
|
systems.url = "github:nix-systems/default";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{ self
|
||||||
|
, nixpkgs
|
||||||
|
, systems
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
forEachSystem = nixpkgs.lib.genAttrs (import systems);
|
||||||
|
pkgsFor = forEachSystem (system: import nixpkgs { inherit system; });
|
||||||
|
|
||||||
|
pname = "name";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
formatter = forEachSystem (system: pkgsFor.${system}.nixpgks-fmt);
|
||||||
|
|
||||||
|
devShells = forEachSystem (system: {
|
||||||
|
default = pkgsFor.${system}.mkShell {
|
||||||
|
packages = with pkgsFor.${system}; [
|
||||||
|
libllvm
|
||||||
|
cmake
|
||||||
|
gtest
|
||||||
|
cppcheck
|
||||||
|
valgrind
|
||||||
|
doxygen
|
||||||
|
clang-tools
|
||||||
|
# cudatoolkit
|
||||||
|
];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
packages = forEachSystem (system: {
|
||||||
|
default = pkgsFor.${system}.stdenv.mkDerivation {
|
||||||
|
inherit pname;
|
||||||
|
version = "0.1.0";
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgsFor.${system}; [
|
||||||
|
cmake
|
||||||
|
];
|
||||||
|
buildInputs = with pkgsFor.${system}; [
|
||||||
|
gtest
|
||||||
|
];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
apps = forEachSystem (system: {
|
||||||
|
default = {
|
||||||
|
type = "app";
|
||||||
|
program = "${self.packages.${system}.default}/bin/${pname}";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
1
templates/cpp/src/CMakeLists.txt
Normal file
1
templates/cpp/src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
add_executable(name name.cpp name.cpp)
|
||||||
7
templates/cpp/src/name.cpp
Normal file
7
templates/cpp/src/name.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
cout << "Hello, world!" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
# flake.nix
|
|
||||||
{
|
|
||||||
description = "C/C++ environment";
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs = { nixpkgs, ... }:
|
|
||||||
let
|
|
||||||
system = "x86_64-linux";
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
llvm = pkgs.llvmPackages_latest;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
devShells.${system}.default = pkgs.mkShell {
|
|
||||||
packages = with pkgs; [
|
|
||||||
gcc
|
|
||||||
#builder
|
|
||||||
cmake
|
|
||||||
gnumake
|
|
||||||
#headers
|
|
||||||
clang-tools
|
|
||||||
#lsp
|
|
||||||
llvm.libstdcxxClang
|
|
||||||
#tools
|
|
||||||
cppcheck
|
|
||||||
valgrind
|
|
||||||
doxygen
|
|
||||||
];
|
|
||||||
hardeningDisable = [ "all" ];
|
|
||||||
# direnv does not allow aliases, use scripts as a workaround
|
|
||||||
shellHook = ''
|
|
||||||
PATH_add ~/.dotfiles/scripts/devShell
|
|
||||||
'';
|
|
||||||
# ...
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
# flake.nix
|
|
||||||
{
|
|
||||||
description = "CUDA environment";
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs = { nixpkgs, ... }:
|
|
||||||
let
|
|
||||||
system = "x86_64-linux";
|
|
||||||
pkgs = import nixpkgs {
|
|
||||||
system = "x86_64-linux";
|
|
||||||
config.allowUnfree = true;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
devShells.${system}.default = pkgs.mkShell {
|
|
||||||
packages = with pkgs; [
|
|
||||||
# gcc
|
|
||||||
#builder
|
|
||||||
# cmake
|
|
||||||
# gnumake
|
|
||||||
#headers
|
|
||||||
clang-tools
|
|
||||||
#lsp
|
|
||||||
# llvm.libstdcxxClang
|
|
||||||
# cudaPackages.cuda_nvcc
|
|
||||||
#tools
|
|
||||||
cppcheck
|
|
||||||
valgrind
|
|
||||||
doxygen
|
|
||||||
cudatoolkit
|
|
||||||
|
|
||||||
(pkgs.python3.withPackages (python-pkgs: [
|
|
||||||
python-pkgs.numpy
|
|
||||||
python-pkgs.pandas
|
|
||||||
python-pkgs.scipy
|
|
||||||
python-pkgs.matplotlib
|
|
||||||
python-pkgs.requests
|
|
||||||
python-pkgs.debugpy
|
|
||||||
python-pkgs.python-lsp-server
|
|
||||||
]))
|
|
||||||
];
|
|
||||||
hardeningDisable = [ "all" ];
|
|
||||||
# ...
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -4,6 +4,7 @@ let
|
||||||
"python"
|
"python"
|
||||||
"rust"
|
"rust"
|
||||||
"go"
|
"go"
|
||||||
|
"cpp"
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
lib.swarselsystems.mkTemplates templateNames
|
lib.swarselsystems.mkTemplates templateNames
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue