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

Commit 97d5f35

Browse files
committed
Update build to use nix-tools.
1 parent fd48ab2 commit 97d5f35

30 files changed

+1042
-84
lines changed

.buildkite/pipeline.yml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
11
steps:
2-
3-
- label: 'stack coveralls coverage'
4-
command:
5-
- 'nix-shell -A runCoveralls'
2+
- label: 'check-hydra'
3+
command: 'ci/check-hydra.sh'
64
agents:
75
system: x86_64-linux
8-
9-
- label: 'nix build'
10-
command: 'nix-build release.nix'
6+
- label: 'stack2nix'
7+
command: 'ci/check-regenerate-nix.sh'
118
agents:
12-
system: x86_64-linux
13-
14-
- label: 'stack rebuild'
15-
env:
16-
AWS_REGION: us-west-1
17-
S3_BUCKET: appveyor-ci-cache
18-
CACHE_S3_MAX_SIZE: 2500MB
19-
STACK_ROOT: "/build/cardano-shell.stack"
20-
command:
21-
- "nix-build scripts/buildkite -o stack-rebuild"
22-
- "./stack-rebuild --build-dir /build/cardano-shell --base-branch develop"
23-
agents:
24-
system: x86_64-linux
9+
system: x86_64-linux

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# GitHub Linguist annotations.
2+
# Hide nix/.stack.nix/*.nix
3+
# That is stuff that is generated by nix-tools stack-to-nix
4+
5+
nix/.stack.nix/*.nix linguist-generated=true
6+
.stack-to-nix.cache linguist-generated=true

.stack-to-nix.cache

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bors.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
status = [
2+
"buildkite/cardano-shell",
3+
"ci/hydra:Cardano:cardano-shell:required",
4+
]
5+
timeout_sec = 7200
6+
required_approvals = 1
7+
block_labels = [ "WIP", "DO NOT MERGE" ]
8+
delete_merged_branches = true

ci/check-hydra.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -p jq hydra -i bash -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/09195057114a0a8d112c847a9a8f52957420857d.tar.gz
3+
4+
echo '~~~ Evaluating release.nix'
5+
command time --format '%e' -o eval-time.txt \
6+
hydra-eval-jobs \
7+
--option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \
8+
-I . release.nix \
9+
--arg supportedSystems '["x86_64-linux"]' > eval.json
10+
EVAL_EXIT_CODE="$?"
11+
if [ "$EVAL_EXIT_CODE" != 0 ]
12+
then
13+
rm eval.json eval-time.txt
14+
echo -e "\\e[31;1mERROR: Failed to evaluate release.nix\\e[0m"
15+
exit 1
16+
fi
17+
EVAL_TIME=$(cat eval-time.txt)
18+
jq . < eval.json
19+
ERRORS=$(jq -r 'map_values(.error)|to_entries[]|select(.value)|@text "\(.key): \(.value)"' < eval.json)
20+
NUM_ERRORS=$(jq -r '[ map_values(.error)|to_entries[]|select(.value) ] |length' < eval.json)
21+
rm eval.json eval-time.txt
22+
23+
if [ "$NUM_ERRORS" != 0 ]
24+
then
25+
echo -e "\\e[31;1mERROR: evaluation completed in $EVAL_TIME seconds with $NUM_ERRORS errors\\e[0m"
26+
echo "$ERRORS"
27+
exit 1
28+
else
29+
echo -e "\\e[32;1mOK: evaluation completed in $EVAL_TIME seconds with no errors\\e[0m"
30+
exit 0
31+
fi

ci/check-regenerate-nix.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i bash -p git bash nixStable
3+
4+
# Check and warn if stack-to-nix auto-generated code is out of date.
5+
6+
set -xe
7+
8+
fail_stack2nix_check() {
9+
git diff -w --text > /tmp/stack2nix.patch
10+
buildkite-agent artifact upload /tmp/stack2nix.patch --job "$BUILDKITE_JOB_ID"
11+
echo "ERROR: you need to (run ./nix/regenerate.sh or apply the patch in the buildkite artifact) and commit the changes" >&2
12+
exit 1
13+
}
14+
15+
# Get relative path to script directory
16+
scriptDir=$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")
17+
18+
"${scriptDir}/../nix/regenerate.sh"
19+
20+
git diff -w --text --exit-code || fail_stack2nix_check

config.nix

Lines changed: 0 additions & 26 deletions
This file was deleted.

default.nix

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#
2+
# The defaul.nix file. This will generate targets for all
3+
# buildables (see release.nix for nomenclature, excluding
4+
# the "build machine" last part, specific to release.nix), eg.:
5+
#
6+
# - nix build -f default.nix nix-tools.tests.iohk-monitoring # All `iohk-monitoring` tests
7+
# - nix build -f default.nix nix-tools.tests.iohk-monitoring.tests
8+
# - nix build -f default.nix nix-tools.exes.iohk-monitoring # All `iohk-monitoring` executables
9+
# - nix build -f default.nix nix-tools.cexes.iohk-monitoring.example-simple
10+
#
11+
# Generated targets include anything from stack.yaml (via
12+
# nix-tools:stack-to-nix and the nix/regenerate.sh script)
13+
# or cabal.project (via nix-tools:plan-to-nix), including all
14+
# version overrides specified there.
15+
#
16+
# Nix-tools stack-to-nix will generate the `nix/.stack-pkgs.nix`
17+
# file which is imported from the `nix/pkgs.nix` where further
18+
# customizations outside of the ones in stack.yaml/cabal.project
19+
# can be specified as needed for nix/ci.
20+
#
21+
# Please run `nix/regenerate.sh` after modifying stack.yaml
22+
# or relevant part of cabal configuration files.
23+
# When switching to recent stackage or hackage package version,
24+
# you might also need to update the iohk-nix common lib. You
25+
# can do so by running the `nix/update-iohk-nix.sh` script.
26+
#
27+
# More information about iohk-nix and nix-tools is available at:
28+
# https://github.com/input-output-hk/iohk-nix/blob/master/docs/nix-toolification.org#for-a-stackage-project
29+
#
30+
31+
32+
# We will need to import the iohk-nix common lib, which includes
33+
# the nix-tools tooling.
34+
let
35+
commonLib = import ./nix/iohk-common.nix;
36+
in
37+
# This file needs to export a function that takes
38+
# the arguments it is passed and forwards them to
39+
# the default-nix template from iohk-nix. This is
40+
# important so that the release.nix file can properly
41+
# parameterize this file when targetting different
42+
# hosts.
43+
{ system ? builtins.currentSystem
44+
, config ? {}, ... }@args:
45+
# We will instantiate the default-nix template with the
46+
# nix/pkgs.nix file...
47+
commonLib.nix-tools.default-nix ./nix/pkgs.nix args
48+
# ... and add additional non-haskell packages we want to build on CI:
49+
// {
50+
cardano-shell-env = (import ./stack-shell.nix { inherit config system; });
51+
}

nix/.stack.nix/canonical-json.nix

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/.stack.nix/cardano-crypto.nix

Lines changed: 88 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/.stack.nix/cardano-prelude-test.nix

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)