2022-10-06 20:42:04 +03:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
utils,
|
2023-05-19 11:48:24 +03:00
|
|
|
mkDerivation,
|
2023-05-19 11:33:45 +03:00
|
|
|
extractSource ?
|
|
|
|
import ../extractSource.nix {
|
2023-05-19 11:48:24 +03:00
|
|
|
inherit lib mkDerivation;
|
2023-05-19 11:33:45 +03:00
|
|
|
},
|
2022-10-06 20:42:04 +03:00
|
|
|
...
|
|
|
|
}: let
|
2021-12-09 08:54:22 +03:00
|
|
|
b = builtins;
|
2022-03-07 13:12:07 +03:00
|
|
|
in rec {
|
|
|
|
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
|
|
|
|
2021-12-09 11:47:08 +03:00
|
|
|
defaultUpdater = "npmNewestReleaseVersion";
|
|
|
|
|
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:
|
2022-03-07 13:12:07 +03:00
|
|
|
if b.length params == b.length inputs
|
|
|
|
then
|
2021-12-09 08:54:22 +03:00
|
|
|
lib.listToAttrs
|
2022-03-07 13:12:07 +03:00
|
|
|
(lib.forEach
|
|
|
|
(lib.range 0 ((lib.length inputs) - 1))
|
|
|
|
(
|
|
|
|
idx:
|
2021-12-09 08:54:22 +03:00
|
|
|
lib.nameValuePair
|
2022-03-07 13:12:07 +03:00
|
|
|
(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-12-09 08:54:22 +03:00
|
|
|
|
2021-11-01 09:48:23 +03:00
|
|
|
# defaultUpdater = "";
|
|
|
|
|
2022-03-07 13:12:07 +03:00
|
|
|
outputs = {
|
|
|
|
pname,
|
|
|
|
version,
|
2022-10-06 20:42:04 +03:00
|
|
|
}: let
|
2022-03-07 13:12:07 +03:00
|
|
|
b = builtins;
|
2021-11-01 09:48:23 +03:00
|
|
|
|
2022-03-07 13:12:07 +03:00
|
|
|
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;}
|
2021-11-01 09:48:23 +03:00
|
|
|
);
|
|
|
|
|
2022-03-07 13:12:07 +03:00
|
|
|
fetched = hash: let
|
|
|
|
source =
|
2022-10-06 20:42:04 +03:00
|
|
|
(pkgs.fetchurl {
|
2022-03-07 13:12:07 +03:00
|
|
|
inherit url;
|
|
|
|
sha256 = hash;
|
|
|
|
})
|
|
|
|
.overrideAttrs (old: {
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
});
|
|
|
|
in
|
2023-05-19 11:33:45 +03:00
|
|
|
extractSource {
|
2022-03-07 13:12:07 +03:00
|
|
|
inherit source;
|
|
|
|
};
|
|
|
|
};
|
2021-11-01 09:48:23 +03:00
|
|
|
}
|