From db23f8e80d0305bc534771c6d19f6e86e0f19471 Mon Sep 17 00:00:00 2001
From: Graham Christensen <graham@grahamc.com>
Date: Mon, 7 Apr 2025 17:18:15 -0400
Subject: [PATCH] Add trailing commas on addFlag incantations

(cherry picked from commit 06acbd37bdbfb6287b882d0464372e6f71259014)

# Conflicts:
#	src/libcmd/installables.cc
#	src/nix/copy.cc
#	src/nix/flake.cc
---
 src/libcmd/command.cc          |  7 ++++---
 src/libcmd/common-eval-args.cc |  8 ++++----
 src/libcmd/installables.cc     | 29 +++++++++++++++++------------
 src/libmain/common-args.cc     |  4 ++--
 src/libmain/shared.cc          |  2 +-
 src/libstore/globals.cc        |  6 +++---
 src/nix/build.cc               |  2 +-
 src/nix/bundle.cc              |  4 ++--
 src/nix/copy.cc                | 12 ++++++++++++
 src/nix/derivation-show.cc     |  2 +-
 src/nix/develop.cc             |  4 ++--
 src/nix/env.cc                 | 21 +++++++++++----------
 src/nix/flake.cc               | 32 ++++++++++++++++++++++++--------
 src/nix/prefetch.cc            |  4 ++--
 src/nix/sigs.cc                |  2 +-
 src/nix/store-delete.cc        |  2 +-
 src/nix/store-gc.cc            |  2 +-
 src/nix/upgrade-nix.cc         |  4 ++--
 src/nix/verify.cc              |  4 ++--
 19 files changed, 93 insertions(+), 58 deletions(-)

diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc
index 1a4c76ec5..7c67acf36 100644
--- a/src/libcmd/command.cc
+++ b/src/libcmd/command.cc
@@ -233,12 +233,13 @@ void StorePathCommand::run(ref<Store> store, StorePaths && storePaths)
 
 MixProfile::MixProfile()
 {
-    addFlag(
-        {.longName = "profile",
+    addFlag({
+        .longName = "profile",
          .description = "The profile to operate on.",
          .labels = {"path"},
          .handler = {&profile},
-         .completer = completePath});
+         .completer = completePath,
+    });
 }
 
 void MixProfile::updateProfile(const StorePath & storePath)
diff --git a/src/libcmd/common-eval-args.cc b/src/libcmd/common-eval-args.cc
index ccbf957d9..f74b7d242 100644
--- a/src/libcmd/common-eval-args.cc
+++ b/src/libcmd/common-eval-args.cc
@@ -61,7 +61,7 @@ MixEvalArgs::MixEvalArgs()
         .description = "Pass the value *expr* as the argument *name* to Nix functions.",
         .category = category,
         .labels = {"name", "expr"},
-        .handler = {[&](std::string name, std::string expr) { autoArgs.insert_or_assign(name, AutoArg{AutoArgExpr{expr}}); }}
+        .handler = {[&](std::string name, std::string expr) { autoArgs.insert_or_assign(name, AutoArg{AutoArgExpr{expr}}); }},
     });
 
     addFlag({
@@ -78,7 +78,7 @@ MixEvalArgs::MixEvalArgs()
         .category = category,
         .labels = {"name", "path"},
         .handler = {[&](std::string name, std::string path) { autoArgs.insert_or_assign(name, AutoArg{AutoArgFile{path}}); }},
-        .completer = completePath
+        .completer = completePath,
     });
 
     addFlag({
@@ -103,7 +103,7 @@ MixEvalArgs::MixEvalArgs()
         .labels = {"path"},
         .handler = {[&](std::string s) {
             lookupPath.elements.emplace_back(LookupPath::Elem::parse(s));
-        }}
+        }},
     });
 
     addFlag({
@@ -129,7 +129,7 @@ MixEvalArgs::MixEvalArgs()
         }},
         .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
             completeFlakeRef(completions, openStore(), prefix);
