Home Explore Blog CI



nix

2nd chunk of `doc/manual/source/package-management/profiles.md`
ef64df728d31a62b7fe895a93945324fa3520e21ae59cada00000001000004eb


Of course, you wouldn’t want to type

```console
$ /nix/store/dpmvp969yhdq...-subversion-1.1.3/bin/svn
```

every time you want to run Subversion. Of course we could set up the
`PATH` environment variable to include the `bin` directory of every
package we want to use, but this is not very convenient since changing
`PATH` doesn’t take effect for already existing processes. The solution
Nix uses is to create directory trees of symlinks to *activated*
packages. These are called *user environments* and they are packages
themselves (though automatically generated by `nix-env`), so they too
reside in the Nix store. For instance, in the figure above, the user
environment `/nix/store/0c1p5z4kda11...-user-env` contains a symlink to
just Subversion 1.1.2 (arrows in the figure indicate symlinks). This
would be what we would obtain if we had done

```console
$ nix-env --install --attr nixpkgs.subversion
```

on a set of Nix expressions that contained Subversion 1.1.2.

This doesn’t in itself solve the problem, of course; you wouldn’t want
to type `/nix/store/0c1p5z4kda11...-user-env/bin/svn` either. That’s why
there are symlinks outside of the store that point to the user

Title: User Environments in Nix
Summary
Typing the full path to an executable in the Nix store is inconvenient. While modifying the `PATH` environment variable is a possible solution, it doesn't affect existing processes. Nix resolves this by creating user environments, which are directory trees of symlinks to activated packages, residing in the Nix store. These environments, such as `/nix/store/0c1p5z4kda11...-user-env`, contain symlinks to specific package versions, for example, Subversion 1.1.2.