Unverified Commit 8819f633 authored by Lily Foster's avatar Lily Foster
Browse files

open-stage-control: 1.18.3 -> 1.20.0

parent 94191b60
Loading
Loading
Loading
Loading
+24 −20
Original line number Diff line number Diff line
{ pkgs, stdenv, lib, fetchFromGitHub, makeBinaryWrapper, makeDesktopItem, copyDesktopItems, nodejs, electron, python3, ... }:
{ lib, buildNpmPackage, fetchFromGitHub, makeBinaryWrapper, makeDesktopItem, copyDesktopItems, electron, python3 }:

let
  nodeComposition = import ./node-composition.nix {
    inherit pkgs nodejs;
    inherit (stdenv.hostPlatform) system;
  };
in

nodeComposition.package.override rec {
buildNpmPackage rec {
  pname = "open-stage-control";
  version = "1.18.3";
  version = "1.20.0";

  src = fetchFromGitHub {
    owner = "jean-emmanuel";
    repo = "open-stage-control";
    rev = "v${version}";
    hash = "sha256-AXdPxTauy2rMRMdfUjkfTjbNDgOKmoiGUeeLak0wu84=";
    hash = "sha256-XgwlRdwUSl4gIRKqk6BnMAKarVvp291zk8vmNkuRWKo=";
  };

  strictDeps = true;
  patches = [
    # Use generated package-lock.json since upstream does not provide one in releases
    ./package-lock.json.patch
  ];

  npmDepsHash = "sha256-UF3pZ+SlrgDLqntciXRNbWfpPMtQw1DXl41x9r37QN4=";

  nativeBuildInputs = [
    copyDesktopItems
    makeBinaryWrapper
    nodejs
    python3
  ];

@@ -33,14 +30,19 @@ nodeComposition.package.override rec {

  doInstallCheck = true;

  preRebuild = ''
    # remove electron to prevent building since nixpkgs electron is used instead
    rm -r node_modules/electron
  '';
  makeCacheWritable = true;
  npmFlags = [ "--legacy-peer-deps" ];

  # Override installPhase so we can copy the only folders that matter (app and node_modules)
  installPhase = ''
    runHook preInstall

  postInstall = ''
    # build assets
    npm run build
    # prune unused deps
    npm prune --omit dev $npmFlags

    # copy built app and node_modules directories
    mkdir -p $out/lib/node_modules/open-stage-control
    cp -r app node_modules $out/lib/node_modules/open-stage-control/

    # copy icon
    install -Dm644 resources/images/logo.png $out/share/icons/hicolor/256x256/apps/open-stage-control.png
@@ -52,6 +54,8 @@ nodeComposition.package.override rec {
      --add-flags $out/lib/node_modules/open-stage-control/app \
      --prefix PYTHONPATH : "$PYTHONPATH" \
      --prefix PATH : '${lib.makeBinPath [ python3 ]}'

    runHook postInstall
  '';

  installCheckPhase = ''
+0 −17
Original line number Diff line number Diff line
# This file has been generated by node2nix 1.11.1. Do not edit!

{pkgs ? import <nixpkgs> {
    inherit system;
  }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-16_x"}:

let
  nodeEnv = import ../../../development/node-packages/node-env.nix {
    inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
    inherit pkgs nodejs;
    libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
  };
in
import ./node-packages.nix {
  inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
  inherit nodeEnv;
}
+0 −9220

File deleted.

Preview size limit exceeded, changes collapsed.

+18247 −0

File added.

Preview size limit exceeded, changes collapsed.

+52 −14
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p common-updater-scripts jq nodePackages.node2nix
#! nix-shell -i bash -p common-updater-scripts jq nodejs
set -euo pipefail

# Find nixpkgs repo
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))"

# Get latest release tag
tag="$(curl -s https://api.github.com/repos/jean-emmanuel/open-stage-control/releases/latest | jq -r .tag_name)"
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 -f "$nixpkgs" --no-link "$1" 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:-open-stage-control}"
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")"
pkgdir="$(dirname "$pkgpath")"

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

# Download package.json from the latest release
curl -sSL https://raw.githubusercontent.com/jean-emmanuel/open-stage-control/"$tag"/package.json | grep -v '"electron"\|"electron-installer-debian"' >"$nixpkgs"/pkgs/applications/audio/open-stage-control/package.json
curl -sSL https://raw.githubusercontent.com/jean-emmanuel/open-stage-control/v"$version"/package.json | grep -v '"electron"\|"electron-installer-debian"' >"$pkgdir"/package.json

# Lock dependencies with npm
(cd "$pkgdir" && npm install --package-lock-only --ignore-scripts --legacy-peer-deps)

# Turn lock file into patch file
(cd "$pkgdir" && (diff -u /dev/null ./package-lock.json || [ $? -eq 1 ])) >"$pkgdir"/package-lock.json.patch

# Lock dependencies with node2nix
node2nix \
  --node-env "$nixpkgs"/pkgs/development/node-packages/node-env.nix \
  --nodejs-16 \
  --input "$nixpkgs"/pkgs/applications/audio/open-stage-control/package.json \
  --output "$nixpkgs"/pkgs/applications/audio/open-stage-control/node-packages.nix \
  --composition "$nixpkgs"/pkgs/applications/audio/open-stage-control/node-composition.nix
rm -f "$pkgdir"/{package.json,package-lock.json}

rm -f "$nixpkgs"/pkgs/applications/audio/open-stage-control/package.json
# Update FOD hash
curhash="$(nixeval "$attr.npmDeps.outputHash")"
newhash="$(vendorhash "$attr.npmDeps")"

# Update hash
(cd "$nixpkgs" && update-source-version "${UPDATE_NIX_ATTR_PATH:-open-stage-control}" "${tag#v}")
if [ -n "$newhash" ] && [ "$curhash" != "$newhash" ]; then
    sed -i -e "s|\"$curhash\"|\"$newhash\"|" "$pkgpath"
else
    echo 'update.sh: New npmDepsHash same as old npmDepsHash, nothing to do.'
fi
Loading