Skip to content

Commit

Permalink
🔧 Add a Nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeta611 committed Dec 8, 2024
1 parent 267f459 commit d264799
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 5 deletions.
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Created by https://www.toptal.com/developers/gitignore/api/ocaml,vim,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=ocaml,vim,macos
# Created by https://www.toptal.com/developers/gitignore/api/ocaml,vim,macos,direnv
# Edit at https://www.toptal.com/developers/gitignore?templates=ocaml,vim,macos,direnv

### direnv ###
.direnv
.envrc

### macOS ###
# General
Expand All @@ -8,7 +12,8 @@
.LSOverride

# Icon must end with two \r
Icon
Icon


# Thumbnails
._*
Expand Down Expand Up @@ -85,5 +90,4 @@ tags
# Persistent undo
[._]*.un~

# End of https://www.toptal.com/developers/gitignore/api/ocaml,vim,macos
n
# End of https://www.toptal.com/developers/gitignore/api/ocaml,vim,macos,direnv
207 changes: 207 additions & 0 deletions flake.lock

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

55 changes: 55 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
inputs = {
opam-nix.url = "github:tweag/opam-nix";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.follows = "opam-nix/nixpkgs";
};
outputs =
{
self,
flake-utils,
opam-nix,
nixpkgs,
}@inputs:
let
package = "react_trace";
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
on = opam-nix.lib.${system};
devPackagesQuery = {
ocaml-lsp-server = "*";
ocamlformat = "*";
utop = "*";
};
query = devPackagesQuery // {
ocaml-base-compiler = "*";
};
scope = on.buildDuneProject { resolveArgs.with-test = true; } package ./. query;
overlay = final: prev: {
${package} = prev.${package}.overrideAttrs (_: {
# Prevent the ocaml dependencies from leaking into dependent environments
doNixSupport = false;
});
};
scope' = scope.overrideScope overlay;
main = scope'.${package};
devPackages = builtins.attrValues (pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope');
in
{
legacyPackages = scope';

packages.default = main;

devShells.default = pkgs.mkShell {
inputsFrom = [ main ];
buildInputs =
devPackages
++ [
];
};
}
);
}

0 comments on commit d264799

Please sign in to comment.