Skip to content

Commit

Permalink
Add stack/nix integration
Browse files Browse the repository at this point in the history
Relates to #4
  • Loading branch information
rvl committed Mar 4, 2019
1 parent 0f3245a commit 3672b30
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ cabal.project.local~
.HTF/
.ghc.environment.*
.ghci

### Nix ###
/result*
18 changes: 18 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ system ? builtins.currentSystem
, crossSystem ? null
, config ? {}

# Import IOHK common nix lib
, iohkLib ? import ./nix/iohk-common.nix
# Pin nixpkgs to a revision on the nixos-19.03 channel
, nixpkgs ? iohkLib.fetchNixpkgs ./nix/nixpkgs-src.json
, pkgs ? import nixpkgs { inherit system crossSystem config; }

# Keep this argument even if unused.
# It will prevent Hydra from caching the evaluation.
, gitrev ? iohkLib.commitIdFromGitRepo ./.
}:

{
inherit pkgs;
}
15 changes: 15 additions & 0 deletions nix/iohk-common.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Imports the iohk-nix library.
# The version can be overridden for debugging purposes by setting
# NIX_PATH=iohk_nix=/path/to/iohk-nix

import (
let try = builtins.tryEval <iohk_nix>;
in if try.success
then builtins.trace "using host <iohk_nix>" try.value
else
let
spec = builtins.fromJSON (builtins.readFile ./iohk-nix.json);
in builtins.fetchTarball {
url = "${spec.url}/archive/${spec.rev}.tar.gz";
inherit (spec) sha256;
}) {}
7 changes: 7 additions & 0 deletions nix/iohk-nix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"url": "https://github.com/input-output-hk/iohk-nix",
"rev": "f20ab3940d3ec5d5a3d92e1f0544f501316adc43",
"date": "2019-02-15T19:35:36+10:00",
"sha256": "07hla7d0l91is5m5mwa86vq51fdxkjvbjv7176ipdg1z59wy21bj",
"fetchSubmodules": false
}
7 changes: 7 additions & 0 deletions nix/nixpkgs-src.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"url": "https://github.com/NixOS/nixpkgs.git",
"rev": "07e2b59812de95deeedde95fb6ba22d581d12fbc",
"date": "2019-02-26T15:31:33+01:00",
"sha256": "1yxmv04v2dywk0a5lxvi9a2rrfq29nw8qsm33nc856impgxadpgf",
"fetchSubmodules": false
}
20 changes: 20 additions & 0 deletions nix/stack-shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This is the derivation used by "stack --nix".
# It provides the system dependencies required for a stack build.
{ system ? builtins.currentSystem
, config ? {}
, walletPackages ? import ./.. { inherit config system; }
, pkgs ? walletPackages.pkgs
}:
with pkgs;

haskell.lib.buildStackProject {
name = "cardano-wallet-stack-env";
ghc = haskell.compiler.ghc863;

buildInputs = [
zlib gmp ncurses lzma openssl git
] ++ (lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Cocoa CoreServices libcxx libiconv ]));

phases = ["nobuildPhase"];
nobuildPhase = "mkdir -p $out";
}
3 changes: 3 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ extra-deps:

- git: https://github.com/input-output-hk/cardano-crypto
commit: 3c5db489c71a4d70ee43f5f9b979fcde3c797f2a

nix:
shell-file: nix/stack-shell.nix

0 comments on commit 3672b30

Please sign in to comment.