From c8c1e8cead808c0d9f12a7fc4fb6b580f70b79b5 Mon Sep 17 00:00:00 2001 From: Daniel Hines Date: Fri, 21 Oct 2022 21:50:58 -0400 Subject: [PATCH] feat: static builds --- .github/workflows/build.yml | 23 +++++++++++++++++++++++ nix/deku-p/default.nix | 11 ++++++++++- nix/deku-p/deku.nix | 16 +++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..566898a636 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: build +on: + push: + branches: + - "main" + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v17 + with: + extra_nix_config: | + system-features = nixos-test benchmark big-parallel kvm + extra-substituters = https://anmonteiro.nix-cache.workers.dev + extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY= + + - name: Build default + run: nix --log-format raw -L build '.#deku' + - name: Build static + run: nix --log-format raw -L build '.#deku-static' diff --git a/nix/deku-p/default.nix b/nix/deku-p/default.nix index 8f00629a27..acc166b4ee 100644 --- a/nix/deku-p/default.nix +++ b/nix/deku-p/default.nix @@ -18,6 +18,8 @@ , ... }: let + pkgs' = pkgs.pkgsCross.musl64; + npmPackages = import ./npm.nix { inherit system dream2nix-lib nodejs; inherit (inputs) nix-filter; @@ -29,13 +31,20 @@ doCheck = true; }; + deku-static = pkgs'.callPackage ./deku.nix { + inherit nodejs npmPackages; + inherit (inputs) nix-filter; + doCheck = true; + static = true; + }; + ligo = inputs.ligo.packages.${system}.ligoLight; docker = pkgs.callPackage ./docker.nix { inherit deku; }; in { - packages = { default = deku; inherit deku docker; }; + packages = { default = deku; inherit deku deku-static; }; apps = { node = { type = "app"; diff --git a/nix/deku-p/deku.nix b/nix/deku-p/deku.nix index 241e1a75e8..36dac8b967 100644 --- a/nix/deku-p/deku.nix +++ b/nix/deku-p/deku.nix @@ -10,12 +10,20 @@ with ocamlPackages; buildDunePackage rec { root = ../..; include = [ "deku.opam" + "dune" "deku-p/src" "dune-project" ]; + exclude = + # TODO: We haven't figured out static linking for libpg_query. Hence, + # right now we can't build the node when building staticaly + if static then [ + "deku-p/src/core/bin/node" + "deku-p/src/core/indexer" + ] else [ ] + ; }; - # This is the same as standard dune build but with static support buildPhase = '' echo NODE_PATH @@ -28,6 +36,12 @@ with ocamlPackages; buildDunePackage rec { nativeBuildInputs = [ nodejs removeReferencesTo ] ++ npmPackages; + checkPhase = '' + runHook preInstall + dune build -p ${pname} --profile=${if static then "static" else "release"} @runtest + runHook postInstall + ''; + propagatedBuildInputs = [ tezos-micheline ppx_deriving