mirror of
https://github.com/nmattia/niv.git
synced 2024-09-19 11:27:40 +03:00
Merge pull request #179 from nmattia/nm-format-examples
Reformat libosmium example and build it on CI
This commit is contained in:
commit
d20eed4ce6
37
examples/cpp-libosmium/default.nix
Normal file
37
examples/cpp-libosmium/default.nix
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
let
|
||||||
|
sources = import ./nix/sources.nix;
|
||||||
|
pkgs = import sources.nixpkgs {
|
||||||
|
overlays = [
|
||||||
|
(_: _: { inherit sources; })
|
||||||
|
(import ./overlay.nix)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
with pkgs;
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "nix-cpp-demo";
|
||||||
|
nativeBuildInputs = [ cmake pkgconfig ];
|
||||||
|
src = pkgs.lib.cleanSource ./.;
|
||||||
|
|
||||||
|
# tell Cmake location of all headers
|
||||||
|
cmakeFlags = [
|
||||||
|
"-DEXTERNAL_INCLUDE_DIRECTORIES=${stdenv.lib.strings.makeSearchPathOutput "dev" "include" libosmium.buildInputs}"
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = stdenv.lib.lists.concatLists [
|
||||||
|
# We want to check if dependencies exist using find_package
|
||||||
|
[
|
||||||
|
libosmium.buildInputs
|
||||||
|
]
|
||||||
|
# dependencies
|
||||||
|
[
|
||||||
|
libosmium
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp bin/hello-world $out/bin
|
||||||
|
'';
|
||||||
|
}
|
@ -125,12 +125,14 @@ let
|
|||||||
# The "config" used by the fetchers
|
# The "config" used by the fetchers
|
||||||
mkConfig =
|
mkConfig =
|
||||||
{ sourcesFile ? ./sources.json
|
{ sourcesFile ? ./sources.json
|
||||||
|
, sources ? builtins.fromJSON (builtins.readFile sourcesFile)
|
||||||
|
, pkgs ? mkPkgs sources
|
||||||
}: rec {
|
}: rec {
|
||||||
# The sources, i.e. the attribute set of spec name to spec
|
# The sources, i.e. the attribute set of spec name to spec
|
||||||
sources = builtins.fromJSON (builtins.readFile sourcesFile);
|
inherit sources;
|
||||||
|
|
||||||
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
||||||
pkgs = mkPkgs sources;
|
inherit pkgs;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
mkSources (mkConfig {}) //
|
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
||||||
{ __functor = _: settings: mkSources (mkConfig settings); }
|
|
@ -1,4 +1,4 @@
|
|||||||
{ stdenv, fetchFromGitHub, cmake, protozero, expat, zlib, bzip2, boost, sources ? import ../nix/sources.nix }:
|
{ stdenv, cmake, protozero, expat, zlib, bzip2, boost, sources }:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "libosmium";
|
name = "libosmium";
|
@ -1,37 +0,0 @@
|
|||||||
{
|
|
||||||
# import the sources
|
|
||||||
sources ? import ./nix/sources.nix
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
pkgs = import sources.nixpkgs {
|
|
||||||
overlays = [ (import ./overlay.nix) ];
|
|
||||||
};
|
|
||||||
in
|
|
||||||
with pkgs;
|
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
name = "nix-cpp-demo";
|
|
||||||
nativeBuildInputs = [ cmake pkgconfig];
|
|
||||||
src = ./.;
|
|
||||||
|
|
||||||
# tell Cmake location of all headers
|
|
||||||
cmakeFlags = [
|
|
||||||
"-DEXTERNAL_INCLUDE_DIRECTORIES=${stdenv.lib.strings.makeSearchPathOutput "dev" "include" libosmium.buildInputs}"
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = stdenv.lib.lists.concatLists[
|
|
||||||
# We want to check if dependencies exist using find_package
|
|
||||||
[
|
|
||||||
libosmium.buildInputs
|
|
||||||
]
|
|
||||||
# dependencies
|
|
||||||
[
|
|
||||||
libosmium
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/bin
|
|
||||||
cp bin/hello-world $out/bin
|
|
||||||
'';
|
|
||||||
}
|
|
16
script/test
16
script/test
@ -15,6 +15,10 @@ nixargs=(
|
|||||||
"--max-jobs" "10"
|
"--max-jobs" "10"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
targets=(
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if [[ ! $OSTYPE =~ darwin ]]; then
|
if [[ ! $OSTYPE =~ darwin ]]; then
|
||||||
echo "Not testing on darwin"
|
echo "Not testing on darwin"
|
||||||
@ -23,11 +27,11 @@ if [[ ! $OSTYPE =~ darwin ]]; then
|
|||||||
else
|
else
|
||||||
echo "Testing on darwin"
|
echo "Testing on darwin"
|
||||||
echo "Not enabling sandbox, not running integration"
|
echo "Not enabling sandbox, not running integration"
|
||||||
nixargs+=("-A" "niv-test")
|
targets+=("-A" "niv-test")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build and create a root
|
# Build and create a root
|
||||||
nix-build ${nixargs[@]}
|
nix-build ${nixargs[@]} ${targets[@]}
|
||||||
|
|
||||||
echo "Formatting"
|
echo "Formatting"
|
||||||
if ! nixpkgs-fmt --check . ; then
|
if ! nixpkgs-fmt --check . ; then
|
||||||
@ -36,4 +40,12 @@ if ! nixpkgs-fmt --check . ; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Building examples"
|
||||||
|
for example in examples/*; do
|
||||||
|
echo " - $(basename $example)"
|
||||||
|
pushd $example
|
||||||
|
nix-build ${nixargs[@]}
|
||||||
|
popd
|
||||||
|
done
|
||||||
|
|
||||||
echo "all good"
|
echo "all good"
|
||||||
|
Loading…
Reference in New Issue
Block a user