[Nix-dev] Re: I'm stuck again.. How is the nix way to do this? nix-env -i superfluous?

Eelco Dolstra eelco at cs.uu.nl
Fri Aug 17 17:09:14 CEST 2007


apfelmus wrote:

>>> In the end we only have one expression:
>>>
>>> mynix = derivation {
>>>   all_stuff = [ ghc ghcWrapperWithLibs mutt ... ... ... ... .. .. 100
>>>   150 1000 ];
>>> }
>>>
>>> and we no longer have a nix-env -i at all?
>>> I can see nix-env -i as a way to populate all_stuff ..
>>> and builder.pl is mynix.. So it is already there?
> 
> Yes,  nix-env -i  is like adding stuff to a user-defined nix-expression,
> namely the one that generates the user-environment.

Exactly!  Nix-env is really just a user-friendly frontend that generates the
call to the function that builds a user environment.

In fact, in NixOS there is a more declarative (though not necessarily more
user-friendly) way to install software, you can set the
environment.extraPackages attribute in the system configuration:

  environment = {
    extraPackages = pkgs: [
      pkgs.fuse
      pkgs.sshfsFuse
      pkgs.aefs
      pkgs.kcachegrind
      pkgs.firefox
      ...
    ];
  };

which is ultimately way more powerful than using nix-env, since instead of
"pkgs.firefox" you can have any expression, including whatever variant of
Firefox you want.

> (I think that) currently, the user-environment has no nix-expression,

It does: nix/corepkgs/buildenv/default.nix in the Nix distribution.  But it
doesn't do a lot except call the Perl script that does the actual work :-)  And
it's not very customizable right now.

> but is build by some shell/perl-script. This means that nix package
> writers have a hard time to customize user environments. It seems that
> the ./nix-support/ directory has significance here, is there any
> documentation about it, Eelco?

Well, the Perl script looks at each
$pkg/nix-support/propagated-user-env-packages and recursively adds the store
paths listed in that file to the user environment as well.  There are some other
nix-support files used in various places, but not by the user environment builder.

> The user environment is still managed by the garbage collector, though.
> Remember that nix-expressions and the storage-manager are two different
> things. The latter can happily live without the former.

Yes. :-)

-- 
Eelco Dolstra | http://www.cs.uu.nl/~eelco



More information about the nix-dev mailing list