2022-08-18 08:28:31 +00:00
|
|
|
{
|
2023-09-08 11:00:13 +00:00
|
|
|
go_1_20,
|
2023-04-21 13:51:47 +00:00
|
|
|
buildGoApplication,
|
2022-09-25 18:38:42 +00:00
|
|
|
git,
|
|
|
|
fetchFromGitHub,
|
|
|
|
lib,
|
|
|
|
writeScript,
|
2023-09-08 11:00:13 +00:00
|
|
|
libde265,
|
|
|
|
libheif,
|
|
|
|
pkg-config,
|
|
|
|
cmake,
|
2022-09-25 18:38:42 +00:00
|
|
|
}: let
|
|
|
|
source = builtins.fromJSON (builtins.readFile ./source.json);
|
2023-09-08 11:00:13 +00:00
|
|
|
libheif' = libheif.overrideAttrs (super: rec {
|
|
|
|
version = "1.16.2";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "strukturag";
|
|
|
|
repo = "libheif";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "sha256-+6vWHkhsHSJDjOmNmdf18+IKavH/ysgfyxREMeTasLc=";
|
|
|
|
};
|
|
|
|
nativeBuildInputs = [cmake pkg-config];
|
|
|
|
});
|
2022-09-25 18:38:42 +00:00
|
|
|
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-09-08 14:35:57 +00:00
|
|
|
patches = [
|
|
|
|
./0001-Make-using-MD5-hashing-a-config-option-on-the-datast.patch
|
|
|
|
];
|
2023-04-21 13:51:47 +00:00
|
|
|
modules = ./gomod2nix.toml;
|
2023-09-08 11:00:13 +00:00
|
|
|
go = go_1_20;
|
2022-06-12 13:06:20 +00:00
|
|
|
nativeBuildInputs = [
|
2022-09-25 18:38:42 +00:00
|
|
|
git
|
2023-09-08 11:00:13 +00:00
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
buildInputs = [
|
|
|
|
libde265
|
|
|
|
libheif'
|
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
|
2022-06-12 14:10:57 +00:00
|
|
|
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-09-08 11:00:13 +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
|
2022-11-21 09:55:15 +00:00
|
|
|
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/
|
2022-11-21 09:55:15 +00:00
|
|
|
fi
|
2022-09-25 18:38:42 +00:00
|
|
|
'';
|
|
|
|
}
|