I want install in the same user two version of the software.
I think than specify the --profile directory was the solution.
but this command
nix-env -iA nixos.postgresql_10 --profile ~/app/binary/
retrun:
error: â/home/postgres/app/binaryâ is not a symlink
So my question is :
How i can install two version of the software binary?
Why i want to do this ?
To use the pg_upgrade binary to migrate db from one version to another.
It doesnât really make sense to install multiple versions of packages, because you canât have more than one version of a binary in your PATH.
I assume you intended to call pg_upgrade after installing like ~/app/binary/bin/pg_upgrade? I recommend either calling the binary directly (which doesnât install anything):
$(nix-build --no-out-link '<nixpkgs>' -A postgresql_10)/bin/pg_upgrade
Or running the binary in a nix-shell, which also doesnât install anything:
For completenessâs sake: you can create another profile, but it mustnât already exist as a directory or file:
$ mkdir profile1
$ nix-env -p profile1 -iA nixos.hello
error: '/home/linus/profile1' is not a symlink
$ nix-env -p profile2 -iA nixos.hello
installing 'hello-2.10'
Note that this may not produce your desired behaviour though, for several reasons:
It will not create garbage collection roots for the profile, meaning that its dependencies may be removed from under your feet during a garbage collection;
It will keep historical versions of the profile right next to it. For example, the successful invocation of nix-env in my example created profile2-1-link in addition to profile2;
The profileâs bin directory will not be in your PATH, nor will any other relevant environment variables be set, so you should have another use for putting them in a profile.
The first two issues can be solved by first creating a symlink to /nix/var/nix/profiles/per-user/$USER/profilename: ln -s /nix/var/nix/profiles/per-user/$USER/testprofile profile3 && nix-env -p profile3 -iA nixos.hello.
I sorry , but the command pg_upgrade have need of a path on the two versions.
pg_upgrade -d oldCluster/data -D newCluster/data -b oldCluster/bin -B newCluster/bin
On Debian and all others distributions you can install several version.
You can have need to manage a cluster DB in 9.6 and one in 11.
Checking cluster versions ok
Checking database user is the install user ok
Checking database connection settings ok
Checking for prepared transactions ok
Checking for reg* data types in user tables ok
Checking for contrib/isn with bigint-passing mismatch ok
Creating dump of global objects ok
Creating dump of database schemas
ok
Checking for presence of required libraries ok
Checking database user is the install user ok
Checking for prepared transactions ok
If pg_upgrade fails after this point, you must re-initdb the
new cluster before continuing.
Performing Upgrade
Analyzing all rows in the new cluster ok
Freezing all rows in the new cluster ok
Deleting files from new pg_xact ok
Copying old pg_xact to new server ok
Setting next transaction ID and epoch for new cluster ok
Deleting files from new pg_multixact/offsets ok
Copying old pg_multixact/offsets to new server ok
Deleting files from new pg_multixact/members ok
Copying old pg_multixact/members to new server ok
Setting next multixact ID and offset for new cluster ok
Resetting WAL archives ok
Setting frozenxid and minmxid counters in new cluster ok
Restoring global objects in the new cluster ok
Restoring database schemas in the new cluster
ok
Adding â.oldâ suffix to old global/pg_control ok
If you want to start the old cluster, you will need to remove
the â.oldâ suffix from /home/postgres/app/data/DB1/global/pg_control.old.
Because âlinkâ mode was used, the old cluster cannot be safely
started once the new cluster has been started.
Linking user relation files
ok
Setting next OID for new cluster ok
Sync data directory to disk ok
Creating script to analyze new cluster ok
Creating script to delete old cluster ok
Upgrade Complete
Optimizer statistics are not transferred by pg_upgrade so,
once you start the new server, consider running:
./analyze_new_cluster.sh
Running this script will delete the old clusterâs data files:
./delete_old_cluster.sh
You can pass additional args to the nix run command. That said, the -b /home/postgres/.nix-profile/bin has me a little concerned, as nix run doesnât touch that symlink.
nix-build '<nixpkgs>' -A postgresql_11 -o pg11
nix-build '<nixpkgs>' -A postgresql_10 -o pg10
Will create symlinks to the packages which are also GC roots, i.e. their dependencies wonât get removed by the garbage collector until the symlinks themselves are removed (with the caveat that the âremoval detectionâ is fairly naĂŻve and will consider the symlink removed if it is moved/renamed as well).