[Nix-dev] some basic questions from a new NixOS user

Nicolas Pierron nicolas.b.pierron at gmail.com
Thu Nov 24 19:00:29 CET 2011


Hi Linus,

On Thu, Nov 24, 2011 at 07:24, Linus Arver <linusarver at gmail.com> wrote:
> I'm new to this list.

Great.

> 1a. I've added a new user account with "useradd," per the manual, and
> have done a couple installations of software with `nix-env -i'. This is
> great, but I'm curious --- what is the preferred way to install
> software? The wiki page at http://nixos.org/wiki/Install/remove_software
> says that there are two ways to install software --- system-wide (by
> editing environment.systemPackages), and per-user (by just doing nix-env
> -i [package]). My understanding is that in order to get the advertised
> advantages of NixOS's rollback functionality, you have to do system-wide
> installs because the whole "nixos-rebuild" command only looks at
> /etc/nixos/configuration.nix. I.e., there is no way to rollback the
> system on a per-user basis. So, do most people on here have a very long
> environment.systemPackages definition in their configuration.nix,
> defining all system-wide packages?

Using either per-user install or system-wide install depends on what
you want to do.  Personally I use both.

NixOS is build on top of Nix and relies on the nix-env command to
update the system profile and also to do rollbacks (have a look at the
end of nix-env man page).  One advantage of per-user profiles is that
the root account does not see (in its default PATH) the user installed
software and also the opposite.  This difference is not a big security
protection but it helps to separate the administrative tools from the
commonly used tools.

On my case, I am using user profiles to install software that I don't
want to see under the root user (inkscape, gimp, firefox, …) and I am
also using user-profiles (not the default ~/.nix-profile) to test
compilation with different tool-chains (x64-gcc45, x86-gcc46, …), in
which case I reset the environment and rebuild it from scratch with
only this user profile.

> 1b. If I wanted zsh, git, and rxvt-unicode to be available system-wide,
> can I do:
>
>    environment.systemPackages = [
>        pkgs.zsh
>        pkgs.git
>        pkgs.rxvt-unicode
>    ];
>
> in my configuration.nix? There does not seem to be any documentation
> regarding the syntax for this.

Sure, you can do it, except that the papckages names are extracted
from /etc/nixos/nixpkgs/pkgs/top-level/all-packages.nix .  Thus you
should not use the package name, but the key listed in this file.  So
you will need to replace

>        pkgs.rxvt-unicode

by    pkgs.rxvt_unicode

> 2. If I do "nix-env -i" as the root user, then the installation is only
> for the root user, correct?

I am no longer sure since I haven't reinstalled NixOS since a while,
but I think you have a default profile which is used by all users
including root.  So you may want to switch to another profile such as
$NIX_USER_PROFILE_DIR .


Don't hesitate to give us your feedback if you think that some steps
are not clear and took you time to figure out.  I'll update the wiki
page to fix one mistake and to separate the uninstall from the
removal.

-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/


More information about the nix-dev mailing list