blob: f048ef45742238d73cd4b55e90d131f2c6ad38fe [file] [log] [blame]
{ hscloud, pkgs, ... }:
# This supports building laserproxy in nix, which is used for deploying it to customs.
# This is mildly hacky and should be reworked to function for any hscloud bazel target
# in a more generic fashion.
#
# To build:
# ~/hscloud $ nix-build -A hswaw.laserproxy
pkgs.buildBazelPackage rec {
name = "laserproxy";
src = hscloud.root;
bazelTarget = "//hswaw/laserproxy";
nativeBuildInputs = with pkgs; [
git python3 postgresql go
];
patches = [
./nix-use-system-go.patch
./nix-disable-workspace-status.patch
];
removeRulesCC = false;
fetchConfigured = true;
fetchAttrs = {
# Nicked from nixpkgs' usages of buildBazelPackage in bazel_watcher.
preInstall = ''
# Remove the go_sdk (it's just a copy of the go derivation) and all
# references to it from the marker files. Bazel does not need to download
# this sdk because we have patched the WORKSPACE file to point to the one
# currently present in PATH. Without removing the go_sdk from the marker
# file, the hash of it will change anytime the Go derivation changes and
# that would lead to impurities in the marker files which would result in
# a different sha256 for the fetch phase.
rm -rf $bazelOut/external/{go_sdk,\@go_sdk.marker}
sed -e '/^FILE:@go_sdk.*/d' -i $bazelOut/external/\@*.marker
# Retains go build input markers
chmod -R 755 $bazelOut/external/{bazel_gazelle_go_repository_cache,@\bazel_gazelle_go_repository_cache.marker}
rm -rf $bazelOut/external/{bazel_gazelle_go_repository_cache,@\bazel_gazelle_go_repository_cache.marker}
# Remove the gazelle tools, they contain go binaries that are built
# non-deterministically. As long as the gazelle version matches the tools
# should be equivalent.
rm -rf $bazelOut/external/{bazel_gazelle_go_repository_tools,\@bazel_gazelle_go_repository_tools.marker}
sed -e '/^FILE:@bazel_gazelle_go_repository_tools.*/d' -i $bazelOut/external/\@*.marker
'';
sha256 = "178ai44v8lczzy9gyqnkqmcnjvmw8m89qzaqv6my5fqkw6psliqz";
};
buildAttrs = {
inherit patches;
installPhase = ''
install -Dm755 bazel-bin/hswaw/laserproxy/*/laserproxy $out/bin/laserproxy
'';
};
}