Serge Bazanski | b1de757 | 2020-10-29 00:43:43 +0100 | [diff] [blame] | 1 | { hscloud, pkgs, ... }: |
| 2 | |
| 3 | # This supports building laserproxy in nix, which is used for deploying it to customs. |
| 4 | # This is mildly hacky and should be reworked to function for any hscloud bazel target |
| 5 | # in a more generic fashion. |
| 6 | # |
| 7 | # To build: |
| 8 | # ~/hscloud $ nix-build -A hswaw.laserproxy |
| 9 | |
| 10 | pkgs.buildBazelPackage rec { |
| 11 | name = "laserproxy"; |
| 12 | src = hscloud.root; |
| 13 | bazelTarget = "//hswaw/laserproxy"; |
| 14 | nativeBuildInputs = with pkgs; [ |
| 15 | git python3 postgresql go |
| 16 | ]; |
| 17 | patches = [ |
Serge Bazanski | b1de757 | 2020-10-29 00:43:43 +0100 | [diff] [blame] | 18 | ./nix-use-system-go.patch |
| 19 | ./nix-disable-workspace-status.patch |
| 20 | ]; |
| 21 | |
| 22 | removeRulesCC = false; |
| 23 | fetchConfigured = true; |
| 24 | fetchAttrs = { |
Serge Bazanski | ae2886b | 2021-10-16 20:35:21 +0200 | [diff] [blame^] | 25 | # Nicked from nixpkgs' usages of buildBazelPackage in bazel_watcher. |
Serge Bazanski | b1de757 | 2020-10-29 00:43:43 +0100 | [diff] [blame] | 26 | preInstall = '' |
Serge Bazanski | ae2886b | 2021-10-16 20:35:21 +0200 | [diff] [blame^] | 27 | # Remove the go_sdk (it's just a copy of the go derivation) and all |
| 28 | # references to it from the marker files. Bazel does not need to download |
| 29 | # this sdk because we have patched the WORKSPACE file to point to the one |
| 30 | # currently present in PATH. Without removing the go_sdk from the marker |
| 31 | # file, the hash of it will change anytime the Go derivation changes and |
| 32 | # that would lead to impurities in the marker files which would result in |
| 33 | # a different sha256 for the fetch phase. |
Serge Bazanski | b1de757 | 2020-10-29 00:43:43 +0100 | [diff] [blame] | 34 | rm -rf $bazelOut/external/{go_sdk,\@go_sdk.marker} |
| 35 | sed -e '/^FILE:@go_sdk.*/d' -i $bazelOut/external/\@*.marker |
Serge Bazanski | ae2886b | 2021-10-16 20:35:21 +0200 | [diff] [blame^] | 36 | |
| 37 | # Retains go build input markers |
Serge Bazanski | b1de757 | 2020-10-29 00:43:43 +0100 | [diff] [blame] | 38 | chmod -R 755 $bazelOut/external/{bazel_gazelle_go_repository_cache,@\bazel_gazelle_go_repository_cache.marker} |
| 39 | rm -rf $bazelOut/external/{bazel_gazelle_go_repository_cache,@\bazel_gazelle_go_repository_cache.marker} |
Serge Bazanski | ae2886b | 2021-10-16 20:35:21 +0200 | [diff] [blame^] | 40 | |
| 41 | # Remove the gazelle tools, they contain go binaries that are built |
| 42 | # non-deterministically. As long as the gazelle version matches the tools |
| 43 | # should be equivalent. |
Serge Bazanski | b1de757 | 2020-10-29 00:43:43 +0100 | [diff] [blame] | 44 | rm -rf $bazelOut/external/{bazel_gazelle_go_repository_tools,\@bazel_gazelle_go_repository_tools.marker} |
| 45 | sed -e '/^FILE:@bazel_gazelle_go_repository_tools.*/d' -i $bazelOut/external/\@*.marker |
| 46 | ''; |
Serge Bazanski | ae2886b | 2021-10-16 20:35:21 +0200 | [diff] [blame^] | 47 | sha256 = "178ai44v8lczzy9gyqnkqmcnjvmw8m89qzaqv6my5fqkw6psliqz"; |
Serge Bazanski | b1de757 | 2020-10-29 00:43:43 +0100 | [diff] [blame] | 48 | }; |
| 49 | buildAttrs = { |
| 50 | inherit patches; |
| 51 | installPhase = '' |
| 52 | install -Dm755 bazel-bin/hswaw/laserproxy/*/laserproxy $out/bin/laserproxy |
| 53 | ''; |
| 54 | }; |
| 55 | } |