support updating arbitrary git repos via niv

This commit is contained in:
arcnmx 2021-05-19 09:48:24 -07:00
parent d712176441
commit 2a6edb8656
2 changed files with 16 additions and 3 deletions

View file

@ -50,9 +50,21 @@ with lib; {
chmod 0600 ~/.ssh/id_rsa chmod 0600 ~/.ssh/id_rsa
fi fi
for source in ${toString (attrNames channels.nixfiles.sources)}; do ${concatStringsSep "\n" (mapAttrsToList (source: spec: let
niv update $source || true update = "niv update ${source}";
done fetch = "timeout 30 git fetch -q --depth 1 ${spec.repo} ${spec.branch}:source-${source}";
revision = "$(git show-ref -s source-${source})";
isGit = hasPrefix "https://" spec.repo or "";
git = ''
if ${fetch}; then
echo "${source}:${spec.branch} HEAD at ${revision}" >&2
${update} -r ${revision} || true
else
echo "failed to fetch latest revision from ${spec.repo}" >&2
fi
'';
auto = "${update} || true";
in if isGit then git else auto) channels.nixfiles.sources)}
if git status --porcelain | grep -qF nix/sources.json; then if git status --porcelain | grep -qF nix/sources.json; then
git -P diff nix/sources.json git -P diff nix/sources.json

View file

@ -143,6 +143,7 @@
"url_template": "<repo>/archive/<rev>.tar.gz" "url_template": "<repo>/archive/<rev>.tar.gz"
}, },
"qyliss-nixlib": { "qyliss-nixlib": {
"branch": "master",
"builtin": false, "builtin": false,
"repo": "https://git.qyliss.net/nixlib", "repo": "https://git.qyliss.net/nixlib",
"rev": "e14330c5be9b005d4310cd4dc0d384cff882aedc", "rev": "e14330c5be9b005d4310cd4dc0d384cff882aedc",