From c275a13ba47534da137529847fdd93949933a2ed Mon Sep 17 00:00:00 2001 From: frekw Date: Tue, 20 Aug 2024 09:20:42 +0200 Subject: [PATCH] Add nix.flake for easy devshell. --- .envrc | 1 + .gitignore | 4 +- flake.lock | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 132 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 309 insertions(+), 1 deletion(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..3550a30f2 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 32a5a5c0f..80e0054ec 100644 --- a/.gitignore +++ b/.gitignore @@ -186,4 +186,6 @@ Sessionx.vim *~ .*.swp # Auto-generated tag files -tags \ No newline at end of file +tags +# nix flake stuff +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..5a8be6e34 --- /dev/null +++ b/flake.lock @@ -0,0 +1,173 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1724120248, + "narHash": "sha256-Y72+q7ghUvHQvcdEWuFEalo+gkNYguxm+D/BF2YFRVI=", + "owner": "nix-ocaml", + "repo": "nix-overlays", + "rev": "47a8a69b0d0902bad2a77816a9808166148579e6", + "type": "github" + }, + "original": { + "owner": "nix-ocaml", + "repo": "nix-overlays", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1724050343, + "narHash": "sha256-tGRPGJKwczrM7793zaR74KnuYLMHArJvYXmGu8Wo9oI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ed434d7889eddb68002d81bc25212f26ff8f2862", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ed434d7889eddb68002d81bc25212f26ff8f2862", + "type": "github" + } + }, + "ocaml-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1724120248, + "narHash": "sha256-Y72+q7ghUvHQvcdEWuFEalo+gkNYguxm+D/BF2YFRVI=", + "owner": "nix-ocaml", + "repo": "nix-overlays", + "rev": "47a8a69b0d0902bad2a77816a9808166148579e6", + "type": "github" + }, + "original": { + "owner": "nix-ocaml", + "repo": "nix-overlays", + "type": "github" + } + }, + "quickjs": { + "flake": false, + "locked": { + "lastModified": 1721745727, + "narHash": "sha256-stXnv2xedbLeXSFIgypShSB7yzwO+A9x9y7iBk+UEMg=", + "ref": "refs/heads/main", + "rev": "82044fc532211ac6c7df71fbe879baa2481c9509", + "revCount": 78, + "submodules": true, + "type": "git", + "url": "https://github.com/ml-in-barcelona/quickjs.ml.git" + }, + "original": { + "submodules": true, + "type": "git", + "url": "https://github.com/ml-in-barcelona/quickjs.ml.git" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "ocaml-overlay": "ocaml-overlay", + "quickjs": "quickjs", + "server-reason-react": "server-reason-react" + } + }, + "server-reason-react": { + "flake": false, + "locked": { + "lastModified": 1723568686, + "narHash": "sha256-CEZ30VAtCOaspjgVzEyQ9K+GNCyViKTJgmFSJmv8CC0=", + "owner": "ml-in-barcelona", + "repo": "server-reason-react", + "rev": "26affb80e01fffd9557d771f8ef00cedae01d483", + "type": "github" + }, + "original": { + "owner": "ml-in-barcelona", + "repo": "server-reason-react", + "type": "github" + } + }, + "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 000000000..f3e22fcee --- /dev/null +++ b/flake.nix @@ -0,0 +1,132 @@ +{ + description = "styled-ppx"; + + inputs = { + nixpkgs = { + url = "github:nix-ocaml/nix-overlays"; + inputs.flake-utils.follows = "flake-utils"; + }; + + ocaml-overlay = { + url = "github:nix-ocaml/nix-overlays"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + flake-utils = { + url = "github:numtide/flake-utils"; + }; + + quickjs = { + type = "git"; + url = "https://github.com/ml-in-barcelona/quickjs.ml.git"; + submodules = true; + flake = false; + }; + + server-reason-react = { + url = "github:ml-in-barcelona/server-reason-react"; + flake = false; + }; + }; + + outputs = + inputs@{ + self, + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + version = "0.59.2+dev"; + pkgs = nixpkgs.legacyPackages."${system}".extend ( + self: super: { + ocaml = super.ocaml-ng.ocamlPackages_5_1; + ocamlPackages = super.ocaml-ng.ocamlPackages_5_1; + # .overrideScope ( + # oself: osuper: { ppxlib = osuper.ppxlib.override ({ version = "0.32.1"; }); } + # ); + } + ); + inherit (pkgs) ocamlPackages mkShell; + inherit (ocamlPackages) buildDunePackage; + + quickjs = buildDunePackage { + pname = "quickjs"; + version = ""; + propagatedBuildInputs = with ocamlPackages; [ + dune_3 + ocaml + integers + ctypes + ]; + src = inputs.quickjs; + }; + + server-reason-react = buildDunePackage { + pname = "server-reason-react"; + version = ""; + nativeBuildInputs = with ocamlPackages; [ + reason + melange + ]; + propagatedBuildInputs = with ocamlPackages; [ + dune_3 + ocaml + ppxlib + melange + quickjs + lwt + lwt_ppx + integers + uri + ]; + src = inputs.server-reason-react; + }; + in + { + devShells = { + default = mkShell.override { stdenv = pkgs.clang18Stdenv; } { + buildInputs = with ocamlPackages; [ + dune_3 + ocaml + utop + ocamlformat + ]; + inputsFrom = [ self.packages."${system}".default ]; + packages = builtins.attrValues { + inherit (pkgs) clang_18 clang-tools_18 pkg-config; + inherit (ocamlPackages) ocaml-lsp ocamlformat-rpc-lib; + }; + }; + }; + packages = { + default = buildDunePackage { + inherit version; + pname = "styled-ppx"; + nativeBuildInputs = with ocamlPackages; [ ]; + propagatedBuildInputs = with ocamlPackages; [ + alcotest + dune_3 + fmt + melange + menhir + ocaml + ppx_deriving + ppx_deriving_yojson + ppxlib + reason + reason-react + reason-react-ppx + sedlex + server-reason-react + yojson + ]; + src = ./.; + }; + }; + formatter = pkgs.alejandra; + } + ); +}