From b5954cf18c7933bde5d952821a8457b64da52d65 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 12 Nov 2017 20:40:59 +0100 Subject: taalo-build: Rewrite as wrapper and move to pkgs We no longer use the legacy SSH store protocol for taalo but the new ssh-ng protocol, which makes the implementation of taalo-build a LOT less clunky. It also didn't make sense to have this as a NixOS module when we after all just emit a static store path without any stuff depending on configuration options. The new implementation basically just wraps nix-build and nix-store -r along with the right NIX_REMOTE variable. With Nix 1.2 this can also be done with the new "nix build" command using the --store option, but unfortunately "nix build" doesn't yet have the same functionality as nix-build. Signed-off-by: aszlig Cc: @Profpatsch, @bendlas --- .../user/aszlig/programs/taalo-build/default.nix | 93 ---------------------- 1 file changed, 93 deletions(-) delete mode 100644 modules/user/aszlig/programs/taalo-build/default.nix (limited to 'modules/user/aszlig/programs/taalo-build/default.nix') diff --git a/modules/user/aszlig/programs/taalo-build/default.nix b/modules/user/aszlig/programs/taalo-build/default.nix deleted file mode 100644 index 5fb09438..00000000 --- a/modules/user/aszlig/programs/taalo-build/default.nix +++ /dev/null @@ -1,93 +0,0 @@ -{ config, pkgs, lib, ... }: - -let - # Make sure we use a Nix version prior to 1.12, because taalo currently uses - # the legacy SSH protocol, so we can't use the ssh-ng store backend here. - # - # Apart from that, even if we would use the new store backend we would break - # the taalo-build backend for Nix 1.11. - inherit (import (import (../../../../../nixpkgs-path.nix)) { - config = {}; - }) nix; - - backend = pkgs.writeScript "taalo-realize-backend" '' - #!${pkgs.perl}/bin/perl -I${nix}/lib/perl5/site_perl - use strict; - use Nix::CopyClosure; - use Nix::SSH; - use IPC::Open2; - - binmode STDERR, ":encoding(utf8)"; - - my ($from, $to); - my $dest = 'nix-remote-build@taalo.headcounter.org'; - my $cmd = "exec ssh $dest -C -- nix-store --serve --write"; - my $pid = open2($from, $to, $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", \@ARGV, 0, 0, 0, 1 - ); - - writeInt(6, $to) or die; - writeStrings(\@ARGV, $to); - writeInt(0, $to); - writeInt(0, $to); - - my $res = readInt($from); - - close $to; - - waitpid($pid, 0); - exit $res; - ''; - - taalo-realize = pkgs.writeScriptBin "taalo-realize" '' - #!${pkgs.stdenv.shell} - if [ $# -le 0 -o "$1" = "--help" -o "$1" = "-h" ]; then - echo "Usage: $0 DERIVATION..." >&2 - exit 1 - fi - - exec ${backend} "$@" - ''; - - taalo-build = pkgs.writeScriptBin "taalo-build" '' - #!${pkgs.stdenv.shell} - if tmpdir="$("${pkgs.coreutils}/bin/mktemp" -d -t taalo-build.XXXXXX)"; then - trap "rm -rf '$tmpdir'" EXIT - set -o pipefail - drvs="$(nix-instantiate --add-root "$tmpdir/derivation" --indirect "$@" \ - | cut -d'!' -f1)" || exit 1 - ${backend} $("${pkgs.coreutils}/bin/readlink" $drvs) - exit $? - else - echo "Unable to create temporary directory for build link!" >&2 - exit 1 - fi - ''; - -in { - options.vuizvui.user.aszlig.programs.taalo-build = { - enable = lib.mkEnableOption "aszlig's build helpers for remote builds"; - }; - config = lib.mkIf config.vuizvui.user.aszlig.programs.taalo-build.enable { - environment.systemPackages = [ taalo-realize taalo-build ]; - }; -} -- cgit 1.4.1