问题
I use Vagrant
+ virtualBox
and a Debian 8
/ Ubuntu
image for my development environments.
I want to use nix for provisioning, but I can't get nixOS
to work completely right (ie. with networking, provisioning...), but I'd more than happy to switch. So I'm falling back to nix + Debian 8
or nix + Ubuntu
to mimic the production server.
I can't quite get the differences between user packages
and system packages
and what is preferable to use in in my context, in order to be able to reuse that into a production server.
Should I install packages with nix -i
, or edit the configuration.nix
file ?
回答1:
Whether you should install packages into the system profile or into a user profile depends on what you'd like to achieve. There is no single right answer. Instead, both types of installing packages have different pros and cons.
System packages are defined in a global configuration file that typically resides in /etc/nixos/configuration.nix
. Users other than root
can typically not edit that file and thus cannot add or remove packages from the list. Packages defined in there will be installed as part of nixos-rebuild
and they'll be available in $PATH
to every user of your system. If any of those packages don't compile for some reason, however, then you cannot rebuild your system, i.e. you may find yourself in a situation where you cannot update your kernel because, say, nano
doesn't compile. People who follow the master
branch of the Nixpkgs git repository may experience this problem frequently, but it doesn't happen so much for users of the unstable
or the release-x.y
channels.
User packages can be installed, updated, and de-installed by any user on your system without the need for super-user privileges. One user's packages will not be visible to another user (unless she makes a conscious effort to import them into $PATH
). Thus, it's possible for two users to install two different versions of the same package.
If a user does not regularly update her profile, then you'll accumulate old packages in your Nix store that cannot be garbage collected. This may be a problem or a feature, depending on how you look at it. System packages, on the other hand, are all updated every time you update the system, so those tend to have a smaller disk space footprint.
Personally, I prefer to keep my system profile as small as possible; I install packages mostly into user profiles with nix-env
. I know many people, however, who do the exact opposite and we all get along fine. :-)
来源:https://stackoverflow.com/questions/31505436/nix-user-packages-vs-system-packages