cleverca22
10/26/2015 - 11:50 PM

gistfile1.txt

diff --git a/src/lib/Hydra/Plugin/NixPush.pm b/src/lib/Hydra/Plugin/NixPush.pm
new file mode 100644
index 0000000..2b4e29f
--- /dev/null
+++ b/src/lib/Hydra/Plugin/NixPush.pm
@@ -0,0 +1,22 @@
+package Hydra::Plugin::NixPush;
+
+use strict;
+use parent 'Hydra::Plugin';
+use Nix::Config;
+
+sub buildFinished {
+  my ($self, $build, $dependents) = @_;
+
+  return unless $build->buildstatus == 0 or $build->buildstatus == 6;
+  my @needed_paths = ();
+  foreach my $output ($build->buildoutputs) {
+    push @needed_paths, $output->path;
+  }
+  
+  while (@needed_paths) {
+    my $path = shift @needed_paths;
+    system("$Nix::Config::binDir/nix-push --dest /media/videos/4tb/nix-cache/ --key-file /etc/nix/signing-key.sec $path") == 0 or die;
+  }
+}
+
+1;