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/update.sh

37 lines
980 B
Bash
Raw Normal View History

2022-06-12 13:06:20 +00:00
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p nix-prefetch-git nix-prefetch jq
2022-06-12 13:06:20 +00:00
set -e
WORK_DIR=$(mktemp -d)
URL=https://github.com/turt2live/matrix-media-repo
REVISION=$(jq -r '.nodes."matrix-media-repo".locked.rev' ../../flake.lock)
TARGET_DIR="$PWD"
function cleanup {
grep "fatal" $WORK_DIR/nix-prefetch-git.out >/dev/stderr || true
rm -rf "$WORK_DIR"
}
trap cleanup EXIT
echo "Fetching source code $REVISION from $URL"
2022-06-12 14:03:59 +00:00
JSON=$(nix-prefetch-git --url "$URL" --rev "$REVISION" --leave-dotGit 2> $WORK_DIR/nix-prefetch-git.out)
2022-06-12 13:06:20 +00:00
SHA=$(echo $JSON | jq -r .sha256)
SOURCE_DIR=$(grep '^path is' $WORK_DIR/nix-prefetch-git.out | sed 's/^path is //')
cat > source.nix << EOF
2022-07-19 19:56:40 +00:00
{applyPatches, fetchgit}:
applyPatches {
src = fetchgit {
url = "$URL";
rev = "$REVISION";
sha256 = "$SHA";
leaveDotGit = true;
};
patches = [
./async-media.patch
];
}
EOF
2022-07-19 20:10:17 +00:00
SOURCE_DIR="$(nix-build --no-out-link -E '(import <nixpkgs> {}).callPackage ./source.nix {}')"