1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-29 06:21:14 +02:00

Merge pull request #24 from DeterminateSystems/rename-nix-profile-install-to-add

Rename `nix profile install` to `nix profile add`
This commit is contained in:
Graham Christensen 2025-04-10 18:38:33 +00:00 committed by GitHub
commit 02da540353
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 153 additions and 147 deletions

View file

@ -250,7 +250,6 @@ nix3_manpages = [
'nix3-print-dev-env', 'nix3-print-dev-env',
'nix3-profile-diff-closures', 'nix3-profile-diff-closures',
'nix3-profile-history', 'nix3-profile-history',
'nix3-profile-install',
'nix3-profile-list', 'nix3-profile-list',
'nix3-profile', 'nix3-profile',
'nix3-profile-remove', 'nix3-profile-remove',
@ -283,7 +282,6 @@ nix3_manpages = [
'nix3-store', 'nix3-store',
'nix3-store-optimise', 'nix3-store-optimise',
'nix3-store-path-from-hash-part', 'nix3-store-path-from-hash-part',
'nix3-store-ping',
'nix3-store-prefetch-file', 'nix3-store-prefetch-file',
'nix3-store-repair', 'nix3-store-repair',
'nix3-store-sign', 'nix3-store-sign',

View file

@ -844,7 +844,7 @@ RawInstallablesCommand::RawInstallablesCommand()
void RawInstallablesCommand::applyDefaultInstallables(std::vector<std::string> & rawInstallables) void RawInstallablesCommand::applyDefaultInstallables(std::vector<std::string> & rawInstallables)
{ {
if (rawInstallables.empty()) { if (rawInstallables.empty()) {
// FIXME: commands like "nix profile install" should not have a // FIXME: commands like "nix profile add" should not have a
// default, probably. // default, probably.
rawInstallables.push_back("."); rawInstallables.push_back(".");
} }

View file

@ -647,4 +647,25 @@ nlohmann::json MultiCommand::toJSON()
return res; return res;
} }
Strings::iterator MultiCommand::rewriteArgs(Strings & args, Strings::iterator pos)
{
if (command)
return command->second->rewriteArgs(args, pos);
if (aliasUsed || pos == args.end()) return pos;
auto arg = *pos;
auto i = aliases.find(arg);
if (i == aliases.end()) return pos;
auto & info = i->second;
if (info.status == AliasStatus::Deprecated) {
warn("'%s' is a deprecated alias for '%s'",
arg, concatStringsSep(" ", info.replacement));
}
pos = args.erase(pos);
for (auto j = info.replacement.rbegin(); j != info.replacement.rend(); ++j)
pos = args.insert(pos, *j);
aliasUsed = true;
return pos;
}
} }

View file

@ -393,8 +393,30 @@ public:
nlohmann::json toJSON() override; nlohmann::json toJSON() override;
enum struct AliasStatus {
/** Aliases that don't go away */
AcceptedShorthand,
/** Aliases that will go away */
Deprecated,
};
/** An alias, except for the original syntax, which is in the map key. */
struct AliasInfo {
AliasStatus status;
std::vector<std::string> replacement;
};
/**
* A list of aliases (remapping a deprecated/shorthand subcommand
* to something else).
*/
std::map<std::string, AliasInfo> aliases;
Strings::iterator rewriteArgs(Strings & args, Strings::iterator pos) override;
protected: protected:
std::string commandName = ""; std::string commandName = "";
bool aliasUsed = false;
}; };
Strings argvToStrings(int argc, char * * argv); Strings argvToStrings(int argc, char * * argv);

View file

