-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(operations): Verify building of the Nix package (#1432)
* Verify building of Nix package Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com> * Fix script name Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com> * Use version from the template Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com> * Generate `cargoSha256` automatically Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com> * Run `make generate` Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com> * Run Vector tests during building of the package Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
- Loading branch information
Showing
6 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Taken from https://github.com/nixos/nixpkgs | ||
|
||
{ stdenv, lib, fetchFromGitHub, rustPlatform | ||
, openssl, pkgconfig, protobuf | ||
, Security, libiconv, rdkafka, cmake | ||
, tzdata | ||
|
||
, features ? | ||
(if stdenv.isAarch64 | ||
then [ "shiplift/unix-socket" "jemallocator" "rdkafka" "rdkafka/dynamic_linking" ] | ||
else [ "leveldb" "leveldb/leveldb-sys-2" "shiplift/unix-socket" "jemallocator" "rdkafka" "rdkafka/dynamic_linking" ]) | ||
}: | ||
|
||
rustPlatform.buildRustPackage rec { | ||
pname = "vector"; | ||
version = "<%= | ||
require "toml-rb" | ||
TomlRB.load_file("Cargo.toml")["package"]["version"] | ||
%>"; | ||
|
||
src = <% if ENV.has_key?("GITHUB_SHA256") %>fetchFromGitHub { | ||
owner = "timberio"; | ||
repo = pname; | ||
rev = "refs/tags/v${version}"; | ||
sha256 = "<%= ENV["GITHUB_SHA256"] %>"; | ||
}<% else %><%= Dir.getwd %><% end %>; | ||
|
||
cargoSha256 = "<%= | ||
# The only offical way to calculate `cargoSha256` is to set it arbitrarily, | ||
# run the build, and then extract the correct checksum from the error | ||
# message. See | ||
# https://nixos.org/nixpkgs/manual/#compiling-rust-applications-with-cargo | ||
# for details. | ||
|
||
if ENV.has_key?("CARGO_SHA256") | ||
ENV["CARGO_SHA256"] | ||
else | ||
require 'open3' | ||
|
||
_, output, _ = Open3.capture3({ "CARGO_SHA256" => "1" * 52 }, "./scripts/verify-nix.sh") | ||
expected_sha256 = output | ||
.split("\n") | ||
.select { |s| s =~ /got:.*sha256:/ } | ||
.map { |s| s.split(":")[-1] } | ||
.first | ||
|
||
expected_sha256 | ||
end | ||
%>"; | ||
buildInputs = [ openssl pkgconfig protobuf rdkafka cmake ] | ||
++ stdenv.lib.optional stdenv.isDarwin [ Security libiconv ]; | ||
|
||
# needed for internal protobuf c wrapper library | ||
PROTOC="${protobuf}/bin/protoc"; | ||
PROTOC_INCLUDE="${protobuf}/include"; | ||
|
||
cargoBuildFlags = [ "--no-default-features" "--features" "${lib.concatStringsSep "," features}" ]; | ||
checkPhase = "TZDIR=${tzdata}/share/zoneinfo cargo test --no-default-features --features ${lib.concatStringsSep "," features}"; | ||
|
||
meta = with stdenv.lib; { | ||
description = "A high-performance logs, metrics, and events router"; | ||
homepage = "https://github.com/timberio/vector"; | ||
license = with licenses; [ asl20 ]; | ||
maintainers = with maintainers; [ thoughtpolice ]; | ||
platforms = platforms.all; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM nixos/nix:latest | ||
|
||
RUN nix-env -i git ruby | ||
|
||
COPY verifier-nixos/Gemfile Gemfile | ||
RUN bundle install | ||
RUN rm Gemfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
source 'https://rubygems.org' | ||
gem 'toml-rb', '~> 1.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
mkdir -p /tmp | ||
nixpkgs=/tmp/nixpkgs | ||
git clone --depth=1 https://github.com/nixos/nixpkgs $nixpkgs | ||
erb < distribution/nix/default.nix.erb > $nixpkgs/pkgs/tools/misc/vector/default.nix | ||
|
||
nix-env -f $nixpkgs -iA vector |