Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,35 @@ project(tablo)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Tablo shared libraries
# Build options

# libtabcrypt
add_subdirectory(lib/libtabcrypt)
option(DEF_LIBTABCRYPT "Build libtabcrypt" ON)
option(DEF_LIBTABNET "Build libtabnet" ON)

# libtabnet
add_subdirectory(lib/libtabnet)
option(DEF_CLIENT "Build TabloClient" ON)
option(DEF_MASTER "Build TabloMaster" ON)
option(DEF_NODE "Build TabloNode" ON)

# Test executables
# Shared libraries

add_subdirectory(TCTest)
if(DEF_LIBTABCRYPT)
add_subdirectory(lib/libtabcrypt)
endif()

if(DEF_LIBTABNET)
add_subdirectory(lib/libtabnet)
endif()

# TabloClient, TabloMaster and TabloNode executables (provided by own CMakeLists.txt files)
# Executables

add_subdirectory(TabloClient)
add_subdirectory(TabloMaster)
add_subdirectory(TabloNode)
if(DEF_CLIENT)
add_subdirectory(TabloClient)
endif()

if(DEF_MASTER)
add_subdirectory(TabloMaster)
endif()

if(DEF_NODE)
add_subdirectory(TabloNode)
endif()
14 changes: 0 additions & 14 deletions TCTest/CMakeLists.txt

This file was deleted.

50 changes: 0 additions & 50 deletions TCTest/src/main.cpp

This file was deleted.

13 changes: 0 additions & 13 deletions TCTest/src/tabcrypt_test.h

This file was deleted.

189 changes: 156 additions & 33 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";

ttp2 = {
url = "github:Sobottasgithub/ttp2";
};
Expand All @@ -16,9 +17,12 @@
}:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };

version = "1.2";
pkgs = import nixpkgs {
inherit system;
};

version = "1.3";

libttp2 = ttp2.packages.${system}.lib;

Expand All @@ -33,51 +37,169 @@
{
packages.${system} =
let
tablo-full = pkgs.stdenv.mkDerivation {
mkTabloPackage =
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so smooth!

{
pname,
buildTarget ? pname,

enableLibtabcrypt ? false,
enableLibtabnet ? false,

enableNode ? false,
enableClient ? false,
enableMaster ? false,

extraInputs ? [ ],
}:
pkgs.stdenv.mkDerivation {
inherit pname version;

src = ./.;

meta = {
description = "${pname} package";
mainProgram = pname;
};

buildInputs = packages ++ extraInputs;

configurePhase = ''
cmake -B build -S $src \
-DCMAKE_BUILD_TYPE=Release \
-DDEF_LIBTABCRYPT=${if enableLibtabcrypt then "ON" else "OFF"} \
-DDEF_LIBTABNET=${if enableLibtabnet then "ON" else "OFF"} \
-DDEF_NODE=${if enableNode then "ON" else "OFF"} \
-DDEF_CLIENT=${if enableClient then "ON" else "OFF"} \
-DDEF_MASTER=${if enableMaster then "ON" else "OFF"}
'';

buildPhase = ''
cmake --build build \
--target ${buildTarget} \
-j$NIX_BUILD_CORES
'';

installPhase = ''
cmake --install build --prefix=$out
cp LICENSE $out/
'';
};

libtabcrypt = mkTabloPackage {
pname = "libtabcrypt";
buildTarget = "tabcrypt";

enableLibtabcrypt = true;
};

libtabnet = mkTabloPackage {
pname = "libtabnet";
buildTarget = "tabnet";

enableLibtabnet = true;

extraInputs = [
libtabcrypt
# include libttp2 just here for later setup!
];
};

tablo-node = mkTabloPackage {
pname = "tablo-node";

enableNode = true;

extraInputs = [
libtabcrypt
libtabnet
];
};

tablo-client = mkTabloPackage {
pname = "tablo-client";

enableClient = true;
enableLibtabcrypt = true;
enableLibtabnet = true;
Comment on lines +121 to +123

extraInputs = [
libtabcrypt
libtabnet
];
};

tablo-master = mkTabloPackage {
pname = "tablo-master";

enableMaster = true;
enableLibtabcrypt = true;
enableLibtabnet = true;

extraInputs = [
libtabcrypt
libtabnet
];
};

tablo-full = mkTabloPackage {
pname = "tablo-full";
inherit version;
src = ./.;
buildTarget = "all";

meta = {
description = "Full tablo package";
mainProgram = "tablo-node";
};
enableLibtabcrypt = true;
enableLibtabnet = true;

buildInputs = packages;
enableNode = true;
enableClient = true;
enableMaster = true;

configurePhase = ''
cmake -B build -S $src -DCMAKE_BUILD_TYPE=Release
'';
extraInputs = [
libtabcrypt
libtabnet
];
};

buildPhase = ''
cmake --build build
'';
tablo = pkgs.symlinkJoin {
name = "tablo-${version}";

installPhase = ''
cmake --install build --prefix=$out
cp LICENSE $out/
'';
paths = [
libtabcrypt
libtabnet
tablo-node
tablo-client
tablo-master
];
};

mkTabloDocker =
name: extraConfig:
package: binary:
pkgs.dockerTools.buildImage {
inherit name;
name = binary;
tag = version;

config = {
Cmd = [ "${tablo-full}/bin/${name}" ];
}
// extraConfig;
Cmd = [ "${package}/bin/${binary}" ];
};
};
in
{
inherit tablo-full libttp2;
default = tablo-full;
tablo-node-docker = mkTabloDocker "tablo-node" { };
tablo-master-docker = mkTabloDocker "tablo-master" { };
inherit
tablo
tablo-node
tablo-client
tablo-master
tablo-full
libtabcrypt
libtabnet
libttp2
;

default = tablo;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually an issue. Please open an issue for it @copilot


tablo-node-docker = mkTabloDocker tablo-node "tablo-node";

# used for client containers not deployed via swarm
tablo-client-docker = mkTabloDocker "tablo-client" { };
tablo-master-docker = mkTabloDocker tablo-master "tablo-master";

tablo-client-docker = mkTabloDocker tablo-client "tablo-client";
};

devShells.${system}.default =
Expand All @@ -91,13 +213,14 @@
pkgs.mkShell {
packages = devPackages;

inputsFrom = [ self.packages.${system}.default ];
inputsFrom = [
self.packages.${system}.default
];

shellHook = ''
git status
cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
'';
};

};
}