-
Notifications
You must be signed in to change notification settings - Fork 0
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
emeinhardt
wants to merge
4
commits into
main
Choose a base branch
from
eric/add-flake
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
22b13a6
Add onix-based flake, associated make task, and .envrc template
emeinhardt b83118d
Add 4.12 Ocaml version to CI config
emeinhardt 3d6fc96
Polish + transition towards nix run over Makefile
emeinhardt d80d1b4
fix: onix-lock-dev works correctly
emeinhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,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 | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,102 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "nixpkgs/nixpkgs-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
|
||
onix = { | ||
url = "github:rizo/onix/3740a2beb84bc21860385f8bbb0d5f557842de03"; | ||
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; | ||
compilerVersion = "5.2.0"; | ||
opamFiles = [ | ||
./imandra-document.opam | ||
]; | ||
onixEnv = onix'.env { | ||
path = ./.; | ||
roots = opamFiles; | ||
lock = ./onix-lock.json; | ||
deps = { | ||
"ocaml-system" = compilerVersion; | ||
}; | ||
}; | ||
onixEnvDev = onix'.env { | ||
path = ./.; | ||
roots = opamFiles; | ||
lock = ./onix-lock-dev.json; | ||
deps = { | ||
"ocaml-system" = compilerVersion; | ||
"ocaml-lsp-server" = "*"; | ||
"utop" = "*"; | ||
}; | ||
}; | ||
onixLock = | ||
let | ||
shellHook = pkgs.writeText "onix-lock-shellHook" onixEnv.lock.shellHook; | ||
lockPatched = pkgs.runCommand "onix-lock-shellHook-patched" { } '' | ||
sed 's:--lock-file=/nix/store/.*/onix-lock.json:--lock-file=./onix-lock.json:' "${shellHook}" > "$out" | ||
chmod +x "$out" | ||
''; | ||
in | ||
pkgs.writeShellApplication { | ||
name = "onix-lock"; | ||
runtimeInputs = [ onix' ]; | ||
text = lockPatched; | ||
}; | ||
onixLockDev = | ||
let | ||
shellHook = pkgs.writeText "onix-lock-dev-shellHook" onixEnvDev.lock.shellHook; | ||
emeinhardt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
lockPatched = pkgs.runCommand "onix-lock-dev-shellHook-patched" { } '' | ||
sed 's:--lock-file=/nix/store/.*/onix-lock-dev.json:--lock-file=./onix-lock-dev.json:' "${shellHook}" > "$out" | ||
chmod +x "$out" | ||
''; | ||
in | ||
pkgs.writeShellApplication { | ||
name = "onix-lock-dev"; | ||
runtimeInputs = [ onix' ]; | ||
text = lockPatched; | ||
}; | ||
in | ||
rec { | ||
formatter = pkgs.nixfmt-rfc-style; | ||
|
||
packages.imandra-document = onixEnv.pkgs.imandra-document; | ||
packages.default = onixEnv.pkgs.imandra-document; | ||
|
||
packages.onix-lock = onixLock; | ||
packages.onix-lock-dev = onixLockDev; | ||
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' | ||
]; | ||
} | ||
); | ||
|
||
# Allows the default devshell to be cached | ||
packages.devShell-default = devShells.default.inputDerivation; | ||
} | ||
); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the
onix
readme, the API might change, so I've pinned the version here.