[Nix-dev] Newbie questions
Moritz Ulrich
moritz at tarn-vedra.de
Mon Dec 2 13:19:51 CET 2013
Answered inline:
Matt Paine writes:
> 1) I am currently running a mac. I tentatively use HomeBrew (a bsd ports
> like package manager) as it doesn't interfere too much with the system, and
> uninstall it and all the ports it has installed is a relatively easy
> process. How does installing nix on my mac integrate? Obviously using the
> NixOS it is tightly integrated, but I would like to try it out with my mac.
> What does the installer (for macosx) actually touch? Hopefully just adding
> .nix-profile to the path etc, but I would like to make sure before I
> uninstall it and wreck my specific mac setup.
By default, nix puts stuff to /nix/store and ~/.nix-profile. That's it.
If you're not on NixOS, you'll have to add a line to your bash
initialization to point PATH (and other things) to ~/.nix-profile/bin so
it can find the binaries there.
> 2) I LOVE the way I can define a system from the one file
> (/etc/nixos/configuration.nix). Is there a way I can define my user profile
> like that as well? i.e. ~/.nixos/configuration.nix. This way I can
> source-control that file, and when I setup a new machine, I can not only
> ensure the system is configured sanely, but also my specific user (which
> might want a different version of python for instance than whats built for
> the system)
You can define a list of packages in a nix file and install it to your
user's env. I can't remember the correct flags for nix-env right now,
but it's possible.
You can also use the `myEnvFun function of Nix. It will create a shell
script for you which loads up a shell which *only* contains a specified
list of packages. Super useful to create 'language' specific
environments (one for Ruby, one for Python, whatever). It's also
possible to define different environments for different python versions.
> 3) After modifying /etc/nixos/configuration.nix, and if the system screws
> up, and I want to rollback, is there a way of knowing what the previous
> configuration.nix was so I can compare to the existing one?
There's an option to put configuration.nix in the store, but I found
NixOS to be pretty sturdy - I never needed this, as I usually know what
changed before my system failed to boot.
> 4) I notice there is a raspberry pi image available for download. Its quite
> old, I was hoping to build my own .img file and try out nixos on my
> raspberry pi. Building CD/DVD ISO's is pretty easy, but I am unfamiliar
> with out to build an image for raspberry pi. Any hints on how I can do that?
NixOS on the Pi isn't much fun. It's way too slow at compiling.
> 5) The documentation mentions after creating a .nix file for a software
> package, to add it to the top-level/all-packages.nix. If I wanted to create
> a derivation for a specific older instance of php with specific
> configuration, which would not be very useful for the community, but highly
> useful for my deployment, what is the best way to handle that instance? Can
> I just put the .nix file in my projects repo, and run the derivation direct
> from that file? I assume the answer is yes, but I have not found out how
> yet.
I'd just put the .nix file in the repository, yeah. As for the how-to:
You must see Nix as a programming language. There's a function
`stdenv.mkDerivation' which takes a 'build script' (more or less) and
some inputs (the dependencies) and returns a string. The string is the
path to the result of the build script in the nix-store (/nix/store).
You can use this function in your own nix files anywhere. Nothing ties
you to put it to all-packages.nix.
As the php expressions are pretty big, I'd just copy the whole file over
to the repo, and create a new 'default.nix' file which is responsible
for including php's file and build your project with it.
I'd suggest to head over to the IRC channel for some help with this - or
just drop another mail to this list here.
--
Moritz Ulrich
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20131202/5bcd79ec/attachment.bin
More information about the nix-dev
mailing list