Skip to content

Commit

Permalink
Add onix-based flake, associated make task, and .envrc template
Browse files Browse the repository at this point in the history
  • Loading branch information
emeinhardt committed Nov 15, 2024
1 parent dd3a90d commit 22b13a6
Show file tree
Hide file tree
Showing 6 changed files with 1,065 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .envrc.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# rebuild the environment on `nix-direnv-reload` only
nix_direnv_manual_reload

# direnv will consider the environment changed if these files change, and
# nix-direnv will then prompt for the manual reload
watch_file flake.nix flake.lock onix-lock.json onix-lock-dev.json

# use the flake with the `default` devShell:
use flake

# To use another devShell, you can use (e.g. for devShell.other:
# use flake .#other

6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ clean:

watch:
@dune build @all -w

onix-lock:
onix lock ./imandra-document.opam --resolutions="ocaml-system=5.2.0" --lock-file ./onix-lock.json
onix lock ./imandra-document.opam --resolutions="ocaml-system=5.2.0,ocaml-lsp-server" --with-test=true --lock-file ./onix-lock-dev.json
git add onix-lock.json onix-lock-dev.json

97 changes: 97 additions & 0 deletions flake.lock

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

56 changes: 56 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";

onix.url = "github:rizo/onix";
onix.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = { self, nixpkgs, flake-utils, onix }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
onix' = onix.packages.${system}.latest;
opamFiles = [
./imandra-document.opam
];
onixEnv = onix'.env {
path = ./.;
roots = opamFiles;
lock = ./onix-lock.json;
deps = { "ocaml-system" = "*"; };
};
onixEnvDev = onix'.env {
path = ./.;
roots = opamFiles;
lock = ./onix-lock-dev.json;
deps = {
"ocaml-system" = "*";
"ocaml-lsp-server" = "*";
};
};

in rec {
formatter = pkgs.nixfmt-rfc-style;

packages.imandra-document = onixEnv.pkgs.imandra-document;

devShells.onixLock = pkgs.mkShell {
buildInputs = [
onix'
];
};

devShells.default = onixEnvDev.shell.overrideAttrs (final: prev: {
buildInputs = prev.buildInputs ++ [
pkgs.ocamlformat_0_22_4
pkgs.dune_3
pkgs.ocaml
onix'
];
});

packages.dev-shell = devShells.default.inputDerivation;
});
}
Loading

0 comments on commit 22b13a6

Please sign in to comment.