Skip to content

Commit

Permalink
Fix build of aarch64-linux using cross compilation on x86_64-linux
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed May 10, 2024
1 parent 4791447 commit 052647b
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 63 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci-nix-aarch64-linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "CI (aarch64-linux)"

# Limit concurrent runs of this workflow within a single PR
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on:
push:
branches:
- master
- release
pull_request:
schedule:
# Everyday at 4:00 AM
- cron: "0 4 * * *"

jobs:
build-test:
name: "Build & test"
runs-on: ubuntu-latest
strategy:
matrix:
package:
- hydra-node

steps:
- name: 📥 Checkout repository
uses: actions/checkout@v4

- name: ❄ Prepare nix
uses: cachix/install-nix-action@v26
with:
extra_nix_config: |
accept-flake-config = true
log-lines = 1000
- name: ❄ Cachix cache of nix derivations
uses: cachix/cachix-action@v14
with:
name: cardano-scaling
authToken: '${{ secrets.CACHIX_CARDANO_SCALING_AUTH_TOKEN }}'

- name: ❓Build
run: |
nix build .#legacyPackages.x86_64-linux.aarch64.hydra-node.components.exes.hydra-node
59 changes: 33 additions & 26 deletions flake.lock

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

103 changes: 68 additions & 35 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
{
inputs = {
nixpkgs.follows = "haskellNix/nixpkgs";
haskellNix.url = "github:input-output-hk/haskell.nix";
haskellNix.url = "github:input-output-hk/haskell.nix?ref=angerman/fix-aarch64-musl";
hackageNix = {
url = "github:input-output-hk/hackage.nix";
flake = false;
};
haskellNix.inputs.hackage.follows = "hackageNix";
iserv-proxy = {
url = "github:stable-haskell/iserv-proxy?ref=iserv-syms";
flake = false;
};
haskellNix.inputs.iserv-proxy.follows = "iserv-proxy";
iohk-nix.url = "github:input-output-hk/iohk-nix";
flake-parts.url = "github:hercules-ci/flake-parts";
lint-utils = {
Expand Down Expand Up @@ -43,39 +53,40 @@

# nixpkgs enhanced with haskell.nix and crypto libs as used by iohk

overlays = [
# This overlay contains libsodium and libblst libraries
inputs.iohk-nix.overlays.crypto
# This overlay contains pkg-config mappings via haskell.nix to use the
# crypto libraries above
inputs.iohk-nix.overlays.haskell-nix-crypto
# Keep haskell.nix as the last overlay!
#
# Reason: haskell.nix modules/overlays neds to be last
# https://github.com/input-output-hk/haskell.nix/issues/1954
inputs.haskellNix.overlay
# Custom static libs used for darwin build
(import ./nix/static-libs.nix)
inputs.nix-npm-buildpackage.overlays.default
# Specific versions of tools we require
(final: prev: {
apply-refact = pkgs.haskell-nix.tool compiler "apply-refact" "0.14.0.0";
cabal-fmt = pkgs.haskell-nix.tool compiler "cabal-fmt" "0.1.9";
cabal-install = pkgs.haskell-nix.cabal-install.${compiler};
cabal-plan = pkgs.haskell-nix.tool compiler "cabal-plan" "0.7.3.0";
fourmolu = pkgs.haskell-nix.tool compiler "fourmolu" "0.14.1.0";
haskell-language-server = pkgs.haskell-nix.tool compiler "haskell-language-server" rec {
src = inputs.hls;
cabalProject = builtins.readFile (src + "/cabal.project");
};
hlint = pkgs.haskell-nix.tool compiler "hlint" "3.8";
cardano-cli = inputs.cardano-node.packages.${system}.cardano-cli;
cardano-node = inputs.cardano-node.packages.${system}.cardano-node;
mithril-client-cli = inputs.mithril.packages.${system}.mithril-client-cli;
})
];

pkgs = import nixpkgs {
inherit system;
overlays = [
# This overlay contains libsodium and libblst libraries
inputs.iohk-nix.overlays.crypto
# This overlay contains pkg-config mappings via haskell.nix to use the
# crypto libraries above
inputs.iohk-nix.overlays.haskell-nix-crypto
# Keep haskell.nix as the last overlay!
#
# Reason: haskell.nix modules/overlays neds to be last
# https://github.com/input-output-hk/haskell.nix/issues/1954
inputs.haskellNix.overlay
# Custom static libs used for darwin build
(import ./nix/static-libs.nix)
inputs.nix-npm-buildpackage.overlays.default
# Specific versions of tools we require
(final: prev: {
apply-refact = pkgs.haskell-nix.tool compiler "apply-refact" "0.14.0.0";
cabal-fmt = pkgs.haskell-nix.tool compiler "cabal-fmt" "0.1.9";
cabal-install = pkgs.haskell-nix.cabal-install.${compiler};
cabal-plan = pkgs.haskell-nix.tool compiler "cabal-plan" "0.7.3.0";
fourmolu = pkgs.haskell-nix.tool compiler "fourmolu" "0.14.1.0";
haskell-language-server = pkgs.haskell-nix.tool compiler "haskell-language-server" rec {
src = inputs.hls;
cabalProject = builtins.readFile (src + "/cabal.project");
};
hlint = pkgs.haskell-nix.tool compiler "hlint" "3.8";
cardano-cli = inputs.cardano-node.packages.${system}.cardano-cli;
cardano-node = inputs.cardano-node.packages.${system}.cardano-node;
mithril-client-cli = inputs.mithril.packages.${system}.mithril-client-cli;
})
];
inherit system overlays;
};

inputMap = { "https://intersectmbo.github.io/cardano-haskell-packages" = inputs.CHaP; };
Expand All @@ -85,13 +96,31 @@
compiler-nix-name = compiler;
};

hsPkgsArm = import ./nix/hydra/project.nix {
inherit inputMap;
pkgs = pkgs.pkgsCross.aarch64-multiplatform-musl;
compiler-nix-name = compiler;
};


hydraPackages = import ./nix/hydra/packages.nix {
inherit system pkgs inputs hsPkgs self;
gitRev = self.rev or "dirty";
};

hydraPackagesArm = import ./nix/hydra/packages.nix {
inherit system inputs hsPkgs self;
pkgs = pkgs.pkgsCross.aarch64-multiplatform-musl;
gitRev = self.rev or "dirty";
};

hydraImages = import ./nix/hydra/docker.nix {
inherit hydraPackages system nixpkgs;
inherit hydraPackages system pkgs;
};

hydraImagesArm = import ./nix/hydra/docker.nix {
inherit hydraPackages system;
pkgs = pkgs.pkgsCross.aarch64-multiplatform-musl;
};

prefixAttrs = s: attrs:
Expand All @@ -100,7 +129,11 @@

in
rec {
legacyPackages = hsPkgs;
legacyPackages = hsPkgs // {
aarch64 =
hsPkgsArm //
(if pkgs.stdenv.isLinux then (prefixAttrs "docker-" hydraImagesArm) else { });
};

packages =
hydraPackages //
Expand Down
3 changes: 1 addition & 2 deletions nix/hydra/docker.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

{ hydraPackages # as defined in packages.nix
, system
, nixpkgs
, pkgs
}:
let
pkgs = import nixpkgs { inherit system; };
in
{
hydra-node = pkgs.dockerTools.buildImage {
Expand Down
Loading

0 comments on commit 052647b

Please sign in to comment.