forked from lix-project/lix
Merge pull request #4803 from ShamrockLee/nix-channel-list-generations
Add `nix-channel --list-generations`
This commit is contained in:
commit
ff905cb796
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
# Synopsis
|
# Synopsis
|
||||||
|
|
||||||
`nix-channel` {`--add` url [*name*] | `--remove` *name* | `--list` | `--update` [*names…*] | `--rollback` [*generation*] }
|
`nix-channel` {`--add` url [*name*] | `--remove` *name* | `--list` | `--update` [*names…*] | `--list-generations` | `--rollback` [*generation*] }
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
|
|
||||||
|
@ -39,6 +39,15 @@ This command has the following operations:
|
||||||
for `nix-env` operations (by symlinking them from the directory
|
for `nix-env` operations (by symlinking them from the directory
|
||||||
`~/.nix-defexpr`).
|
`~/.nix-defexpr`).
|
||||||
|
|
||||||
|
- `--list-generations`\
|
||||||
|
Prints a list of all the current existing generations for the
|
||||||
|
channel profile.
|
||||||
|
|
||||||
|
Works the same way as
|
||||||
|
```
|
||||||
|
nix-env --profile /nix/var/nix/profiles/per-user/$USER/channels --list-generations
|
||||||
|
```
|
||||||
|
|
||||||
- `--rollback` \[*generation*\]\
|
- `--rollback` \[*generation*\]\
|
||||||
Reverts the previous call to `nix-channel
|
Reverts the previous call to `nix-channel
|
||||||
--update`. Optionally, you can specify a specific channel generation
|
--update`. Optionally, you can specify a specific channel generation
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
# Release X.Y (202?-??-??)
|
# Release X.Y (202?-??-??)
|
||||||
|
|
||||||
|
- [`nix-channel`](../command-ref/nix-channel.md) now supports a `--list-generations` subcommand
|
||||||
|
|
|
@ -177,6 +177,7 @@ static int main_nix_channel(int argc, char ** argv)
|
||||||
cRemove,
|
cRemove,
|
||||||
cList,
|
cList,
|
||||||
cUpdate,
|
cUpdate,
|
||||||
|
cListGenerations,
|
||||||
cRollback
|
cRollback
|
||||||
} cmd = cNone;
|
} cmd = cNone;
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
|
@ -193,6 +194,8 @@ static int main_nix_channel(int argc, char ** argv)
|
||||||
cmd = cList;
|
cmd = cList;
|
||||||
} else if (*arg == "--update") {
|
} else if (*arg == "--update") {
|
||||||
cmd = cUpdate;
|
cmd = cUpdate;
|
||||||
|
} else if (*arg == "--list-generations") {
|
||||||
|
cmd = cListGenerations;
|
||||||
} else if (*arg == "--rollback") {
|
} else if (*arg == "--rollback") {
|
||||||
cmd = cRollback;
|
cmd = cRollback;
|
||||||
} else {
|
} else {
|
||||||
|
@ -237,6 +240,11 @@ static int main_nix_channel(int argc, char ** argv)
|
||||||
case cUpdate:
|
case cUpdate:
|
||||||
update(StringSet(args.begin(), args.end()));
|
update(StringSet(args.begin(), args.end()));
|
||||||
break;
|
break;
|
||||||
|
case cListGenerations:
|
||||||
|
if (!args.empty())
|
||||||
|
throw UsageError("'--list-generations' expects no arguments");
|
||||||
|
std::cout << runProgram(settings.nixBinDir + "/nix-env", false, {"--profile", profile, "--list-generations"}) << std::flush;
|
||||||
|
break;
|
||||||
case cRollback:
|
case cRollback:
|
||||||
if (args.size() > 1)
|
if (args.size() > 1)
|
||||||
throw UsageError("'--rollback' has at most one argument");
|
throw UsageError("'--rollback' has at most one argument");
|
||||||
|
|
|
@ -8,6 +8,7 @@ rm -f $TEST_HOME/.nix-channels $TEST_HOME/.nix-profile
|
||||||
nix-channel --add http://foo/bar xyzzy
|
nix-channel --add http://foo/bar xyzzy
|
||||||
nix-channel --list | grepQuiet http://foo/bar
|
nix-channel --list | grepQuiet http://foo/bar
|
||||||
nix-channel --remove xyzzy
|
nix-channel --remove xyzzy
|
||||||
|
[[ $(nix-channel --list-generations | wc -l) == 1 ]]
|
||||||
|
|
||||||
[ -e $TEST_HOME/.nix-channels ]
|
[ -e $TEST_HOME/.nix-channels ]
|
||||||
[ "$(cat $TEST_HOME/.nix-channels)" = '' ]
|
[ "$(cat $TEST_HOME/.nix-channels)" = '' ]
|
||||||
|
@ -38,6 +39,7 @@ ln -s dependencies.nix $TEST_ROOT/nixexprs/default.nix
|
||||||
# Test the update action.
|
# Test the update action.
|
||||||
nix-channel --add file://$TEST_ROOT/foo
|
nix-channel --add file://$TEST_ROOT/foo
|
||||||
nix-channel --update
|
nix-channel --update
|
||||||
|
[[ $(nix-channel --list-generations | wc -l) == 2 ]]
|
||||||
|
|
||||||
# Do a query.
|
# Do a query.
|
||||||
nix-env -qa \* --meta --xml --out-path > $TEST_ROOT/meta.xml
|
nix-env -qa \* --meta --xml --out-path > $TEST_ROOT/meta.xml
|
||||||
|
|
Loading…
Reference in a new issue