From 139df7744014cf46f1194afdb8d797588513f853 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 16 Oct 2025 12:42:53 +0200 Subject: [PATCH] Factor out --no-check-sigs --- src/libcmd/include/nix/cmd/command.hh | 14 ++++++++++++++ src/nix/copy.cc | 10 +--------- src/nix/flake.cc | 9 +-------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/libcmd/include/nix/cmd/command.hh b/src/libcmd/include/nix/cmd/command.hh index 20cd1abc1..2bff11dc1 100644 --- a/src/libcmd/include/nix/cmd/command.hh +++ b/src/libcmd/include/nix/cmd/command.hh @@ -350,6 +350,20 @@ struct MixEnvironment : virtual Args void setEnviron(); }; +struct MixNoCheckSigs : virtual Args +{ + CheckSigsFlag checkSigs = CheckSigs; + + MixNoCheckSigs() + { + addFlag({ + .longName = "no-check-sigs", + .description = "Do not require that paths are signed by trusted keys.", + .handler = {&checkSigs, NoCheckSigs}, + }); + } +}; + void completeFlakeInputAttrPath( AddCompletions & completions, ref evalState, diff --git a/src/nix/copy.cc b/src/nix/copy.cc index 62e8b64f5..706edc6c9 100644 --- a/src/nix/copy.cc +++ b/src/nix/copy.cc @@ -5,10 +5,9 @@ using namespace nix; -struct CmdCopy : virtual CopyCommand, virtual BuiltPathsCommand, MixProfile +struct CmdCopy : virtual CopyCommand, virtual BuiltPathsCommand, MixProfile, MixNoCheckSigs { std::optional outLink; - CheckSigsFlag checkSigs = CheckSigs; SubstituteFlag substitute = NoSubstitute; @@ -24,13 +23,6 @@ struct CmdCopy : virtual CopyCommand, virtual BuiltPathsCommand, MixProfile .handler = {&outLink}, .completer = completePath, }); - - addFlag({ - .longName = "no-check-sigs", - .description = "Do not require that paths are signed by trusted keys.", - .handler = {&checkSigs, NoCheckSigs}, - }); - addFlag({ .longName = "substitute-on-destination", .shortName = 's', diff --git a/src/nix/flake.cc b/src/nix/flake.cc index cf05f6943..04d4ec8eb 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -1032,12 +1032,10 @@ struct CmdFlakeClone : FlakeCommand } }; -struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun +struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun, MixNoCheckSigs { std::string dstUri; - CheckSigsFlag checkSigs = CheckSigs; - SubstituteFlag substitute = NoSubstitute; CmdFlakeArchive() @@ -1048,11 +1046,6 @@ struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun .labels = {"store-uri"}, .handler = {&dstUri}, }); - addFlag({ - .longName = "no-check-sigs", - .description = "Do not require that paths are signed by trusted keys.", - .handler = {&checkSigs, NoCheckSigs}, - }); } std::string description() override