diff options
Diffstat (limited to 'nixpkgs/pkgs/applications/audio/castopod')
-rw-r--r-- | nixpkgs/pkgs/applications/audio/castopod/default.nix | 53 | ||||
-rwxr-xr-x | nixpkgs/pkgs/applications/audio/castopod/update.sh | 89 |
2 files changed, 142 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/audio/castopod/default.nix b/nixpkgs/pkgs/applications/audio/castopod/default.nix new file mode 100644 index 000000000000..9d9f83e2ecce --- /dev/null +++ b/nixpkgs/pkgs/applications/audio/castopod/default.nix @@ -0,0 +1,53 @@ +{ stdenv +, fetchurl +, ffmpeg-headless +, lib +, nixosTests +, stateDirectory ? "/var/lib/castopod" +}: +stdenv.mkDerivation { + pname = "castopod"; + version = "1.6.4"; + + src = fetchurl { + url = "https://code.castopod.org/adaures/castopod/uploads/ce56d4f149242f12bedd20f9a2b0916d/castopod-1.6.4.tar.gz"; + sha256 = "080jj91yxbn3xsbs0sywzwa2f5in9bp9qi2zwqcfqpaxlq9ga62v"; + }; + + dontBuild = true; + dontFixup = true; + + postPatch = '' + # not configurable at runtime unfortunately: + substituteInPlace app/Config/Paths.php \ + --replace "__DIR__ . '/../../writable'" "'${stateDirectory}/writable'" + + # configuration file must be writable, place it to ${stateDirectory} + substituteInPlace modules/Install/Controllers/InstallController.php \ + --replace "ROOTPATH" "'${stateDirectory}/'" + substituteInPlace public/index.php spark \ + --replace "DotEnv(ROOTPATH)" "DotEnv('${stateDirectory}')" + + # ffmpeg is required for Video Clips feature + substituteInPlace modules/MediaClipper/VideoClipper.php \ + --replace "ffmpeg" "${ffmpeg-headless}/bin/ffmpeg" + substituteInPlace modules/Admin/Controllers/VideoClipsController.php \ + --replace "which ffmpeg" "echo ${ffmpeg-headless}/bin/ffmpeg" + ''; + + installPhase = '' + mkdir -p $out/share/castopod + cp -r . $out/share/castopod + ''; + + passthru.tests.castopod = nixosTests.castopod; + passthru.updateScript = ./update.sh; + + meta = with lib; { + description = "An open-source hosting platform made for podcasters who want to engage and interact with their audience"; + homepage = "https://castopod.org"; + license = licenses.agpl3Only; + maintainers = with maintainers; [ alexoundos misuzu ]; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/applications/audio/castopod/update.sh b/nixpkgs/pkgs/applications/audio/castopod/update.sh new file mode 100755 index 000000000000..742788dc8ddf --- /dev/null +++ b/nixpkgs/pkgs/applications/audio/castopod/update.sh @@ -0,0 +1,89 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p curl jq +set -euo pipefail + +nixpkgs="$(git rev-parse --show-toplevel)" +castopod_nix="$nixpkgs/pkgs/applications/audio/castopod/default.nix" + +# https://www.meetup.com/api/guide/#p02-querying-section +query=' +query allReleases($fullPath: ID!, $first: Int, $last: Int, $before: String, $after: String, $sort: ReleaseSort) { + project(fullPath: $fullPath) { + id + releases( + first: $first + last: $last + before: $before + after: $after + sort: $sort + ) { + nodes { + ...Release + __typename + } + __typename + } + __typename + } +} + +fragment Release on Release { + id + name + tagName + releasedAt + createdAt + upcomingRelease + historicalRelease + assets { + links { + nodes { + id + name + url + directAssetUrl + linkType + __typename + } + __typename + } + __typename + } + __typename +} +' +variables='{ + "fullPath": "adaures/castopod", + "first": 1, + "sort": "RELEASED_AT_DESC" +}' + +post=$(cat <<EOF +{"query": "$(echo $query)", "variables": $(echo $variables)} +EOF +) + +json="$(curl -s -X POST https://code.castopod.org/api/graphql \ + -H 'Content-Type: application/json' \ + -d "$post")" + +echo "$json" +TAG=$(echo $json | jq -r '.data.project.releases.nodes[].tagName') +ASSET_URL=$(echo $json | jq -r '.data.project.releases.nodes[].assets.links.nodes[].url' | grep .tar.gz$) + +CURRENT_VERSION=$(nix eval -f "$nixpkgs" --raw castopod.version) +VERSION=${TAG:1} + +if [[ "$CURRENT_VERSION" == "$VERSION" ]]; then + echo "castopod is up-to-date: ${CURRENT_VERSION}" + exit 0 +fi + +SHA256=$(nix-prefetch-url "$ASSET_URL") + +URL=$(echo $ASSET_URL | sed -e 's/[\/&]/\\&/g') + +sed -e "s/version =.*;/version = \"$VERSION\";/g" \ + -e "s/url =.*;/url = \"$URL\";/g" \ + -e "s/sha256 =.*;/sha256 = \"$SHA256\";/g" \ + -i "$castopod_nix" |