From 2f8266e02234a6a2e2ce2b939366e63b5369c278 Mon Sep 17 00:00:00 2001 From: Lily Foster Date: Tue, 3 Jan 2023 08:13:03 -0500 Subject: [PATCH 1/2] sonic-pi: add updateScript --- pkgs/applications/audio/sonic-pi/default.nix | 2 + pkgs/applications/audio/sonic-pi/update.sh | 50 ++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 pkgs/applications/audio/sonic-pi/update.sh diff --git a/pkgs/applications/audio/sonic-pi/default.nix b/pkgs/applications/audio/sonic-pi/default.nix index 1f5bb36a514..85e9d514a51 100644 --- a/pkgs/applications/audio/sonic-pi/default.nix +++ b/pkgs/applications/audio/sonic-pi/default.nix @@ -216,6 +216,8 @@ stdenv.mkDerivation rec { }) ]; + passthru.updateScript = ./update.sh; + meta = with lib; { homepage = "https://sonic-pi.net/"; description = "Free live coding synth for everyone originally designed to support computing and music lessons within schools"; diff --git a/pkgs/applications/audio/sonic-pi/update.sh b/pkgs/applications/audio/sonic-pi/update.sh new file mode 100755 index 00000000000..014af49e73a --- /dev/null +++ b/pkgs/applications/audio/sonic-pi/update.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p nix jq common-updater-scripts + +set -euo pipefail + +nixpkgs="$(git rev-parse --show-toplevel || (printf 'Could not find root of nixpkgs repo\nAre we running from within the nixpkgs git repo?\n' >&2; exit 1))" + +stripwhitespace() { + sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' +} + +nixeval() { + nix --extra-experimental-features nix-command eval --json --impure -f "$nixpkgs" "$1" | jq -r . +} + +vendorhash() { + (nix --extra-experimental-features nix-command build --impure --argstr nixpkgs "$nixpkgs" --argstr attr "$1" --expr '{ nixpkgs, attr }: let pkgs = import nixpkgs {}; in with pkgs.lib; (getAttrFromPath (splitString "." attr) pkgs).overrideAttrs (attrs: { outputHash = fakeHash; })' --no-link 2>&1 >/dev/null | tail -n3 | grep -F got: | cut -d: -f2- | stripwhitespace) 2>/dev/null || true +} + +findpath() { + path="$(nix --extra-experimental-features nix-command eval --json --impure -f "$nixpkgs" "$1.meta.position" | jq -r . | cut -d: -f1)" + outpath="$(nix --extra-experimental-features nix-command eval --json --impure --expr "builtins.fetchGit \"$nixpkgs\"")" + + if [ -n "$outpath" ]; then + path="${path/$(echo "$outpath" | jq -r .)/$nixpkgs}" + fi + + echo "$path" +} + +attr="${UPDATE_NIX_ATTR_PATH:-sonic-pi}" +version="$(cd "$nixpkgs" && list-git-tags --pname="$(nixeval "$attr".pname)" --attr-path="$attr" | grep '^v' | sed -e 's|^v||' | sort -V | tail -n1)" + +pkgpath="$(findpath "$attr")" + +updated="$(cd "$nixpkgs" && update-source-version "$attr" "$version" --file="$pkgpath" --print-changes | jq -r length)" + +if [ "$updated" -eq 0 ]; then + echo 'update.sh: Package version not updated, nothing to do.' + exit 0 +fi + +curhash="$(nixeval "$attr.mixFodDeps.outputHash")" +newhash="$(vendorhash "$attr.mixFodDeps")" + +if [ -n "$newhash" ] && [ "$curhash" != "$newhash" ]; then + sed -i -e "s|\"$curhash\"|\"$newhash\"|" "$pkgpath" +else + echo 'update.sh: New vendorHash same as old vendorHash, nothing to do.' +fi From 5988ada8358cb66b5486889db22aba37caaf4f4c Mon Sep 17 00:00:00 2001 From: Lily Foster Date: Tue, 3 Jan 2023 08:08:40 -0500 Subject: [PATCH 2/2] sonic-pi: add ruby to nativeBuildInputs The ruby interpreter is used during the configure and build phases in addition to the check phase, so add it to nativeBuildInputs instead of checkInputs. --- pkgs/applications/audio/sonic-pi/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/audio/sonic-pi/default.nix b/pkgs/applications/audio/sonic-pi/default.nix index 85e9d514a51..dc8ce444482 100644 --- a/pkgs/applications/audio/sonic-pi/default.nix +++ b/pkgs/applications/audio/sonic-pi/default.nix @@ -63,6 +63,7 @@ stdenv.mkDerivation rec { copyDesktopItems cmake pkg-config + ruby erlang elixir beamPackages.hex @@ -94,7 +95,6 @@ stdenv.mkDerivation rec { checkInputs = [ parallel - ruby supercollider-with-sc3-plugins jack2 ];