2021-11-01 09:48:23 +03:00
|
|
|
{
|
|
|
|
fetchurl,
|
|
|
|
lib,
|
|
|
|
python3,
|
|
|
|
|
|
|
|
utils,
|
|
|
|
...
|
|
|
|
}:
|
2021-12-09 08:54:22 +03:00
|
|
|
|
|
|
|
let
|
|
|
|
b = builtins;
|
|
|
|
in
|
|
|
|
|
|
|
|
rec {
|
2021-11-30 08:20:27 +03:00
|
|
|
inputs = [ "pname" "version" ];
|
2021-12-09 08:54:22 +03:00
|
|
|
|
2021-11-01 09:48:23 +03:00
|
|
|
versionField = "version";
|
2021-12-09 08:54:22 +03:00
|
|
|
|
|
|
|
# becuase some node packages contain submodules like `@hhhtj/draw.io`
|
|
|
|
# the amount of arguments can vary and a custom parser is needed
|
|
|
|
parseParams = params:
|
|
|
|
if b.length params == b.length inputs then
|
|
|
|
lib.listToAttrs
|
|
|
|
(lib.forEach
|
|
|
|
(lib.range 0 ((lib.length inputs) - 1))
|
|
|
|
(idx:
|
|
|
|
lib.nameValuePair
|
|
|
|
(lib.elemAt inputs idx)
|
|
|
|
(lib.elemAt params idx)
|
|
|
|
))
|
|
|
|
else if b.length params == (b.length inputs) + 1 then
|
|
|
|
parseParams [
|
|
|
|
"${b.elemAt params 0}/${b.elemAt params 1}"
|
|
|
|
(b.elemAt params 2)
|
|
|
|
]
|
|
|
|
else
|
|
|
|
throw ''
|
|
|
|
Wrong number of arguments provided in shortcut for fetcher 'npm'
|
|
|
|
Should be npm:${lib.concatStringsSep "/" inputs}
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
2021-11-01 09:48:23 +03:00
|
|
|
# defaultUpdater = "";
|
|
|
|
|
2021-11-24 04:50:05 +03:00
|
|
|
outputs = { pname, version, }@inp:
|
2021-11-01 09:48:23 +03:00
|
|
|
let
|
|
|
|
b = builtins;
|
|
|
|
|
|
|
|
submodule = lib.last (lib.splitString "/" pname);
|
|
|
|
url = "https://registry.npmjs.org/${pname}/-/${submodule}-${version}.tgz";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
|
|
|
|
calcHash = algo: utils.hashPath algo (
|
|
|
|
b.fetchurl { inherit url; }
|
|
|
|
);
|
|
|
|
|
|
|
|
fetched = hash:
|
2021-12-09 08:54:22 +03:00
|
|
|
let
|
|
|
|
source =
|
|
|
|
(fetchurl {
|
|
|
|
inherit url;
|
|
|
|
sha256 = hash;
|
|
|
|
}).overrideAttrs (old: {
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
});
|
|
|
|
in
|
|
|
|
utils.extractSource {
|
|
|
|
inherit source;
|
|
|
|
};
|
|
|
|
|
2021-11-01 09:48:23 +03:00
|
|
|
};
|
|
|
|
}
|