Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Update build to use nix-tools. #83

Merged
merged 24 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
steps:

- label: 'stack coveralls coverage'
command:
- 'nix-shell -A runCoveralls'
- label: 'check-hydra'
command: 'ci/check-hydra.sh'
agents:
system: x86_64-linux

- label: 'nix build'
command: 'nix-build release.nix'
- label: 'stack2nix'
command: 'ci/check-regenerate-nix.sh'
agents:
system: x86_64-linux

- label: 'stack rebuild'
env:
AWS_REGION: us-west-1
S3_BUCKET: appveyor-ci-cache
CACHE_S3_MAX_SIZE: 2500MB
STACK_ROOT: "/build/cardano-shell.stack"
command:
- "nix-build scripts/buildkite -o stack-rebuild"
- "./stack-rebuild --build-dir /build/cardano-shell --base-branch develop"
agents:
system: x86_64-linux
system: x86_64-linux
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# GitHub Linguist annotations.
# Hide nix/.stack.nix/*.nix
# That is stuff that is generated by nix-tools stack-to-nix

nix/.stack.nix/*.nix linguist-generated=true
.stack-to-nix.cache linguist-generated=true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,6 @@ exchange-topology.yaml
launch_*
result*
cabal.config

# avoid issues when running /nix/regenerate.sh
.stack-to-nix.cache
8 changes: 8 additions & 0 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
status = [
"buildkite/cardano-shell",
"ci/hydra:Cardano:cardano-shell:required",
]
timeout_sec = 7200
required_approvals = 1
block_labels = [ "WIP", "DO NOT MERGE" ]
delete_merged_branches = true
13 changes: 12 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
packages:
./

source-repository-package
type: git
Expand All @@ -11,4 +13,13 @@ source-repository-package
tag: cbe7ab32354f3838dc8c95c64109904c8f503347
subdir: iohk-monitoring

with-compiler: ghc-8.6.4
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-sl-x509
tag: e8bfc1294e088f90e5ae0b4aedbc82ee46ac5ee4

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-prelude
tag: 2256fd727c5f92e6218afdcf8cddf6e01c4a9dcd

18 changes: 0 additions & 18 deletions canonical-json.nix

This file was deleted.

20 changes: 0 additions & 20 deletions cardano-prelude.nix

This file was deleted.

1 change: 1 addition & 0 deletions cardano-shell.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ executable cardano-launcher
, formatting
-- exception handling
, safe-exceptions
, turtle
if os(windows)
build-depends: Win32
else
Expand Down
30 changes: 0 additions & 30 deletions cardano-shell.nix

This file was deleted.

25 changes: 0 additions & 25 deletions cardano-sl-x509.nix

This file was deleted.

31 changes: 31 additions & 0 deletions ci/check-hydra.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env nix-shell
#!nix-shell -p jq hydra -i bash -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/09195057114a0a8d112c847a9a8f52957420857d.tar.gz

echo '~~~ Evaluating release.nix'
command time --format '%e' -o eval-time.txt \
hydra-eval-jobs \
--option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \
-I . release.nix \
--arg supportedSystems '["x86_64-linux"]' > eval.json
EVAL_EXIT_CODE="$?"
if [ "$EVAL_EXIT_CODE" != 0 ]
then
rm eval.json eval-time.txt
echo -e "\\e[31;1mERROR: Failed to evaluate release.nix\\e[0m"
exit 1
fi
EVAL_TIME=$(cat eval-time.txt)
jq . < eval.json
ERRORS=$(jq -r 'map_values(.error)|to_entries[]|select(.value)|@text "\(.key): \(.value)"' < eval.json)
NUM_ERRORS=$(jq -r '[ map_values(.error)|to_entries[]|select(.value) ] |length' < eval.json)
rm eval.json eval-time.txt

if [ "$NUM_ERRORS" != 0 ]
then
echo -e "\\e[31;1mERROR: evaluation completed in $EVAL_TIME seconds with $NUM_ERRORS errors\\e[0m"
echo "$ERRORS"
exit 1
else
echo -e "\\e[32;1mOK: evaluation completed in $EVAL_TIME seconds with no errors\\e[0m"
exit 0
fi
20 changes: 20 additions & 0 deletions ci/check-regenerate-nix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p git bash nixStable

# Check and warn if stack-to-nix auto-generated code is out of date.

set -xe

fail_stack2nix_check() {
git diff -w --text > /tmp/stack2nix.patch
buildkite-agent artifact upload /tmp/stack2nix.patch --job "$BUILDKITE_JOB_ID"
echo "ERROR: you need to (run ./nix/regenerate.sh or apply the patch in the buildkite artifact) and commit the changes" >&2
exit 1
}

# Get relative path to script directory
scriptDir=$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")

"${scriptDir}/../nix/regenerate.sh"

git diff -w --text --exit-code || fail_stack2nix_check
26 changes: 0 additions & 26 deletions config.nix

This file was deleted.

64 changes: 64 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#
# The defaul.nix file. This will generate targets for all
# buildables (see release.nix for nomenclature, excluding
# the "build machine" last part, specific to release.nix), eg.:
#
# - nix build -f default.nix nix-tools.tests.cardano-shell # All `cardano-shell` tests
# - nix build -f default.nix nix-tools.tests.cardano-shell.tests
# - nix build -f default.nix nix-tools.exes.cardano-shell # All `cardano-shell` executables
# - nix build -f default.nix nix-tools.cexes.cardano-shell.cardano-launcher
#
# Generated targets include anything from stack.yaml (via
# nix-tools:stack-to-nix and the nix/regenerate.sh script)
# or cabal.project (via nix-tools:plan-to-nix), including all
# version overrides specified there.
#
# Nix-tools stack-to-nix will generate the `nix/.stack-pkgs.nix`
# file which is imported from the `nix/pkgs.nix` where further
# customizations outside of the ones in stack.yaml/cabal.project
# can be specified as needed for nix/ci.
#
# Please run `nix/regenerate.sh` after modifying stack.yaml
# or relevant part of cabal configuration files.
# When switching to recent stackage or hackage package version,
# you might also need to update the iohk-nix common lib. You
# can do so by running the `nix/update-iohk-nix.sh` script.
#
# More information about iohk-nix and nix-tools is available at:
# https://github.com/input-output-hk/iohk-nix/blob/master/docs/nix-toolification.org#for-a-stackage-project
#


# We will need to import the iohk-nix common lib, which includes
# the nix-tools tooling.
let
commonLib = import ./nix/iohk-common.nix;
in
# This file needs to export a function that takes
# the arguments it is passed and forwards them to
# the default-nix template from iohk-nix. This is
# important so that the release.nix file can properly
# parameterize this file when targetting different
# hosts.
{ system ? builtins.currentSystem
, config ? {}
, pkgs ? commonLib.getPkgs { inherit config system; }
, ... }@args:
# We will instantiate the default-nix template with the
# nix/pkgs.nix file...
commonLib.nix-tools.default-nix ./nix/pkgs.nix args
# ... and add additional non-haskell packages we want to build on CI:
// {

runCoveralls = pkgs.stdenv.mkDerivation {
name = "run-coveralls";
buildInputs = with pkgs; [ haskellPackages.stack-hpc-coveralls stack ];
shellHook = ''
echo '~~~ stack test'
stack test --coverage
echo '~~~ shc'
shc --repo-token=$COVERALLS_REPO_TOKEN cardano-shell cardano-shell-test
exit
'';
};
}
49 changes: 49 additions & 0 deletions nix/.stack.nix/canonical-json.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading