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

Linus Arver linusarver at gmail.com
Thu Dec 1 00:51:25 CET 2011


On Wed, Nov 30, 2011 at 05:45:37PM +0100, Peter Simons wrote:
> Hi Linus,
> 
>  > I see that you're on NixOS as well. You might remember me from the
>  > Arch-Haskell list some time ago...
> 
> ah, of course! Now that you've mentioned it, I recognize your name. :-)
> After supporting Haskell on ArchLinux for a while, I found that most of
> the tasks I had to do (i.e. figure out which packages need to be rebuilt
> after an update, etc.) come for free with Nix, so I switched to NixOS a
> while ago.

I see... my reason for trying out NixOS is simple: it is the only OS
that I know of which uses a functional package manager. It's like the
epiphany I had when I started programming in Haskell... suddenly, all
imperative paradigms looked really, really dangerous and ugly to me.

Maybe one day, the concept of functional package managers will spread to
other OSes. I mean, with nix-collect-garbage, I can't see any downsides
to using NixOS. The way I see it, Nix is to packages as git/hg/svn is to
source code because it introduces "commits" (generations) and "branches"
(profiles) to package managers! It's the way of the future!

>  >     $ nix-env -i haskell-ghc7.0.4
> 
> You probably want to install "ghc-7.0.4-wrapper" into your profile
> instead of "ghc-7.0.4". The wrapper ensures that the real compiler is
> called with all those extra paths on the command-line that are required
> to make GHC see the library packages installed in the profile.
> 
> NixOS has those wrappers for many packages (like gcc, python, and so on)
> for precisely that purpose. It's a bit of inconvenience at first, but in
> the long run the benefits outweigh the extra effort.

Ah, that makes sense. Unfortunately (or fortunately?), there is no need
for me to install xmonad with nix-env: I actually ended up just doing
everything in configuration.nix, by adopting the configuration Shea Levy
posted in this thread (thanks, Shea!!), which installed
ghc/xmonad/xmonad-contrib correctly (all modules are recognized by
ghci!).

>  > Strangely, I can't use this convenient syntax, because nix throws an
>  > error:
>  >
>  >     $ nix-env -iA haskellPackages.{xmonad,ghc}
>  >     error: attribute `haskellPackages' in selection path `haskellPackages' not found
>  >
>  > I've already done a nixos-checkout, so, I don't understand why my
>  > freshly-installed NixOS is coughing up this error...
> 
> The exact attribute path that you have to use depends on the way your
> system is installed. "nix-env -qaP \*" should print the proper paths for
> your system.

The "nix-env -qaP \*" command does work, but I am unable to make sense
of the output. For example, there is this line:

    nixpkgs_sys.haskellPackages_ghc704_no_profiling.xmonad      haskell-xmonad-ghc7.0.4-0.10

I can see that the second column is the package name, but what is the
first column? How do I use it so I can use the "nix-env -iA" syntax?

>  >     $ nix-env -qaA '*'
>  >     warning: you probably meant to specify the argument '*' to show all packages
>  >     error: attribute `*' in selection path `*' not found
> 
> I guess that you meant to use the "P" option instead of "A"?

No, because the nix-env manpage explicitly says "nix-env -qaA '*'" gives
the attribute paths. Could this be a typo in the manpage?

Anyway, thanks to everyone's help, I've got a running system with Xmonad
+ urxvt + zsh. So things are looking 99% identical to my 2+ year Arch
Linux setups on my other machines... :)

-Linus


More information about the nix-dev mailing list