Bootstrap project

This commit is contained in:
Bruno BELANYI 2024-08-23 21:15:26 +01:00
commit c4d81c4e81
12 changed files with 357 additions and 0 deletions

23
.clang-format Normal file
View file

@ -0,0 +1,23 @@
# vim: ft=yaml
---
BasedOnStyle: LLVM
IndentWidth: 4
---
Language: Cpp
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left
# Short functions should not be on a single line, unless empty
AllowShortFunctionsOnASingleLine: Empty
# Make them level
AccessModifierOffset: -4
# It makes more sense this way
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: true
# Aesthetic
AlignOperands: AlignAfterOperator
---

5
.envrc Normal file
View file

@ -0,0 +1,5 @@
if ! has nix_direnv_version || ! nix_direnv_version 3.0.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.0/direnvrc" "sha256-21TMnI2xWX7HkSTjFFri2UaohXVj854mgvWapWrxRXg="
fi
use flake

7
.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
# CMake build directories
/build
/build-*
# Nix generated files
/.pre-commit-config.yaml
/result

31
.woodpecker/check.yml Normal file
View file

@ -0,0 +1,31 @@
labels:
backend: local
steps:
- name: pre-commit check
image: bash
commands:
- nix develop --command pre-commit run --all
- name: nix flake check
image: bash
commands:
- nix flake check
- name: notify
image: bash
environment:
ADDRESS:
from_secret: matrix_homeserver
ROOM:
from_secret: matrix_roomid
USER:
from_secret: matrix_username
PASS:
from_secret: matrix_password
commands:
- nix run github:ambroisie/matrix-notifier
when:
status:
- failure
- success

140
flake.lock Normal file
View file

@ -0,0 +1,140 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"futils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"ref": "main",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1724224976,
"narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c374d94f1536013ca8e92341b540eba4c22f9c62",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1720386169,
"narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "194846768975b7ad2c4988bdb82572c00222c0d7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1724440431,
"narHash": "sha256-9etXEOUtzeMgqg1u0wp+EdwG7RpmrAZ2yX516bMj2aE=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "c8a54057aae480c56e28ef3e14e4960628ac495b",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "master",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"futils": "futils",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

112
flake.nix Normal file
View file

@ -0,0 +1,112 @@
{
description = "Interval Map coding exercise";
inputs = {
futils = {
type = "github";
owner = "numtide";
repo = "flake-utils";
ref = "main";
};
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-unstable";
};
pre-commit-hooks = {
type = "github";
owner = "cachix";
repo = "pre-commit-hooks.nix";
ref = "master";
inputs = {
flake-utils.follows = "futils";
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = { self, futils, nixpkgs, pre-commit-hooks }:
{
overlays = {
default = final: _prev: {
interval-map = with final; stdenv.mkDerivation {
pname = "interval-map";
version = "0.0.0";
src = self;
nativeBuildInputs = with pkgs; [
meson
ninja
pkg-config
];
checkInputs = with pkgs; [
gtest
];
doCheck = true;
meta = with lib; {
description = "An implementation of interval_map";
homepage = "https://git.belanyi.fr/ambroisie/interval-map";
license = licenses.mit;
maintainers = with maintainers; [ ambroisie ];
platforms = platforms.unix;
};
};
};
};
} // futils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
];
};
pre-commit = pre-commit-hooks.lib.${system}.run {
src = self;
hooks = {
nixpkgs-fmt = {
enable = true;
};
clang-format = {
enable = true;
};
};
};
in
{
checks = {
inherit (self.packages.${system}) interval-map;
inherit pre-commit;
};
devShells = {
default = pkgs.mkShell {
inputsFrom = with self.packages.${system}; [
interval-map
];
packages = with pkgs; [
clang-tools
];
inherit (pre-commit) shellHook;
};
};
packages = futils.lib.flattenTree {
default = pkgs.interval-map;
inherit (pkgs) interval-map;
};
});
}

13
meson.build Normal file
View file

@ -0,0 +1,13 @@
project(
'interval-map',
'cpp',
version : '0.0.0',
license: 'MIT',
default_options : [
'cpp_std=c++20',
'warning_level=3',
],
)
subdir('src')
subdir('tests')

View file

@ -0,0 +1 @@
#pragma once

1
src/meson.build Normal file
View file

@ -0,0 +1 @@
interval_map_dep = declare_dependency(include_directories: 'include')

1
tests/meson.build Normal file
View file

@ -0,0 +1 @@
subdir('unit')

16
tests/unit/meson.build Normal file
View file

@ -0,0 +1,16 @@
gtest_dep = dependency(
'gtest',
main : true,
required : false,
)
dummy_test = executable(
'unit_test',
'unit_test.cc',
dependencies : [
gtest_dep,
interval_map_dep
],
)
test('unit test', dummy_test)

7
tests/unit/unit_test.cc Normal file
View file

@ -0,0 +1,7 @@
#include <gtest/gtest.h>
#include <interval-map/interval-map.hh>
TEST(misc, passing) {
ASSERT_EQ(1, 1);
}