mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-30 10:07:33 +03:00
add npm fetcher
This commit is contained in:
parent
03ef2e4c7a
commit
5a00d557b9
41
src/fetchers/npm/default.nix
Normal file
41
src/fetchers/npm/default.nix
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
fetchurl,
|
||||
lib,
|
||||
python3,
|
||||
|
||||
utils,
|
||||
...
|
||||
}:
|
||||
{
|
||||
|
||||
inputs = [
|
||||
"pname"
|
||||
"version"
|
||||
];
|
||||
|
||||
versionField = "version";
|
||||
|
||||
# defaultUpdater = "";
|
||||
|
||||
outputs = { pname, version, ... }@inp:
|
||||
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:
|
||||
(fetchurl {
|
||||
inherit url;
|
||||
sha256 = hash;
|
||||
}).overrideAttrs (old: {
|
||||
outputHashMode = "recursive";
|
||||
});
|
||||
};
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
http,
|
||||
fetchurl,
|
||||
python3,
|
||||
|
||||
utils,
|
||||
@ -19,34 +19,24 @@
|
||||
outputs = { pname, version, extension ? "tar.gz", ... }@inp:
|
||||
let
|
||||
b = builtins;
|
||||
|
||||
firstChar = builtins.substring 0 1 pname;
|
||||
url =
|
||||
"https://files.pythonhosted.org/packages/source/"
|
||||
+ "${firstChar}/${pname}/${pname}-${version}.${extension}";
|
||||
in
|
||||
{
|
||||
|
||||
calcHash = algo: utils.hashPath algo (
|
||||
let
|
||||
firstChar = builtins.substring 0 1 pname;
|
||||
result = b.http {
|
||||
url =
|
||||
"https://files.pythonhosted.org/packages/source/"
|
||||
+ "${firstChar}/${pname}/${pname}-${version}.${extension}";
|
||||
};
|
||||
in
|
||||
result
|
||||
|
||||
b.fetchurl { inherit url; }
|
||||
);
|
||||
|
||||
fetched = hash:
|
||||
let
|
||||
firstChar = builtins.substring 0 1 pname;
|
||||
result = (http {
|
||||
url =
|
||||
"https://files.pythonhosted.org/packages/source/"
|
||||
+ "${firstChar}/${pname}/${pname}-${version}.${extension}";
|
||||
sha256 = hash;
|
||||
}).overrideAttrs (old: {
|
||||
outputHashMode = "recursive";
|
||||
});
|
||||
in
|
||||
result;
|
||||
(fetchurl {
|
||||
inherit url;
|
||||
sha256 = hash;
|
||||
}).overrideAttrs (old: {
|
||||
outputHashMode = "recursive";
|
||||
});
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user