Okay David, that worked well, not being able to compose contracts has
been a thorn in my side for a long time, this makes me very happy
indeed.
Thank you kindly.
This is the solution:
contracts/list/command/default.nix
{stdenv, buildFractalideContract, upkeepers
, command
, ...}:
buildFractalideContract rec {
src = ./.;
contract = ''
@0xf61e7fcd2b18d862;
using Command = import "${command}/src/contract.capnp";
struct ListCommand {
commands @0 :List(Command.Command);
}
'';
}
imports contracts/command/default.nix:
{stdenv, buildFractalideContract, upkeepers
, tuple
, ...}:
buildFractalideContract rec {
src = ./.;
contract = ''
@0xdfa17455eb3bee21;
using Tuple = import "${tuple}/src/contract.capnp";
struct Command {
name @0 : Text;
singles @1 : List(Text);
kvs @2 : List(Tuple.Tuple);
}
'';
}
which imports tuple:
{stdenv, buildFractalideContract, upkeepers
, ...}:
buildFractalideContract rec {
src = ./.;
searchPaths = [];
contract = ''
@0xf6e41344bb789d96;
struct Tuple {
first @0 : Text;
second @1 : Text;
}
'';
}
The trick as David said is to make the "project directory" to be "/"
by setting "-I /" in buildFractalideContract.nix:
{ stdenv, writeTextFile, capnproto, capnpc-rust, genName }:
{ src, contract, ... } @ args:
let
name = genName src;
contractText = writeTextFile {
name = name;
text = contract;
executable = false;
};
in stdenv.mkCachedDerivation (args // {
name = name;
unpackPhase = "true";
installPhase = ''
runHook preInstall
mkdir -p $out/src
cp ${contractText} $out/src/contract.capnp
${capnproto}/bin/capnp compile
-o${capnpc-rust}/bin/capnpc-rust:$out/src/ $out/src/contract.capnp -I
"/"
'';
})
[stewart@rivergod:~/dev/fractalide/fractalide]$ nix-build --argstr
debug true --argstr cache $(./support/buildCache.sh) -I
nixpkgs=/home/stewart/dev/fractalide/nixpkgs/ --argstr test true -A
contracts.list_command
these derivations will be built:
/nix/store/3hkx1arvi8f3x8dw6skdgkrdnj95lk8x-tuple.drv
/nix/store/hii3683m00r4q19vig6kiaraqbi24gbn-tuple.drv
/nix/store/nmkxzkhmd9yd20glqia8dkl5cpn7pyqk-command.drv
/nix/store/z8r47ijlag9iabazgxy6mpsyh37f6gw8-command.drv
/nix/store/z3xpbhdxi4wbrnrs78ql2q5jzpqznis4-list_command.drv
/nix/store/w0vdhm7rgfw55bmhrps4549i3wc0b3yi-list_command.drv
building path(s) ‘/nix/store/adcj38q8bmll054alpfxk19llx8zzmwl-tuple’
building path(s)
‘/nix/store/9w3bv3f8mz2ca9ic80wszhkvlfzw96vd-tuple-cache’,
‘/nix/store/zrdnjya6ha14jdyk0ap4ypd3xlpgxcfy-tuple’
unpacking sources
patching sources
configuring
grep: Invalid range end
no configure script, doing nothing
building
no Makefile, doing nothing
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in
/nix/store/zrdnjya6ha14jdyk0ap4ypd3xlpgxcfy-tuple
patching script interpreter paths in
/nix/store/zrdnjya6ha14jdyk0ap4ypd3xlpgxcfy-tuple
shrinking RPATHs of ELF executables and libraries in
/nix/store/9w3bv3f8mz2ca9ic80wszhkvlfzw96vd-tuple-cache
patching script interpreter paths in
/nix/store/9w3bv3f8mz2ca9ic80wszhkvlfzw96vd-tuple-cache
building path(s) ‘/nix/store/50mkbfrrw8qvn6r8gba8h5k9pp0688x2-command’
building path(s)
‘/nix/store/08574rmrlryw0mmg70sq55vy7i01c8wc-command’,
‘/nix/store/6ka7hqssp1lqazcd7d61y60ndf5bgrgb-command-cache’
unpacking sources
patching sources
configuring
grep: Invalid range end
no configure script, doing nothing
building
no Makefile, doing nothing
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in
/nix/store/08574rmrlryw0mmg70sq55vy7i01c8wc-command
patching script interpreter paths in
/nix/store/08574rmrlryw0mmg70sq55vy7i01c8wc-command
shrinking RPATHs of ELF executables and libraries in
/nix/store/6ka7hqssp1lqazcd7d61y60ndf5bgrgb-command-cache
patching script interpreter paths in
/nix/store/6ka7hqssp1lqazcd7d61y60ndf5bgrgb-command-cache
building path(s) ‘/nix/store/s9kxz8g6gx14vkqixcfsjfj28aglibia-list_command’
building path(s)
‘/nix/store/15bhwdygyfmb04lkwwgb2fxsf7g5wxsa-list_command’,
‘/nix/store/rm82734ni6l24xbk80ypj8f39rw9fcac-list_command-cache’
unpacking sources
patching sources
configuring
grep: Invalid range end
no configure script, doing nothing
building
no Makefile, doing nothing
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in
/nix/store/15bhwdygyfmb04lkwwgb2fxsf7g5wxsa-list_command
patching script interpreter paths in
/nix/store/15bhwdygyfmb04lkwwgb2fxsf7g5wxsa-list_command
shrinking RPATHs of ELF executables and libraries in
/nix/store/rm82734ni6l24xbk80ypj8f39rw9fcac-list_command-cache
patching script interpreter paths in
/nix/store/rm82734ni6l24xbk80ypj8f39rw9fcac-list_command-cache
/nix/store/15bhwdygyfmb04lkwwgb2fxsf7g5wxsa-list_command
\m/ perfect!
It would be neat if the language on the website reflected what David mentioned.
kr/sjm
--
You received this message because you are subscribed to the Google Groups
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.