mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +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.",
|
||||
|
|
|
@ -77,6 +77,13 @@ nix profile upgrade --regex '.*'
|
|||
[[ $(readlink $TEST_HOME/.nix-profile/bin/hello) =~ .*-profile-test-2\.1/bin/hello ]]
|
||||
nix profile rollback
|
||||
|
||||
# Test upgrading all packages
|
||||
printf 2.2 > $flake1Dir/version
|
||||
nix profile upgrade --all
|
||||
[[ $(readlink $TEST_HOME/.nix-profile/bin/hello) =~ .*-profile-test-2\.2/bin/hello ]]
|
||||
nix profile rollback
|
||||
printf 1.0 > $flake1Dir/version
|
||||
|
||||
# Test matching no packages using literal package name.
|
||||
assertStderr nix --offline profile upgrade this_package_is_not_installed << EOF
|
||||
warning: Package name 'this_package_is_not_installed' does not match any packages in the profile.
|
||||
|
|
Loading…
Reference in a new issue