-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from akirak/ocaml
Add OCaml
- Loading branch information
Showing
8 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Check ocaml | ||
|
||
on: | ||
push: | ||
paths: | ||
# Set this to the directory of the template | ||
- ocaml/** | ||
- .github/workflows/check-ocaml.yml | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: cachix/install-nix-action@v25 | ||
with: | ||
extra_nix_config: | | ||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | ||
- uses: actions/checkout@v4 | ||
with: | ||
path: ./tmp | ||
|
||
- name: Initialize a Dune project | ||
run: | | ||
nix run nixpkgs#dune_3 -- init project hello work | ||
- name: Use the template | ||
run: | | ||
nix flake new -t ./tmp#ocaml work | ||
- name: Prepare the project | ||
working-directory: work | ||
run: | | ||
sed -i 's/throw "Name your OCaml package"/"hello"/' flake.nix | ||
sed -i 's/throw "Version your OCaml package"/"0.1"/' flake.nix | ||
git init | ||
git add . | ||
- name: Check executables | ||
run: | | ||
nix develop -L --command ocamlc --version | ||
working-directory: work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use flake | ||
|
||
# Using _build directory may not be properly allowed for storing user contents | ||
export ODIG_CACHE_DIR="$(pwd)/_build/default/.odig" | ||
export SHERLODOC_DB="$(pwd)/_build/default/.sherlodoc.marshal" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Latest version is available from | ||
# https://github.com/ocaml-ppx/ocamlformat/blob/main/.ocamlformat | ||
|
||
profile = ocamlformat | ||
break-cases = fit | ||
margin = 77 | ||
wrap-comments = true | ||
line-endings = lf | ||
|
||
# To make ocaml-ci happy | ||
version = ignore | ||
version-check = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
inputs = { | ||
# nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
systems.url = "github:nix-systems/default"; | ||
|
||
ocaml-overlays.url = "github:nix-ocaml/nix-overlays"; | ||
ocaml-overlays.inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
|
||
outputs = { | ||
self, | ||
systems, | ||
nixpkgs, | ||
ocaml-overlays, | ||
... | ||
} @ inputs: let | ||
inherit (nixpkgs) lib; | ||
|
||
eachSystem = f: | ||
nixpkgs.lib.genAttrs (import systems) ( | ||
system: let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [ocaml-overlays.overlays.default]; | ||
}; | ||
in | ||
f | ||
{ | ||
inherit pkgs system; | ||
ocamlPackages = pkgs.ocaml-ng.ocamlPackages_latest; | ||
} | ||
); | ||
in { | ||
ocamlPackages = eachSystem ({ocamlPackages, ...}: ocamlPackages); | ||
|
||
packages = eachSystem ({ | ||
pkgs, | ||
ocamlPackages, | ||
... | ||
}: { | ||
default = ocamlPackages.buildDunePackage { | ||
pname = throw "Name your OCaml package"; | ||
version = throw "Version your OCaml package"; | ||
duneVersion = "3"; | ||
src = self.outPath; | ||
|
||
# Uncomment if you need the executable of dream_eml during build | ||
# preBuild = '' | ||
# PATH="${ocamlPackages.dream}/bin:$PATH" | ||
# export PATH | ||
# ''; | ||
|
||
buildInputs = with ocamlPackages; [ | ||
ocaml-syntax-shims | ||
]; | ||
|
||
propagatedBuildInputs = with ocamlPackages; [ | ||
# Add OCaml dependencies required for your project | ||
|
||
# Jane Street | ||
base | ||
core | ||
core_unix | ||
|
||
# Some common dependencies | ||
# eio | ||
# eio_main | ||
# yojson | ||
# ppx_yojson_conv | ||
]; | ||
}; | ||
}); | ||
|
||
devShells = eachSystem ({ | ||
pkgs, | ||
ocamlPackages, | ||
... | ||
}: { | ||
default = pkgs.mkShell { | ||
inputsFrom = [self.packages.${pkgs.system}.default]; | ||
buildInputs = | ||
lib.optional pkgs.stdenv.isLinux pkgs.inotify-tools | ||
++ (with ocamlPackages; [ | ||
ocaml-lsp | ||
ocamlformat | ||
ocp-indent | ||
utop | ||
# Needed for generating documentation | ||
opam | ||
odoc | ||
odig | ||
]); | ||
}; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
odig-odoc: | ||
odig odoc | ||
|
||
sherlodoc-index: odig-odoc | ||
find "$(odig cache path)/odoc" -name '*.odocl' \ | ||
| grep -v '__' \ | ||
| xargs sherlodoc index |