From 2bf516613d88dc16e9185bc0bb1f0e021fbd9442 Mon Sep 17 00:00:00 2001 From: Edward Tjörnhammar Date: Wed, 29 Apr 2015 22:02:13 +0200 Subject: Add section on fetching sources --- doc/coding-conventions.xml | 53 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) (limited to 'doc/coding-conventions.xml') diff --git a/doc/coding-conventions.xml b/doc/coding-conventions.xml index 61d373738f9..e1853d47ce0 100644 --- a/doc/coding-conventions.xml +++ b/doc/coding-conventions.xml @@ -169,8 +169,8 @@ stdenv.mkDerivation { ... args: with args; ... - or - + or + { stdenv, fetchurl, perl, ... }: ... @@ -598,6 +598,51 @@ evaluate correctly. - - +
Fetching Sources + There are multiple ways to fetch a package source in nixpkgs. The + general guidline is that you should package sources with a high degree of + availability. Right now there is only one fetcher which has mirroring + support and that is fetchurl. Note that you should also + prefer protocols which have a corresponding proxy environment variable. + + You can find many source fetch helpers in pkgs/build-support/fetch*. + + In the file pkgs/top-level/all-packages.nix you can + find fetch helpers, these have names on the form + fetchFrom*. The intention of these are to provide + snapshot fetches but using the same api as some of the version controlled + fetchers from pkgs/build-support/. As an example going + from bad to good: + + Uses git:// which won't be proxied. + + src = fetchgit { + url = "git://github.com/NixOS/nix.git"; + rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; + sha256 = "1cw5fszffl5pkpa6s6wjnkiv6lm5k618s32sp60kvmvpy7a2v9kg"; + } + + + This is ok, but an archive fetch will still be faster. + + src = fetchgit { + url = "https://github.com/NixOS/nix.git"; + rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; + sha256 = "1cw5fszffl5pkpa6s6wjnkiv6lm5k618s32sp60kvmvpy7a2v9kg"; + } + + + Fetches a snapshot archive and you get the rev you want. + + src = fetchFromGitHub { + owner = "NixOS"; + repo = "nix"; + rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; + sha256 = "04yri911rj9j19qqqn6m82266fl05pz98inasni0vxr1cf1gdgv9"; + } + + + + +
-- cgit 1.4.1