[Nix-dev] some basic questions from a new NixOS user
Linus Arver
linusarver at gmail.com
Thu Nov 24 22:44:11 CET 2011
On Thu, Nov 24, 2011 at 07:00:29PM +0100, Nicolas Pierron wrote:
> 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.
>
Thanks, this cleared up a lot of things. I just learned from reading the
Nix manual that you can create new profiles by just doing
nix-env --switch-profile /nix/var/nix/profiles/foo
and it will create "foo" if it doesn't exist already. I'm having trouble
understanding the hierarchy of folders/files in the profiles folder,
though. For my system, there appear to be 3 distinct profiles
1. /nix/var/nix/profiles/default (3 generations)
2. /nix/var/nix/profiles/system (7 generations)
3. /nix/var/nix/profiles/per-user/l/profile (11 generations)
4. /nix/var/nix/profiles/per-user/root (no files)
I can tell that #3 is what I'm currently using (if I do "nix-env
--list-generations" I get 11 generatios). If I do a "su" to change into
root and then do "nix-env --list-generations" I get 3 generations, so
that would correspond to #1. So my question is --- why does #4 exist? Is
it to house new, custom-created profiles for the root user? Perhaps
these different profiles should be documented in the Nix manual...
> > 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
>
Thanks, that makes sense --- I was getting errors with the former form.
Is the path
"/etc/nixos/nixpkgs/pkgs/top-level/all-packages.nix" documented
somewhere so I can learn more about it?
> > 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 .
I don't understand --- I thought switching profiles is done with the
"nix-env --switch-profile" command? My original question was formulated
when I did not have a good idea about profiles --- and maybe it doesn't
make much sense in light of my discoveries above regarding
/nix/var/nix/profiles.
> 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.
Thanks! The biggest problem for me is the lack of practical
documentation --- right now the NixOS docs are concerned more about the
technical advantages of NixOS and do not really help actual users trying
out the system. Of course, this will improve as more users install
NixOS, but it's the same chicken-and-egg problem that all Linux distros
have to face.
Anyway, my #1 goal right now is to get Xmonad installed and started on
boot. I don't want to bother with logging in manually with SLIM --- I
just want to stare at a blank rxvt-unicode terminal from Xmonad when I
start up. In my Arch Linux boxes, I have a /etc/inittab which deals with
how all of this is handled (automatic logging in, startx, etc.), but I'm
not so sure how to translate this setup into NixOS.
My #2 goal is to get firefox installed. Right now if I do "nix-env -i
firefox", it fails because install_flash_player_10_linux.tar.gz cannot
be downloaded from any mirror. Maybe this is only affecting i686
platforms.
And it would really help out new users if the manpages for nix-env,
nixos-rebuild, etc. were all available online --- working with terminals
inside plain X without resizable windows is difficult.
And for some reason the manpage for configuration.nix gives me a ton of
errors like
<standard input>:10440: warning [p 2, 72,0i]: can't break line
although it loads just fine.
It would also help if the "apropos" command worked --- if I do "apropos
nix" to try to get all the nix-related manpages, it just says
nix: nothing appropriate
which is not very useful.
And also, this is a small nitpick, but would anyone know why the "<"
shell stdin redirection symbol for bash does not work? I have
echo hello > hello
cat hello # gives "hello", as expected
<hello # gives me an empty line
Curiously, zsh does not give me any problems in this regard. It's not
really a problem for me, because I use zsh whenever possible (and will
set it to my login shell as soon as I figure out chsh for my regular
user...)
Sorry about the long email...
-Linus
More information about the nix-dev
mailing list