-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build / develop environment in Nix
- Loading branch information
Showing
12 changed files
with
5,583 additions
and
1 deletion.
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: test in Nix | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
tests-in-nix: | ||
name: Tests in Nix | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- macos-latest | ||
ocaml-version: | ||
- 4_11 | ||
- 4_12 | ||
- 4_13 | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Nix | ||
uses: cachix/install-nix-action@v15 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-21.11 | ||
extra_nix_config: | | ||
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= | ||
substituters = https://cache.nixos.org/ | ||
max-jobs = auto | ||
cores = 0 | ||
- name: Build | ||
run: | | ||
nix-shell --argstr ocamlVersion ${{ matrix.ocaml-version }} --run "dune build" | ||
- name: Test | ||
run: | | ||
nix-shell --argstr ocamlVersion ${{ matrix.ocaml-version }} --run "dune runtest" | ||
- name: Examples | ||
run: | | ||
nix-shell --argstr ocamlVersion ${{ matrix.ocaml-version }} --run "dune examples" |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: build | ||
name: test | ||
|
||
on: | ||
- push | ||
|
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 |
---|---|---|
|
@@ -7,3 +7,5 @@ lib_test/tests_ | |
*.docdir | ||
.merlin | ||
*.install | ||
|
||
/result |
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,10 @@ | ||
{ pkgs ? import <nixpkgs> {} | ||
, ocamlVersion ? import ./nix/ocamlDefaultVersion.nix | ||
, opam2nix ? | ||
pkgs.callPackage ./nix/opam2nix.nix { | ||
inherit pkgs; | ||
ocamlPackagesOverride = pkgs.ocaml-ng."ocamlPackages_${ocamlVersion}"; | ||
|
||
} }: | ||
|
||
pkgs.callPackage ./nix { inherit ocamlVersion opam2nix; } |
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,36 @@ | ||
{ pkgs, lib, stdenv, ocamlVersion, opam2nix }: | ||
let | ||
inherit (lib) strings; | ||
args = { | ||
inherit (pkgs.ocaml-ng."ocamlPackages_${ocamlVersion}") ocaml; | ||
src = | ||
let ignores = pkgs.lib.strings.fileContents ../.gitignore; | ||
in pkgs.nix-gitignore.gitignoreSourcePure ignores ../.; | ||
}; | ||
|
||
opam-selection = opam2nix.build (args // { | ||
selection = "${./opam-selection_${ocamlVersion}.nix}"; | ||
}); | ||
|
||
localPackages = | ||
let contents = builtins.attrNames (builtins.readDir ../.); | ||
in builtins.filter (strings.hasSuffix ".opam") contents; | ||
|
||
# list of dependencies with "with-test" flag manually | ||
testPackageNames = [ "alcotest" ]; | ||
testPackages = | ||
builtins.map (name: builtins.getAttr name opam-selection) testPackageNames; | ||
|
||
resolve = opam2nix.resolve (args // { | ||
selection = "./nix/opam-selection_${ocamlVersion}.nix"; | ||
}) (localPackages ++ testPackageNames); | ||
|
||
|
||
in (builtins.listToAttrs (builtins.map (fname: | ||
let packageName = strings.removeSuffix ".opam" fname; | ||
in { | ||
name = packageName; | ||
value = builtins.getAttr packageName opam-selection; | ||
}) localPackages)) // { | ||
inherit resolve opam-selection testPackages; | ||
} |
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 @@ | ||
"4_13" |
Oops, something went wrong.