Use importNpmLock to build node_modules instead of fetchNpmDeps

This commit is contained in:
ulic-youthlic
2025-05-14 23:08:46 +02:00
committed by Lorenz Leutgeb
parent db0789b031
commit 1062c53fd5
2 changed files with 6 additions and 55 deletions
+6 -7
View File
@@ -61,12 +61,11 @@
radicle-desktop = pkgs.callPackage (
{
lib,
fetchNpmDeps,
importNpmLock,
rust-bin,
makeRustPlatform,
cargo-tauri,
nodejs,
npmHooks,
pkg-config,
wrapGAppsHook4,
glib,
@@ -96,16 +95,16 @@
};
};
npmDeps = fetchNpmDeps {
name = pname + "-npm-deps-" + version;
inherit src;
hash = "sha256-KECQdLg9lUJ/H0xn+5ejJOtBvzUGe3nTi0lrJ/vkr6E="; # npmDepsHash : Update canary, don't touch!
npmDeps = importNpmLock {
inherit version;
pname = pname + "-npm-deps";
npmRoot = ./.;
};
nativeBuildInputs = [
cargo-tauri.hook
nodejs
npmHooks.npmConfigHook
importNpmLock.npmConfigHook
pkg-config
wrapGAppsHook4
];
-48
View File
@@ -1,48 +0,0 @@
#!/bin/sh
set -eu
usage() {
printf \
'Update flake.
USAGE:
update-flake [-h]
OPTIONS:
-h --help\tPrint this help.\n'
}
while [ $# -ne 0 ]; do
case $1 in
--help | -h)
usage >&2
exit
;;
esac
done
# Some root detection guess work...
root=$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")
if [ ! -e "$root/scripts/update-flake" ]; then
root=$(
cd ..
pwd
)
fi
if [ -e "$root/flake.nix" ]; then
# If running on a nix-enabled system, also update npmDepsHash.
if type nix >/dev/null 2>&1; then
npmDepsHash=$(nix --experimental-features 'nix-command flakes' \
run --inputs-from "$root" nixpkgs#prefetch-npm-deps \
-- "$root/package-lock.json")
sed -E -e '/# npmDepsHash :/s#(hash[ ]*=[ ]*").*(".*$)#\1'"$npmDepsHash"'\2#' "$root/flake.nix" >$root/flake.nix.tmp
mv "$root/flake.nix.tmp" "$root/flake.nix"
nix --experimental-features 'nix-command flakes' flake update --flake git+file://"$root"
else
printf >&2 'Node dependencies may be out of date!
Re-run on a nix-enabled system to update npmDepsHash.\n'
fi
fi