Skip to content

Commit b4dfeaf

Browse files
committed
nix flake archive: Skip relative path inputs
Fixes NixOS#12438.
1 parent f3ea14c commit b4dfeaf

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/nix/flake.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,12 +1090,14 @@ struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun
10901090
nlohmann::json jsonObj2 = json ? json::object() : nlohmann::json(nullptr);
10911091
for (auto & [inputName, input] : node.inputs) {
10921092
if (auto inputNode = std::get_if<0>(&input)) {
1093+
if ((*inputNode)->lockedRef.input.isRelative())
1094+
continue;
10931095
auto storePath =
10941096
dryRun
10951097
? (*inputNode)->lockedRef.input.computeStorePath(*store)
10961098
: (*inputNode)->lockedRef.input.fetchToStore(store).first;
10971099
if (json) {
1098-
auto& jsonObj3 = jsonObj2[inputName];
1100+
auto & jsonObj3 = jsonObj2[inputName];
10991101
jsonObj3["path"] = store->printStorePath(storePath);
11001102
sources.insert(std::move(storePath));
11011103
jsonObj3["inputs"] = traverse(**inputNode);

tests/functional/flakes/relative-paths.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ if ! isTestOnNixOS; then
7676
fi
7777
(! grep narHash "$subflake2/flake.lock")
7878

79+
# Test `nix flake archive` with relative path flakes.
80+
nix flake archive --json "$rootFlake"
81+
7982
# Test circular relative path flakes. FIXME: doesn't work at the moment.
8083
if false; then
8184

0 commit comments

Comments
 (0)