modrinth-app: use pnpm.fetchDeps

This commit is contained in:
seth 2024-06-07 17:46:07 -04:00
parent f71e09a7ce
commit c1b54d4d86
No known key found for this signature in database
GPG Key ID: D31BD0D494BBEE86

View File

@ -1,27 +1,23 @@
{
lib,
stdenv,
stdenvNoCC,
fetchFromGitHub,
rustPlatform,
buildGoModule,
nix-update-script,
modrinth-app-unwrapped,
cacert,
cargo-tauri,
desktop-file-utils,
esbuild,
darwin,
jq,
libsoup,
moreutils,
pnpm_8,
nodejs,
openssl,
pkg-config,
webkitgtk_4_0,
}:
rustPlatform.buildRustPackage {
rustPlatform.buildRustPackage rec {
pname = "modrinth-app-unwrapped";
version = "0.7.1";
@ -39,46 +35,17 @@ rustPlatform.buildRustPackage {
};
};
pnpm-deps = stdenvNoCC.mkDerivation (finalAttrs: {
pname = "${modrinth-app-unwrapped.pname}-pnpm-deps";
inherit (modrinth-app-unwrapped) version src;
sourceRoot = "${finalAttrs.src.name}/theseus_gui";
dontConfigure = true;
dontBuild = true;
doCheck = false;
nativeBuildInputs = [
cacert
jq
moreutils
pnpm_8
];
# https://github.com/NixOS/nixpkgs/blob/763e59ffedb5c25774387bf99bc725df5df82d10/pkgs/applications/misc/pot/default.nix#L56
installPhase = ''
export HOME=$(mktemp -d)
pnpm config set store-dir "$out"
pnpm install --frozen-lockfile --ignore-script --force
# remove timestamp and sort json files
rm -rf "$out"/v3/tmp
for f in $(find "$out" -name "*.json"); do
sed -i -E -e 's/"checkedAt":[0-9]+,//g' $f
jq --sort-keys . "$f" | sponge "$f"
done
'';
dontFixup = true;
outputHashMode = "recursive";
outputHash = "sha256-g/uUGfC9TQh0LE8ed51oFY17FySoeTvfaeEpzpNeMao=";
});
pnpmDeps = pnpm_8.fetchDeps {
inherit pname version src;
sourceRoot = "${src.name}/theseus_gui";
hash = "sha256-g/uUGfC9TQh0LE8ed51oFY17FySoeTvfaeEpzpNeMao=";
};
pnpmRoot = "theseus_gui";
nativeBuildInputs = [
cargo-tauri.hook
desktop-file-utils
pnpm_8
pnpm_8.configHook
nodejs
pkg-config
];
@ -116,19 +83,6 @@ rustPlatform.buildRustPackage {
);
};
postPatch = ''
export HOME=$(mktemp -d)
export STORE_PATH=$(mktemp -d)
pushd theseus_gui
cp -rT ${modrinth-app-unwrapped.pnpm-deps} "$STORE_PATH"
chmod -R +w "$STORE_PATH"
pnpm config set store-dir "$STORE_PATH"
pnpm install --offline --frozen-lockfile --ignore-script
popd
'';
postInstall =
lib.optionalString stdenv.hostPlatform.isDarwin ''
mv "$out"/Applications/Modrinth\ App.app/Contents/MacOS/Modrinth\ App "$out"/bin/modrinth-app