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
Charlotte 🦝 Delenk 901489102b
All checks were successful
Hydra papermc Hydra build #48037 of nix-packages:x86_64-linux-master-pr259:papermc
Hydra mautrix-discord Hydra build #48041 of nix-packages:x86_64-linux-master-pr259:mautrix-discord
Hydra mautrix-whatsapp Hydra build #48033 of nix-packages:aarch64-linux-master-pr259:mautrix-whatsapp
Hydra woodpecker-agent Hydra build #48031 of nix-packages:aarch64-linux-master-pr259:woodpecker-agent
Hydra woodpecker-frontend Hydra build #48032 of nix-packages:aarch64-linux-master-pr259:woodpecker-frontend
Hydra element-web Hydra build #48034 of nix-packages:aarch64-linux-master-pr259:element-web
Hydra woodpecker-cli Hydra build #48035 of nix-packages:aarch64-linux-master-pr259:woodpecker-cli
Hydra woodpecker-server Hydra build #48030 of nix-packages:aarch64-linux-master-pr259:woodpecker-server
update
2023-06-08 20:02:25 +01:00

45 lines
1.4 KiB
Nix

{
go_1_19,
buildGoApplication,
git,
fetchFromGitHub,
lib,
writeScript,
}: let
source = builtins.fromJSON (builtins.readFile ./source.json);
in
buildGoApplication rec {
pname = "matrix-media-repo";
version = source.date;
src = fetchFromGitHub {
owner = "turt2live";
repo = "matrix-media-repo";
inherit (source) rev sha256;
};
modules = ./gomod2nix.toml;
go = go_1_19;
nativeBuildInputs = [
git
];
CGO_ENABLED = "1";
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/...
'';
installPhase = ''
mkdir $out
cp -rv bin $out
'';
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} $SRC_PATH matrix/matrix-media-repo/
fi
'';
}