2021-01-08 01:58:22 +00:00
|
|
|
{ buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, lib
|
|
|
|
, envoy
|
|
|
|
, zip
|
2021-01-08 03:04:24 +00:00
|
|
|
, nixosTests
|
2022-03-11 14:01:27 +00:00
|
|
|
, pomerium-cli
|
2021-01-08 01:58:22 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-12-07 15:04:09 +00:00
|
|
|
inherit (lib) concatStringsSep concatMap id mapAttrsToList;
|
2021-01-08 01:58:22 +00:00
|
|
|
in
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "pomerium";
|
2022-03-11 13:54:14 +00:00
|
|
|
version = "0.17.0";
|
2021-01-08 01:58:22 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pomerium";
|
|
|
|
repo = "pomerium";
|
|
|
|
rev = "v${version}";
|
2022-03-11 13:54:14 +00:00
|
|
|
hash = "sha256:1hv76i6k9f0kp527nxlxqhklsvkh2cmfnqlszmlk2hxij31qnf8q";
|
2021-01-08 01:58:22 +00:00
|
|
|
};
|
|
|
|
|
2022-03-11 13:54:14 +00:00
|
|
|
vendorSha256 = "sha256:1cq4m5a7z64yg3v1c68d15ilw78il6p53vaqzxgn338zjggr3kig";
|
2021-01-08 01:58:22 +00:00
|
|
|
subPackages = [
|
|
|
|
"cmd/pomerium"
|
|
|
|
];
|
|
|
|
|
2021-08-26 07:45:51 +01:00
|
|
|
ldflags = let
|
2021-01-08 01:58:22 +00:00
|
|
|
# Set a variety of useful meta variables for stamping the build with.
|
|
|
|
setVars = {
|
2021-12-07 15:04:09 +00:00
|
|
|
"github.com/pomerium/pomerium/internal/version" = {
|
|
|
|
Version = "v${version}";
|
|
|
|
BuildMeta = "nixpkgs";
|
|
|
|
ProjectName = "pomerium";
|
|
|
|
ProjectURL = "github.com/pomerium/pomerium";
|
|
|
|
};
|
|
|
|
"github.com/pomerium/pomerium/internal/envoy" = {
|
|
|
|
OverrideEnvoyPath = "${envoy}/bin/envoy";
|
|
|
|
};
|
2021-01-08 01:58:22 +00:00
|
|
|
};
|
2021-12-07 15:04:09 +00:00
|
|
|
concatStringsSpace = list: concatStringsSep " " list;
|
|
|
|
mapAttrsToFlatList = fn: list: concatMap id (mapAttrsToList fn list);
|
|
|
|
varFlags = concatStringsSpace (
|
|
|
|
mapAttrsToFlatList (package: packageVars:
|
|
|
|
mapAttrsToList (variable: value:
|
|
|
|
"-X ${package}.${variable}=${value}"
|
|
|
|
) packageVars
|
|
|
|
) setVars);
|
2021-01-08 01:58:22 +00:00
|
|
|
in [
|
2021-08-26 07:45:51 +01:00
|
|
|
"${varFlags}"
|
2021-01-08 01:58:22 +00:00
|
|
|
];
|
|
|
|
|
2021-09-18 03:57:32 +01:00
|
|
|
preBuild = ''
|
2021-12-07 15:04:09 +00:00
|
|
|
# Replace embedded envoy with nothing.
|
|
|
|
# We set OverrideEnvoyPath above, so rawBinary should never get looked at
|
|
|
|
# but we still need to set a checksum/version.
|
2021-09-18 03:57:32 +01:00
|
|
|
rm internal/envoy/files/files_{darwin,linux}*.go
|
|
|
|
cat <<EOF >internal/envoy/files/files_generic.go
|
|
|
|
package files
|
|
|
|
|
|
|
|
import _ "embed" // embed
|
|
|
|
|
|
|
|
var rawBinary []byte
|
2021-01-08 01:58:22 +00:00
|
|
|
|
2021-09-18 03:57:32 +01:00
|
|
|
//go:embed envoy.sha256
|
|
|
|
var rawChecksum string
|
2021-01-08 01:58:22 +00:00
|
|
|
|
2021-09-18 03:57:32 +01:00
|
|
|
//go:embed envoy.version
|
|
|
|
var rawVersion string
|
|
|
|
EOF
|
2021-12-07 15:04:09 +00:00
|
|
|
sha256sum '${envoy}/bin/envoy' > internal/envoy/files/envoy.sha256
|
|
|
|
echo '${envoy.version}' > internal/envoy/files/envoy.version
|
2021-01-08 01:58:22 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -Dm0755 $GOPATH/bin/pomerium $out/bin/pomerium
|
|
|
|
'';
|
|
|
|
|
2021-01-08 03:04:24 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit (nixosTests) pomerium;
|
2022-03-11 14:01:27 +00:00
|
|
|
inherit pomerium-cli;
|
2021-01-08 03:04:24 +00:00
|
|
|
};
|
|
|
|
|
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.
|
|
|
|
};
|
|
|
|
}
|