nix-community/nurl

Generate Nix fetcher calls from URLs [maintainer=@figsoda]

Rust

797

956 commits

updated Oct 9, 2026

See the code

README

nurl

release version deps license ci

Generate Nix fetcher calls from repository URLs

$ nurl https://github.com/nix-community/patsh v0.2.0 2>/dev/null
fetchFromGitHub {
  owner = "nix-community";
  repo = "patsh";
  tag = "v0.2.0";
  hash = "sha256-7HXJspebluQeejKYmVA7sy/F3dtU1gc4eAbKiPexMMA=";
}

If you want to generate Nix packages, check out nix-init, which builds on top of nurl, and includes a lot of features to reduce boilerplate

Supported Fetchers

  • builtins.fetchGit
  • fetchCrate
  • fetchFromBitbucket
  • fetchFromGitHub
  • fetchFromGitLab
  • fetchFromGitea
  • fetchFromGitiles
  • fetchFromRepoOrCz
  • fetchFromSourcehut
  • fetchHex
  • fetchPypi
  • fetchgit
  • fetchhg
  • fetchpatch
  • fetchpatch2
  • fetchsvn
  • fetchurl
  • fetchzip

Usage

Usage: nurl [OPTIONS] [URL] [REV]

Arguments:
  [URL]
          URL to the repository to be fetched

  [REV]
          The revision or reference to be fetched

Options:
  -S, --submodules[=<SUBMODULES>]
          Fetch submodules instead of using the fetcher's default

          [possible values: true, false]

  -f, --fetcher <FETCHER>
          Specify the fetcher function instead of inferring from the URL

          [possible values: builtins.fetchGit, fetchCrate, fetchFromBitbucket,
          fetchFromGitHub, fetchFromGitLab, fetchFromGitea, fetchFromGitiles,
          fetchFromRepoOrCz, fetchFromSourcehut, fetchHex, fetchPypi, fetchgit, fetchhg,
          fetchpatch, fetchpatch2, fetchsvn, fetchurl, fetchzip]

  -F, --fallback <FALLBACK>
          The fetcher to fall back to when nurl fails to infer it from the URL

          [default: fetchgit]
          [possible values: builtins.fetchGit, fetchCrate, fetchFromBitbucket,
          fetchFromGitHub, fetchFromGitLab, fetchFromGitea, fetchFromGitiles,
          fetchFromRepoOrCz, fetchFromSourcehut, fetchHex, fetchPypi, fetchgit, fetchhg,
          fetchpatch, fetchpatch2, fetchsvn, fetchurl, fetchzip]

  -n, --nixpkgs <NIXPKGS>
          Path to nixpkgs (in nix)

          [default: <nixpkgs>]

  -i, --indent <INDENT>
          Extra indentation (in number of spaces)

          [default: 0]

  -H, --hash
          Only output the hash

  -j, --json
          Output in json format

  -p, --parse
          Parse the url without fetching the hash, output in json format

          Note that --arg(-str) and --overwrite(-str) will be ignored silently

  -a, --arg <NAME> <EXPR>
          Additional arguments to pass to the fetcher

  -A, --arg-str <NAME> <STRING>
          Same as --arg, but accepts strings instead Nix expressions

  -o, --overwrite <NAME> <EXPR>
          Overwrite arguments in the final output, not taken into consideration when
          fetching the hash

          Note that nurl does not verify any of the overwrites, for the final output to
          be valid, the user should not overwrite anything that would change the hash

          Examples:
            --overwrite repo pname
            --overwrite rev version

  -O, --overwrite-str <NAME> <STRING>
          Same as --overwrite, but accepts strings instead Nix expressions

          Examples:
            --overwrite-str rev 'v${version}'
            --overwrite-str meta.homepage https://example.org

      --overwrite-rev <EXPR>
          Same as --overwrite (rev|tag|version) <EXPR>, depending on the rev-like
          attribute the fetcher uses

      --overwrite-rev-str <STRING>
          Same as --overwrite-str (rev|tag|version) <STRING>, depending on the rev-like
          attribute the fetcher uses

  -e, --expr <EXPR>
          Instead of fetching a URL, get the hash of a fixed-output derivation, implies
          --hash and ignores all other options

          Example: --expr '(import <nixpkgs> { }).nurl.src'

  -l, --list-fetchers
          List all available fetchers

  -L, --list-possible-fetchers
          List all fetchers that can be generated without --fetcher

  -s, --list-sep <SEPARATOR>
          Print out the listed fetchers with the specified separator, only used when
          --list-fetchers or --list-possible-fetchers is specified

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

Comparison to nix-prefetch

  • nurl infers the fetcher from the URL. For nix-prefetch, you need to pick the fetcher and supply the arguments manually.
  • nix-prefetch relies on FOD which is slow, nurl tries to use alternatives when possible.
  • nix-prefetch is more configurable and supports file attributes.
  • nix-prefetch has an interface similar to nix-build.
  • nurl has some nice features dedicated to generated packages (--indent, --list-possible-fetchers).

Changelog

See CHANGELOG.md

bitbucket
codeberg
crate
crates
fetch
git
gitea
github
gitlab
hg
mercurial
nix
prefetch
sourcehut
svn

nix-community/nurl

Generate Nix fetcher calls from URLs [maintainer=@figsoda]

Rust

797

956 commits

updated Oct 9, 2026

See the code

README

nurl

