Hydra trick: Reproducing a build locally, using the Hydra server’s own store

Currently, the “Reproduce this build locally” feature in Hydra does not support certain kinds of build inputs (for example local directories internal to the build server, and outputs from other build jobs).

If you have shell access to the build server, and Nix installed locally, you can do the following:

$ nix-copy-closure --include-outputs --from <user>@<hydra-machine> <drv-file>
$ nix-store -r <drv-file> -K

The <drv-file> is given under the tab Derivation store path on the pages for a specific build (example contains ).

The nix-copy-closure command first downloads the derivation and all its requirements. The nix-store command realizes the derivation (i.e., builds the derivation). If the build fails, the temporary build directories are kept for analysis (the -K option).

Update: Shell access is not necessary. @ikwildrpepper and @niksnut suggest using

nix-store -r <drv-file> --option extra-binary-caches http://hydra-machine

This works if you are running Nix as a single user install. If trying to do this system-wide on NixOS, you must add <hydra-machine> to the trusted-binary-caches setting in /etc/nix/nix.conf:

trusted-binary-caches = http://cache.nixos.org http://hydra-machine

Hydra trick: How to download the latest build product directly

Let’s say you have a Hydra project projectx and a jobset laser and derivation pistol. The link to the latest successful build is then


Let’s assume this derivation produces one tarball, called blueprint.tar.gz. You can download the file directly at


Nix trix: How to duplicate a derivation from a remote machine

Today I needed to duplicate a Nix derivation from our build machine to my local workstation. Turns out this is really easy using nix-store's --export and --import:

$ ssh user@remote "nix-store --export /nix/store/m7h9ch7n5gfx3p0375f2ayhj15asd1qf-ruby-rake-0.9.6/"
| nix-store --import

@ikwildrpepper pointed out that this is even easier if you use nix-copy-closure:

$ nix-copy-closure --from user@remote /nix/store/m7h9ch7n5gfx3p0375f2ayhj15asd1qf-ruby-rake-0.9.6

I would highly recommended that you set up password-less login for user@remote before you try this.

“The compar routine is expected to have two arguments which point to the key object and to an array member, in that order, and should return an integer less than, equal to, or greater than zero if the key object is found, respectively, to be less than, to match, or be greater than the array member.”
man bsearch

Shell trick #4: Keyboard shortcuts for output control

Ever regret you didn’t take that speed reading class when the output some console program scrolls by too fast? Worry not, there’s a fix for that.

It’s possible to suspend and resume the output from any console program. It’s also possible to scroll back and forth in the console buffer, whether you are in a graphical terminal or a text-mode console such as the Linux virtual terminal (textmode VT).

Bash and Zsh
  • Ctrl-S - suspend output from current program
  • Ctrl-Q - continue output from current program
  • Ctrl-PgUp - scroll backwards in the console buffer to read older program output
  • Ctrl-PgDn - scroll forwards in the console buffer to read newer program output

A common rookie mistake is to freeze the entire terminal by accidentally hitting Ctrl-S. When this happens, hitting Ctrl-Q will thaw it just fine.