Skip to content

Commit

Permalink
modrinth-app: use pnpm.fetchDeps
Browse files Browse the repository at this point in the history
  • Loading branch information
getchoo committed Jul 12, 2024
1 parent c1a19f9 commit d18da92
Showing 1 changed file with 9 additions and 55 deletions.
64 changes: 9 additions & 55 deletions pkgs/by-name/mo/modrinth-app-unwrapped/package.nix
Original file line number Diff line number Diff line change
@@ -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,
pnpm_8,
webkitgtk,
}:
rustPlatform.buildRustPackage {
rustPlatform.buildRustPackage rec {
pname = "modrinth-app-unwrapped";
version = "0.7.1";

Expand All @@ -39,47 +35,18 @@ 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
desktop-file-utils
pnpm_8
nodejs
pnpm_8.configHook
pkg-config
];

Expand Down Expand Up @@ -124,19 +91,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
'';

buildPhase = ''
runHook preBuild
Expand Down

0 comments on commit d18da92

Please sign in to comment.