diff --git a/.gitignore b/.gitignore index 70449f0..0d737f7 100644 --- a/.gitignore +++ b/.gitignore @@ -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 @@ -8,7 +12,8 @@ .LSOverride # Icon must end with two \r -Icon +Icon + # Thumbnails ._* @@ -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 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..53b312e --- /dev/null +++ b/flake.lock @@ -0,0 +1,207 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "mirage-opam-overlays": { + "flake": false, + "locked": { + "lastModified": 1710922379, + "narHash": "sha256-j4QREQDUf8oHOX7qg6wAOupgsNQoYlufxoPrgagD+pY=", + "owner": "dune-universe", + "repo": "mirage-opam-overlays", + "rev": "797cb363df3ff763c43c8fbec5cd44de2878757e", + "type": "github" + }, + "original": { + "owner": "dune-universe", + "repo": "mirage-opam-overlays", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1730785428, + "narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "opam-nix": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", + "mirage-opam-overlays": "mirage-opam-overlays", + "nixpkgs": "nixpkgs", + "opam-overlays": "opam-overlays", + "opam-repository": "opam-repository", + "opam2json": "opam2json" + }, + "locked": { + "lastModified": 1732617437, + "narHash": "sha256-jj25fziYrES8Ix6HkfSiLzrN6MZjiwlHUxFSIuLRjgE=", + "owner": "tweag", + "repo": "opam-nix", + "rev": "ea8b9cb81fe94e1fc45c6376fcff15f17319c445", + "type": "github" + }, + "original": { + "owner": "tweag", + "repo": "opam-nix", + "type": "github" + } + }, + "opam-overlays": { + "flake": false, + "locked": { + "lastModified": 1726822209, + "narHash": "sha256-bwM18ydNT9fYq91xfn4gmS21q322NYrKwfq0ldG9GYw=", + "owner": "dune-universe", + "repo": "opam-overlays", + "rev": "f2bec38beca4aea9e481f2fd3ee319c519124649", + "type": "github" + }, + "original": { + "owner": "dune-universe", + "repo": "opam-overlays", + "type": "github" + } + }, + "opam-repository": { + "flake": false, + "locked": { + "lastModified": 1733656817, + "narHash": "sha256-ddoiIYY6AhWLUxkgtXhPbB7Du0OcHPyR4iEF/Tm8BsY=", + "owner": "ocaml", + "repo": "opam-repository", + "rev": "211ce1c3d5d6eb57dee3ca21cb1e4a16da41d01f", + "type": "github" + }, + "original": { + "owner": "ocaml", + "repo": "opam-repository", + "type": "github" + } + }, + "opam2json": { + "inputs": { + "nixpkgs": [ + "opam-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1671540003, + "narHash": "sha256-5pXfbUfpVABtKbii6aaI2EdAZTjHJ2QntEf0QD2O5AM=", + "owner": "tweag", + "repo": "opam2json", + "rev": "819d291ea95e271b0e6027679de6abb4d4f7f680", + "type": "github" + }, + "original": { + "owner": "tweag", + "repo": "opam2json", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "opam-nix", + "nixpkgs" + ], + "opam-nix": "opam-nix" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..64325fa --- /dev/null +++ b/flake.nix @@ -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 + ++ [ + ]; + }; + } + ); +}