Skip to content
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 nix.flake for easy devshell #507

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,6 @@ Sessionx.vim
*~
.*.swp
# Auto-generated tag files
tags
tags
# nix flake stuff
.direnv
173 changes: 173 additions & 0 deletions flake.lock

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

132 changes: 132 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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;
};
Comment on lines +26 to +29
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server-reason-react depends on quickjs, do we need to annotate both here?

};

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;
}
);
}