2021-04-05 15:23:46 +00:00
|
|
|
{ buildGoModule
|
|
|
|
, fetchFromGitHub
|
2022-09-09 14:08:57 +00:00
|
|
|
, callPackage
|
2021-04-05 15:23:46 +00:00
|
|
|
, lib
|
|
|
|
, envoy
|
2022-09-09 14:08:57 +00:00
|
|
|
, mkYarnPackage
|
|
|
|
, fetchYarnDeps
|
2021-04-05 15:23:46 +00:00
|
|
|
, nixosTests
|
2022-03-05 16:20:37 +00:00
|
|
|
, pomerium-cli
|
2021-04-05 15:23:46 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-12-06 16:07:01 +00:00
|
|
|
inherit (lib) concatStringsSep concatMap id mapAttrsToList;
|
2021-04-05 15:23:46 +00:00
|
|
|
in
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "pomerium";
|
2023-03-24 00:07:29 +00:00
|
|
|
version = "0.21.2";
|
2021-04-05 15:23:46 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pomerium";
|
|
|
|
repo = "pomerium";
|
|
|
|
rev = "v${version}";
|
2023-03-24 00:07:29 +00:00
|
|
|
sha256 = "sha256-wsfbG4VAS3U3voDdry35QlWknlWIfThZQalf9S/9GO0=";
|
2022-09-09 14:08:57 +00:00
|
|
|
};
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
vendorSha256 = "sha256-8g3jhxKIT0EGUXh0hrvDbw3i04khqlAfGzM6k4q3O8g=";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
ui = mkYarnPackage {
|
|
|
|
inherit version;
|
|
|
|
src = "${src}/ui";
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
packageJSON = ./package.json;
|
2022-09-09 14:08:57 +00:00
|
|
|
offlineCache = fetchYarnDeps {
|
|
|
|
yarnLock = "${src}/ui/yarn.lock";
|
2023-03-24 00:07:29 +00:00
|
|
|
sha256 = lib.fileContents ./yarn-hash;
|
2022-09-09 14:08:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
yarn --offline build
|
|
|
|
runHook postbuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
cp -R deps/pomerium/dist $out
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
doDist = false;
|
2021-04-05 15:23:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
subPackages = [
|
|
|
|
"cmd/pomerium"
|
|
|
|
];
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
# patch pomerium to allow use of external envoy
|
|
|
|
patches = [ ./external-envoy.diff ];
|
|
|
|
|
2021-08-27 14:25:00 +00:00
|
|
|
ldflags = let
|
2021-04-05 15:23:46 +00:00
|
|
|
# Set a variety of useful meta variables for stamping the build with.
|
|
|
|
setVars = {
|
2021-12-06 16:07:01 +00:00
|
|
|
"github.com/pomerium/pomerium/internal/version" = {
|
|
|
|
Version = "v${version}";
|
|
|
|
BuildMeta = "nixpkgs";
|
|
|
|
ProjectName = "pomerium";
|
|
|
|
ProjectURL = "github.com/pomerium/pomerium";
|
|
|
|
};
|
2022-09-09 14:08:57 +00:00
|
|
|
"github.com/pomerium/pomerium/pkg/envoy" = {
|
2021-12-06 16:07:01 +00:00
|
|
|
OverrideEnvoyPath = "${envoy}/bin/envoy";
|
|
|
|
};
|
2021-04-05 15:23:46 +00:00
|
|
|
};
|
2021-12-06 16:07:01 +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-04-05 15:23:46 +00:00
|
|
|
in [
|
2021-08-27 14:25:00 +00:00
|
|
|
"${varFlags}"
|
2021-04-05 15:23:46 +00:00
|
|
|
];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
preBuild = ''
|
|
|
|
# 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.
|
2022-09-09 14:08:57 +00:00
|
|
|
rm pkg/envoy/files/files_{darwin,linux}*.go
|
|
|
|
cat <<EOF >pkg/envoy/files/files_external.go
|
2021-12-06 16:07:01 +00:00
|
|
|
package files
|
2021-04-05 15:23:46 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
import _ "embed" // embed
|
2021-04-05 15:23:46 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
var rawBinary []byte
|
2021-04-05 15:23:46 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
//go:embed envoy.sha256
|
|
|
|
var rawChecksum string
|
|
|
|
|
|
|
|
//go:embed envoy.version
|
|
|
|
var rawVersion string
|
|
|
|
EOF
|
2022-09-09 14:08:57 +00:00
|
|
|
sha256sum '${envoy}/bin/envoy' > pkg/envoy/files/envoy.sha256
|
|
|
|
echo '${envoy.version}' > pkg/envoy/files/envoy.version
|
|
|
|
|
|
|
|
# put the built UI files where they will be picked up as part of binary build
|
|
|
|
cp -r ${ui}/* ui/dist
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
2021-04-05 15:23:46 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -Dm0755 $GOPATH/bin/pomerium $out/bin/pomerium
|
|
|
|
'';
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
passthru = {
|
|
|
|
tests = {
|
|
|
|
inherit (nixosTests) pomerium;
|
|
|
|
inherit pomerium-cli;
|
|
|
|
};
|
|
|
|
updateScript = ./updater.sh;
|
2021-04-05 15:23:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://pomerium.io";
|
|
|
|
description = "Authenticating reverse proxy";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ lukegb ];
|
2022-04-27 09:35:20 +00:00
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" ];
|
2021-04-05 15:23:46 +00:00
|
|
|
};
|
|
|
|
}
|