From 20a0e2e3bf839588740b9265545d22506a511890 Mon Sep 17 00:00:00 2001 From: Corbin Date: Thu, 18 Aug 2016 22:29:30 -0700 Subject: [PATCH 1/5] build-support: Add fetchfossil function. This is a dead-simple fetcher which clones a Fossil repository, opens it directly into $out, and then nicks out the single Fossil checkout marker. --- pkgs/build-support/fetchfossil/builder.sh | 21 +++++++++++++++++++++ pkgs/build-support/fetchfossil/default.nix | 21 +++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 3 files changed, 44 insertions(+) create mode 100644 pkgs/build-support/fetchfossil/builder.sh create mode 100644 pkgs/build-support/fetchfossil/default.nix diff --git a/pkgs/build-support/fetchfossil/builder.sh b/pkgs/build-support/fetchfossil/builder.sh new file mode 100644 index 00000000000..a44296543be --- /dev/null +++ b/pkgs/build-support/fetchfossil/builder.sh @@ -0,0 +1,21 @@ +source $stdenv/setup +header "Cloning Fossil $url into $out" + +# Fossil, bless its adorable little heart, wants to write global configuration +# to $HOME/.fossil. AFAICT, there is no way to disable this functionality. +export HOME=. + +# We must explicitly set the admin user for the clone to something reasonable. +fossil clone -A nobody "$url" fossil-clone.fossil + +mkdir fossil-clone +WORKDIR=$(pwd) +mkdir $out +pushd $out +fossil open "$WORKDIR/fossil-clone.fossil" +popd + +# Just nuke the checkout file. +rm $out/.fslckout + +stopNest diff --git a/pkgs/build-support/fetchfossil/default.nix b/pkgs/build-support/fetchfossil/default.nix new file mode 100644 index 00000000000..8918c1991b1 --- /dev/null +++ b/pkgs/build-support/fetchfossil/default.nix @@ -0,0 +1,21 @@ +{stdenv, fossil}: + +{name ? null, url, rev ? null, md5 ? null, sha256 ? null}: + +# TODO: statically check if mercurial as the https support if the url starts woth https. +stdenv.mkDerivation { + name = "fossil-archive" + (if name != null then "-${name}" else ""); + builder = ./builder.sh; + buildInputs = [fossil]; + + impureEnvVars = [ + "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy" + ]; + + outputHashAlgo = if md5 != null then "md5" else "sha256"; + outputHashMode = "recursive"; + outputHash = if md5 != null then md5 else sha256; + + inherit url rev; + preferLocalBuild = true; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0cbce62a580..34a4acc2305 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -162,6 +162,8 @@ in fetchdarcs = callPackage ../build-support/fetchdarcs { }; + fetchfossil = callPackage ../build-support/fetchfossil { }; + fetchgit = callPackage ../build-support/fetchgit { git = gitMinimal; }; From 23a50ca40776464ea18dc1c7136a37d3e11c5840 Mon Sep 17 00:00:00 2001 From: Corbin Date: Thu, 18 Aug 2016 23:16:37 -0700 Subject: [PATCH 2/5] fetchfossil: Don't let Fossil write to $out/.fossil. --- pkgs/build-support/fetchfossil/builder.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/fetchfossil/builder.sh b/pkgs/build-support/fetchfossil/builder.sh index a44296543be..89bfeb89cfc 100644 --- a/pkgs/build-support/fetchfossil/builder.sh +++ b/pkgs/build-support/fetchfossil/builder.sh @@ -3,7 +3,8 @@ header "Cloning Fossil $url into $out" # Fossil, bless its adorable little heart, wants to write global configuration # to $HOME/.fossil. AFAICT, there is no way to disable this functionality. -export HOME=. +# Instead, we'll let it write to the build directory. +export HOME=$(pwd) # We must explicitly set the admin user for the clone to something reasonable. fossil clone -A nobody "$url" fossil-clone.fossil From 7880bc0c21498e27523e42f8d3361492dd4fe165 Mon Sep 17 00:00:00 2001 From: Corbin Date: Fri, 19 Aug 2016 07:34:58 -0700 Subject: [PATCH 3/5] fetchfossil: Cleanup some copy-and-paste. --- pkgs/build-support/fetchfossil/default.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkgs/build-support/fetchfossil/default.nix b/pkgs/build-support/fetchfossil/default.nix index 8918c1991b1..54b9e78c5d6 100644 --- a/pkgs/build-support/fetchfossil/default.nix +++ b/pkgs/build-support/fetchfossil/default.nix @@ -2,15 +2,14 @@ {name ? null, url, rev ? null, md5 ? null, sha256 ? null}: -# TODO: statically check if mercurial as the https support if the url starts woth https. stdenv.mkDerivation { name = "fossil-archive" + (if name != null then "-${name}" else ""); builder = ./builder.sh; buildInputs = [fossil]; - impureEnvVars = [ - "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy" - ]; + # Envvar docs are hard to find. A link for the future: + # https://www.fossil-scm.org/index.html/doc/trunk/www/env-opts.md + impureEnvVars = [ "http_proxy" ]; outputHashAlgo = if md5 != null then "md5" else "sha256"; outputHashMode = "recursive"; From 2d94071cc4ad420a488833c674e9e39d8c153bf2 Mon Sep 17 00:00:00 2001 From: Corbin Date: Fri, 19 Aug 2016 13:55:10 -0700 Subject: [PATCH 4/5] fetchfossil: Require rev. Otherwise no bumps are done when upstream changes. Not sure how to ping the repository and check without just doing the clone. --- pkgs/build-support/fetchfossil/builder.sh | 4 ++-- pkgs/build-support/fetchfossil/default.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/fetchfossil/builder.sh b/pkgs/build-support/fetchfossil/builder.sh index 89bfeb89cfc..5f08aca424f 100644 --- a/pkgs/build-support/fetchfossil/builder.sh +++ b/pkgs/build-support/fetchfossil/builder.sh @@ -1,5 +1,5 @@ source $stdenv/setup -header "Cloning Fossil $url into $out" +header "Cloning Fossil $url [$rev] into $out" # Fossil, bless its adorable little heart, wants to write global configuration # to $HOME/.fossil. AFAICT, there is no way to disable this functionality. @@ -13,7 +13,7 @@ mkdir fossil-clone WORKDIR=$(pwd) mkdir $out pushd $out -fossil open "$WORKDIR/fossil-clone.fossil" +fossil open "$WORKDIR/fossil-clone.fossil" "$rev" popd # Just nuke the checkout file. diff --git a/pkgs/build-support/fetchfossil/default.nix b/pkgs/build-support/fetchfossil/default.nix index 54b9e78c5d6..e0bde91f120 100644 --- a/pkgs/build-support/fetchfossil/default.nix +++ b/pkgs/build-support/fetchfossil/default.nix @@ -1,6 +1,6 @@ {stdenv, fossil}: -{name ? null, url, rev ? null, md5 ? null, sha256 ? null}: +{name ? null, url, rev, md5 ? null, sha256 ? null}: stdenv.mkDerivation { name = "fossil-archive" + (if name != null then "-${name}" else ""); From 76b74ab2f16d49df3cf021ca645cb0243f3b2861 Mon Sep 17 00:00:00 2001 From: Corbin Date: Sun, 21 Aug 2016 11:52:53 -0700 Subject: [PATCH 5/5] fetchfossil: Don't support MD5. This effectively means that SHA256 is the only way to go. I'm not really bothered by this. --- pkgs/build-support/fetchfossil/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/fetchfossil/default.nix b/pkgs/build-support/fetchfossil/default.nix index e0bde91f120..439c96019a4 100644 --- a/pkgs/build-support/fetchfossil/default.nix +++ b/pkgs/build-support/fetchfossil/default.nix @@ -1,6 +1,6 @@ {stdenv, fossil}: -{name ? null, url, rev, md5 ? null, sha256 ? null}: +{name ? null, url, rev, sha256}: stdenv.mkDerivation { name = "fossil-archive" + (if name != null then "-${name}" else ""); @@ -11,9 +11,9 @@ stdenv.mkDerivation { # https://www.fossil-scm.org/index.html/doc/trunk/www/env-opts.md impureEnvVars = [ "http_proxy" ]; - outputHashAlgo = if md5 != null then "md5" else "sha256"; + outputHashAlgo = "sha256"; outputHashMode = "recursive"; - outputHash = if md5 != null then md5 else sha256; + outputHash = sha256; inherit url rev; preferLocalBuild = true;