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

52 lines
1.6 KiB
Nix
Raw Normal View History

{
2023-04-21 13:51:47 +00:00
go_1_19,
buildGoApplication,
2022-09-25 18:38:42 +00:00
git,
fetchFromGitHub,
lib,
writeScript,
}: let
source = builtins.fromJSON (builtins.readFile ./source.json);
in
2023-04-21 13:51:47 +00:00
buildGoApplication 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;
};
2023-04-21 13:51:47 +00:00
modules = ./gomod2nix.toml;
go = go_1_19;
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-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;
};
2023-08-22 12:10:26 +00:00
postConfigure = ''
chmod -R +w vendor/
for f in vendor/golang.org/x/net/publicsuffix/data/*; do
cp -v --remove-destination -f `readlink $f` $f
done
'';
2023-06-08 19:02:25 +00:00
passthru.updateScript' = writeScript "update-matrix-media-repo" ''
2022-09-25 18:38:42 +00:00
${../../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')
2023-04-21 13:51:47 +00:00
${../../scripts/update-go.sh} $SRC_PATH matrix/matrix-media-repo/
fi
2022-09-25 18:38:42 +00:00
'';
}