diff --git a/.github/workflows/ci-nix-aarch64-linux.yaml b/.github/workflows/ci-nix-aarch64-linux.yaml new file mode 100644 index 00000000000..83e7b1fc41d --- /dev/null +++ b/.github/workflows/ci-nix-aarch64-linux.yaml @@ -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 diff --git a/flake.lock b/flake.lock index 9fdbfc80c74..7bae888dd3c 100644 --- a/flake.lock +++ b/flake.lock @@ -933,14 +933,14 @@ "type": "github" } }, - "hackage": { + "hackageNix": { "flake": false, "locked": { - "lastModified": 1708561382, - "narHash": "sha256-IDr2G3komoctjHALk8wGvDKOF39BaqrdEmjvAOsob5I=", + "lastModified": 1709684582, + "narHash": "sha256-+rC8Vpaxdd4Nw2fJIn9wzAnzW5arILly5AkTG6chRAw=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "4b07be837c34475fdde3c9bb9903a850b5692bac", + "rev": "c2ed9aa79252ed67a1fb694b3fffaf7dd7ead6d2", "type": "github" }, "original": { @@ -949,14 +949,14 @@ "type": "github" } }, - "hackageNix": { + "hackageNix_2": { "flake": false, "locked": { - "lastModified": 1709684582, - "narHash": "sha256-+rC8Vpaxdd4Nw2fJIn9wzAnzW5arILly5AkTG6chRAw=", + "lastModified": 1715214831, + "narHash": "sha256-HJdB/AIS0LTs/ko37L8o9Thw3v5UVgEiwrwP6mK0NvY=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "c2ed9aa79252ed67a1fb694b3fffaf7dd7ead6d2", + "rev": "6effcc28a0c73517dfbebc4c2a8fc6f26a6c26a4", "type": "github" }, "original": { @@ -1031,7 +1031,9 @@ "ghc-8.6.5-iohk": "ghc-8.6.5-iohk_2", "ghc98X": "ghc98X_2", "ghc99": "ghc99_2", - "hackage": "hackage", + "hackage": [ + "hackageNix" + ], "hls-1.10": "hls-1.10_2", "hls-2.0": "hls-2.0_2", "hls-2.2": "hls-2.2_2", @@ -1041,7 +1043,9 @@ "hls-2.6": "hls-2.6_2", "hpc-coveralls": "hpc-coveralls_2", "hydra": "hydra_2", - "iserv-proxy": "iserv-proxy_2", + "iserv-proxy": [ + "iserv-proxy" + ], "nix-tools-static": "nix-tools-static_2", "nixpkgs": [ "haskellNix", @@ -1059,15 +1063,16 @@ "stackage": "stackage_2" }, "locked": { - "lastModified": 1708563005, - "narHash": "sha256-RgC6n1kuSDo90Jy1ETlCGL3tr125WeWiDl6z6amEXoQ=", + "lastModified": 1710828274, + "narHash": "sha256-GmCvhqJWBTxP4ohSggGWwvJjMdIY8qP0/RhIIRhbbXI=", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "83acf6dc3fe8b3b9d218df2ee88ac875d1aeb801", + "rev": "9f55274618f3da19ab10b7b966f0d54c29c71c81", "type": "github" }, "original": { "owner": "input-output-hk", + "ref": "angerman/fix-aarch64-musl", "repo": "haskell.nix", "type": "github" } @@ -1537,18 +1542,18 @@ "iserv-proxy_2": { "flake": false, "locked": { - "lastModified": 1691634696, - "narHash": "sha256-MZH2NznKC/gbgBu8NgIibtSUZeJ00HTLJ0PlWKCBHb0=", - "ref": "hkm/remote-iserv", - "rev": "43a979272d9addc29fbffc2e8542c5d96e993d73", - "revCount": 14, - "type": "git", - "url": "https://gitlab.haskell.org/hamishmack/iserv-proxy.git" + "lastModified": 1710581758, + "narHash": "sha256-UNUXGiKLGUv1TuQumV70rfjCJERP4w8KZEDxsMG0RHc=", + "owner": "stable-haskell", + "repo": "iserv-proxy", + "rev": "50ea210590ab0519149bfd163d5ba199be925fb6", + "type": "github" }, "original": { - "ref": "hkm/remote-iserv", - "type": "git", - "url": "https://gitlab.haskell.org/hamishmack/iserv-proxy.git" + "owner": "stable-haskell", + "ref": "iserv-syms", + "repo": "iserv-proxy", + "type": "github" } }, "lint-utils": { @@ -2705,9 +2710,11 @@ "CHaP": "CHaP", "cardano-node": "cardano-node", "flake-parts": "flake-parts", + "hackageNix": "hackageNix_2", "haskellNix": "haskellNix_2", "hls": "hls", "iohk-nix": "iohk-nix", + "iserv-proxy": "iserv-proxy_2", "lint-utils": "lint-utils", "mithril": "mithril", "nix-npm-buildpackage": "nix-npm-buildpackage", @@ -2852,11 +2859,11 @@ "stackage_2": { "flake": false, "locked": { - "lastModified": 1708560571, - "narHash": "sha256-/ZxWtAaoskXxeE79aA/K5PirGFUsqdu2TLRLskDj1js=", + "lastModified": 1708906175, + "narHash": "sha256-KJDF0CO077Jx4GjjPK6pNkx6NkY7p1x5RMPfaIe8nl4=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "e0cb41371d5b1e76cddb4e25d748fdb87c176176", + "rev": "bfa4778050cf69fe50f91d39dcefbb9005d6d0d0", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 05afacd8af7..0cebc2b5884 100644 --- a/flake.nix +++ b/flake.nix @@ -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 = { @@ -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; }; @@ -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: @@ -100,7 +129,11 @@ in rec { - legacyPackages = hsPkgs; + legacyPackages = hsPkgs // { + aarch64 = + hsPkgsArm // + (if pkgs.stdenv.isLinux then (prefixAttrs "docker-" hydraImagesArm) else { }); + }; packages = hydraPackages // diff --git a/nix/hydra/docker.nix b/nix/hydra/docker.nix index a23a3c8fef6..c773e10707a 100644 --- a/nix/hydra/docker.nix +++ b/nix/hydra/docker.nix @@ -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 { diff --git a/nix/hydra/project.nix b/nix/hydra/project.nix index c99c48f056a..2b2e38f0b61 100644 --- a/nix/hydra/project.nix +++ b/nix/hydra/project.nix @@ -54,5 +54,76 @@ pkgs.haskell-nix.project { # For this reason, we try to get away without re-installing lib:ghc for now. reinstallableLibGhc = false; } + { + # This is needed to stop GHC from trying to load libc++.a; I hope we'll + # have a better fix for this eventually. For now this will have to do. + packages.double-conversion.ghcOptions = [ + # stop putting U __gxx_personality_v0 into the library! + "-optcxx-fno-rtti" + "-optcxx-fno-exceptions" + # stop putting U __cxa_guard_release into the library! + "-optcxx-std=gnu++98" + "-optcxx-fno-threadsafe-statics" + ]; + # This is needed to stop failing when `git` can't be found. When + # cross compiling, git does not exist in the target context, and thus can + # not be executed. Template Hsakell does not distinguish between native + # and target. + packages.gitrev.patches = [ + (builtins.toFile "gitrev.patch" '' + diff --git a/src/Development/GitRev.hs b/src/Development/GitRev.hs + index b664692..603ad1b 100644 + --- a/src/Development/GitRev.hs + +++ b/src/Development/GitRev.hs + @@ -62,7 +62,9 @@ runGit :: [String] -> String -> IndexUsed -> Q String + runGit args def useIdx = do + let oops :: SomeException -> IO (ExitCode, String, String) + oops _e = return (ExitFailure 1, def, "") + + none :: SomeException -> IO (Maybe FilePath) + + none _e = return Nothing + - gitFound <- runIO $ isJust <$> findExecutable "git" + + gitFound <- runIO $ isJust <$> findExecutable "git" `catch` none + if gitFound + then do + -- a lot of bookkeeping to record the right dependencies + '') + ]; + } + # This is needed because plutus-tx, force loads the PlutusTx.Plugin, and then + # we fail with + # + # > : error: + # > Plugins require -fno-external-interpreter + # + # during the build. Plugins and cross compilers are still WIP :-/ + + (pkgs.lib.mkIf (pkgs.hostPlatform.isMusl && pkgs.hostPlatform.isAarch64) { + packages.plutus-tx.patches = [ + (builtins.toFile "plutus-tx.patch" '' + From 895a8a4af848ec29f9165fbff585f391d2c3358b Mon Sep 17 00:00:00 2001 + From: Moritz Angermann + Date: Sun, 10 Dec 2023 16:23:24 +0800 + Subject: [PATCH] Update TH.hs + + Just don't force load it. + --- + src/PlutusTx/TH.hs | 1 - + 1 file changed, 1 deletion(-) + + diff --git a/src/PlutusTx/TH.hs b/src/PlutusTx/TH.hs + index 49f26f6585e..02a0f927dd5 100644 + --- a/src/PlutusTx/TH.hs + +++ b/src/PlutusTx/TH.hs + @@ -46,7 +46,6 @@ going to typecheck, and the result is always a 'CompiledCode', so that's also fi + -- | Compile a quoted Haskell expression into a corresponding Plutus Core program. + compileUntyped :: TH.Q TH.Exp -> TH.Q TH.Exp + compileUntyped e = do + - TH.addCorePlugin "PlutusTx.Plugin" + loc <- TH.location + let locStr = TH.pprint loc + -- See note [Typed TH] + '') + ]; + }) ]; }