From 20c6bcb7305d4b85c5fd6dfc72c04c68b772d15f Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Sat, 16 Oct 2021 23:07:29 +0200 Subject: [PATCH] hswaw/laserproxy: limit nix rebuilds Change-Id: I6d8208b46524adf6542a1164910f3b7818f47910 Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1168 Reviewed-by: q3k --- hswaw/laserproxy/default.nix | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/hswaw/laserproxy/default.nix b/hswaw/laserproxy/default.nix index f048ef45..d6f48f13 100644 --- a/hswaw/laserproxy/default.nix +++ b/hswaw/laserproxy/default.nix @@ -1,4 +1,4 @@ -{ hscloud, pkgs, ... }: +{ hscloud, lib, 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 @@ -9,7 +9,32 @@ pkgs.buildBazelPackage rec { name = "laserproxy"; - src = hscloud.root; + + # Cleanup source tree to limit impact of unrelated changes to hscloud source + # tree on nix build cache. This should only pass over: + # //BUILD, //WORKSPACE, //.bazelrc + # //hscloud/go/** + # //hscloud/third_party/** + # //hscloud/devtools/gerrit/** (WORKSPACE reference) + # //hswaw/laserproxy/** (our build target) + src = lib.cleanSourceWith { + filter = name: type: ( + lib.strings.hasInfix "/go" name || + lib.strings.hasInfix "/third_party" name || + + lib.strings.hasSuffix "/devtools" name || + lib.strings.hasInfix "/devtools/gerrit" name || + + lib.strings.hasSuffix "/hswaw" name || + lib.strings.hasInfix "/hswaw/laserproxy" name || + + lib.strings.hasSuffix "/BUILD" name || + lib.strings.hasSuffix "/WORKSPACE" name || + lib.strings.hasSuffix "/.bazelrc" name + ); + src = hscloud.root; + }; + bazelTarget = "//hswaw/laserproxy"; nativeBuildInputs = with pkgs; [ git python3 postgresql go