Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenvNoCC, buildPackages 2, subversion, glibcLocales, sshSupport ? true, openssh ? null 3}: 4 5{ url, rev ? "HEAD", md5 ? "", sha256 ? "" 6, ignoreExternals ? false, ignoreKeywords ? false, name ? null 7, preferLocalBuild ? true 8}: 9 10assert sshSupport -> openssh != null; 11 12let 13 repoName = with lib; 14 let 15 fst = head; 16 snd = l: head (tail l); 17 trd = l: head (tail (tail l)); 18 path_ = 19 (p: if head p == "" then tail p else p) # ~ drop final slash if any 20 (reverseList (splitString "/" url)); 21 path = [ (removeSuffix "/" (head path_)) ] ++ (tail path_); 22 in 23 # ../repo/trunk -> repo 24 if fst path == "trunk" then snd path 25 # ../repo/branches/branch -> repo-branch 26 else if snd path == "branches" then "${trd path}-${fst path}" 27 # ../repo/tags/tag -> repo-tag 28 else if snd path == "tags" then "${trd path}-${fst path}" 29 # ../repo (no trunk) -> repo 30 else fst path; 31 32 name_ = if name == null then "${repoName}-r${toString rev}" else name; 33in 34 35if md5 != "" then 36 throw "fetchsvn does not support md5 anymore, please use sha256" 37else 38stdenvNoCC.mkDerivation { 39 name = name_; 40 builder = ./builder.sh; 41 nativeBuildInputs = [ subversion glibcLocales ] 42 ++ lib.optional sshSupport openssh; 43 44 SVN_SSH = if sshSupport then "${buildPackages.openssh}/bin/ssh" else null; 45 46 outputHashAlgo = "sha256"; 47 outputHashMode = "recursive"; 48 outputHash = sha256; 49 50 inherit url rev ignoreExternals ignoreKeywords; 51 52 impureEnvVars = lib.fetchers.proxyImpureEnvVars; 53 inherit preferLocalBuild; 54}