From 8d261441217aa9138d02a9825237de7a8962d51e Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <edolstra@gmail.com>
Date: Tue, 30 Oct 2018 14:41:21 +0100
Subject: [PATCH] Fix building against nix master

---
 release.nix                             | 3 ++-
 src/hydra-queue-runner/queue-monitor.cc | 3 ++-
 src/hydra-queue-runner/state.hh         | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/release.nix b/release.nix
index 71927be7..d67c5cf5 100644
--- a/release.nix
+++ b/release.nix
@@ -1,5 +1,5 @@
 { hydraSrc ? builtins.fetchGit ./.
-, nixpkgs ? builtins.fetchGit { url = https://github.com/NixOS/nixpkgs-channels.git; ref = "nixos-18.03-small"; }
+, nixpkgs ? builtins.fetchGit { url = https://github.com/NixOS/nixpkgs-channels.git; ref = "nixos-18.09-small"; }
 , officialRelease ? false
 , shell ? false
 }:
@@ -111,6 +111,7 @@ rec {
           perlDeps perl nix
           postgresql95 # for running the tests
           boost
+          nlohmann_json
         ];
 
       hydraPath = lib.makeBinPath (
diff --git a/src/hydra-queue-runner/queue-monitor.cc b/src/hydra-queue-runner/queue-monitor.cc
index 862925b2..c10f895b 100644
--- a/src/hydra-queue-runner/queue-monitor.cc
+++ b/src/hydra-queue-runner/queue-monitor.cc
@@ -428,8 +428,9 @@ Step::ptr State::createStep(ref<Store> destStore,
        it's not runnable yet, and other threads won't make it
        runnable while step->created == false. */
     step->drv = readDerivation(drvPath);
+    step->parsedDrv = std::make_unique<ParsedDerivation>(drvPath, step->drv);
 
-    step->preferLocalBuild = step->drv.willBuildLocally();
+    step->preferLocalBuild = step->parsedDrv->willBuildLocally();
     step->isDeterministic = get(step->drv.env, "isDetermistic", "0") == "1";
 
     step->systemType = step->drv.platform;
diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh
index 0e91ab56..79bbe355 100644
--- a/src/hydra-queue-runner/state.hh
+++ b/src/hydra-queue-runner/state.hh
@@ -10,7 +10,7 @@
 #include "db.hh"
 #include "token-server.hh"
 
-#include "derivations.hh"
+#include "parsed-derivations.hh"
 #include "pathlocks.hh"
 #include "pool.hh"
 #include "store-api.hh"
@@ -152,6 +152,7 @@ struct Step
 
     nix::Path drvPath;
     nix::Derivation drv;
+    std::unique_ptr<nix::ParsedDerivation> parsedDrv;
     std::set<std::string> requiredSystemFeatures;
     bool preferLocalBuild;
     bool isDeterministic;