Skip to content

Commit f64f77c

Browse files
committed
Sandbox pnpm deps in flake build
1 parent 2e596ff commit f64f77c

2 files changed

Lines changed: 16 additions & 18 deletions

File tree

flake.nix

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
inherit version;
5151

5252
buildFeatures =
53-
[ ]
54-
++ pkgs.lib.optional enableRustEditor "rust-editor"
53+
pkgs.lib.optional enableRustEditor "rust-editor"
5554
++ pkgs.lib.optional enableSourceMap "source-map"
5655
++ pkgs.lib.optional enableAquascope "aquascope";
5756

@@ -69,37 +68,35 @@
6968

7069
cargoHash = "sha256-pDWTvJKz1W41Y/ck+GBE6vaBc45l2Ut7nPwl/oYAknw=";
7170

72-
pnpmRoot = "js";
73-
pnpmWorkspaces = [
74-
"@wcrichto/quiz"
75-
"@wcrichto/quiz-embed"
76-
];
77-
7871
pnpmDeps = pnpm.fetchDeps {
79-
inherit
80-
pname
81-
version
82-
src
83-
pnpmWorkspaces
84-
;
72+
inherit pname version;
73+
src = pkgs.lib.cleanSource ./js;
8574
fetcherVersion = 2;
8675
hash = "sha256-xbctcU8vXWeYF/50iDRpa6SGST9fttL1yGJrkbf9NuI=";
87-
sourceRoot = "js";
8876
};
8977

9078
preBuild = ''
79+
export NPM_CONFIG_OFFLINE=true
9180
export PNPM_WRITABLE_STORE=$(mktemp -d)
81+
9282
# Copy pnpm deps to writable store
93-
cp -r ${pnpmDeps}/.* $PNPM_WRITABLE_STORE/ || true
83+
cp -LR ${pnpmDeps}/* $PNPM_WRITABLE_STORE/ || true
9484
export npm_config_store_dir=$PNPM_WRITABLE_STORE
9585
96-
# Run the JS build
86+
# Generate TS bindings
9787
cargo test -p mdbook-quiz-schema --locked export_bindings --features ts
9888
mkdir -p js/packages/quiz/src/bindings
9989
cp crates/mdbook-quiz-schema/bindings/* js/packages/quiz/src/bindings
90+
91+
# Build JS so that the build.rs won't
92+
cd js
93+
pnpm install --offline --frozen-lockfile --ignore-scripts
94+
chmod -R +w node_modules
95+
${pkgs.lib.optionalString enableRustEditor "export RUST_EDITOR=yes"}
96+
depot build --release
97+
cd ..
10098
'';
10199
};
102-
103100
in
104101
{
105102
packages.default = pkgs.lib.makeOverridable buildQuiz { };

js/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
supported-architectures = os=linux,darwin cpu=x64,arm64

0 commit comments

Comments
 (0)