From ef1e7ab840eaa50da29ddde7bf990a1ff6a8b185 Mon Sep 17 00:00:00 2001
From: Alexander Bantyev <balsoft@balsoft.ru>
Date: Thu, 1 Jul 2021 00:23:47 +0300
Subject: [PATCH] flake.nixConfig: fix flake-registry config settings

Before this commit, nixConfig.flake-registry didn't have any real effect
on the evaluation, since config was applied after inputs were evaluated.
Change this behavior: apply the config in the beginning of flake::lockFile.
---
 src/libcmd/installables.cc | 2 --
 src/libexpr/flake/flake.cc | 3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc
index fe52912cf..540e53eee 100644
--- a/src/libcmd/installables.cc
+++ b/src/libcmd/installables.cc
@@ -575,8 +575,6 @@ std::shared_ptr<flake::LockedFlake> InstallableFlake::getLockedFlake() const
 {
     if (!_lockedFlake) {
         _lockedFlake = std::make_shared<flake::LockedFlake>(lockFlake(*state, flakeRef, lockFlags));
-        _lockedFlake->flake.config.apply();
-        // FIXME: send new config to the daemon.
     }
     return _lockedFlake;
 }
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 8e6f06949..b57679d3b 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -298,6 +298,9 @@ LockedFlake lockFlake(
 
     auto flake = getFlake(state, topRef, lockFlags.useRegistries, flakeCache);
 
+    flake.config.apply();
+    // FIXME: send new config to the daemon.
+
     try {
 
         // FIXME: symlink attack
-- 
GitLab