Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onix-based flake, associated make task, and .envrc template #7

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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