mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
profile: add --all option to match any package
This commit is contained in:
parent
fb391ebc77
commit
7a4d5e89d3
4 changed files with 38 additions and 2 deletions
|
@ -11,9 +11,16 @@ R""(
|
|||
* Remove all packages:
|
||||
|
||||
```console
|
||||
# nix profile remove --regex '.*'
|
||||
# nix profile remove --all
|
||||
```
|
||||
|
||||
* Remove packages by regular expression:
|
||||
|
||||
```console
|
||||
# nix profile remove --regex '.*vim.*'
|
||||
```
|
||||
|
||||
|
||||
* Remove a package by store path:
|
||||
|
||||
```console
|
||||
|
|
|
@ -6,7 +6,7 @@ R""(
|
|||
reference:
|
||||
|
||||
```console
|
||||
# nix profile upgrade --regex '.*'
|
||||
# nix profile upgrade --all
|
||||
```
|
||||
|
||||
* Upgrade a specific package by name:
|
||||
|
@ -15,6 +15,12 @@ R""(
|
|||
# nix profile upgrade hello
|
||||
```
|
||||
|
||||
* Upgrade all packages that include 'vim' in their name:
|
||||
|
||||
```console
|
||||
# nix profile upgrade --regex '.*vim.*'
|
||||
```
|
||||
|
||||
# Description
|
||||
|
||||
This command upgrades a previously installed package in a Nix profile,
|
||||
|
|
|
@ -458,6 +458,7 @@ enum MatcherType
|
|||
Regex,
|
||||
StorePath,
|
||||
Name,
|
||||
All,
|
||||
};
|
||||
|
||||
struct Matcher
|
||||
|
@ -500,6 +501,14 @@ Matcher createNameMatcher(const std::string & name) {
|
|||
};
|
||||
}
|
||||
|
||||
Matcher all = {
|
||||
.type = MatcherType::All,
|
||||
.title = "--all",
|
||||
.matches = [](const std::string &name, const ProfileElement & element) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class MixProfileElementMatchers : virtual Args, virtual StoreCommand
|
||||
{
|
||||
std::vector<Matcher> _matchers;
|
||||
|
@ -508,6 +517,13 @@ public:
|
|||
|
||||
MixProfileElementMatchers()
|
||||
{
|
||||
addFlag({
|
||||
.longName = "all",
|
||||
.description = "Match all packages in the profile.",
|
||||
.handler = {[this]() {
|
||||
_matchers.push_back(all);
|
||||
}},
|
||||
});
|
||||
addFlag({
|
||||
.longName = "regex",
|
||||
.description = "A regular expression to match one or more packages in the profile.",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue