1
0
Fork 0
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:
Bob van der Linden 2024-03-06 22:04:53 +01:00
parent fb391ebc77
commit 7a4d5e89d3
No known key found for this signature in database
4 changed files with 38 additions and 2 deletions

View file

@ -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

View file

@ -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,

View file

@ -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.",