diff options
author | aszlig <aszlig@redmoonstudios.org> | 2015-12-14 20:27:45 +0100 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2015-12-14 20:38:25 +0100 |
commit | efc21083dc93903db9bb0a2a561721cb92e75ed9 (patch) | |
tree | 1bcd2a48712b14fcbcba781fc5688a12b01610d9 /modules | |
parent | a681f8b98982c5528272195a863c218e99688d18 (diff) |
aszlig/programs: Add a new "taalo-build" program.
This is primarily for whenever I'm on the road with varying degrees of internet connectivity. What it essentially does is ssh to mmrnmhrm, then ssh to taalo and then run nix-store --serve --write on it. Taalo is the Hydra master of https://headcounter.org/hydra/ and it has remote builds enabled. The script essentially only builds on the remote host but doesn't fetch the builds. The latter can be done if the Hydra is added as a build cache to the local system, which in case of vuizvui is by default. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/module-list.nix | 1 | ||||
-rw-r--r-- | modules/user/aszlig/programs/taalo-build/default.nix | 65 |
2 files changed, 66 insertions, 0 deletions
diff --git a/modules/module-list.nix b/modules/module-list.nix index f45e2451..771ba1d9 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -9,6 +9,7 @@ ./user/aszlig/programs/gajim ./user/aszlig/programs/git ./user/aszlig/programs/mpv + ./user/aszlig/programs/taalo-build ./user/aszlig/programs/taskwarrior ./user/aszlig/programs/vim ./user/aszlig/programs/zsh diff --git a/modules/user/aszlig/programs/taalo-build/default.nix b/modules/user/aszlig/programs/taalo-build/default.nix new file mode 100644 index 00000000..61fa159d --- /dev/null +++ b/modules/user/aszlig/programs/taalo-build/default.nix @@ -0,0 +1,65 @@ +{ config, pkgs, lib, ... }: + +with lib; + +{ + options.vuizvui.user.aszlig.programs.taalo-build = { + enable = mkEnableOption "aszlig's build helper for remote builds"; + }; + config = mkIf config.vuizvui.user.aszlig.programs.taalo-build.enable { + environment.systemPackages = singleton (pkgs.writeScriptBin "taalo-build" '' + #!${pkgs.perl}/bin/perl -I${pkgs.nix}/lib/perl5/site_perl + use strict; + use Nix::CopyClosure; + use Nix::SSH; + use IPC::Open2; + + binmode STDERR, ":encoding(utf8)"; + + open my $instantiate, "-|", "nix-instantiate", @ARGV + or die "Failed to run nix-instantiate"; + my $to_realize = join "", <$instantiate>; + close $instantiate or exit $? >> 8; + + chomp $to_realize; + + my ($from, $to); + my $cmd = "nixops ssh -d headcounter taalo -- -C " + . "nix-store --serve --write"; + my $pid = open2($from, $to, "exec ssh -x -a -C mmrnmhrm '$cmd'"); + + # Do the handshake. + my $magic; + eval { + my $SERVE_MAGIC_1 = 0x390c9deb; # FIXME + my $clientVersion = 0x200; + syswrite($to, pack("L<x4L<x4", $SERVE_MAGIC_1, $clientVersion)) + or die; + $magic = readInt($from); + }; + + die "unable to connect to taalo\n" if $@; + die "did not get valid handshake from taalo\n" if $magic != 0x5452eecb; + + my $serverVersion = readInt($from); + die "unsupported server version\n" + if $serverVersion < 0x200 || $serverVersion >= 0x300; + + Nix::CopyClosure::copyToOpen( + $from, $to, "taalo", [$to_realize], 0, 0, 0, 1 + ); + + writeInt(6, $to) or die; + writeStrings([$to_realize], $to); + writeInt(0, $to); + writeInt(0, $to); + + my $res = readInt($from); + + close $to; + + waitpid($pid, 0); + exit $res; + ''); + }; +} |