From f63f2f1a79e506504c9be61f0071cd559ab972ef Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <e.dolstra@tudelft.nl>
Date: Mon, 2 Mar 2009 15:21:05 +0000
Subject: [PATCH] * Pass the version of dependencies to the Nix expression.

---
 src/Hydra/script/hydra_scheduler.pl | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/Hydra/script/hydra_scheduler.pl b/src/Hydra/script/hydra_scheduler.pl
index 7d10e96e..3dfc4a7c 100755
--- a/src/Hydra/script/hydra_scheduler.pl
+++ b/src/Hydra/script/hydra_scheduler.pl
@@ -297,6 +297,7 @@ sub checkJobAlternatives {
             if (defined $inputInfo->{$argName}->{storePath}) {
                 push @newArgs, "--arg", $argName,
                     "{path = builtins.storePath " . $inputInfo->{$argName}->{storePath} . ";" .
+                    " outPath = builtins.storePath " . $inputInfo->{$argName}->{storePath} . ";" .
                     " rev = \"" . $inputInfo->{$argName}->{revision} . "\";}";
             } elsif ($inputInfo->{$argName}->{type} eq "string") {
                 push @newArgs, "--argstr", $argName, $inputInfo->{$argName}->{value};
@@ -333,8 +334,18 @@ sub checkJobAlternatives {
             , id => $prevBuild->id
             };
 
+        my $pkgNameRE = "(?:(?:[A-Za-z0-9]|(?:-[^0-9]))+)";
+        my $versionRE = "(?:[A-Za-z0-9\.\-]+)";
+
+        my $relName = ($prevBuild->resultInfo->releasename or $prevBuild->nixname);
+        my $version = $2 if $relName =~ /^($pkgNameRE)-($versionRE)$/;
+
         my @newArgs = @{$extraArgs};
-        push @newArgs, "--arg", $argName, "{path = builtins.storePath " . $prevBuild->outpath . ";}";
+        push @newArgs, "--arg", $argName,
+            "{ path = builtins.storePath " . $prevBuild->outpath . "; " .
+            "  outPath = builtins.storePath " . $prevBuild->outpath . "; " .
+            ($version ? "  version = \"$version\"; " : "") . # !!! escape
+            "}";
         
         checkJobAlternatives(
             $project, $jobset, $inputInfo, $nixExprPath,