diff --git a/flake.nix b/flake.nix index 0b4b1b848..cac42cae3 100644 --- a/flake.nix +++ b/flake.nix @@ -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 ]; diff --git a/scripts/update-flake b/scripts/update-flake deleted file mode 100755 index 28fe75a76..000000000 --- a/scripts/update-flake +++ /dev/null @@ -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