hswaw/laserproxy: fix nix build

This bitrot at some point. Now it's all freshened up.

Change-Id: Ia7df1ccd9b39d9180131452e9bf18d0fb8fa50d5
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1163
Reviewed-by: informatic <informatic@hackerspace.pl>
diff --git a/hswaw/laserproxy/default.nix b/hswaw/laserproxy/default.nix
index 5b235ef..f048ef4 100644
--- a/hswaw/laserproxy/default.nix
+++ b/hswaw/laserproxy/default.nix
@@ -15,7 +15,6 @@
     git python3 postgresql go
   ];
   patches = [
-    ./nix-disable-uwsgi.patch
     ./nix-use-system-go.patch
     ./nix-disable-workspace-status.patch
   ];
@@ -23,19 +22,29 @@
   removeRulesCC = false;
   fetchConfigured = true;
   fetchAttrs = {
-    inherit patches;
-    # Nicked from nixpkgs usages of buildBazelPackage.
+    # 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 = "0d0vlls1i0nmlqiszfhwb0cn1kwll3ffxd3sn30pk7drhfrbvqhf";
+    sha256 = "178ai44v8lczzy9gyqnkqmcnjvmw8m89qzaqv6my5fqkw6psliqz";
   };
   buildAttrs = {
     inherit patches;
diff --git a/hswaw/laserproxy/nix-disable-uwsgi.patch b/hswaw/laserproxy/nix-disable-uwsgi.patch
deleted file mode 100644
index 02a69b7..0000000
--- a/hswaw/laserproxy/nix-disable-uwsgi.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff --git a/third_party/py/requirements.txt b/third_party/py/requirements.txt
-index 94765d7..d7f0f3d 100644
---- a/third_party/py/requirements.txt
-+++ b/third_party/py/requirements.txt
-@@ -42,6 +42,5 @@ six==1.12.0
- SQLAlchemy==1.3.8
- sqlparse==0.3.0
- urllib3==1.25.3
--uWSGI==2.0.18
- Werkzeug==0.15.5
- WTForms==2.2.1
diff --git a/hswaw/laserproxy/nix-use-system-go.patch b/hswaw/laserproxy/nix-use-system-go.patch
index 15584f2..92880f5 100644
--- a/hswaw/laserproxy/nix-use-system-go.patch
+++ b/hswaw/laserproxy/nix-use-system-go.patch
@@ -1,13 +1,11 @@
-diff --git a/third_party/nix/repository_rules.bzl b/third_party/nix/repository_rules.bzl
-index 35c3d2d..3386d4b 100644
---- a/third_party/nix/repository_rules.bzl
-+++ b/third_party/nix/repository_rules.bzl
-@@ -16,7 +16,7 @@ def hscloud_go_register_toolchains():
-     imports_for_non_nix = """
- load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")
- def hscloud_go_register_toolchains():
--    go_register_toolchains()
-+    go_register_toolchains(go_version="host")
- """
+--- a/WORKSPACE	2021-10-07 21:56:55.869547029 +0200
++++ b/WORKSPACE	2021-10-16 20:23:37.841448038 +0200
+@@ -63,7 +63,7 @@
+ # Setup Go toolchain.
+ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains")
  
-     if has_nix(ctx):
+-go_register_toolchains(version = "1.17")
++go_register_toolchains(go_version = "host")
+ 
+ # IMPORTANT: match protobuf version above with the one loaded by grpc
+ http_archive(