inja: init at 3.4.0 (#312868)
Includes a packaging test with a simple cmake project.
This commit is contained in:
parent
ac41bab16d
commit
14800786a9
46
pkgs/by-name/in/inja/package.nix
Normal file
46
pkgs/by-name/in/inja/package.nix
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
cmake,
|
||||
nlohmann_json,
|
||||
doctest,
|
||||
callPackage,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "inja";
|
||||
version = "3.4.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "pantor";
|
||||
repo = "inja";
|
||||
rev = "v${finalAttrs.version}";
|
||||
hash = "sha256-B1EaR+qN32nLm3rdnlZvXQ/dlSd5XSc+5+gzBTPzUZU=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
propagatedBuildInputs = [ nlohmann_json ];
|
||||
|
||||
cmakeFlags = [
|
||||
(lib.cmakeBool "INJA_BUILD_TESTS" finalAttrs.finalPackage.doCheck)
|
||||
(lib.cmakeBool "INJA_USE_EMBEDDED_JSON" false)
|
||||
(lib.cmakeBool "BUILD_BENCHMARK" false)
|
||||
];
|
||||
|
||||
checkInputs = [ doctest ];
|
||||
doCheck = true;
|
||||
|
||||
passthru.tests = {
|
||||
simple-cmake = callPackage ./simple-cmake-test { };
|
||||
};
|
||||
|
||||
meta = {
|
||||
changelog = "https://github.com/pantor/inja/releases/tag/v${finalAttrs.version}";
|
||||
description = "Template engine for modern C++, loosely inspired by jinja for python";
|
||||
homepage = "https://github.com/pantor/inja";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ xokdvium ];
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
})
|
5
pkgs/by-name/in/inja/simple-cmake-test/CMakeLists.txt
Normal file
5
pkgs/by-name/in/inja/simple-cmake-test/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
project(inja-simple-cmake-test LANGUAGES CXX)
|
||||
find_package(inja REQUIRED)
|
||||
add_executable(simple-cmake-test main.cpp)
|
||||
target_link_libraries(simple-cmake-test PRIVATE pantor::inja)
|
||||
install(TARGETS simple-cmake-test DESTINATION bin)
|
27
pkgs/by-name/in/inja/simple-cmake-test/default.nix
Normal file
27
pkgs/by-name/in/inja/simple-cmake-test/default.nix
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
stdenv,
|
||||
cmake,
|
||||
inja,
|
||||
lib,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "inja-simple-cmake-test";
|
||||
src = lib.fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = lib.fileset.unions [
|
||||
./main.cpp
|
||||
./CMakeLists.txt
|
||||
];
|
||||
};
|
||||
nativeBuildInputs = [ cmake ];
|
||||
buildInputs = [ inja ];
|
||||
doInstallCheck = true;
|
||||
installCheckPhase = ''
|
||||
if [[ `$out/bin/simple-cmake-test` != "Hello world!" ]]; then
|
||||
echo "ERROR: $out/bin/simple-cmake-test does not output 'Hello world!'"
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
meta.timeout = 30;
|
||||
}
|
8
pkgs/by-name/in/inja/simple-cmake-test/main.cpp
Normal file
8
pkgs/by-name/in/inja/simple-cmake-test/main.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include <inja/inja.hpp>
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
int main() {
|
||||
nlohmann::json data = {{"name", "world"}};
|
||||
inja::render_to(std::cout, "Hello {{ name }}!", data);
|
||||
}
|
Loading…
Reference in New Issue
Block a user