-        }}
+        }},
     });
 
     addFlag({
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc
index 227bb64ed..1c6569cfe 100644
--- a/src/libcmd/installables.cc
+++ b/src/libcmd/installables.cc
@@ -64,21 +64,21 @@ MixFlakeOptions::MixFlakeOptions()
         .handler = {[&]() {
             lockFlags.recreateLockFile = true;
             warn("'--recreate-lock-file' is deprecated and will be removed in a future version; use 'nix flake update' instead.");
-        }}
+        }},
     });
 
     addFlag({
         .longName = "no-update-lock-file",
         .description = "Do not allow any updates to the flake's lock file.",
         .category = category,
-        .handler = {&lockFlags.updateLockFile, false}
+        .handler = {&lockFlags.updateLockFile, false},
     });
 
     addFlag({
         .longName = "no-write-lock-file",
         .description = "Do not write the flake's newly generated lock file.",
         .category = category,
-        .handler = {&lockFlags.writeLockFile, false}
+        .handler = {&lockFlags.writeLockFile, false},
     });
 
     addFlag({
@@ -94,14 +94,14 @@ MixFlakeOptions::MixFlakeOptions()
         .handler = {[&]() {
             lockFlags.useRegistries = false;
             warn("'--no-registries' is deprecated; use '--no-use-registries'");
-        }}
+        }},
     });
 
     addFlag({
         .longName = "commit-lock-file",
         .description = "Commit changes to the flake's lock file.",
         .category = category,
-        .handler = {&lockFlags.commitLockFile, true}
+        .handler = {&lockFlags.commitLockFile, true},
     });
 
     addFlag({
@@ -120,8 +120,13 @@ MixFlakeOptions::MixFlakeOptions()
             lockFlags.inputUpdates.insert(flake::parseInputPath(s));
         }},
         .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
+<<<<<<< HEAD
             completeFlakeInputPath(completions, getEvalState(), getFlakeRefsForCompletion(), prefix);
         }}
+=======
+            completeFlakeInputAttrPath(completions, getEvalState(), getFlakeRefsForCompletion(), prefix);
+        }},
+>>>>>>> 06acbd37b (Add trailing commas on addFlag incantations)
     });
 
     addFlag({
@@ -141,7 +146,7 @@ MixFlakeOptions::MixFlakeOptions()
             } else if (n == 1) {
                 completeFlakeRef(completions, getEvalState()->store, prefix);
             }
-        }}
+        }},
     });
 
     addFlag({
@@ -152,7 +157,7 @@ MixFlakeOptions::MixFlakeOptions()
         .handler = {[&](std::string lockFilePath) {
             lockFlags.referenceLockFilePath = {getFSSourceAccessor(), CanonPath(absPath(lockFilePath))};
         }},
-        .completer = completePath
+        .completer = completePath,
     });
 
     addFlag({
@@ -163,7 +168,7 @@ MixFlakeOptions::MixFlakeOptions()
         .handler = {[&](std::string lockFilePath) {
             lockFlags.outputLockFilePath = lockFilePath;
         }},
-        .completer = completePath
+        .completer = completePath,
     });
 
     addFlag({
@@ -190,7 +195,7 @@ MixFlakeOptions::MixFlakeOptions()
         }},
         .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
             completeFlakeRef(completions, getEvalState()->store, prefix);
-        }}
+        }},
     });
 }
 
@@ -206,7 +211,7 @@ SourceExprCommand::SourceExprCommand()
         .category = installablesCategory,
         .labels = {"file"},
         .handler = {&file},
-        .completer = completePath
+        .completer = completePath,
     });
 
     addFlag({
@@ -214,7 +219,7 @@ SourceExprCommand::SourceExprCommand()
         .description = "Interpret [*installables*](@docroot@/command-ref/new-cli/nix.md#installables) as attribute paths relative to the Nix expression *expr*.",
         .category = installablesCategory,
         .labels = {"expr"},
-        .handler = {&expr}
+        .handler = {&expr},
     });
 }
 
