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

Commit 30829cc

Browse files
jbgiCodiePP
authored andcommitted
Update build to use nix-tools. (#83)
* Update build to use nix-tools. * updated commands for 'cardano-shell' Signed-off-by: Alexander Diemand <[email protected]> * Regeneate nix. * set project name in nix commands Signed-off-by: Alexander Diemand <[email protected]> * Fix nix-shells. * Update iohk-nix * Clean-up unused nix files. * Bump process and transformers for compat with ghc 8.6 * regenerated nix files; updated iohk-nix Signed-off-by: Alexander Diemand <[email protected]> * pinned logging to new version Signed-off-by: Alexander Diemand <[email protected]> * Update pkgs.nix * Update pkgs.nix * Update pkgs.nix * allow: cabal new-build Signed-off-by: Alexander Diemand <[email protected]> * Update pkgs.nix * bump iohk-nix (and thus haskell.nix) * regenerate * Fix katip on Windows * Set `doExactConfig` on `turtle` on windows as well. * trying cross-compilation Signed-off-by: Alexander Diemand <[email protected]> * rebased; stack2nix applied Signed-off-by: Alexander Diemand <[email protected]> * adapted; but still does not build with 'stack build --nix' Signed-off-by: Alexander Diemand <[email protected]> * Update iohk-nix. Fix nix-shells. * Disable nix-shell purity in stack.yaml To allow stack to pick git for user environnement. (waiting for input-output-hk/haskell.nix#121 for a better fix.
1 parent 4e9651d commit 30829cc

37 files changed

+1067
-192
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

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,6 @@ exchange-topology.yaml
113113
launch_*
114114
result*
115115
cabal.config
116+
117+
# avoid issues when running /nix/regenerate.sh
118+
.stack-to-nix.cache

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

cabal.project

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
packages:
2+
./
13

24
source-repository-package
35
type: git
@@ -11,4 +13,13 @@ source-repository-package
1113
tag: cbe7ab32354f3838dc8c95c64109904c8f503347
1214
subdir: iohk-monitoring
1315

14-
with-compiler: ghc-8.6.4
16+
source-repository-package
17+
type: git
18+
location: https://github.com/input-output-hk/cardano-sl-x509
19+
tag: e8bfc1294e088f90e5ae0b4aedbc82ee46ac5ee4
20+
21+
source-repository-package
22+
type: git
23+
location: https://github.com/input-output-hk/cardano-prelude
24+
tag: 2256fd727c5f92e6218afdcf8cddf6e01c4a9dcd
25+

canonical-json.nix

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

cardano-prelude.nix

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

cardano-shell.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ executable cardano-launcher
159159
, formatting
160160
-- exception handling
161161
, safe-exceptions
162+
, turtle
162163
if os(windows)
163164
build-depends: Win32
164165
else

cardano-shell.nix

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

cardano-sl-x509.nix

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

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: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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.cardano-shell # All `cardano-shell` tests
7+
# - nix build -f default.nix nix-tools.tests.cardano-shell.tests
8+
# - nix build -f default.nix nix-tools.exes.cardano-shell # All `cardano-shell` executables
9+
# - nix build -f default.nix nix-tools.cexes.cardano-shell.cardano-launcher
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 ? {}
45+
, pkgs ? commonLib.getPkgs { inherit config system; }
46+
, ... }@args:
47+
# We will instantiate the default-nix template with the
48+
# nix/pkgs.nix file...
49+
commonLib.nix-tools.default-nix ./nix/pkgs.nix args
50+
# ... and add additional non-haskell packages we want to build on CI:
51+
// {
52+
53+
runCoveralls = pkgs.stdenv.mkDerivation {
54+
name = "run-coveralls";
55+
buildInputs = with pkgs; [ haskellPackages.stack-hpc-coveralls stack ];
56+
shellHook = ''
57+
echo '~~~ stack test'
58+
stack test --coverage
59+
echo '~~~ shc'
60+
shc --repo-token=$COVERALLS_REPO_TOKEN cardano-shell cardano-shell-test
61+
exit
62+
'';
63+
};
64+
}

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.

0 commit comments

Comments
 (0)