Skip to content

Commit f84b336

Browse files
authored
Merge pull request NixOS#14271 from NixOS/no-check-sigs
Factor out `--no-check-sigs` into its own class
2 parents 0503a86 + 3bd2b76 commit f84b336

File tree

4 files changed

+17
-20
lines changed

4 files changed

+17
-20
lines changed

src/libcmd/include/nix/cmd/command.hh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,20 @@ struct MixEnvironment : virtual Args
350350
void setEnviron();
351351
};
352352

353+
struct MixNoCheckSigs : virtual Args
354+
{
355+
CheckSigsFlag checkSigs = CheckSigs;
356+
357+
MixNoCheckSigs()
358+
{
359+
addFlag({
360+
.longName = "no-check-sigs",
361+
.description = "Do not require that paths are signed by trusted keys.",
362+
.handler = {&checkSigs, NoCheckSigs},
363+
});
364+
}
365+
};
366+
353367
void completeFlakeInputAttrPath(
354368
AddCompletions & completions,
355369
ref<EvalState> evalState,

src/nix/copy.cc

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
using namespace nix;
77

8-
struct CmdCopy : virtual CopyCommand, virtual BuiltPathsCommand, MixProfile
8+
struct CmdCopy : virtual CopyCommand, virtual BuiltPathsCommand, MixProfile, MixNoCheckSigs
99
{
1010
std::optional<std::filesystem::path> outLink;
11-
CheckSigsFlag checkSigs = CheckSigs;
1211

1312
SubstituteFlag substitute = NoSubstitute;
1413

@@ -24,13 +23,6 @@ struct CmdCopy : virtual CopyCommand, virtual BuiltPathsCommand, MixProfile
2423
.handler = {&outLink},
2524
.completer = completePath,
2625
});
27-
28-
addFlag({
29-
.longName = "no-check-sigs",
30-
.description = "Do not require that paths are signed by trusted keys.",
31-
.handler = {&checkSigs, NoCheckSigs},
32-
});
33-
3426
addFlag({
3527
.longName = "substitute-on-destination",
3628
.shortName = 's',

src/nix/flake.cc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,12 +1032,10 @@ struct CmdFlakeClone : FlakeCommand
10321032
}
10331033
};
10341034

1035-
struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun
1035+
struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun, MixNoCheckSigs
10361036
{
10371037
std::string dstUri;
10381038

1039-
CheckSigsFlag checkSigs = CheckSigs;
1040-
10411039
SubstituteFlag substitute = NoSubstitute;
10421040

10431041
CmdFlakeArchive()
@@ -1048,11 +1046,6 @@ struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun
10481046
.labels = {"store-uri"},
10491047
.handler = {&dstUri},
10501048
});
1051-
addFlag({
1052-
.longName = "no-check-sigs",
1053-
.description = "Do not require that paths are signed by trusted keys.",
1054-
.handler = {&checkSigs, NoCheckSigs},
1055-
});
10561049
}
10571050

10581051
std::string description() override

src/nix/sigs.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ struct CmdSign : StorePathsCommand
104104
.labels = {"file"},
105105
.handler = {&secretKeyFile},
106106
.completer = completePath,
107+
.required = true,
107108
});
108109
}
109110

@@ -114,9 +115,6 @@ struct CmdSign : StorePathsCommand
114115

115116
void run(ref<Store> store, StorePaths && storePaths) override
116117
{
117-
if (secretKeyFile.empty())
118-
throw UsageError("you must specify a secret key file using '-k'");
119-
120118
SecretKey secretKey(readFile(secretKeyFile));
121119
LocalSigner signer(std::move(secretKey));
122120

0 commit comments

Comments
 (0)