mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
Vicinae extension helpers always used importNpmLock, which reads package.json and package-lock.json during evaluation. When extension src comes from fetchgit or fetchFromGitHub, that forces Nix to realize the fetched source during eval and trips allow-import-from-derivation = false. Accept npmDepsHash in mkExtension and mkRayCastExtension so fetched extension sources can use buildNpmPackage's fixed npm dependency fetcher path instead. Keep the existing importNpmLock behavior for local sources and document the hash requirement in the option example.
79 lines
1.4 KiB
Nix
79 lines
1.4 KiB
Nix
{
|
|
pkgs,
|
|
}:
|
|
let
|
|
buildExtension =
|
|
{
|
|
name,
|
|
src,
|
|
installPhase,
|
|
npmDepsHash,
|
|
}:
|
|
pkgs.buildNpmPackage (
|
|
{
|
|
inherit name src installPhase;
|
|
}
|
|
// (
|
|
if npmDepsHash != null then
|
|
{ inherit npmDepsHash; }
|
|
else
|
|
{
|
|
inherit (pkgs.importNpmLock) npmConfigHook;
|
|
npmDeps = pkgs.importNpmLock { npmRoot = src; };
|
|
}
|
|
)
|
|
);
|
|
in
|
|
{
|
|
mkExtension =
|
|
{
|
|
name,
|
|
src,
|
|
npmDepsHash ? null,
|
|
}:
|
|
buildExtension {
|
|
inherit name src npmDepsHash;
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
mkdir -p $out
|
|
cp -r /build/.local/share/vicinae/extensions/${name}/* $out/
|
|
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
|
|
mkRayCastExtension =
|
|
{
|
|
name,
|
|
src ? null,
|
|
rev ? null,
|
|
sha256 ? null,
|
|
npmDepsHash ? null,
|
|
}:
|
|
let
|
|
resolvedSrc =
|
|
if src != null then
|
|
src
|
|
else
|
|
pkgs.fetchgit {
|
|
inherit rev sha256;
|
|
url = "https://github.com/raycast/extensions";
|
|
sparseCheckout = [ "/extensions/${name}" ];
|
|
}
|
|
+ "/extensions/${name}";
|
|
in
|
|
buildExtension {
|
|
inherit name npmDepsHash;
|
|
src = resolvedSrc;
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
mkdir -p $out
|
|
cp -r /build/.config/raycast/extensions/${name}/* $out/
|
|
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
}
|