Reputation: 103
I'm trying to write a haskell project using stack + nix. My current stack.yaml and shell.nix are as follows:
resolver: lts-14.6
packages:
- .
nix:
enable: true
pure: true
shell-file: shell.nix
{ghc}:
with (import <nixpkgs> {});
haskell.lib.buildStackProject {
inherit ghc;
name = "myproject";
buildInputs = [ pkg-config libmysqlclient postgresql_10 pcre libsodium secp256k1 zlib ];
PGPASSWORD = builtins.getEnv "PGPASSWORD";
}
Now, in my haskell project, I want to execute tezos-client and other tools provided by tezos-baking-platform. I can build it by running
nix-build -A tezos.babylonnet.kit
The problem is, after building, I can find all the executable files in, for example, /nix/store/bgqva3wgi3knivdk9pf7gdd0384hj2qf-tezos-0.0.0/bin/
. But they are not exposed to nix-env and I can't find any symlink for tezos in ~/.nix-profile/bin/
.
So, (1) how can I fix this? and (2) how can I set that tezos-baking-platform as a dependency of my haskell project? (i.e. through stack to ask nix for building tezos for me right before build my haskell project)
Upvotes: 3
Views: 342
Reputation: 103
I figured out a working (but maybe not perfect) solution.
Because the tezos-baking-platform is not providing nix derivation, so the simplest way is to put the entire repository into the working repository and import
its nix file. This will make tezos.babylonnet.kit
available in nix so we can set it as a dependency directly.
{ghc}:
with (import <nixpkgs> {});
with import ./tezos-baking-platform/default.nix {};
haskell.lib.buildStackProject {
inherit ghc;
name = "qq";
buildInputs = [ tezos.babylonnet.kit ];
}
PS. Ideally, if the tezos-baking-platform provided a nix derivation, then we can do something like
{ghc}:
with (import <nixpkgs> {});
stdenv.mkDerivation {
name = "tezos-baking-platform";
version = "0.0.0";
src = fetchurl {
url = "https://gitlab.com/obsidian.systems/tezos-baking-platform/";
rev = "2f37c78a4b0ac26ee5e428711ab3c7ebeb9869fb";
sha256 = "0h71ivsva7hfqy0zy1pbx68a4i8lbqln3k9zkw0j2rgain39844r";
};
}
haskell.lib.buildStackProject {
inherit ghc;
name = "myproject";
buildInputs = [ tezos-baking-platform ];
}
Upvotes: 2
Reputation: 34071
To enter a shell with the executables in the PATH: nix shell
(by default it references shell.nix
).
To add tezos-baking-platform
as a dependency I think you just add it in buildInputs
. If this is from a channel
named tezos
you will have to import this:
tezos = import <tezos> {};
...
tezos.tezos-baking-platform
Upvotes: 0