Skip to content

Commit

Permalink
ci: build a static linux binary (#10485)
Browse files Browse the repository at this point in the history
* ci: build a static linux binary

Signed-off-by: Etienne Millon <me@emillon.org>

* Pass flags

Signed-off-by: Etienne Millon <me@emillon.org>

* simplify overlay

Signed-off-by: Etienne Millon <me@emillon.org>

---------

Signed-off-by: Etienne Millon <me@emillon.org>
  • Loading branch information
emillon committed May 13, 2024
1 parent 36f2046 commit d43d011
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ jobs:
include:
- os: macos-13
name: mac-intel
installable: .#
- os: macos-14
name: mac-arm
installable: .#
- os: ubuntu-22.04
name: linux-intel
installable: .#
- os: ubuntu-22.04
name: linux-intel-static
installable: .#dune-static
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v22
- run: nix build
- run: nix build ${{ installable }}
- uses: actions/upload-artifact@v4
with:
path: result/bin/dune
Expand Down
24 changes: 24 additions & 0 deletions flake.lock

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

25 changes: 25 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
ocaml-overlays = {
url = "github:nix-ocaml/nix-overlays";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs =
{ self
, flake-utils
, nixpkgs
, ocamllsp
, melange
, ocaml-overlays
}:
flake-utils.lib.eachDefaultSystem (system:
let
Expand All @@ -37,6 +43,24 @@
melange.overlays.default
ocamllsp.overlays.default
];
dune-static-overlay = self: super: {
ocamlPackages = super.ocaml-ng.ocamlPackages_4_14.overrideScope (oself: osuper: {
dune_3 = osuper.dune_3.overrideAttrs (a: {
src = ./.;
postPatch = ''
substituteInPlace \
boot/duneboot.ml \
--replace-fail \
'; link_flags' \
'; link_flags; ["-ccopt"; "-static"]'
'';
});
});
};
pkgs-static = nixpkgs.legacyPackages.${system}.appendOverlays [
ocaml-overlays.overlays.default
dune-static-overlay
];

ocamlformat =
let
Expand Down Expand Up @@ -79,6 +103,7 @@
installFlags = [ "PREFIX=${placeholder "out"}" "LIBDIR=$(OCAMLFIND_DESTDIR)" ];
};
dune = default;
dune-static = pkgs-static.pkgsCross.musl64.ocamlPackages.dune;
};

devShells =
Expand Down

0 comments on commit d43d011

Please sign in to comment.