mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
profile: add --regex option to match packages
This commit is contained in:
parent
d6f5da51d3
commit
87741dbd21
4 changed files with 21 additions and 3 deletions
|
@ -11,7 +11,7 @@ R""(
|
|||
* Remove all packages:
|
||||
|
||||
```console
|
||||
# nix profile remove '.*'
|
||||
# nix profile remove --regex '.*'
|
||||
```
|
||||
|
||||
* Remove a package by store path:
|
||||
|
|
|
@ -6,7 +6,7 @@ R""(
|
|||
reference:
|
||||
|
||||
```console
|
||||
# nix profile upgrade '.*'
|
||||
# nix profile upgrade --regex '.*'
|
||||
```
|
||||
|
||||
* Upgrade a specific package by name:
|
||||
|
|
|
@ -508,7 +508,15 @@ public:
|
|||
|
||||
MixProfileElementMatchers()
|
||||
{
|
||||
expectArgs(ExpectedArg {
|
||||
addFlag({
|
||||
.longName = "regex",
|
||||
.description = "A regular expression to match one or more packages in the profile.",
|
||||
.labels = {"pattern"},
|
||||
.handler = {[this](std::string arg) {
|
||||
_matchers.push_back(createRegexMatcher(arg));
|
||||
}},
|
||||
});
|
||||
expectArgs({
|
||||
.label = "elements",
|
||||
.optional = true,
|
||||
.handler = {[this](std::vector<std::string> args) {
|
||||
|
|
|
@ -71,6 +71,16 @@ nix profile upgrade flake1
|
|||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello NixOS" ]]
|
||||
nix profile history | grep "packages.$system.default: 1.0, 1.0-man -> 2.0, 2.0-man"
|
||||
|
||||
# Test upgrading package using regular expression.
|
||||
printf 2.1 > $flake1Dir/version
|
||||
nix profile upgrade --regex '.*'
|
||||
[[ $(readlink $TEST_HOME/.nix-profile/bin/hello) =~ .*-profile-test-2\.1/bin/hello ]]
|
||||
nix profile rollback
|
||||
|
||||
# Test removing all packages using regular expression.
|
||||
nix profile remove --regex '.*' 2>&1 | grep "removed 2 packages, kept 0 packages"
|
||||
nix profile rollback
|
||||
|
||||
# Test 'history', 'diff-closures'.
|
||||
nix profile diff-closures
|
||||
|
||||
|
|
Loading…
Reference in a new issue