From efc21083dc93903db9bb0a2a561721cb92e75ed9 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 14 Dec 2015 20:27:45 +0100 Subject: 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 --- modules/module-list.nix | 1 + .../user/aszlig/programs/taalo-build/default.nix | 65 ++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 modules/user/aszlig/programs/taalo-build/default.nix (limited to 'modules') 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= 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; + ''); + }; +} -- cgit 1.4.1