laserproxy: add nix build

Change-Id: If93f4ba69afa028fed9098663a523f46d6134f7c
diff --git a/hswaw/laserproxy/default.nix b/hswaw/laserproxy/default.nix
new file mode 100644
index 0000000..5b235ef
--- /dev/null
+++ b/hswaw/laserproxy/default.nix
@@ -0,0 +1,46 @@
+{ 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-disable-uwsgi.patch
+    ./nix-use-system-go.patch
+    ./nix-disable-workspace-status.patch
+  ];
+
+  removeRulesCC = false;
+  fetchConfigured = true;
+  fetchAttrs = {
+    inherit patches;
+    # Nicked from nixpkgs usages of buildBazelPackage.
+    preInstall = ''
+      rm -rf $bazelOut/external/{go_sdk,\@go_sdk.marker}
+      sed -e '/^FILE:@go_sdk.*/d' -i $bazelOut/external/\@*.marker
+    
+      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}
+    
+      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 = "0d0vlls1i0nmlqiszfhwb0cn1kwll3ffxd3sn30pk7drhfrbvqhf";
+  };
+  buildAttrs = {
+    inherit patches;
+    installPhase = ''
+      install -Dm755 bazel-bin/hswaw/laserproxy/*/laserproxy $out/bin/laserproxy
+    '';
+  };
+}