[Nix-dev] A few questions from a NixOS newbie.

Mateusz Kowalczyk fuuzetsu at fuuzetsu.co.uk
Mon Apr 21 14:23:41 CEST 2014


Greetings,

I have been planning to move to NixOS for quite a few months now but
only yesterday I finally clobbered my old /. Like many others, I'm a
Haskeller looking for a better development environment than we can
sanely achieve with cabal sandboxes.

Anyway, to the point. I have a few questions and I fear that I've been
pestering the IRC channel a bit too much. Unfortunately there isn't
enough information on the web yet for me to solve it, and there are many
deadlinks and unanswered IRC question which doesn't help my searches.
For reference, I'm moving from Gentoo. In no particular order:

* How do I get onto a channel that uses nixpkgs? When I file a bug with
a package, it fortunately tends to get fixed up quite fast but I do not
know how I'm meant to then receive it. I find various URLs of
nix-channel --add on the net but things like what's shown on the main
Getting Nixpkgs page don't work:

[root at lenalee:~]# nix-channel --add
http://nixos.org/channels/nixpkgs-unstable

[root at lenalee:~]# nix-channel --update
downloading Nix expressions from
`http://releases.nixos.org/nixpkgs/nixpkgs-14.04pre42251.552d66c/nixexprs.tar.xz'...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time
Current
                                 Dload  Upload   Total   Spent    Left
Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--
    0
unpacking channels...

[root at lenalee:~]# nixos-rebuild switch --upgrade
unpacking channels...
error: unable to find
`nixpkgs/nixos/modules/installer/tools/nixos-rebuild.sh'
building Nix...
error: file `nixpkgs/nixos' was not found in the Nix search path (add it
using $NIX_PATH or -I)
error: file `nixpkgs/nixos' was not found in the Nix search path (add it
using $NIX_PATH or -I)
error: file `nixpkgs' was not found in the Nix search path (add it using
$NIX_PATH or -I)
/tmp/nixos-rebuild.YUCbJ0/nix
error: unable to find `nixpkgs'
building the system configuration...
error: file `nixpkgs/nixos' was not found in the Nix search path (add it
using $NIX_PATH or -I)


Many other pages show a similar invocation but with 'nixos' in the end.
This 'nixos' is not explained anywhere as far as I can tell! My guess is
that it simply names the channel locally so that it's easy to refer to,
is that correct? By the way

nix-channel --add http://nixos.org/channels/nixos-unstable nixos

seems to work but is probably not what I want (getting few-minutes-old
fixes from nixpkgs git repository).

* The nix packages don't seem to be versioned in any way. On Gentoo, I
could inspect the software in the tree: I could check the version of the
software itself, and the version of the e-build. An example use case is
if the software fetch source dies: we need to update the e-build and
bump its version but the software version stays the same. Is there an
equivalent in NixOS?

* What is the proper way to integrate own packages into the tree?
Yesterday I found it necessary to try and package a (proprietary ;( )
blob which amongst some other things needs patchelf &c. What I did was
to fork then clone nixpkgs and written the package in appropriate
directory. I now don't know how to work with this repository so that the
rest of the system sees it. What I did was cd to the repository and then
use nix-env -f . -i mypackage but I fear that as soon as I go back to
using nix-env -i outside of that repository, nix will be confused: it
had newer packages a second ago and now it's back to old!

* In my aforementioned package, there's a binary that I expected to be
able to run after nix-env -i. That's however not the case. Is there a
section that's necessary in the .nix file that tells nix which files
should be made visible? I looked at some other packages briefly but
didn't see much.

* I started off with a 64-bit version of NixOS, installed from the .iso
but I quickly found myself needing to run 32-bit software. It quickly
became apparent that NixOS does not offer anything like ia32-lib
(Ubuntu) on multilib (Arch). What is the procedure for running 32-bit
software? After a longer time searching, I figured out how to install
some 32-bit versions of software, mainly using nix-env -iA and referring
to the package explicitly. Namely, something like nix-env -iA
nixos.pkgs.pkgsi686Linux.mesa. This doesn't work for every package in
tree however: to get 32-bit libX11, a different invocation was necessary
and only after painful amount of time spent on Google, I managed to came
up with nixpkgs.xorg.libX11.i686-linux (if I'm remembering correctly).
How do I just list properties of the packages? For example I'd like to
see all incantations needed to get packages of different architectures.

* The versioning displayed seems to be a bit weird:

✗ 1 lenalee shana % nix-env -qa | grep xmonad
haskell-xmonad-contrib-ghc7.6.3-0.11.2
haskell-xmonad-contrib-ghc7.6.3-0.11.2
haskell-xmonad-contrib-ghc7.6.3-0.11.2-profiling
haskell-xmonad-extras-ghc7.6.3-0.12
haskell-xmonad-extras-ghc7.6.3-0.12
haskell-xmonad-extras-ghc7.6.3-0.12-profiling
haskell-xmonad-ghc7.6.3-0.11
haskell-xmonad-ghc7.6.3-0.11
haskell-xmonad-ghc7.6.3-0.11-profiling

Here we have multiple packages which display the same version (why?) and
some -profiling packages. What is the naming scheme followed? Does the
version start at the last `-%d'? How do I check the difference between
the packages that display in the same fashion?

