mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 19:21:04 +00:00
micropad: reformat using yarn{Config,Build}Hooks
This commit is contained in:
parent
5403387f87
commit
ef845dd609
|
@ -2,100 +2,88 @@
|
|||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, fetchYarnDeps
|
||||
, yarnBuildHook
|
||||
, fetchzip
|
||||
, makeWrapper
|
||||
, makeDesktopItem
|
||||
, mkYarnPackage
|
||||
, electron
|
||||
, desktopToDarwinBundle
|
||||
, copyDesktopItems
|
||||
}:
|
||||
let
|
||||
executableName = "micropad";
|
||||
in
|
||||
mkYarnPackage rec {
|
||||
pname = "micropad";
|
||||
version = "4.5.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "MicroPad";
|
||||
repo = "Micropad-Electron";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-z+g+FwmoX4Qqf+v4BVLCtfrXwGiAUFlPLQQhp2CMhLU=";
|
||||
};
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "micropad";
|
||||
version = "4.5.1";
|
||||
|
||||
micropad-core = fetchzip {
|
||||
url = "https://github.com/MicroPad/MicroPad-Core/releases/download/v${version}/micropad.tar.xz";
|
||||
hash = "sha256-y13PVA/AKKsc5q7NDwZFasb7fOo+56IW8qbTbsm2WWc=";
|
||||
};
|
||||
src = fetchFromGitHub {
|
||||
owner = "MicroPad";
|
||||
repo = "Micropad-Electron";
|
||||
rev = "v${finalAttrs.version}";
|
||||
hash = "sha256-z+g+FwmoX4Qqf+v4BVLCtfrXwGiAUFlPLQQhp2CMhLU=";
|
||||
};
|
||||
|
||||
packageJSON = ./package.json;
|
||||
# This project can't be built from source currently, because Nixpkgs lacks
|
||||
# ecosystem for https://bun.sh
|
||||
micropad-core = fetchzip {
|
||||
url = "https://github.com/MicroPad/MicroPad-Core/releases/download/v${finalAttrs.version}/micropad.tar.xz";
|
||||
hash = "sha256-y13PVA/AKKsc5q7NDwZFasb7fOo+56IW8qbTbsm2WWc=";
|
||||
};
|
||||
|
||||
offlineCache = fetchYarnDeps {
|
||||
yarnLock = "${src}/yarn.lock";
|
||||
hash = "sha256-ESYSHuHLNsn3EYKIe2p0kg142jyC0USB+Ef//oGeF08=";
|
||||
};
|
||||
offlineCache = fetchYarnDeps {
|
||||
yarnLock = "${finalAttrs.src}/yarn.lock";
|
||||
hash = "sha256-ESYSHuHLNsn3EYKIe2p0kg142jyC0USB+Ef//oGeF08=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ copyDesktopItems makeWrapper ]
|
||||
++ lib.optionals stdenv.isDarwin [ desktopToDarwinBundle ];
|
||||
nativeBuildInputs = [ yarnBuildHook copyDesktopItems makeWrapper ]
|
||||
++ lib.optionals stdenv.isDarwin [ desktopToDarwinBundle ];
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
pushd deps/micropad/
|
||||
yarn --offline build
|
||||
popd
|
||||
runHook postBuild
|
||||
'';
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
# resources
|
||||
mkdir -p "$out/share/"
|
||||
cp -r './deps/micropad' "$out/share/micropad"
|
||||
ln -s '${finalAttrs.micropad-core}' "$out/share/micropad/core"
|
||||
rm "$out/share/micropad/node_modules"
|
||||
cp -r './node_modules' "$out/share/micropad"
|
||||
|
||||
# resources
|
||||
mkdir -p "$out/share/"
|
||||
cp -r './deps/micropad' "$out/share/micropad"
|
||||
ln -s '${micropad-core}' "$out/share/micropad/core"
|
||||
rm "$out/share/micropad/node_modules"
|
||||
cp -r './node_modules' "$out/share/micropad"
|
||||
# icons
|
||||
for icon in $out/share/micropad/build/icons/*.png; do
|
||||
mkdir -p "$out/share/icons/hicolor/$(basename $icon .png | sed -e 's/^icon-//')/apps"
|
||||
ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png | sed -e 's/^icon-//')/apps/micropad.png"
|
||||
done
|
||||
|
||||
# icons
|
||||
for icon in $out/share/micropad/build/icons/*.png; do
|
||||
mkdir -p "$out/share/icons/hicolor/$(basename $icon .png | sed -e 's/^icon-//')/apps"
|
||||
ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png | sed -e 's/^icon-//')/apps/micropad.png"
|
||||
done
|
||||
# executable wrapper
|
||||
makeWrapper '${electron}/bin/electron' "$out/bin/micropad" \
|
||||
--add-flags "$out/share/micropad" \
|
||||
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
|
||||
|
||||
# executable wrapper
|
||||
makeWrapper '${electron}/bin/electron' "$out/bin/${executableName}" \
|
||||
--add-flags "$out/share/micropad" \
|
||||
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
# Do not attempt generating a tarball for micropad again.
|
||||
doDist = false;
|
||||
|
||||
# Do not attempt generating a tarball for micropad again.
|
||||
doDist = false;
|
||||
# The desktop item properties should be kept in sync with data from upstream:
|
||||
# https://github.com/MicroPad/MicroPad-Electron/blob/master/package.json
|
||||
desktopItems = [
|
||||
(makeDesktopItem {
|
||||
name = "micropad";
|
||||
exec = "micropad %u";
|
||||
icon = "micropad";
|
||||
desktopName = "µPad";
|
||||
startupWMClass = "µPad";
|
||||
comment = finalAttrs.meta.description;
|
||||
categories = ["Office"];
|
||||
})
|
||||
];
|
||||
|
||||
# The desktop item properties should be kept in sync with data from upstream:
|
||||
# https://github.com/MicroPad/MicroPad-Electron/blob/master/package.json
|
||||
desktopItems = [
|
||||
(makeDesktopItem {
|
||||
name = "micropad";
|
||||
exec = "${executableName} %u";
|
||||
icon = "micropad";
|
||||
desktopName = "µPad";
|
||||
startupWMClass = "µPad";
|
||||
comment = meta.description;
|
||||
categories = ["Office"];
|
||||
})
|
||||
];
|
||||
|
||||
passthru.updateScript = ./update.sh;
|
||||
|
||||
meta = with lib; {
|
||||
description = "A powerful note-taking app that helps you organise + take notes without restrictions";
|
||||
homepage = "https://getmicropad.com/";
|
||||
license = licenses.mpl20;
|
||||
maintainers = with maintainers; [rhysmdnz];
|
||||
inherit (electron.meta) platforms;
|
||||
mainProgram = "micropad";
|
||||
};
|
||||
}
|
||||
meta = {
|
||||
description = "A powerful note-taking app that helps you organise + take notes without restrictions";
|
||||
homepage = "https://getmicropad.com/";
|
||||
license = lib.licenses.mpl20;
|
||||
maintainers = with lib.maintainers; [rhysmdnz];
|
||||
inherit (electron.meta) platforms;
|
||||
mainProgram = "micropad";
|
||||
};
|
||||
})
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
{
|
||||
"name": "micropad",
|
||||
"version": "4.5.1",
|
||||
"description": "A powerful note-taking app that helps you organise + take notes without restrictions.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"start": "yarn build && yarn electron . --is-dev --no-sandbox",
|
||||
"build": "yarn tsc -p tsconfig.json",
|
||||
"update-core": "rm -rf core && rm -rf tmp && mkdir tmp && wget https://github.com/MicroPad/MicroPad-Core/releases/download/v${npm_package_version}/micropad.tar.xz -P ./tmp && cd tmp && tar -xf micropad.tar.xz && rm build/dist/*.map && cp -r build ../core && cd .. && rm -rf tmp",
|
||||
"pack": "yarn build && yarn electron-builder --dir",
|
||||
"dist": "yarn build && yarn electron-builder",
|
||||
"windows:version": "echo %npm_package_version%"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/MicroPad/Electron.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "Nick Webster",
|
||||
"email": "nick@nick.geek.nz"
|
||||
},
|
||||
"license": "MPL-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/MicroPad/Electron/issues"
|
||||
},
|
||||
"homepage": "https://getmicropad.com",
|
||||
"devDependencies": {
|
||||
"@types/mime": "^3.0.1",
|
||||
"@types/node": "^18.7.18",
|
||||
"@types/typo-js": "^1.2.1",
|
||||
"electron": "^28.1.0",
|
||||
"electron-builder": "^24.9.1",
|
||||
"typescript": "~5.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"dictionary-en": "^3.0.0",
|
||||
"dictionary-en-au": "^2.1.1",
|
||||
"electron-context-menu": "^3.1.2",
|
||||
"electron-window-state": "^5.0.3",
|
||||
"localforage": "^1.10.0",
|
||||
"mime": "^3.0.0",
|
||||
"typo-js": "^1.2.3"
|
||||
},
|
||||
"build": {
|
||||
"appId": "com.getmicropad.micropad",
|
||||
"productName": "µPad",
|
||||
"publish": {
|
||||
"provider": "github",
|
||||
"releaseType": "release"
|
||||
},
|
||||
"asarUnpack": [
|
||||
"preload.js"
|
||||
],
|
||||
"linux": {
|
||||
"target": [
|
||||
{
|
||||
"target": "tar.gz",
|
||||
"arch": [
|
||||
"x64",
|
||||
"armv7l",
|
||||
"arm64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "AppImage",
|
||||
"arch": [
|
||||
"x64",
|
||||
"armv7l",
|
||||
"arm64"
|
||||
]
|
||||
},
|
||||
"snap",
|
||||
"deb",
|
||||
"rpm",
|
||||
"pacman"
|
||||
],
|
||||
"executableName": "micropad",
|
||||
"category": "Office",
|
||||
"icon": "build/icons"
|
||||
},
|
||||
"pacman": {
|
||||
"depends": [
|
||||
"gtk3"
|
||||
]
|
||||
},
|
||||
"snap": {
|
||||
"publish": {
|
||||
"provider": "github",
|
||||
"releaseType": "release"
|
||||
}
|
||||
},
|
||||
"mac": {
|
||||
"target": {
|
||||
"target": "dmg",
|
||||
"arch": "universal"
|
||||
},
|
||||
"category": "public.app-category.productivity",
|
||||
"identity": null
|
||||
},
|
||||
"win": {
|
||||
"target": [
|
||||
{
|
||||
"target": "nsis",
|
||||
"arch": [
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
},
|
||||
"portable"
|
||||
]
|
||||
},
|
||||
"nsis": {
|
||||
"allowToChangeInstallationDirectory": true,
|
||||
"oneClick": false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!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')
|
||||
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")
|
||||
|
||||
sed -i "$nixFile" -re "s|\"$old_core_hash\"|\"$new_core_hash\"|"
|
||||
|
||||
curl -o "$nixFolder/package.json" -s "https://raw.githubusercontent.com/MicroPad/MicroPad-Electron/v$latest_version/package.json"
|
||||
curl -o "$nixFolder/yarn.lock" -s "https://raw.githubusercontent.com/MicroPad/MicroPad-Electron/v$latest_version/yarn.lock"
|
||||
|
||||
prettier --write "$nixFolder/package.json"
|
||||
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"
|
Loading…
Reference in a new issue