1
1
mirror of https://github.com/nmattia/niv.git synced 2024-11-29 09:42:35 +03:00

Merge pull request #179 from nmattia/nm-format-examples

Reformat libosmium example and build it on CI
This commit is contained in:
Nicolas Mattia 2020-01-11 12:16:42 +01:00 committed by GitHub
commit d20eed4ce6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 64 additions and 50 deletions

View 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
'';
}

View File

@ -19,7 +19,7 @@ let
pkgs.fetchzip { inherit (spec) url sha256; };
fetch_git = spec:
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
fetch_builtin-tarball = spec:
builtins.trace
@ -125,12 +125,14 @@ let
# The "config" used by the fetchers
mkConfig =
{ sourcesFile ? ./sources.json
, sources ? builtins.fromJSON (builtins.readFile sourcesFile)
, pkgs ? mkPkgs sources
}: rec {
# 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
pkgs = mkPkgs sources;
inherit pkgs;
};
in
mkSources (mkConfig {}) //
{ __functor = _: settings: mkSources (mkConfig settings); }
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }

View File

@ -1,3 +1,3 @@
self: super: {
libosmium = self.callPackage ./overlay/libosmium.nix {};
}
}

View File

@ -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 {
name = "libosmium";
@ -13,10 +13,10 @@ stdenv.mkDerivation rec {
"-DBUILD_TESTING=OFF"
];
buildInputs = [
protozero
protozero
expat
zlib
bzip2
zlib
bzip2
boost
];
}
}

View File

@ -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
'';
}

View File

@ -15,6 +15,10 @@ nixargs=(
"--max-jobs" "10"
)
targets=(
)
if [[ ! $OSTYPE =~ darwin ]]; then
echo "Not testing on darwin"
@ -23,11 +27,11 @@ if [[ ! $OSTYPE =~ darwin ]]; then
else
echo "Testing on darwin"
echo "Not enabling sandbox, not running integration"
nixargs+=("-A" "niv-test")
targets+=("-A" "niv-test")
fi
# Build and create a root
nix-build ${nixargs[@]}
nix-build ${nixargs[@]} ${targets[@]}
echo "Formatting"
if ! nixpkgs-fmt --check . ; then
@ -36,4 +40,12 @@ if ! nixpkgs-fmt --check . ; then
exit 1
fi
echo "Building examples"
for example in examples/*; do
echo " - $(basename $example)"
pushd $example
nix-build ${nixargs[@]}
popd
done
echo "all good"