* How can I find out more about packages? For example, I'd like to query
a package of a license, or to see its .nix file. Someone told me on IRC
how to do the second one but it involved grepping all-packages.nix,
getting the path from there and then opening that. Is there no mechanism
in place which can tell me more about a package? I'd expect at least the
information given by the `eix' tool on Gentoo: installed and available
versions, short description, homepage and license. It seems to me like
fairly basic and useful information.

* Sometimes when I nixos-rebuild switch --upgrade, I get messages about
clashing packages. Unfortunately I don't have the messages on hand
because it doesn't always happens (only seems to happen when there are
things to actually update). How did I get myself into this mess and how
do I fix it? I am guessing it's either one of the two: running nix-env
-f . -i ... in the nixpkgs git checkout while being on a channel that's
less up-to-date *or* the fact that I switched architectures from 64-bit
to 32-bit and now nix is confused about the packages from each both
being present.

* Regarding switching architectures, I was very pleased to hear that I
could simply put `nixpkgs.system = "i686-linux"' in my configuration
file and then rebuild. I was a bit less pleased to see that all my old,
64-bit packages did not go away and the 32-bit packages wouldn't install
on top of them automatically. For now I ran nix-env -e and then nix-env
-i for the packages that nix-env -qs showed me but I imagine this would
be very unsatisfactory if the system was more than a day old. What is
the proper way to switch between architectures, including rebuilding the
packages so that the architecture is correct?

* Yesterday I ran nix-env -i while I already had a build running. This
caused both the invocations to crash (sorry, again, I don't have the
error for you, I did not think much of it when it happened). I was
assured on IRC that this should not happen so I will be on the lookout
for this in the future, but are there any known bugs to do with this?

* Regarding having to report packages, are there no runtime checks done?
For example, I reported the `uzbl' yesterday. While it compiled fine,
none of the binaries it provides would as much as even run, they all
errored straight away. What's done in terms of testing that the packages
actually work? I know that on Gentoo the packagers at least run the
package's test-suite and the user can even ask to run it themselves by
setting the `test' USE flag.

* Regarding USE, I quite liked the functionality. For those unaware, USE
flags let you toggle some options to do with the package. As Gentoo is
source-based, this pretty much always simply changed the compilation
flags. This provided great flexibility: one can choose whether they want
ALSA or Gnome or KDE or taglib or test or whatever support for each
package and the dependencies would be pulled in (or left out)
accordingly. As far as I know, there is no such system in place for nix.
Say I wanted to install emacs but didn't want a graphical environment:
it's a perfectly valid use case to want to run emacs on your headless
VPS. Yet, if I were to just nix-env -i emacs, I would be prompted to
install gtk3, Xorg and who knows what else (I have not actually tried
but this is simply for demonstration purposes). In Gentoo I can simply
set the -gtk3 and -X flags and any software that allows me to switch
those off will do so. How do I achieve this on NixOS? As far as I can
tell, one has to effectively make their own emacs package that removes
all the things we don't want along with their dependencies and then
install that. This is of course a problem: a lot of hassle, anything
depending on emacs doesn't see that we now have it, even if we convince
things depending on emacs that we do now have it, they might actually
depend on emacs with gtk3 and so on and so on. What's the way this
problem is solved on NixOS? If I wanted to use NixOS on any of my
servers, just this stops it from me doing so.

* I found myself needing older glibc yesterday. Namely, I wanted glibc
2.17. Normally I would be very wary of changing my glibc version but I
thought nix can make this easy for me and if something breaks I can just
use an older configuration anyway, right? To my surprise, I only found
glibc 2.19 in nix-env -qa! How do I access older packages? I honestly
don't think that only glibc 2.19 was every packaged which means the
older version was there somewhere. Does -qa hide it from me? Was it
removed from the tree and if yes, why? If `it would make -qa' messy is
the answer, maybe the way looking for packages works should be
rethought. I honestly hope I'm not expected to package glibc 2.17 myself
after about a day of usage...

* Assuming I managed to get glibc 2.17 in the tree, how do I use 2.17
for some packages but 2.19 for the rest? For example, I could make the
packages that require 2.17 depend on it, but then when I try to install
them, nix will either refuse me because it would break everything
depending on 2.19 or it would install it and break everything. I suppose
I'm asking about how to sandbox packages. I hear nix-shell is something
that might be applicable here but I'm unsure.

* Unfortunately about half of the software that I used in the past seems
to be missing and I assure you I didn't use much software at all. While
I'm not blaming anyone and realise I'll most likely have to package it
all myself, what is the procedure of getting your packages back into the
official channels? With Gentoo, one would file a request to include
software in the tree on the bug tracker and then wait. We'd provide an
e-build if we wanted to speed things up a bit but after that, it's the
packagers that take ownership of it. How is the situation in NixOS? I
write the package then what? I imagine I send a pull request to nixpkgs
on GitHub. If it gets merged, am I now responsible for it? Does anyone
else take the blame when it's not up-to-date or broken?

I think this about covers all my initial questions. Hopefully I can get
answers to most of them and this can then serve anyone else trying to
Google like mad for these.

Thanks!
-- 
Mateusz K.


More information about the nix-dev mailing list