Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sevanspowell committed Apr 14, 2021
1 parent 2849e83 commit a5689b6
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .buildkite/default.nix
Expand Up @@ -11,13 +11,19 @@ let
libs = ps: with ps; [turtle safe transformers extra async];
ghc' = haskellPackages.ghcWithPackages libs;

# Include the stack nix-shell in closure of stackRebuild, so that it
# doesn't get garbage-collected whilst the build is running.
# https://github.com/commercialhaskell/stack/issues/3479
stackShell = import ../nix/stack-shell.nix {};

stackRebuild = runCommand "stack-rebuild" {
buildInputs = [ ghc' makeWrapper ];
} ''
mkdir -p $out/bin
ghc -Wall -threaded -o $out/bin/rebuild ${./rebuild.hs}
wrapProgram $out/bin/rebuild \
--set PATH "${lib.makeBinPath buildTools}"
--set PATH "${lib.makeBinPath buildTools}" \
--set NO_GC_STACK_SHELL ${stackShell}
'';

in
Expand Down
58 changes: 58 additions & 0 deletions nix/cabal-shell.nix
@@ -0,0 +1,58 @@
# This shell file provides a compiler, build tools and system
# libraries, and lets Cabal build all of the Haskell package
# dependencies.
#
# The default shell (../shell.nix) uses the Haskell.nix shellFor to
# also provide Haskell package dependencies in the shell environment.

{ pkgs ? import ./default.nix {}
# optional string argument to override compiler, e.g.
# nix-shell nix/cabal-shell.nix --argstr compiler ghc8102
, compiler ? null
}:

with pkgs;

mkShell rec {
name = "offchain-metadata-tools-cabal-env";
meta.platforms = lib.platforms.unix;

ghc = if (compiler == null)
then offchainMetadataToolsHaskellPackages.metadata-lib.project.pkg-set.config.ghc.package
else haskell-nix.compiler.${compiler};

tools = [
ghc
cabal-install
nix
pkgconfig
]
++ lib.optional (!stdenv.isDarwin) git;

libs = [
zlib
gmp
ncurses
lzma
openssl
libsodium
]
++ lib.optional (stdenv.hostPlatform.libc == "glibc") glibcLocales
++ lib.optional stdenv.isLinux systemd.dev
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
Cocoa CoreServices libcxx libiconv
]);

buildInputs = tools ++ libs;

# allow building the shell so that it can be cached in hydra
phases = ["nobuildPhase"];
nobuildPhase = "echo '${lib.concatStringsSep "\n" buildInputs}' > $out";
preferLocalBuild = true;

# Ensure that libz.so and other libraries are available to TH splices.
LD_LIBRARY_PATH = lib.makeLibraryPath libs;

# Force a UTF-8 locale because many Haskell programs and tests assume this.
LANG = "en_US.UTF-8";
}
20 changes: 20 additions & 0 deletions nix/stack-shell.nix
@@ -0,0 +1,20 @@
# This is the derivation used by "stack --nix".
# It provides the system dependencies required for a stack build.
{ pkgs ? import ./default.nix {}
}:

let
cabalShell = import ./cabal-shell.nix {
inherit pkgs;
};
in
cabalShell.overrideAttrs (old: {
name = "offchain-metadata-tools-stack-env";

buildInputs = old.buildInputs ++ [ pkgs.stack ];

# Build environment setup copied from
# <nixpkgs/pkgs/development/haskell-modules/generic-stack-builder.nix>
GIT_SSL_CAINFO = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
STACK_IN_NIX_SHELL = "true";
})

0 comments on commit a5689b6

Please sign in to comment.