Skip to content

Commit

Permalink
chore: set up CI (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro authored Sep 15, 2023
1 parent 276aef9 commit 443fdff
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Nix Build"
on:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
ocamlVersion: [5_1]
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v21
with:
extra_nix_config: |
extra-substituters = https://anmonteiro.nix-cache.workers.dev
extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=
- name: "Run Nix tests"
run: nix build .#

151 changes: 151 additions & 0 deletions flake.lock

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

60 changes: 60 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
description = "melange-json Nix Flake";

inputs.nix-filter.url = "github:numtide/nix-filter";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs = {
url = "github:nix-ocaml/nix-overlays";
inputs.flake-utils.follows = "flake-utils";
};
inputs.melange-src = {
url = "github:melange-re/melange";
inputs.nix-filter.follows = "nix-filter";
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};

outputs = { self, nixpkgs, flake-utils, nix-filter, melange-src }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages."${system}".appendOverlays [
(self: super: {
ocamlPackages = super.ocaml-ng.ocamlPackages_5_1;
})
melange-src.overlays.default
];
inherit (pkgs) nodejs_latest lib stdenv darwin;

melange-json = with pkgs.ocamlPackages; buildDunePackage {
pname = "melange-json";
version = "dev";

src = ./.;
nativeBuildInputs = with pkgs.ocamlPackages; [ melange ];
propagatedBuildInputs = with pkgs.ocamlPackages; [ melange ];
};

mkShell = { buildInputs ? [ ] }: pkgs.mkShell {
inputsFrom = [ melange-json ];
nativeBuildInputs = with pkgs; [
yarn
nodejs_latest
] ++ (with pkgs.ocamlPackages; [
ocamlformat
merlin
melange-jest
reason
]);
inherit buildInputs;
};
in
rec {
packages.default = melange-json;
devShells = {
default = mkShell { };
release = mkShell {
buildInputs = with pkgs; [ cacert curl ocamlPackages.dune-release git ];
};
};
});
}

0 comments on commit 443fdff

Please sign in to comment.