Skip to content

Commit

Permalink
feat: static builds
Browse files Browse the repository at this point in the history
  • Loading branch information
d4hines committed Oct 22, 2022
1 parent 6224c33 commit c8c1e8c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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'
11 changes: 10 additions & 1 deletion nix/deku-p/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
, ...
}:
let
pkgs' = pkgs.pkgsCross.musl64;

npmPackages = import ./npm.nix {
inherit system dream2nix-lib nodejs;
inherit (inputs) nix-filter;
Expand All @@ -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";
Expand Down
16 changes: 15 additions & 1 deletion nix/deku-p/deku.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c8c1e8c

Please sign in to comment.