diff --git a/pkgs/servers/mastodon/source.nix b/pkgs/servers/mastodon/source.nix index 1daa150d8456..8809483fe17d 100644 --- a/pkgs/servers/mastodon/source.nix +++ b/pkgs/servers/mastodon/source.nix @@ -1,9 +1,10 @@ # This file was generated by pkgs.mastodon.updateScript. -{ fetchgit, applyPatches }: let - src = fetchgit { - url = "https://github.com/mastodon/mastodon.git"; +{ fetchFromGitHub, applyPatches }: let + src = fetchFromGitHub { + owner = "mastodon"; + repo = "mastodon"; rev = "v4.1.2"; - sha256 = "18yzpc2rz9sa04y2sdxzsfkndbqqsfqvji47imwc3yj40l8hciws"; + sha256 = "mkcGEQVE+sF4jYdEubHTGK9mp9O/Ny08AUqnnwW736M="; }; in applyPatches { inherit src; diff --git a/pkgs/servers/mastodon/update.nix b/pkgs/servers/mastodon/update.nix index 1bd557a74a5b..f9dc8db3980a 100644 --- a/pkgs/servers/mastodon/update.nix +++ b/pkgs/servers/mastodon/update.nix @@ -1,17 +1,16 @@ -{ pkgs -, runCommand +{ runCommand , lib , makeWrapper , yarn2nix , bundix , coreutils , diffutils -, nix-prefetch-git +, nix-prefetch-github , gnused , jq }: let - binPath = lib.makeBinPath [ yarn2nix bundix coreutils diffutils nix-prefetch-git gnused jq ]; + binPath = lib.makeBinPath [ yarn2nix bundix coreutils diffutils nix-prefetch-github gnused jq ]; in runCommand "mastodon-update-script" { diff --git a/pkgs/servers/mastodon/update.sh b/pkgs/servers/mastodon/update.sh index 3a0686a72158..7b4d97fd1397 100755 --- a/pkgs/servers/mastodon/update.sh +++ b/pkgs/servers/mastodon/update.sh @@ -1,15 +1,21 @@ #!/usr/bin/env bash set -e -URL=https://github.com/mastodon/mastodon.git +OWNER=mastodon +REPO=mastodon POSITIONAL=() while [[ $# -gt 0 ]]; do key="$1" case $key in - --url) - URL="$2" + --owner) + OWNER="$2" + shift # past argument + shift # past value + ;; + --repo) + REPO="$2" shift # past argument shift # past value ;; @@ -36,13 +42,11 @@ while [[ $# -gt 0 ]]; do done if [[ -z "$VERSION" || -n "$POSITIONAL" ]]; then - echo "Usage: update.sh [--url URL] --ver VERSION [--rev REVISION] [--patches PATCHES]" - echo "URL may be any path acceptable to 'git clone' and VERSION the" - echo "semantic version number. If VERSION is not a revision acceptable to" - echo "'git checkout', you must provide one in REVISION. If URL is not" - echo "provided, it defaults to https://github.com/mastodon/mastodon.git." - echo "PATCHES, if provided, should be one or more Nix expressions" - echo "separated by spaces." + echo "Usage: update.sh [--owner OWNER] [--repo REPO] --ver VERSION [--rev REVISION] [--patches PATCHES]" + echo "OWNER and repo must be paths on github." + echo "If VERSION is not a revision acceptable to 'git checkout', you must provide one in REVISION." + echo "If OWNER and REPO are not provided, it defaults they default to mastodon and mastodon." + echo "PATCHES, if provided, should be one or more Nix expressions separated by spaces." exit 1 fi @@ -57,7 +61,7 @@ TARGET_DIR="$PWD" WORK_DIR=$(mktemp -d) # Check that working directory was created. -if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then +if [[ -z "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then echo "Could not create temporary directory" exit 1 fi @@ -70,19 +74,19 @@ function cleanup { } trap cleanup EXIT -echo "Fetching source code $REVISION from $URL" -JSON=$(nix-prefetch-git --url "$URL" --rev "$REVISION" 2> $WORK_DIR/nix-prefetch-git.out) -SHA=$(echo $JSON | jq -r .sha256) -FETCHED_SOURCE_DIR=$(grep '^path is' $WORK_DIR/nix-prefetch-git.out | sed 's/^path is //') +echo "Fetching source code $REVISION" +JSON=$(nix-prefetch-github "$OWNER" "$REPO" --rev "$REVISION" 2> $WORK_DIR/nix-prefetch-git.out) +SHA=$(echo "$JSON" | jq -r .sha256) echo "Creating version.nix" -echo \"$VERSION\" | sed 's/^"v/"/' > version.nix +echo "\"$VERSION\"" | sed 's/^"v/"/' > version.nix cat > source.nix << EOF # This file was generated by pkgs.mastodon.updateScript. -{ fetchgit, applyPatches }: let - src = fetchgit { - url = "$URL"; +{ fetchFromGitHub, applyPatches }: let + src = fetchFromGitHub { + owner = "mastodon"; + repo = "mastodon"; rev = "$REVISION"; sha256 = "$SHA"; }; @@ -95,4 +99,4 @@ SOURCE_DIR="$(nix-build --no-out-link -E '(import {}).callPackage ./so echo "Creating gemset.nix" bundix --lockfile="$SOURCE_DIR/Gemfile.lock" --gemfile="$SOURCE_DIR/Gemfile" -echo "" >> $TARGET_DIR/gemset.nix # Create trailing newline to please EditorConfig checks +echo "" >> "$TARGET_DIR/gemset.nix" # Create trailing newline to please EditorConfig checks