Skip to content

Commit ce08b15

Browse files
committed
Add opinionated template
1 parent 5a67e32 commit ce08b15

File tree

4 files changed

+120
-0
lines changed

4 files changed

+120
-0
lines changed

flake.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@
5757
pkgs.appendOverlays extraOverlays;
5858

5959
overlays.default = import ./overlay nixpkgs;
60+
61+
templates.opinionated = {
62+
description =
63+
"Opinionated setup for ocaml development";
64+
path = ./templates/opinionated;
65+
};
66+
67+
templates.default = self.templates.opinionated;
6068
} // flake-utils.lib.eachDefaultSystem (system:
6169
{
6270
legacyPackages = self.makePkgs { inherit system; };

templates/opinionated/.ocamlformat

Whitespace-only changes.

templates/opinionated/flake.nix

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
nixConfig = {
3+
extra-substituters = "https://ocaml.nix-cache.com";
4+
extra-trusted-public-keys = "ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=";
5+
};
6+
7+
inputs = {
8+
nixpkgs.url = "github:nix-ocaml/nix-overlays";
9+
treefmt-nix.url = "github:numtide/treefmt-nix";
10+
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
11+
nix-filter.url = "github:numtide/nix-filter";
12+
};
13+
14+
outputs = inputs @ { flake-parts, ... }:
15+
flake-parts.lib.mkFlake { inherit inputs; } {
16+
imports = [
17+
inputs.treefmt-nix.flakeModule
18+
];
19+
systems = [ "x86_64-linux" "aarch64-darwin" ];
20+
perSystem =
21+
{ config
22+
, self'
23+
, inputs'
24+
, pkgs
25+
, system
26+
, ...
27+
}: {
28+
treefmt = {
29+
projectRootFile = "flake.nix";
30+
programs = {
31+
alejandra.enable = true;
32+
ocamlformat = {
33+
inherit pkgs;
34+
configFile = ./.ocamlformat;
35+
enable = true;
36+
};
37+
};
38+
};
39+
40+
packages = pkgs.ocamlPackages.callPackage ./nix {
41+
inherit (inputs) nix-filter;
42+
doCheck = true;
43+
};
44+
45+
devShells.default = pkgs.mkShell {
46+
inputsFrom = with self'.packages; [
47+
self'.packages.package
48+
];
49+
50+
packages = with pkgs.ocamlPackages; [
51+
ocaml
52+
dune
53+
54+
ocaml-lsp
55+
56+
ocamlformat
57+
dune-release
58+
odoc
59+
];
60+
};
61+
};
62+
};
63+
}

templates/opinionated/nix/default.nix

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{ pkgs
2+
, stdenv
3+
, lib
4+
, nix-filter
5+
, ocamlPackages
6+
, static ? false
7+
, doCheck
8+
,
9+
}:
10+
with ocamlPackages; rec {
11+
package = buildDunePackage {
12+
pname = "package";
13+
version = "1.0.0";
14+
15+
src = with nix-filter.lib;
16+
filter {
17+
# Root of the project relative to this file
18+
root = ./..;
19+
# If no include is passed, it will include all the paths.
20+
include = [
21+
# Include the "src" path relative to the root.
22+
"src"
23+
"test"
24+
# Include this specific path. The path must be under the root.
25+
../package.opam
26+
../dune-project
27+
];
28+
};
29+
30+
checkInputs = [
31+
# Put test dependencies here
32+
];
33+
34+
propagatedBuildInputs = [
35+
# Put dependencies here
36+
];
37+
38+
buildInputs = [
39+
# Put build-time dependencies here
40+
];
41+
42+
inherit doCheck;
43+
44+
meta = {
45+
description = "Describe your project here";
46+
# license = stdenv.lib.licenses.bsd3;
47+
};
48+
};
49+
}

0 commit comments

Comments
 (0)