From 9b2cd793cb3d562dd59372dc00d2faf6706977bb Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Mon, 19 Jul 2021 11:29:42 -0400
Subject: [PATCH] Point NIX_PATH at a source tree containing our desired
 version of nixpkgs

We can't point it at a Nix expression that evaluates to our desired version of
nixpkgs because certain consumers want it to be a filesystem path instead.
---
 nixos/modules/update-deployment | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/nixos/modules/update-deployment b/nixos/modules/update-deployment
index cc8dd996..90adc6ff 100755
--- a/nixos/modules/update-deployment
+++ b/nixos/modules/update-deployment
@@ -75,8 +75,15 @@ EOF
 # Make sure known_hosts has the host key in it.
 ssh -o StrictHostKeyChecking=no "$(hostname).$(domainname)" ":"
 
-# Set nixpkgs to our preferred version for the morph build.
-export NIX_PATH="nixpkgs=${CHECKOUT}/nixpkgs-2105.nix"
+# Set nixpkgs to our preferred version for the morph build.  Annoyingly, we
+# can't just use nixpkgs-2105.nix as our nixpkgs because some code (in morph,
+# at least) wants <nixpkgs> to be a fully-resolved path to a nixpkgs tree.
+# For example, morph evaluated `import <nixpkgs/lib>` which would turn into
+# something like `import nixpkgs-2105.nix/lib` which is nonsense.
+#
+# So instead, import our nixpkgs which forces it to be instantiated in the
+# store, then ask for its path, then set NIX_PATH to that.
+export NIX_PATH="nixpkgs=$(nix eval "(import ${CHECKOUT}/nixpkgs-2105.nix { }).path")"
 
 # Attempt to update just this host.  Choose the morph grid definition matching
 # the grid we belong to and limit the morph deployment update to the host
-- 
GitLab