2021-01-08 01:58:22 +00:00
|
|
|
{ buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, lib
|
|
|
|
, envoy
|
|
|
|
, zip
|
2021-01-08 03:04:24 +00:00
|
|
|
, nixosTests
|
2021-01-08 01:58:22 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) concatStringsSep mapAttrsToList;
|
|
|
|
in
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "pomerium";
|
2021-06-30 01:44:30 +00:00
|
|
|
version = "0.14.7";
|
2021-01-08 01:58:22 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pomerium";
|
|
|
|
repo = "pomerium";
|
|
|
|
rev = "v${version}";
|
2021-06-30 01:44:30 +00:00
|
|
|
hash = "sha256:1jb96jk5qmary4fi1z9zwmppdyskj0qb6qii8s8mwazjjxqj1z2s";
|
2021-01-08 01:58:22 +00:00
|
|
|
};
|
|
|
|
|
2021-06-30 01:44:30 +00:00
|
|
|
vendorSha256 = "sha256:1daabi9qc9nx8bafn26iw6rv4vx2xpd0nnk06265aqaksx26db0s";
|
2021-01-08 01:58:22 +00:00
|
|
|
subPackages = [
|
|
|
|
"cmd/pomerium"
|
|
|
|
"cmd/pomerium-cli"
|
|
|
|
];
|
|
|
|
|
2021-08-26 06:45:51 +00:00
|
|
|
ldflags = let
|
2021-01-08 01:58:22 +00:00
|
|
|
# Set a variety of useful meta variables for stamping the build with.
|
|
|
|
setVars = {
|
|
|
|
Version = "v${version}";
|
|
|
|
BuildMeta = "nixpkgs";
|
|
|
|
ProjectName = "pomerium";
|
|
|
|
ProjectURL = "github.com/pomerium/pomerium";
|
|
|
|
};
|
|
|
|
varFlags = concatStringsSep " " (mapAttrsToList (name: value: "-X github.com/pomerium/pomerium/internal/version.${name}=${value}") setVars);
|
|
|
|
in [
|
2021-08-26 06:45:51 +00:00
|
|
|
"${varFlags}"
|
2021-01-08 01:58:22 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
zip
|
|
|
|
];
|
|
|
|
|
|
|
|
# Pomerium expects to have envoy append to it in a zip.
|
|
|
|
# We use a store-only (-0) zip, so that the Nix scanner can find any store references we had in the envoy binary.
|
|
|
|
postBuild = ''
|
|
|
|
# Append Envoy
|
|
|
|
pushd $NIX_BUILD_TOP
|
|
|
|
mkdir -p envoy
|
|
|
|
cd envoy
|
|
|
|
cp ${envoy}/bin/envoy envoy
|
|
|
|
zip -0 envoy.zip envoy
|
|
|
|
popd
|
|
|
|
|
|
|
|
mv $GOPATH/bin/pomerium $GOPATH/bin/pomerium.old
|
|
|
|
cat $GOPATH/bin/pomerium.old $NIX_BUILD_TOP/envoy/envoy.zip >$GOPATH/bin/pomerium
|
|
|
|
zip --adjust-sfx $GOPATH/bin/pomerium
|
|
|
|
'';
|
|
|
|
|
|
|
|
# We also need to set dontStrip to avoid having the envoy ZIP stripped off the end.
|
|
|
|
dontStrip = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -Dm0755 $GOPATH/bin/pomerium $out/bin/pomerium
|
|
|
|
install -Dm0755 $GOPATH/bin/pomerium-cli $out/bin/pomerium-cli
|
|
|
|
'';
|
|
|
|
|
2021-01-08 03:04:24 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit (nixosTests) pomerium;
|
|
|
|
};
|
|
|
|
|
2021-01-08 01:58:22 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://pomerium.io";
|
|
|
|
description = "Authenticating reverse proxy";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ lukegb ];
|
|
|
|
platforms = [ "x86_64-linux" ]; # Envoy derivation is x86_64-linux only.
|
|
|
|
};
|
|
|
|
}
|