From 2f63cc02de5e319708157f2b56f69581106e59b8 Mon Sep 17 00:00:00 2001
From: Matthew Bauer <mjbauer95@gmail.com>
Date: Sat, 8 May 2021 21:31:28 -0500
Subject: [PATCH] Create parent trusted list path before writing

This makes sure that $HOME/.local/share/nix exists before we try to
write to it.
---
 src/libexpr/flake/config.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/libexpr/flake/config.cc b/src/libexpr/flake/config.cc
index 63566131e..c8a5a319f 100644
--- a/src/libexpr/flake/config.cc
+++ b/src/libexpr/flake/config.cc
@@ -22,7 +22,9 @@ static TrustedList readTrustedList()
 
 static void writeTrustedList(const TrustedList & trustedList)
 {
-    writeFile(trustedListPath(), nlohmann::json(trustedList).dump());
+    auto path = trustedListPath();
+    createDirs(dirOf(path));
+    writeFile(path, nlohmann::json(trustedList).dump());
 }
 
 void ConfigFile::apply()