This repository has been archived on 2024-10-13. You can view files and clone it, but cannot push or open issues or pull requests.
nix-packages/matrix/matrix-media-repo/default.nix

46 lines
1.5 KiB
Nix
Raw Normal View History

{
2022-10-23 10:12:24 +00:00
buildGo118Module,
2022-09-25 18:38:42 +00:00
git,
fetchFromGitHub,
lib,
writeScript,
}: let
source = builtins.fromJSON (builtins.readFile ./source.json);
in
2022-10-23 10:12:24 +00:00
buildGo118Module rec {
2022-06-12 13:06:20 +00:00
pname = "matrix-media-repo";
2022-09-25 18:38:42 +00:00
version = source.date;
src = fetchFromGitHub {
owner = "turt2live";
repo = "matrix-media-repo";
inherit (source) rev sha256;
};
patches = [./async-media.patch];
vendorSha256 = builtins.readFile ./vendor.sha256;
2022-06-12 13:06:20 +00:00
nativeBuildInputs = [
2022-09-25 18:38:42 +00:00
git
2022-06-12 13:06:20 +00:00
];
2022-08-18 09:01:45 +00:00
proxyVendor = true;
2022-06-12 14:22:57 +00:00
CGO_ENABLED = "1";
2022-06-12 13:06:20 +00:00
buildPhase = ''
GOBIN=$PWD/bin go install -v ./cmd/compile_assets
$PWD/bin/compile_assets
GOBIN=$PWD/bin go install -ldflags "-X github.com/turt2live/matrix-media-repo/common/version.GitCommit=$(git rev-list -1 HEAD) -X github.com/turt2live/matrix-media-repo/common/version.Version=${version}" -v ./cmd/...
2022-06-12 13:06:20 +00:00
'';
installPhase = ''
mkdir $out
cp -rv bin $out
'';
2022-09-25 18:38:42 +00:00
meta = {
description = "Matrix media repository with multi-domain in mind.";
license = lib.licenses.mit;
};
passthru.updateScript = writeScript "update-matrix-media-repo" ''
${../../scripts/update-git.sh} "https://github.com/turt2live/matrix-media-repo" matrix/matrix-media-repo/source.json
if [ "$(git diff -- matrix/matrix-media-repo/source.json)" ]; then
SRC_PATH=$(nix-build -E '(import ./. {}).${pname}.src')
${../../scripts/update-go.sh} ./matrix/matrix-media-repo matrix/matrix-media-repo/vendor.sha256
fi
2022-09-25 18:38:42 +00:00
'';
}