Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and modernize nix builds to flake.nix + haskell.nix #29

Merged
merged 14 commits into from
Nov 17, 2023
Merged
46 changes: 46 additions & 0 deletions .github/workflows/nix.yml
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/by-root@v3.1
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/copy-root-aws-credentials@v3.1

- 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
3 changes: 2 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ allow-newer:
source-repository-package
type: git
location: https://github.com/kadena-io/deeproute.git
tag: 856be917bf162a769d9082c26700af4bdbb87d49
tag: 856be917bf162a769d9082c26700af4bdbb87d49
--sha256: sha256-FHLl0gkwr+rtu42XBdVRD9k3bnhYl01GZAE0lz0V8wI=
2 changes: 1 addition & 1 deletion chainweb-mining-client.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ executable chainweb-mining-client
attoparsec >=0.14
, base >=4.10 && <5
, base16-bytestring >=1.0
, aeson >=1.5
, aeson >=1.5 && <2
, async >=2.2
, bytes >=0.17
, bytestring >=0.10
Expand Down
56 changes: 9 additions & 47 deletions default.nix
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
Loading
Loading