This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
generated from Nymphium/ocaml-nix-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3718eff
Showing
22 changed files
with
1,111 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 @@ | ||
use nix |
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,32 @@ | ||
*.annot | ||
*.cmo | ||
*.cma | ||
*.cmi | ||
*.a | ||
*.o | ||
*.cmx | ||
*.cmxs | ||
*.cmxa | ||
|
||
# ocamlbuild working directory | ||
_build/ | ||
|
||
# ocamlbuild targets | ||
*.byte | ||
*.native | ||
|
||
# oasis generated files | ||
setup.data | ||
setup.log | ||
|
||
# Merlin configuring file for Vim and Emacs | ||
.merlin | ||
|
||
# Dune generated files | ||
*.install | ||
|
||
# Local OPAM switch | ||
_opam/ | ||
|
||
# nix-build out-link | ||
/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
version=0.20.1 | ||
profile=janestreet | ||
|
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Nymphium | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,17 @@ | ||
OCaml + [Nix](https://nixos.org/manual/nixpkgs/stable/) template | ||
=== | ||
|
||
# Concepts | ||
Setup *reproducable* and *lightweight* OCaml dev environment with [opam2nix](https://github.com/timbertson/opam2nix). | ||
|
||
This template provides OCaml-LSP and ocamlformat for development. | ||
|
||
# Setup & Run | ||
Use [direnv](https://direnv.net/) and `dune exec it-is-test`, or run `nix-shell --run "dune exec it-is-test"` | ||
|
||
# Add Packages | ||
1. add `pkg` to `depends` (or `depexts`) in `test.opam`, | ||
2. add `pkg` to `testPackages` in `nix/default.nix` if it is for test, | ||
3. run `nix-shell default.nix -A resolve`, | ||
4. reload shell. | ||
|
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 @@ | ||
(executable | ||
(name main) | ||
(public_name it-is-test) | ||
(libraries it-is-test.lib)) |
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 @@ | ||
let () = Lib.Main.run () |
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,3 @@ | ||
{ pkgs ? import ./nix/pkgs.nix | ||
, ocamlPackages ? pkgs.callPackage ./nix/ocamlPackages.nix {}}: | ||
pkgs.callPackage ./nix { inherit ocamlPackages; } |
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 @@ | ||
(lang dune 3.0) |
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,11 @@ | ||
opam-version: "2.0" | ||
version: "0.0.0" | ||
depends: [ | ||
"dune" {>= "3.0"} | ||
"ocaml" {< "5.0"} | ||
"lwt" | ||
] | ||
|
||
build: [ | ||
"dune" "build" "@install" "-p" name "-j" jobs | ||
] |
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 @@ | ||
(library | ||
(name lib) | ||
(public_name it-is-test.lib) | ||
(libraries lwt.unix)) |
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,2 @@ | ||
let run () = | ||
Lwt_main.run @@ Lwt_io.print "hello" |
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,28 @@ | ||
{ pkgs, lib, fetchFromGitHub, ocamlPackages }: | ||
let | ||
opam2nix = pkgs.callPackage ./opam2nix.nix { | ||
ocamlPackagesOverride = ocamlPackages; | ||
}; | ||
|
||
src = pkgs.nix-gitignore.gitignoreSource [] ../.; | ||
|
||
localPackages = | ||
let contents = builtins.attrNames (builtins.readDir ../.); | ||
in builtins.filter (lib.strings.hasSuffix ".opam") contents; | ||
|
||
# package names with {with-test} in opam; | ||
# opam2nix does not support the flag at present. | ||
testPackages = [ "ppx_inline_test" ]; | ||
|
||
args = { | ||
ocaml = ocamlPackages.ocaml; | ||
selection = ./opam-selection.nix; | ||
inherit src; | ||
}; | ||
|
||
opam = opam2nix.build args; | ||
resolve = opam2nix.resolve args (localPackages ++ testPackages); | ||
in | ||
{ | ||
inherit opam resolve; | ||
} |
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 @@ | ||
let | ||
sources = import ./sources.nix {}; | ||
in | ||
import sources.niv {} |
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,2 @@ | ||
{ pkgs }: | ||
pkgs.ocaml-ng.ocamlPackages_4_13 |
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,17 @@ | ||
{ pkgs, lib, ocamlformat }: | ||
let | ||
ocamlformat_version = | ||
let | ||
ocamlformat_config = lib.strings.splitString "\n" (builtins.readFile ocamlformat); | ||
re = builtins.match "version\s*=\s*(.*)"; | ||
version_line = lib.lists.findFirst | ||
(l: builtins.isList (re l)) | ||
(throw "no version specified in .ocamlformat") | ||
ocamlformat_config; | ||
version = builtins.elemAt (re version_line) 0; | ||
in | ||
builtins.trace | ||
"detect ocamlformat version: ${version}" | ||
(builtins.replaceStrings ["."] ["_"] version); | ||
in | ||
builtins.getAttr ("ocamlformat_" + ocamlformat_version) pkgs |
Oops, something went wrong.