mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-30 10:07:33 +03:00
add finders for finding new package versions
This commit is contained in:
parent
9adf141700
commit
66c1ce3c0d
@ -41,10 +41,12 @@ let
|
||||
inherit (config) allowBuiltinFetchers;
|
||||
};
|
||||
|
||||
# updater modules to find newest package versions
|
||||
finders = callPackageDream ./finders {};
|
||||
|
||||
# the translator modules and utils for all subsystems
|
||||
translators = callPackageDream ./translators {};
|
||||
|
||||
|
||||
# the location of the dream2nix framework for self references (update scripts, etc.)
|
||||
location = ./.;
|
||||
|
||||
@ -52,7 +54,7 @@ in
|
||||
|
||||
rec {
|
||||
|
||||
inherit apps builders fetchers location translators;
|
||||
inherit apps builders fetchers finders location translators;
|
||||
|
||||
# automatically find a suitable builder for a given generic lock
|
||||
findBuilder = dreamLock:
|
||||
|
64
src/finders/default.nix
Normal file
64
src/finders/default.nix
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
curl,
|
||||
gnugrep,
|
||||
jq,
|
||||
lib,
|
||||
python3,
|
||||
writeText,
|
||||
|
||||
# dream2nix inputs
|
||||
utils,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
githubNewestReleaseTag =
|
||||
{
|
||||
owner,
|
||||
repo,
|
||||
...
|
||||
}:
|
||||
utils.writePureShellScript [ curl jq ] ''
|
||||
curl -s "https://api.github.com/repos/${owner}/${repo}/releases?per_page=1" | jq -r '.[0].tag_name'
|
||||
'';
|
||||
|
||||
pypiNewestReleaseVersion =
|
||||
{
|
||||
pname,
|
||||
...
|
||||
}:
|
||||
utils.writePureShellScript [ curl jq ] ''
|
||||
curl -s https://pypi.org/pypi/${pname}/json | jq -r '.info.version'
|
||||
'';
|
||||
|
||||
npmNewestReleaseVersion =
|
||||
{
|
||||
pname,
|
||||
...
|
||||
}:
|
||||
# api docs: https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#get
|
||||
utils.writePureShellScript [ curl jq ] ''
|
||||
curl -s https://registry.npmjs.com/${pname} | jq -r '."dist-tags".latest'
|
||||
'';
|
||||
|
||||
urlRegexPython =
|
||||
# Don't forget to use double quoted strings
|
||||
# or double escape ('\\' instead of '\').
|
||||
# Expects named group 'rev' to be defined.
|
||||
# Example regex:
|
||||
# ''[Pp]ython-(?P<ver>[\d\.]+)\.tgz''
|
||||
{
|
||||
url,
|
||||
regex,
|
||||
...
|
||||
}:
|
||||
let
|
||||
reFile = writeText "regex" regex;
|
||||
in
|
||||
utils.writePureShellScript [ curl gnugrep python3 ] ''
|
||||
curl -s ${url} \
|
||||
| python3 -c \
|
||||
'import re, sys; print(re.search(open("${reFile}").read(), sys.stdin.read()).group("ver"), end="")'
|
||||
'';
|
||||
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
{
|
||||
coreutils,
|
||||
lib,
|
||||
nix,
|
||||
runCommand,
|
||||
writeScriptBin,
|
||||
...
|
||||
}:
|
||||
let
|
||||
@ -60,4 +62,15 @@ rec {
|
||||
in
|
||||
b.readFile hashFile;
|
||||
|
||||
writePureShellScript = availablePrograms: script: writeScriptBin "run" ''
|
||||
export PATH="${lib.makeBinPath availablePrograms}"
|
||||
tmpdir=$(${coreutils}/bin/mktemp -d)
|
||||
cd $tmpdir
|
||||
|
||||
${script}
|
||||
|
||||
cd
|
||||
${coreutils}/bin/rm -rf $tmpdir
|
||||
'';
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user