From 1f9b92b0e6f2dd073f1863d95fd6587448415214 Mon Sep 17 00:00:00 2001 From: Hraban Luyat Date: Mon, 5 Dec 2022 14:49:37 -0500 Subject: [PATCH] fetchdarcs: fetch by commit hash --- pkgs/build-support/fetchdarcs/builder.sh | 10 +++++++--- pkgs/build-support/fetchdarcs/default.nix | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pkgs/build-support/fetchdarcs/builder.sh b/pkgs/build-support/fetchdarcs/builder.sh index 301deb98307f..ce0cb1b18d5f 100644 --- a/pkgs/build-support/fetchdarcs/builder.sh +++ b/pkgs/build-support/fetchdarcs/builder.sh @@ -2,11 +2,15 @@ source $stdenv/setup tagtext="" tagflags="" -if test -n "$rev"; then - tagtext="(tag $rev) " +# Darcs hashes are sha1 (120 bits, 40-character hex) +if [[ "$rev" =~ [a-fA-F0-9]{40} ]]; then + tagtext="(hash $rev)" + tagflags="--to-hash=$rev" +elif test -n "$rev"; then + tagtext="(tag $rev)" tagflags="--tag=$rev" elif test -n "$context"; then - tagtext="(context) " + tagtext="(context)" tagflags="--context=$context" fi diff --git a/pkgs/build-support/fetchdarcs/default.nix b/pkgs/build-support/fetchdarcs/default.nix index 02777c9900dc..ae38edee4fdf 100644 --- a/pkgs/build-support/fetchdarcs/default.nix +++ b/pkgs/build-support/fetchdarcs/default.nix @@ -1,12 +1,17 @@ {stdenvNoCC, darcs, cacert}: -{url, rev ? null, context ? null, md5 ? "", sha256 ? ""}: +{ url +, rev ? null +, context ? null +, md5 ? "" +, sha256 ? "" +, name ? "fetchdarcs" +}: if md5 != "" then throw "fetchdarcs does not support md5 anymore, please use sha256" else stdenvNoCC.mkDerivation { - name = "fetchdarcs"; builder = ./builder.sh; nativeBuildInputs = [cacert darcs]; @@ -14,5 +19,5 @@ stdenvNoCC.mkDerivation { outputHashMode = "recursive"; outputHash = sha256; - inherit url rev context; + inherit url rev context name; }