From d20e217b1c8af0b6bdb43a02e1a99419168ed9ba Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Thu, 6 Jun 2024 21:34:23 -0700 Subject: [PATCH] add nix derivation for complement Alternative to this would be just running 'go test' and pointing it at the complement source code when we want to do a test run. This would mean that we can't cache the unit test build, and would have to include the 'olm' input in the devshell. --- flake.nix | 3 +++ nix/pkgs/complement/default.nix | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 nix/pkgs/complement/default.nix diff --git a/flake.nix b/flake.nix index 50fe2135..9cdd3ceb 100644 --- a/flake.nix +++ b/flake.nix @@ -20,6 +20,8 @@ let # Keep sorted mkScope = pkgs: pkgs.lib.makeScope pkgs.newScope (self: { + complement = self.callPackage ./nix/pkgs/complement {}; + craneLib = (inputs.crane.mkLib pkgs).overrideToolchain self.toolchain; @@ -72,6 +74,7 @@ { packages = { default = (mkScope pkgs).default; + complement = (mkScope pkgs).complement; } // builtins.listToAttrs diff --git a/nix/pkgs/complement/default.nix b/nix/pkgs/complement/default.nix new file mode 100644 index 00000000..2494f064 --- /dev/null +++ b/nix/pkgs/complement/default.nix @@ -0,0 +1,33 @@ +# Dependencies (keep sorted) +{ buildGoModule +, fetchFromGitHub +, lib +, olm +}: + +buildGoModule { + name = "complement"; + + src = fetchFromGitHub { + owner = "matrix-org"; + repo = "complement"; + rev = "5b72981ea3de814a2c41e010dbc0a2cffcbd2e79"; + hash = "sha256-kSZcuXHHRsq6Vfv2rDBq682VdUkeRWse944fR25Zc0A="; + }; + + vendorHash = "sha256-mNt6lI4ppVjZC5UMsNqEDHQ0kjXutEFZTCMvXwp24ew="; + + buildInputs = [ olm ]; + + doCheck = false; + postBuild = '' + # compiles the tests into a binary + go test -c ./tests -o "$GOPATH/bin/complement.test" + ''; + + meta = { + description = "Matrix compliance test suite"; + homepage = "https://github.com/matrix-org/complement"; + license = lib.licenses.asl20; + }; +}