@@ -834,7 +839,7 @@ RawInstallablesCommand::RawInstallablesCommand()
     addFlag({
         .longName = "stdin",
         .description = "Read installables from the standard input. No default installable applied.",
-        .handler = {&readFromStdIn, true}
+        .handler = {&readFromStdIn, true},
     });
 
     expectArgs({
diff --git a/src/libmain/common-args.cc b/src/libmain/common-args.cc
index 13d358623..6ab30f9a3 100644
--- a/src/libmain/common-args.cc
+++ b/src/libmain/common-args.cc
@@ -57,7 +57,7 @@ MixCommonArgs::MixCommonArgs(const std::string & programName)
                     if (hasPrefix(s.first, prefix))
                         completions.add(s.first, fmt("Set the `%s` setting.", s.first));
             }
-        }
+        },
     });
 
     addFlag({
@@ -75,7 +75,7 @@ MixCommonArgs::MixCommonArgs(const std::string & programName)
         .labels = Strings{"jobs"},
         .handler = {[=](std::string s) {
             settings.set("max-jobs", s);
-        }}
+        }},
     });
 
     std::string cat = "Options to override configuration settings";
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 50f90bfb3..c57fcf3e9 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -228,7 +228,7 @@ LegacyArgs::LegacyArgs(const std::string & programName,
             .handler = {[=](std::string s) {
                 auto n = string2IntWithUnitPrefix<uint64_t>(s);
                 settings.set(dest, std::to_string(n));
-            }}
+            }},
         });
     };
 
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index b64e73c26..fde92f5d0 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -279,21 +279,21 @@ template<> void BaseSetting<SandboxMode>::convertToArg(Args & args, const std::s
         .aliases = aliases,
         .description = "Enable sandboxing.",
         .category = category,
-        .handler = {[this]() { override(smEnabled); }}
+        .handler = {[this]() { override(smEnabled); }},
     });
     args.addFlag({
         .longName = "no-" + name,
         .aliases = aliases,
         .description = "Disable sandboxing.",
         .category = category,
-        .handler = {[this]() { override(smDisabled); }}
+        .handler = {[this]() { override(smDisabled); }},
     });
     args.addFlag({
         .longName = "relaxed-" + name,
         .aliases = aliases,
         .description = "Enable sandboxing, but allow builds to disable it.",
         .category = category,
-        .handler = {[this]() { override(smRelaxed); }}
+        .handler = {[this]() { override(smRelaxed); }},
     });
 }
 
diff --git a/src/nix/build.cc b/src/nix/build.cc
index da9132d02..3b0adc98f 100644
--- a/src/nix/build.cc
+++ b/src/nix/build.cc
@@ -79,7 +79,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile
             .description = "Use *path* as prefix for the symlinks to the build results. It defaults to `result`.",
             .labels = {"path"},
             .handler = {&outLink},
-            .completer = completePath
+            .completer = completePath,
         });
 
         addFlag({
diff --git a/src/nix/bundle.cc b/src/nix/bundle.cc
index 5b7862c4e..7741841de 100644
--- a/src/nix/bundle.cc
+++ b/src/nix/bundle.cc
@@ -24,7 +24,7 @@ struct CmdBundle : InstallableValueCommand
             .handler = {&bundler},
             .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
                 completeFlakeRef(completions, getStore(), prefix);
-            }}
+            }},
         });
 
         addFlag({
@@ -33,7 +33,7 @@ struct CmdBundle : InstallableValueCommand
             .description = "Override the name of the symlink to the build result. It defaults to the base name of the app.",
             .labels = {"path"},
             .handler = {&outLink},
-            .completer = completePath
+            .completer = completePath,
         });
 
     }
diff --git a/src/nix/copy.cc b/src/nix/copy.cc
index 151d28277..e0766b382 100644
--- a/src/nix/copy.cc
+++ b/src/nix/copy.cc
@@ -14,6 +14,18 @@ struct CmdCopy : virtual CopyCommand, virtual BuiltPathsCommand
         : BuiltPathsCommand(true)
     {
         addFlag({
+<<<<<<< HEAD
+=======
+            .longName = "out-link",
+            .shortName = 'o',
+            .description = "Create symlinks prefixed with *path* to the top-level store paths fetched from the source store.",
+            .labels = {"path"},
+            .handler = {&outLink},
+            .completer = completePath,
+        });
+
+        addFlag({
+>>>>>>> 06acbd37b (Add trailing commas on addFlag incantations)
             .longName = "no-check-sigs",
             .description = "Do not require that paths are signed by trusted keys.",
             .handler = {&checkSigs, NoCheckSigs},
diff --git a/src/nix/derivation-show.cc b/src/nix/derivation-show.cc
index bf637246d..927bf97a4 100644
--- a/src/nix/derivation-show.cc
+++ b/src/nix/derivation-show.cc
@@ -21,7 +21,7 @@ struct CmdShowDerivation : InstallablesCommand
             .longName = "recursive",
             .shortName = 'r',
             .description = "Include the dependencies of the specified derivations.",
-            .handler = {&recursive, true}
+            .handler = {&recursive, true},
         });
     }
 
