Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Created October 26, 2015 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleverca22/1ef1abdfdea1a2ac8d38 to your computer and use it in GitHub Desktop.
Save cleverca22/1ef1abdfdea1a2ac8d38 to your computer and use it in GitHub Desktop.
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment