···11-use flake
11+# shellcheck shell=bash
22+# For use with direnv.
33+# Installing nix-direnv will ensure a smoother experience.
44+use flake
+2-2
dune-project
···2020 (synopsis "A short synopsis")
2121 (description "A longer description")
2222 (depends
2323- ocaml dune stdio nottui lwd base eio_main angstrom ppx_expect ppx_jane
2323+ ocaml dune stdio lwd base eio_main angstrom ppx_expect ppx_jane
2424 lwd
2525 eio-process
2626- notty
2626+27272828 )
2929 (tags
-58
flake-old.nix
···11-{
22- inputs = {
33- opam-nix.url = "github:tweag/opam-nix";
44- flake-utils.url = "github:numtide/flake-utils";
55- nixpkgs.follows = "opam-nix/nixpkgs";
66- };
77- outputs = { self, flake-utils, opam-nix, nixpkgs }@inputs:
88- flake-utils.lib.eachDefaultSystem (system:
99- let
1010- pkgs = nixpkgs.legacyPackages.${system};
1111- on = opam-nix.lib.${system};
1212- localPackagesQuery = builtins.mapAttrs (_: pkgs.lib.last)
1313- (on.listRepo (on.makeOpamRepo ./.));
1414- devPackagesQuery = {
1515- # You can add "development" packages here. They will get added to the devShell automatically.
1616- ocaml-lsp-server = "*";
1717- ocamlformat = "*";
1818- };
1919- query = devPackagesQuery // {
2020- ## You can force versions of certain packages here, e.g:
2121- ## - force the ocaml compiler to be taken from opam-repository:
2222- # ocaml-base-compiler = "5.1.0";
2323- ## - or force the compiler to be taken from nixpkgs and be a certain version:
2424- # ocaml-system = "5.1.0";
2525- ## - or force ocamlfind to be a certain version:
2626- # ocamlfind = "1.9.2";
2727- };
2828- scope = on.buildOpamProject' {
2929-3030- pkgs=pkgs.pkgsStatic;
3131- } ./. query;
3232- overlay = final: prev:
3333- {
3434- # You can add overrides here
3535- };
3636- scope' = scope.overrideScope' overlay;
3737- # Packages from devPackagesQuery
3838- devPackages = builtins.attrValues
3939- (pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope');
4040- # Packages in this workspace
4141- packages =
4242- pkgs.lib.getAttrs (builtins.attrNames localPackagesQuery) scope';
4343- in {
4444- legacyPackages = scope';
4545-4646- # inherit packages;
4747-4848- ## If you want to have a "default" package which will be built with just `nix build`, do this instead of `inherit packages;`:
4949- packages = packages // { default = packages.jj_tui; };
5050-5151- devShells.default = pkgs.mkShell {
5252- inputsFrom = builtins.attrValues packages;
5353- buildInputs = devPackages ++ [
5454- # You can add packages from nixpkgs here
5555- ];
5656- };
5757- });
5858-}
···11{
22- description = "Example JavaScript development environment for Zero to Nix";
33-44- # Flake inputs
52 inputs = {
66-77- nixpkgs.url = "nixpkgs-unstable"; # also valid: "nixpkgs"
33+ opam-repository = {
44+ url = "github:ocaml/opam-repository";
55+ flake = false;
66+ };
77+ nixpkgs-unstable.url = "nixpkgs-unstable";
88+ opam-nix = {
99+ url = "github:tweag/opam-nix";
1010+ inputs.nixpkgs.follows = "nixpkgs-unstable";
1111+ inputs.opam-repository.follows = "opam-repository";
8121313+ };
1414+ flake-utils.url = "github:numtide/flake-utils";
1515+ nixpkgs.follows = "nixpkgs-unstable";
916 };
1010- # Flake outputs
1111- outputs = { self, nixpkgs, flake-parts, ... }@inputs:
1212- flake-parts.lib.mkFlake { inherit inputs; } {
1313- systems =
1414- [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
1515- perSystem = { config, self', inputs', pkgs, system, ... }:
1616- let
1717- jj_tui = pkgs: ocamlPackages: profile:
1717+ outputs =
1818+ { self, flake-utils, opam-nix, nixpkgs, opam-repository, ... }@inputs:
1919+ # Don't forget to put the package name instead of `throw':
2020+ let package = "jj_tui";
2121+ in flake-utils.lib.eachDefaultSystem (system:
2222+ let
2323+ pkgs = nixpkgs.legacyPackages.${system};
2424+ on = opam-nix.lib.${system};
2525+ devPackagesQuery = {
2626+ # You can add "development" packages here. They will get added to the devShell automatically.
2727+ # ocaml-lsp-server = "*";
2828+ # ocamlformat = "*";
2929+ };
3030+ query = devPackagesQuery // {
3131+ ## You can force versions of certain packages here, e.g:
3232+ ## - force the ocaml compiler to be taken from opam-repository:
3333+ # ocaml-base-compiler = "5.1.1";
3434+ ## - or force the compiler to be taken from nixpkgs and be a certain version:
3535+ ocaml-system = "5.1.1";
3636+ ## - or force ocamlfind to be a certain version:
3737+ # ocamlfind = "1.9.2";
3838+ };
3939+ scope = on.buildDuneProject {
4040+ pkgs = pkgs.pkgsStatic;
4141+ } package ./. query;
18421919- let
2020- eio-process = ocamlPackages.buildDunePackage {
2121- pname = "eio-process";
2222- version = "0.1.0";
2323- duneVersion = "3";
2424- src = pkgs.fetchFromGitHub {
4343+ overlay = final: prev: {
4444+ # You can add overrides here
4545+ ${package} = prev.${package}.overrideAttrs (_: {
4646+ env = { DUNE_PROFILE = "static"; };
25472626- owner = "mbarbin";
2727- repo = "eio-process";
2828- rev = "482ba341884dc8711f93ec9cc6d7c941099e0faa";
2929- sha256 =
3030- "sha256-/Y2U+1y+nDMBrRfDAYif0WJp0vPWmvbSMt39wAB/rS8=";
3131- };
4848+ # Prevent the ocaml dependencies from leaking into dependent environments
4949+ doNixSupport = false;
5050+ });
5151+ };
5252+ scope' = scope.overrideScope' overlay;
5353+ # The main package containing the executable
5454+ main = scope'.${package};
5555+ # Packages from devPackagesQuery
5656+ devPackages = builtins.attrValues
5757+ (pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope');
5858+ in {
5959+ legacyPackages = scope';
32603333- buildInputs = with ocamlPackages; [
3434- base
3535- eio
3636- parsexp
3737- ppx_compare
3838- ppx_enumerate
3939- ppx_hash
4040- ppx_here
4141- ppx_let
4242- ppx_sexp_conv
4343- ppx_sexp_value
4444- ];
6161+ packages.default = main;
45624646- strictDeps = true;
4747- };
4848- jj_tui_build_pkgs =
4949-5050- [
5151- eio-process
5252- ocamlPackages.parsexp
5353- ocamlPackages.eio_main
5454- ocamlPackages.stdio
5555- ocamlPackages.base
5656- ocamlPackages.angstrom
5757- ocamlPackages.ppx_expect
5858- ocamlPackages.uutf
5959- # ocamlPackages.parsexp
6060-6161- # Ocaml package dependencies needed to build go here.
6262- ];
6363- jj_tui = let pname = "jj_tui";
6464- in ocamlPackages.buildDunePackage {
6565- pname = pname;
6666- version = "0.1.0";
6767- duneVersion = "3";
6868- src = ./.;
6969-7070- buildInputs = jj_tui_build_pkgs;
7171-7272-7373- buildPhase = ''
7474- runHook preBuild
7575- dune build -p ${pname} --profile ${profile} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
7676- runHook postBuild
7777- '';
7878- checkPhase = ''
7979- runHook preCheck
8080- dune runtest -p ${pname}--profile ${profile} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
8181- runHook postCheck
8282- '';
8383- installPhase = ''
8484- runHook preInstall
8585- dune install --profile ${profile} --prefix $out --libdir $OCAMLFIND_DESTDIR ${pname}
8686- runHook postInstall
8787- '';
8888-8989- };
9090- in {
9191- jj_tui = jj_tui;
9292- jj_tui_build_pkgs = jj_tui_build_pkgs;
9393- };
9494- # OCaml packages available on nixpkgs
9595- inherit (pkgs) ocamlPackages mkShell lib;
9696- inherit (ocamlPackages) buildDunePackage;
9797-9898- in {
9999- packages = {
100100- default = (jj_tui pkgs
101101- ocamlPackages "release").jj_tui; # Development environment output
102102- static = (jj_tui pkgs.pkgsStatic
103103- pkgs.pkgsStatic.ocamlPackages "static").jj_tui; # Development environment output
104104- };
105105- devShells = {
106106- default = mkShell.override { stdenv = pkgs.gccStdenv; } {
107107- buildInputs = with ocamlPackages; [
108108- dune_3
109109- ocaml
110110- utop
111111- ocamlformat
112112- ];
113113- inputsFrom = [ self'.packages.default ];
114114- packages = builtins.attrValues {
115115- inherit (pkgs) gcc pkg-config;
116116- inherit (ocamlPackages) ocaml-lsp ocamlformat-rpc-lib;
117117- };
118118- };
119119- };
120120-6363+ devShells.default = pkgs.mkShell {
6464+ inputsFrom = [ main ];
6565+ buildInputs = devPackages ++ [
6666+ # You can add packages from nixpkgs here
6767+ ];
12168 };
122122- };
6969+ });
12370}
+1-1
jj_tui.opam
···4444x-opam-monorepo-opam-provided: ["lwd"]
4545#This is needed because eio-process doesn't exict
4646pin-depends:[
4747-["eio-process.dev" "git+https://github.com/mbarbin/eio-process"]
4747+["eio-process.dev" "git+https://github.com/mbarbin/eio-process#ac1e965eb33f19fcedc7ce203111bca0c3fc8278"]
4848]
4949
+1-1
jj_tui.opam.template
···22x-opam-monorepo-opam-provided: ["lwd"]
33#This is needed because eio-process doesn't exict
44pin-depends:[
55-["eio-process.dev" "git+https://github.com/mbarbin/eio-process"]
55+["eio-process.dev" "git+https://github.com/mbarbin/eio-process#ac1e965eb33f19fcedc7ce203111bca0c3fc8278"]
66]
77
+1-6
jj_tui/bin/jj_ui.ml
···22open Nottui
33open Lwd_infix
44open Global_funcs
55+open Jj_tui.Util
56module W = Nottui_widgets
6778module Ui = struct
···3738 let _quitButton =
3839 W.button (Printf.sprintf "quit ") (fun () -> Vars.quit $= true) |> Lwd.pure
3940 ;;
4040-4141- let ( <-$ ) f v = Lwd.map ~f (Lwd.get v)
4242- let ( $-> ) v f = Lwd.map ~f (Lwd.get v)
4343- let ( |>$ ) v f = Lwd.map ~f v
4444- let ( >> ) f g x = g (f x)
4545- let ( << ) f g x = f (g x)
46414742 (* let ( let<- ) v f = Lwd.map ~f (Lwd.get v) *)
4843
+1
jj_tui/lib/util.ml
···2929;;
3030 let ( <-$ ) f v = Lwd.map ~f (Lwd.get v)
3131 let ( $-> ) v f = Lwd.map ~f (Lwd.get v)
3232+ let ( let$$ ) v f = Lwd.map ~f (Lwd.get v)
3233 let ( |>$ ) v f = Lwd.map ~f v
3334 let ( >> ) f g x = g (f x)
3435 let ( << ) f g x = f (g x)