diff --git a/src/nix/develop.cc b/src/nix/develop.cc
index 9a95bc695..0fe6b68da 100644
--- a/src/nix/develop.cc
+++ b/src/nix/develop.cc
@@ -335,7 +335,7 @@ struct Common : InstallableCommand, MixProfile
             .labels = {"installable", "outputs-dir"},
             .handler = {[&](std::string installable, std::string outputsDir) {
                 redirects.push_back({installable, outputsDir});
-            }}
+            }},
         });
     }
 
@@ -525,7 +525,7 @@ struct CmdDevelop : Common, MixEnvironment
             .handler = {[&](std::vector<std::string> ss) {
                 if (ss.empty()) throw UsageError("--command requires at least one argument");
                 command = ss;
-            }}
+            }},
         });
 
         addFlag({
diff --git a/src/nix/env.cc b/src/nix/env.cc
index 832320320..7b26f7235 100644
--- a/src/nix/env.cc
+++ b/src/nix/env.cc
@@ -38,16 +38,17 @@ struct CmdShell : InstallablesCommand, MixEnvironment
 
     CmdShell()
     {
-        addFlag(
-            {.longName = "command",
-             .shortName = 'c',
-             .description = "Command and arguments to be executed, defaulting to `$SHELL`",
-             .labels = {"command", "args"},
-             .handler = {[&](std::vector<std::string> ss) {
-                 if (ss.empty())
-                     throw UsageError("--command requires at least one argument");
-                 command = ss;
-             }}});
+        addFlag({
+            .longName = "command",
+            .shortName = 'c',
+            .description = "Command and arguments to be executed, defaulting to `$SHELL`",
+            .labels = {"command", "args"},
+            .handler = {[&](std::vector<std::string> ss) {
+                if (ss.empty())
+                    throw UsageError("--command requires at least one argument");
+                command = ss;
+            }},
+        });
     }
 
     std::string description() override
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 17637f50d..bb3c5382c 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -88,7 +88,7 @@ public:
             .handler={&flakeUrl},
             .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
                 completeFlakeRef(completions, getStore(), prefix);
-            }}
+            }},
         });
         expectArgs({
             .label="inputs",
@@ -108,8 +108,13 @@ public:
                 }
             }},
             .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
+<<<<<<< HEAD
                 completeFlakeInputPath(completions, getEvalState(), getFlakeRefsForCompletion(), prefix);
             }}
+=======
+                completeFlakeInputAttrPath(completions, getEvalState(), getFlakeRefsForCompletion(), prefix);
+            }},
+>>>>>>> 06acbd37b (Add trailing commas on addFlag incantations)
         });
 
         /* Remove flags that don't make sense. */
@@ -333,12 +338,12 @@ struct CmdFlakeCheck : FlakeCommand
         addFlag({
             .longName = "no-build",
             .description = "Do not build checks.",
-            .handler = {&build, false}
+            .handler = {&build, false},
         });
         addFlag({
             .longName = "all-systems",
             .description = "Check the outputs for all systems.",
-            .handler = {&checkAllSystems, true}
+            .handler = {&checkAllSystems, true},
         });
     }
 
@@ -870,7 +875,7 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
                     defaultTemplateAttrPathsPrefixes,
                     defaultTemplateAttrPaths,
                     prefix);
-            }}
+            }},
         });
     }
 
@@ -1035,7 +1040,7 @@ struct CmdFlakeClone : FlakeCommand
             .shortName = 'f',
             .description = "Clone the flake to path *dest*.",
             .labels = {"path"},
-            .handler = {&destDir}
+            .handler = {&destDir},
         });
     }
 
@@ -1058,7 +1063,7 @@ struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun
             .longName = "to",
             .description = "URI of the destination Nix store",
             .labels = {"store-uri"},
-            .handler = {&dstUri}
+            .handler = {&dstUri},
         });
     }
 
@@ -1136,12 +1141,12 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
         addFlag({
             .longName = "legacy",
             .description = "Show the contents of the `legacyPackages` output.",
-            .handler = {&showLegacy, true}
+            .handler = {&showLegacy, true},
         });
         addFlag({
             .longName = "all-systems",
             .description = "Show the contents of outputs for all systems.",
-            .handler = {&showAllSystems, true}
+            .handler = {&showAllSystems, true},
         });
     }
 
