Commit f4450f90 authored by Rhys Davies's avatar Rhys Davies
Browse files

micropad: use fetchYarnDeps

parent 037a0529
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
{ lib
, stdenv
, fetchFromGitHub
, fetchYarnDeps
, fetchzip
, makeWrapper
, makeDesktopItem
@@ -29,8 +30,11 @@ in
    };

    packageJSON = ./package.json;
    yarnLock = ./yarn.lock;
    yarnNix = ./yarn.nix;

    offlineCache = fetchYarnDeps {
      yarnLock = "${src}/yarn.lock";
      hash = "sha256-3p+fTyei6THZIYbxg30ybr1r+PxbLyO0ypt+bP5P9QM=";
    };

    nativeBuildInputs = [ copyDesktopItems makeWrapper ]
      ++ lib.optionals stdenv.isDarwin [ desktopToDarwinBundle ];
+6 −9
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl common-updater-scripts jq nix nodePackages.prettier yarn2nix
#!nix-shell -i bash -p curl common-updater-scripts jq nix nodePackages.prettier prefetch-yarn-deps

set -eu -o pipefail

latest_version=$(curl -s https://api.github.com/repos/MicroPad/Micropad-Electron/releases/latest | jq --raw-output '.tag_name[1:]')
old_core_hash=$(nix-instantiate --eval --strict -A "micropad.micropad-core.drvAttrs.outputHash" | tr -d '"' | sed -re 's|[+]|\\&|g')

{
    read new_core_hash
    read store_path
} < <(
    nix-prefetch-url --unpack --print-path "https://github.com/MicroPad/MicroPad-Core/releases/download/v$latest_version/micropad.tar.xz"
)
new_core_hash=$(nix hash to-sri --type sha256 $(nix-prefetch-url --unpack "https://github.com/MicroPad/MicroPad-Core/releases/download/v$latest_version/micropad.tar.xz"))

nixFile=$(nix-instantiate --eval --strict -A "micropad.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
nixFolder=$(dirname "$nixFile")
@@ -22,6 +16,9 @@ curl -o "$nixFolder/package.json" -s "https://raw.githubusercontent.com/MicroPad
curl -o "$nixFolder/yarn.lock" -s "https://raw.githubusercontent.com/MicroPad/MicroPad-Electron/v$latest_version/yarn.lock"

prettier --write "$nixFolder/package.json"
yarn2nix --lockfile "$nixFolder/yarn.lock" >"$nixFolder/yarn.nix"
old_yarn_hash=$(nix-instantiate --eval --strict -A "micropad.offlineCache.outputHash" | tr -d '"' | sed -re 's|[+]|\\&|g')
new_yarn_hash=$(nix hash to-sri --type sha256 $(prefetch-yarn-deps "$nixFolder/yarn.lock"))
sed -i "$nixFile" -re "s|\"$old_yarn_hash\"|\"$new_yarn_hash\"|"
rm "$nixFolder/yarn.lock"

update-source-version micropad "$latest_version"
+0 −1733

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −2013

File deleted.

Preview size limit exceeded, changes collapsed.