[Nix-dev] getting dependencies

stewart mackenzie setori88 at gmail.com
Sat Nov 19 10:27:20 CET 2016


Greetings,

The actual code in question is here:
https://github.com/fractalide/fractalide/blob/master/contracts/list/command/default.nix
Notice all the duplication!

My problem: Achieve Contract Composition!

This is where Command should be - without the Tuple duplication!:
https://github.com/fractalide/fractalide/blob/master/contracts/command/default.nix

This is where Tuple should be:
https://github.com/fractalide/fractalide/blob/master/contracts/tuple/default.nix


Each derivation will generate a *.rs file from a *.capnp file.

This is the technique capnproto uses to import another capnproto file:

```

# /nix/store/...-bar/src/contract.capnp
@0x8744595ef8d1c0ed;

struct Bar {
  a @0 :Text;
}
```

and in a separate derivation

```
# /nix/store/...-qux/src/contract.capnp
@0x99055c3145684b93;

using Bar = import "${bar}/src/contract.capnp";
struct Qux {
  a @0 :List(Bar.Bar);
}
```
(that ${bar} is nix code! I'm omitting the { bar }: at the top of the file)

The compilation of Qux works but when a component imports the
generated Qux.rs code and compiles Qux it will fail because there is
no generated Bar.rs code present, and therefore there are unresolved
dependencies on Bar.

A possible way to work around this is:

What I need to do is have a list of all the dependencies of Qux and
then concatenate the results of all the dependency derivation's *.rs
together into one final Qux.rs file.

This would then satisfy any component that uses Qux.rs

My question: how do I get a *unique* list of all the dependencies of
Qux? If it's not unique I could run into name collisions when
compiling the concatenated list.

This has to be a common issue and there must be a simple solution in nix.

Now I need help with my incompetence please.

I looked at propagatedBuildInputs, but it doesn't seem to work. Why?

Z depends on Y
Y depends on X

When I compile Z, X does not appear in any of the env-vars fields!
Only Y appears in an environment variable called
propagatedNativeBuildInputs (whatever that is, there doesn't seem to
be any documentation on propagatedNativeBuildInputs) Despite the
documentation saying otherwise. Secondly I cannot find a
nix-support/propagated-build-inputs file anywhere.

here is the documentation:

"propagatedBuildInputs

Like buildInputs, but these dependencies are propagated: that is, the
dependencies listed here are added to the buildInputs of any package
that uses this package as a dependency. So if package Y has
propagatedBuildInputs = [X], and package Z has buildInputs = [Y], then
package X will appear in Z’s build environment automatically."

Using this logic, I would need to include any dependent contract in
both the buildInputs and propagatedBuildInputs, so that contracts
would propagate "upstream". This also doesn't seem to work.

What am I missing?

kr/sjm


More information about the nix-dev mailing list