@@ -1434,6 +1439,17 @@ struct CmdFlakePrefetch : FlakeCommand, MixJSON
 {
     CmdFlakePrefetch()
     {
+<<<<<<< HEAD
+=======
+        addFlag({
+            .longName = "out-link",
+            .shortName = 'o',
+            .description = "Create symlink named *path* to the resulting store path.",
+            .labels = {"path"},
+            .handler = {&outLink},
+            .completer = completePath,
+        });
+>>>>>>> 06acbd37b (Add trailing commas on addFlag incantations)
     }
 
     std::string description() override
diff --git a/src/nix/prefetch.cc b/src/nix/prefetch.cc
index db7d9e4ef..38cc5b729 100644
--- a/src/nix/prefetch.cc
+++ b/src/nix/prefetch.cc
@@ -276,7 +276,7 @@ struct CmdStorePrefetchFile : StoreCommand, MixJSON
             .longName = "name",
             .description = "Override the name component of the resulting store path. It defaults to the base name of *url*.",
             .labels = {"name"},
-            .handler = {&name}
+            .handler = {&name},
         });
 
         addFlag({
@@ -285,7 +285,7 @@ struct CmdStorePrefetchFile : StoreCommand, MixJSON
             .labels = {"hash"},
             .handler = {[&](std::string s) {
                 expectedHash = Hash::parseAny(s, hashAlgo);
-            }}
+            }},
         });
 
         addFlag(flag::hashAlgo("hash-type", &hashAlgo));
diff --git a/src/nix/sigs.cc b/src/nix/sigs.cc
index 2afe4b267..113571601 100644
--- a/src/nix/sigs.cc
+++ b/src/nix/sigs.cc
@@ -106,7 +106,7 @@ struct CmdSign : StorePathsCommand
             .description = "File containing the secret signing key.",
             .labels = {"file"},
             .handler = {&secretKeyFile},
-            .completer = completePath
+            .completer = completePath,
         });
     }
 
diff --git a/src/nix/store-delete.cc b/src/nix/store-delete.cc
index 6719227df..ad50dc8b8 100644
--- a/src/nix/store-delete.cc
+++ b/src/nix/store-delete.cc
@@ -16,7 +16,7 @@ struct CmdStoreDelete : StorePathsCommand
         addFlag({
             .longName = "ignore-liveness",
             .description = "Do not check whether the paths are reachable from a root.",
-            .handler = {&options.ignoreLiveness, true}
+            .handler = {&options.ignoreLiveness, true},
         });
     }
 
diff --git a/src/nix/store-gc.cc b/src/nix/store-gc.cc
index 8b9b5d164..03612a2e1 100644
--- a/src/nix/store-gc.cc
+++ b/src/nix/store-gc.cc
@@ -17,7 +17,7 @@ struct CmdStoreGC : StoreCommand, MixDryRun
             .longName = "max",
             .description = "Stop after freeing *n* bytes of disk space.",
             .labels = {"n"},
-            .handler = {&options.maxFreed}
+            .handler = {&options.maxFreed},
         });
     }
 
diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc
index 28174c4fb..ea8655fee 100644
--- a/src/nix/upgrade-nix.cc
+++ b/src/nix/upgrade-nix.cc
@@ -24,14 +24,14 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
             .shortName = 'p',
             .description = "The path to the Nix profile to upgrade.",
             .labels = {"profile-dir"},
-            .handler = {&profileDir}
+            .handler = {&profileDir},
         });
 
         addFlag({
             .longName = "nix-store-paths-url",
             .description = "The URL of the file that contains the store paths of the latest Nix release.",
             .labels = {"url"},
-            .handler = {&(std::string&) settings.upgradeNixStorePathUrl}
+            .handler = {&(std::string&) settings.upgradeNixStorePathUrl},
         });
     }
 
diff --git a/src/nix/verify.cc b/src/nix/verify.cc
index 124a05bed..558598207 100644
--- a/src/nix/verify.cc
+++ b/src/nix/verify.cc
@@ -37,7 +37,7 @@ struct CmdVerify : StorePathsCommand
             .shortName = 's',
             .description = "Use signatures from the specified store.",
             .labels = {"store-uri"},
-            .handler = {[&](std::string s) { substituterUris.push_back(s); }}
+            .handler = {[&](std::string s) { substituterUris.push_back(s); }},
         });
 
         addFlag({
@@ -45,7 +45,7 @@ struct CmdVerify : StorePathsCommand
             .shortName = 'n',
             .description = "Require that each path is signed by at least *n* different keys.",
             .labels = {"n"},
-            .handler = {&sigsNeeded}
+            .handler = {&sigsNeeded},
         });
     }