@ -51,19 +51,6 @@ void chrootHelper(int argc, char * * argv);
namespace nix { namespace nix {
enum struct AliasStatus {
/** Aliases that don't go away */
AcceptedShorthand,
/** Aliases that will go away */
Deprecated,
};
/** An alias, except for the original syntax, which is in the map key. */
struct AliasInfo {
AliasStatus status;
std::vector<std::string> replacement;
};
/* Check if we have a non-loopback/link-local network interface. */ /* Check if we have a non-loopback/link-local network interface. */
static bool haveInternet() static bool haveInternet()
{ {
@ -151,54 +138,34 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs
.category = miscCategory, .category = miscCategory,
.handler = {[&]() { refresh = true; }}, .handler = {[&]() { refresh = true; }},
}); });
}
std::map<std::string, AliasInfo> aliases = { aliases = {
{"add-to-store", { AliasStatus::Deprecated, {"store", "add-path"}}}, {"add-to-store", { AliasStatus::Deprecated, {"store", "add-path"}}},
{"cat-nar", { AliasStatus::Deprecated, {"nar", "cat"}}}, {"cat-nar", { AliasStatus::Deprecated, {"nar", "cat"}}},
{"cat-store", { AliasStatus::Deprecated, {"store", "cat"}}}, {"cat-store", { AliasStatus::Deprecated, {"store", "cat"}}},
{"copy-sigs", { AliasStatus::Deprecated, {"store", "copy-sigs"}}}, {"copy-sigs", { AliasStatus::Deprecated, {"store", "copy-sigs"}}},
{"dev-shell", { AliasStatus::Deprecated, {"develop"}}}, {"dev-shell", { AliasStatus::Deprecated, {"develop"}}},
{"diff-closures", { AliasStatus::Deprecated, {"store", "diff-closures"}}}, {"diff-closures", { AliasStatus::Deprecated, {"store", "diff-closures"}}},
{"dump-path", { AliasStatus::Deprecated, {"store", "dump-path"}}}, {"dump-path", { AliasStatus::Deprecated, {"store", "dump-path"}}},
{"hash-file", { AliasStatus::Deprecated, {"hash", "file"}}}, {"hash-file", { AliasStatus::Deprecated, {"hash", "file"}}},
{"hash-path", { AliasStatus::Deprecated, {"hash", "path"}}}, {"hash-path", { AliasStatus::Deprecated, {"hash", "path"}}},
{"ls-nar", { AliasStatus::Deprecated, {"nar", "ls"}}}, {"ls-nar", { AliasStatus::Deprecated, {"nar", "ls"}}},
{"ls-store", { AliasStatus::Deprecated, {"store", "ls"}}}, {"ls-store", { AliasStatus::Deprecated, {"store", "ls"}}},
{"make-content-addressable", { AliasStatus::Deprecated, {"store", "make-content-addressed"}}}, {"make-content-addressable", { AliasStatus::Deprecated, {"store", "make-content-addressed"}}},
{"optimise-store", { AliasStatus::Deprecated, {"store", "optimise"}}}, {"optimise-store", { AliasStatus::Deprecated, {"store", "optimise"}}},
{"ping-store", { AliasStatus::Deprecated, {"store", "info"}}}, {"ping-store", { AliasStatus::Deprecated, {"store", "info"}}},
{"sign-paths", { AliasStatus::Deprecated, {"store", "sign"}}}, {"sign-paths", { AliasStatus::Deprecated, {"store", "sign"}}},
{"shell", { AliasStatus::AcceptedShorthand, {"env", "shell"}}}, {"shell", { AliasStatus::AcceptedShorthand, {"env", "shell"}}},
{"show-derivation", { AliasStatus::Deprecated, {"derivation", "show"}}}, {"show-derivation", { AliasStatus::Deprecated, {"derivation", "show"}}},
{"show-config", { AliasStatus::Deprecated, {"config", "show"}}}, {"show-config", { AliasStatus::Deprecated, {"config", "show"}}},
{"to-base16", { AliasStatus::Deprecated, {"hash", "to-base16"}}}, {"to-base16", { AliasStatus::Deprecated, {"hash", "to-base16"}}},
{"to-base32", { AliasStatus::Deprecated, {"hash", "to-base32"}}}, {"to-base32", { AliasStatus::Deprecated, {"hash", "to-base32"}}},
{"to-base64", { AliasStatus::Deprecated, {"hash", "to-base64"}}}, {"to-base64", { AliasStatus::Deprecated, {"hash", "to-base64"}}},
{"verify", { AliasStatus::Deprecated, {"store", "verify"}}}, {"verify", { AliasStatus::Deprecated, {"store", "verify"}}},
{"doctor", { AliasStatus::Deprecated, {"config", "check"}}}, {"doctor", { AliasStatus::Deprecated, {"config", "check"}}},
};
}; };
bool aliasUsed = false;
Strings::iterator rewriteArgs(Strings & args, Strings::iterator pos) override
{
if (aliasUsed || command || pos == args.end()) return pos;
auto arg = *pos;
auto i = aliases.find(arg);
if (i == aliases.end()) return pos;
auto & info = i->second;
if (info.status == AliasStatus::Deprecated) {
warn("'%s' is a deprecated alias for '%s'",
arg, concatStringsSep(" ", info.replacement));
}
pos = args.erase(pos);
for (auto j = info.replacement.rbegin(); j != info.replacement.rend(); ++j)
pos = args.insert(pos, *j);
aliasUsed = true;
return pos;
}
std::string description() override std::string description() override
{ {
return "a tool for reproducible and declarative configuration management"; return "a tool for reproducible and declarative configuration management";

37
src/nix/profile-add.md Normal file
View file

@ -0,0 +1,37 @@
R""(
# Examples
- Add a package from Nixpkgs:
```console
# nix profile add nixpkgs#hello
```
- Add a package from a specific branch of Nixpkgs:
```console
# nix profile add nixpkgs/release-20.09#hello
```
- Add a package from a specific revision of Nixpkgs:
```console
# nix profile add nixpkgs/d73407e8e6002646acfdef0e39ace088bacc83da#hello
```
- Add a specific output of a package:
```console
# nix profile add nixpkgs#bash^man
```
# Description
This command adds [_installables_](./nix.md#installables) to a Nix profile.
> **Note**
>
> `nix profile install` is an alias for `nix profile add` in Determinate Nix.
)""

View file

@ -1,34 +0,0 @@
R""(
# Examples
* Install a package from Nixpkgs:
```console
# nix profile install nixpkgs#hello
```
* Install a package from a specific branch of Nixpkgs:
```console
# nix profile install nixpkgs/release-20.09#hello
```
* Install a package from a specific revision of Nixpkgs:
```console
# nix profile install nixpkgs/d73407e8e6002646acfdef0e39ace088bacc83da#hello
```
* Install a specific output of a package:
```console
# nix profile install nixpkgs#bash^man
```
# Description
This command adds [*installables*](./nix.md#installables) to a Nix profile.
)""

View file

@ -338,14 +338,14 @@ builtPathsPerInstallable(
return res; return res;
} }
struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile struct CmdProfileAdd : InstallablesCommand, MixDefaultProfile
{ {
std::optional<int64_t> priority; std::optional<int64_t> priority;
CmdProfileInstall() { CmdProfileAdd() {
addFlag({ addFlag({
.longName = "priority", .longName = "priority",
.description = "The priority of the package to install.", .description = "The priority of the package to add.",
.labels = {"priority"}, .labels = {"priority"},
.handler = {&priority}, .handler = {&priority},
}); });
@ -353,13 +353,13 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile
std::string description() override std::string description() override
{ {
return "install a package into a profile"; return "add a package to a profile";
} }
std::string doc() override std::string doc() override
{ {
return return
#include "profile-install.md" #include "profile-add.md"
; ;
} }
@ -415,7 +415,7 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile
&& existingSource->originalRef == elementSource->originalRef && existingSource->originalRef == elementSource->originalRef
&& existingSource->attrPath == elementSource->attrPath && existingSource->attrPath == elementSource->attrPath
) { ) {
warn("'%s' is already installed", elementName); warn("'%s' is already added", elementName);
continue; continue;
} }
} }
@ -462,15 +462,15 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile
"\n" "\n"
" nix profile remove %3%\n" " nix profile remove %3%\n"
"\n" "\n"
"The new package can also be installed next to the existing one by assigning a different priority.\n" "The new package can also be added next to the existing one by assigning a different priority.\n"
"The conflicting packages have a priority of %5%.\n" "The conflicting packages have a priority of %5%.\n"
"To prioritise the new package:\n" "To prioritise the new package:\n"
"\n" "\n"
" nix profile install %4% --priority %6%\n" " nix profile add %4% --priority %6%\n"
"\n" "\n"
"To prioritise the existing package:\n" "To prioritise the existing package:\n"
"\n" "\n"
" nix profile install %4% --priority %7%\n", " nix profile add %4% --priority %7%\n",
originalConflictingFilePath, originalConflictingFilePath,
newConflictingFilePath, newConflictingFilePath,
originalEntryName, originalEntryName,
@ -708,16 +708,14 @@ struct CmdProfileUpgrade : virtual SourceExprCommand, MixDefaultProfile, MixProf
if (!element.source) { if (!element.source) {
warn( warn(
"Found package '%s', but it was not installed from a flake, so it can't be checked for upgrades!", "Found package '%s', but it was not added from a flake, so it can't be checked for upgrades!",
element.identifier() element.identifier());
);
continue; continue;
} }
if (element.source->originalRef.input.isLocked()) { if (element.source->originalRef.input.isLocked()) {
warn( warn(
"Found package '%s', but it was installed from a locked flake reference so it can't be upgraded!", "Found package '%s', but it was added from a locked flake reference so it can't be upgraded!",
element.identifier() element.identifier());
);
continue; continue;
} }
@ -787,7 +785,7 @@ struct CmdProfileList : virtual EvalCommand, virtual StoreCommand, MixDefaultPro
{ {
std::string description() override std::string description() override
{ {
return "list installed packages"; return "list packages in the profile";
} }
std::string doc() override std::string doc() override
@ -978,7 +976,7 @@ struct CmdProfile : NixMultiCommand
: NixMultiCommand( : NixMultiCommand(
"profile", "profile",
{ {
{"install", []() { return make_ref<CmdProfileInstall>(); }}, {"add", []() { return make_ref<CmdProfileAdd>(); }},
{"remove", []() { return make_ref<CmdProfileRemove>(); }}, {"remove", []() { return make_ref<CmdProfileRemove>(); }},
{"upgrade", []() { return make_ref<CmdProfileUpgrade>(); }}, {"upgrade", []() { return make_ref<CmdProfileUpgrade>(); }},
{"list", []() { return make_ref<CmdProfileList>(); }}, {"list", []() { return make_ref<CmdProfileList>(); }},
@ -987,7 +985,11 @@ struct CmdProfile : NixMultiCommand
{"rollback", []() { return make_ref<CmdProfileRollback>(); }}, {"rollback", []() { return make_ref<CmdProfileRollback>(); }},
{"wipe-history", []() { return make_ref<CmdProfileWipeHistory>(); }}, {"wipe-history", []() { return make_ref<CmdProfileWipeHistory>(); }},
}) })
{ } {
aliases = {
{"install", { AliasStatus::Deprecated, {"add"}}},
};
}
std::string description() override std::string description() override
{ {

View file

@ -7,7 +7,7 @@
using namespace nix; using namespace nix;
struct CmdPingStore : StoreCommand, MixJSON struct CmdInfoStore : StoreCommand, MixJSON
{ {
std::string description() override std::string description() override
{ {
@ -46,15 +46,4 @@ struct CmdPingStore : StoreCommand, MixJSON
} }
}; };
struct CmdInfoStore : CmdPingStore static auto rCmdInfoStore = registerCommand2<CmdInfoStore>({"store", "info"});
{
void run(nix::ref<nix::Store> store) override
{
warn("'nix store ping' is a deprecated alias for 'nix store info'");
CmdPingStore::run(store);
}
};
static auto rCmdPingStore = registerCommand2<CmdPingStore>({"store", "info"});
static auto rCmdInfoStore = registerCommand2<CmdInfoStore>({"store", "ping"});

View file

@ -5,7 +5,11 @@ using namespace nix;
struct CmdStore : NixMultiCommand struct CmdStore : NixMultiCommand
{ {
CmdStore() : NixMultiCommand("store", RegisterCommand::getCommandsFor({"store"})) CmdStore() : NixMultiCommand("store", RegisterCommand::getCommandsFor({"store"}))
{ } {
aliases = {
{"ping", { AliasStatus::Deprecated, {"info"}}},
};
}
std::string description() override std::string description() override
{ {

View file

@ -52,7 +52,7 @@ cp "${config_nix}" $flake1Dir/
# Test upgrading from nix-env. # Test upgrading from nix-env.
nix-env -f ./user-envs.nix -i foo-1.0 nix-env -f ./user-envs.nix -i foo-1.0
nix profile list | grep -A2 'Name:.*foo' | grep 'Store paths:.*foo-1.0' nix profile list | grep -A2 'Name:.*foo' | grep 'Store paths:.*foo-1.0'
nix profile install $flake1Dir -L nix profile add $flake1Dir -L
nix profile list | grep -A4 'Name:.*flake1' | grep 'Locked flake URL:.*narHash' nix profile list | grep -A4 'Name:.*flake1' | grep 'Locked flake URL:.*narHash'
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]] [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
[ -e $TEST_HOME/.nix-profile/share/man ] [ -e $TEST_HOME/.nix-profile/share/man ]
@ -64,12 +64,12 @@ nix profile diff-closures | grep 'env-manifest.nix: ε → ∅'
# Test XDG Base Directories support # Test XDG Base Directories support
export NIX_CONFIG="use-xdg-base-directories = true" export NIX_CONFIG="use-xdg-base-directories = true"
nix profile remove flake1 2>&1 | grep 'removed 1 packages' nix profile remove flake1 2>&1 | grep 'removed 1 packages'
nix profile install $flake1Dir nix profile add $flake1Dir
[[ $($TEST_HOME/.local/state/nix/profile/bin/hello) = "Hello World" ]] [[ $($TEST_HOME/.local/state/nix/profile/bin/hello) = "Hello World" ]]
unset NIX_CONFIG unset NIX_CONFIG
# Test conflicting package install. # Test conflicting package add.
nix profile install $flake1Dir 2>&1 | grep "warning: 'flake1' is already installed" nix profile add $flake1Dir 2>&1 | grep "warning: 'flake1' is already added"
# Test upgrading a package. # Test upgrading a package.
printf NixOS > $flake1Dir/who printf NixOS > $flake1Dir/who
@ -132,16 +132,16 @@ nix profile history | grep 'foo: 1.0 -> ∅'
nix profile diff-closures | grep 'Version 3 -> 4' nix profile diff-closures | grep 'Version 3 -> 4'
# Test installing a non-flake package. # Test installing a non-flake package.
nix profile install --file ./simple.nix '' nix profile add --file ./simple.nix ''
[[ $(cat $TEST_HOME/.nix-profile/hello) = "Hello World!" ]] [[ $(cat $TEST_HOME/.nix-profile/hello) = "Hello World!" ]]
nix profile remove simple 2>&1 | grep 'removed 1 packages' nix profile remove simple 2>&1 | grep 'removed 1 packages'
nix profile install $(nix-build --no-out-link ./simple.nix) nix profile add $(nix-build --no-out-link ./simple.nix)
[[ $(cat $TEST_HOME/.nix-profile/hello) = "Hello World!" ]] [[ $(cat $TEST_HOME/.nix-profile/hello) = "Hello World!" ]]
# Test packages with same name from different sources # Test packages with same name from different sources
mkdir $TEST_ROOT/simple-too mkdir $TEST_ROOT/simple-too
cp ./simple.nix "${config_nix}" simple.builder.sh $TEST_ROOT/simple-too cp ./simple.nix "${config_nix}" simple.builder.sh $TEST_ROOT/simple-too
nix profile install --file $TEST_ROOT/simple-too/simple.nix '' nix profile add --file $TEST_ROOT/simple-too/simple.nix ''
nix profile list | grep -A4 'Name:.*simple' | grep 'Name:.*simple-1' nix profile list | grep -A4 'Name:.*simple' | grep 'Name:.*simple-1'
nix profile remove simple 2>&1 | grep 'removed 1 packages' nix profile remove simple 2>&1 | grep 'removed 1 packages'
nix profile remove simple-1 2>&1 | grep 'removed 1 packages' nix profile remove simple-1 2>&1 | grep 'removed 1 packages'
@ -160,13 +160,13 @@ nix profile history | grep "packages.$system.default: 1.0, 1.0-man -> 3.0, 3.0-m
nix profile remove flake1 2>&1 | grep 'removed 1 packages' nix profile remove flake1 2>&1 | grep 'removed 1 packages'
printf 4.0 > $flake1Dir/version printf 4.0 > $flake1Dir/version
printf Utrecht > $flake1Dir/who printf Utrecht > $flake1Dir/who
nix profile install $flake1Dir nix profile add $flake1Dir
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello Utrecht" ]] [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello Utrecht" ]]
[[ $(nix path-info --json $(realpath $TEST_HOME/.nix-profile/bin/hello) | jq -r .[].ca) =~ fixed:r:sha256: ]] [[ $(nix path-info --json $(realpath $TEST_HOME/.nix-profile/bin/hello) | jq -r .[].ca) =~ fixed:r:sha256: ]]
# Override the outputs. # Override the outputs.
nix profile remove simple flake1 nix profile remove simple flake1
nix profile install "$flake1Dir^*" nix profile add "$flake1Dir^*"
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello Utrecht" ]] [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello Utrecht" ]]
[ -e $TEST_HOME/.nix-profile/share/man ] [ -e $TEST_HOME/.nix-profile/share/man ]
[ -e $TEST_HOME/.nix-profile/include ] [ -e $TEST_HOME/.nix-profile/include ]
@ -179,7 +179,7 @@ nix profile upgrade flake1
[ -e $TEST_HOME/.nix-profile/include ] [ -e $TEST_HOME/.nix-profile/include ]
nix profile remove flake1 2>&1 | grep 'removed 1 packages' nix profile remove flake1 2>&1 | grep 'removed 1 packages'
nix profile install "$flake1Dir^man" nix profile add "$flake1Dir^man"
(! [ -e $TEST_HOME/.nix-profile/bin/hello ]) (! [ -e $TEST_HOME/.nix-profile/bin/hello ])
[ -e $TEST_HOME/.nix-profile/share/man ] [ -e $TEST_HOME/.nix-profile/share/man ]
(! [ -e $TEST_HOME/.nix-profile/include ]) (! [ -e $TEST_HOME/.nix-profile/include ])
@ -193,9 +193,9 @@ printf World > $flake1Dir/who
cp -r $flake1Dir $flake2Dir cp -r $flake1Dir $flake2Dir
printf World2 > $flake2Dir/who printf World2 > $flake2Dir/who
nix profile install $flake1Dir nix profile add $flake1Dir
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]] [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
expect 1 nix profile install $flake2Dir expect 1 nix profile add $flake2Dir
diff -u <( diff -u <(
nix --offline profile install $flake2Dir 2>&1 1> /dev/null \ nix --offline profile install $flake2Dir 2>&1 1> /dev/null \
| grep -vE "^warning: " \ | grep -vE "^warning: " \
@ -214,31 +214,31 @@ error: An existing package already provides the following file:
nix profile remove flake1 nix profile remove flake1
The new package can also be installed next to the existing one by assigning a different priority. The new package can also be added next to the existing one by assigning a different priority.
The conflicting packages have a priority of 5. The conflicting packages have a priority of 5.
To prioritise the new package: To prioritise the new package:
nix profile install path:${flake2Dir}#packages.${system}.default --priority 4 nix profile add path:${flake2Dir}#packages.${system}.default --priority 4
To prioritise the existing package: To prioritise the existing package:
nix profile install path:${flake2Dir}#packages.${system}.default --priority 6 nix profile add path:${flake2Dir}#packages.${system}.default --priority 6
EOF EOF
) )
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]] [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
nix profile install $flake2Dir --priority 100 nix profile add $flake2Dir --priority 100
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]] [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
nix profile install $flake2Dir --priority 0 nix profile add $flake2Dir --priority 0
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World2" ]] [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World2" ]]
# nix profile install $flake1Dir --priority 100 # nix profile add $flake1Dir --priority 100
# [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]] # [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
# Ensure that conflicts are handled properly even when the installables aren't # Ensure that conflicts are handled properly even when the installables aren't
# flake references. # flake references.
# Regression test for https://github.com/NixOS/nix/issues/8284 # Regression test for https://github.com/NixOS/nix/issues/8284
clearProfiles clearProfiles
nix profile install $(nix build $flake1Dir --no-link --print-out-paths) nix profile add $(nix build $flake1Dir --no-link --print-out-paths)
expect 1 nix profile install --impure --expr "(builtins.getFlake ''$flake2Dir'').packages.$system.default" expect 1 nix profile add --impure --expr "(builtins.getFlake ''$flake2Dir'').packages.$system.default"
# Test upgrading from profile version 2. # Test upgrading from profile version 2.
clearProfiles clearProfiles