From 1b67c62f15e1c92aa1ccdf392fcdfe85488e3f48 Mon Sep 17 00:00:00 2001
From: tv <tv@krebsco.de>
Date: Tue, 2 Feb 2016 03:29:42 +0100
Subject: [PATCH] make populate: define and pass lib to krebs/v2

---
 Makefile             | 6 +++++-
 krebs/v2/default.nix | 9 +++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index f81666ae3..c4f5cd398 100644
--- a/Makefile
+++ b/Makefile
@@ -55,14 +55,18 @@ endif
 
 # usage: make populate system=foo [target=bar]
 .PHONY: populate
+populate: export lib = \
+	let nlib = import <nixpkgs/lib>; in \
+	nlib // import krebs/4lib { lib = nlib; } // builtins
 populate: export source = \
-	with (import ~/stockholm {}).users.$(LOGNAME).$(system).config.krebs.build; \
+	with (import ./. {}).users.$(LOGNAME).$(system).config.krebs.build; \
 	assert source-version == 2; \
 	source
 populate:;@
 	result=$$(nix-instantiate \
 			--eval \
 			--json \
+			--arg lib "$$lib" \
 			--arg source "$$source" \
 			--argstr target-host "$$target" \
 			--argstr target-path /var/src \
diff --git a/krebs/v2/default.nix b/krebs/v2/default.nix
index 78e990d1c..ac1c13e72 100644
--- a/krebs/v2/default.nix
+++ b/krebs/v2/default.nix
@@ -1,13 +1,10 @@
-{ source
+{ lib
+, source
 , target-user ? "root"
 , target-host
 , target-path ? "/var/src"
 }:
-with import <nixpkgs/lib>;
-with import ~/stockholm/krebs/4lib {
-  lib = import <nixpkgs/lib>;
-};
-with builtins;
+with lib;
 let
   out = {
     inherit populate;