[Nix-dev] nix-shell with system pkgs

Yacine Hmito yacine.hmito at gmail.com
Tue Jan 26 00:15:55 CET 2016


Hi,

Bear with me a minute, because I need to introduce a setup in order
to make sense to my following questions.

Say I packaged a piece of software and the derivation is written in a
mypkg.nix file.
I want to use the <nixpkgs> provided by the unstable channel and don't want
to fork the repo and link to it, so I create a nix set in a file myset.nix
with an attribute `mypkg = callPackage ./mypkg.nix` and use
`packageOverrides`
to make it available. The software is installed ; everything works fine.

Now, say I want to do something like `nix-shell '<nixpkgs>' -A mypkg`.
Obviously, this will not work, because mypkgs does not belong to the pkgs
set provided by the channel. However I see no simple way to use nix-shell
from this derivation.

So, I did this workaround: I added to NIX_PATH a "custompkgs" field that
points to a file holding this expression:
`(import <nixpkgs> { }) // (import ./myset.nix (import <nixpkgs> { }))`.
Note that myset.nix takes pkgs as an argument because packageOverrides
requires it.
`nix-shell '<custompkgs>' -A mypkgs` now works like a charm.

Now, let's get to something a tad harder: say I have another package
in the form of the file myotherpkg.nix.
Now, myset.nix contains both the mypkg and myotherpkg. Thing is,
myotherpkg depends on mypkgs!
Using `packageOverrides` is fine. myotherpkgs finds its dependency when the
set is made recursive. It installs ; great!
But `nix-shell '<custompkgs>' -A myotherpkgs` complains about not finding
the mypkgs dependency.

So, after this lengthy introduction, these are my questions:

- Is it possible for nix-shell to use pkgs as configured by the system
instead of evaluating '<nixpkgs>'? Would pointing toward the system's .drv
file
help? If so, how should I proceed?
- If it is not possible (yet ? :P), can someone explain to me why myotherpkg
can't find its dependency? This really doesn't make sense to me.

Thanks to anyone who'll be kind enough to answer, and to anyone how has made
this awesome OS.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160126/5d75e406/attachment.html 


More information about the nix-dev mailing list