@@ -50,19 +50,6 @@ void chrootHelper(int argc, char * * argv);
5050
5151namespace nix {
5252
53- enum struct AliasStatus {
54- /* * Aliases that don't go away */
55- AcceptedShorthand,
56- /* * Aliases that will go away */
57- Deprecated,
58- };
59-
60- /* * An alias, except for the original syntax, which is in the map key. */
61- struct AliasInfo {
62- AliasStatus status;
63- std::vector<std::string> replacement;
64- };
65-
6653/* Check if we have a non-loopback/link-local network interface. */
6754static bool haveInternet ()
6855{
@@ -153,54 +140,34 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs
153140 .handler = {[&]() { refresh = true ; }},
154141 .experimentalFeature = Xp::NixCommand,
155142 });
156- }
157143
158- std::map<std::string, AliasInfo> aliases = {
159- {" add-to-store" , { AliasStatus::Deprecated, {" store" , " add-path" }}},
160- {" cat-nar" , { AliasStatus::Deprecated, {" nar" , " cat" }}},
161- {" cat-store" , { AliasStatus::Deprecated, {" store" , " cat" }}},
162- {" copy-sigs" , { AliasStatus::Deprecated, {" store" , " copy-sigs" }}},
163- {" dev-shell" , { AliasStatus::Deprecated, {" develop" }}},
164- {" diff-closures" , { AliasStatus::Deprecated, {" store" , " diff-closures" }}},
165- {" dump-path" , { AliasStatus::Deprecated, {" store" , " dump-path" }}},
166- {" hash-file" , { AliasStatus::Deprecated, {" hash" , " file" }}},
167- {" hash-path" , { AliasStatus::Deprecated, {" hash" , " path" }}},
168- {" ls-nar" , { AliasStatus::Deprecated, {" nar" , " ls" }}},
169- {" ls-store" , { AliasStatus::Deprecated, {" store" , " ls" }}},
170- {" make-content-addressable" , { AliasStatus::Deprecated, {" store" , " make-content-addressed" }}},
171- {" optimise-store" , { AliasStatus::Deprecated, {" store" , " optimise" }}},
172- {" ping-store" , { AliasStatus::Deprecated, {" store" , " info" }}},
173- {" sign-paths" , { AliasStatus::Deprecated, {" store" , " sign" }}},
174- {" shell" , { AliasStatus::AcceptedShorthand, {" env" , " shell" }}},
175- {" show-derivation" , { AliasStatus::Deprecated, {" derivation" , " show" }}},
176- {" show-config" , { AliasStatus::Deprecated, {" config" , " show" }}},
177- {" to-base16" , { AliasStatus::Deprecated, {" hash" , " to-base16" }}},
178- {" to-base32" , { AliasStatus::Deprecated, {" hash" , " to-base32" }}},
179- {" to-base64" , { AliasStatus::Deprecated, {" hash" , " to-base64" }}},
180- {" verify" , { AliasStatus::Deprecated, {" store" , " verify" }}},
181- {" doctor" , { AliasStatus::Deprecated, {" config" , " check" }}},
144+ aliases = {
145+ {" add-to-store" , { AliasStatus::Deprecated, {" store" , " add-path" }}},
146+ {" cat-nar" , { AliasStatus::Deprecated, {" nar" , " cat" }}},
147+ {" cat-store" , { AliasStatus::Deprecated, {" store" , " cat" }}},
148+ {" copy-sigs" , { AliasStatus::Deprecated, {" store" , " copy-sigs" }}},
149+ {" dev-shell" , { AliasStatus::Deprecated, {" develop" }}},
150+ {" diff-closures" , { AliasStatus::Deprecated, {" store" , " diff-closures" }}},
151+ {" dump-path" , { AliasStatus::Deprecated, {" store" , " dump-path" }}},
152+ {" hash-file" , { AliasStatus::Deprecated, {" hash" , " file" }}},
153+ {" hash-path" , { AliasStatus::Deprecated, {" hash" , " path" }}},
154+ {" ls-nar" , { AliasStatus::Deprecated, {" nar" , " ls" }}},
155+ {" ls-store" , { AliasStatus::Deprecated, {" store" , " ls" }}},
156+ {" make-content-addressable" , { AliasStatus::Deprecated, {" store" , " make-content-addressed" }}},
157+ {" optimise-store" , { AliasStatus::Deprecated, {" store" , " optimise" }}},
158+ {" ping-store" , { AliasStatus::Deprecated, {" store" , " info" }}},
159+ {" sign-paths" , { AliasStatus::Deprecated, {" store" , " sign" }}},
160+ {" shell" , { AliasStatus::AcceptedShorthand, {" env" , " shell" }}},
161+ {" show-derivation" , { AliasStatus::Deprecated, {" derivation" , " show" }}},
162+ {" show-config" , { AliasStatus::Deprecated, {" config" , " show" }}},
163+ {" to-base16" , { AliasStatus::Deprecated, {" hash" , " to-base16" }}},
164+ {" to-base32" , { AliasStatus::Deprecated, {" hash" , " to-base32" }}},
165+ {" to-base64" , { AliasStatus::Deprecated, {" hash" , " to-base64" }}},
166+ {" verify" , { AliasStatus::Deprecated, {" store" , " verify" }}},
167+ {" doctor" , { AliasStatus::Deprecated, {" config" , " check" }}},
168+ };
182169 };
183170
184- bool aliasUsed = false ;
185-
186- Strings::iterator rewriteArgs (Strings & args, Strings::iterator pos) override
187- {
188- if (aliasUsed || command || pos == args.end ()) return pos;
189- auto arg = *pos;
190- auto i = aliases.find (arg);
191- if (i == aliases.end ()) return pos;
192- auto & info = i->second ;
193- if (info.status == AliasStatus::Deprecated) {
194- warn (" '%s' is a deprecated alias for '%s'" ,
195- arg, concatStringsSep (" " , info.replacement ));
196- }
197- pos = args.erase (pos);
198- for (auto j = info.replacement .rbegin (); j != info.replacement .rend (); ++j)
199- pos = args.insert (pos, *j);
200- aliasUsed = true ;
201- return pos;
202- }
203-
204171 std::string description () override
205172 {
206173 return " a tool for reproducible and declarative configuration management" ;
0 commit comments