From 4bd0113767d47676564283292ff911d2572caf78 Mon Sep 17 00:00:00 2001
From: metame <michaeljameserwin@gmail.com>
Date: Tue, 27 Feb 2024 06:31:01 -0500
Subject: [PATCH] chore: Add nix flake (#4)

---
 .gitignore |  4 ++++
 flake.lock | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 flake.nix  | 34 +++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+)
 create mode 100644 flake.lock
 create mode 100644 flake.nix

diff --git a/.gitignore b/.gitignore
index e35d885..77bbcd3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,5 @@
 _build
+# nix ignores
+.direnv
+result
+.envrc
\ No newline at end of file
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..3ff75b0
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,63 @@
+{
+  "nodes": {
+    "flake-parts": {
+      "inputs": {
+        "nixpkgs-lib": "nixpkgs-lib"
+      },
+      "locked": {
+        "lastModified": 1706830856,
+        "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=",
+        "owner": "hercules-ci",
+        "repo": "flake-parts",
+        "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f",
+        "type": "github"
+      },
+      "original": {
+        "id": "flake-parts",
+        "type": "indirect"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1708807242,
+        "narHash": "sha256-sRTRkhMD4delO/hPxxi+XwLqPn8BuUq6nnj4JqLwOu0=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "nixpkgs-lib": {
+      "locked": {
+        "dir": "lib",
+        "lastModified": 1706550542,
+        "narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "97b17f32362e475016f942bbdfda4a4a72a8a652",
+        "type": "github"
+      },
+      "original": {
+        "dir": "lib",
+        "owner": "NixOS",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-parts": "flake-parts",
+        "nixpkgs": "nixpkgs"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..452cf15
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,34 @@
+{
+  description = "A pure OCaml library for working with terminals";
+
+  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+
+  outputs = inputs@{ flake-parts, ... }:
+    flake-parts.lib.mkFlake { inherit inputs; } {
+      systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
+      perSystem = { config, self', inputs', pkgs, system, ... }:
+        let
+          inherit (pkgs) ocamlPackages mkShell;
+          inherit (ocamlPackages) buildDunePackage;
+          name = "tty";
+          version = "0.0.2";
+        in
+        {
+          devShells = {
+            default = mkShell {
+	      buildInputs = [ ocamlPackages.utop ];
+              inputsFrom = [ self'.packages.default ];
+            };
+          };
+
+          packages = {
+            default = buildDunePackage {
+              inherit version;
+              pname = name;
+	      propagatedBuildInputs = with ocamlPackages; [ uutf ];
+              src = ./.;
+            };
+	  };
+        };
+    };
+}