release version deps license ci

Generate Nix fetcher calls from repository URLs

$ nurl https://github.com/nix-community/patsh v0.2.0 2>/dev/null
fetchFromGitHub {
  owner = "nix-community";
  repo = "patsh";
  tag = "v0.2.0";
  hash = "sha256-7HXJspebluQeejKYmVA7sy/F3dtU1gc4eAbKiPexMMA=";
}

If you want to generate Nix packages, check out nix-init, which builds on top of nurl, and includes a lot of features to reduce boilerplate

Supported Fetchers

  • builtins.fetchGit
  • fetchCrate
  • fetchFromBitbucket
  • fetchFromGitHub
  • fetchFromGitLab
  • fetchFromGitea
  • fetchFromGitiles
  • fetchFromRepoOrCz
  • fetchFromSourcehut
  • fetchHex
  • fetchPypi
  • fetchgit
  • fetchhg
  • fetchpatch
  • fetchpatch2
  • fetchsvn
  • fetchurl
  • fetchzip

Usage

Usage: nurl [OPTIONS] [URL] [REV]

Arguments:
  [URL]
          URL to the repository to be fetched

  [REV]
          The revision or reference to be fetched

Options:
  -S, --submodules[=<SUBMODULES>]
          Fetch submodules instead of using the fetcher's default

          [possible values: true, false]

  -f, --fetcher <FETCHER>
          Specify the fetcher function instead of inferring from the URL

          [possible values: builtins.fetchGit, fetchCrate, fetchFromBitbucket,
          fetchFromGitHub, fetchFromGitLab, fetchFromGitea, fetchFromGitiles,
          fetchFromRepoOrCz, fetchFromSourcehut, fetchHex, fetchPypi, fetchgit, fetchhg,
          fetchpatch, fetchpatch2, fetchsvn, fetchurl, fetchzip]

  -F, --fallback <FALLBACK>
          The fetcher to fall back to when nurl fails to infer it from the URL

          [default: fetchgit]
          [possible values: builtins.fetchGit, fetchCrate, fetchFromBitbucket,
          fetchFromGitHub, fetchFromGitLab, fetchFromGitea, fetchFromGitiles,
          fetchFromRepoOrCz, fetchFromSourcehut, fetchHex, fetchPypi, fetchgit, fetchhg,
          fetchpatch, fetchpatch2, fetchsvn, fetchurl, fetchzip]

  -n, --nixpkgs <NIXPKGS>
          Path to nixpkgs (in nix)

          [default: <nixpkgs>]

  -i, --indent <INDENT>
          Extra indentation (in number of spaces)

          [default: 0]

  -H, --hash
          Only output the hash

  -j, --json
          Output in json format

  -p, --parse
          Parse the url without fetching the hash, output in json format

          Note that --arg(-str) and --overwrite(-str) will be ignored silently

  -a, --arg <NAME> <EXPR>
          Additional arguments to pass to the fetcher

  -A, --arg-str <NAME> <STRING>
          Same as --arg, but accepts strings instead Nix expressions

  -o, --overwrite <NAME> <EXPR>
          Overwrite arguments in the final output, not taken into consideration when
          fetching the hash

          Note that nurl does not verify any of the overwrites, for the final output to
          be valid, the user should not overwrite anything that would change the hash

          Examples:
            --overwrite repo pname
            --overwrite rev version

  -O, --overwrite-str <NAME> <STRING>
          Same as --overwrite, but accepts strings instead Nix expressions

          Examples:
            --overwrite-str rev 'v${version}'
            --overwrite-str meta.homepage https://example.org

      --overwrite-rev <EXPR>
          Same as --overwrite (rev|tag|version) <EXPR>, depending on the rev-like
          attribute the fetcher uses

      --overwrite-rev-str <STRING>
          Same as --overwrite-str (rev|tag|version) <STRING>, depending on the rev-like
          attribute the fetcher uses

  -e, --expr <EXPR>
          Instead of fetching a URL, get the hash of a fixed-output derivation, implies
          --hash and ignores all other options

          Example: --expr '(import <nixpkgs> { }).nurl.src'

  -l, --list-fetchers
          List all available fetchers

  -L, --list-possible-fetchers
          List all fetchers that can be generated without --fetcher

  -s, --list-sep <SEPARATOR>
          Print out the listed fetchers with the specified separator, only used when
          --list-fetchers or --list-possible-fetchers is specified

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

Comparison to nix-prefetch

  • nurl infers the fetcher from the URL. For nix-prefetch, you need to pick the fetcher and supply the arguments manually.
  • nix-prefetch relies on FOD which is slow, nurl tries to use alternatives when possible.
  • nix-prefetch is more configurable and supports file attributes.
  • nix-prefetch has an interface similar to nix-build.
  • nurl has some nice features dedicated to generated packages (--indent, --list-possible-fetchers).

Changelog

See CHANGELOG.md

bitbucket
codeberg
crate
crates
fetch
git
gitea
github
gitlab
hg
mercurial
nix
prefetch
sourcehut
svn

Project health

crates.io

Latest release

0.4.1 · Aug 29, 2026

Releases this year

2

Significant stargazers

(top 24 of 102)

Catherine

2,929 followers · starred Oct 2025

Jules Aguillon

311 followers · starred Jan 2023

Kenichi Kamiya

188 followers · starred Aug 2024

Phil Pluckthun

1,854 followers · starred May 2023