···1-#!/usr/bin/env bash
02set -e
34OWNER=mastodon
···41 esac
42done
4344-if [[ -z "$VERSION" || -n "$POSITIONAL" ]]; then
45- echo "Usage: update.sh [--owner OWNER] [--repo REPO] --ver VERSION [--rev REVISION] [--patches PATCHES]"
46- echo "OWNER and repo must be paths on github."
47- echo "If VERSION is not a revision acceptable to 'git checkout', you must provide one in REVISION."
48 echo "If OWNER and REPO are not provided, it defaults they default to mastodon and mastodon."
49 echo "PATCHES, if provided, should be one or more Nix expressions separated by spaces."
50 exit 1
51fi
5253if [[ -z "$REVISION" ]]; then
54- REVISION="$VERSION"
055fi
5657rm -f gemset.nix version.nix source.nix
58-TARGET_DIR="$PWD"
59-6061WORK_DIR=$(mktemp -d)
62···85# This file was generated by pkgs.mastodon.updateScript.
86{ fetchFromGitHub, applyPatches }: let
87 src = fetchFromGitHub {
88- owner = "mastodon";
89- repo = "mastodon";
90 rev = "$REVISION";
91 hash = "$HASH";
92 };
···99100echo "Creating gemset.nix"
101bundix --lockfile="$SOURCE_DIR/Gemfile.lock" --gemfile="$SOURCE_DIR/Gemfile"
102-echo "" >> "$TARGET_DIR/gemset.nix" # Create trailing newline to please EditorConfig checks
···1+#!/usr/bin/env nix-shell
2+#! nix-shell -i bash -p yarn2nix bundix coreutils diffutils nix-prefetch-github gnused jq
3set -e
45OWNER=mastodon
···42 esac
43done
4445+if [[ -n "$POSITIONAL" ]]; then
46+ echo "Usage: update.sh [--owner OWNER] [--repo REPO] [--ver VERSION] [--rev REVISION] [--patches PATCHES]"
47+ echo "OWNER and REPO must be paths on github."
48+ echo "If REVISION is not provided, the latest tag from github.com/mastodon/mastodon is fetched and VERSION is calculated from it."
49 echo "If OWNER and REPO are not provided, it defaults they default to mastodon and mastodon."
50 echo "PATCHES, if provided, should be one or more Nix expressions separated by spaces."
51 exit 1
52fi
5354if [[ -z "$REVISION" ]]; then
55+ REVISION="$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} -s "https://api.github.com/repos/$OWNER/$REPO/releases" | jq -r 'map(select(.prerelease == false)) | .[0].tag_name')"
56+ VERSION="$(echo "$REVISION" | cut -c2-)"
57fi
5859rm -f gemset.nix version.nix source.nix
60+cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
06162WORK_DIR=$(mktemp -d)
63···86# This file was generated by pkgs.mastodon.updateScript.
87{ fetchFromGitHub, applyPatches }: let
88 src = fetchFromGitHub {
89+ owner = "$OWNER";
90+ repo = "$REPO";
91 rev = "$REVISION";
92 hash = "$HASH";
93 };
···100101echo "Creating gemset.nix"
102bundix --lockfile="$SOURCE_DIR/Gemfile.lock" --gemfile="$SOURCE_DIR/Gemfile"
103+echo "" >> gemset.nix # Create trailing newline to please EditorConfig checks
···67 "--disable-shared" # brrr...
68 ];
69 }));
70- } // lib.optionalAttrs (stdenv0.hostPlatform.libc == "libc") {
71 extraBuildInputs = (old.extraBuildInputs or []) ++ [
72 pkgs.glibc.static
73 ];
···121 # Apple does not provide a static version of libSystem or crt0.o
122 # So we can’t build static binaries without extensive hacks.
123 ++ lib.optional (!stdenv.hostPlatform.isDarwin) makeStaticBinaries
124-125- # Glibc doesn’t come with static runtimes by default.
126- # ++ lib.optional (stdenv.hostPlatform.libc == "glibc") ((lib.flip overrideInStdenv) [ self.glibc.static ])
127 );
128129
···67 "--disable-shared" # brrr...
68 ];
69 }));
70+ } // lib.optionalAttrs (stdenv0.hostPlatform.libc == "glibc") {
71 extraBuildInputs = (old.extraBuildInputs or []) ++ [
72 pkgs.glibc.static
73 ];
···121 # Apple does not provide a static version of libSystem or crt0.o
122 # So we can’t build static binaries without extensive hacks.
123 ++ lib.optional (!stdenv.hostPlatform.isDarwin) makeStaticBinaries
000124 );
125126