Generate nix code to fetch package from url


I am trying to generate nix code to fetch programs from different types of url:
git:// or

Iam looking for a program that would convert the input git:// into

builtins.fetchGit {
  "url": "git://",
  "rev": "57b1f90cf6cec46450e87289ed5a676165d31071",
  "date": "2018-06-14T11:56:56+02:00",
  "sha256": "0yiwl4p1zh9qid3ksc4n9fv5bwaa9vjb0vgwnkars204xmxdj8fj",
  "fetchSubmodules": false

and intofetchurl { url =; sha256 = ... }

In the first example, I can run nix-prefetch-git --quiet git:// but it still means that I detected in advance it was a git url. I am looking for a more holistic program that detects the protocol / domain and depending on those generate the appropriate fetch instructions like fetchFromGithub or fetchFromGitlab or fetchurl.

Is there anything like it available ?


like why nix-prefetch-url doesn’t have a --quiet option that outputs the json as nix-prefetch-git does ?


I wrote nix-update-source to deal with similar issues - I want to generate some nix code (or JSON code which can be imported from nix) based on some inputs, but let it generate the digest for me. So far I’ve only added support for git / github types, but it should be reasonably straightforward to add a plain fetchurl type.

If you’re interested in contributing, a url handler shouldn’t bet much more than 10 lines, you could use the github handler for reference: