-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and modernize nix builds to flake.nix + haskell.nix (#29)
This PR updates the nix build infrastructure to use flakes and haskell.nix through our new `hs-nix-infra` flake and converts default.nix to be a wrapper around the new `flake.nix`. * Add a flake.nix that builds with haskell.nix * Add sha256 to deeproute source-repository-package * Fix compiler-nix-name * Set uppoer bound on aeson Otherwise the build fails with: [ 1 of 16] Compiling JsonRpc ( src/JsonRpc.hs, dist/build/chainweb-mining-client/chainweb-mining-client-tmp/JsonRpc.o, dist/build/chainweb-mining-client/chainweb-mining-client-tmp/JsonRpc.dyn_o ) src/JsonRpc.hs:162:22: error: • Expecting one more argument to ‘A.KeyValue kv’ Expected a constraint, but ‘A.KeyValue kv’ has kind ‘* -> Constraint’ • In the type signature: requestProperties :: A.KeyValue kv => A.ToJSON a => T.Text -> a -> Maybe MsgId -> [kv] | 162 | requestProperties :: A.KeyValue kv => A.ToJSON a => T.Text -> a -> Maybe MsgId -> [kv] | ^^^^^^^^^^^^^ * Convert default.nix as legacy wrapper for flake.nix * Switch to hs-nix-infra for pinning Haskell toolchain * Add Nix build and cache action * Add a recursive output * Build recursive.allDerivations in CI * Update setup-nix-with-cache * Configure Nix with recursive-nix * Switch back to hs-nix-infra/main * Bump hs-nix-infra * Turn default.nix into a function In order to maintain backwards compatibility with old consumers
- Loading branch information
Showing
6 changed files
with
421 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Build and cache with Nix | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- '**' | ||
- '!.github/**' | ||
- '.github/workflows/nix.yml' | ||
|
||
jobs: | ||
build-and-cache: | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 740 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, macos-m1] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Nix with caching | ||
uses: kadena-io/setup-nix-with-cache/[email protected] | ||
with: | ||
cache_url: s3://nixcache.chainweb.com?region=us-east-1 | ||
signing_private_key: ${{ secrets.NIX_CACHE_PRIVATE_KEY }} | ||
additional_experimental_features: recursive-nix | ||
|
||
- name: Set up AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-access-key-id: ${{ secrets.NIX_CACHE_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.NIX_CACHE_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
|
||
- name: Give root user AWS credentials | ||
uses: kadena-io/setup-nix-with-cache/[email protected] | ||
|
||
- name: Build and cache artifacts | ||
run: | | ||
echo Building the project and its devShell | ||
nix build --log-lines 500 --show-trace | ||
echo Build the recursive output | ||
nix build .#recursive.allDerivations --accept-flake-config --log-lines 500 --show-trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,10 @@ | ||
{ compiler ? "ghc8107" | ||
, rev ? "7a94fcdda304d143f9a40006c033d7e190311b54" | ||
, sha256 ? "0d643wp3l77hv2pmg2fi7vyxn4rwy0iyr8djcw1h5x72315ck9ik" | ||
, pkgs ? | ||
import (builtins.fetchTarball { | ||
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz"; | ||
inherit sha256; }) { | ||
config.allowBroken = false; # autodocodec | ||
config.allowUnfree = true; | ||
} | ||
, mkDerivation ? null | ||
{ | ||
... # Maintain backwards compatibility with old consumers | ||
}: | ||
let gitignoreSrc = import (pkgs.fetchFromGitHub { | ||
owner = "hercules-ci"; | ||
repo = "gitignore"; | ||
rev = "9e80c4d83026fa6548bc53b1a6fab8549a6991f6"; | ||
sha256 = "04n9chlpbifgc5pa3zx6ff3rji9am6msrbn1z3x1iinjz2xjfp4p"; | ||
}) {}; | ||
in | ||
pkgs.haskell.packages.${compiler}.developPackage { | ||
name = builtins.baseNameOf ./.; | ||
root = gitignoreSrc.gitignoreSource ./.; | ||
|
||
overrides = self: super: with pkgs.haskell.lib; { | ||
configuration-tools = self.callHackageDirect { | ||
pkg = "configuration-tools"; | ||
ver = "0.6.1"; | ||
sha256 = "0vrml1gj6bb5f6x79m80k9wqn5qvjjzz8c6gf36mqwdqv30irxdv"; | ||
} {}; | ||
|
||
streaming-events = doJailbreak (self.callHackageDirect { | ||
pkg = "streaming-events"; | ||
ver = "1.0.1"; | ||
sha256 = "11v9rrhvlxlq43m5pw63hdfn6n0fkqryphvplild1y920db96wk9"; | ||
} {}); | ||
|
||
autodocodec = markUnbroken super.autodocodec; | ||
validity-aeson = markUnbroken super.validity-aeson; | ||
}; | ||
source-overrides = { | ||
}; | ||
modifier = drv: pkgs.haskell.lib.overrideCabal drv (attrs: { | ||
buildTools = (attrs.buildTools or []) ++ [ | ||
pkgs.haskell.packages.${compiler}.cabal-install | ||
pkgs.haskell.packages.${compiler}.ghcid | ||
]; | ||
}); | ||
} | ||
(import ( | ||
fetchTarball { | ||
url = "https://github.com/edolstra/flake-compat/archive/12c64ca55c1014cdc1b16ed5a804aa8576601ff2.tar.gz"; | ||
sha256 = "0jm6nzb83wa6ai17ly9fzpqc40wg1viib8klq8lby54agpl213w5"; } | ||
) { | ||
src = ./.; | ||
}).defaultNix.packages.${builtins.currentSystem}.default |
Oops, something went wrong.